diff --git a/app/adminapi/controller/supervision_dangerous/SupervisionDangerousEngineeringCaseController.php b/app/adminapi/controller/supervision_dangerous/SupervisionDangerousEngineeringCaseController.php new file mode 100644 index 000000000..8fb253295 --- /dev/null +++ b/app/adminapi/controller/supervision_dangerous/SupervisionDangerousEngineeringCaseController.php @@ -0,0 +1,108 @@ +dataLists(new SupervisionDangerousEngineeringCaseLists()); + } + + + /** + * @notes 添加工程监理--危大方案提交列表 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public function add() + { + $params = (new SupervisionDangerousEngineeringCaseValidate())->post()->goCheck('add'); + $result = SupervisionDangerousEngineeringCaseLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(SupervisionDangerousEngineeringCaseLogic::getError()); + } + + + /** + * @notes 编辑工程监理--危大方案提交列表 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public function edit() + { + $params = (new SupervisionDangerousEngineeringCaseValidate())->post()->goCheck('edit'); + $result = SupervisionDangerousEngineeringCaseLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(SupervisionDangerousEngineeringCaseLogic::getError()); + } + + + /** + * @notes 删除工程监理--危大方案提交列表 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public function delete() + { + $params = (new SupervisionDangerousEngineeringCaseValidate())->post()->goCheck('delete'); + SupervisionDangerousEngineeringCaseLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取工程监理--危大方案提交列表详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public function detail() + { + $params = (new SupervisionDangerousEngineeringCaseValidate())->goCheck('detail'); + $result = SupervisionDangerousEngineeringCaseLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/supervision_dangerous/SupervisionDangerousEngineeringCaseLists.php b/app/adminapi/lists/supervision_dangerous/SupervisionDangerousEngineeringCaseLists.php new file mode 100644 index 000000000..8f89e99f0 --- /dev/null +++ b/app/adminapi/lists/supervision_dangerous/SupervisionDangerousEngineeringCaseLists.php @@ -0,0 +1,86 @@ + ['dangerous_engineering_monitoring_id'], + '%like%' => ['case_name', 'assessor'], + ]; + } + + + /** + * @notes 获取工程监理--危大方案提交列表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public function lists(): array + { + return SupervisionDangerousEngineeringCase::where($this->searchWhere) + ->field(['id', 'dangerous_engineering_monitoring_id', 'case_name', 'assessor']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $dangerous_engineering_monitoring = SupervisionDangerousEngineeringMonitoring::field('project_id,type,partial_project')->where('id',$data['dangerous_engineering_monitoring_id'])->findOrEmpty(); + $project = SupervisionProject::field('project_name')->where('id',$dangerous_engineering_monitoring['project_id'])->findOrEmpty(); + $data['dangerous_engineering_monitoring_title'] = $project['project_name']; + $data['project_name'] = $project['project_name']; + $data['partial_project'] = $dangerous_engineering_monitoring->partial_project_text; + }) + ->toArray(); + } + + + /** + * @notes 获取工程监理--危大方案提交列表数量 + * @return int + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public function count(): int + { + return SupervisionDangerousEngineeringCase::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/supervision_dangerous/SupervisionDangerousEngineeringCaseLogic.php b/app/adminapi/logic/supervision_dangerous/SupervisionDangerousEngineeringCaseLogic.php new file mode 100644 index 000000000..ca9ac0e7d --- /dev/null +++ b/app/adminapi/logic/supervision_dangerous/SupervisionDangerousEngineeringCaseLogic.php @@ -0,0 +1,136 @@ +findOrEmpty(); + if($dangerous_engineering_monitoring['status'] != 0){ + self::setError('当前危大工程监控信息已提交方案'); + return false; + } + Db::startTrans(); + try { + SupervisionDangerousEngineeringCase::create([ + 'dangerous_engineering_monitoring_id' => $params['dangerous_engineering_monitoring_id'], + 'case_name' => $params['case_name'], + 'assessor' => $params['assessor'], + 'review_content' => $params['review_content'], + 'remark' => $params['remark'], + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + 'create_user' => $admin_id + ]); + SupervisionDangerousEngineeringMonitoring::where('id',$params['dangerous_engineering_monitoring_id'])->update([ + 'status' => 1, + 'update_time' => time() + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑工程监理--危大方案提交列表 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + SupervisionDangerousEngineeringCase::where('id', $params['id'])->update([ + 'case_name' => $params['case_name'], + 'assessor' => $params['assessor'], + 'review_content' => $params['review_content'], + 'remark' => $params['remark'], + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + 'update_time' => time() + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除工程监理--危大方案提交列表 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public static function delete(array $params): bool + { + return SupervisionDangerousEngineeringCase::destroy($params['id']); + } + + + /** + * @notes 获取工程监理--危大方案提交列表详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public static function detail($params): array + { + $data = SupervisionDangerousEngineeringCase::withoutField('update_time,delete_time')->findOrEmpty($params['id']); + $dangerous_engineering_monitoring = SupervisionDangerousEngineeringMonitoring::field('project_id,type,partial_project')->where('id',$data['dangerous_engineering_monitoring_id'])->findOrEmpty(); + $project = SupervisionProject::field('project_name')->where('id',$dangerous_engineering_monitoring['project_id'])->findOrEmpty(); + $create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); + $data['dangerous_engineering_monitoring_title'] = $project['project_name']; + $data['project_name'] = $project['project_name']; + $data['type'] = $dangerous_engineering_monitoring->type_text; + $data['partial_project'] = $dangerous_engineering_monitoring->partial_project_text; + $data['create_user_name'] = $create_user['name']; + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/supervision_dangerous/SupervisionDangerousEngineeringCaseValidate.php b/app/adminapi/validate/supervision_dangerous/SupervisionDangerousEngineeringCaseValidate.php new file mode 100644 index 000000000..5e49543f6 --- /dev/null +++ b/app/adminapi/validate/supervision_dangerous/SupervisionDangerousEngineeringCaseValidate.php @@ -0,0 +1,131 @@ + 'require|checkData', + 'dangerous_engineering_monitoring_id' => 'require|checkDangerousEngineeringMonitoring', + 'case_name' => 'require', + 'assessor' => 'require', + 'review_content' => 'require', + 'annex' => 'checkAnnex' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'dangerous_engineering_monitoring_id' => '危大工程监控id', + 'case_name' => '方案名称', + 'assessor' => '评审人员', + 'review_content' => '评审内容', + 'remark' => '备注', + 'create_user' => '提交人', + ]; + + + /** + * @notes 添加场景 + * @return SupervisionDangerousEngineeringCaseValidate + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return SupervisionDangerousEngineeringCaseValidate + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return SupervisionDangerousEngineeringCaseValidate + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return SupervisionDangerousEngineeringCaseValidate + * @author likeadmin + * @date 2024/03/04 14:00 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = SupervisionDangerousEngineeringCase::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '数据不存在'; + } + return true; + } + + public function checkDangerousEngineeringMonitoring($value): bool|string + { + $data = SupervisionDangerousEngineeringMonitoring::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '危大工程监控信息不存在'; + } + return true; + } + + public function checkAnnex($value): bool|string + { + if(!empty($value) && $value != '' && !is_array($value)){ + return '附件格式错误'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/supervision_dangerous/SupervisionDangerousEngineeringCase.php b/app/common/model/supervision_dangerous/SupervisionDangerousEngineeringCase.php new file mode 100644 index 000000000..47fe99511 --- /dev/null +++ b/app/common/model/supervision_dangerous/SupervisionDangerousEngineeringCase.php @@ -0,0 +1,36 @@ +