新增危险性较大工程安全监控模块

This commit is contained in:
weiz 2024-03-04 10:08:01 +08:00
parent 035d551e6c
commit b04b7e3cc6
5 changed files with 588 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\SupervisionHighRiskSecurityMonitoringLists;
use app\adminapi\logic\supervision_dangerous\SupervisionHighRiskSecurityMonitoringLogic;
use app\adminapi\validate\supervision_dangerous\SupervisionHighRiskSecurityMonitoringValidate;
/**
* 工程监理--危险性较大的工程安全监控控制器
* Class SupervisionHighRiskSecurityMonitoringController
* @package app\adminapi\controller\supervision_dangerous
*/
class SupervisionHighRiskSecurityMonitoringController extends BaseAdminController
{
/**
* @notes 获取工程监理--危险性较大的工程安全监控列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function lists()
{
return $this->dataLists(new SupervisionHighRiskSecurityMonitoringLists());
}
/**
* @notes 添加工程监理--危险性较大的工程安全监控
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function add()
{
$params = (new SupervisionHighRiskSecurityMonitoringValidate())->post()->goCheck('add');
$result = SupervisionHighRiskSecurityMonitoringLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SupervisionHighRiskSecurityMonitoringLogic::getError());
}
/**
* @notes 编辑工程监理--危险性较大的工程安全监控
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function edit()
{
$params = (new SupervisionHighRiskSecurityMonitoringValidate())->post()->goCheck('edit');
$result = SupervisionHighRiskSecurityMonitoringLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SupervisionHighRiskSecurityMonitoringLogic::getError());
}
/**
* @notes 删除工程监理--危险性较大的工程安全监控
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function delete()
{
$params = (new SupervisionHighRiskSecurityMonitoringValidate())->post()->goCheck('delete');
SupervisionHighRiskSecurityMonitoringLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取工程监理--危险性较大的工程安全监控详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function detail()
{
$params = (new SupervisionHighRiskSecurityMonitoringValidate())->goCheck('detail');
$result = SupervisionHighRiskSecurityMonitoringLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,82 @@
<?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\SupervisionHighRiskSecurityMonitoring;
use app\common\lists\ListsSearchInterface;
use app\common\model\supervision_project\SupervisionProject;
/**
* 工程监理--危险性较大的工程安全监控列表
* Class SupervisionHighRiskSecurityMonitoringLists
* @package app\adminapi\listssupervision_dangerous
*/
class SupervisionHighRiskSecurityMonitoringLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function setSearch(): array
{
return [
'=' => ['project_id', 'partial_project', 'project_characteristics'],
];
}
/**
* @notes 获取工程监理--危险性较大的工程安全监控列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function lists(): array
{
return SupervisionHighRiskSecurityMonitoring::where($this->searchWhere)
->field(['id', 'project_id', 'partial_project', 'attribution_date', 'project_characteristics', 'planned_construction_time'])
->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'];
$data['partial_project_text'] = $data->partial_project_text;
})
->toArray();
}
/**
* @notes 获取工程监理--危险性较大的工程安全监控数量
* @return int
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function count(): int
{
return SupervisionHighRiskSecurityMonitoring::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,152 @@
<?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\auth\Admin;
use app\common\model\supervision_dangerous\SupervisionHighRiskSecurityMonitoring;
use app\common\logic\BaseLogic;
use app\common\model\supervision_project\SupervisionProject;
use think\facade\Db;
/**
* 工程监理--危险性较大的工程安全监控逻辑
* Class SupervisionHighRiskSecurityMonitoringLogic
* @package app\adminapi\logic\supervision_dangerous
*/
class SupervisionHighRiskSecurityMonitoringLogic extends BaseLogic
{
/**
* @notes 添加工程监理--危险性较大的工程安全监控
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/03/04 09:22
*/
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
SupervisionHighRiskSecurityMonitoring::create([
'project_id' => $params['project_id'],
'partial_project' => $params['partial_project'],
'attribution_date' => !empty($params['attribution_date']) ? strtotime($params['attribution_date']) : 0,
'project_characteristics' => $params['project_characteristics'],
'planned_construction_time' => !empty($params['planned_construction_time']) ? strtotime($params['planned_construction_time']) : 0,
'actual_construction_time' => !empty($params['actual_construction_time']) ? strtotime($params['actual_construction_time']) : 0,
'is_report' => $params['is_report'],
'is_agree' => $params['is_agree'],
'is_accept' => $params['is_accept'],
'is_accept_to_plan' => $params['is_accept_to_plan'],
'check_user' => $params['check_user'],
'check_time' => !empty($params['check_time']) ? strtotime($params['check_time']) : 0,
'problems_rectification' => $params['problems_rectification'],
'responsible_person' => $params['responsible_person'],
'exceed_the_control_value' => $params['exceed_the_control_value'],
'exceed_the_warning_value' => $params['exceed_the_warning_value'],
'control_measures' => $params['control_measures'],
'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/03/04 09:22
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
SupervisionHighRiskSecurityMonitoring::where('id', $params['id'])->update([
'project_id' => $params['project_id'],
'partial_project' => $params['partial_project'],
'attribution_date' => !empty($params['attribution_date']) ? strtotime($params['attribution_date']) : 0,
'project_characteristics' => $params['project_characteristics'],
'planned_construction_time' => !empty($params['planned_construction_time']) ? strtotime($params['planned_construction_time']) : 0,
'actual_construction_time' => !empty($params['actual_construction_time']) ? strtotime($params['actual_construction_time']) : 0,
'is_report' => $params['is_report'],
'is_agree' => $params['is_agree'],
'is_accept' => $params['is_accept'],
'is_accept_to_plan' => $params['is_accept_to_plan'],
'check_user' => $params['check_user'],
'check_time' => !empty($params['check_time']) ? strtotime($params['check_time']) : 0,
'problems_rectification' => $params['problems_rectification'],
'responsible_person' => $params['responsible_person'],
'exceed_the_control_value' => $params['exceed_the_control_value'],
'exceed_the_warning_value' => $params['exceed_the_warning_value'],
'control_measures' => $params['control_measures'],
'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/04 09:22
*/
public static function delete(array $params): bool
{
return SupervisionHighRiskSecurityMonitoring::destroy($params['id']);
}
/**
* @notes 获取工程监理--危险性较大的工程安全监控详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/03/04 09:22
*/
public static function detail($params): array
{
$data = SupervisionHighRiskSecurityMonitoring::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
$admin = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
$data['project_name'] = $project['project_name'];
$data['create_user_name'] = $admin['name'];
$data['partial_project_text'] = $data->partial_project_text;
$data['is_report_text'] = $data->is_report_text;
$data['is_agree_text'] = $data->is_agree_text;
$data['is_accept_text'] = $data->is_accept_text;
$data['is_accept_to_plan_text'] = $data->is_accept_to_plan_text;
$data['exceed_the_control_value_text'] = $data->exceed_the_control_value_text;
$data['exceed_the_warning_value_text'] = $data->exceed_the_warning_value_text;
return $data->toArray();
}
}

View File

@ -0,0 +1,152 @@
<?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\dict\DictData;
use app\common\model\supervision_dangerous\SupervisionHighRiskSecurityMonitoring;
use app\common\model\supervision_project\SupervisionProject;
use app\common\validate\BaseValidate;
/**
* 工程监理--危险性较大的工程安全监控验证器
* Class SupervisionHighRiskSecurityMonitoringValidate
* @package app\adminapi\validate\supervision_dangerous
*/
class SupervisionHighRiskSecurityMonitoringValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'project_id' => 'require|checkProject',
'partial_project' => 'require|checkPartialProject',
'attribution_date' => 'require|dateFormat:Y-m',
'planned_construction_time' => 'dateFormat:Y-m-d',
'actual_construction_time' => 'dateFormat:Y-m-d',
'is_report' => 'require|in:0,1',
'is_agree' => 'require|in:0,1',
'is_accept' => 'require|in:0,1',
'is_accept_to_plan' => 'require|in:0,1',
'check_time' => 'dateFormat:Y-m-d',
'exceed_the_control_value' => 'require|in:0,1',
'exceed_the_warning_value' => 'require|in:0,1',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'project_id' => '项目id',
'partial_project' => '分部分项工程',
'attribution_date' => '归属年月',
'project_characteristics' => '本项目特征',
'planned_construction_time' => '计划施工时间',
'actual_construction_time' => '实际施工时间',
'is_report' => '施工方案是否上报监理',
'is_agree' => '监理审批是否同意',
'is_accept' => '是否实施验收',
'is_accept_to_plan' => '是否按方案实施验收',
'check_user' => '检查人',
'check_time' => '检查时间',
'problems_rectification' => '存在问题和整改情况',
'responsible_person' => '项目部监控责任人',
'exceed_the_control_value' => '是否超控制值',
'exceed_the_warning_value' => '是否超预警值',
'control_measures' => '控制措施',
'create_user' => '创建人',
];
/**
* @notes 添加场景
* @return SupervisionHighRiskSecurityMonitoringValidate
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return SupervisionHighRiskSecurityMonitoringValidate
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return SupervisionHighRiskSecurityMonitoringValidate
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionHighRiskSecurityMonitoringValidate
* @author likeadmin
* @date 2024/03/04 09:22
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionHighRiskSecurityMonitoring::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 checkPartialProject($value): bool|string
{
$dict = DictData::where('type_value','partial_project')->column('value');
if(!in_array($value,$dict)){
return '分部分项工程数据值无效';
}
return true;
}
}

View File

@ -0,0 +1,94 @@
<?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 app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 工程监理--危险性较大的工程安全监控模型
* Class SupervisionHighRiskSecurityMonitoring
* @package app\common\model\supervision_dangerous
*/
class SupervisionHighRiskSecurityMonitoring extends BaseModel
{
use SoftDelete;
protected $name = 'supervision_high_risk_security_monitoring';
protected $deleteTime = 'delete_time';
public function getPartialProjectTextAttr($value,$data){
$dict = DictData::where('type_value','partial_project')->column('name','value');
return !empty($data['partial_project']) ? $dict[$data['partial_project']] : '';
}
public function getIsReportTextAttr($value,$data): string
{
$arr = [0=>'否', 1=>'是'];
return $arr[$data['is_report']];
}
public function getIsAgreeTextAttr($value,$data): string
{
$arr = [0=>'否', 1=>'是'];
return $arr[$data['is_agree']];
}
public function getIsAcceptTextAttr($value,$data): string
{
$arr = [0=>'否', 1=>'是'];
return $arr[$data['is_accept']];
}
public function getIsAcceptToPlanTextAttr($value,$data): string
{
$arr = [0=>'否', 1=>'是'];
return $arr[$data['is_accept_to_plan']];
}
public function getExceedTheControlValueTextAttr($value,$data): string
{
$arr = [0=>'否', 1=>'是'];
return $arr[$data['exceed_the_control_value']];
}
public function getExceedTheWarningValueTextAttr($value,$data): string
{
$arr = [0=>'否', 1=>'是'];
return $arr[$data['exceed_the_warning_value']];
}
public function getattribution_dateAttr($value): string
{
return !empty($value) ? date('Y-m',$value) : '';
}
public function getPlannedConstructionTimeAttr($value): string
{
return !empty($value) ? date('Y-m-d',$value) : '';
}
public function getActualConstructionTimeAttr($value): string
{
return !empty($value) ? date('Y-m-d',$value) : '';
}
public function getCheckTimeAttr($value): string
{
return !empty($value) ? date('Y-m-d',$value) : '';
}
}