dataList(); $params['brandList'] = BrandRepository::getAllAvailableBrands(); $params['deviceCatParentList'] = DeviceCatRepository::getTopParentCats(); // 增加故障数据是否已录入的筛选条件 $params['dataStausMap'] = [ self::STATUS_HAS_DATA => '已录入', self::STATUS_DATA_NULL => '未录入' ]; $params['search_model_count'] = self::SEARCH_MODEL_COUNT; return $this->render('index', $params); } /** * 私有设备列表 */ public function actionPrivateDeviceIndex() { $params = $this->privateDeviceDataList(); $params['brandList'] = BrandRepository::getAllAvailableBrands(); $params['deviceCatParentList'] = DeviceCatRepository::getTopParentCats(); // 增加故障数据是否已录入的筛选条件 $params['dataStausMap'] = [ self::STATUS_HAS_DATA => '已录入', self::STATUS_DATA_NULL => '未录入' ]; $params['search_model_count'] = self::SEARCH_MODEL_COUNT; return $this->render('private-device-index', $params); } /** * 私有设备列表 */ public function actionPrivateDeviceExport() { $params = $this->privateDeviceDataList(); $params['brandList'] = BrandRepository::getAllAvailableBrands(); $params['deviceCatParentList'] = DeviceCatRepository::getTopParentCats(); $params['search_model_count'] = self::SEARCH_MODEL_COUNT; return $this->renderPartial('private-device-export', $params); } /** * 查询价格列表 */ public function actionViewPrice() { $params = $this->dataViewPriceList(); return $this->render('view-price', $params); } protected function dataViewPriceList() { $request = Yii::$app->request; $uuid = $request->get('uuid'); $name = $request->get('name'); $device_name = $request->get('device_name'); /** * 查询过滤处理 */ $get = []; $get['uuid'] = $uuid; $get['name'] = empty($name) ? "" : $name; $get['device_name'] = empty($device_name) ? "" : $device_name; /** * 分页处理 */ $deviceModel = new DeviceModel(); $pageSize = $request->get("pageSize") ? (int)$request->get("pageSize") : 50; $pages = new Pagination(['totalCount' => $deviceModel->getDevicePriceListCountFilter($uuid, $name), 'pageSize' => $pageSize]); $list = $deviceModel->getDevicePrieListFilter($pages->offset, $pages->limit, $uuid, $name); foreach ($list as $key => $item) { $warrantyDays = SysSettingModel::getGuranteeTime().'天'; if (isset($item['device_cat_id'])) { $modelDeviceCat = DeviceCatRepository::selectOne($item['device_cat_id']); $warrantyDaysPlan = WarrantyLevelRule::getWarrantyLevelsByDeviceCatId($modelDeviceCat->parent_id, $modelDeviceCat->id, $item['warranty_level']); if ($warrantyDaysPlan) { $warrantyDays = $warrantyDaysPlan['desc']; } } $list[$key]['warranty_days'] = $warrantyDays; } return [ 'list' => $list, 'pages' => $pages, 'gets' => $get, ]; } protected function dataList() { $request = Yii::$app->request; $device_name = $request->get('device_name'); $device_id = $request->get('device_id'); $cat_pid = $request->get('deviceParentCat'); $cat_id = $request->get('deviceChildCat'); $brand = $request->get('brand'); $device_model = $request->get('device_model'); $data_status = empty($request->get('data_status')) ? 0 : intval($request->get('data_status')); $main_pic = $request->get('main_pic'); /** * 查询过滤处理 */ $get = []; $get['brand_id'] = empty($brand) ? 0 : $brand; $get['cat_pid'] = empty($cat_pid) ? 0 : $cat_pid; $get['cat_id'] = empty($cat_id) ? 0 : $cat_id; $get['device_id'] = empty($device_id) ? "" : $device_id; $get['device_name'] = empty($device_name) ? "" : $device_name; $get['device_model'] = empty($device_model) ? "" : $device_model; $get['data_status'] = $data_status; $get['main_pic'] = $main_pic; $map = array(); if (!empty($brand)) { $map[] = array("=", "b.id", $brand, "I"); } if (!empty($device_id)) { $map[] = array("=", "d.id", (int)$device_id, "I"); } if (!empty($device_name)) { $map[] = array("like", "d.device_name", "'%" . $device_name . "%'", "I"); } if (!empty($device_model)) { //$map[] = array("=","m.model",$device_model,"S"); $map[] = array("like", "m.model", "'%" . $device_model . "%'", "I"); } if (!empty($main_pic)) { if ($main_pic == 1) { $map[] = array(" ", "img.path", 'is not null', "I"); } else if ($main_pic == 2) { $map[] = array(" ", "img.path", 'is null', "I"); } } // if (!empty($cat_id)){ // $map[] = array("=","d.device_cat_id",$cat_id,"I"); // } if ($cat_pid > 0) { if ($cat_id > 0) { // 选择了二级分类则精准查找 $map[] = array("=", "d.device_cat_id", $cat_id, "I"); } else { // 仅选择了一级分类, 则查询一级分类下所有子分类的数据 $deviceCatIdArray = array(); $childrens = DeviceCatRepository::getSubCatsByParentId($cat_pid, 'sort_order ASC', false); //find()->where(['parent_id' => $cat_pid])->orderBy('sort_order ASC')->all(); foreach ($childrens as $child) { $deviceCatIdArray[] = $child->id; } // 父节点 $deviceCatIdArray[] = $cat_pid; $deviceCatIds = '(' . implode(",", $deviceCatIdArray) . ')'; $map[] = array("in", "d.device_cat_id", $deviceCatIds, "I"); // 转换为sql: id IN (1,2,3) } } // 是否有设备维修方案数据 if ($data_status == self::STATUS_HAS_DATA) { $map[] = array(" ", "mdf.device_fault_id", 'is not null', "I"); } elseif ($data_status == self::STATUS_DATA_NULL) { $map[] = array(" ", "mdf.device_fault_id", 'is null', "I"); } /** * 分页处理 */ $deviceModel = new DeviceModel(); $pageSize = $request->get("pageSize") ? (int)$request->get("pageSize") : 50; $pages = new Pagination(['totalCount' => $deviceModel->getDeviceListCountFilter($map), 'pageSize' => $pageSize]); $deviceList = $deviceModel->getDeviceListFilter($pages->offset, $pages->limit, $map); return [ 'deviceList' => $deviceList, 'pages' => $pages, 'gets' => $get, ]; } public function actionExportDa() { $request = Yii::$app->request; $device_name = $request->get('device_name'); $device_id = $request->get('device_id'); $cat_pid = $request->get('cat_pid'); $cat_id = $request->get('cat_id'); $brand = $request->get('brand'); $device_model = $request->get('device_model'); $data_status = empty($request->get('data_status')) ? 0 : intval($request->get('data_status')); /** * 查询过滤处理 */ $get = []; $get['brand_id'] = empty($brand) ? 0 : $brand; $get['cat_pid'] = empty($cat_pid) ? 0 : $cat_pid; $get['cat_id'] = empty($cat_id) ? 0 : $cat_id; $get['device_id'] = empty($device_id) ? "" : $device_id; $get['device_name'] = empty($device_name) ? "" : $device_name; $get['device_model'] = empty($device_model) ? "" : $device_model; $get['data_status'] = $data_status; $map = array(); if (!empty($brand)) { $map[] = array("=", "b.id", $brand, "I"); } if (!empty($device_id)) { $map[] = array("=", "d.id", (int)$device_id, "I"); } if (!empty($device_name)) { $map[] = array("like", "d.device_name", "'%" . $device_name . "%'", "I"); } if (!empty($device_model)) { //$map[] = array("=","m.model",$device_model,"S"); $map[] = array("like", "m.model", "'%" . $device_model . "%'", "I"); } if (!empty($cat_id)) { $map[] = array("=", "d.device_cat_id", $cat_id, "I"); } // 是否有设备维修方案数据 if ($data_status == self::STATUS_HAS_DATA) { $map[] = array(" ", "mdf.device_fault_id", 'is not null', "I"); } elseif ($data_status == self::STATUS_DATA_NULL) { $map[] = array(" ", "mdf.device_fault_id", 'is null', "I"); } /** * 分页处理 */ $deviceModel = new DeviceModel(); $deviceList = $deviceModel->getDeviceListFilter('', '', $map); $params['deviceList'] = $deviceList; /** * 后台操作日志 */ AdminLogs::doExport('设备', count($deviceList)); return $this->renderPartial("exportDa", $params); } /** * 新增界面 */ public function actionCreate() { $params = array(); $params['brandList'] = BrandRepository::getAllAvailableBrands(); return $this->render('create', $params); } public function actionDoAdd() { $req = Yii::$app->request; $cat_id = $req->post('cat_id'); $brand_id = $req->post('brand_id'); //目前品牌没用上 $model_id = $req->post('model_id'); $device_name = trim($req->post('device_name')); $img_path = $req->post('img_path'); $price = $req->post('price'); $deposit_amount = $req->post('deposit_amount'); //根据品牌id 获取品牌名 #$brand = BrandRepository::selectOne(["id"=>$brand_id])->toArray(); #$brand_name = $brand['chinese_name']; //执行写入之前,需要先检查是否存在 $deviceResult = DeviceModel::find()->where(["device_cat_id" => $cat_id, "model_id" => $model_id, "device_name" => $device_name])->asArray()->one(); if (sizeof($deviceResult) == 0) { $device = new DeviceModel(); $device->device_cat_id = $cat_id; $device->model_id = $model_id; $device->sys_user_id = 1; $device->device_name = $device_name; $device->price = $price; $device->deposit_amount = $deposit_amount; $device->desc = ""; $device->created_at = time(); $device->updated_at = time(); $result = $device->insert(); if ($result > 0) { if (!empty($img_path)) { $suffix = substr($img_path, (strripos($img_path, ".") + 1)); $newPath = ImageManager::getDeviceImgPath($cat_id, $suffix); ImageManager::move($img_path, $newPath); $deviceImg = new DeviceImgModel(); $deviceImg->device_id = $device->id; $deviceImg->path = $newPath; $deviceImg->is_cover = 1; $deviceImg->sort_order = 0; $deviceImg->created_at = time(); $deviceImg->updated_at = time(); $deviceImg->insert(); } return $this->renderJson(array("status" => 1, "msg" => "操作成功")); } else { return $this->renderJson(array("status" => 0, "msg" => "操作失败")); } } else { return $this->renderJson(array("status" => 0, "msg" => "此设备已经存在")); } } /** * 修改界面 */ public function actionUpdate() { $req = Yii::$app->request; $id = $req->get('id'); $map = array(); if (!empty($id)) { $map[] = array("=", "d.id", $id, "I"); } $deviceModel = new DeviceModel(); $params = array(); //读取设备信息 $device = $deviceModel->getDeviceInfo($map); if (!empty($device)) { //下面可以用组合sql 查询。。先这样吧。 //取出一条类型 $model = array(); $modelM = ModelModel::findOne(["id" => $device['model_id']]); if ($modelM) { $model = $modelM->toArray(); } if (!empty($model)) { //根据去除的类型,得到品牌id 再结合分类id 读取次分类品牌下面的所有类型 $modelList = ModelModel::find()->where(["brand_id" => $model['brand_id'], "device_cat_id" => $device['device_cat_id']])->asArray()->all(); //根据分类信息,获取完整的分类记录, 用来标记 一级 二级 分类信息 $deviceCatModel = DeviceCatRepository::selectOne($device['device_cat_id']); $catagory = $deviceCatModel->toArray(); //读取一级分类 和 二级分类 $deviceCatParentList = DeviceCatRepository::getTopParentCats(); //find()->select("id,name,parent_id")->where(["parent_id" => 0])->asArray()->all(); $deviceCatChildList = DeviceCatRepository::getSubCatsByParentId($catagory['parent_id']); //find()->select("id,name,parent_id")->where(["parent_id" => $catagory['parent_id']])->asArray()->all(); $params['deviceCatParentList'] = $deviceCatParentList; $params['deviceCatChildList'] = $deviceCatChildList; $params['brand_id'] = $model['brand_id']; $params['catagory'] = $catagory; $params['modelList'] = $modelList; $params['device'] = $device; $params['brandList'] = BrandRepository::getAllAvailableBrands(); // 设备速度列表 $speedList = DeviceModel::getSpeedList(); $params['speedList'] = $speedList; } else { $params['device'] = ""; } } else { $params['device'] = ""; } return $this->render('update', $params); } public function actionDoUpdate() { $req = Yii::$app->request; $device_id = $req->post('device_id'); $cat_id = $req->post('cat_id'); $model_id = $req->post('model_id'); $device_name = $req->post('device_name'); $img_id = $req->post("img_id"); $img_path = $req->post("img_path"); $speed = $req->post('speed'); $price = $req->post('price'); $deposit_amount = $req->post('deposit_amount'); $e = new stdClass(); $e->status = 0; $e->msg = 'fail'; $deviceResult = DeviceModel::find()->where([ "device_cat_id" => $cat_id, "model_id" => $model_id, ])->asArray()->one(); if (sizeof($deviceResult) != 0 && $deviceResult['id'] != $device_id) { $e->msg = "操作失败,已存在的设备"; return $this->renderJson($e); } $deviceModel = DeviceModel::find(); $deviceModel->where(["device_name" => $device_name ]); $deviceModel->andWhere(['<>','id',$device_id]); $sameNameDevice = $deviceModel->one(); if ($sameNameDevice) { $e->msg = "操作失败,已存在相同的设备名称"; return $this->renderJson($e); } $deviceModel = DeviceModel::findOne(["id" => intval($device_id)]); $deviceModel->device_cat_id = $cat_id; $deviceModel->model_id = $model_id; $deviceModel->device_name = $device_name; $deviceModel->price = $price; $deviceModel->deposit_amount = $deposit_amount; $deviceModel->desc = ""; $deviceModel->updated_at = time(); $deviceModel->speed = $speed; $result = $deviceModel->save(); if ($result > 0) { if (!empty($img_path)) { $deviceImg = DeviceImgModel::find()->where(["device_id" => intval($device_id), "is_cover" => 1])->asArray()->one(); if ($deviceImg && !empty($deviceImg['path'])) { // 删除原有图片(不能为空路径) ImageManager::delete($deviceImg['path']); } //补充新的图片数据 $suffix = substr($img_path, (strripos($img_path, ".") + 1)); $newPath = ImageManager::getDeviceImgPath($cat_id, $suffix); ImageManager::move($img_path, $newPath); //有可能添加设备的时候没有上传图片。所以需要判断处理 if (!empty($deviceImg)) { //修改数据 $deviceImgModel = DeviceImgModel::findOne(["id" => intval($deviceImg['id'])]); $deviceImgModel->path = $newPath; $deviceImgModel->updated_at = time(); $deviceImgModel->save(); } else { $deviceImg = new DeviceImgModel(); $deviceImg->device_id = intval($device_id); $deviceImg->path = $newPath; $deviceImg->is_cover = 1; $deviceImg->sort_order = 0; $deviceImg->created_at = time(); $deviceImg->updated_at = time(); $deviceImg->insert(); } } $e->status = 1; $e->msg = "操作成功"; return $this->renderJson($e); } else { $e->msg = "操作失败"; return $this->renderJson($e); } } // 删除 public function actionDoDel() { $req = Yii::$app->request; $id = $req->get('id'); $e = new stdClass(); $e->success = false; $e->msg = 'ERROR'; $deviceModel = DeviceModel::find(); $deviceModel->select(['device.id as id', 'model.id as model_id', 'model.model as model']); $deviceModel->leftJoin("model", "model.id = device.model_id"); $deviceModel->where(['device.id' => $id]); $deviceModel->asArray(); $deviceItem = $deviceModel->one(); if (empty($deviceItem)) { $e->msg = '无设备'; return $this->renderJson($e); } $modelDeviceFaults = ModelsDeviceFaultsModel::findOne([ 'model_id' => $deviceItem['model_id'] ]); if (!empty($modelDeviceFaults)) { $e->msg = '设备还有故障,不可删除'; return $this->renderJson($e); } $userDeviceModel = UserDeviceModel::findOne([ 'device_id' => $id ]); if (!empty($userDeviceModel)) { $e->msg = '该设备已经有用户设备绑定,不可删除'; return $this->renderJson($e); } $result = DeviceModel::deleteAll(['id' => $id]); if ($result) { $e->success = true; $e->msg = '成功删除'; } else { $e->msg = '删除失败'; } return $this->renderJson($e); } // 删除私有设备 public function actionDoPrivateDel() { $req = Yii::$app->request; $id = $req->get('id'); $e = new stdClass(); $e->success = false; $e->msg = 'ERROR'; $deviceModel = PrivateDeviceModel::find()->alias("device"); $deviceModel->where(['device.id' => $id]); $deviceModel->asArray(); $deviceItem = $deviceModel->one(); if (empty($deviceItem)) { $e->msg = '无设备'; return $this->renderJson($e); } $result = PrivateDeviceModel::deleteAll(['id' => $id]); if ($result) { $e->success = true; $e->msg = '成功删除'; } else { $e->msg = '删除失败'; } return $this->renderJson($e); } /** * AJAX * 保存设备图标 */ public function actionAjaxUploadImg() { $req = Yii::$app->request; if (empty($_FILES['device_img']['name'])) { return json_encode([ 'success' => false, ]); } $image = $_FILES['device_img']; // 图片路径数据整理 $tmp = explode('.', $image['name']); $suffix = end($tmp); //$savePath = ImageManager::getBrandLogoPath($suffix); $savePath = ImageManager::getTempImgPath($suffix); ImageManager::add($image["tmp_name"], $savePath); /** * 后台操作日志 */ AdminLogs::doImport('设备图标', 1); return json_encode([ 'success' => true, 'url' => ImageManager::getUrl($savePath), 'path' => $savePath ]); } /** * 导入商品EXCEL表数据 * @return string */ public function actionImportSpeed() { // 防止PHP超时 set_time_limit(0); $rootPath = Yii::getAlias('@webroot') . "/tmp/"; $folder = "device/"; $maxSize = 20 * 1024 * 1024; // 定义允许上传的文件扩展名 $extArr = array('xlsx', 'xls'); // 检查文件是否上传 if (empty($_FILES['file']['name'])) { return json_encode(["code" => 0, "errMsg" => "请选择文件进行上传"]); } // 检查文件大小 $fileSize = $_FILES['file']['size']; if ($fileSize > $maxSize) { return json_encode(["code" => 0, "errMsg" => "文件过大,不能上传大于20M的文件"]); } // 检查扩展名 $fileName = strtolower($_FILES['file']['name']); $tempArr = explode(".", $fileName); $fileExt = array_pop($tempArr); $fileExt = trim($fileExt); $fileExt = strtolower($fileExt); if (in_array($fileExt, $extArr) === false) { return json_encode(["code" => 0, "errMsg" => "上传文件扩展名不允许。\n只允许" . implode(",", $extArr) . "格式。"]); } // 拷贝临时文件到服务器指定目录 $temp_name = $_FILES['file']['tmp_name']; $saveFileName = date("Ymd", time()) . "." . $fileExt; $savePath = $rootPath . $folder . $saveFileName; $result = FileHelper::moveUploadFile($temp_name, $savePath); // 导入处理 if ($result) { return $this->importSpeed($savePath); //return $this->batchImportProducts($savePath); } else { return json_encode(["code" => 0, "errMsg" => "上传文件失败,请稍后重新上传"]); } } /** * 导入设备速度 */ private function importSpeed($excelFilepath) { // 开始执行时间 $startTime = time(); ini_set('memory_limit', '2048M'); // 初始化 $result = new stdClass(); $result->code = 0; $objReader = null; $objPHPExcel = null; $currentSheet = null; try { $objReader = \PHPExcel_IOFactory::createReaderForFile($excelFilepath); $objPHPExcel = $objReader->load($excelFilepath); $objPHPExcel->setActiveSheetIndex(0); $currentSheet = $objPHPExcel->getSheet(0);//载入文件并获取第一个sheet $total_line = $currentSheet->getHighestRow(); $total_column = $currentSheet->getHighestColumn(); } catch (Exception $e) { $result->errMsg = "Excel表格式错误"; return json_encode($result); } $transaction = Yii::$app->db->beginTransaction(); try { // 从第二行开始遍历 for ($row = 2; $row <= $total_line; $row++) { $device_id = trim($currentSheet->getCell('A' . $row)->getValue()); // 货品代号 $speed = trim($currentSheet->getCell('F' . $row)->getValue()); // 商品全称 if (!$device_id || !$speed) { $result->errMsg = "存在空值: row=" . $row; $result->useSeconds = time() - $startTime; return json_encode($result); } $deviceModel = DeviceModel::findOne($device_id); if (!$deviceModel) { //$result->errMsg = "该设备不存在: row=" . $row . '| device_id=' . $device_id; //$result->useSeconds = time() - $startTime; //return json_encode($result); continue; } if (strstr($speed, "高速")) { $deviceModel->speed = 1; } elseif (strstr($speed, "中速")) { $deviceModel->speed = 2; } elseif (strstr($speed, "低速")) { $deviceModel->speed = 3; } else { $deviceModel->speed = 0; } if (!$deviceModel->save()) { throw new ErrorException('保存速度失败!'); } unset($findItemSpu, $itemSpu, $itemSku, $sao); } // 提交事务 $transaction->commit(); } catch (Exception $e) { // 回滚 $transaction->rollBack(); $result->errMsg = "数据库写入失败: " . $e->getMessage(); $result->useSeconds = time() - $startTime; return json_encode($result); } // 成功 $result->code = 1; $result->useSeconds = time() - $startTime; return json_encode($result); } /** 搜索型号 * @return string */ public function actionSearchModel() { $e = new stdClass(); $e->success = false; $e->list = []; $req = Yii::$app->request; $keyword = $req->post('query'); $models = ModelModel::find()->where(['like', "model", $keyword])->limit(self::SEARCH_MODEL_COUNT)->asArray()->all(); $e->list = $models; return $this->renderJson($e); } public function actionDeviceMap() { $badId = Yii::$app->request->get("bid"); $locationFind = BindDeviceApplyModel::find(); $result = $locationFind->alias("bda") ->select("longitude,latitude,a.address") ->leftJoin("address a", "a.id = bda.address_id") ->where("bda.id = " . $badId) ->asArray() ->one(); // 获取经纬度对应的地址 $qqmapResult = QQMapSDK::getMapInfo(QQMapSDK::QQMAP_KEY_TYPE_ENGINEER, $result['latitude'], $result["longitude"], 0); $addressInfo = "--"; if ($qqmapResult) { $qqmapResult = json_decode($qqmapResult, true); $addressInfo = (isset($qqmapResult["result"]["address"]) && !empty($qqmapResult["result"]["address"])) ? $qqmapResult["result"]["address"] : "解析失败"; } $rItems = Distance::convertGCJ02ToBD09($result['longitude'], $result['latitude']); return $this->render("device-map", ["datas" => $rItems, "find_address" => $addressInfo, "write_address" => $result['address']]); } protected function privateDeviceDataList($export = false) { $request = Yii::$app->request; $device_name = $request->get('device_name'); $device_id = $request->get('device_id'); $cat_pid = $request->get('deviceParentCat'); $cat_id = $request->get('deviceChildCat'); $brand = $request->get('brand'); $device_model = $request->get('device_model'); $data_status = empty($request->get('data_status')) ? 0 : intval($request->get('data_status')); /** * 查询过滤处理 */ $get = []; $get['brand_id'] = empty($brand) ? 0 : $brand; $get['cat_pid'] = empty($cat_pid) ? 0 : $cat_pid; $get['cat_id'] = empty($cat_id) ? 0 : $cat_id; $get['device_id'] = empty($device_id) ? "" : $device_id; $get['device_name'] = empty($device_name) ? "" : $device_name; $get['device_model'] = empty($device_model) ? "" : $device_model; $get['data_status'] = $data_status; $map = array(); if (!empty($brand)) { $map[] = array("=", "b.id", $brand, "I"); } if (!empty($device_id)) { $map[] = array("=", "d.id", (int)$device_id, "I"); } if (!empty($device_name)) { $map[] = array("like", "d.device_name", "'%" . $device_name . "%'", "I"); } if (!empty($device_model)) { $map[] = array("like", "m.model", "'%" . $device_model . "%'", "I"); } if ($cat_pid > 0) { if ($cat_id > 0) { // 选择了二级分类则精准查找 $map[] = array("=", "d.device_cat_id", $cat_id, "I"); } else { // 仅选择了一级分类, 则查询一级分类下所有子分类的数据 $deviceCatIdArray = array(); $childrens = DeviceCatRepository::getSubCatsByParentId($cat_pid, 'sort_order ASC', false); //find()->where(['parent_id' => $cat_pid])->orderBy('sort_order ASC')->all(); foreach ($childrens as $child) { $deviceCatIdArray[] = $child->id; } // 父节点 $deviceCatIdArray[] = $cat_pid; $deviceCatIds = '(' . implode(",", $deviceCatIdArray) . ')'; $map[] = array("in", "d.device_cat_id", $deviceCatIds, "I"); // 转换为sql: id IN (1,2,3) } } // 是否有设备维修方案数据 if ($data_status == self::STATUS_HAS_DATA) { $map[] = array(" ", "mdf.device_fault_id", 'is not null', "I"); } elseif ($data_status == self::STATUS_DATA_NULL) { $map[] = array(" ", "mdf.device_fault_id", 'is null', "I"); } /** * 分页处理 */ $deviceModel = new DeviceModel(); if ($export == true) { $pages = []; $deviceList = $deviceModel->getDeviceListFilter("", "", $map); } else { $pageSize = $request->get("pageSize") ? (int)$request->get("pageSize") : 50; $pages = new Pagination(['totalCount' => $deviceModel->getPrivateDeviceListCountFilter($map), 'pageSize' => $pageSize]); $deviceList = $deviceModel->getPrivateDeviceListFilter($pages->offset, $pages->limit, $map); } return [ 'deviceList' => $deviceList, 'pages' => $pages, 'gets' => $get, ]; } }