166 lines
7.0 KiB
PHP
166 lines
7.0 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_project;
|
||
|
||
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\supervision_project\SupervisionProject;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 工程监理--监理项目信息逻辑
|
||
* Class SupervisionProjectLogic
|
||
* @package app\adminapi\logic\supervision_project
|
||
*/
|
||
class SupervisionProjectLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加工程监理--监理项目信息
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/02/23 09:52
|
||
*/
|
||
public static function add(array $params,$admin_id): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionProject::create([
|
||
'project_name' => $params['project_name'],
|
||
'project_code' => data_unique_code('JLXM'),
|
||
'industry' => $params['industry'],
|
||
'nature' => $params['nature'],
|
||
'build_unit' => $params['build_unit'],
|
||
'build_area' => $params['build_area'],
|
||
'address' => $params['address'],
|
||
'project_level' => $params['project_level'],
|
||
'total_investment' => $params['total_investment'],
|
||
'initiation_date' => $params['initiation_date'],
|
||
'contract' => $params['contract'],
|
||
'contract_amount' => $params['contract_amount'],
|
||
'actual_start_date' => !empty($params['actual_start_date']) ? strtotime($params['actual_start_date']) : 0,
|
||
'actual_end_date' => !empty($params['actual_end_date']) ? strtotime($params['actual_end_date']) : 0,
|
||
'planned_start_date' => !empty($params['planned_start_date']) ? strtotime($params['planned_start_date']) : 0,
|
||
'planned_end_date' => !empty($params['planned_end_date']) ? strtotime($params['planned_end_date']) : 0,
|
||
'contract_content' => $params['contract_content'],
|
||
'project_overview' => $params['project_overview'],
|
||
'project_requirements' => $params['project_requirements'],
|
||
'remark' => $params['remark'],
|
||
'supervision_department' => $params['supervision_department'],
|
||
'implementation_department' => $params['implementation_department'],
|
||
'project_department' => $params['project_department'],
|
||
'engineering_status' => $params['engineering_status'],
|
||
'project_manager' => $params['project_manager'],
|
||
'part_a_unit' => $params['part_a_unit'],
|
||
'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/23 09:52
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionProject::where('id', $params['id'])->update([
|
||
'project_name' => $params['project_name'],
|
||
'industry' => $params['industry'],
|
||
'nature' => $params['nature'],
|
||
'build_unit' => $params['build_unit'],
|
||
'build_area' => $params['build_area'],
|
||
'address' => $params['address'],
|
||
'project_level' => $params['project_level'],
|
||
'total_investment' => $params['total_investment'],
|
||
'initiation_date' => $params['initiation_date'],
|
||
'contract' => $params['contract'],
|
||
'contract_amount' => $params['contract_amount'],
|
||
'actual_start_date' => !empty($params['actual_start_date']) ? strtotime($params['actual_start_date']) : 0,
|
||
'actual_end_date' => !empty($params['actual_end_date']) ? strtotime($params['actual_end_date']) : 0,
|
||
'planned_start_date' => !empty($params['planned_start_date']) ? strtotime($params['planned_start_date']) : 0,
|
||
'planned_end_date' =>!empty($params['planned_end_date']) ? strtotime($params['planned_end_date']) : 0,
|
||
'contract_content' => $params['contract_content'],
|
||
'project_overview' => $params['project_overview'],
|
||
'project_requirements' => $params['project_requirements'],
|
||
'remark' => $params['remark'],
|
||
'supervision_department' => $params['supervision_department'],
|
||
'implementation_department' => $params['implementation_department'],
|
||
'project_department' => $params['project_department'],
|
||
'engineering_status' => $params['engineering_status'],
|
||
'project_manager' => $params['project_manager'],
|
||
'part_a_unit' => $params['part_a_unit'],
|
||
'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/23 09:52
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return SupervisionProject::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取工程监理--监理项目信息详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2024/02/23 09:52
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = SupervisionProject::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||
$admin = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
|
||
$data['create_user_name'] = $admin['name'];
|
||
$data['industry_text'] = $data->industry_text;
|
||
$data['nature_text'] = $data->nature_text;
|
||
$data['build_area_text'] = $data->build_area_text;
|
||
$data['project_level_text'] = $data->project_level_text;
|
||
$data['engineering_status_text'] = $data->engineering_status_text;
|
||
return $data->toArray();
|
||
}
|
||
} |