diff --git a/app/adminapi/controller/supervision_work/SupervisionAcceptController.php b/app/adminapi/controller/supervision_work/SupervisionAcceptController.php index 585e4a168..acdc0fc1e 100644 --- a/app/adminapi/controller/supervision_work/SupervisionAcceptController.php +++ b/app/adminapi/controller/supervision_work/SupervisionAcceptController.php @@ -102,8 +102,11 @@ class SupervisionAcceptController extends BaseAdminController public function delete() { $params = (new SupervisionAcceptValidate())->post()->goCheck('delete'); - SupervisionAcceptLogic::delete($params); - return $this->success('删除成功', [], 1, 1); + $result = SupervisionAcceptLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionAcceptLogic::getError()); } diff --git a/app/adminapi/controller/supervision_work/SupervisionCheckItemController.php b/app/adminapi/controller/supervision_work/SupervisionCheckItemController.php index 264a9c48e..b60f7fb09 100644 --- a/app/adminapi/controller/supervision_work/SupervisionCheckItemController.php +++ b/app/adminapi/controller/supervision_work/SupervisionCheckItemController.php @@ -86,8 +86,11 @@ class SupervisionCheckItemController extends BaseAdminController public function delete() { $params = (new SupervisionCheckItemValidate())->post()->goCheck('delete'); - SupervisionCheckItemLogic::delete($params); - return $this->success('删除成功', [], 1, 1); + $result = SupervisionCheckItemLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionCheckItemLogic::getError()); } diff --git a/app/adminapi/controller/supervision_work/SupervisionDeviceEntryController.php b/app/adminapi/controller/supervision_work/SupervisionDeviceEntryController.php index ac13af693..479c660e1 100644 --- a/app/adminapi/controller/supervision_work/SupervisionDeviceEntryController.php +++ b/app/adminapi/controller/supervision_work/SupervisionDeviceEntryController.php @@ -86,8 +86,11 @@ class SupervisionDeviceEntryController extends BaseAdminController public function delete() { $params = (new SupervisionDeviceEntryValidate())->post()->goCheck('delete'); - SupervisionDeviceEntryLogic::delete($params); - return $this->success('删除成功', [], 1, 1); + $result = SupervisionDeviceEntryLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionDeviceEntryLogic::getError()); } diff --git a/app/adminapi/controller/supervision_work/SupervisionEntityParallelTestingController.php b/app/adminapi/controller/supervision_work/SupervisionEntityParallelTestingController.php new file mode 100644 index 000000000..c6a1b57f8 --- /dev/null +++ b/app/adminapi/controller/supervision_work/SupervisionEntityParallelTestingController.php @@ -0,0 +1,111 @@ +dataLists(new SupervisionEntityParallelTestingLists()); + } + + + /** + * @notes 添加工程监理--实体平行检验 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/29 16:32 + */ + public function add() + { + $params = (new SupervisionEntityParallelTestingValidate())->post()->goCheck('add'); + $result = SupervisionEntityParallelTestingLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(SupervisionEntityParallelTestingLogic::getError()); + } + + + /** + * @notes 编辑工程监理--实体平行检验 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/29 16:32 + */ + public function edit() + { + $params = (new SupervisionEntityParallelTestingValidate())->post()->goCheck('edit'); + $result = SupervisionEntityParallelTestingLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(SupervisionEntityParallelTestingLogic::getError()); + } + + + /** + * @notes 删除工程监理--实体平行检验 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/29 16:32 + */ + public function delete() + { + $params = (new SupervisionEntityParallelTestingValidate())->post()->goCheck('delete'); + $result = SupervisionEntityParallelTestingLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionEntityParallelTestingLogic::getError()); + } + + + /** + * @notes 获取工程监理--实体平行检验详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/02/29 16:32 + */ + public function detail() + { + $params = (new SupervisionEntityParallelTestingValidate())->goCheck('detail'); + $result = SupervisionEntityParallelTestingLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/supervision_work/SupervisionInspectionController.php b/app/adminapi/controller/supervision_work/SupervisionInspectionController.php index 5be03ec11..6f2eb9903 100644 --- a/app/adminapi/controller/supervision_work/SupervisionInspectionController.php +++ b/app/adminapi/controller/supervision_work/SupervisionInspectionController.php @@ -86,8 +86,11 @@ class SupervisionInspectionController extends BaseAdminController public function delete() { $params = (new SupervisionInspectionValidate())->post()->goCheck('delete'); - SupervisionInspectionLogic::delete($params); - return $this->success('删除成功', [], 1, 1); + $result = SupervisionInspectionLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionInspectionLogic::getError()); } diff --git a/app/adminapi/controller/supervision_work/SupervisionMaterialEntryController.php b/app/adminapi/controller/supervision_work/SupervisionMaterialEntryController.php index 78dbd754f..0c37063bc 100644 --- a/app/adminapi/controller/supervision_work/SupervisionMaterialEntryController.php +++ b/app/adminapi/controller/supervision_work/SupervisionMaterialEntryController.php @@ -86,8 +86,11 @@ class SupervisionMaterialEntryController extends BaseAdminController public function delete() { $params = (new SupervisionMaterialEntryValidate())->post()->goCheck('delete'); - SupervisionMaterialEntryLogic::delete($params); - return $this->success('删除成功', [], 1, 1); + $result = SupervisionMaterialEntryLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionMaterialEntryLogic::getError()); } diff --git a/app/adminapi/controller/supervision_work/SupervisionMaterialParallelTestingController.php b/app/adminapi/controller/supervision_work/SupervisionMaterialParallelTestingController.php index 325e221d9..822dbf8c0 100644 --- a/app/adminapi/controller/supervision_work/SupervisionMaterialParallelTestingController.php +++ b/app/adminapi/controller/supervision_work/SupervisionMaterialParallelTestingController.php @@ -86,8 +86,11 @@ class SupervisionMaterialParallelTestingController extends BaseAdminController public function delete() { $params = (new SupervisionMaterialParallelTestingValidate())->post()->goCheck('delete'); - SupervisionMaterialParallelTestingLogic::delete($params); - return $this->success('删除成功', [], 1, 1); + $result = SupervisionMaterialParallelTestingLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionMaterialParallelTestingLogic::getError()); } diff --git a/app/adminapi/controller/supervision_work/SupervisionMaterialParallelTestingDetailController.php b/app/adminapi/controller/supervision_work/SupervisionMaterialParallelTestingDetailController.php index adaa67376..a18ef6ec5 100644 --- a/app/adminapi/controller/supervision_work/SupervisionMaterialParallelTestingDetailController.php +++ b/app/adminapi/controller/supervision_work/SupervisionMaterialParallelTestingDetailController.php @@ -102,8 +102,11 @@ class SupervisionMaterialParallelTestingDetailController extends BaseAdminContro public function delete() { $params = (new SupervisionMaterialParallelTestingDetailValidate())->post()->goCheck('delete'); - SupervisionMaterialParallelTestingDetailLogic::delete($params); - return $this->success('删除成功', [], 1, 1); + $result = SupervisionMaterialParallelTestingDetailLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionMaterialParallelTestingDetailLogic::getError()); } diff --git a/app/adminapi/controller/supervision_work/SupervisionSideStationController.php b/app/adminapi/controller/supervision_work/SupervisionSideStationController.php index 8412c8511..4c23b8554 100644 --- a/app/adminapi/controller/supervision_work/SupervisionSideStationController.php +++ b/app/adminapi/controller/supervision_work/SupervisionSideStationController.php @@ -86,8 +86,11 @@ class SupervisionSideStationController extends BaseAdminController public function delete() { $params = (new SupervisionSideStationValidate())->post()->goCheck('delete'); - SupervisionSideStationLogic::delete($params); - return $this->success('删除成功', [], 1, 1); + $result = SupervisionSideStationLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionSideStationLogic::getError()); } diff --git a/app/adminapi/controller/supervision_work/SupervisionTestBlocksSpecimensController.php b/app/adminapi/controller/supervision_work/SupervisionTestBlocksSpecimensController.php index 96ac972b3..9ac583a43 100644 --- a/app/adminapi/controller/supervision_work/SupervisionTestBlocksSpecimensController.php +++ b/app/adminapi/controller/supervision_work/SupervisionTestBlocksSpecimensController.php @@ -86,8 +86,11 @@ class SupervisionTestBlocksSpecimensController extends BaseAdminController public function delete() { $params = (new SupervisionTestBlocksSpecimensValidate())->post()->goCheck('delete'); - SupervisionTestBlocksSpecimensLogic::delete($params); - return $this->success('删除成功', [], 1, 1); + $result = SupervisionTestBlocksSpecimensLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionTestBlocksSpecimensLogic::getError()); } diff --git a/app/adminapi/controller/supervision_work/SupervisionWitnessSamplingController.php b/app/adminapi/controller/supervision_work/SupervisionWitnessSamplingController.php index 43a87352e..d5906c6fd 100644 --- a/app/adminapi/controller/supervision_work/SupervisionWitnessSamplingController.php +++ b/app/adminapi/controller/supervision_work/SupervisionWitnessSamplingController.php @@ -86,8 +86,11 @@ class SupervisionWitnessSamplingController extends BaseAdminController public function delete() { $params = (new SupervisionWitnessSamplingValidate())->post()->goCheck('delete'); - SupervisionWitnessSamplingLogic::delete($params); - return $this->success('删除成功', [], 1, 1); + $result = SupervisionWitnessSamplingLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionWitnessSamplingLogic::getError()); } diff --git a/app/adminapi/controller/supervision_work/SupervisionWitnessSamplingDetailController.php b/app/adminapi/controller/supervision_work/SupervisionWitnessSamplingDetailController.php index 3040d3d03..ccac22ea1 100644 --- a/app/adminapi/controller/supervision_work/SupervisionWitnessSamplingDetailController.php +++ b/app/adminapi/controller/supervision_work/SupervisionWitnessSamplingDetailController.php @@ -102,8 +102,11 @@ class SupervisionWitnessSamplingDetailController extends BaseAdminController public function delete() { $params = (new SupervisionWitnessSamplingDetailValidate())->post()->goCheck('delete'); - SupervisionWitnessSamplingDetailLogic::delete($params); - return $this->success('删除成功', [], 1, 1); + $result = SupervisionWitnessSamplingDetailLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(SupervisionWitnessSamplingDetailLogic::getError()); } diff --git a/app/adminapi/lists/supervision_work/SupervisionEntityParallelTestingLists.php b/app/adminapi/lists/supervision_work/SupervisionEntityParallelTestingLists.php new file mode 100644 index 000000000..35786fbd3 --- /dev/null +++ b/app/adminapi/lists/supervision_work/SupervisionEntityParallelTestingLists.php @@ -0,0 +1,88 @@ + ['project_id', 'result'], + '%like%' => ['theme', 'code', 'position'], + ]; + } + + + /** + * @notes 获取工程监理--实体平行检验列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/02/29 16:32 + */ + public function lists(): array + { + return SupervisionEntityParallelTesting::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')->where('id',$data['project_id'])->findOrEmpty(); + $check_item = SupervisionCheckItem::field('node_name')->where('id',$data['check_item_id'])->findOrEmpty(); + $create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); + $data['project_name'] = $project['project_name']; + $data['check_item_name'] = $check_item['node_name']; + $data['create_user_name'] = $create_user['name']; + $data['result_text'] = $data->result_text; + }) + ->toArray(); + } + + + /** + * @notes 获取工程监理--实体平行检验数量 + * @return int + * @author likeadmin + * @date 2024/02/29 16:32 + */ + public function count(): int + { + return SupervisionEntityParallelTesting::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/supervision_work/SupervisionEntityParallelTestingLogic.php b/app/adminapi/logic/supervision_work/SupervisionEntityParallelTestingLogic.php new file mode 100644 index 000000000..ff5349caa --- /dev/null +++ b/app/adminapi/logic/supervision_work/SupervisionEntityParallelTestingLogic.php @@ -0,0 +1,177 @@ + $params['project_id'], + 'theme' => $params['theme'], + 'code' => data_unique_code('STPXJY'), + 'check_item_id' => $params['check_item_id'], + 'position' => $params['position'], + 'start_time' => !empty($params['start_time']) ? strtotime($params['start_time']) : 0, + 'end_time' => !empty($params['end_time']) ? strtotime($params['end_time']) : 0, + 'result' => $params['result'], + 'remark' => $params['remark'], + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + 'create_user' => $admin_id + ]); + if(!empty($params['problem'])){ + foreach($params['problem'] as $v){ + SupervisionProblem::create([ + 'data_id' => $res->id, + 'data_type' => 8, + 'problem_cate' => $v['problem_cate'], + 'problem_description' => $v['problem_description'], + 'problem_name' => $v['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/29 16:32 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + SupervisionEntityParallelTesting::where('id', $params['id'])->update([ + 'project_id' => $params['project_id'], + 'theme' => $params['theme'], + 'check_item_id' => $params['check_item_id'], + 'position' => $params['position'], + 'start_time' => !empty($params['start_time']) ? strtotime($params['start_time']) : 0, + 'end_time' => !empty($params['end_time']) ? strtotime($params['end_time']) : 0, + 'result' => $params['result'], + 'remark' => $params['remark'], + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + 'update_time' => time(), + ]); + if(!empty($params['problem'])){ + foreach($params['problem'] as $v){ + if(!empty($v['id'])){ + SupervisionProblem::where('id',$v['id'])->update([ + 'data_id' => $params['id'], + 'data_type' => 8, + 'problem_cate' => $v['problem_cate'], + 'problem_description' => $v['problem_description'], + 'problem_name' => $v['problem_name'], + 'update_time' => time(), + ]); + }else{ + SupervisionProblem::create([ + 'data_id' => $params['id'], + 'data_type' => 8, + 'problem_cate' => $v['problem_cate'], + 'problem_description' => $v['problem_description'], + 'problem_name' => $v['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/29 16:32 + */ + public static function delete(array $params): bool + { + $problem = SupervisionProblem::where('data_id',$params['id'])->where('data_type',8)->findOrEmpty(); + if(!$problem->isEmpty()){ + self::setError('该内容下存在实体平行检验问题数据,请先删除实体平行检验问题数据'); + return false; + } + return SupervisionEntityParallelTesting::destroy($params['id']); + } + + + /** + * @notes 获取工程监理--实体平行检验详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/02/29 16:32 + */ + public static function detail($params): array + { + $data = SupervisionEntityParallelTesting::withoutField('update_time,delete_time')->findOrEmpty($params['id']); + $project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty(); + $check_item = SupervisionCheckItem::field('node_name')->where('id',$data['check_item_id'])->findOrEmpty(); + $create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); + $data['project_name'] = $project['project_name']; + $data['check_item_name'] = $check_item['node_name']; + $data['create_user_name'] = $create_user['name']; + $data['result_text'] = $data->result_text; + $data['problem_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',8)->count(); + $data['reply_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',8)->where('is_rectification',1)->count(); + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/supervision_work/SupervisionEntityParallelTestingValidate.php b/app/adminapi/validate/supervision_work/SupervisionEntityParallelTestingValidate.php new file mode 100644 index 000000000..9ac93a8e1 --- /dev/null +++ b/app/adminapi/validate/supervision_work/SupervisionEntityParallelTestingValidate.php @@ -0,0 +1,172 @@ + 'require|checkData', + 'project_id' => 'require|checkProject', + 'theme' => 'require', + 'check_item_id' => 'checkCheckItem', + 'start_time' => 'require|dateFormat:Y-m-d', + 'end_time' => 'require|dateFormat:Y-m-d', + 'result' => 'require|in:0,1', + 'annex' => 'checkAnnex', + 'problem' => 'checkProblem' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'project_id' => '项目id', + 'theme' => '检验主题', + 'code' => '编号', + 'check_item_id' => '工程单位', + 'position' => '检验部位', + 'start_time' => '开始时间', + 'end_time' => '结束时间', + 'result' => '检验结果', + 'remark' => '备注', + 'create_user' => '创建人', + ]; + + + /** + * @notes 添加场景 + * @return SupervisionEntityParallelTestingValidate + * @author likeadmin + * @date 2024/02/29 16:32 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return SupervisionEntityParallelTestingValidate + * @author likeadmin + * @date 2024/02/29 16:32 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return SupervisionEntityParallelTestingValidate + * @author likeadmin + * @date 2024/02/29 16:32 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return SupervisionEntityParallelTestingValidate + * @author likeadmin + * @date 2024/02/29 16:32 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value){ + $data = SupervisionEntityParallelTesting::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 checkCheckItem($value,$rule,$params): bool|string + { + $data = SupervisionCheckItem::where('id',$value)->where('project_id',$params['project_id'])->where('node_type',2)->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 = SupervisionProblem::where('id',$v['id'])->findOrEmpty(); + if($data->isEmpty()){ + 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).'行问题名称为空'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/supervision_work/SupervisionEntityParallelTesting.php b/app/common/model/supervision_work/SupervisionEntityParallelTesting.php new file mode 100644 index 000000000..e65058381 --- /dev/null +++ b/app/common/model/supervision_work/SupervisionEntityParallelTesting.php @@ -0,0 +1,52 @@ +'符合标准', 1=>'不符合标准']; + return $arr[$data['result']]; + } + + public function getStartTimeAttr($value): string + { + return !empty($value) ? date('Y-m-d', $value) : ''; + } + + public function getEndTimeAttr($value): string + { + return !empty($value) ? date('Y-m-d', $value) : ''; + } +} \ No newline at end of file