From abcf31cb5108d6aa87b56d568caea7861db85c4c Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Wed, 28 Feb 2024 11:19:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=97=AE=E9=A2=98=E5=8F=B0?= =?UTF-8?q?=E8=B4=A6=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SupervisionAcceptController.php | 18 +- .../SupervisionInspectionController.php | 2 +- .../SupervisionProblemController.php | 124 ++++++++++++++ .../SupervisionSideStationController.php | 2 +- .../SupervisionAcceptLists.php | 3 + .../SupervisionInspectionLists.php | 3 + .../SupervisionProblemLists.php | 84 ++++++++++ .../SupervisionSideStationLists.php | 3 + .../SupervisionAcceptLogic.php | 58 +++++-- .../SupervisionInspectionLogic.php | 23 ++- .../SupervisionProblemLogic.php | 150 +++++++++++++++++ .../SupervisionSideStationLogic.php | 23 ++- .../SupervisionAcceptValidate.php | 24 ++- .../SupervisionInspectionValidate.php | 11 +- .../SupervisionProblemValidate.php | 154 ++++++++++++++++++ .../SupervisionSideStationValidate.php | 11 +- .../supervision_work/SupervisionProblem.php | 67 ++++++++ 17 files changed, 716 insertions(+), 44 deletions(-) create mode 100644 app/adminapi/controller/supervision_work/SupervisionProblemController.php create mode 100644 app/adminapi/lists/supervision_work/SupervisionProblemLists.php create mode 100644 app/adminapi/logic/supervision_work/SupervisionProblemLogic.php create mode 100644 app/adminapi/validate/supervision_work/SupervisionProblemValidate.php create mode 100644 app/common/model/supervision_work/SupervisionProblem.php diff --git a/app/adminapi/controller/supervision_work/SupervisionAcceptController.php b/app/adminapi/controller/supervision_work/SupervisionAcceptController.php index 57724d683..585e4a168 100644 --- a/app/adminapi/controller/supervision_work/SupervisionAcceptController.php +++ b/app/adminapi/controller/supervision_work/SupervisionAcceptController.php @@ -69,12 +69,28 @@ class SupervisionAcceptController extends BaseAdminController public function edit() { $params = (new SupervisionAcceptValidate())->post()->goCheck('edit'); - $result = SupervisionAcceptLogic::edit($params); + $result = SupervisionAcceptLogic::edit($params,$this->adminId); if (true === $result) { return $this->success('编辑成功', [], 1, 1); } return $this->fail(SupervisionAcceptLogic::getError()); } + + /** + * @notes 编辑工程监理--验收登记 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/27 15:23 + */ + public function accept() + { + $params = (new SupervisionAcceptValidate())->post()->goCheck('accept'); + $result = SupervisionAcceptLogic::accept($params); + if (true === $result) { + return $this->success('操作成功', [], 1, 1); + } + return $this->fail(SupervisionAcceptLogic::getError()); + } /** diff --git a/app/adminapi/controller/supervision_work/SupervisionInspectionController.php b/app/adminapi/controller/supervision_work/SupervisionInspectionController.php index 15fd38a0f..5be03ec11 100644 --- a/app/adminapi/controller/supervision_work/SupervisionInspectionController.php +++ b/app/adminapi/controller/supervision_work/SupervisionInspectionController.php @@ -69,7 +69,7 @@ class SupervisionInspectionController extends BaseAdminController public function edit() { $params = (new SupervisionInspectionValidate())->post()->goCheck('edit'); - $result = SupervisionInspectionLogic::edit($params); + $result = SupervisionInspectionLogic::edit($params,$this->adminId); if (true === $result) { return $this->success('编辑成功', [], 1, 1); } diff --git a/app/adminapi/controller/supervision_work/SupervisionProblemController.php b/app/adminapi/controller/supervision_work/SupervisionProblemController.php new file mode 100644 index 000000000..507639f28 --- /dev/null +++ b/app/adminapi/controller/supervision_work/SupervisionProblemController.php @@ -0,0 +1,124 @@ +dataLists(new SupervisionProblemLists()); + } + + + /** + * @notes 添加问题跟踪台账 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function add() + { + $params = (new SupervisionProblemValidate())->post()->goCheck('add'); + $result = SupervisionProblemLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(SupervisionProblemLogic::getError()); + } + + + /** + * @notes 编辑问题跟踪台账 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function edit() + { + $params = (new SupervisionProblemValidate())->post()->goCheck('edit'); + $result = SupervisionProblemLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(SupervisionProblemLogic::getError()); + } + + /** + * @notes 检查验收问题跟踪台账 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function check() + { + $params = (new SupervisionProblemValidate())->post()->goCheck('check'); + $result = SupervisionProblemLogic::check($params); + if (true === $result) { + return $this->success('检查验收成功', [], 1, 1); + } + return $this->fail(SupervisionProblemLogic::getError()); + } + + + /** + * @notes 删除问题跟踪台账 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function delete() + { + $params = (new SupervisionProblemValidate())->post()->goCheck('delete'); + SupervisionProblemLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取问题跟踪台账详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function detail() + { + $params = (new SupervisionProblemValidate())->goCheck('detail'); + $result = SupervisionProblemLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/supervision_work/SupervisionSideStationController.php b/app/adminapi/controller/supervision_work/SupervisionSideStationController.php index 7fbb8a188..8412c8511 100644 --- a/app/adminapi/controller/supervision_work/SupervisionSideStationController.php +++ b/app/adminapi/controller/supervision_work/SupervisionSideStationController.php @@ -69,7 +69,7 @@ class SupervisionSideStationController extends BaseAdminController public function edit() { $params = (new SupervisionSideStationValidate())->post()->goCheck('edit'); - $result = SupervisionSideStationLogic::edit($params); + $result = SupervisionSideStationLogic::edit($params,$this->adminId); if (true === $result) { return $this->success('编辑成功', [], 1, 1); } diff --git a/app/adminapi/lists/supervision_work/SupervisionAcceptLists.php b/app/adminapi/lists/supervision_work/SupervisionAcceptLists.php index d7df735b8..73d3d2fa3 100644 --- a/app/adminapi/lists/supervision_work/SupervisionAcceptLists.php +++ b/app/adminapi/lists/supervision_work/SupervisionAcceptLists.php @@ -22,6 +22,7 @@ use app\common\model\supervision_project\SupervisionProject; use app\common\model\supervision_work\SupervisionAccept; use app\common\lists\ListsSearchInterface; use app\common\model\supervision_work\SupervisionCheckItem; +use app\common\model\supervision_work\SupervisionProblem; /** @@ -75,6 +76,8 @@ class SupervisionAcceptLists extends BaseAdminDataLists implements ListsSearchIn $data['create_user_name'] = $create_user['name']; $data['accept_type_text'] = $data->accept_type_text; $data['accept_result_text'] = $data->accept_result_text; + $data['problem_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',3)->count(); + $data['reply_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',3)->where('is_rectification',1)->count(); }) ->toArray(); } diff --git a/app/adminapi/lists/supervision_work/SupervisionInspectionLists.php b/app/adminapi/lists/supervision_work/SupervisionInspectionLists.php index 9913fbaaf..5310bf395 100644 --- a/app/adminapi/lists/supervision_work/SupervisionInspectionLists.php +++ b/app/adminapi/lists/supervision_work/SupervisionInspectionLists.php @@ -22,6 +22,7 @@ use app\common\model\supervision_project\SupervisionProject; use app\common\model\supervision_work\SupervisionCheckItem; use app\common\model\supervision_work\SupervisionInspection; use app\common\lists\ListsSearchInterface; +use app\common\model\supervision_work\SupervisionProblem; /** @@ -75,6 +76,8 @@ class SupervisionInspectionLists extends BaseAdminDataLists implements ListsSear $data['create_user_name'] = $create_user['name']; $data['inspection_type_text'] = $data->inspection_type_text; $data['is_important_text'] = $data->is_important_text; + $data['problem_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',1)->count(); + $data['reply_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',1)->where('is_rectification',1)->count(); }) ->toArray(); } diff --git a/app/adminapi/lists/supervision_work/SupervisionProblemLists.php b/app/adminapi/lists/supervision_work/SupervisionProblemLists.php new file mode 100644 index 000000000..7af5725ea --- /dev/null +++ b/app/adminapi/lists/supervision_work/SupervisionProblemLists.php @@ -0,0 +1,84 @@ + ['data_id', 'data_type', 'problem_cate'], + '%like%' => ['problem_description', 'problem_name'], + ]; + } + + + /** + * @notes 获取问题跟踪台账列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function lists(): array + { + return SupervisionProblem::withoutField('update_time,delete_time')->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); + $data['create_user_name'] = $create_user['name']; + $data['problem_cate_text'] = $data->problem_cate_text; + $data['rectification_result_text'] = $data->rectification_result_text; + $data['is_rectification_text'] = $data->is_rectification_text; + }) + ->toArray(); + } + + + /** + * @notes 获取问题跟踪台账数量 + * @return int + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function count(): int + { + return SupervisionProblem::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/supervision_work/SupervisionSideStationLists.php b/app/adminapi/lists/supervision_work/SupervisionSideStationLists.php index 14f17f07c..41a2eb8f3 100644 --- a/app/adminapi/lists/supervision_work/SupervisionSideStationLists.php +++ b/app/adminapi/lists/supervision_work/SupervisionSideStationLists.php @@ -20,6 +20,7 @@ use app\common\model\auth\Admin; use app\common\model\supervision_project\SupervisionParticipatingUnits; use app\common\model\supervision_project\SupervisionProject; use app\common\model\supervision_work\SupervisionCheckItem; +use app\common\model\supervision_work\SupervisionProblem; use app\common\model\supervision_work\SupervisionSideStation; use app\common\lists\ListsSearchInterface; @@ -75,6 +76,8 @@ class SupervisionSideStationLists extends BaseAdminDataLists implements ListsSea $data['create_user_name'] = $create_user['name']; $data['side_station_type_text'] = $data->side_station_type_text; $data['side_station_result_text'] = $data->side_station_result_text; + $data['problem_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',2)->count(); + $data['reply_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',2)->where('is_rectification',1)->count(); }) ->toArray(); } diff --git a/app/adminapi/logic/supervision_work/SupervisionAcceptLogic.php b/app/adminapi/logic/supervision_work/SupervisionAcceptLogic.php index 89f0dbcc9..9ae2570ca 100644 --- a/app/adminapi/logic/supervision_work/SupervisionAcceptLogic.php +++ b/app/adminapi/logic/supervision_work/SupervisionAcceptLogic.php @@ -20,9 +20,9 @@ use app\common\model\supervision_project\SupervisionParticipatingUnits; use app\common\model\supervision_project\SupervisionProject; use app\common\model\supervision_work\SupervisionAccept; use app\common\logic\BaseLogic; -use app\common\model\supervision_work\SupervisionAcceptProblem; use app\common\model\supervision_work\SupervisionAcceptResult; use app\common\model\supervision_work\SupervisionCheckItem; +use app\common\model\supervision_work\SupervisionProblem; use think\facade\Db; @@ -75,11 +75,13 @@ class SupervisionAcceptLogic extends BaseLogic } if(!empty($params['accept_check_problem'])){ foreach($params['accept_check_problem'] as $v){ - SupervisionAcceptProblem::create([ - 'accept_id' => $res->id, + SupervisionProblem::create([ + 'data_id' => $res->id, + 'data_type' => 3, 'problem_cate' => $v['problem_cate'], 'problem_description' => $v['problem_description'], 'problem_name' => $v['problem_name'], + 'create_user' => $admin_id, ]); } } @@ -100,7 +102,7 @@ class SupervisionAcceptLogic extends BaseLogic * @author likeadmin * @date 2024/02/27 15:23 */ - public static function edit(array $params): bool + public static function edit(array $params,$admin_id): bool { Db::startTrans(); try { @@ -145,19 +147,22 @@ class SupervisionAcceptLogic extends BaseLogic if(!empty($params['accept_check_problem'])){ foreach($params['accept_check_problem'] as $v){ if(!empty($v['id'])){ - SupervisionAcceptProblem::where('id',$v['id'])->update([ - 'accept_id' => $params['id'], + SupervisionProblem::where('id',$v['id'])->update([ + 'data_id' => $params['id'], + 'data_type' => 3, 'problem_cate' => $v['problem_cate'], 'problem_description' => $v['problem_description'], 'problem_name' => $v['problem_name'], 'update_time' => time(), ]); }else{ - SupervisionAcceptProblem::create([ - 'accept_id' => $params['id'], + SupervisionProblem::create([ + 'data_id' => $params['id'], + 'data_type' => 3, 'problem_cate' => $v['problem_cate'], 'problem_description' => $v['problem_description'], - 'problem_name' => $v['problem_name'] + 'problem_name' => $v['problem_name'], + 'create_user' => $admin_id, ]); } } @@ -170,9 +175,36 @@ class SupervisionAcceptLogic extends BaseLogic return false; } } - - - /** + + /** + * @notes 编辑工程监理--验收登记 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/02/27 15:23 + */ + public static function accept(array $params): bool + { + Db::startTrans(); + try { + SupervisionAccept::where('id', $params['id'])->update([ + 'accept_time' => !empty($params['accept_time']) ? strtotime($params['accept_time']) : 0, + 'accept_result' => $params['accept_result'], + '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 @@ -186,7 +218,7 @@ class SupervisionAcceptLogic extends BaseLogic self::setError('该验收内容下存在验收结果数据,请先删除验收结果数据'); return false; } - $accept_problem = SupervisionAcceptProblem::where('accept_id',$params['id'])->findOrEmpty(); + $accept_problem = SupervisionProblem::where('data_id',$params['id'])->where('data_type',3)->findOrEmpty(); if(!$accept_problem->isEmpty()){ self::setError('该验收内容下存在验收问题数据,请先删除验收问题数据'); return false; diff --git a/app/adminapi/logic/supervision_work/SupervisionInspectionLogic.php b/app/adminapi/logic/supervision_work/SupervisionInspectionLogic.php index f55a55d3f..2aceaafc1 100644 --- a/app/adminapi/logic/supervision_work/SupervisionInspectionLogic.php +++ b/app/adminapi/logic/supervision_work/SupervisionInspectionLogic.php @@ -21,8 +21,8 @@ use app\common\model\supervision_project\SupervisionProject; use app\common\model\supervision_work\SupervisionCheckItem; use app\common\model\supervision_work\SupervisionInspection; use app\common\logic\BaseLogic; -use app\common\model\supervision_work\SupervisionInspectionProblem; use app\common\model\supervision_work\SupervisionInspectionResult; +use app\common\model\supervision_work\SupervisionProblem; use think\facade\Db; @@ -78,11 +78,13 @@ class SupervisionInspectionLogic extends BaseLogic } if(!empty($params['inspection_problem'])){ foreach($params['inspection_problem'] as $v){ - SupervisionInspectionProblem::create([ - 'inspection_id' => $res->id, + SupervisionProblem::create([ + 'data_id' => $res->id, + 'data_type' => 1, 'problem_cate' => $v['problem_cate'], 'problem_description' => $v['problem_description'], 'problem_name' => $v['problem_name'], + 'create_user' => $admin_id, ]); } } @@ -103,7 +105,7 @@ class SupervisionInspectionLogic extends BaseLogic * @author likeadmin * @date 2024/02/26 17:18 */ - public static function edit(array $params): bool + public static function edit(array $params,$admin_id): bool { Db::startTrans(); try { @@ -150,18 +152,21 @@ class SupervisionInspectionLogic extends BaseLogic if(!empty($params['inspection_problem'])){ foreach($params['inspection_problem'] as $v){ if(!empty($v['id'])){ - SupervisionInspectionProblem::where('id',$v['id'])->update([ - 'inspection_id' => $params['id'], + SupervisionProblem::where('id',$v['id'])->update([ + 'data_id' => $params['id'], + 'data_type' => 1, 'problem_cate' => $v['problem_cate'], 'problem_description' => $v['problem_description'], 'problem_name' => $v['problem_name'], ]); }else{ - SupervisionInspectionProblem::create([ - 'inspection_id' => $params['id'], + SupervisionProblem::create([ + 'data_id' => $params['id'], + 'data_type' => 1, 'problem_cate' => $v['problem_cate'], 'problem_description' => $v['problem_description'], 'problem_name' => $v['problem_name'], + 'create_user' => $admin_id, ]); } } @@ -190,7 +195,7 @@ class SupervisionInspectionLogic extends BaseLogic self::setError('该巡视内容下存在巡视结果数据,请先删除巡视结果数据'); return false; } - $inspection_problem = SupervisionInspectionProblem::where('inspection_id',$params['id'])->findOrEmpty(); + $inspection_problem = SupervisionProblem::where('data_id',$params['id'])->where('data_type',1)->findOrEmpty(); if(!$inspection_problem->isEmpty()){ self::setError('该巡视内容下存在巡视问题数据,请先删除巡视问题数据'); return false; diff --git a/app/adminapi/logic/supervision_work/SupervisionProblemLogic.php b/app/adminapi/logic/supervision_work/SupervisionProblemLogic.php new file mode 100644 index 000000000..d6fa286da --- /dev/null +++ b/app/adminapi/logic/supervision_work/SupervisionProblemLogic.php @@ -0,0 +1,150 @@ + $params['data_id'], + 'data_type' => $params['data_type'], + 'problem_cate' => $params['problem_cate'], + 'problem_description' => $params['problem_description'], + 'problem_name' => $params['problem_name'], + '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/02/28 09:19 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + SupervisionProblem::where('id', $params['id'])->update([ + 'data_id' => $params['data_id'], + 'data_type' => $params['data_type'], + 'problem_cate' => $params['problem_cate'], + 'problem_description' => $params['problem_description'], + 'problem_name' => $params['problem_name'], + '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/02/28 09:19 + */ + public static function check(array $params): bool + { + Db::startTrans(); + try { + SupervisionProblem::where('id', $params['id'])->update([ + 'rectification_time' => !empty($params['rectification_time']) ? strtotime($params['rectification_time']) : 0, + 'rectification_user' => $params['rectification_user'], + 'rectification_result' => $params['rectification_result'], + 'rectification_opinion' => $params['rectification_opinion'], + 'rectification_annex' => $params['rectification_annex'] ? json_encode($params['rectification_annex']) : null, + 'is_rectification' => $params['rectification_result']==0 ? 1 : 0, + '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/02/28 09:19 + */ + public static function delete(array $params): bool + { + return SupervisionProblem::destroy($params['id']); + } + + + /** + * @notes 获取问题跟踪台账详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public static function detail($params): array + { + $data = SupervisionProblem::withoutField('update_time,delete_time')->findOrEmpty($params['id']); + $create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); + $data['create_user_name'] = $create_user['name']; + $data['problem_cate_text'] = $data->problem_cate_text; + $data['rectification_result_text'] = $data->rectification_result_text; + $data['is_rectification_text'] = $data->is_rectification_text; + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/supervision_work/SupervisionSideStationLogic.php b/app/adminapi/logic/supervision_work/SupervisionSideStationLogic.php index 24a67d661..199ded7f6 100644 --- a/app/adminapi/logic/supervision_work/SupervisionSideStationLogic.php +++ b/app/adminapi/logic/supervision_work/SupervisionSideStationLogic.php @@ -19,9 +19,9 @@ use app\common\model\auth\Admin; use app\common\model\supervision_project\SupervisionParticipatingUnits; use app\common\model\supervision_project\SupervisionProject; use app\common\model\supervision_work\SupervisionCheckItem; +use app\common\model\supervision_work\SupervisionProblem; use app\common\model\supervision_work\SupervisionSideStation; use app\common\logic\BaseLogic; -use app\common\model\supervision_work\SupervisionSideStationProblem; use app\common\model\supervision_work\SupervisionSideStationResult; use think\facade\Db; @@ -77,11 +77,13 @@ class SupervisionSideStationLogic extends BaseLogic } if(!empty($params['side_problem'])){ foreach($params['side_problem'] as $v){ - SupervisionSideStationProblem::create([ - 'side_station_id' => $res->id, + SupervisionProblem::create([ + 'data_id' => $res->id, + 'data_type' => 2, 'problem_cate' => $v['problem_cate'], 'problem_description' => $v['problem_description'], 'problem_name' => $v['problem_name'], + 'create_user' => $admin_id ]); } } @@ -102,7 +104,7 @@ class SupervisionSideStationLogic extends BaseLogic * @author likeadmin * @date 2024/02/27 13:58 */ - public static function edit(array $params): bool + public static function edit(array $params,$admin_id): bool { Db::startTrans(); try { @@ -148,19 +150,22 @@ class SupervisionSideStationLogic extends BaseLogic if(!empty($params['side_problem'])){ foreach($params['side_problem'] as $v){ if(!empty($v['id'])){ - SupervisionSideStationProblem::where('id',$v['id'])->update([ - 'side_station_id' => $params['id'], + SupervisionProblem::where('id',$v['id'])->update([ + 'data_id' => $params['id'], + 'data_type' => 2, 'problem_cate' => $v['problem_cate'], 'problem_description' => $v['problem_description'], 'problem_name' => $v['problem_name'], 'update_time' => time(), ]); }else{ - SupervisionSideStationProblem::create([ - 'side_station_id' => $params['id'], + SupervisionProblem::create([ + 'data_id' => $params['id'], + 'data_type' => 2, 'problem_cate' => $v['problem_cate'], 'problem_description' => $v['problem_description'], 'problem_name' => $v['problem_name'], + 'create_user' => $admin_id ]); } } @@ -189,7 +194,7 @@ class SupervisionSideStationLogic extends BaseLogic self::setError('该旁站内容下存在旁站结果数据,请先删除旁站结果数据'); return false; } - $side_station_problem = SupervisionSideStationProblem::where('side_station_id',$params['id'])->findOrEmpty(); + $side_station_problem = SupervisionProblem::where('data_id',$params['id'])->where('data_type',2)->findOrEmpty(); if(!$side_station_problem->isEmpty()){ self::setError('该旁站内容下存在旁站问题数据,请先删除旁站问题数据'); return false; diff --git a/app/adminapi/validate/supervision_work/SupervisionAcceptValidate.php b/app/adminapi/validate/supervision_work/SupervisionAcceptValidate.php index 264f3202d..adfe8d6d3 100644 --- a/app/adminapi/validate/supervision_work/SupervisionAcceptValidate.php +++ b/app/adminapi/validate/supervision_work/SupervisionAcceptValidate.php @@ -19,9 +19,9 @@ use app\common\model\dict\DictData; use app\common\model\supervision_project\SupervisionParticipatingUnits; use app\common\model\supervision_project\SupervisionProject; use app\common\model\supervision_work\SupervisionAccept; -use app\common\model\supervision_work\SupervisionAcceptProblem; use app\common\model\supervision_work\SupervisionAcceptResult; use app\common\model\supervision_work\SupervisionCheckItem; +use app\common\model\supervision_work\SupervisionProblem; use app\common\validate\BaseValidate; @@ -44,7 +44,7 @@ class SupervisionAcceptValidate extends BaseValidate 'check_item_id' => 'require|checkCheckItem', 'accept_time' => 'require|dateFormat:Y-m-d H:i:s', 'company_id' => 'checkCompany', - 'accept_result' => 'in:0,1', + 'accept_result' => 'require|in:0,1', 'check_item_detail_ids' => 'checkCheckItemDetail', 'annex' => 'checkAnnex', 'accept_check_result' => 'checkAcceptResult', @@ -92,6 +92,17 @@ class SupervisionAcceptValidate extends BaseValidate */ public function sceneEdit() {} + + /** + * @notes 验收场景 + * @return SupervisionAcceptValidate + * @author likeadmin + * @date 2024/02/27 15:23 + */ + public function sceneAccept() + { + return $this->only(['id','accept_time','accept_result','remark','annex']); + } /** @@ -211,12 +222,17 @@ class SupervisionAcceptValidate extends BaseValidate if(!is_array($value)) return '验收问题数据格式错误'; foreach($value as $k=>$v){ if(!empty($v['id'])){ - $data = SupervisionAcceptProblem::where('id',$v['id'])->findOrEmpty(); + $data = SupervisionProblem::where('id',$v['id'])->findOrEmpty(); if($data->isEmpty()){ return '验收问题列表第'.($k+1).'行数据不存在'; } } - if(empty($v['problem_cate'])) return '验收问题列表第'.($k+1).'行问题分类为空'; + if(empty($v['problem_cate'])){ + return '验收问题列表第'.($k+1).'行问题分类为空'; + }else{ + $dict = DictData::where('type_value','problem_cate')->column('value'); + if(!in_array($v['problem_cate'],$dict)) return '验收问题列表第'.($k+1).'行问题分类数据值无效'; + } if(empty($v['problem_description'])) return '验收问题列表第'.($k+1).'行问题说明为空'; if(empty($v['problem_name'])) return '验收问题列表第'.($k+1).'行问题名称为空'; } diff --git a/app/adminapi/validate/supervision_work/SupervisionInspectionValidate.php b/app/adminapi/validate/supervision_work/SupervisionInspectionValidate.php index a868e71d6..61b24bc25 100644 --- a/app/adminapi/validate/supervision_work/SupervisionInspectionValidate.php +++ b/app/adminapi/validate/supervision_work/SupervisionInspectionValidate.php @@ -20,8 +20,8 @@ use app\common\model\supervision_project\SupervisionParticipatingUnits; use app\common\model\supervision_project\SupervisionProject; use app\common\model\supervision_work\SupervisionCheckItem; use app\common\model\supervision_work\SupervisionInspection; -use app\common\model\supervision_work\SupervisionInspectionProblem; use app\common\model\supervision_work\SupervisionInspectionResult; +use app\common\model\supervision_work\SupervisionProblem; use app\common\validate\BaseValidate; @@ -219,12 +219,17 @@ class SupervisionInspectionValidate extends BaseValidate if(!is_array($value)) return '巡视问题数据格式错误'; foreach($value as $k=>$v){ if(!empty($v['id'])){ - $data = SupervisionInspectionProblem::where('id',$v['id'])->findOrEmpty(); + $data = SupervisionProblem::where('id',$v['id'])->findOrEmpty(); if($data->isEmpty()){ return '巡视问题列表第'.($k+1).'行数据不存在'; } } - if(empty($v['problem_cate'])) return '巡视问题列表第'.($k+1).'行问题分类为空'; + if(empty($v['problem_cate'])){ + return '巡视问题列表第'.($k+1).'行问题分类为空'; + }else{ + $dict = DictData::where('type_value','problem_cate')->column('value'); + if(!in_array($v['problem_cate'],$dict)) return '巡视问题列表第'.($k+1).'行问题分类数据值无效'; + } if(empty($v['problem_description'])) return '巡视问题列表第'.($k+1).'行问题说明为空'; if(empty($v['problem_name'])) return '巡视问题列表第'.($k+1).'行问题名称为空'; } diff --git a/app/adminapi/validate/supervision_work/SupervisionProblemValidate.php b/app/adminapi/validate/supervision_work/SupervisionProblemValidate.php new file mode 100644 index 000000000..77998a265 --- /dev/null +++ b/app/adminapi/validate/supervision_work/SupervisionProblemValidate.php @@ -0,0 +1,154 @@ + 'require|checkData', + 'data_id' => 'require', + 'data_type' => 'require|in:1,2,3,4,5,6,7', + 'problem_cate' => 'require|checkProblemCate', + 'problem_description' => 'require', + 'problem_name' => 'require', + 'rectification_time' => 'require|dateFormat:Y-m-d', + 'rectification_user' => 'require', + 'rectification_result' => 'require|in:0,1', + 'rectification_opinion' => 'require', + 'is_rectification' => 'require|in:0,1', + 'rectification_annex' => 'checkAnnex', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'data_id' => '数据id', + 'data_type' => '数据类型', + 'problem_cate' => '问题分类', + 'problem_description' => '问题说明', + 'problem_name' => '问题名称', + 'rectification_time' => '整改时间', + 'rectification_user' => '整改人', + 'rectification_result' => '整改结果', + 'rectification_opinion' => '整改意见', + 'is_rectification' => '是否整改', + ]; + + + /** + * @notes 添加场景 + * @return SupervisionProblemValidate + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function sceneAdd() + { + return $this->only(['data_id','data_type','problem_cate','problem_description','problem_name']); + } + + + /** + * @notes 编辑场景 + * @return SupervisionProblemValidate + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function sceneEdit() + { + return $this->only(['id','data_id','data_type','problem_cate','problem_description','problem_name']); + } + + /** + * @notes 检查验收场景 + * @return SupervisionProblemValidate + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function sceneCheck() + { + return $this->only(['id','rectification_time','rectification_user','rectification_result','rectification_opinion','rectification_annex']); + } + + + /** + * @notes 删除场景 + * @return SupervisionProblemValidate + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return SupervisionProblemValidate + * @author likeadmin + * @date 2024/02/28 09:19 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = SupervisionProblem::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '数据不存在'; + } + return true; + } + + public function checkProblemCate($value): bool|string + { + $dict = DictData::where('type_value','problem_cate')->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/adminapi/validate/supervision_work/SupervisionSideStationValidate.php b/app/adminapi/validate/supervision_work/SupervisionSideStationValidate.php index b7f7b4b6e..8796097da 100644 --- a/app/adminapi/validate/supervision_work/SupervisionSideStationValidate.php +++ b/app/adminapi/validate/supervision_work/SupervisionSideStationValidate.php @@ -19,8 +19,8 @@ use app\common\model\dict\DictData; use app\common\model\supervision_project\SupervisionParticipatingUnits; use app\common\model\supervision_project\SupervisionProject; use app\common\model\supervision_work\SupervisionCheckItem; +use app\common\model\supervision_work\SupervisionProblem; use app\common\model\supervision_work\SupervisionSideStation; -use app\common\model\supervision_work\SupervisionSideStationProblem; use app\common\model\supervision_work\SupervisionSideStationResult; use app\common\validate\BaseValidate; @@ -216,12 +216,17 @@ class SupervisionSideStationValidate extends BaseValidate if(!is_array($value)) return '旁站问题数据格式错误'; foreach($value as $k=>$v){ if(!empty($v['id'])){ - $data = SupervisionSideStationProblem::where('id',$v['id'])->findOrEmpty(); + $data = SupervisionProblem::where('id',$v['id'])->findOrEmpty(); if($data->isEmpty()){ return '旁站问题列表第'.($k+1).'行数据不存在'; } } - if(empty($v['problem_cate'])) return '旁站问题列表第'.($k+1).'行问题分类为空'; + if(empty($v['problem_cate'])){ + return '旁站问题列表第'.($k+1).'行问题分类为空'; + }else{ + $dict = DictData::where('type_value','problem_cate')->column('value'); + if(!in_array($v['problem_cate'],$dict)) return '旁站问题列表第'.($k+1).'行问题分类数据值无效'; + } if(empty($v['problem_description'])) return '旁站问题列表第'.($k+1).'行问题说明为空'; if(empty($v['problem_name'])) return '旁站问题列表第'.($k+1).'行问题名称为空'; } diff --git a/app/common/model/supervision_work/SupervisionProblem.php b/app/common/model/supervision_work/SupervisionProblem.php new file mode 100644 index 000000000..b453d063d --- /dev/null +++ b/app/common/model/supervision_work/SupervisionProblem.php @@ -0,0 +1,67 @@ +'巡视', 2=>'旁站', 3=>'验收', 4=>'设备进场', 5=>'见证取样', 6=>'材料平行检验', 7=>'实体平行检验']; + return $arr[$data['data_type']]; + } + + public function getProblemCateTextAttr($value,$data){ + $dict = DictData::where('type_value','problem_cate')->column('name','value'); + return !empty($data['problem_cate']) ? $dict[$data['problem_cate']] : ''; + } + + public function getRectificationResultTextAttr($value,$data): string + { + $arr = [0=>'通过', 1=>'不通过']; + return $arr[$data['rectification_result']]; + } + + public function getIsRectificationTextAttr($value,$data): string + { + $arr = [0=>'否', 1=>'是']; + return $arr[$data['is_rectification']]; + } + + public function getRectificationTimeAttr($value,$data): string + { + return !empty($data['rectification_time']) ? date('Y-m-d H:i:s',$data['rectification_time']) : ''; + } + + public function getRectificationAnnexAttr($value,$data): string + { + return !empty($data['rectification_annex']) ? json_decode($data['rectification_annex'],true) : ''; + } +} \ No newline at end of file