From d6cbfb53a3a16f667b5b7260f9672753cadfaeba Mon Sep 17 00:00:00 2001 From: weiz Date: Wed, 20 Dec 2023 16:23:20 +0800 Subject: [PATCH 01/17] QualityCheckNature --- .../quality/QualityCheckNatureController.php | 108 +++++++++++++++ .../lists/quality/QualityCheckNatureLists.php | 86 ++++++++++++ .../logic/quality/QualityCheckNatureLogic.php | 129 ++++++++++++++++++ .../quality/QualityCheckNatureValidate.php | 120 ++++++++++++++++ .../safety/SafetyAccidentValidate.php | 4 +- .../validate/safety/SafetyCheckValidate.php | 4 +- .../safety/SafetyEmergencyPlanValidate.php | 4 +- .../safety/SafetyEvaluateValidate.php | 4 +- .../validate/safety/SafetyEventValidate.php | 4 +- .../validate/safety/SafetyModifyValidate.php | 4 +- .../safety/SafetyRehearsalValidate.php | 4 +- .../safety/SafetySuperviseValidate.php | 4 +- .../model/quality/QualityCheckNature.php | 37 +++++ app/common/model/safety/SafetyAccident.php | 2 +- app/common/model/safety/SafetyCheck.php | 2 +- .../model/safety/SafetyEmergencyPlan.php | 2 +- app/common/model/safety/SafetyEvaluate.php | 2 +- app/common/model/safety/SafetyEvent.php | 2 +- app/common/model/safety/SafetyModify.php | 2 +- app/common/model/safety/SafetyRehearsal.php | 2 +- app/common/model/safety/SafetySupervise.php | 2 +- 21 files changed, 504 insertions(+), 24 deletions(-) create mode 100644 app/adminapi/controller/quality/QualityCheckNatureController.php create mode 100644 app/adminapi/lists/quality/QualityCheckNatureLists.php create mode 100644 app/adminapi/logic/quality/QualityCheckNatureLogic.php create mode 100644 app/adminapi/validate/quality/QualityCheckNatureValidate.php create mode 100644 app/common/model/quality/QualityCheckNature.php diff --git a/app/adminapi/controller/quality/QualityCheckNatureController.php b/app/adminapi/controller/quality/QualityCheckNatureController.php new file mode 100644 index 000000000..362438ac2 --- /dev/null +++ b/app/adminapi/controller/quality/QualityCheckNatureController.php @@ -0,0 +1,108 @@ +dataLists(new QualityCheckNatureLists()); + } + + + /** + * @notes 添加检查性质 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:56 + */ + public function add() + { + $params = (new QualityCheckNatureValidate())->post()->goCheck('add'); + $result = QualityCheckNatureLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(QualityCheckNatureLogic::getError()); + } + + + /** + * @notes 编辑检查性质 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:56 + */ + public function edit() + { + $params = (new QualityCheckNatureValidate())->post()->goCheck('edit'); + $result = QualityCheckNatureLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(QualityCheckNatureLogic::getError()); + } + + + /** + * @notes 删除检查性质 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:56 + */ + public function delete() + { + $params = (new QualityCheckNatureValidate())->post()->goCheck('delete'); + QualityCheckNatureLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取检查性质详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 15:56 + */ + public function detail() + { + $params = (new QualityCheckNatureValidate())->goCheck('detail'); + $result = QualityCheckNatureLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/quality/QualityCheckNatureLists.php b/app/adminapi/lists/quality/QualityCheckNatureLists.php new file mode 100644 index 000000000..d2adab76b --- /dev/null +++ b/app/adminapi/lists/quality/QualityCheckNatureLists.php @@ -0,0 +1,86 @@ + ['name', 'user'], + + ]; + } + + + /** + * @notes 获取检查性质列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/20 15:56 + */ + public function lists(): array + { + return QualityCheckNature::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'name', 'user', 'illustrate', 'date']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取检查性质数量 + * @return int + * @author likeadmin + * @date 2023/12/20 15:56 + */ + public function count(): int + { + return QualityCheckNature::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/quality/QualityCheckNatureLogic.php b/app/adminapi/logic/quality/QualityCheckNatureLogic.php new file mode 100644 index 000000000..bd7d204fc --- /dev/null +++ b/app/adminapi/logic/quality/QualityCheckNatureLogic.php @@ -0,0 +1,129 @@ + $params['org_id'], + 'dept_id' => $params['dept_id'], + 'name' => $params['name'], + 'user' => $params['user'], + 'illustrate' => $params['illustrate'], + 'date' => strtotime($params['date']), + 'add_user' => $admin_id, + 'update_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 2023/12/20 15:56 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + QualityCheckNature::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'name' => $params['name'], + 'user' => $params['user'], + 'illustrate' => $params['illustrate'], + 'date' => strtotime($params['date']), + 'update_user' => $admin_id, + '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 2023/12/20 15:56 + */ + public static function delete(array $params): bool + { + return QualityCheckNature::destroy($params['id']); + } + + + /** + * @notes 获取检查性质详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/20 15:56 + */ + public static function detail($params): array + { + $data = QualityCheckNature::findOrEmpty($params['id'])->toArray(); + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/quality/QualityCheckNatureValidate.php b/app/adminapi/validate/quality/QualityCheckNatureValidate.php new file mode 100644 index 000000000..941a81d81 --- /dev/null +++ b/app/adminapi/validate/quality/QualityCheckNatureValidate.php @@ -0,0 +1,120 @@ + 'require', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'name' => 'require', + 'user' => 'require', + 'date' => 'dateFormat:Y-m-d', + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'org_id.require' => '请选择组织', + 'dept_id.require' => '请选择部门', + 'name.require' => '请填写检查性质名称', + 'user.require' => '请填写创建人', + 'date.dateFormat' => '创建日期格式错误' + ]; + + + /** + * @notes 添加场景 + * @return QualityCheckNatureValidate + * @author likeadmin + * @date 2023/12/20 15:56 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return QualityCheckNatureValidate + * @author likeadmin + * @date 2023/12/20 15:56 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return QualityCheckNatureValidate + * @author likeadmin + * @date 2023/12/20 15:56 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return QualityCheckNatureValidate + * @author likeadmin + * @date 2023/12/20 15:56 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkOrg($value): bool|string + { + $data = Orgs::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门不属于当前选择的组织'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/safety/SafetyAccidentValidate.php b/app/adminapi/validate/safety/SafetyAccidentValidate.php index a22628223..49cf6cd8f 100644 --- a/app/adminapi/validate/safety/SafetyAccidentValidate.php +++ b/app/adminapi/validate/safety/SafetyAccidentValidate.php @@ -38,7 +38,7 @@ class SafetyAccidentValidate extends BaseValidate 'org_id' => 'require|checkOrg', 'dept_id' => 'require|checkDept', 'project_id' => 'require|checkProject', - 'happen_time' => 'date', + 'happen_time' => 'dateFormat:Y-m-d', 'file' => 'checkFile' ]; @@ -47,7 +47,7 @@ class SafetyAccidentValidate extends BaseValidate 'org_id.require' => '请选择组织', 'dept_id.require' => '请选择部门', 'project_id.require' => '请选择项目', - 'happen_time.date' => '发生时间格式错误', + 'happen_time.dateFormat' => '发生时间格式错误', ]; diff --git a/app/adminapi/validate/safety/SafetyCheckValidate.php b/app/adminapi/validate/safety/SafetyCheckValidate.php index 93bc1ddbc..2756d93e9 100644 --- a/app/adminapi/validate/safety/SafetyCheckValidate.php +++ b/app/adminapi/validate/safety/SafetyCheckValidate.php @@ -38,7 +38,7 @@ class SafetyCheckValidate extends BaseValidate 'org_id' => 'require|checkOrg', 'dept_id' => 'require|checkDept', 'project_id' => 'require|checkProject', - 'check_date' => 'date', + 'check_date' => 'dateFormat:Y-m-d', 'file' => 'checkFile' ]; @@ -47,7 +47,7 @@ class SafetyCheckValidate extends BaseValidate 'org_id.require' => '请选择组织', 'dept_id.require' => '请选择部门', 'project_id.require' => '请选择项目', - 'check_date.date' => '检查日期格式错误', + 'check_date.dateFormat' => '检查日期格式错误', ]; /** diff --git a/app/adminapi/validate/safety/SafetyEmergencyPlanValidate.php b/app/adminapi/validate/safety/SafetyEmergencyPlanValidate.php index 48795ccfa..342949ada 100644 --- a/app/adminapi/validate/safety/SafetyEmergencyPlanValidate.php +++ b/app/adminapi/validate/safety/SafetyEmergencyPlanValidate.php @@ -39,7 +39,7 @@ class SafetyEmergencyPlanValidate extends BaseValidate 'dept_id' => 'require|checkDept', 'project_id' => 'require|checkProject', 'name' => 'require', - 'happen_date' => 'date', + 'happen_date' => 'dateFormat:Y-m-d', 'file' => 'checkFile' ]; @@ -49,7 +49,7 @@ class SafetyEmergencyPlanValidate extends BaseValidate 'dept_id.require' => '请选择部门', 'project_id.require' => '请选择项目', 'name.require' => '请填写名称', - 'happen_date.date' => '发生日期格式错误', + 'happen_date.dateFormat' => '发生日期格式错误', ]; diff --git a/app/adminapi/validate/safety/SafetyEvaluateValidate.php b/app/adminapi/validate/safety/SafetyEvaluateValidate.php index 0baab74f7..77e73df0f 100644 --- a/app/adminapi/validate/safety/SafetyEvaluateValidate.php +++ b/app/adminapi/validate/safety/SafetyEvaluateValidate.php @@ -39,7 +39,7 @@ class SafetyEvaluateValidate extends BaseValidate 'dept_id' => 'require|checkDept', 'project_id' => 'require|checkProject', 'name' => 'require', - 'happen_date' => 'date', + 'happen_date' => 'dateFormat:Y-m-d', 'file' => 'checkFile' ]; @@ -49,7 +49,7 @@ class SafetyEvaluateValidate extends BaseValidate 'dept_id.require' => '请选择部门', 'project_id.require' => '请选择项目', 'name.require' => '请填写名称', - 'happen_date.date' => '发生日期格式错误', + 'happen_date.dateFormat' => '发生日期格式错误', ]; diff --git a/app/adminapi/validate/safety/SafetyEventValidate.php b/app/adminapi/validate/safety/SafetyEventValidate.php index ee292c3ae..d851df3ab 100644 --- a/app/adminapi/validate/safety/SafetyEventValidate.php +++ b/app/adminapi/validate/safety/SafetyEventValidate.php @@ -38,7 +38,7 @@ class SafetyEventValidate extends BaseValidate 'org_id' => 'require|checkOrg', 'dept_id' => 'require|checkDept', 'project_id' => 'require|checkProject', - 'happen_time' => 'date', + 'happen_time' => 'dateFormat:Y-m-d', 'file' => 'checkFile' ]; @@ -47,7 +47,7 @@ class SafetyEventValidate extends BaseValidate 'org_id.require' => '请选择组织', 'dept_id.require' => '请选择部门', 'project_id.require' => '请选择项目', - 'happen_time.date' => '发生时间格式错误', + 'happen_time.dateFormat' => '发生时间格式错误', ]; diff --git a/app/adminapi/validate/safety/SafetyModifyValidate.php b/app/adminapi/validate/safety/SafetyModifyValidate.php index b8ed28e60..7f63120ea 100644 --- a/app/adminapi/validate/safety/SafetyModifyValidate.php +++ b/app/adminapi/validate/safety/SafetyModifyValidate.php @@ -38,7 +38,7 @@ class SafetyModifyValidate extends BaseValidate 'org_id' => 'require|checkOrg', 'dept_id' => 'require|checkDept', 'project_id' => 'require|checkProject', - 'check_date' => 'date', + 'check_date' => 'dateFormat:Y-m-d', ]; protected $message = [ @@ -46,7 +46,7 @@ class SafetyModifyValidate extends BaseValidate 'org_id.require' => '请选择组织', 'dept_id.require' => '请选择部门', 'project_id.require' => '请选择项目', - 'check_date.date' => '检查日期格式错误', + 'check_date.dateFormat' => '检查日期格式错误', ]; diff --git a/app/adminapi/validate/safety/SafetyRehearsalValidate.php b/app/adminapi/validate/safety/SafetyRehearsalValidate.php index ed92a7141..860db4ec9 100644 --- a/app/adminapi/validate/safety/SafetyRehearsalValidate.php +++ b/app/adminapi/validate/safety/SafetyRehearsalValidate.php @@ -39,7 +39,7 @@ class SafetyRehearsalValidate extends BaseValidate 'dept_id' => 'require|checkDept', 'project_id' => 'require|checkProject', 'name' => 'require', - 'happen_date' => 'date', + 'happen_date' => 'dateFormat:Y-m-d', 'file' => 'checkFile' ]; @@ -49,7 +49,7 @@ class SafetyRehearsalValidate extends BaseValidate 'dept_id.require' => '请选择部门', 'project_id.require' => '请选择项目', 'name.require' => '请填写名称', - 'happen_date.date' => '发生日期格式错误', + 'happen_date.dateFormat' => '发生日期格式错误', ]; diff --git a/app/adminapi/validate/safety/SafetySuperviseValidate.php b/app/adminapi/validate/safety/SafetySuperviseValidate.php index 25ba0de4f..f7fd825ff 100644 --- a/app/adminapi/validate/safety/SafetySuperviseValidate.php +++ b/app/adminapi/validate/safety/SafetySuperviseValidate.php @@ -37,7 +37,7 @@ class SafetySuperviseValidate extends BaseValidate 'id' => 'require', 'org_id' => 'require|checkOrg', 'dept_id' => 'require|checkDept', - 'happen_time' => 'date', + 'happen_time' => 'dateFormat:Y-m-d', 'file' => 'checkFile' ]; @@ -45,7 +45,7 @@ class SafetySuperviseValidate extends BaseValidate 'id.require' => '缺少必要参数', 'org_id.require' => '请选择组织', 'dept_id.require' => '请选择部门', - 'happen_time.date' => '发生时间格式错误', + 'happen_time.dateFormat' => '发生时间格式错误', ]; diff --git a/app/common/model/quality/QualityCheckNature.php b/app/common/model/quality/QualityCheckNature.php new file mode 100644 index 000000000..c00b17063 --- /dev/null +++ b/app/common/model/quality/QualityCheckNature.php @@ -0,0 +1,37 @@ + Date: Wed, 20 Dec 2023 16:54:41 +0800 Subject: [PATCH 02/17] QualitySpecification --- .../QualitySpecificationController.php | 108 ++++++++++++++ .../quality/QualitySpecificationLists.php | 86 +++++++++++ .../quality/QualitySpecificationLogic.php | 133 ++++++++++++++++++ .../quality/QualitySpecificationValidate.php | 129 +++++++++++++++++ .../model/quality/QualitySpecification.php | 42 ++++++ 5 files changed, 498 insertions(+) create mode 100644 app/adminapi/controller/quality/QualitySpecificationController.php create mode 100644 app/adminapi/lists/quality/QualitySpecificationLists.php create mode 100644 app/adminapi/logic/quality/QualitySpecificationLogic.php create mode 100644 app/adminapi/validate/quality/QualitySpecificationValidate.php create mode 100644 app/common/model/quality/QualitySpecification.php diff --git a/app/adminapi/controller/quality/QualitySpecificationController.php b/app/adminapi/controller/quality/QualitySpecificationController.php new file mode 100644 index 000000000..c6a37bd29 --- /dev/null +++ b/app/adminapi/controller/quality/QualitySpecificationController.php @@ -0,0 +1,108 @@ +dataLists(new QualitySpecificationLists()); + } + + + /** + * @notes 添加质量规范 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 16:30 + */ + public function add() + { + $params = (new QualitySpecificationValidate())->post()->goCheck('add'); + $result = QualitySpecificationLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(QualitySpecificationLogic::getError()); + } + + + /** + * @notes 编辑质量规范 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 16:30 + */ + public function edit() + { + $params = (new QualitySpecificationValidate())->post()->goCheck('edit'); + $result = QualitySpecificationLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(QualitySpecificationLogic::getError()); + } + + + /** + * @notes 删除质量规范 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 16:30 + */ + public function delete() + { + $params = (new QualitySpecificationValidate())->post()->goCheck('delete'); + QualitySpecificationLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取质量规范详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 16:30 + */ + public function detail() + { + $params = (new QualitySpecificationValidate())->goCheck('detail'); + $result = QualitySpecificationLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/quality/QualitySpecificationLists.php b/app/adminapi/lists/quality/QualitySpecificationLists.php new file mode 100644 index 000000000..5118a454c --- /dev/null +++ b/app/adminapi/lists/quality/QualitySpecificationLists.php @@ -0,0 +1,86 @@ + ['name', 'type', 'release_dept'], + + ]; + } + + + /** + * @notes 获取质量规范列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/20 16:30 + */ + public function lists(): array + { + return QualitySpecification::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'name', 'type', 'release_date', 'release_dept', 'content', 'file']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取质量规范数量 + * @return int + * @author likeadmin + * @date 2023/12/20 16:30 + */ + public function count(): int + { + return QualitySpecification::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/quality/QualitySpecificationLogic.php b/app/adminapi/logic/quality/QualitySpecificationLogic.php new file mode 100644 index 000000000..d02da2da5 --- /dev/null +++ b/app/adminapi/logic/quality/QualitySpecificationLogic.php @@ -0,0 +1,133 @@ + $params['org_id'], + 'dept_id' => $params['dept_id'], + 'name' => $params['name'], + 'type' => $params['type'], + 'release_date' => strtotime($params['release_date']), + 'release_dept' => $params['release_dept'], + 'content' => $params['content'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'add_user' => $admin_id, + 'update_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 2023/12/20 16:30 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + QualitySpecification::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'name' => $params['name'], + 'type' => $params['type'], + 'release_date' => $params['release_date'], + 'release_dept' => $params['release_dept'], + 'content' => $params['content'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'update_user' => $admin_id, + '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 2023/12/20 16:30 + */ + public static function delete(array $params): bool + { + return QualitySpecification::destroy($params['id']); + } + + + /** + * @notes 获取质量规范详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/20 16:30 + */ + public static function detail($params): array + { + $data = QualitySpecification::findOrEmpty($params['id'])->toArray(); + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/quality/QualitySpecificationValidate.php b/app/adminapi/validate/quality/QualitySpecificationValidate.php new file mode 100644 index 000000000..3efb9e4d4 --- /dev/null +++ b/app/adminapi/validate/quality/QualitySpecificationValidate.php @@ -0,0 +1,129 @@ + 'require', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'name' => 'require', + 'release_date' => 'dateFormat:Y-m-d', + 'file' => 'checkFile' + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'org_id.require' => '请选择组织', + 'dept_id.require' => '请选择部门', + 'name.require' => '请填写规范名称', + 'release_date.dateFormat' => '发布时间格式错误', + ]; + + /** + * @notes 添加场景 + * @return QualitySpecificationValidate + * @author likeadmin + * @date 2023/12/20 16:30 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return QualitySpecificationValidate + * @author likeadmin + * @date 2023/12/20 16:30 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return QualitySpecificationValidate + * @author likeadmin + * @date 2023/12/20 16:30 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return QualitySpecificationValidate + * @author likeadmin + * @date 2023/12/20 16:30 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkOrg($value): bool|string + { + $data = Orgs::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门不属于当前选择的组织'; + } + return true; + } + + public function checkFile($value): bool|string + { + if($value != ''){ + $file = json_decode($value,true); + if(empty($file)){ + return '附件必须是json数组'; + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/quality/QualitySpecification.php b/app/common/model/quality/QualitySpecification.php new file mode 100644 index 000000000..386189052 --- /dev/null +++ b/app/common/model/quality/QualitySpecification.php @@ -0,0 +1,42 @@ + Date: Wed, 20 Dec 2023 17:19:22 +0800 Subject: [PATCH 03/17] QualityCheck --- .../quality/QualityCheckController.php | 108 +++++++++++++ .../lists/quality/QualityCheckLists.php | 90 +++++++++++ .../logic/quality/QualityCheckLogic.php | 147 ++++++++++++++++++ .../validate/quality/QualityCheckValidate.php | 128 +++++++++++++++ app/common/model/quality/QualityCheck.php | 37 +++++ 5 files changed, 510 insertions(+) create mode 100644 app/adminapi/controller/quality/QualityCheckController.php create mode 100644 app/adminapi/lists/quality/QualityCheckLists.php create mode 100644 app/adminapi/logic/quality/QualityCheckLogic.php create mode 100644 app/adminapi/validate/quality/QualityCheckValidate.php create mode 100644 app/common/model/quality/QualityCheck.php diff --git a/app/adminapi/controller/quality/QualityCheckController.php b/app/adminapi/controller/quality/QualityCheckController.php new file mode 100644 index 000000000..930e3e6bb --- /dev/null +++ b/app/adminapi/controller/quality/QualityCheckController.php @@ -0,0 +1,108 @@ +dataLists(new QualityCheckLists()); + } + + + /** + * @notes 添加质量检查 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 17:06 + */ + public function add() + { + $params = (new QualityCheckValidate())->post()->goCheck('add'); + $result = QualityCheckLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(QualityCheckLogic::getError()); + } + + + /** + * @notes 编辑质量检查 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 17:06 + */ + public function edit() + { + $params = (new QualityCheckValidate())->post()->goCheck('edit'); + $result = QualityCheckLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(QualityCheckLogic::getError()); + } + + + /** + * @notes 删除质量检查 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 17:06 + */ + public function delete() + { + $params = (new QualityCheckValidate())->post()->goCheck('delete'); + QualityCheckLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取质量检查详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 17:06 + */ + public function detail() + { + $params = (new QualityCheckValidate())->goCheck('detail'); + $result = QualityCheckLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/quality/QualityCheckLists.php b/app/adminapi/lists/quality/QualityCheckLists.php new file mode 100644 index 000000000..decdbdff7 --- /dev/null +++ b/app/adminapi/lists/quality/QualityCheckLists.php @@ -0,0 +1,90 @@ + ['check_nature', 'check_user', 'check_unit', 'modify_unit', 'resp_user'], + + ]; + } + + + /** + * @notes 获取质量检查列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/20 17:06 + */ + public function lists(): array + { + return QualityCheck::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'project_id', 'check_nature', 'check_date', 'modify_term', 'check_user', 'check_unit', 'modify_unit', 'resp_user', 'check_item', 'quality_hazards', 'check_result']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + $item['project_name'] = $project['name']; + $item['project_code'] = $project['project_code']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取质量检查数量 + * @return int + * @author likeadmin + * @date 2023/12/20 17:06 + */ + public function count(): int + { + return QualityCheck::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/quality/QualityCheckLogic.php b/app/adminapi/logic/quality/QualityCheckLogic.php new file mode 100644 index 000000000..fc1c98682 --- /dev/null +++ b/app/adminapi/logic/quality/QualityCheckLogic.php @@ -0,0 +1,147 @@ + $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'check_nature' => $params['check_nature'], + 'check_date' => strtotime($params['check_date']), + 'modify_term' => $params['modify_term'], + 'check_user' => $params['check_user'], + 'check_unit' => $params['check_unit'], + 'modify_unit' => $params['modify_unit'], + 'resp_user' => $params['resp_user'], + 'check_item' => $params['check_item'], + 'quality_hazards' => $params['quality_hazards'], + 'check_result' => $params['check_result'], + 'add_user' => $admin_id, + 'update_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 2023/12/20 17:06 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + QualityCheck::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'check_nature' => $params['check_nature'], + 'check_date' => strtotime($params['check_date']), + 'modify_term' => $params['modify_term'], + 'check_user' => $params['check_user'], + 'check_unit' => $params['check_unit'], + 'modify_unit' => $params['modify_unit'], + 'resp_user' => $params['resp_user'], + 'check_item' => $params['check_item'], + 'quality_hazards' => $params['quality_hazards'], + 'check_result' => $params['check_result'], + 'update_user' => $admin_id, + '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 2023/12/20 17:06 + */ + public static function delete(array $params): bool + { + return QualityCheck::destroy($params['id']); + } + + + /** + * @notes 获取质量检查详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/20 17:06 + */ + public static function detail($params): array + { + $data = QualityCheck::findOrEmpty($params['id'])->toArray(); + $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['project_name'] = $project['name']; + $data['project_code'] = $project['project_code']; + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/quality/QualityCheckValidate.php b/app/adminapi/validate/quality/QualityCheckValidate.php new file mode 100644 index 000000000..3336b764c --- /dev/null +++ b/app/adminapi/validate/quality/QualityCheckValidate.php @@ -0,0 +1,128 @@ + 'require', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'project_id' => 'require|checkProject', + 'check_date' => 'dateFormat:Y-m-d', + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'org_id.require' => '请选择组织', + 'dept_id.require' => '请选择部门', + 'project_id.require' => '请选择项目', + 'check_date.dateFormat' => '检查日期格式错误', + ]; + + + /** + * @notes 添加场景 + * @return QualityCheckValidate + * @author likeadmin + * @date 2023/12/20 17:06 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return QualityCheckValidate + * @author likeadmin + * @date 2023/12/20 17:06 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return QualityCheckValidate + * @author likeadmin + * @date 2023/12/20 17:06 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return QualityCheckValidate + * @author likeadmin + * @date 2023/12/20 17:06 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkOrg($value): bool|string + { + $data = Orgs::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门不属于当前选择的组织'; + } + return true; + } + + public function checkProject($value): bool|string + { + $data = Project::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '项目不存在'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/quality/QualityCheck.php b/app/common/model/quality/QualityCheck.php new file mode 100644 index 000000000..fca9d9d5f --- /dev/null +++ b/app/common/model/quality/QualityCheck.php @@ -0,0 +1,37 @@ + Date: Wed, 20 Dec 2023 17:40:49 +0800 Subject: [PATCH 04/17] QualityModify --- .../quality/QualityModifyController.php | 108 +++++++++++++ .../lists/quality/QualityModifyLists.php | 90 +++++++++++ .../logic/quality/QualityModifyLogic.php | 142 ++++++++++++++++++ .../quality/QualityModifyValidate.php | 127 ++++++++++++++++ app/common/model/quality/QualityModify.php | 37 +++++ 5 files changed, 504 insertions(+) create mode 100644 app/adminapi/controller/quality/QualityModifyController.php create mode 100644 app/adminapi/lists/quality/QualityModifyLists.php create mode 100644 app/adminapi/logic/quality/QualityModifyLogic.php create mode 100644 app/adminapi/validate/quality/QualityModifyValidate.php create mode 100644 app/common/model/quality/QualityModify.php diff --git a/app/adminapi/controller/quality/QualityModifyController.php b/app/adminapi/controller/quality/QualityModifyController.php new file mode 100644 index 000000000..06694a1d8 --- /dev/null +++ b/app/adminapi/controller/quality/QualityModifyController.php @@ -0,0 +1,108 @@ +dataLists(new QualityModifyLists()); + } + + + /** + * @notes 添加质量整改 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public function add() + { + $params = (new QualityModifyValidate())->post()->goCheck('add'); + $result = QualityModifyLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(QualityModifyLogic::getError()); + } + + + /** + * @notes 编辑质量整改 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public function edit() + { + $params = (new QualityModifyValidate())->post()->goCheck('edit'); + $result = QualityModifyLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(QualityModifyLogic::getError()); + } + + + /** + * @notes 删除质量整改 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public function delete() + { + $params = (new QualityModifyValidate())->post()->goCheck('delete'); + QualityModifyLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取质量整改详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public function detail() + { + $params = (new QualityModifyValidate())->goCheck('detail'); + $result = QualityModifyLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/quality/QualityModifyLists.php b/app/adminapi/lists/quality/QualityModifyLists.php new file mode 100644 index 000000000..a53b82a92 --- /dev/null +++ b/app/adminapi/lists/quality/QualityModifyLists.php @@ -0,0 +1,90 @@ + ['check_nature', 'check_user', 'check_unit', 'modify_unit', 'resp_user', 'copy_user'], + + ]; + } + + + /** + * @notes 获取质量整改列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public function lists(): array + { + return QualityModify::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'project_id', 'check_nature', 'check_date', 'modify_term', 'check_user', 'check_unit', 'modify_unit', 'resp_user', 'copy_user', 'check_item', 'quality_hazards', 'check_result']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + $item['project_name'] = $project['name']; + $item['project_code'] = $project['project_code']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取质量整改数量 + * @return int + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public function count(): int + { + return QualityModify::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/quality/QualityModifyLogic.php b/app/adminapi/logic/quality/QualityModifyLogic.php new file mode 100644 index 000000000..34bfa5ffd --- /dev/null +++ b/app/adminapi/logic/quality/QualityModifyLogic.php @@ -0,0 +1,142 @@ + $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'check_nature' => $params['check_nature'], + 'check_date' => strtotime($params['check_date']), + 'modify_term' => $params['modify_term'], + 'check_user' => $params['check_user'], + 'check_unit' => $params['check_unit'], + 'modify_unit' => $params['modify_unit'], + 'resp_user' => $params['resp_user'], + 'copy_user' => $params['copy_user'], + 'check_item' => $params['check_item'], + 'quality_hazards' => $params['quality_hazards'], + 'check_result' => $params['check_result'], + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑质量整改 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + QualityModify::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'check_nature' => $params['check_nature'], + 'check_date' => strtotime($params['check_date']), + 'modify_term' => $params['modify_term'], + 'check_user' => $params['check_user'], + 'check_unit' => $params['check_unit'], + 'modify_unit' => $params['modify_unit'], + 'resp_user' => $params['resp_user'], + 'copy_user' => $params['copy_user'], + 'check_item' => $params['check_item'], + 'quality_hazards' => $params['quality_hazards'], + 'check_result' => $params['check_result'], + '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 2023/12/20 17:28 + */ + public static function delete(array $params): bool + { + return QualityModify::destroy($params['id']); + } + + + /** + * @notes 获取质量整改详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public static function detail($params): array + { + $data = QualityModify::findOrEmpty($params['id'])->toArray(); + $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['project_name'] = $project['name']; + $data['project_code'] = $project['project_code']; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/quality/QualityModifyValidate.php b/app/adminapi/validate/quality/QualityModifyValidate.php new file mode 100644 index 000000000..a3889d726 --- /dev/null +++ b/app/adminapi/validate/quality/QualityModifyValidate.php @@ -0,0 +1,127 @@ + 'require', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'project_id' => 'require|checkProject', + 'check_date' => 'dateFormat:Y-m-d', + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'org_id.require' => '请选择组织', + 'dept_id.require' => '请选择部门', + 'project_id.require' => '请选择项目', + 'check_date.dateFormat' => '检查日期格式错误', + ]; + + + /** + * @notes 添加场景 + * @return QualityModifyValidate + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return QualityModifyValidate + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return QualityModifyValidate + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return QualityModifyValidate + * @author likeadmin + * @date 2023/12/20 17:28 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkOrg($value): bool|string + { + $data = Orgs::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门不属于当前选择的组织'; + } + return true; + } + + public function checkProject($value): bool|string + { + $data = Project::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '项目不存在'; + } + return true; + } +} \ No newline at end of file diff --git a/app/common/model/quality/QualityModify.php b/app/common/model/quality/QualityModify.php new file mode 100644 index 000000000..9e5f5a7b4 --- /dev/null +++ b/app/common/model/quality/QualityModify.php @@ -0,0 +1,37 @@ + Date: Thu, 21 Dec 2023 09:33:24 +0800 Subject: [PATCH 05/17] QualityMbo --- .../quality/QualityMboController.php | 108 ++++++++++++++ .../lists/quality/QualityMboLists.php | 90 +++++++++++ .../logic/quality/QualityMboLogic.php | 139 +++++++++++++++++ .../validate/quality/QualityMboValidate.php | 141 ++++++++++++++++++ app/common/model/quality/QualityMbo.php | 37 +++++ 5 files changed, 515 insertions(+) create mode 100644 app/adminapi/controller/quality/QualityMboController.php create mode 100644 app/adminapi/lists/quality/QualityMboLists.php create mode 100644 app/adminapi/logic/quality/QualityMboLogic.php create mode 100644 app/adminapi/validate/quality/QualityMboValidate.php create mode 100644 app/common/model/quality/QualityMbo.php diff --git a/app/adminapi/controller/quality/QualityMboController.php b/app/adminapi/controller/quality/QualityMboController.php new file mode 100644 index 000000000..b40082091 --- /dev/null +++ b/app/adminapi/controller/quality/QualityMboController.php @@ -0,0 +1,108 @@ +dataLists(new QualityMboLists()); + } + + + /** + * @notes 添加目标管理 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 09:17 + */ + public function add() + { + $params = (new QualityMboValidate())->post()->goCheck('add'); + $result = QualityMboLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(QualityMboLogic::getError()); + } + + + /** + * @notes 编辑目标管理 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 09:17 + */ + public function edit() + { + $params = (new QualityMboValidate())->post()->goCheck('edit'); + $result = QualityMboLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(QualityMboLogic::getError()); + } + + + /** + * @notes 删除目标管理 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 09:17 + */ + public function delete() + { + $params = (new QualityMboValidate())->post()->goCheck('delete'); + QualityMboLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取目标管理详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 09:17 + */ + public function detail() + { + $params = (new QualityMboValidate())->goCheck('detail'); + $result = QualityMboLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/quality/QualityMboLists.php b/app/adminapi/lists/quality/QualityMboLists.php new file mode 100644 index 000000000..198db5eff --- /dev/null +++ b/app/adminapi/lists/quality/QualityMboLists.php @@ -0,0 +1,90 @@ + ['target'], + + ]; + } + + + /** + * @notes 获取目标管理列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/21 09:17 + */ + public function lists(): array + { + return QualityMbo::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'project_id', 'target', 'pass_rate', 'target_specification', 'basic_requirements', 'allowable_deviation', 'file']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + $item['project_name'] = $project['name']; + $item['project_code'] = $project['project_code']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取目标管理数量 + * @return int + * @author likeadmin + * @date 2023/12/21 09:17 + */ + public function count(): int + { + return QualityMbo::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/quality/QualityMboLogic.php b/app/adminapi/logic/quality/QualityMboLogic.php new file mode 100644 index 000000000..3be93bd7b --- /dev/null +++ b/app/adminapi/logic/quality/QualityMboLogic.php @@ -0,0 +1,139 @@ + $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'target' => $params['target'], + 'pass_rate' => $params['pass_rate'], + 'target_specification' => $params['target_specification'], + 'basic_requirements' => $params['basic_requirements'], + 'allowable_deviation' => $params['allowable_deviation'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'add_user' => $admin_id, + 'update_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 2023/12/21 09:17 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + QualityMbo::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'target' => $params['target'], + 'pass_rate' => $params['pass_rate'], + 'target_specification' => $params['target_specification'], + 'basic_requirements' => $params['basic_requirements'], + 'allowable_deviation' => $params['allowable_deviation'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'update_user' => $admin_id, + '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 2023/12/21 09:17 + */ + public static function delete(array $params): bool + { + return QualityMbo::destroy($params['id']); + } + + + /** + * @notes 获取目标管理详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/21 09:17 + */ + public static function detail($params): array + { + $data = QualityMbo::findOrEmpty($params['id'])->toArray(); + $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['project_name'] = $project['name']; + $data['project_code'] = $project['project_code']; + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/quality/QualityMboValidate.php b/app/adminapi/validate/quality/QualityMboValidate.php new file mode 100644 index 000000000..94380c289 --- /dev/null +++ b/app/adminapi/validate/quality/QualityMboValidate.php @@ -0,0 +1,141 @@ + 'require', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'project_id' => 'require|checkProject', + 'pass_rate' => 'float|egt:0', + 'file' => 'checkFile' + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'org_id.require' => '请选择组织', + 'dept_id.require' => '请选择部门', + 'project_id.require' => '请选择项目', + 'pass_rate.float' => '合格率值必须是数字', + 'pass_rate.egt' => '合格率值必须大于等于0', + ]; + + + /** + * @notes 添加场景 + * @return QualityMboValidate + * @author likeadmin + * @date 2023/12/21 09:17 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return QualityMboValidate + * @author likeadmin + * @date 2023/12/21 09:17 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return QualityMboValidate + * @author likeadmin + * @date 2023/12/21 09:17 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return QualityMboValidate + * @author likeadmin + * @date 2023/12/21 09:17 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkOrg($value): bool|string + { + $data = Orgs::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门不属于当前选择的组织'; + } + return true; + } + + public function checkProject($value): bool|string + { + $data = Project::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '项目不存在'; + } + return true; + } + + public function checkFile($value): bool|string + { + if($value != ''){ + $file = json_decode($value,true); + if(empty($file)){ + return '附件必须是json数组'; + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/quality/QualityMbo.php b/app/common/model/quality/QualityMbo.php new file mode 100644 index 000000000..65b354626 --- /dev/null +++ b/app/common/model/quality/QualityMbo.php @@ -0,0 +1,37 @@ + Date: Thu, 21 Dec 2023 09:59:08 +0800 Subject: [PATCH 06/17] QualityEvent --- .../quality/QualityEventController.php | 108 ++++++++++++++ .../lists/quality/QualityEventLists.php | 91 +++++++++++ .../logic/quality/QualityEventLogic.php | 140 +++++++++++++++++ .../validate/quality/QualityEventValidate.php | 141 ++++++++++++++++++ app/common/model/quality/QualityEvent.php | 42 ++++++ 5 files changed, 522 insertions(+) create mode 100644 app/adminapi/controller/quality/QualityEventController.php create mode 100644 app/adminapi/lists/quality/QualityEventLists.php create mode 100644 app/adminapi/logic/quality/QualityEventLogic.php create mode 100644 app/adminapi/validate/quality/QualityEventValidate.php create mode 100644 app/common/model/quality/QualityEvent.php diff --git a/app/adminapi/controller/quality/QualityEventController.php b/app/adminapi/controller/quality/QualityEventController.php new file mode 100644 index 000000000..ce9c8909e --- /dev/null +++ b/app/adminapi/controller/quality/QualityEventController.php @@ -0,0 +1,108 @@ +dataLists(new QualityEventLists()); + } + + + /** + * @notes 添加质量事件 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 09:42 + */ + public function add() + { + $params = (new QualityEventValidate())->post()->goCheck('add'); + $result = QualityEventLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(QualityEventLogic::getError()); + } + + + /** + * @notes 编辑质量事件 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 09:42 + */ + public function edit() + { + $params = (new QualityEventValidate())->post()->goCheck('edit'); + $result = QualityEventLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(QualityEventLogic::getError()); + } + + + /** + * @notes 删除质量事件 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 09:42 + */ + public function delete() + { + $params = (new QualityEventValidate())->post()->goCheck('delete'); + QualityEventLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取质量事件详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 09:42 + */ + public function detail() + { + $params = (new QualityEventValidate())->goCheck('detail'); + $result = QualityEventLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/quality/QualityEventLists.php b/app/adminapi/lists/quality/QualityEventLists.php new file mode 100644 index 000000000..2ce8499e5 --- /dev/null +++ b/app/adminapi/lists/quality/QualityEventLists.php @@ -0,0 +1,91 @@ + ['happen_date'], + '%like%' => ['name', 'type'], + + ]; + } + + + /** + * @notes 获取质量事件列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/21 09:42 + */ + public function lists(): array + { + return QualityEvent::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'project_id', 'name', 'type', 'happen_date', 'content', 'remark', 'file']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + $item['project_name'] = $project['name']; + $item['project_code'] = $project['project_code']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取质量事件数量 + * @return int + * @author likeadmin + * @date 2023/12/21 09:42 + */ + public function count(): int + { + return QualityEvent::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/quality/QualityEventLogic.php b/app/adminapi/logic/quality/QualityEventLogic.php new file mode 100644 index 000000000..9534d1629 --- /dev/null +++ b/app/adminapi/logic/quality/QualityEventLogic.php @@ -0,0 +1,140 @@ + $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'name' => $params['name'], + 'type' => $params['type'], + 'happen_date' => strtotime($params['happen_date']), + 'content' => $params['content'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'add_user' => $admin_id, + 'update_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 2023/12/21 09:42 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + QualityEvent::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'name' => $params['name'], + 'type' => $params['type'], + 'happen_date' => strtotime($params['happen_date']), + 'content' => $params['content'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'update_user' => $admin_id, + '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 2023/12/21 09:42 + */ + public static function delete(array $params): bool + { + return QualityEvent::destroy($params['id']); + } + + + /** + * @notes 获取质量事件详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/21 09:42 + */ + public static function detail($params): array + { + $data = QualityEvent::findOrEmpty($params['id'])->toArray(); + $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['project_name'] = $project['name']; + $data['project_code'] = $project['project_code']; + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/quality/QualityEventValidate.php b/app/adminapi/validate/quality/QualityEventValidate.php new file mode 100644 index 000000000..9f4109ec6 --- /dev/null +++ b/app/adminapi/validate/quality/QualityEventValidate.php @@ -0,0 +1,141 @@ + 'require', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'project_id' => 'require|checkProject', + 'name' => 'require', + 'happen_date' => 'dateFormat:Y-m-d', + 'file' => 'checkFile', + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'org_id.require' => '请选择组织', + 'dept_id.require' => '请选择部门', + 'project_id.require' => '请选择项目', + 'name.require' => '请填写事件名称', + 'happen_date.dateFormat' => '发生日期格式错误', + ]; + + /** + * @notes 添加场景 + * @return QualityEventValidate + * @author likeadmin + * @date 2023/12/21 09:42 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return QualityEventValidate + * @author likeadmin + * @date 2023/12/21 09:42 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return QualityEventValidate + * @author likeadmin + * @date 2023/12/21 09:42 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return QualityEventValidate + * @author likeadmin + * @date 2023/12/21 09:42 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkOrg($value): bool|string + { + $data = Orgs::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门不属于当前选择的组织'; + } + return true; + } + + public function checkProject($value): bool|string + { + $data = Project::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '项目不存在'; + } + return true; + } + + public function checkFile($value): bool|string + { + if($value != ''){ + $file = json_decode($value,true); + if(empty($file)){ + return '附件必须是json数组'; + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/quality/QualityEvent.php b/app/common/model/quality/QualityEvent.php new file mode 100644 index 000000000..8a98355e6 --- /dev/null +++ b/app/common/model/quality/QualityEvent.php @@ -0,0 +1,42 @@ + Date: Thu, 21 Dec 2023 10:22:51 +0800 Subject: [PATCH 07/17] fixed --- app/adminapi/logic/safety/SafetySuperviseLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/adminapi/logic/safety/SafetySuperviseLogic.php b/app/adminapi/logic/safety/SafetySuperviseLogic.php index f146f9cea..476c34c1a 100644 --- a/app/adminapi/logic/safety/SafetySuperviseLogic.php +++ b/app/adminapi/logic/safety/SafetySuperviseLogic.php @@ -84,7 +84,7 @@ class SafetySuperviseLogic extends BaseLogic 'dept_id' => $params['dept_id'], 'project_name' => $params['project_name'], 'name' => $params['name'], - 'happen_time' => $params['happen_time'], + 'happen_time' => strtotime($params['happen_time']), 'device_accident' => $params['device_accident'], 'content' => $params['content'], 'remark' => $params['remark'], From efb38e120d9c37f4e3e0e571a3fb3ce65a6ec84f Mon Sep 17 00:00:00 2001 From: weiz Date: Thu, 21 Dec 2023 14:24:50 +0800 Subject: [PATCH 08/17] QualityAccident --- .../quality/QualityAccidentController.php | 108 +++++++++++++ .../lists/quality/QualityAccidentLists.php | 91 +++++++++++ .../logic/quality/QualityAccidentLogic.php | 147 ++++++++++++++++++ .../quality/QualityAccidentValidate.php | 140 +++++++++++++++++ app/common/model/quality/QualityAccident.php | 42 +++++ 5 files changed, 528 insertions(+) create mode 100644 app/adminapi/controller/quality/QualityAccidentController.php create mode 100644 app/adminapi/lists/quality/QualityAccidentLists.php create mode 100644 app/adminapi/logic/quality/QualityAccidentLogic.php create mode 100644 app/adminapi/validate/quality/QualityAccidentValidate.php create mode 100644 app/common/model/quality/QualityAccident.php diff --git a/app/adminapi/controller/quality/QualityAccidentController.php b/app/adminapi/controller/quality/QualityAccidentController.php new file mode 100644 index 000000000..415486594 --- /dev/null +++ b/app/adminapi/controller/quality/QualityAccidentController.php @@ -0,0 +1,108 @@ +dataLists(new QualityAccidentLists()); + } + + + /** + * @notes 添加质量事故 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 14:03 + */ + public function add() + { + $params = (new QualityAccidentValidate())->post()->goCheck('add'); + $result = QualityAccidentLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(QualityAccidentLogic::getError()); + } + + + /** + * @notes 编辑质量事故 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 14:03 + */ + public function edit() + { + $params = (new QualityAccidentValidate())->post()->goCheck('edit'); + $result = QualityAccidentLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(QualityAccidentLogic::getError()); + } + + + /** + * @notes 删除质量事故 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 14:03 + */ + public function delete() + { + $params = (new QualityAccidentValidate())->post()->goCheck('delete'); + QualityAccidentLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取质量事故详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 14:03 + */ + public function detail() + { + $params = (new QualityAccidentValidate())->goCheck('detail'); + $result = QualityAccidentLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/quality/QualityAccidentLists.php b/app/adminapi/lists/quality/QualityAccidentLists.php new file mode 100644 index 000000000..72521559c --- /dev/null +++ b/app/adminapi/lists/quality/QualityAccidentLists.php @@ -0,0 +1,91 @@ + ['happen_date'], + '%like%' => ['type', 'device_accident'], + + ]; + } + + + /** + * @notes 获取质量事故列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/21 14:03 + */ + public function lists(): array + { + return QualityAccident::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'project_id', 'happen_date', 'type', 'device_accident', 'contractor_user', 'our_company_user', 'not_our_company_user', 'content', 'remark', 'file', 'add_user', 'update_user']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + $item['project_name'] = $project['name']; + $item['project_code'] = $project['project_code']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取质量事故数量 + * @return int + * @author likeadmin + * @date 2023/12/21 14:03 + */ + public function count(): int + { + return QualityAccident::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/quality/QualityAccidentLogic.php b/app/adminapi/logic/quality/QualityAccidentLogic.php new file mode 100644 index 000000000..fa37d305f --- /dev/null +++ b/app/adminapi/logic/quality/QualityAccidentLogic.php @@ -0,0 +1,147 @@ + $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'happen_date' => strtotime($params['happen_date']), + 'type' => $params['type'], + 'device_accident' => $params['device_accident'], + 'contractor_user' => $params['contractor_user'], + 'our_company_user' => $params['our_company_user'], + 'not_our_company_user' => $params['not_our_company_user'], + 'content' => $params['content'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'add_user' => $admin_id, + 'update_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 2023/12/21 14:03 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + QualityAccident::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'happen_date' => strtotime($params['happen_date']), + 'type' => $params['type'], + 'device_accident' => $params['device_accident'], + 'contractor_user' => $params['contractor_user'], + 'our_company_user' => $params['our_company_user'], + 'not_our_company_user' => $params['not_our_company_user'], + 'content' => $params['content'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'update_user' => $admin_id, + '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 2023/12/21 14:03 + */ + public static function delete(array $params): bool + { + return QualityAccident::destroy($params['id']); + } + + + /** + * @notes 获取质量事故详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/21 14:03 + */ + public static function detail($params): array + { + $data = QualityAccident::findOrEmpty($params['id'])->toArray(); + $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['project_name'] = $project['name']; + $data['project_code'] = $project['project_code']; + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/quality/QualityAccidentValidate.php b/app/adminapi/validate/quality/QualityAccidentValidate.php new file mode 100644 index 000000000..66e474d29 --- /dev/null +++ b/app/adminapi/validate/quality/QualityAccidentValidate.php @@ -0,0 +1,140 @@ + 'require', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'project_id' => 'require|checkProject', + 'happen_date' => 'dateFormat:Y-m-d', + 'file' => 'checkFile', + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'org_id.require' => '请选择组织', + 'dept_id.require' => '请选择部门', + 'project_id.require' => '请选择项目', + 'happen_date.dateFormat' => '发生日期格式错误', + ]; + + + /** + * @notes 添加场景 + * @return QualityAccidentValidate + * @author likeadmin + * @date 2023/12/21 14:03 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return QualityAccidentValidate + * @author likeadmin + * @date 2023/12/21 14:03 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return QualityAccidentValidate + * @author likeadmin + * @date 2023/12/21 14:03 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return QualityAccidentValidate + * @author likeadmin + * @date 2023/12/21 14:03 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkOrg($value): bool|string + { + $data = Orgs::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门不属于当前选择的组织'; + } + return true; + } + + public function checkProject($value): bool|string + { + $data = Project::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '项目不存在'; + } + return true; + } + + public function checkFile($value): bool|string + { + if($value != ''){ + $file = json_decode($value,true); + if(empty($file)){ + return '附件必须是json数组'; + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/quality/QualityAccident.php b/app/common/model/quality/QualityAccident.php new file mode 100644 index 000000000..5ec4ccf02 --- /dev/null +++ b/app/common/model/quality/QualityAccident.php @@ -0,0 +1,42 @@ + Date: Thu, 21 Dec 2023 14:53:54 +0800 Subject: [PATCH 09/17] QualitySupervise --- .../quality/QualitySuperviseController.php | 108 ++++++++++++++ .../lists/quality/QualitySuperviseLists.php | 89 +++++++++++ .../logic/quality/QualitySuperviseLogic.php | 135 +++++++++++++++++ .../quality/QualitySuperviseValidate.php | 140 ++++++++++++++++++ app/common/model/quality/QualitySupervise.php | 42 ++++++ 5 files changed, 514 insertions(+) create mode 100644 app/adminapi/controller/quality/QualitySuperviseController.php create mode 100644 app/adminapi/lists/quality/QualitySuperviseLists.php create mode 100644 app/adminapi/logic/quality/QualitySuperviseLogic.php create mode 100644 app/adminapi/validate/quality/QualitySuperviseValidate.php create mode 100644 app/common/model/quality/QualitySupervise.php diff --git a/app/adminapi/controller/quality/QualitySuperviseController.php b/app/adminapi/controller/quality/QualitySuperviseController.php new file mode 100644 index 000000000..991a6b48a --- /dev/null +++ b/app/adminapi/controller/quality/QualitySuperviseController.php @@ -0,0 +1,108 @@ +dataLists(new QualitySuperviseLists()); + } + + + /** + * @notes 添加质量监督 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 14:32 + */ + public function add() + { + $params = (new QualitySuperviseValidate())->post()->goCheck('add'); + $result = QualitySuperviseLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(QualitySuperviseLogic::getError()); + } + + + /** + * @notes 编辑质量监督 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 14:32 + */ + public function edit() + { + $params = (new QualitySuperviseValidate())->post()->goCheck('edit'); + $result = QualitySuperviseLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(QualitySuperviseLogic::getError()); + } + + + /** + * @notes 删除质量监督 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 14:32 + */ + public function delete() + { + $params = (new QualitySuperviseValidate())->post()->goCheck('delete'); + QualitySuperviseLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取质量监督详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 14:32 + */ + public function detail() + { + $params = (new QualitySuperviseValidate())->goCheck('detail'); + $result = QualitySuperviseLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/quality/QualitySuperviseLists.php b/app/adminapi/lists/quality/QualitySuperviseLists.php new file mode 100644 index 000000000..0a0340ecb --- /dev/null +++ b/app/adminapi/lists/quality/QualitySuperviseLists.php @@ -0,0 +1,89 @@ + ['happen_date'], + ]; + } + + + /** + * @notes 获取质量监督列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/21 14:32 + */ + public function lists(): array + { + return QualitySupervise::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'project_id', 'happen_date', 'content', 'remark', 'file']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + $item['project_name'] = $project['name']; + $item['project_code'] = $project['project_code']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取质量监督数量 + * @return int + * @author likeadmin + * @date 2023/12/21 14:32 + */ + public function count(): int + { + return QualitySupervise::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/quality/QualitySuperviseLogic.php b/app/adminapi/logic/quality/QualitySuperviseLogic.php new file mode 100644 index 000000000..389c18c52 --- /dev/null +++ b/app/adminapi/logic/quality/QualitySuperviseLogic.php @@ -0,0 +1,135 @@ + $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'happen_date' => strtotime($params['happen_date']), + 'content' => $params['content'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'add_user' => $admin_id, + 'update_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 2023/12/21 14:32 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + QualitySupervise::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'happen_date' => strtotime($params['happen_date']), + 'content' => $params['content'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'update_user' => $admin_id, + '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 2023/12/21 14:32 + */ + public static function delete(array $params): bool + { + return QualitySupervise::destroy($params['id']); + } + + + /** + * @notes 获取质量监督详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/21 14:32 + */ + public static function detail($params): array + { + $data = QualitySupervise::findOrEmpty($params['id'])->toArray(); + $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['project_name'] = $project['name']; + $data['project_code'] = $project['project_code']; + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/quality/QualitySuperviseValidate.php b/app/adminapi/validate/quality/QualitySuperviseValidate.php new file mode 100644 index 000000000..b1e76cc6e --- /dev/null +++ b/app/adminapi/validate/quality/QualitySuperviseValidate.php @@ -0,0 +1,140 @@ + 'require', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'project_id' => 'require|checkProject', + 'happen_date' => 'dateFormat:Y-m-d', + 'file' => 'checkFile', + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'org_id.require' => '请选择组织', + 'dept_id.require' => '请选择部门', + 'project_id.require' => '请选择项目', + 'happen_date.dateFormat' => '发生日期格式错误', + ]; + + + /** + * @notes 添加场景 + * @return QualitySuperviseValidate + * @author likeadmin + * @date 2023/12/21 14:32 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return QualitySuperviseValidate + * @author likeadmin + * @date 2023/12/21 14:32 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return QualitySuperviseValidate + * @author likeadmin + * @date 2023/12/21 14:32 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return QualitySuperviseValidate + * @author likeadmin + * @date 2023/12/21 14:32 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkOrg($value): bool|string + { + $data = Orgs::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门不属于当前选择的组织'; + } + return true; + } + + public function checkProject($value): bool|string + { + $data = Project::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '项目不存在'; + } + return true; + } + + public function checkFile($value): bool|string + { + if($value != ''){ + $file = json_decode($value,true); + if(empty($file)){ + return '附件必须是json数组'; + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/quality/QualitySupervise.php b/app/common/model/quality/QualitySupervise.php new file mode 100644 index 000000000..51df3a710 --- /dev/null +++ b/app/common/model/quality/QualitySupervise.php @@ -0,0 +1,42 @@ + Date: Thu, 21 Dec 2023 15:30:35 +0800 Subject: [PATCH 10/17] QualityAccept --- .../quality/QualityAcceptController.php | 108 ++++++++++++++ .../lists/quality/QualityAcceptLists.php | 90 +++++++++++ .../logic/quality/QualityAcceptLogic.php | 140 ++++++++++++++++++ .../quality/QualityAcceptValidate.php | 140 ++++++++++++++++++ app/common/model/quality/QualityAccept.php | 42 ++++++ 5 files changed, 520 insertions(+) create mode 100644 app/adminapi/controller/quality/QualityAcceptController.php create mode 100644 app/adminapi/lists/quality/QualityAcceptLists.php create mode 100644 app/adminapi/logic/quality/QualityAcceptLogic.php create mode 100644 app/adminapi/validate/quality/QualityAcceptValidate.php create mode 100644 app/common/model/quality/QualityAccept.php diff --git a/app/adminapi/controller/quality/QualityAcceptController.php b/app/adminapi/controller/quality/QualityAcceptController.php new file mode 100644 index 000000000..0c8f4f46b --- /dev/null +++ b/app/adminapi/controller/quality/QualityAcceptController.php @@ -0,0 +1,108 @@ +dataLists(new QualityAcceptLists()); + } + + + /** + * @notes 添加质量验收 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 15:03 + */ + public function add() + { + $params = (new QualityAcceptValidate())->post()->goCheck('add'); + $result = QualityAcceptLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(QualityAcceptLogic::getError()); + } + + + /** + * @notes 编辑质量验收 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 15:03 + */ + public function edit() + { + $params = (new QualityAcceptValidate())->post()->goCheck('edit'); + $result = QualityAcceptLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(QualityAcceptLogic::getError()); + } + + + /** + * @notes 删除质量验收 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 15:03 + */ + public function delete() + { + $params = (new QualityAcceptValidate())->post()->goCheck('delete'); + QualityAcceptLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取质量验收详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 15:03 + */ + public function detail() + { + $params = (new QualityAcceptValidate())->goCheck('detail'); + $result = QualityAcceptLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/quality/QualityAcceptLists.php b/app/adminapi/lists/quality/QualityAcceptLists.php new file mode 100644 index 000000000..9ac4caf54 --- /dev/null +++ b/app/adminapi/lists/quality/QualityAcceptLists.php @@ -0,0 +1,90 @@ + ['accept_date'], + '%like%' => ['type', 'engineer'], + ]; + } + + + /** + * @notes 获取质量验收列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/21 15:03 + */ + public function lists(): array + { + return QualityAccept::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'project_id', 'accept_date', 'type', 'engineer', 'content', 'remark', 'file']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + $item['project_name'] = $project['name']; + $item['project_code'] = $project['project_code']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取质量验收数量 + * @return int + * @author likeadmin + * @date 2023/12/21 15:03 + */ + public function count(): int + { + return QualityAccept::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/quality/QualityAcceptLogic.php b/app/adminapi/logic/quality/QualityAcceptLogic.php new file mode 100644 index 000000000..69064810d --- /dev/null +++ b/app/adminapi/logic/quality/QualityAcceptLogic.php @@ -0,0 +1,140 @@ + $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'accept_date' => strtotime($params['accept_date']), + 'type' => $params['type'], + 'engineer' => $params['engineer'], + 'content' => $params['content'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'add_user' => $admin_id, + 'update_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 2023/12/21 15:03 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + QualityAccept::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'accept_date' => strtotime($params['accept_date']), + 'type' => $params['type'], + 'engineer' => $params['engineer'], + 'content' => $params['content'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'update_user' => $admin_id, + '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 2023/12/21 15:03 + */ + public static function delete(array $params): bool + { + return QualityAccept::destroy($params['id']); + } + + + /** + * @notes 获取质量验收详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/21 15:03 + */ + public static function detail($params): array + { + $data = QualityAccept::findOrEmpty($params['id'])->toArray(); + if(empty($data)) return []; + $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['project_name'] = $project['name']; + $data['project_code'] = $project['project_code']; + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/quality/QualityAcceptValidate.php b/app/adminapi/validate/quality/QualityAcceptValidate.php new file mode 100644 index 000000000..d08d9834f --- /dev/null +++ b/app/adminapi/validate/quality/QualityAcceptValidate.php @@ -0,0 +1,140 @@ + 'require', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'project_id' => 'require|checkProject', + 'accept_date' => 'dateFormat:Y-m-d', + 'file' => 'checkFile', + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'org_id.require' => '请选择组织', + 'dept_id.require' => '请选择部门', + 'project_id.require' => '请选择项目', + 'accept_date.dateFormat' => '验收日期格式错误', + ]; + + + /** + * @notes 添加场景 + * @return QualityAcceptValidate + * @author likeadmin + * @date 2023/12/21 15:03 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return QualityAcceptValidate + * @author likeadmin + * @date 2023/12/21 15:03 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return QualityAcceptValidate + * @author likeadmin + * @date 2023/12/21 15:03 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return QualityAcceptValidate + * @author likeadmin + * @date 2023/12/21 15:03 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkOrg($value): bool|string + { + $data = Orgs::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门不属于当前选择的组织'; + } + return true; + } + + public function checkProject($value): bool|string + { + $data = Project::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '项目不存在'; + } + return true; + } + + public function checkFile($value): bool|string + { + if($value != ''){ + $file = json_decode($value,true); + if(empty($file)){ + return '附件必须是json数组'; + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/quality/QualityAccept.php b/app/common/model/quality/QualityAccept.php new file mode 100644 index 000000000..bcf8da8d3 --- /dev/null +++ b/app/common/model/quality/QualityAccept.php @@ -0,0 +1,42 @@ + Date: Thu, 21 Dec 2023 15:59:34 +0800 Subject: [PATCH 11/17] QualityDetectionTemp --- .../QualityDetectionTempController.php | 108 ++++++++++++++ .../quality/QualityDetectionTempLists.php | 86 +++++++++++ .../quality/QualityDetectionTempLogic.php | 132 +++++++++++++++++ .../quality/QualityDetectionTempValidate.php | 138 ++++++++++++++++++ .../model/quality/QualityDetectionTemp.php | 43 ++++++ 5 files changed, 507 insertions(+) create mode 100644 app/adminapi/controller/quality/QualityDetectionTempController.php create mode 100644 app/adminapi/lists/quality/QualityDetectionTempLists.php create mode 100644 app/adminapi/logic/quality/QualityDetectionTempLogic.php create mode 100644 app/adminapi/validate/quality/QualityDetectionTempValidate.php create mode 100644 app/common/model/quality/QualityDetectionTemp.php diff --git a/app/adminapi/controller/quality/QualityDetectionTempController.php b/app/adminapi/controller/quality/QualityDetectionTempController.php new file mode 100644 index 000000000..580789066 --- /dev/null +++ b/app/adminapi/controller/quality/QualityDetectionTempController.php @@ -0,0 +1,108 @@ +dataLists(new QualityDetectionTempLists()); + } + + + /** + * @notes 添加质量检测模板 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 15:41 + */ + public function add() + { + $params = (new QualityDetectionTempValidate())->post()->goCheck('add'); + $result = QualityDetectionTempLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(QualityDetectionTempLogic::getError()); + } + + + /** + * @notes 编辑质量检测模板 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 15:41 + */ + public function edit() + { + $params = (new QualityDetectionTempValidate())->post()->goCheck('edit'); + $result = QualityDetectionTempLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(QualityDetectionTempLogic::getError()); + } + + + /** + * @notes 删除质量检测模板 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 15:41 + */ + public function delete() + { + $params = (new QualityDetectionTempValidate())->post()->goCheck('delete'); + QualityDetectionTempLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取质量检测模板详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 15:41 + */ + public function detail() + { + $params = (new QualityDetectionTempValidate())->goCheck('detail'); + $result = QualityDetectionTempLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/quality/QualityDetectionTempLists.php b/app/adminapi/lists/quality/QualityDetectionTempLists.php new file mode 100644 index 000000000..0395a7ec1 --- /dev/null +++ b/app/adminapi/lists/quality/QualityDetectionTempLists.php @@ -0,0 +1,86 @@ + ['node', 'serial_number'], + ]; + } + + + /** + * @notes 获取质量检测模板列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/21 15:41 + */ + public function lists(): array + { + return QualityDetectionTemp::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'node', 'serial_number', 'standard_duration', 'remark', 'file', 'add_user', 'update_user']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $item['node_text'] = $item->node_text; + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取质量检测模板数量 + * @return int + * @author likeadmin + * @date 2023/12/21 15:41 + */ + public function count(): int + { + return QualityDetectionTemp::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/quality/QualityDetectionTempLogic.php b/app/adminapi/logic/quality/QualityDetectionTempLogic.php new file mode 100644 index 000000000..dcc336c58 --- /dev/null +++ b/app/adminapi/logic/quality/QualityDetectionTempLogic.php @@ -0,0 +1,132 @@ + $params['org_id'], + 'dept_id' => $params['dept_id'], + 'node' => $params['node'], + 'serial_number' => $params['serial_number'], + 'standard_duration' => $params['standard_duration'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'add_user' => $admin_id, + 'update_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 2023/12/21 15:41 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + QualityDetectionTemp::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'node' => $params['node'], + 'serial_number' => $params['serial_number'], + 'standard_duration' => $params['standard_duration'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'update_user' => $admin_id, + '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 2023/12/21 15:41 + */ + public static function delete(array $params): bool + { + return QualityDetectionTemp::destroy($params['id']); + } + + + /** + * @notes 获取质量检测模板详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/21 15:41 + */ + public static function detail($params): array + { + $data = QualityDetectionTemp::findOrEmpty($params['id'])->toArray(); + if(empty($data)) return []; + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/quality/QualityDetectionTempValidate.php b/app/adminapi/validate/quality/QualityDetectionTempValidate.php new file mode 100644 index 000000000..6271cb35d --- /dev/null +++ b/app/adminapi/validate/quality/QualityDetectionTempValidate.php @@ -0,0 +1,138 @@ + 'require', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'node' => 'require|checkNode', + 'file' => 'checkFile', + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'org_id.require' => '请选择组织', + 'dept_id.require' => '请选择部门', + 'node.require' => '请选择质量检测节点', + ]; + + + /** + * @notes 添加场景 + * @return QualityDetectionTempValidate + * @author likeadmin + * @date 2023/12/21 15:41 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return QualityDetectionTempValidate + * @author likeadmin + * @date 2023/12/21 15:41 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return QualityDetectionTempValidate + * @author likeadmin + * @date 2023/12/21 15:41 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return QualityDetectionTempValidate + * @author likeadmin + * @date 2023/12/21 15:41 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkOrg($value): bool|string + { + $data = Orgs::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门不属于当前选择的组织'; + } + return true; + } + + public function checkFile($value): bool|string + { + if($value != ''){ + $file = json_decode($value,true); + if(empty($file)){ + return '附件必须是json数组'; + } + } + return true; + } + + public function checkNode($value): bool|string + { + $dictData = DictData::where('type_value','quality_detection_node')->column('value'); + if(!in_array($value,$dictData)){ + return '质量检测节点无效'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/quality/QualityDetectionTemp.php b/app/common/model/quality/QualityDetectionTemp.php new file mode 100644 index 000000000..b234e837f --- /dev/null +++ b/app/common/model/quality/QualityDetectionTemp.php @@ -0,0 +1,43 @@ +column('name','value'); + return $dictData[$data['node']]; + } +} \ No newline at end of file From 050e512e451a3a13a165f653c221d99e389ba875 Mon Sep 17 00:00:00 2001 From: weiz Date: Thu, 21 Dec 2023 16:35:44 +0800 Subject: [PATCH 12/17] QualityDetection --- .../quality/QualityDetectionController.php | 108 ++++++++++++ .../lists/quality/QualityDetectionLists.php | 90 ++++++++++ .../logic/quality/QualityDetectionLogic.php | 162 ++++++++++++++++++ .../quality/QualityDetectionValidate.php | 130 ++++++++++++++ app/common/model/quality/QualityDetection.php | 57 ++++++ 5 files changed, 547 insertions(+) create mode 100644 app/adminapi/controller/quality/QualityDetectionController.php create mode 100644 app/adminapi/lists/quality/QualityDetectionLists.php create mode 100644 app/adminapi/logic/quality/QualityDetectionLogic.php create mode 100644 app/adminapi/validate/quality/QualityDetectionValidate.php create mode 100644 app/common/model/quality/QualityDetection.php diff --git a/app/adminapi/controller/quality/QualityDetectionController.php b/app/adminapi/controller/quality/QualityDetectionController.php new file mode 100644 index 000000000..72eaa419c --- /dev/null +++ b/app/adminapi/controller/quality/QualityDetectionController.php @@ -0,0 +1,108 @@ +dataLists(new QualityDetectionLists()); + } + + + /** + * @notes 添加质量检测 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 16:14 + */ + public function add() + { + $params = (new QualityDetectionValidate())->post()->goCheck('add'); + $result = QualityDetectionLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(QualityDetectionLogic::getError()); + } + + + /** + * @notes 编辑质量检测 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 16:14 + */ + public function edit() + { + $params = (new QualityDetectionValidate())->post()->goCheck('edit'); + $result = QualityDetectionLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(QualityDetectionLogic::getError()); + } + + + /** + * @notes 删除质量检测 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 16:14 + */ + public function delete() + { + $params = (new QualityDetectionValidate())->post()->goCheck('delete'); + QualityDetectionLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取质量检测详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/21 16:14 + */ + public function detail() + { + $params = (new QualityDetectionValidate())->goCheck('detail'); + $result = QualityDetectionLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/quality/QualityDetectionLists.php b/app/adminapi/lists/quality/QualityDetectionLists.php new file mode 100644 index 000000000..471b692f1 --- /dev/null +++ b/app/adminapi/lists/quality/QualityDetectionLists.php @@ -0,0 +1,90 @@ + ['detection_task', 'owning_stage', 'resp_user', 'standard_duration', 'document_number', 'document_name'], + + ]; + } + + + /** + * @notes 获取质量检测列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/21 16:14 + */ + public function lists(): array + { + return QualityDetection::where($this->searchWhere) + ->field(['id', 'org_id', 'dept_id', 'project_id', 'detection_task', 'owning_stage', 'resp_user', 'standard_duration', 'scheduled_start_time', 'scheduled_end_time', 'complete', 'actual_start_time', 'actual_end_time', 'document_number', 'document_name', 'document_manuscript', 'archiving', 'data_content_requirements', 'detection_situation', 'remark', 'file']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + $item['project_name'] = $project['name']; + $item['project_code'] = $project['project_code']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取质量检测数量 + * @return int + * @author likeadmin + * @date 2023/12/21 16:14 + */ + public function count(): int + { + return QualityDetection::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/quality/QualityDetectionLogic.php b/app/adminapi/logic/quality/QualityDetectionLogic.php new file mode 100644 index 000000000..3d9507cd0 --- /dev/null +++ b/app/adminapi/logic/quality/QualityDetectionLogic.php @@ -0,0 +1,162 @@ + $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'detection_task' => $params['detection_task'], + 'owning_stage' => $params['owning_stage'], + 'resp_user' => $params['resp_user'], + 'standard_duration' => $params['standard_duration'], + 'scheduled_start_time' => strtotime($params['scheduled_start_time']), + 'scheduled_end_time' => strtotime($params['scheduled_end_time']), + 'complete' => $params['complete'], + 'actual_start_time' => strtotime($params['actual_start_time']), + 'actual_end_time' => strtotime($params['actual_end_time']), + 'document_number' => $params['document_number'], + 'document_name' => $params['document_name'], + 'document_manuscript' => $params['document_manuscript'], + 'archiving' => $params['archiving'], + 'data_content_requirements' => $params['data_content_requirements'], + 'detection_situation' => $params['detection_situation'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'add_user' => $admin_id, + 'update_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 2023/12/21 16:14 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + QualityDetection::where('id', $params['id'])->update([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'detection_task' => $params['detection_task'], + 'owning_stage' => $params['owning_stage'], + 'resp_user' => $params['resp_user'], + 'standard_duration' => $params['standard_duration'], + 'scheduled_start_time' => strtotime($params['scheduled_start_time']), + 'scheduled_end_time' => strtotime($params['scheduled_end_time']), + 'complete' => $params['complete'], + 'actual_start_time' => strtotime($params['actual_start_time']), + 'actual_end_time' => strtotime($params['actual_end_time']), + 'document_number' => $params['document_number'], + 'document_name' => $params['document_name'], + 'document_manuscript' => $params['document_manuscript'], + 'archiving' => $params['archiving'], + 'data_content_requirements' => $params['data_content_requirements'], + 'detection_situation' => $params['detection_situation'], + 'remark' => $params['remark'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'update_user' => $admin_id, + '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 2023/12/21 16:14 + */ + public static function delete(array $params): bool + { + return QualityDetection::destroy($params['id']); + } + + + /** + * @notes 获取质量检测详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/21 16:14 + */ + public static function detail($params): array + { + $data = QualityDetection::findOrEmpty($params['id'])->toArray(); + if(empty($data)) return []; + $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['project_name'] = $project['name']; + $data['project_code'] = $project['project_code']; + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/quality/QualityDetectionValidate.php b/app/adminapi/validate/quality/QualityDetectionValidate.php new file mode 100644 index 000000000..a88a8d7ec --- /dev/null +++ b/app/adminapi/validate/quality/QualityDetectionValidate.php @@ -0,0 +1,130 @@ + 'require', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'project_id' => 'require|checkProject', + 'scheduled_start_time' => 'dateFormat:Y-m-d', + 'scheduled_end_time' => 'dateFormat:Y-m-d', + 'actual_start_time' => 'dateFormat:Y-m-d', + 'actual_end_time' => 'dateFormat:Y-m-d', + 'file' => 'checkFile', + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'org_id.require' => '请选择组织', + 'dept_id.require' => '请选择部门', + 'project_id.require' => '请选择项目', + 'scheduled_start_time.dateFormat' => '计划开始时间格式错误', + 'scheduled_end_time.dateFormat' => '计划结束时间格式错误', + 'actual_start_time.dateFormat' => '实际开始式错误', + 'actual_end_time.dateFormat' => '实际结束格式错误', + ]; + + /** + * @notes 添加场景 + * @return QualityDetectionValidate + * @author likeadmin + * @date 2023/12/21 16:14 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return QualityDetectionValidate + * @author likeadmin + * @date 2023/12/21 16:14 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return QualityDetectionValidate + * @author likeadmin + * @date 2023/12/21 16:14 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return QualityDetectionValidate + * @author likeadmin + * @date 2023/12/21 16:14 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkOrg($value): bool|string + { + $data = Orgs::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门不属于当前选择的组织'; + } + return true; + } + + public function checkProject($value): bool|string + { + $data = Project::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '项目不存在'; + } + return true; + } + + public function checkFile($value): bool|string + { + if($value != ''){ + $file = json_decode($value,true); + if(empty($file)){ + return '附件必须是json数组'; + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/quality/QualityDetection.php b/app/common/model/quality/QualityDetection.php new file mode 100644 index 000000000..eae1188d6 --- /dev/null +++ b/app/common/model/quality/QualityDetection.php @@ -0,0 +1,57 @@ + Date: Thu, 21 Dec 2023 17:52:06 +0800 Subject: [PATCH 13/17] fixed --- config/project.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/project.php b/config/project.php index 38e960821..46940a316 100755 --- a/config/project.php +++ b/config/project.php @@ -75,7 +75,7 @@ return [ ], // 文件上传限制 (文件) 'file_file' => [ - 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'txt', 'zip','rar','tar' + 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'txt', 'zip','rar','tar','jpg', 'png', 'gif', 'jpeg', 'webp','wmv', 'avi', 'mpg', 'mpeg', '3gp', 'mov', 'mp4', 'flv', 'f4v', 'rmvb', 'mkv' ], // 登录设置 'login' => [ From 86f7e740b63b7b12a14b64243562b5e51632984b Mon Sep 17 00:00:00 2001 From: weiz Date: Fri, 22 Dec 2023 09:36:25 +0800 Subject: [PATCH 14/17] BuildDivision --- .../build/BuildDivisionController.php | 108 ++++++++++++++++ .../lists/build/BuildDivisionLists.php | 77 ++++++++++++ .../logic/build/BuildDivisionLogic.php | 119 ++++++++++++++++++ .../validate/build/BuildDivisionValidate.php | 112 +++++++++++++++++ app/common/model/build/BuildDivision.php | 34 +++++ 5 files changed, 450 insertions(+) create mode 100644 app/adminapi/controller/build/BuildDivisionController.php create mode 100644 app/adminapi/lists/build/BuildDivisionLists.php create mode 100644 app/adminapi/logic/build/BuildDivisionLogic.php create mode 100644 app/adminapi/validate/build/BuildDivisionValidate.php create mode 100644 app/common/model/build/BuildDivision.php diff --git a/app/adminapi/controller/build/BuildDivisionController.php b/app/adminapi/controller/build/BuildDivisionController.php new file mode 100644 index 000000000..a83038741 --- /dev/null +++ b/app/adminapi/controller/build/BuildDivisionController.php @@ -0,0 +1,108 @@ +dataLists(new BuildDivisionLists()); + } + + + /** + * @notes 添加分部分项划分 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 09:17 + */ + public function add() + { + $params = (new BuildDivisionValidate())->post()->goCheck('add'); + $result = BuildDivisionLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(BuildDivisionLogic::getError()); + } + + + /** + * @notes 编辑分部分项划分 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 09:17 + */ + public function edit() + { + $params = (new BuildDivisionValidate())->post()->goCheck('edit'); + $result = BuildDivisionLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(BuildDivisionLogic::getError()); + } + + + /** + * @notes 删除分部分项划分 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 09:17 + */ + public function delete() + { + $params = (new BuildDivisionValidate())->post()->goCheck('delete'); + BuildDivisionLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取分部分项划分详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 09:17 + */ + public function detail() + { + $params = (new BuildDivisionValidate())->goCheck('detail'); + $result = BuildDivisionLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/build/BuildDivisionLists.php b/app/adminapi/lists/build/BuildDivisionLists.php new file mode 100644 index 000000000..6de7806b0 --- /dev/null +++ b/app/adminapi/lists/build/BuildDivisionLists.php @@ -0,0 +1,77 @@ + ['division_engineering', 'sub_division_engineering', 'subentry_engineering', 'subentry_engineering_code'], + ]; + } + + + /** + * @notes 获取分部分项划分列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/22 09:17 + */ + public function lists(): array + { + return BuildDivision::where($this->searchWhere) + ->field(['id', 'division_engineering', 'sub_division_engineering', 'subentry_engineering', 'subentry_engineering_code']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取分部分项划分数量 + * @return int + * @author likeadmin + * @date 2023/12/22 09:17 + */ + public function count(): int + { + return BuildDivision::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/build/BuildDivisionLogic.php b/app/adminapi/logic/build/BuildDivisionLogic.php new file mode 100644 index 000000000..c5922c4dc --- /dev/null +++ b/app/adminapi/logic/build/BuildDivisionLogic.php @@ -0,0 +1,119 @@ + $params['division_engineering'], + 'sub_division_engineering' => $params['sub_division_engineering'], + 'subentry_engineering' => $params['subentry_engineering'], + 'subentry_engineering_code' => $params['subentry_engineering_code'], + 'add_user' => $admin_id, + 'update_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 2023/12/22 09:17 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + BuildDivision::where('id', $params['id'])->update([ + 'division_engineering' => $params['division_engineering'], + 'sub_division_engineering' => $params['sub_division_engineering'], + 'subentry_engineering' => $params['subentry_engineering'], + 'subentry_engineering_code' => $params['subentry_engineering_code'], + 'update_user' => $admin_id, + 'updatte_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 2023/12/22 09:17 + */ + public static function delete(array $params): bool + { + return BuildDivision::destroy($params['id']); + } + + + /** + * @notes 获取分部分项划分详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/22 09:17 + */ + public static function detail($params): array + { + $data = BuildDivision::findOrEmpty($params['id'])->toArray(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/build/BuildDivisionValidate.php b/app/adminapi/validate/build/BuildDivisionValidate.php new file mode 100644 index 000000000..52939e22b --- /dev/null +++ b/app/adminapi/validate/build/BuildDivisionValidate.php @@ -0,0 +1,112 @@ + 'require', + 'division_engineering' => 'require', + 'sub_division_engineering' => 'require', + 'subentry_engineering' => 'require', + 'subentry_engineering_code' => 'require' + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'division_engineering.require' => '请填写分部工程', + 'sub_division_engineering.require' => '请填写子分部工程', + 'subentry_engineering.require' => '请填写分项工程', + 'subentry_engineering_code.require' => '请填写分项工程编码' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'division_engineering' => '分部工程', + 'sub_division_engineering' => '子分部工程', + 'subentry_engineering' => '分项工程', + 'subentry_engineering_code' => '分项工程编码', + 'add_user' => '添加人', + 'update_user' => '更新人', + ]; + + + /** + * @notes 添加场景 + * @return BuildDivisionValidate + * @author likeadmin + * @date 2023/12/22 09:17 + */ + public function sceneAdd() + { + return $this->only(['division_engineering','sub_division_engineering','subentry_engineering','subentry_engineering_code']); + } + + + /** + * @notes 编辑场景 + * @return BuildDivisionValidate + * @author likeadmin + * @date 2023/12/22 09:17 + */ + public function sceneEdit() + { + return $this->only(['id','division_engineering','sub_division_engineering','subentry_engineering','subentry_engineering_code']); + } + + + /** + * @notes 删除场景 + * @return BuildDivisionValidate + * @author likeadmin + * @date 2023/12/22 09:17 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return BuildDivisionValidate + * @author likeadmin + * @date 2023/12/22 09:17 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/build/BuildDivision.php b/app/common/model/build/BuildDivision.php new file mode 100644 index 000000000..86e8bfce6 --- /dev/null +++ b/app/common/model/build/BuildDivision.php @@ -0,0 +1,34 @@ + Date: Fri, 22 Dec 2023 10:23:26 +0800 Subject: [PATCH 15/17] BuildProcessSettings --- .../build/BuildProcessSettingsController.php | 108 ++++++++++++++ .../lists/build/BuildProcessSettingsLists.php | 85 +++++++++++ .../logic/build/BuildProcessSettingsLogic.php | 128 +++++++++++++++++ .../build/BuildProcessSettingsValidate.php | 134 ++++++++++++++++++ .../model/build/BuildProcessSettings.php | 37 +++++ 5 files changed, 492 insertions(+) create mode 100644 app/adminapi/controller/build/BuildProcessSettingsController.php create mode 100644 app/adminapi/lists/build/BuildProcessSettingsLists.php create mode 100644 app/adminapi/logic/build/BuildProcessSettingsLogic.php create mode 100644 app/adminapi/validate/build/BuildProcessSettingsValidate.php create mode 100644 app/common/model/build/BuildProcessSettings.php diff --git a/app/adminapi/controller/build/BuildProcessSettingsController.php b/app/adminapi/controller/build/BuildProcessSettingsController.php new file mode 100644 index 000000000..6c234717d --- /dev/null +++ b/app/adminapi/controller/build/BuildProcessSettingsController.php @@ -0,0 +1,108 @@ +dataLists(new BuildProcessSettingsLists()); + } + + + /** + * @notes 添加施工工序设置 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 09:51 + */ + public function add() + { + $params = (new BuildProcessSettingsValidate())->post()->goCheck('add'); + $result = BuildProcessSettingsLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(BuildProcessSettingsLogic::getError()); + } + + + /** + * @notes 编辑施工工序设置 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 09:51 + */ + public function edit() + { + $params = (new BuildProcessSettingsValidate())->post()->goCheck('edit'); + $result = BuildProcessSettingsLogic::edit($params,$this->adminId); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(BuildProcessSettingsLogic::getError()); + } + + + /** + * @notes 删除施工工序设置 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 09:51 + */ + public function delete() + { + $params = (new BuildProcessSettingsValidate())->post()->goCheck('delete'); + BuildProcessSettingsLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取施工工序设置详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 09:51 + */ + public function detail() + { + $params = (new BuildProcessSettingsValidate())->goCheck('detail'); + $result = BuildProcessSettingsLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/build/BuildProcessSettingsLists.php b/app/adminapi/lists/build/BuildProcessSettingsLists.php new file mode 100644 index 000000000..0167b4c5d --- /dev/null +++ b/app/adminapi/lists/build/BuildProcessSettingsLists.php @@ -0,0 +1,85 @@ + ['process_step_no'], + ]; + } + + + /** + * @notes 获取施工工序设置列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/22 09:51 + */ + public function lists(): array + { + return BuildProcessSettings::where($this->searchWhere) + ->field(['id', 'division_id', 'process_step_no', 'process_step', 'file', 'quality_control_points']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $division = BuildDivision::where('id',$item['division_id'])->findOrEmpty(); + $item['division_engineering'] = $division['division_engineering']; + $item['sub_division_engineering'] = $division['sub_division_engineering']; + $item['subentry_engineering'] = $division['subentry_engineering']; + $item['subentry_engineering_code'] = $division['subentry_engineering_code']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取施工工序设置数量 + * @return int + * @author likeadmin + * @date 2023/12/22 09:51 + */ + public function count(): int + { + return BuildProcessSettings::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/build/BuildProcessSettingsLogic.php b/app/adminapi/logic/build/BuildProcessSettingsLogic.php new file mode 100644 index 000000000..d26bf26dc --- /dev/null +++ b/app/adminapi/logic/build/BuildProcessSettingsLogic.php @@ -0,0 +1,128 @@ + $params['division_id'], + 'process_step_no' => $params['process_step_no'], + 'process_step' => $params['process_step'], + 'quality_control_points' => $params['quality_control_points'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'add_user' => $admin_id, + 'update_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 2023/12/22 09:51 + */ + public static function edit(array $params,$admin_id): bool + { + Db::startTrans(); + try { + BuildProcessSettings::where('id', $params['id'])->update([ + 'division_id' => $params['division_id'], + 'process_step_no' => $params['process_step_no'], + 'process_step' => $params['process_step'], + 'quality_control_points' => $params['quality_control_points'], + 'file' => !empty($params['file']) ? $params['file'] : null, + 'update_user' => $admin_id, + '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 2023/12/22 09:51 + */ + public static function delete(array $params): bool + { + return BuildProcessSettings::destroy($params['id']); + } + + + /** + * @notes 获取施工工序设置详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/22 09:51 + */ + public static function detail($params): array + { + $data = BuildProcessSettings::findOrEmpty($params['id'])->toArray(); + if(empty($data)) return []; + $division = BuildDivision::where('id',$data['division_id'])->findOrEmpty(); + $admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id'); + $data['division_engineering'] = $division['division_engineering']; + $data['sub_division_engineering'] = $division['sub_division_engineering']; + $data['subentry_engineering'] = $division['subentry_engineering']; + $data['subentry_engineering_code'] = $division['subentry_engineering_code']; + $data['add_user_name'] = $admin[$data['add_user']]; + $data['update_user_name'] = $admin[$data['update_user']]; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/build/BuildProcessSettingsValidate.php b/app/adminapi/validate/build/BuildProcessSettingsValidate.php new file mode 100644 index 000000000..1b4fe3c38 --- /dev/null +++ b/app/adminapi/validate/build/BuildProcessSettingsValidate.php @@ -0,0 +1,134 @@ + 'require', + 'division_id' => 'require|checkDivision', + 'process_step_no' => 'require', + 'process_step' => 'require', + 'quality_control_points' => 'require', + 'file' => 'checkFile' + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'division_id.require' => '请选择分部工程', + 'process_step_no.require' => '请填写工序步骤号', + 'process_step.require' => '请填写工序步骤', + 'quality_control_points.require' => '请填写质量控制点', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'division_id' => '分部分项id', + 'process_step_no' => '工序步骤号', + 'process_step' => '工序步骤', + 'quality_control_points' => '质量控制点', + 'add_user' => '添加人', + 'update_user' => '更新人', + ]; + + + /** + * @notes 添加场景 + * @return BuildProcessSettingsValidate + * @author likeadmin + * @date 2023/12/22 09:51 + */ + public function sceneAdd() + { + return $this->only(['division_id','process_step_no','process_step','quality_control_points','file']); + } + + + /** + * @notes 编辑场景 + * @return BuildProcessSettingsValidate + * @author likeadmin + * @date 2023/12/22 09:51 + */ + public function sceneEdit() + { + return $this->only(['id','division_id','process_step_no','process_step','quality_control_points','file']); + } + + + /** + * @notes 删除场景 + * @return BuildProcessSettingsValidate + * @author likeadmin + * @date 2023/12/22 09:51 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return BuildProcessSettingsValidate + * @author likeadmin + * @date 2023/12/22 09:51 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkDivision($value): bool|string + { + $data = BuildDivision::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '分部工程不存在'; + } + return true; + } + + public function checkFile($value): bool|string + { + if($value != ''){ + $file = json_decode($value,true); + if(empty($file)){ + return '附件必须是json数组'; + } + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/build/BuildProcessSettings.php b/app/common/model/build/BuildProcessSettings.php new file mode 100644 index 000000000..69453531e --- /dev/null +++ b/app/common/model/build/BuildProcessSettings.php @@ -0,0 +1,37 @@ + Date: Fri, 22 Dec 2023 10:41:53 +0800 Subject: [PATCH 16/17] fixed --- .../build/BuildProcessSettingsController.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/adminapi/controller/build/BuildProcessSettingsController.php b/app/adminapi/controller/build/BuildProcessSettingsController.php index 6c234717d..835309998 100644 --- a/app/adminapi/controller/build/BuildProcessSettingsController.php +++ b/app/adminapi/controller/build/BuildProcessSettingsController.php @@ -20,6 +20,7 @@ use app\adminapi\controller\BaseAdminController; use app\adminapi\lists\build\BuildProcessSettingsLists; use app\adminapi\logic\build\BuildProcessSettingsLogic; use app\adminapi\validate\build\BuildProcessSettingsValidate; +use app\common\model\build\BuildProcessSettings; /** @@ -103,6 +104,30 @@ class BuildProcessSettingsController extends BaseAdminController $result = BuildProcessSettingsLogic::detail($params); return $this->data($result); } + + //获取某个分部工程下的施工工序 + public function listToDivision(): \think\response\Json + { + $params = $this->request->get(['division_id','page_size','page_no']); + if(empty($params['division_id'])){ + return $this->fail('参数错误'); + } + $pageNo = empty($params['page_no']) ? 1 : $params['page_no']; + $pageSize = empty($params['page_size']) ? 15 : $params['page_size']; + $data = BuildProcessSettings::field('id,process_step_no,process_step,quality_control_points,file') + ->where('division_id',$params['division_id']) + ->page($pageNo,$pageSize) + ->order('id desc') + ->select()->toArray(); + $count = BuildProcessSettings::field('id,process_step_no,process_step,quality_control_points,file')->where('division_id',$params['division_id'])->count(); + $result = [ + 'count' => $count, + 'page_no' => $pageNo, + 'page_size' => $pageSize, + 'lists' => $data + ]; + return $this->success('请求成功',$result); + } } \ No newline at end of file From 4fc161559c25fb55a6a252ab37b7c1d8b0d7d7b6 Mon Sep 17 00:00:00 2001 From: weiz Date: Fri, 22 Dec 2023 13:57:37 +0800 Subject: [PATCH 17/17] BuildPlan --- .../controller/build/BuildPlanController.php | 108 ++++++++++++ .../project/ProjectMemberController.php | 38 ++++ app/adminapi/lists/build/BuildPlanLists.php | 98 +++++++++++ app/adminapi/logic/build/BuildPlanLogic.php | 146 ++++++++++++++++ .../validate/build/BuildPlanValidate.php | 165 ++++++++++++++++++ app/common.php | 5 + app/common/model/build/BuildPlan.php | 42 +++++ 7 files changed, 602 insertions(+) create mode 100644 app/adminapi/controller/build/BuildPlanController.php create mode 100644 app/adminapi/lists/build/BuildPlanLists.php create mode 100644 app/adminapi/logic/build/BuildPlanLogic.php create mode 100644 app/adminapi/validate/build/BuildPlanValidate.php create mode 100644 app/common/model/build/BuildPlan.php diff --git a/app/adminapi/controller/build/BuildPlanController.php b/app/adminapi/controller/build/BuildPlanController.php new file mode 100644 index 000000000..e9a34352d --- /dev/null +++ b/app/adminapi/controller/build/BuildPlanController.php @@ -0,0 +1,108 @@ +dataLists(new BuildPlanLists()); + } + + + /** + * @notes 添加施工计划 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public function add() + { + $params = (new BuildPlanValidate())->post()->goCheck('add'); + $result = BuildPlanLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(BuildPlanLogic::getError()); + } + + + /** + * @notes 编辑施工计划 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public function edit() + { + $params = (new BuildPlanValidate())->post()->goCheck('edit'); + $result = BuildPlanLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(BuildPlanLogic::getError()); + } + + + /** + * @notes 删除施工计划 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public function delete() + { + $params = (new BuildPlanValidate())->post()->goCheck('delete'); + BuildPlanLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取施工计划详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public function detail() + { + $params = (new BuildPlanValidate())->goCheck('detail'); + $result = BuildPlanLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/project/ProjectMemberController.php b/app/adminapi/controller/project/ProjectMemberController.php index d67544310..76c7794af 100644 --- a/app/adminapi/controller/project/ProjectMemberController.php +++ b/app/adminapi/controller/project/ProjectMemberController.php @@ -20,6 +20,10 @@ use app\adminapi\controller\BaseAdminController; use app\adminapi\lists\project\ProjectMemberLists; use app\adminapi\logic\project\ProjectMemberLogic; use app\adminapi\validate\project\ProjectMemberValidate; +use app\common\model\auth\Admin; +use app\common\model\project\Project; +use app\common\model\project\ProjectMember; +use app\common\model\project\ProjectRoleSet; /** @@ -103,6 +107,40 @@ class ProjectMemberController extends BaseAdminController $result = ProjectMemberLogic::detail($params); return $this->data($result); } + + //获取某个项目下的所有成员 + public function listToProject(): \think\response\Json + { + $params = $this->request->get(['project_id','page_size','page_no']); + if(empty($params['project_id'])){ + return $this->fail('参数错误'); + } + $pageNo = empty($params['page_no']) ? 1 : $params['page_no']; + $pageSize = empty($params['page_size']) ? 15 : $params['page_size']; + $data = ProjectMember::where('project_id',$params['project_id']) + ->field(['id', 'project_id', 'project_role_id', 'admin_id', 'working_unit_price', 'remark']) + ->page($pageNo, $pageSize) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); + $role = ProjectRoleSet::field('name')->where('id',$item['project_role_id'])->findOrEmpty(); + $admin = Admin::field('name')->where('id',$item['admin_id'])->findOrEmpty(); + $item['project_name'] = $project['name']; + $item['project_code'] = $project['project_code']; + $item['project_role_name'] = $role['name']; + $item['admin_name'] = $admin['name']; + return $item; + }) + ->toArray(); + $count = ProjectMember::field(['id', 'project_id', 'project_role_id', 'admin_id', 'working_unit_price', 'remark'])->where('project_id',$params['project_id'])->count(); + $result = [ + 'count' => $count, + 'page_no' => $pageNo, + 'page_size' => $pageSize, + 'lists' => $data + ]; + return $this->success('请求成功',$result); + } } \ No newline at end of file diff --git a/app/adminapi/lists/build/BuildPlanLists.php b/app/adminapi/lists/build/BuildPlanLists.php new file mode 100644 index 000000000..67abe5525 --- /dev/null +++ b/app/adminapi/lists/build/BuildPlanLists.php @@ -0,0 +1,98 @@ + ['zy_code', 'plan_start_date', 'plan_end_date', 'work_user'], + ]; + } + + + /** + * @notes 获取施工计划列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public function lists(): array + { + return BuildPlan::where($this->searchWhere) + ->field(['id', 'project_id', 'process_id', 'project_member_id', 'zy_code', 'plan_start_date', 'plan_end_date', 'work_user', 'work_content', 'workload', 'unit', 'price', 'amount']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($item){ + $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); + $process = BuildProcessSettings::field('division_id,process_step_no,process_step,quality_control_points,file')->where('id',$item['process_id'])->findOrEmpty(); + $division = BuildDivision::field('subentry_engineering,subentry_engineering_code')->where('id',$process['division_id'])->findOrEmpty(); + $projectMember = ProjectMember::field('admin_id')->where('id',$item['project_member_id'])->findOrEmpty(); + $admin = Admin::field('name')->where('id',$projectMember['admin_id'])->findOrEmpty(); + $item['project_name'] = $project['name']; + $item['project_code'] = $project['project_code']; + $item['subentry_engineering'] = $division['subentry_engineering']; + $item['subentry_engineering_code'] = $division['subentry_engineering_code']; + $item['process_step_no'] = $process['process_step_no']; + $item['process_step'] = $process['process_step']; + $item['quality_control_points'] = $process['quality_control_points']; + $item['file'] = $process['file']; + $item['project_member_name'] = $admin['name']; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取施工计划数量 + * @return int + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public function count(): int + { + return BuildPlan::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/build/BuildPlanLogic.php b/app/adminapi/logic/build/BuildPlanLogic.php new file mode 100644 index 000000000..405726a44 --- /dev/null +++ b/app/adminapi/logic/build/BuildPlanLogic.php @@ -0,0 +1,146 @@ + $params['project_id'], + 'process_id' => $params['process_id'], + 'project_member_id' => $params['project_member_id'], + 'zy_code' => zy_code(), + 'plan_start_date' => strtotime($params['plan_start_date']), + 'plan_end_date' => strtotime($params['plan_end_date']), + 'work_user' => $params['work_user'], + 'work_content' => $params['work_content'], + 'workload' => $params['workload'], + 'unit' => $params['unit'], + 'price' => $params['price'], + 'amount' => $params['amount'], + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑施工计划 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + BuildPlan::where('id', $params['id'])->update([ + 'project_id' => $params['project_id'], + 'process_id' => $params['process_id'], + 'project_member_id' => $params['project_member_id'], + 'plan_start_date' => strtotime($params['plan_start_date']), + 'plan_end_date' => strtotime($params['plan_end_date']), + 'work_user' => $params['work_user'], + 'work_content' => $params['work_content'], + 'workload' => $params['workload'], + 'unit' => $params['unit'], + 'price' => $params['price'], + 'amount' => $params['amount'], + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除施工计划 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public static function delete(array $params): bool + { + return BuildPlan::destroy($params['id']); + } + + + /** + * @notes 获取施工计划详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public static function detail($params): array + { + $data = BuildPlan::findOrEmpty($params['id'])->toArray(); + if(empty($data)) return []; + $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); + $process = BuildProcessSettings::field('division_id,process_step_no,process_step,quality_control_points,file')->where('id',$data['process_id'])->findOrEmpty(); + $division = BuildDivision::field('subentry_engineering,subentry_engineering_code')->where('id',$process['division_id'])->findOrEmpty(); + $projectMember = ProjectMember::field('admin_id')->where('id',$data['project_member_id'])->findOrEmpty(); + $admin = Admin::field('name')->where('id',$projectMember['admin_id'])->findOrEmpty(); + $data['project_name'] = $project['name']; + $data['project_code'] = $project['project_code']; + $data['subentry_engineering'] = $division['subentry_engineering']; + $data['subentry_engineering_code'] = $division['subentry_engineering_code']; + $data['process_step_no'] = $process['process_step_no']; + $data['process_step'] = $process['process_step']; + $data['quality_control_points'] = $process['quality_control_points']; + $data['file'] = $process['file']; + $data['project_member_name'] = $admin['name']; + return $data; + } +} \ No newline at end of file diff --git a/app/adminapi/validate/build/BuildPlanValidate.php b/app/adminapi/validate/build/BuildPlanValidate.php new file mode 100644 index 000000000..8892dd8e0 --- /dev/null +++ b/app/adminapi/validate/build/BuildPlanValidate.php @@ -0,0 +1,165 @@ + 'require', + 'project_id' => 'require|checkProject', + 'process_id' => 'require|checkProcess', + 'project_member_id' => 'require|checkMember', + 'plan_start_date' => 'require|dateFormat:Y-m-d', + 'plan_end_date' => 'require|dateFormat:Y-m-d', + 'workload' => 'require|integer|egt:0', + 'unit' => 'require', + 'price' => 'require|float|egt:0', + 'amount' => 'require|float|egt:0', + ]; + + protected $message = [ + 'id.require' => '缺少必要参数', + 'project_id.require' => '请选择项目', + 'process_id.require' => '请选择工序步骤', + 'project_member_id.require' => '请选择班组长', + 'plan_start_date.require' => '请选择计划开始日期', + 'plan_start_date.dateFormat' => '计划开始日期格式错误', + 'plan_end_date.require' => '请选择计划结束日期', + 'plan_end_date.dateFormat' => '计划结束日期格式错误', + 'workload.require' => '请填写作业量', + 'workload.integer' => '作业量值必须是整数', + 'workload.egt' => '作业量值必须大于等于0', + 'unit.require' => '请填写单位', + 'price.require' => '请填写单价', + 'price.float' => '单价值必须是数字', + 'price.egt' => '单价值必须大于等于0', + 'amount.require' => '请填写金额', + 'amount.float' => '金额值必须是数字', + 'amount.egt' => '金额值必须大于等于0', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'project_id' => '项目id', + 'process_id' => '工序id', + 'project_member_id' => '项目成员id', + 'zy_code' => '作业编码', + 'plan_start_date' => '计划开始日期', + 'plan_end_date' => '计划结束日期', + 'workload' => '作业量', + 'unit' => '单位', + 'price' => '单价', + 'amount' => '金额', + ]; + + + /** + * @notes 添加场景 + * @return BuildPlanValidate + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return BuildPlanValidate + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return BuildPlanValidate + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return BuildPlanValidate + * @author likeadmin + * @date 2023/12/22 11:04 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkProject($value): bool|string + { + $data = Project::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '项目不存在'; + } + return true; + } + + public function checkProcess($value): bool|string + { + $data = BuildProcessSettings::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '工序步骤不存在'; + } + return true; + } + + public function checkMember($value,$rule,$data): bool|string + { + $member = ProjectMember::where('id',$value)->findOrEmpty(); + if($member->isEmpty()){ + return '班组长不存在'; + } + if($member['project_id'] != $data['project_id']){ + return '班组长无效'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/common.php b/app/common.php index 73a7b0921..8f1f841ad 100755 --- a/app/common.php +++ b/app/common.php @@ -338,3 +338,8 @@ function document_code(): string { return 'D'.date('Ymd',time()).'-'.mt_rand(100000, 999999); } + +function zy_code(): string +{ + return 'ZY'.date('Ymd',time()).'-'.mt_rand(100000, 999999); +} diff --git a/app/common/model/build/BuildPlan.php b/app/common/model/build/BuildPlan.php new file mode 100644 index 000000000..34e4a4435 --- /dev/null +++ b/app/common/model/build/BuildPlan.php @@ -0,0 +1,42 @@ +