From 8c908d14ecea1e80d0b8f210036fa0b9d69b550b Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Tue, 5 Mar 2024 10:26:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=A1=B9=E7=9B=AE=E6=9C=88?= =?UTF-8?q?=E6=8A=A5=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ervisionProjectMonthlyReportController.php | 108 ++++++++++++ .../SupervisionProjectMonthlyReportLists.php | 83 +++++++++ .../SupervisionProjectMonthlyReportLogic.php | 154 +++++++++++++++++ ...upervisionProjectMonthlyReportValidate.php | 161 ++++++++++++++++++ .../SupervisionProjectMonthlyReport.php | 47 +++++ 5 files changed, 553 insertions(+) create mode 100644 app/adminapi/controller/supervision_connect/SupervisionProjectMonthlyReportController.php create mode 100644 app/adminapi/lists/supervision_connect/SupervisionProjectMonthlyReportLists.php create mode 100644 app/adminapi/logic/supervision_connect/SupervisionProjectMonthlyReportLogic.php create mode 100644 app/adminapi/validate/supervision_connect/SupervisionProjectMonthlyReportValidate.php create mode 100644 app/common/model/supervision_connect/SupervisionProjectMonthlyReport.php diff --git a/app/adminapi/controller/supervision_connect/SupervisionProjectMonthlyReportController.php b/app/adminapi/controller/supervision_connect/SupervisionProjectMonthlyReportController.php new file mode 100644 index 000000000..9e4993141 --- /dev/null +++ b/app/adminapi/controller/supervision_connect/SupervisionProjectMonthlyReportController.php @@ -0,0 +1,108 @@ +dataLists(new SupervisionProjectMonthlyReportLists()); + } + + + /** + * @notes 添加工程监理--项目月报 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/05 09:41 + */ + public function add() + { + $params = (new SupervisionProjectMonthlyReportValidate())->post()->goCheck('add'); + $result = SupervisionProjectMonthlyReportLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(SupervisionProjectMonthlyReportLogic::getError()); + } + + + /** + * @notes 编辑工程监理--项目月报 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/05 09:41 + */ + public function edit() + { + $params = (new SupervisionProjectMonthlyReportValidate())->post()->goCheck('edit'); + $result = SupervisionProjectMonthlyReportLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(SupervisionProjectMonthlyReportLogic::getError()); + } + + + /** + * @notes 删除工程监理--项目月报 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/05 09:41 + */ + public function delete() + { + $params = (new SupervisionProjectMonthlyReportValidate())->post()->goCheck('delete'); + SupervisionProjectMonthlyReportLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取工程监理--项目月报详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/05 09:41 + */ + public function detail() + { + $params = (new SupervisionProjectMonthlyReportValidate())->goCheck('detail'); + $result = SupervisionProjectMonthlyReportLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/supervision_connect/SupervisionProjectMonthlyReportLists.php b/app/adminapi/lists/supervision_connect/SupervisionProjectMonthlyReportLists.php new file mode 100644 index 000000000..7de1af2a9 --- /dev/null +++ b/app/adminapi/lists/supervision_connect/SupervisionProjectMonthlyReportLists.php @@ -0,0 +1,83 @@ + ['project_id', 'date', 'engineering_status'], + ]; + } + + + /** + * @notes 获取工程监理--项目月报列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/03/05 09:41 + */ + public function lists(): array + { + return SupervisionProjectMonthlyReport::withoutField('update_time,delete_time')->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $project = SupervisionProject::field('project_name,project_manager,implementation_department')->where('id',$data['project_id'])->findOrEmpty(); + $data['project_name'] = $project['project_name']; + $data['project_manager'] = $project['project_manager']; + $data['implementation_department'] = $project['implementation_department']; + $data['engineering_status_text'] = $data->engineering_status_text; + }) + ->toArray(); + } + + + /** + * @notes 获取工程监理--项目月报数量 + * @return int + * @author likeadmin + * @date 2024/03/05 09:41 + */ + public function count(): int + { + return SupervisionProjectMonthlyReport::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/supervision_connect/SupervisionProjectMonthlyReportLogic.php b/app/adminapi/logic/supervision_connect/SupervisionProjectMonthlyReportLogic.php new file mode 100644 index 000000000..356f96824 --- /dev/null +++ b/app/adminapi/logic/supervision_connect/SupervisionProjectMonthlyReportLogic.php @@ -0,0 +1,154 @@ + $params['project_id'], + 'date' => !empty($params['date']) ? strtotime($params['date']) : 0, + 'last_month_planned_progress' => $params['last_month_planned_progress'], + 'next_month_planned_progress' => $params['next_month_planned_progress'], + 'this_month_progress' => $params['this_month_progress'], + 'engineering_status' => $params['engineering_status'], + 'progress_description' => $params['progress_description'], + 'problems_and_measure' => $params['problems_and_measure'], + 'this_month_amount' => $params['this_month_amount'], + 'total_amount' => $params['total_amount'], + 'this_month_pay' => $params['this_month_pay'], + 'total_pay' => $params['total_pay'], + 'quality_behavior' => $params['quality_behavior'], + 'quality_situation' => $params['quality_situation'], + 'quality_hazards' => $params['quality_hazards'], + 'sampling_situation' => $params['sampling_situation'], + 'other_quality_conditions' => $params['other_quality_conditions'], + 'safety_situation' => $params['safety_situation'], + 'remark' => $params['remark'], + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + 'create_user' => $admin_id + ]); + 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/05 09:41 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + SupervisionProjectMonthlyReport::where('id', $params['id'])->update([ + 'project_id' => $params['project_id'], + 'date' => !empty($params['date']) ? strtotime($params['date']) : 0, + 'last_month_planned_progress' => $params['last_month_planned_progress'], + 'next_month_planned_progress' => $params['next_month_planned_progress'], + 'this_month_progress' => $params['this_month_progress'], + 'engineering_status' => $params['engineering_status'], + 'progress_description' => $params['progress_description'], + 'problems_and_measure' => $params['problems_and_measure'], + 'this_month_amount' => $params['this_month_amount'], + 'total_amount' => $params['total_amount'], + 'this_month_pay' => $params['this_month_pay'], + 'total_pay' => $params['total_pay'], + 'quality_behavior' => $params['quality_behavior'], + 'quality_situation' => $params['quality_situation'], + 'quality_hazards' => $params['quality_hazards'], + 'sampling_situation' => $params['sampling_situation'], + 'other_quality_conditions' => $params['other_quality_conditions'], + 'safety_situation' => $params['safety_situation'], + '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/05 09:41 + */ + public static function delete(array $params): bool + { + return SupervisionProjectMonthlyReport::destroy($params['id']); + } + + + /** + * @notes 获取工程监理--项目月报详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/03/05 09:41 + */ + public static function detail($params): array + { + $data = SupervisionProjectMonthlyReport::withoutField('update_time,delete_time')->findOrEmpty($params['id']); + $project = SupervisionProject::field('project_name,project_manager,implementation_department')->where('id',$data['project_id'])->findOrEmpty(); + $create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); + $data['project_name'] = $project['project_name']; + $data['project_manager'] = $project['project_manager']; + $data['implementation_department'] = $project['implementation_department']; + $data['create_user_name'] = $create_user['name']; + $data['engineering_status_text'] = $data->engineering_status_text; + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/supervision_connect/SupervisionProjectMonthlyReportValidate.php b/app/adminapi/validate/supervision_connect/SupervisionProjectMonthlyReportValidate.php new file mode 100644 index 000000000..70184da03 --- /dev/null +++ b/app/adminapi/validate/supervision_connect/SupervisionProjectMonthlyReportValidate.php @@ -0,0 +1,161 @@ + 'require|checkData', + 'project_id' => 'require|checkProject', + 'date' => 'require|dateFormat:Y-m', + 'last_month_planned_progress' => 'require|float', + 'next_month_planned_progress' => 'require|float', + 'this_month_progress' => 'require|float', + 'engineering_status' => 'require|checkEngineeringStatus', + 'this_month_amount' => 'require|float', + 'total_amount' => 'require|float', + 'this_month_pay' => 'require|float', + 'total_pay' => 'require|float', + 'annex' => 'checkAnnex' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'project_id' => '项目id', + 'date' => '年月', + 'last_month_planned_progress' => '上月计划工程进度(%)', + 'next_month_planned_progress' => '下月计划工程进度(%)', + 'this_month_progress' => '本月累计工程进度(%)', + 'engineering_status' => '工程状态', + 'progress_description' => '进度描述', + 'problems_and_measure' => '存在的问题及解决措施', + 'this_month_amount' => '本月完成(万元)', + 'total_amount' => '累计完成(万元)', + 'this_month_pay' => '本月支付(万元)', + 'total_pay' => '累计支付(万元)', + 'quality_behavior' => '建设各方责任主体质量行为', + 'quality_situation' => '施工现场质量情况', + 'quality_hazards' => '质量缺陷或质量隐患的处理情况', + 'sampling_situation' => '检查及抽检情况', + 'other_quality_conditions' => '其他质量情况', + 'safety_situation' => '本月安全情况', + 'remark' => '备注', + 'create_user' => '创建人', + ]; + + + /** + * @notes 添加场景 + * @return SupervisionProjectMonthlyReportValidate + * @author likeadmin + * @date 2024/03/05 09:41 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return SupervisionProjectMonthlyReportValidate + * @author likeadmin + * @date 2024/03/05 09:41 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return SupervisionProjectMonthlyReportValidate + * @author likeadmin + * @date 2024/03/05 09:41 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return SupervisionProjectMonthlyReportValidate + * @author likeadmin + * @date 2024/03/05 09:41 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = SupervisionProjectMonthlyReport::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 checkEngineeringStatus($value): bool|string + { + $dict = DictData::where('type_value','engineering_status')->column('value'); + if(!in_array($value,$dict)){ + 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_connect/SupervisionProjectMonthlyReport.php b/app/common/model/supervision_connect/SupervisionProjectMonthlyReport.php new file mode 100644 index 000000000..0b86f37f9 --- /dev/null +++ b/app/common/model/supervision_connect/SupervisionProjectMonthlyReport.php @@ -0,0 +1,47 @@ +column('name','value'); + return !empty($data['engineering_status']) ? $dict[$data['engineering_status']] : ''; + } +} \ No newline at end of file