142 lines
4.7 KiB
PHP
142 lines
4.7 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\quality;
|
||
|
||
|
||
use app\common\model\dept\Dept;
|
||
use app\common\model\dept\Orgs;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\quality\QualityModify;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 质量整改逻辑
|
||
* Class QualityModifyLogic
|
||
* @package app\adminapi\logic\quality
|
||
*/
|
||
class QualityModifyLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加质量整改
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/20 17:28
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
QualityModify::create([
|
||
'org_id' => $params['org_id'],
|
||
'dept_id' => $params['dept_id'],
|
||
'project_id' => $params['project_id'],
|
||
'check_nature' => $params['check_nature'],
|
||
'check_date' => strtotime($params['check_date']),
|
||
'modify_term' => $params['modify_term'],
|
||
'check_user' => $params['check_user'],
|
||
'check_unit' => $params['check_unit'],
|
||
'modify_unit' => $params['modify_unit'],
|
||
'resp_user' => $params['resp_user'],
|
||
'copy_user' => $params['copy_user'],
|
||
'check_item' => $params['check_item'],
|
||
'quality_hazards' => $params['quality_hazards'],
|
||
'check_result' => $params['check_result'],
|
||
]);
|
||
Db::commit();
|
||
return true;
|
||
} catch (\Exception $e) {
|
||
Db::rollback();
|
||
self::setError($e->getMessage());
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑质量整改
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/20 17:28
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
QualityModify::where('id', $params['id'])->update([
|
||
'org_id' => $params['org_id'],
|
||
'dept_id' => $params['dept_id'],
|
||
'project_id' => $params['project_id'],
|
||
'check_nature' => $params['check_nature'],
|
||
'check_date' => strtotime($params['check_date']),
|
||
'modify_term' => $params['modify_term'],
|
||
'check_user' => $params['check_user'],
|
||
'check_unit' => $params['check_unit'],
|
||
'modify_unit' => $params['modify_unit'],
|
||
'resp_user' => $params['resp_user'],
|
||
'copy_user' => $params['copy_user'],
|
||
'check_item' => $params['check_item'],
|
||
'quality_hazards' => $params['quality_hazards'],
|
||
'check_result' => $params['check_result'],
|
||
'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 2023/12/20 17:28
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return QualityModify::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取质量整改详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/12/20 17:28
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = QualityModify::findOrEmpty($params['id'])->toArray();
|
||
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
|
||
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
|
||
$data['org_name'] = $org['name'];
|
||
$data['dept_name'] = $dept['name'];
|
||
$data['project_name'] = $project['name'];
|
||
$data['project_code'] = $project['project_code'];
|
||
return $data;
|
||
}
|
||
} |