153 lines
6.8 KiB
PHP
153 lines
6.8 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_qualification_review;
|
||
|
||
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\supervision_project\SupervisionParticipatingUnits;
|
||
use app\common\model\supervision_qualification_review\SupervisionParticipatingUnitsQualifications;
|
||
use app\common\model\supervision_qualification_review\SupervisionSafetyManagementPersonnel;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 工程监理--安全管理人员逻辑
|
||
* Class SupervisionSafetyManagementPersonnelLogic
|
||
* @package app\adminapi\logic\supervision_qualification_review
|
||
*/
|
||
class SupervisionSafetyManagementPersonnelLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加工程监理--安全管理人员
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/02/26 11:30
|
||
*/
|
||
public static function add(array $params,$admin_id): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionSafetyManagementPersonnel::create([
|
||
'unit_qualification_id' => $params['unit_qualification_id'],
|
||
'name' => $params['name'],
|
||
'id_card' => $params['id_card'],
|
||
'technical_title' => $params['technical_title'],
|
||
'job' => $params['job'],
|
||
'qualification_name_one' => $params['qualification_name_one'],
|
||
'certification_body_one' => $params['certification_body_one'],
|
||
'qualification_number_one' => $params['qualification_number_one'],
|
||
'get_date_one' => !empty($params['get_date_one']) ? strtotime($params['get_date_one']) : 0,
|
||
'effective_date_one' => !empty($params['effective_date_one']) ? strtotime($params['effective_date_one']) : 0,
|
||
'qualification_one_status' => $params['qualification_one_status'],
|
||
'qualification_name_two' => $params['qualification_name_two'],
|
||
'certification_body_two' => $params['certification_body_two'],
|
||
'qualification_number_two' => $params['qualification_number_two'],
|
||
'get_date_two' => !empty($params['get_date_two']) ? strtotime($params['get_date_two']) : 0,
|
||
'effective_date_two' => !empty($params['effective_date_two']) ? strtotime($params['effective_date_two']) : 0,
|
||
'qualification_two_status' => $params['qualification_two_status'],
|
||
'remark' => $params['remark'],
|
||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||
'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/26 11:30
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionSafetyManagementPersonnel::where('id', $params['id'])->update([
|
||
'unit_qualification_id' => $params['unit_qualification_id'],
|
||
'name' => $params['name'],
|
||
'id_card' => $params['id_card'],
|
||
'technical_title' => $params['technical_title'],
|
||
'job' => $params['job'],
|
||
'qualification_name_one' => $params['qualification_name_one'],
|
||
'certification_body_one' => $params['certification_body_one'],
|
||
'qualification_number_one' => $params['qualification_number_one'],
|
||
'get_date_one' => !empty($params['get_date_one']) ? strtotime($params['get_date_one']) : 0,
|
||
'effective_date_one' => !empty($params['effective_date_one']) ? strtotime($params['effective_date_one']) : 0,
|
||
'qualification_one_status' => $params['qualification_one_status'],
|
||
'qualification_name_two' => $params['qualification_name_two'],
|
||
'certification_body_two' => $params['certification_body_two'],
|
||
'qualification_number_two' => $params['qualification_number_two'],
|
||
'get_date_two' => !empty($params['get_date_two']) ? strtotime($params['get_date_two']) : 0,
|
||
'effective_date_two' => !empty($params['effective_date_two']) ? strtotime($params['effective_date_two']) : 0,
|
||
'qualification_two_status' => $params['qualification_two_status'],
|
||
'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/02/26 11:30
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return SupervisionSafetyManagementPersonnel::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取工程监理--安全管理人员详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2024/02/26 11:30
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = SupervisionSafetyManagementPersonnel::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||
$unit_qualification = SupervisionParticipatingUnitsQualifications::field('company_id')->where('id',$data['unit_qualification_id'])->findOrEmpty();
|
||
$company = SupervisionParticipatingUnits::field('unit_name')->where('id',$unit_qualification['company_id'])->findOrEmpty();
|
||
$admin = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
|
||
$data['company_name'] = $company['unit_name'];
|
||
$data['create_user_name'] = $admin['name'];
|
||
$data['qualification_one_status_text'] = $data->qualification_one_status_text;
|
||
$data['qualification_two_status_text'] = $data->qualification_two_status_text;
|
||
return $data->toArray();
|
||
}
|
||
} |