新增实体平行验证模块

This commit is contained in:
weiz 2024-02-29 17:16:49 +08:00
parent 0830b5d352
commit 9294e94b27
16 changed files with 655 additions and 22 deletions

@ -102,8 +102,11 @@ class SupervisionAcceptController extends BaseAdminController
public function delete()
{
$params = (new SupervisionAcceptValidate())->post()->goCheck('delete');
SupervisionAcceptLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = SupervisionAcceptLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionAcceptLogic::getError());
}

@ -86,8 +86,11 @@ class SupervisionCheckItemController extends BaseAdminController
public function delete()
{
$params = (new SupervisionCheckItemValidate())->post()->goCheck('delete');
SupervisionCheckItemLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = SupervisionCheckItemLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionCheckItemLogic::getError());
}

@ -86,8 +86,11 @@ class SupervisionDeviceEntryController extends BaseAdminController
public function delete()
{
$params = (new SupervisionDeviceEntryValidate())->post()->goCheck('delete');
SupervisionDeviceEntryLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = SupervisionDeviceEntryLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionDeviceEntryLogic::getError());
}

@ -0,0 +1,111 @@
<?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\SupervisionEntityParallelTestingLists;
use app\adminapi\logic\supervision_work\SupervisionEntityParallelTestingLogic;
use app\adminapi\validate\supervision_work\SupervisionEntityParallelTestingValidate;
/**
* 工程监理--实体平行检验控制器
* Class SupervisionEntityParallelTestingController
* @package app\adminapi\controller\supervision_work
*/
class SupervisionEntityParallelTestingController extends BaseAdminController
{
/**
* @notes 获取工程监理--实体平行检验列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function lists()
{
return $this->dataLists(new SupervisionEntityParallelTestingLists());
}
/**
* @notes 添加工程监理--实体平行检验
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function add()
{
$params = (new SupervisionEntityParallelTestingValidate())->post()->goCheck('add');
$result = SupervisionEntityParallelTestingLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SupervisionEntityParallelTestingLogic::getError());
}
/**
* @notes 编辑工程监理--实体平行检验
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function edit()
{
$params = (new SupervisionEntityParallelTestingValidate())->post()->goCheck('edit');
$result = SupervisionEntityParallelTestingLogic::edit($params,$this->adminId);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SupervisionEntityParallelTestingLogic::getError());
}
/**
* @notes 删除工程监理--实体平行检验
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function delete()
{
$params = (new SupervisionEntityParallelTestingValidate())->post()->goCheck('delete');
$result = SupervisionEntityParallelTestingLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionEntityParallelTestingLogic::getError());
}
/**
* @notes 获取工程监理--实体平行检验详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function detail()
{
$params = (new SupervisionEntityParallelTestingValidate())->goCheck('detail');
$result = SupervisionEntityParallelTestingLogic::detail($params);
return $this->data($result);
}
}

@ -86,8 +86,11 @@ class SupervisionInspectionController extends BaseAdminController
public function delete()
{
$params = (new SupervisionInspectionValidate())->post()->goCheck('delete');
SupervisionInspectionLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = SupervisionInspectionLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionInspectionLogic::getError());
}

@ -86,8 +86,11 @@ class SupervisionMaterialEntryController extends BaseAdminController
public function delete()
{
$params = (new SupervisionMaterialEntryValidate())->post()->goCheck('delete');
SupervisionMaterialEntryLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = SupervisionMaterialEntryLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionMaterialEntryLogic::getError());
}

@ -86,8 +86,11 @@ class SupervisionMaterialParallelTestingController extends BaseAdminController
public function delete()
{
$params = (new SupervisionMaterialParallelTestingValidate())->post()->goCheck('delete');
SupervisionMaterialParallelTestingLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = SupervisionMaterialParallelTestingLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionMaterialParallelTestingLogic::getError());
}

@ -102,8 +102,11 @@ class SupervisionMaterialParallelTestingDetailController extends BaseAdminContro
public function delete()
{
$params = (new SupervisionMaterialParallelTestingDetailValidate())->post()->goCheck('delete');
SupervisionMaterialParallelTestingDetailLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = SupervisionMaterialParallelTestingDetailLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionMaterialParallelTestingDetailLogic::getError());
}

@ -86,8 +86,11 @@ class SupervisionSideStationController extends BaseAdminController
public function delete()
{
$params = (new SupervisionSideStationValidate())->post()->goCheck('delete');
SupervisionSideStationLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = SupervisionSideStationLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionSideStationLogic::getError());
}

@ -86,8 +86,11 @@ class SupervisionTestBlocksSpecimensController extends BaseAdminController
public function delete()
{
$params = (new SupervisionTestBlocksSpecimensValidate())->post()->goCheck('delete');
SupervisionTestBlocksSpecimensLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = SupervisionTestBlocksSpecimensLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionTestBlocksSpecimensLogic::getError());
}

@ -86,8 +86,11 @@ class SupervisionWitnessSamplingController extends BaseAdminController
public function delete()
{
$params = (new SupervisionWitnessSamplingValidate())->post()->goCheck('delete');
SupervisionWitnessSamplingLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = SupervisionWitnessSamplingLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionWitnessSamplingLogic::getError());
}

@ -102,8 +102,11 @@ class SupervisionWitnessSamplingDetailController extends BaseAdminController
public function delete()
{
$params = (new SupervisionWitnessSamplingDetailValidate())->post()->goCheck('delete');
SupervisionWitnessSamplingDetailLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
$result = SupervisionWitnessSamplingDetailLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionWitnessSamplingDetailLogic::getError());
}

@ -0,0 +1,88 @@
<?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_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionEntityParallelTesting;
use app\common\lists\ListsSearchInterface;
/**
* 工程监理--实体平行检验列表
* Class SupervisionEntityParallelTestingLists
* @package app\adminapi\listssupervision_work
*/
class SupervisionEntityParallelTestingLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function setSearch(): array
{
return [
'=' => ['project_id', 'result'],
'%like%' => ['theme', 'code', 'position'],
];
}
/**
* @notes 获取工程监理--实体平行检验列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function lists(): array
{
return SupervisionEntityParallelTesting::withoutField('update_time,delete_time')->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
$check_item = SupervisionCheckItem::field('node_name')->where('id',$data['check_item_id'])->findOrEmpty();
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
$data['project_name'] = $project['project_name'];
$data['check_item_name'] = $check_item['node_name'];
$data['create_user_name'] = $create_user['name'];
$data['result_text'] = $data->result_text;
})
->toArray();
}
/**
* @notes 获取工程监理--实体平行检验数量
* @return int
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function count(): int
{
return SupervisionEntityParallelTesting::where($this->searchWhere)->count();
}
}

@ -0,0 +1,177 @@
<?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_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionEntityParallelTesting;
use app\common\logic\BaseLogic;
use app\common\model\supervision_work\SupervisionProblem;
use think\facade\Db;
/**
* 工程监理--实体平行检验逻辑
* Class SupervisionEntityParallelTestingLogic
* @package app\adminapi\logic\supervision_work
*/
class SupervisionEntityParallelTestingLogic extends BaseLogic
{
/**
* @notes 添加工程监理--实体平行检验
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/29 16:32
*/
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
$res = SupervisionEntityParallelTesting::create([
'project_id' => $params['project_id'],
'theme' => $params['theme'],
'code' => data_unique_code('STPXJY'),
'check_item_id' => $params['check_item_id'],
'position' => $params['position'],
'start_time' => !empty($params['start_time']) ? strtotime($params['start_time']) : 0,
'end_time' => !empty($params['end_time']) ? strtotime($params['end_time']) : 0,
'result' => $params['result'],
'remark' => $params['remark'],
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'create_user' => $admin_id
]);
if(!empty($params['problem'])){
foreach($params['problem'] as $v){
SupervisionProblem::create([
'data_id' => $res->id,
'data_type' => 8,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name'],
'create_user' => $admin_id,
]);
}
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑工程监理--实体平行检验
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/29 16:32
*/
public static function edit(array $params,$admin_id): bool
{
Db::startTrans();
try {
SupervisionEntityParallelTesting::where('id', $params['id'])->update([
'project_id' => $params['project_id'],
'theme' => $params['theme'],
'check_item_id' => $params['check_item_id'],
'position' => $params['position'],
'start_time' => !empty($params['start_time']) ? strtotime($params['start_time']) : 0,
'end_time' => !empty($params['end_time']) ? strtotime($params['end_time']) : 0,
'result' => $params['result'],
'remark' => $params['remark'],
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'update_time' => time(),
]);
if(!empty($params['problem'])){
foreach($params['problem'] as $v){
if(!empty($v['id'])){
SupervisionProblem::where('id',$v['id'])->update([
'data_id' => $params['id'],
'data_type' => 8,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name'],
'update_time' => time(),
]);
}else{
SupervisionProblem::create([
'data_id' => $params['id'],
'data_type' => 8,
'problem_cate' => $v['problem_cate'],
'problem_description' => $v['problem_description'],
'problem_name' => $v['problem_name'],
'create_user' => $admin_id,
]);
}
}
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除工程监理--实体平行检验
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/29 16:32
*/
public static function delete(array $params): bool
{
$problem = SupervisionProblem::where('data_id',$params['id'])->where('data_type',8)->findOrEmpty();
if(!$problem->isEmpty()){
self::setError('该内容下存在实体平行检验问题数据,请先删除实体平行检验问题数据');
return false;
}
return SupervisionEntityParallelTesting::destroy($params['id']);
}
/**
* @notes 获取工程监理--实体平行检验详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/02/29 16:32
*/
public static function detail($params): array
{
$data = SupervisionEntityParallelTesting::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
$check_item = SupervisionCheckItem::field('node_name')->where('id',$data['check_item_id'])->findOrEmpty();
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
$data['project_name'] = $project['project_name'];
$data['check_item_name'] = $check_item['node_name'];
$data['create_user_name'] = $create_user['name'];
$data['result_text'] = $data->result_text;
$data['problem_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',8)->count();
$data['reply_num'] = SupervisionProblem::field('id')->where('data_id',$data['id'])->where('data_type',8)->where('is_rectification',1)->count();
return $data->toArray();
}
}

@ -0,0 +1,172 @@
<?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_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\model\supervision_work\SupervisionEntityParallelTesting;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\validate\BaseValidate;
/**
* 工程监理--实体平行检验验证器
* Class SupervisionEntityParallelTestingValidate
* @package app\adminapi\validate\supervision_work
*/
class SupervisionEntityParallelTestingValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'project_id' => 'require|checkProject',
'theme' => 'require',
'check_item_id' => 'checkCheckItem',
'start_time' => 'require|dateFormat:Y-m-d',
'end_time' => 'require|dateFormat:Y-m-d',
'result' => 'require|in:0,1',
'annex' => 'checkAnnex',
'problem' => 'checkProblem'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'project_id' => '项目id',
'theme' => '检验主题',
'code' => '编号',
'check_item_id' => '工程单位',
'position' => '检验部位',
'start_time' => '开始时间',
'end_time' => '结束时间',
'result' => '检验结果',
'remark' => '备注',
'create_user' => '创建人',
];
/**
* @notes 添加场景
* @return SupervisionEntityParallelTestingValidate
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return SupervisionEntityParallelTestingValidate
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return SupervisionEntityParallelTestingValidate
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionEntityParallelTestingValidate
* @author likeadmin
* @date 2024/02/29 16:32
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value){
$data = SupervisionEntityParallelTesting::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkProject($value): bool|string
{
$data = SupervisionProject::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '项目信息不存在';
}
return true;
}
public function checkCheckItem($value,$rule,$params): bool|string
{
$data = SupervisionCheckItem::where('id',$value)->where('project_id',$params['project_id'])->where('node_type',2)->findOrEmpty();
if($data->isEmpty()){
return '工程单位信息不存在';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != '' && !is_array($value)){
return '附件格式错误';
}
return true;
}
public function checkProblem($value): bool|string
{
if(!isset($value) || $value == '') return true;
if(!is_array($value)) return '试块试件见证问题数据格式错误';
foreach($value as $k=>$v){
if(!empty($v['id'])){
$data = SupervisionProblem::where('id',$v['id'])->findOrEmpty();
if($data->isEmpty()){
return '试块试件见证问题列表第'.($k+1).'行数据不存在';
}
}
if(empty($v['problem_cate'])){
return '试块试件见证问题列表第'.($k+1).'行问题分类为空';
}else{
$dict = DictData::where('type_value','problem_cate')->column('value');
if(!in_array($v['problem_cate'],$dict)) return '试块试件见证问题列表第'.($k+1).'行问题分类数据值无效';
}
if(empty($v['problem_description'])) return '试块试件见证问题列表第'.($k+1).'行问题说明为空';
if(empty($v['problem_name'])) return '试块试件见证问题列表第'.($k+1).'行问题名称为空';
}
return true;
}
}

@ -0,0 +1,52 @@
<?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 think\model\concern\SoftDelete;
/**
* 工程监理--实体平行检验模型
* Class SupervisionEntityParallelTesting
* @package app\common\model\supervision_work
*/
class SupervisionEntityParallelTesting extends BaseModel
{
use SoftDelete;
protected $name = 'supervision_entity_parallel_testing';
protected $deleteTime = 'delete_time';
public function getAnnexAttr($value)
{
return !empty($value) ? json_decode($value,true) : '';
}
public function getResultTextAttr($value,$data){
$arr = [0=>'符合标准', 1=>'不符合标准'];
return $arr[$data['result']];
}
public function getStartTimeAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getEndTimeAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
}