163 lines
5.5 KiB
PHP
163 lines
5.5 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_work;
|
||
|
||
|
||
use app\common\model\supervision_work\SupervisionMaterialEntryDetail;
|
||
use app\common\model\supervision_work\SupervisionMaterialParallelTestingDetail;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\supervision_work\SupervisionProblem;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 工程监理--材料平行检验明细逻辑
|
||
* Class SupervisionMaterialParallelTestingDetailLogic
|
||
* @package app\adminapi\logic\supervision_work
|
||
*/
|
||
class SupervisionMaterialParallelTestingDetailLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加工程监理--材料平行检验明细
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/02/29 15:00
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionMaterialParallelTestingDetail::create([
|
||
'material_parallel_testing_id' => $params['material_parallel_testing_id'],
|
||
'material_entry_detail_id' => $params['material_entry_detail_id'],
|
||
'num' => $params['num'],
|
||
]);
|
||
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/29 15:00
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionMaterialParallelTestingDetail::where('id', $params['id'])->update([
|
||
'material_parallel_testing_id' => $params['material_parallel_testing_id'],
|
||
'material_entry_detail_id' => $params['material_entry_detail_id'],
|
||
'num' => $params['num'],
|
||
'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/29 09:22
|
||
*/
|
||
public static function check(array $params,$admin_id): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionMaterialParallelTestingDetail::where('id', $params['id'])->update([
|
||
'check_code' => $params['check_code'],
|
||
'check_result' => $params['check_result'],
|
||
'check_time' => !empty($params['check_time']) ? strtotime($params['check_time']) : 0,
|
||
'check_user' => $params['check_user'],
|
||
'check_remark' => $params['check_remark'],
|
||
'check_annex' => $params['check_annex'] ? json_encode($params['check_annex']) : null,
|
||
]);
|
||
if(!empty($params['check_problem'])){
|
||
foreach($params['check_problem'] as $v){
|
||
SupervisionProblem::create([
|
||
'data_id' => $params['id'],
|
||
'data_type' => 7,
|
||
'problem_cate' => $v['problem_cate'],
|
||
'problem_description' => $v['problem_description'],
|
||
'problem_name' => $v['problem_name'],
|
||
'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/29 15:00
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
$check_problem = SupervisionProblem::where('data_id',$params['id'])->where('data_type',7)->findOrEmpty();
|
||
if(!$check_problem->isEmpty()){
|
||
self::setError('该内容下存在验收问题数据,请先删除验收问题数据');
|
||
return false;
|
||
}
|
||
return SupervisionMaterialParallelTestingDetail::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取工程监理--材料平行检验明细详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2024/02/29 15:00
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = SupervisionMaterialParallelTestingDetail::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||
$material_entry_detail = SupervisionMaterialEntryDetail::field('name,brand,model,contract_brand,entry_number')->where('id',$data['material_entry_detail_id'])->findOrEmpty();
|
||
$data['name'] = $material_entry_detail['name'];
|
||
$data['brand'] = $material_entry_detail['brand'];
|
||
$data['model'] = $material_entry_detail['model'];
|
||
$data['contract_brand'] = $material_entry_detail->contract_brand_text;
|
||
$data['entry_number'] = $material_entry_detail['entry_number'];
|
||
return $data->toArray();
|
||
}
|
||
} |