From 95528e30fe339dc80ff70995e17ed8c2a062db1d Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Fri, 1 Mar 2024 10:56:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=9B=91=E7=90=86=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=8D=95=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SupervisionNoticeController.php | 127 ++++++++++++ .../SupervisionNoticeProblemController.php | 108 ++++++++++ .../SupervisionNoticeLists.php | 84 ++++++++ .../SupervisionNoticeProblemLists.php | 80 ++++++++ .../SupervisionNoticeLogic.php | 188 ++++++++++++++++++ .../SupervisionNoticeProblemLogic.php | 115 +++++++++++ .../SupervisionNoticeProblemValidate.php | 122 ++++++++++++ .../SupervisionNoticeValidate.php | 183 +++++++++++++++++ .../supervision_work/SupervisionNotice.php | 57 ++++++ .../SupervisionNoticeProblem.php | 34 ++++ 10 files changed, 1098 insertions(+) create mode 100644 app/adminapi/controller/supervision_work/SupervisionNoticeController.php create mode 100644 app/adminapi/controller/supervision_work/SupervisionNoticeProblemController.php create mode 100644 app/adminapi/lists/supervision_work/SupervisionNoticeLists.php create mode 100644 app/adminapi/lists/supervision_work/SupervisionNoticeProblemLists.php create mode 100644 app/adminapi/logic/supervision_work/SupervisionNoticeLogic.php create mode 100644 app/adminapi/logic/supervision_work/SupervisionNoticeProblemLogic.php create mode 100644 app/adminapi/validate/supervision_work/SupervisionNoticeProblemValidate.php create mode 100644 app/adminapi/validate/supervision_work/SupervisionNoticeValidate.php create mode 100644 app/common/model/supervision_work/SupervisionNotice.php create mode 100644 app/common/model/supervision_work/SupervisionNoticeProblem.php diff --git a/app/adminapi/controller/supervision_work/SupervisionNoticeController.php b/app/adminapi/controller/supervision_work/SupervisionNoticeController.php new file mode 100644 index 000000000..466731770 --- /dev/null +++ b/app/adminapi/controller/supervision_work/SupervisionNoticeController.php @@ -0,0 +1,127 @@ +dataLists(new SupervisionNoticeLists()); + } + + + /** + * @notes 添加工程监理--监理通知单 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function add() + { + $params = (new SupervisionNoticeValidate())->post()->goCheck('add'); + $result = SupervisionNoticeLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(SupervisionNoticeLogic::getError()); + } + + + /** + * @notes 编辑工程监理--监理通知单 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function edit() + { + $params = (new SupervisionNoticeValidate())->post()->goCheck('edit'); + $result = SupervisionNoticeLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(SupervisionNoticeLogic::getError()); + } + + /** + * @notes 回复工程监理--监理通知单 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function reply() + { + $params = (new SupervisionNoticeValidate())->post()->goCheck('reply'); + $result = SupervisionNoticeLogic::reply($params); + if (true === $result) { + return $this->success('回复成功', [], 1, 1); + } + return $this->fail(SupervisionNoticeLogic::getError()); + } + + + /** + * @notes 删除工程监理--监理通知单 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function delete() + { + $params = (new SupervisionNoticeValidate())->post()->goCheck('delete'); + $result = SupervisionNoticeLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionNoticeLogic::getError()); + } + + + /** + * @notes 获取工程监理--监理通知单详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function detail() + { + $params = (new SupervisionNoticeValidate())->goCheck('detail'); + $result = SupervisionNoticeLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/supervision_work/SupervisionNoticeProblemController.php b/app/adminapi/controller/supervision_work/SupervisionNoticeProblemController.php new file mode 100644 index 000000000..397439c68 --- /dev/null +++ b/app/adminapi/controller/supervision_work/SupervisionNoticeProblemController.php @@ -0,0 +1,108 @@ +dataLists(new SupervisionNoticeProblemLists()); + } + + + /** + * @notes 添加工程监理--监理通知问题 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function add() + { + $params = (new SupervisionNoticeProblemValidate())->post()->goCheck('add'); + $result = SupervisionNoticeProblemLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(SupervisionNoticeProblemLogic::getError()); + } + + + /** + * @notes 编辑工程监理--监理通知问题 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function edit() + { + $params = (new SupervisionNoticeProblemValidate())->post()->goCheck('edit'); + $result = SupervisionNoticeProblemLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(SupervisionNoticeProblemLogic::getError()); + } + + + /** + * @notes 删除工程监理--监理通知问题 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function delete() + { + $params = (new SupervisionNoticeProblemValidate())->post()->goCheck('delete'); + SupervisionNoticeProblemLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取工程监理--监理通知问题详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function detail() + { + $params = (new SupervisionNoticeProblemValidate())->goCheck('detail'); + $result = SupervisionNoticeProblemLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/supervision_work/SupervisionNoticeLists.php b/app/adminapi/lists/supervision_work/SupervisionNoticeLists.php new file mode 100644 index 000000000..bf6cb8d8c --- /dev/null +++ b/app/adminapi/lists/supervision_work/SupervisionNoticeLists.php @@ -0,0 +1,84 @@ + ['project_id'], + '%like%' => ['code', 'notify_user'], + ]; + } + + + /** + * @notes 获取工程监理--监理通知单列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function lists(): array + { + return SupervisionNotice::withoutField('create_user,create_time,update_time,delete_time')->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty(); + $company = SupervisionParticipatingUnits::field('unit_name')->where('id',$data['company_id'])->findOrEmpty(); + $data['project_name'] = $project['project_name']; + $data['company_name'] = $company['unit_name']; + }) + ->toArray(); + } + + + /** + * @notes 获取工程监理--监理通知单数量 + * @return int + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function count(): int + { + return SupervisionNotice::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/supervision_work/SupervisionNoticeProblemLists.php b/app/adminapi/lists/supervision_work/SupervisionNoticeProblemLists.php new file mode 100644 index 000000000..5b1da58d1 --- /dev/null +++ b/app/adminapi/lists/supervision_work/SupervisionNoticeProblemLists.php @@ -0,0 +1,80 @@ + ['notice_id'], + ]; + } + + + /** + * @notes 获取工程监理--监理通知问题列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function lists(): array + { + return SupervisionNoticeProblem::withoutField('create_time,update_time,delete_time')->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $notice = SupervisionNotice::field('code')->where('id',$data['notice_id'])->findOrEmpty(); + $data['code'] = $notice['code']; + }) + ->toArray(); + } + + + /** + * @notes 获取工程监理--监理通知问题数量 + * @return int + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function count(): int + { + return SupervisionNoticeProblem::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/supervision_work/SupervisionNoticeLogic.php b/app/adminapi/logic/supervision_work/SupervisionNoticeLogic.php new file mode 100644 index 000000000..a0aeeff8d --- /dev/null +++ b/app/adminapi/logic/supervision_work/SupervisionNoticeLogic.php @@ -0,0 +1,188 @@ + $params['project_id'], + 'code' => data_unique_code('JLTZD'), + 'reply_date' => !empty($params['reply_date']) ? strtotime($params['reply_date']) : 0, + 'company_id' => $params['company_id'], + 'notify_user' => $params['notify_user'], + 'issue_date' => !empty($params['issue_date']) ? strtotime($params['issue_date']) : 0, + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + 'create_user' => $admin_id, + ]); + if(!empty($params['problem'])){ + foreach($params['problem'] as $v){ + SupervisionNoticeProblem::create([ + 'notice_id' => $res->id, + 'problem_description' => $v['problem_description'], + 'content_description' => $v['content_description'], + 'demand_description' => $v['demand_description'], + ]); + } + } + 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/01 09:20 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + SupervisionNotice::where('id', $params['id'])->update([ + 'project_id' => $params['project_id'], + 'reply_date' => !empty($params['reply_date']) ? strtotime($params['reply_date']) : 0, + 'company_id' => $params['company_id'], + 'notify_user' => $params['notify_user'], + 'issue_date' => !empty($params['issue_date']) ? strtotime($params['issue_date']) : 0, + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + 'update_time' => time(), + ]); + if(!empty($params['problem'])){ + foreach($params['problem'] as $v){ + if(!empty($v['id'])){ + SupervisionNoticeProblem::where('id',$v['id'])->update([ + 'notice_id' => $params['id'], + 'problem_description' => $v['problem_description'], + 'content_description' => $v['content_description'], + 'demand_description' => $v['demand_description'], + ]); + }else{ + SupervisionNoticeProblem::create([ + 'notice_id' => $params['id'], + 'problem_description' => $v['problem_description'], + 'content_description' => $v['content_description'], + 'demand_description' => $v['demand_description'], + ]); + } + } + } + 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/01 09:20 + */ + public static function reply(array $params): bool + { + Db::startTrans(); + try { + SupervisionNotice::where('id', $params['id'])->update([ + 'rectification_reply_time' => !empty($params['rectification_reply_time']) ? strtotime($params['rectification_reply_time']) : 0, + 'rectification_reply_user' => $params['rectification_reply_user'], + 'rectification_reply_opinions' => $params['rectification_reply_opinions'], + 'rectification_reply_annex' => $params['rectification_reply_annex'] ? json_encode($params['rectification_reply_annex']) : null, + ]); + 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/01 09:20 + */ + public static function delete(array $params): bool + { + $problem = SupervisionNoticeProblem::where('notice_id',$params['id'])->findOrEmpty(); + if(!$problem->isEmpty()){ + self::setError('该数据下存在通知问题数据,请先删除通知问题数据'); + return false; + } + return SupervisionNotice::destroy($params['id']); + } + + + /** + * @notes 获取工程监理--监理通知单详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public static function detail($params): array + { + $data = SupervisionNotice::withoutField('update_time,delete_time')->findOrEmpty($params['id']); + $project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty(); + $company = SupervisionParticipatingUnits::field('unit_name')->where('id',$data['company_id'])->findOrEmpty(); + $create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); + $data['project_name'] = $project['project_name']; + $data['company_name'] = $company['unit_name']; + $data['create_user_name'] = $create_user['name']; + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/supervision_work/SupervisionNoticeProblemLogic.php b/app/adminapi/logic/supervision_work/SupervisionNoticeProblemLogic.php new file mode 100644 index 000000000..89cf45712 --- /dev/null +++ b/app/adminapi/logic/supervision_work/SupervisionNoticeProblemLogic.php @@ -0,0 +1,115 @@ + $params['notice_id'], + 'problem_description' => $params['problem_description'], + 'content_description' => $params['content_description'], + 'demand_description' => $params['demand_description'], + ]); + 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/01 09:20 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + SupervisionNoticeProblem::where('id', $params['id'])->update([ + 'notice_id' => $params['notice_id'], + 'problem_description' => $params['problem_description'], + 'content_description' => $params['content_description'], + 'demand_description' => $params['demand_description'], + '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/01 09:20 + */ + public static function delete(array $params): bool + { + return SupervisionNoticeProblem::destroy($params['id']); + } + + + /** + * @notes 获取工程监理--监理通知问题详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public static function detail($params): array + { + $data = SupervisionNoticeProblem::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']); + $notice = SupervisionNotice::field('code')->where('id',$data['notice_id'])->findOrEmpty(); + $data['code'] = $notice['code']; + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/supervision_work/SupervisionNoticeProblemValidate.php b/app/adminapi/validate/supervision_work/SupervisionNoticeProblemValidate.php new file mode 100644 index 000000000..149df1961 --- /dev/null +++ b/app/adminapi/validate/supervision_work/SupervisionNoticeProblemValidate.php @@ -0,0 +1,122 @@ + 'require|checkData', + 'notice_id' => 'require|checkNotice', + 'problem_description' => 'require', + 'content_description' => 'require', + 'demand_description' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'notice_id' => '通知id', + 'problem_description' => '事由描述', + 'content_description' => '内容描述', + 'demand_description' => '要求描述', + ]; + + + /** + * @notes 添加场景 + * @return SupervisionNoticeProblemValidate + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function sceneAdd() + { + return $this->only(['notice_id','problem_description','content_description','demand_description']); + } + + + /** + * @notes 编辑场景 + * @return SupervisionNoticeProblemValidate + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function sceneEdit() + { + return $this->only(['id','notice_id','problem_description','content_description','demand_description']); + } + + + /** + * @notes 删除场景 + * @return SupervisionNoticeProblemValidate + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return SupervisionNoticeProblemValidate + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = SupervisionNoticeProblem::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '数据不存在'; + } + return true; + } + + public function checkNotice($value): bool|string + { + $data = SupervisionNotice::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '监理通知单信息不存在'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/supervision_work/SupervisionNoticeValidate.php b/app/adminapi/validate/supervision_work/SupervisionNoticeValidate.php new file mode 100644 index 000000000..2aa681fad --- /dev/null +++ b/app/adminapi/validate/supervision_work/SupervisionNoticeValidate.php @@ -0,0 +1,183 @@ + 'require|checkData', + 'project_id' => 'require|checkProject', + 'reply_date' => 'require|dateFormat:Y-m-d', + 'company_id' => 'checkCompany', + 'notify_user' => 'require', + 'issue_date' => 'dateFormat:Y-m-d', + 'annex' => 'checkAnnex', + 'rectification_reply_time' => 'require|dateFormat:Y-m-d', + 'rectification_reply_user' => 'require', + 'rectification_reply_opinions' => 'require', + 'rectification_reply_annex' => 'checkAnnex', + 'problem' => 'checkProblem' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'project_id' => '项目id', + 'reply_date' => '要求回复日期', + 'company_id' => '施工单位', + 'notify_user' => '通知人员', + 'issue_date' => '下达日期', + 'rectification_reply_time' => '整改回复时间', + 'rectification_reply_user' => '整改回复人', + 'rectification_reply_opinions' => '整改回复意见', + 'create_user' => '填写人', + + ]; + + + /** + * @notes 添加场景 + * @return SupervisionNoticeValidate + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function sceneAdd() + { + return $this->only(['project_id','reply_date','company_id','notify_user','issue_date','annex','problem']); + } + + + /** + * @notes 编辑场景 + * @return SupervisionNoticeValidate + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function sceneEdit() + { + return $this->only(['id','project_id','reply_date','company_id','notify_user','issue_date','annex','problem']); + } + + /** + * @notes 回复场景 + * @return SupervisionNoticeValidate + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function sceneReply() + { + return $this->only(['id','rectification_reply_time','rectification_reply_user','rectification_reply_opinions','rectification_reply_annex']); + } + + + /** + * @notes 删除场景 + * @return SupervisionNoticeValidate + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return SupervisionNoticeValidate + * @author likeadmin + * @date 2024/03/01 09:20 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = SupervisionNotice::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '数据不存在'; + } + return true; + } + + public function checkProject($value): bool|string + { + $data = SupervisionProject::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '项目信息不存在'; + } + return true; + } + + public function checkCompany($value,$rule,$params): bool|string + { + $data = SupervisionParticipatingUnits::where('id',$value)->where('project_id',$params['project_id'])->findOrEmpty(); + if($data->isEmpty()){ + return '施工单位信息不存在'; + } + return true; + } + + public function checkAnnex($value): bool|string + { + if(!empty($value) && $value != '' && !is_array($value)){ + return '附件格式错误'; + } + return true; + } + + public function checkProblem($value): bool|string + { + if(!isset($value) || $value == '') return true; + if(!is_array($value)) return '监理通知问题数据格式错误'; + foreach($value as $k=>$v){ + if(!empty($v['id'])){ + $data = SupervisionNoticeProblem::where('id',$v['id'])->findOrEmpty(); + if($data->isEmpty()){ + return '监理通知问题列表第'.($k+1).'行数据不存在'; + } + } + if(empty($v['problem_description'])) return '监理通知问题列表第'.($k+1).'行事由描述为空'; + if(empty($v['content_description'])) return '监理通知问题列表第'.($k+1).'行内容描述为空'; + if(empty($v['demand_description'])) return '监理通知问题列表第'.($k+1).'行要求描述为空'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/supervision_work/SupervisionNotice.php b/app/common/model/supervision_work/SupervisionNotice.php new file mode 100644 index 000000000..2822225e8 --- /dev/null +++ b/app/common/model/supervision_work/SupervisionNotice.php @@ -0,0 +1,57 @@ +