154 lines
6.4 KiB
PHP
154 lines
6.4 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_connect;
|
||
|
||
|
||
use app\common\model\supervision_connect\SupervisionProjectMonthlyReport;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\supervision_project\SupervisionProject;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 工程监理--项目月报逻辑
|
||
* Class SupervisionProjectMonthlyReportLogic
|
||
* @package app\adminapi\logic\supervision_connect
|
||
*/
|
||
class SupervisionProjectMonthlyReportLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加工程监理--项目月报
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/03/05 09:41
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionProjectMonthlyReport::create([
|
||
'project_id' => $params['project_id'],
|
||
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
|
||
'last_month_planned_progress' => $params['last_month_planned_progress'],
|
||
'next_month_planned_progress' => $params['next_month_planned_progress'],
|
||
'this_month_progress' => $params['this_month_progress'],
|
||
'engineering_status' => $params['engineering_status'],
|
||
'progress_description' => $params['progress_description'],
|
||
'problems_and_measure' => $params['problems_and_measure'],
|
||
'this_month_amount' => $params['this_month_amount'],
|
||
'total_amount' => $params['total_amount'],
|
||
'this_month_pay' => $params['this_month_pay'],
|
||
'total_pay' => $params['total_pay'],
|
||
'quality_behavior' => $params['quality_behavior'],
|
||
'quality_situation' => $params['quality_situation'],
|
||
'quality_hazards' => $params['quality_hazards'],
|
||
'sampling_situation' => $params['sampling_situation'],
|
||
'other_quality_conditions' => $params['other_quality_conditions'],
|
||
'safety_situation' => $params['safety_situation'],
|
||
'remark' => $params['remark'],
|
||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||
'create_user' => $params['create_user'],
|
||
'create_time' => !empty($params['create_time']) ? strtotime($params['create_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/05 09:41
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionProjectMonthlyReport::where('id', $params['id'])->update([
|
||
'project_id' => $params['project_id'],
|
||
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
|
||
'last_month_planned_progress' => $params['last_month_planned_progress'],
|
||
'next_month_planned_progress' => $params['next_month_planned_progress'],
|
||
'this_month_progress' => $params['this_month_progress'],
|
||
'engineering_status' => $params['engineering_status'],
|
||
'progress_description' => $params['progress_description'],
|
||
'problems_and_measure' => $params['problems_and_measure'],
|
||
'this_month_amount' => $params['this_month_amount'],
|
||
'total_amount' => $params['total_amount'],
|
||
'this_month_pay' => $params['this_month_pay'],
|
||
'total_pay' => $params['total_pay'],
|
||
'quality_behavior' => $params['quality_behavior'],
|
||
'quality_situation' => $params['quality_situation'],
|
||
'quality_hazards' => $params['quality_hazards'],
|
||
'sampling_situation' => $params['sampling_situation'],
|
||
'other_quality_conditions' => $params['other_quality_conditions'],
|
||
'safety_situation' => $params['safety_situation'],
|
||
'remark' => $params['remark'],
|
||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||
'create_user' => $params['create_user'],
|
||
'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : time(),
|
||
'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/05 09:41
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return SupervisionProjectMonthlyReport::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取工程监理--项目月报详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2024/03/05 09:41
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = SupervisionProjectMonthlyReport::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||
$project = SupervisionProject::field('project_name,project_manager,implementation_department')->where('id',$data['project_id'])->findOrEmpty();
|
||
$data['project_name'] = $project['project_name'];
|
||
$data['project_manager'] = $project['project_manager'];
|
||
$data['implementation_department'] = $project['implementation_department'];
|
||
$data['engineering_status_text'] = $data->engineering_status_text;
|
||
return $data->toArray();
|
||
}
|
||
} |