152 lines
6.6 KiB
PHP
152 lines
6.6 KiB
PHP
<?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();
|
||
}
|
||
} |