新增问题台账模块

This commit is contained in:
weiz 2024-02-28 11:19:11 +08:00
parent 2fd360b7e3
commit abcf31cb51
17 changed files with 716 additions and 44 deletions

View File

@ -69,12 +69,28 @@ class SupervisionAcceptController extends BaseAdminController
public function edit()
{
$params = (new SupervisionAcceptValidate())->post()->goCheck('edit');
$result = SupervisionAcceptLogic::edit($params);
$result = SupervisionAcceptLogic::edit($params,$this->adminId);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SupervisionAcceptLogic::getError());
}
/**
* @notes 编辑工程监理--验收登记
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/27 15:23
*/
public function accept()
{
$params = (new SupervisionAcceptValidate())->post()->goCheck('accept');
$result = SupervisionAcceptLogic::accept($params);
if (true === $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(SupervisionAcceptLogic::getError());
}
/**

View File

@ -69,7 +69,7 @@ class SupervisionInspectionController extends BaseAdminController
public function edit()
{
$params = (new SupervisionInspectionValidate())->post()->goCheck('edit');
$result = SupervisionInspectionLogic::edit($params);
$result = SupervisionInspectionLogic::edit($params,$this->adminId);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}

View File

@ -0,0 +1,124 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\supervision_work;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\supervision_work\SupervisionProblemLists;
use app\adminapi\logic\supervision_work\SupervisionProblemLogic;
use app\adminapi\validate\supervision_work\SupervisionProblemValidate;
/**
* 问题跟踪台账控制器
* Class SupervisionProblemController
* @package app\adminapi\controller\supervision_work
*/
class SupervisionProblemController extends BaseAdminController
{
/**
* @notes 获取问题跟踪台账列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function lists()
{
return $this->dataLists(new SupervisionProblemLists());
}
/**
* @notes 添加问题跟踪台账
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function add()
{
$params = (new SupervisionProblemValidate())->post()->goCheck('add');
$result = SupervisionProblemLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SupervisionProblemLogic::getError());
}
/**
* @notes 编辑问题跟踪台账
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function edit()
{
$params = (new SupervisionProblemValidate())->post()->goCheck('edit');
$result = SupervisionProblemLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SupervisionProblemLogic::getError());
}
/**
* @notes 检查验收问题跟踪台账
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function check()
{
$params = (new SupervisionProblemValidate())->post()->goCheck('check');
$result = SupervisionProblemLogic::check($params);
if (true === $result) {
return $this->success('检查验收成功', [], 1, 1);
}
return $this->fail(SupervisionProblemLogic::getError());
}
/**
* @notes 删除问题跟踪台账
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function delete()
{
$params = (new SupervisionProblemValidate())->post()->goCheck('delete');
SupervisionProblemLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取问题跟踪台账详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function detail()
{
$params = (new SupervisionProblemValidate())->goCheck('detail');
$result = SupervisionProblemLogic::detail($params);
return $this->data($result);
}
}

View File

@ -69,7 +69,7 @@ class SupervisionSideStationController extends BaseAdminController
public function edit()
{
$params = (new SupervisionSideStationValidate())->post()->goCheck('edit');
$result = SupervisionSideStationLogic::edit($params);
$result = SupervisionSideStationLogic::edit($params,$this->adminId);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}

View File

@ -22,6 +22,7 @@ use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionAccept;
use app\common\lists\ListsSearchInterface;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionProblem;
/**
@ -75,6 +76,8 @@ class SupervisionAcceptLists extends BaseAdminDataLists implements ListsSearchIn
$data['create_user_name'] = $create_user['name'];
$data['accept_type_text'] = $data->accept_type_text;
$data['accept_result_text'] = $data->accept_result_text;
$data['problem_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',3)->count();
$data['reply_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',3)->where('is_rectification',1)->count();
})
->toArray();
}

View File

@ -22,6 +22,7 @@ use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionInspection;
use app\common\lists\ListsSearchInterface;
use app\common\model\supervision_work\SupervisionProblem;
/**
@ -75,6 +76,8 @@ class SupervisionInspectionLists extends BaseAdminDataLists implements ListsSear
$data['create_user_name'] = $create_user['name'];
$data['inspection_type_text'] = $data->inspection_type_text;
$data['is_important_text'] = $data->is_important_text;
$data['problem_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',1)->count();
$data['reply_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',1)->where('is_rectification',1)->count();
})
->toArray();
}

View File

@ -0,0 +1,84 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists\supervision_work;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\auth\Admin;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\lists\ListsSearchInterface;
/**
* 问题跟踪台账列表
* Class SupervisionProblemLists
* @package app\adminapi\listssupervision_work
*/
class SupervisionProblemLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function setSearch(): array
{
return [
'=' => ['data_id', 'data_type', 'problem_cate'],
'%like%' => ['problem_description', 'problem_name'],
];
}
/**
* @notes 获取问题跟踪台账列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function lists(): array
{
return SupervisionProblem::withoutField('update_time,delete_time')->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
$data['create_user_name'] = $create_user['name'];
$data['problem_cate_text'] = $data->problem_cate_text;
$data['rectification_result_text'] = $data->rectification_result_text;
$data['is_rectification_text'] = $data->is_rectification_text;
})
->toArray();
}
/**
* @notes 获取问题跟踪台账数量
* @return int
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function count(): int
{
return SupervisionProblem::where($this->searchWhere)->count();
}
}

View File

@ -20,6 +20,7 @@ use app\common\model\auth\Admin;
use app\common\model\supervision_project\SupervisionParticipatingUnits;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\model\supervision_work\SupervisionSideStation;
use app\common\lists\ListsSearchInterface;
@ -75,6 +76,8 @@ class SupervisionSideStationLists extends BaseAdminDataLists implements ListsSea
$data['create_user_name'] = $create_user['name'];
$data['side_station_type_text'] = $data->side_station_type_text;
$data['side_station_result_text'] = $data->side_station_result_text;
$data['problem_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',2)->count();
$data['reply_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',2)->where('is_rectification',1)->count();
})
->toArray();
}

View File

@ -20,9 +20,9 @@ use app\common\model\supervision_project\SupervisionParticipatingUnits;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionAccept;
use app\common\logic\BaseLogic;
use app\common\model\supervision_work\SupervisionAcceptProblem;
use app\common\model\supervision_work\SupervisionAcceptResult;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionProblem;
use think\facade\Db;
@ -75,11 +75,13 @@ class SupervisionAcceptLogic extends BaseLogic
}
if(!empty($params['accept_check_problem'])){
foreach($params['accept_check_problem'] as $v){
SupervisionAcceptProblem::create([
'accept_id' => $res->id,
SupervisionProblem::create([
'data_id' => $res->id,
'data_type' => 3,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name'],
'create_user' => $admin_id,
]);
}
}
@ -100,7 +102,7 @@ class SupervisionAcceptLogic extends BaseLogic
* @author likeadmin
* @date 2024/02/27 15:23
*/
public static function edit(array $params): bool
public static function edit(array $params,$admin_id): bool
{
Db::startTrans();
try {
@ -145,19 +147,22 @@ class SupervisionAcceptLogic extends BaseLogic
if(!empty($params['accept_check_problem'])){
foreach($params['accept_check_problem'] as $v){
if(!empty($v['id'])){
SupervisionAcceptProblem::where('id',$v['id'])->update([
'accept_id' => $params['id'],
SupervisionProblem::where('id',$v['id'])->update([
'data_id' => $params['id'],
'data_type' => 3,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name'],
'update_time' => time(),
]);
}else{
SupervisionAcceptProblem::create([
'accept_id' => $params['id'],
SupervisionProblem::create([
'data_id' => $params['id'],
'data_type' => 3,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name']
'problem_name' => $v['problem_name'],
'create_user' => $admin_id,
]);
}
}
@ -170,9 +175,36 @@ class SupervisionAcceptLogic extends BaseLogic
return false;
}
}
/**
/**
* @notes 编辑工程监理--验收登记
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/27 15:23
*/
public static function accept(array $params): bool
{
Db::startTrans();
try {
SupervisionAccept::where('id', $params['id'])->update([
'accept_time' => !empty($params['accept_time']) ? strtotime($params['accept_time']) : 0,
'accept_result' => $params['accept_result'],
'remark' => $params['remark'],
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'update_time' => time(),
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除工程监理--验收登记
* @param array $params
* @return bool
@ -186,7 +218,7 @@ class SupervisionAcceptLogic extends BaseLogic
self::setError('该验收内容下存在验收结果数据,请先删除验收结果数据');
return false;
}
$accept_problem = SupervisionAcceptProblem::where('accept_id',$params['id'])->findOrEmpty();
$accept_problem = SupervisionProblem::where('data_id',$params['id'])->where('data_type',3)->findOrEmpty();
if(!$accept_problem->isEmpty()){
self::setError('该验收内容下存在验收问题数据,请先删除验收问题数据');
return false;

View File

@ -21,8 +21,8 @@ use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionInspection;
use app\common\logic\BaseLogic;
use app\common\model\supervision_work\SupervisionInspectionProblem;
use app\common\model\supervision_work\SupervisionInspectionResult;
use app\common\model\supervision_work\SupervisionProblem;
use think\facade\Db;
@ -78,11 +78,13 @@ class SupervisionInspectionLogic extends BaseLogic
}
if(!empty($params['inspection_problem'])){
foreach($params['inspection_problem'] as $v){
SupervisionInspectionProblem::create([
'inspection_id' => $res->id,
SupervisionProblem::create([
'data_id' => $res->id,
'data_type' => 1,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name'],
'create_user' => $admin_id,
]);
}
}
@ -103,7 +105,7 @@ class SupervisionInspectionLogic extends BaseLogic
* @author likeadmin
* @date 2024/02/26 17:18
*/
public static function edit(array $params): bool
public static function edit(array $params,$admin_id): bool
{
Db::startTrans();
try {
@ -150,18 +152,21 @@ class SupervisionInspectionLogic extends BaseLogic
if(!empty($params['inspection_problem'])){
foreach($params['inspection_problem'] as $v){
if(!empty($v['id'])){
SupervisionInspectionProblem::where('id',$v['id'])->update([
'inspection_id' => $params['id'],
SupervisionProblem::where('id',$v['id'])->update([
'data_id' => $params['id'],
'data_type' => 1,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name'],
]);
}else{
SupervisionInspectionProblem::create([
'inspection_id' => $params['id'],
SupervisionProblem::create([
'data_id' => $params['id'],
'data_type' => 1,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name'],
'create_user' => $admin_id,
]);
}
}
@ -190,7 +195,7 @@ class SupervisionInspectionLogic extends BaseLogic
self::setError('该巡视内容下存在巡视结果数据,请先删除巡视结果数据');
return false;
}
$inspection_problem = SupervisionInspectionProblem::where('inspection_id',$params['id'])->findOrEmpty();
$inspection_problem = SupervisionProblem::where('data_id',$params['id'])->where('data_type',1)->findOrEmpty();
if(!$inspection_problem->isEmpty()){
self::setError('该巡视内容下存在巡视问题数据,请先删除巡视问题数据');
return false;

View File

@ -0,0 +1,150 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\supervision_work;
use app\common\model\auth\Admin;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 问题跟踪台账逻辑
* Class SupervisionProblemLogic
* @package app\adminapi\logic\supervision_work
*/
class SupervisionProblemLogic extends BaseLogic
{
/**
* @notes 添加问题跟踪台账
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/28 09:19
*/
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
SupervisionProblem::create([
'data_id' => $params['data_id'],
'data_type' => $params['data_type'],
'problem_cate' => $params['problem_cate'],
'problem_description' => $params['problem_description'],
'problem_name' => $params['problem_name'],
'create_user' => $admin_id,
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑问题跟踪台账
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/28 09:19
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
SupervisionProblem::where('id', $params['id'])->update([
'data_id' => $params['data_id'],
'data_type' => $params['data_type'],
'problem_cate' => $params['problem_cate'],
'problem_description' => $params['problem_description'],
'problem_name' => $params['problem_name'],
'update_time' => time(),
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 检查验收问题跟踪台账
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/28 09:19
*/
public static function check(array $params): bool
{
Db::startTrans();
try {
SupervisionProblem::where('id', $params['id'])->update([
'rectification_time' => !empty($params['rectification_time']) ? strtotime($params['rectification_time']) : 0,
'rectification_user' => $params['rectification_user'],
'rectification_result' => $params['rectification_result'],
'rectification_opinion' => $params['rectification_opinion'],
'rectification_annex' => $params['rectification_annex'] ? json_encode($params['rectification_annex']) : null,
'is_rectification' => $params['rectification_result']==0 ? 1 : 0,
'update_time' => time(),
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除问题跟踪台账
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/28 09:19
*/
public static function delete(array $params): bool
{
return SupervisionProblem::destroy($params['id']);
}
/**
* @notes 获取问题跟踪台账详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/02/28 09:19
*/
public static function detail($params): array
{
$data = SupervisionProblem::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
$data['create_user_name'] = $create_user['name'];
$data['problem_cate_text'] = $data->problem_cate_text;
$data['rectification_result_text'] = $data->rectification_result_text;
$data['is_rectification_text'] = $data->is_rectification_text;
return $data->toArray();
}
}

View File

@ -19,9 +19,9 @@ use app\common\model\auth\Admin;
use app\common\model\supervision_project\SupervisionParticipatingUnits;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\model\supervision_work\SupervisionSideStation;
use app\common\logic\BaseLogic;
use app\common\model\supervision_work\SupervisionSideStationProblem;
use app\common\model\supervision_work\SupervisionSideStationResult;
use think\facade\Db;
@ -77,11 +77,13 @@ class SupervisionSideStationLogic extends BaseLogic
}
if(!empty($params['side_problem'])){
foreach($params['side_problem'] as $v){
SupervisionSideStationProblem::create([
'side_station_id' => $res->id,
SupervisionProblem::create([
'data_id' => $res->id,
'data_type' => 2,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name'],
'create_user' => $admin_id
]);
}
}
@ -102,7 +104,7 @@ class SupervisionSideStationLogic extends BaseLogic
* @author likeadmin
* @date 2024/02/27 13:58
*/
public static function edit(array $params): bool
public static function edit(array $params,$admin_id): bool
{
Db::startTrans();
try {
@ -148,19 +150,22 @@ class SupervisionSideStationLogic extends BaseLogic
if(!empty($params['side_problem'])){
foreach($params['side_problem'] as $v){
if(!empty($v['id'])){
SupervisionSideStationProblem::where('id',$v['id'])->update([
'side_station_id' => $params['id'],
SupervisionProblem::where('id',$v['id'])->update([
'data_id' => $params['id'],
'data_type' => 2,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name'],
'update_time' => time(),
]);
}else{
SupervisionSideStationProblem::create([
'side_station_id' => $params['id'],
SupervisionProblem::create([
'data_id' => $params['id'],
'data_type' => 2,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name'],
'create_user' => $admin_id
]);
}
}
@ -189,7 +194,7 @@ class SupervisionSideStationLogic extends BaseLogic
self::setError('该旁站内容下存在旁站结果数据,请先删除旁站结果数据');
return false;
}
$side_station_problem = SupervisionSideStationProblem::where('side_station_id',$params['id'])->findOrEmpty();
$side_station_problem = SupervisionProblem::where('data_id',$params['id'])->where('data_type',2)->findOrEmpty();
if(!$side_station_problem->isEmpty()){
self::setError('该旁站内容下存在旁站问题数据,请先删除旁站问题数据');
return false;

View File

@ -19,9 +19,9 @@ use app\common\model\dict\DictData;
use app\common\model\supervision_project\SupervisionParticipatingUnits;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionAccept;
use app\common\model\supervision_work\SupervisionAcceptProblem;
use app\common\model\supervision_work\SupervisionAcceptResult;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\validate\BaseValidate;
@ -44,7 +44,7 @@ class SupervisionAcceptValidate extends BaseValidate
'check_item_id' => 'require|checkCheckItem',
'accept_time' => 'require|dateFormat:Y-m-d H:i:s',
'company_id' => 'checkCompany',
'accept_result' => 'in:0,1',
'accept_result' => 'require|in:0,1',
'check_item_detail_ids' => 'checkCheckItemDetail',
'annex' => 'checkAnnex',
'accept_check_result' => 'checkAcceptResult',
@ -92,6 +92,17 @@ class SupervisionAcceptValidate extends BaseValidate
*/
public function sceneEdit()
{}
/**
* @notes 验收场景
* @return SupervisionAcceptValidate
* @author likeadmin
* @date 2024/02/27 15:23
*/
public function sceneAccept()
{
return $this->only(['id','accept_time','accept_result','remark','annex']);
}
/**
@ -211,12 +222,17 @@ class SupervisionAcceptValidate extends BaseValidate
if(!is_array($value)) return '验收问题数据格式错误';
foreach($value as $k=>$v){
if(!empty($v['id'])){
$data = SupervisionAcceptProblem::where('id',$v['id'])->findOrEmpty();
$data = SupervisionProblem::where('id',$v['id'])->findOrEmpty();
if($data->isEmpty()){
return '验收问题列表第'.($k+1).'行数据不存在';
}
}
if(empty($v['problem_cate'])) return '验收问题列表第'.($k+1).'行问题分类为空';
if(empty($v['problem_cate'])){
return '验收问题列表第'.($k+1).'行问题分类为空';
}else{
$dict = DictData::where('type_value','problem_cate')->column('value');
if(!in_array($v['problem_cate'],$dict)) return '验收问题列表第'.($k+1).'行问题分类数据值无效';
}
if(empty($v['problem_description'])) return '验收问题列表第'.($k+1).'行问题说明为空';
if(empty($v['problem_name'])) return '验收问题列表第'.($k+1).'行问题名称为空';
}

View File

@ -20,8 +20,8 @@ use app\common\model\supervision_project\SupervisionParticipatingUnits;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionInspection;
use app\common\model\supervision_work\SupervisionInspectionProblem;
use app\common\model\supervision_work\SupervisionInspectionResult;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\validate\BaseValidate;
@ -219,12 +219,17 @@ class SupervisionInspectionValidate extends BaseValidate
if(!is_array($value)) return '巡视问题数据格式错误';
foreach($value as $k=>$v){
if(!empty($v['id'])){
$data = SupervisionInspectionProblem::where('id',$v['id'])->findOrEmpty();
$data = SupervisionProblem::where('id',$v['id'])->findOrEmpty();
if($data->isEmpty()){
return '巡视问题列表第'.($k+1).'行数据不存在';
}
}
if(empty($v['problem_cate'])) return '巡视问题列表第'.($k+1).'行问题分类为空';
if(empty($v['problem_cate'])){
return '巡视问题列表第'.($k+1).'行问题分类为空';
}else{
$dict = DictData::where('type_value','problem_cate')->column('value');
if(!in_array($v['problem_cate'],$dict)) return '巡视问题列表第'.($k+1).'行问题分类数据值无效';
}
if(empty($v['problem_description'])) return '巡视问题列表第'.($k+1).'行问题说明为空';
if(empty($v['problem_name'])) return '巡视问题列表第'.($k+1).'行问题名称为空';
}

View File

@ -0,0 +1,154 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate\supervision_work;
use app\common\model\dict\DictData;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\validate\BaseValidate;
/**
* 问题跟踪台账验证器
* Class SupervisionProblemValidate
* @package app\adminapi\validate\supervision_work
*/
class SupervisionProblemValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'data_id' => 'require',
'data_type' => 'require|in:1,2,3,4,5,6,7',
'problem_cate' => 'require|checkProblemCate',
'problem_description' => 'require',
'problem_name' => 'require',
'rectification_time' => 'require|dateFormat:Y-m-d',
'rectification_user' => 'require',
'rectification_result' => 'require|in:0,1',
'rectification_opinion' => 'require',
'is_rectification' => 'require|in:0,1',
'rectification_annex' => 'checkAnnex',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'data_id' => '数据id',
'data_type' => '数据类型',
'problem_cate' => '问题分类',
'problem_description' => '问题说明',
'problem_name' => '问题名称',
'rectification_time' => '整改时间',
'rectification_user' => '整改人',
'rectification_result' => '整改结果',
'rectification_opinion' => '整改意见',
'is_rectification' => '是否整改',
];
/**
* @notes 添加场景
* @return SupervisionProblemValidate
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function sceneAdd()
{
return $this->only(['data_id','data_type','problem_cate','problem_description','problem_name']);
}
/**
* @notes 编辑场景
* @return SupervisionProblemValidate
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function sceneEdit()
{
return $this->only(['id','data_id','data_type','problem_cate','problem_description','problem_name']);
}
/**
* @notes 检查验收场景
* @return SupervisionProblemValidate
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function sceneCheck()
{
return $this->only(['id','rectification_time','rectification_user','rectification_result','rectification_opinion','rectification_annex']);
}
/**
* @notes 删除场景
* @return SupervisionProblemValidate
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionProblemValidate
* @author likeadmin
* @date 2024/02/28 09:19
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionProblem::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkProblemCate($value): bool|string
{
$dict = DictData::where('type_value','problem_cate')->column('value');
if(!in_array($value,$dict)){
return '问题分类数据值无效';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != '' && !is_array($value)){
return '附件格式错误';
}
return true;
}
}

View File

@ -19,8 +19,8 @@ use app\common\model\dict\DictData;
use app\common\model\supervision_project\SupervisionParticipatingUnits;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\model\supervision_work\SupervisionSideStation;
use app\common\model\supervision_work\SupervisionSideStationProblem;
use app\common\model\supervision_work\SupervisionSideStationResult;
use app\common\validate\BaseValidate;
@ -216,12 +216,17 @@ class SupervisionSideStationValidate extends BaseValidate
if(!is_array($value)) return '旁站问题数据格式错误';
foreach($value as $k=>$v){
if(!empty($v['id'])){
$data = SupervisionSideStationProblem::where('id',$v['id'])->findOrEmpty();
$data = SupervisionProblem::where('id',$v['id'])->findOrEmpty();
if($data->isEmpty()){
return '旁站问题列表第'.($k+1).'行数据不存在';
}
}
if(empty($v['problem_cate'])) return '旁站问题列表第'.($k+1).'行问题分类为空';
if(empty($v['problem_cate'])){
return '旁站问题列表第'.($k+1).'行问题分类为空';
}else{
$dict = DictData::where('type_value','problem_cate')->column('value');
if(!in_array($v['problem_cate'],$dict)) return '旁站问题列表第'.($k+1).'行问题分类数据值无效';
}
if(empty($v['problem_description'])) return '旁站问题列表第'.($k+1).'行问题说明为空';
if(empty($v['problem_name'])) return '旁站问题列表第'.($k+1).'行问题名称为空';
}

View File

@ -0,0 +1,67 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model\supervision_work;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 问题跟踪台账模型
* Class SupervisionProblem
* @package app\common\model\supervision_work
*/
class SupervisionProblem extends BaseModel
{
use SoftDelete;
protected $name = 'supervision_problem';
protected $deleteTime = 'delete_time';
public function getDataTypeTextAttr($value,$data): string
{
//1-巡视 2-旁站 3-验收 4-设备进场 5-见证取样 6-材料平行检验 7-实体平行检验
$arr = [1=>'巡视', 2=>'旁站', 3=>'验收', 4=>'设备进场', 5=>'见证取样', 6=>'材料平行检验', 7=>'实体平行检验'];
return $arr[$data['data_type']];
}
public function getProblemCateTextAttr($value,$data){
$dict = DictData::where('type_value','problem_cate')->column('name','value');
return !empty($data['problem_cate']) ? $dict[$data['problem_cate']] : '';
}
public function getRectificationResultTextAttr($value,$data): string
{
$arr = [0=>'通过', 1=>'不通过'];
return $arr[$data['rectification_result']];
}
public function getIsRectificationTextAttr($value,$data): string
{
$arr = [0=>'否', 1=>'是'];
return $arr[$data['is_rectification']];
}
public function getRectificationTimeAttr($value,$data): string
{
return !empty($data['rectification_time']) ? date('Y-m-d H:i:s',$data['rectification_time']) : '';
}
public function getRectificationAnnexAttr($value,$data): string
{
return !empty($data['rectification_annex']) ? json_decode($data['rectification_annex'],true) : '';
}
}