136 lines
5.1 KiB
PHP
136 lines
5.1 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\SupervisionDangerousEngineeringCase;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
|
||
use app\common\model\supervision_project\SupervisionProject;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 工程监理--危大方案提交列表逻辑
|
||
* Class SupervisionDangerousEngineeringCaseLogic
|
||
* @package app\adminapi\logic\supervision_dangerous
|
||
*/
|
||
class SupervisionDangerousEngineeringCaseLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加工程监理--危大方案提交列表
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/03/04 14:00
|
||
*/
|
||
public static function add(array $params,$admin_id): bool
|
||
{
|
||
$dangerous_engineering_monitoring = SupervisionDangerousEngineeringMonitoring::where('id',$params['dangerous_engineering_monitoring_id'])->findOrEmpty();
|
||
if($dangerous_engineering_monitoring['status'] != 0){
|
||
self::setError('当前危大工程监控信息已提交方案');
|
||
return false;
|
||
}
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionDangerousEngineeringCase::create([
|
||
'dangerous_engineering_monitoring_id' => $params['dangerous_engineering_monitoring_id'],
|
||
'case_name' => $params['case_name'],
|
||
'assessor' => $params['assessor'],
|
||
'review_content' => $params['review_content'],
|
||
'remark' => $params['remark'],
|
||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||
'create_user' => $admin_id
|
||
]);
|
||
SupervisionDangerousEngineeringMonitoring::where('id',$params['dangerous_engineering_monitoring_id'])->update([
|
||
'status' => 1,
|
||
'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 14:00
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionDangerousEngineeringCase::where('id', $params['id'])->update([
|
||
'case_name' => $params['case_name'],
|
||
'assessor' => $params['assessor'],
|
||
'review_content' => $params['review_content'],
|
||
'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/04 14:00
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return SupervisionDangerousEngineeringCase::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取工程监理--危大方案提交列表详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2024/03/04 14:00
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = SupervisionDangerousEngineeringCase::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||
$dangerous_engineering_monitoring = SupervisionDangerousEngineeringMonitoring::field('project_id,type,partial_project')->where('id',$data['dangerous_engineering_monitoring_id'])->findOrEmpty();
|
||
$project = SupervisionProject::field('project_name')->where('id',$dangerous_engineering_monitoring['project_id'])->findOrEmpty();
|
||
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
|
||
$data['dangerous_engineering_monitoring_title'] = $project['project_name'];
|
||
$data['project_name'] = $project['project_name'];
|
||
$data['type'] = $dangerous_engineering_monitoring->type_text;
|
||
$data['partial_project'] = $dangerous_engineering_monitoring->partial_project_text;
|
||
$data['create_user_name'] = $create_user['name'];
|
||
return $data->toArray();
|
||
}
|
||
} |