|
@@ -5,17 +5,20 @@
|
|
|
* @Author: likang
|
|
|
* @Date: 2022-05-27 13:34:31
|
|
|
* @LastEditors: likang
|
|
|
- * @LastEditTime: 2022-07-09 14:43:53
|
|
|
+ * @LastEditTime: 2022-07-18 17:05:10
|
|
|
*/
|
|
|
|
|
|
namespace catchAdmin\wind\model;
|
|
|
|
|
|
use catchAdmin\api\Listen;
|
|
|
+use catchAdmin\hydraulic\model\DeviceMold as ModelDeviceMold;
|
|
|
use catcher\base\CatchModel as Model;
|
|
|
use think\facade\Db;
|
|
|
use catchAdmin\wind\model\get\FanGet;
|
|
|
use catchAdmin\wind\model\search\FanSearch;
|
|
|
use catchAdmin\permissions\model\DataRangScopeTrait;
|
|
|
+use catchAdmin\system\controller\Developer;
|
|
|
+use DeviceMold;
|
|
|
|
|
|
class Fan extends Model
|
|
|
{
|
|
@@ -82,13 +85,79 @@ class Fan extends Model
|
|
|
|
|
|
$data = null;
|
|
|
$content = null;
|
|
|
+
|
|
|
$data = [
|
|
|
'id' => intval($obj->id),
|
|
|
'wnum' => Wind::where('id', $obj->wind_id)->value('number'),
|
|
|
'number' => intval($this->number),
|
|
|
+
|
|
|
];
|
|
|
$content['data'] = $data;
|
|
|
$content['type'] = 'Fan';
|
|
|
return $content;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Descripttion: 风机的id
|
|
|
+ * @name: likang
|
|
|
+ * @param {*} $wind_num
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ public function IssuedFanModel($wind_id)
|
|
|
+ {
|
|
|
+
|
|
|
+ //获取风场编号
|
|
|
+ //分组查询当前风场所有的风机模型
|
|
|
+ $array = [];
|
|
|
+ //差集
|
|
|
+ $diff_array = [];
|
|
|
+ $content = [];
|
|
|
+ $diff_array1 = [];
|
|
|
+ $fan_model = $this->where('wind_id', $wind_id)->group('fan_model')->column('fan_model');
|
|
|
+
|
|
|
+ //获取风机名称
|
|
|
+ $wind_num = Wind::where('id', $wind_id)->value('number');
|
|
|
+ $wheres[] = ['device_type', '=', 4];
|
|
|
+ $wheres[] = ['id', 'in', $fan_model];
|
|
|
+ $model_name = ModelDeviceMold::where($wheres)->column('name');
|
|
|
+ $where[] = ['ContentType', '=', 'FanModel'];
|
|
|
+ $where[] = ['ContentId', 'like', '%' . $wind_num . '_%'];
|
|
|
+ $where[] = ['Type', '=', 'add'];
|
|
|
+ //获取当前风场下发的风机模型
|
|
|
+ $list = Db::name('publish')->where($where)->field('ContentId')->select();
|
|
|
+ //截取ContentId 获取模型名称
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $array[] = substr(strstr($item['ContentId'], '_'), 1);
|
|
|
+ }
|
|
|
+ $diff_array = array_diff($array, $model_name);
|
|
|
+ foreach ($diff_array as $item) {
|
|
|
+ Db::name('publish')->where('ContentType', 'FanModel')->where("ContentId", $wind_num . '_' . $item)->update(
|
|
|
+ [
|
|
|
+ "Type" => 'delete',
|
|
|
+ 'Version' => msectime()
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $diff_array1 = array_diff($model_name, $array);
|
|
|
+ foreach ($diff_array1 as $item) {
|
|
|
+ $time = msectime();
|
|
|
+ $json = json_encode([
|
|
|
+ 'id' => $wind_num . '_' . $item,
|
|
|
+ 'wunm' => $wind_num,
|
|
|
+ 'model' => $item
|
|
|
+ ]);
|
|
|
+ $content[] = [
|
|
|
+ 'Type' => 'add',
|
|
|
+ 'ContentType' => 'FanModel',
|
|
|
+ 'Version' => $time,
|
|
|
+ 'ContentId' => $wind_num . '_' . $item,
|
|
|
+ 'Content' => $json,
|
|
|
+ 'AddTime' => $time,
|
|
|
+ 'Status' => 1
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ Db::name('publish')->insertAll($content);
|
|
|
+
|
|
|
+ //风机 模型id
|
|
|
+ }
|
|
|
}
|