新增现场安全警示标志模块

This commit is contained in:
weiz 2024-03-01 16:12:44 +08:00
parent e3f68fb903
commit 2e7dc28f53
6 changed files with 487 additions and 0 deletions

View File

@ -0,0 +1,108 @@
<?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_dangerous;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\supervision_dangerous\SupervisionSafetyWarningSignLists;
use app\adminapi\logic\supervision_dangerous\SupervisionSafetyWarningSignLogic;
use app\adminapi\validate\supervision_dangerous\SupervisionSafetyWarningSignValidate;
/**
* 工程监理--现场安全警示标志控制器
* Class SupervisionSafetyWarningSignController
* @package app\adminapi\controller\supervision_dangerous
*/
class SupervisionSafetyWarningSignController extends BaseAdminController
{
/**
* @notes 获取工程监理--现场安全警示标志列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function lists()
{
return $this->dataLists(new SupervisionSafetyWarningSignLists());
}
/**
* @notes 添加工程监理--现场安全警示标志
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function add()
{
$params = (new SupervisionSafetyWarningSignValidate())->post()->goCheck('add');
$result = SupervisionSafetyWarningSignLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SupervisionSafetyWarningSignLogic::getError());
}
/**
* @notes 编辑工程监理--现场安全警示标志
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function edit()
{
$params = (new SupervisionSafetyWarningSignValidate())->post()->goCheck('edit');
$result = SupervisionSafetyWarningSignLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SupervisionSafetyWarningSignLogic::getError());
}
/**
* @notes 删除工程监理--现场安全警示标志
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function delete()
{
$params = (new SupervisionSafetyWarningSignValidate())->post()->goCheck('delete');
SupervisionSafetyWarningSignLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取工程监理--现场安全警示标志详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function detail()
{
$params = (new SupervisionSafetyWarningSignValidate())->goCheck('detail');
$result = SupervisionSafetyWarningSignLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,81 @@
<?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_dangerous;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\supervision_dangerous\SupervisionSafetyWarningSign;
use app\common\lists\ListsSearchInterface;
use app\common\model\supervision_project\SupervisionProject;
/**
* 工程监理--现场安全警示标志列表
* Class SupervisionSafetyWarningSignLists
* @package app\adminapi\listssupervision_dangerous
*/
class SupervisionSafetyWarningSignLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function setSearch(): array
{
return [
'=' => ['project_id'],
'%like%' => ['check_user', 'check_area'],
];
}
/**
* @notes 获取工程监理--现场安全警示标志列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function lists(): array
{
return SupervisionSafetyWarningSign::withoutField('create_time,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();
$data['project_name'] = $project['project_name'];
})
->toArray();
}
/**
* @notes 获取工程监理--现场安全警示标志数量
* @return int
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function count(): int
{
return SupervisionSafetyWarningSign::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,121 @@
<?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_dangerous;
use app\common\model\supervision_dangerous\SupervisionSafetyWarningSign;
use app\common\logic\BaseLogic;
use app\common\model\supervision_project\SupervisionProject;
use think\facade\Db;
/**
* 工程监理--现场安全警示标志逻辑
* Class SupervisionSafetyWarningSignLogic
* @package app\adminapi\logic\supervision_dangerous
*/
class SupervisionSafetyWarningSignLogic extends BaseLogic
{
/**
* @notes 添加工程监理--现场安全警示标志
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/03/01 15:41
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
SupervisionSafetyWarningSign::create([
'project_id' => $params['project_id'],
'check_user' => $params['check_user'],
'check_date' => !empty($params['check_date']) ? strtotime($params['check_date']) : 0,
'check_area' => $params['check_area'],
'problem_desc' => $params['problem_desc'],
'remark' => $params['remark'],
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
]);
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/03/01 15:41
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
SupervisionSafetyWarningSign::where('id', $params['id'])->update([
'project_id' => $params['project_id'],
'check_user' => $params['check_user'],
'check_date' => !empty($params['check_date']) ? strtotime($params['check_date']) : 0,
'check_area' => $params['check_area'],
'problem_desc' => $params['problem_desc'],
'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
* @author likeadmin
* @date 2024/03/01 15:41
*/
public static function delete(array $params): bool
{
return SupervisionSafetyWarningSign::destroy($params['id']);
}
/**
* @notes 获取工程监理--现场安全警示标志详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/03/01 15:41
*/
public static function detail($params): array
{
$data = SupervisionSafetyWarningSign::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
$data['project_name'] = $project['project_name'];
return $data->toArray();
}
}

View File

@ -107,6 +107,7 @@ class SupervisionInspectionLogic extends BaseLogic
*/
public static function edit(array $params,$admin_id): bool
{
$data = SupervisionInspection::field('check_item_detail_ids')->where('id',$params['id'])->findOrEmpty();
Db::startTrans();
try {
SupervisionInspection::where('id', $params['id'])->update([
@ -127,6 +128,10 @@ class SupervisionInspectionLogic extends BaseLogic
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'update_time' => time(),
]);
if(json_encode($data['check_item_detail_ids']) != json_encode($params['check_item_detail_ids'])){
$supervision_inspection_result_ids = SupervisionInspectionResult::where('inspection_id',$params['id'])->column('id');
SupervisionInspectionResult::where('id','in',$supervision_inspection_result_ids)->delete();
}
if(!empty($params['inspection_result'])){
foreach($params['inspection_result'] as $v){
if(!empty($v['id'])){

View File

@ -0,0 +1,131 @@
<?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_dangerous;
use app\common\model\supervision_dangerous\SupervisionSafetyWarningSign;
use app\common\model\supervision_project\SupervisionProject;
use app\common\validate\BaseValidate;
/**
* 工程监理--现场安全警示标志验证器
* Class SupervisionSafetyWarningSignValidate
* @package app\adminapi\validate\supervision_dangerous
*/
class SupervisionSafetyWarningSignValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'project_id' => 'require|checkProject',
'check_user' => 'require',
'check_date' => 'require|dateFormat:Y-m-d',
'check_area' => 'require',
'annex' => 'checkAnnex',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'project_id' => '项目id',
'check_user' => '检查人',
'check_date' => '检查日期',
'check_area' => '检查地点',
'problem_desc' => '问题描述',
'remark' => '备注',
];
/**
* @notes 添加场景
* @return SupervisionSafetyWarningSignValidate
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return SupervisionSafetyWarningSignValidate
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return SupervisionSafetyWarningSignValidate
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionSafetyWarningSignValidate
* @author likeadmin
* @date 2024/03/01 15:41
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionSafetyWarningSign::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 checkAnnex($value): bool|string
{
if(!empty($value) && $value != '' && !is_array($value)){
return '附件格式错误';
}
return true;
}
}

View File

@ -0,0 +1,41 @@
<?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_dangerous;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 工程监理--现场安全警示标志模型
* Class SupervisionSafetyWarningSign
* @package app\common\model\supervision_dangerous
*/
class SupervisionSafetyWarningSign extends BaseModel
{
use SoftDelete;
protected $name = 'supervision_safety_warning_sign';
protected $deleteTime = 'delete_time';
public function getAnnexAttr($value){
return !empty($value) ? json_decode($value,true) : '';
}
public function getCheckDateAttr($value): string
{
return !empty($value) ? date('Y-m-d',$value) : '';
}
}