新增见证取样模块

This commit is contained in:
weiz 2024-02-29 13:58:35 +08:00
parent 6b1ced0607
commit c8b07a587c
10 changed files with 1213 additions and 0 deletions

View File

@ -0,0 +1,108 @@
<?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\controller\supervision_work;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\supervision_work\SupervisionWitnessSamplingLists;
use app\adminapi\logic\supervision_work\SupervisionWitnessSamplingLogic;
use app\adminapi\validate\supervision_work\SupervisionWitnessSamplingValidate;
/**
* 工程监理--见证取样控制器
* Class SupervisionWitnessSamplingController
* @package app\adminapi\controller\supervision_work
*/
class SupervisionWitnessSamplingController extends BaseAdminController
{
/**
* @notes 获取工程监理--见证取样列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function lists()
{
return $this->dataLists(new SupervisionWitnessSamplingLists());
}
/**
* @notes 添加工程监理--见证取样
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function add()
{
$params = (new SupervisionWitnessSamplingValidate())->post()->goCheck('add');
$result = SupervisionWitnessSamplingLogic::add($params,$this->adminId);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SupervisionWitnessSamplingLogic::getError());
}
/**
* @notes 编辑工程监理--见证取样
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function edit()
{
$params = (new SupervisionWitnessSamplingValidate())->post()->goCheck('edit');
$result = SupervisionWitnessSamplingLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SupervisionWitnessSamplingLogic::getError());
}
/**
* @notes 删除工程监理--见证取样
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function delete()
{
$params = (new SupervisionWitnessSamplingValidate())->post()->goCheck('delete');
SupervisionWitnessSamplingLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取工程监理--见证取样详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function detail()
{
$params = (new SupervisionWitnessSamplingValidate())->goCheck('detail');
$result = SupervisionWitnessSamplingLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,124 @@
<?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\controller\supervision_work;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\supervision_work\SupervisionWitnessSamplingDetailLists;
use app\adminapi\logic\supervision_work\SupervisionWitnessSamplingDetailLogic;
use app\adminapi\validate\supervision_work\SupervisionWitnessSamplingDetailValidate;
/**
* 工程监理--见证取样明细控制器
* Class SupervisionWitnessSamplingDetailController
* @package app\adminapi\controller\supervision_work
*/
class SupervisionWitnessSamplingDetailController extends BaseAdminController
{
/**
* @notes 获取工程监理--见证取样明细列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function lists()
{
return $this->dataLists(new SupervisionWitnessSamplingDetailLists());
}
/**
* @notes 添加工程监理--见证取样明细
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function add()
{
$params = (new SupervisionWitnessSamplingDetailValidate())->post()->goCheck('add');
$result = SupervisionWitnessSamplingDetailLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SupervisionWitnessSamplingDetailLogic::getError());
}
/**
* @notes 编辑工程监理--见证取样明细
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function edit()
{
$params = (new SupervisionWitnessSamplingDetailValidate())->post()->goCheck('edit');
$result = SupervisionWitnessSamplingDetailLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SupervisionWitnessSamplingDetailLogic::getError());
}
/**
* @notes 检验工程监理--见证取样明细
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function check()
{
$params = (new SupervisionWitnessSamplingDetailValidate())->post()->goCheck('check');
$result = SupervisionWitnessSamplingDetailLogic::check($params,$this->adminId);
if (true === $result) {
return $this->success('检验成功', [], 1, 1);
}
return $this->fail(SupervisionWitnessSamplingDetailLogic::getError());
}
/**
* @notes 删除工程监理--见证取样明细
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function delete()
{
$params = (new SupervisionWitnessSamplingDetailValidate())->post()->goCheck('delete');
SupervisionWitnessSamplingDetailLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取工程监理--见证取样明细详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function detail()
{
$params = (new SupervisionWitnessSamplingDetailValidate())->goCheck('detail');
$result = SupervisionWitnessSamplingDetailLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,85 @@
<?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\lists\supervision_work;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\supervision_work\SupervisionMaterialEntryDetail;
use app\common\model\supervision_work\SupervisionWitnessSamplingDetail;
use app\common\lists\ListsSearchInterface;
/**
* 工程监理--见证取样明细列表
* Class SupervisionWitnessSamplingDetailLists
* @package app\adminapi\listssupervision_work
*/
class SupervisionWitnessSamplingDetailLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function setSearch(): array
{
return [
'=' => ['witness_sampling_id', 'material_entry_detail_id', 'check_result'],
'%like%' => ['check_code', 'check_user'],
];
}
/**
* @notes 获取工程监理--见证取样明细列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function lists(): array
{
return SupervisionWitnessSamplingDetail::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$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'];
})
->toArray();
}
/**
* @notes 获取工程监理--见证取样明细数量
* @return int
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function count(): int
{
return SupervisionWitnessSamplingDetail::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,123 @@
<?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\lists\supervision_work;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\supervision_project\SupervisionParticipatingUnits;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionMaterialEntry;
use app\common\model\supervision_work\SupervisionMaterialEntryDetail;
use app\common\model\supervision_work\SupervisionWitnessSampling;
use app\common\lists\ListsSearchInterface;
use app\common\model\supervision_work\SupervisionWitnessSamplingDetail;
/**
* 工程监理--见证取样列表
* Class SupervisionWitnessSamplingLists
* @package app\adminapi\listssupervision_work
*/
class SupervisionWitnessSamplingLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function setSearch(): array
{
return [];
}
/**
* @notes 获取工程监理--见证取样列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function lists(): array
{
$params = $this->request->get();
$where = [];
if(!isset($params['code']) && $params['code'] != ''){
$witness_sampling_ids1 = SupervisionWitnessSampling::where('code','like','%'.$params['code'].'%')->column('id');
$where[] = ['witness_sampling_id','in',$witness_sampling_ids1];
}
if(!isset($params['project_id']) && $params['project_id'] != ''){
$witness_sampling_ids2 = SupervisionWitnessSampling::where('project_id','=',$params['project_id'])->column('id');
$where[] = ['witness_sampling_id','in',$witness_sampling_ids2];
}
if(!isset($params['name']) && $params['name'] != ''){
$material_entry_detail_ids = SupervisionMaterialEntryDetail::where('name','like','%'.$params['name'].'%')->column('id');
$where[] = ['material_entry_detail_id','in',$material_entry_detail_ids];
}
return SupervisionWitnessSamplingDetail::withoutField('check_code,check_time,check_user,check_remark,create_time,update_time,delete_time')->where($where)
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$witness_sampling = SupervisionWitnessSampling::field('project_id,material_entry_id,code,sampling_date,witness')->where('id',$data['witness_sampling_id'])->findOrEmpty();
$project = SupervisionProject::field('project_name')->where('id',$witness_sampling['project_id'])->findOrEmpty();
$material_entry = SupervisionMaterialEntry::field('company_id,enter_time')->where('id',$witness_sampling['material_entry_id'])->findOrEmpty();
$company = SupervisionParticipatingUnits::field('unit_name')->where('id',$material_entry['company_id'])->findOrEmpty();
$material_entry_detail = SupervisionMaterialEntryDetail::field('name,model,entry_number')->where('id',$data['material_entry_detail_id'])->findOrEmpty();
$data['project_name'] = $project['project_name'];
$data['company_name'] = $company['unit_name'];
$data['code'] = $witness_sampling['code'];
$data['enter_time'] = $material_entry['enter_time'];
$data['sampling_date'] = $witness_sampling['sampling_date'];
$data['witness'] = $witness_sampling['witness'];
$data['name'] = $material_entry_detail['name'];
$data['model'] = $material_entry_detail['model'];
$data['entry_number'] = $material_entry_detail['entry_number'];
$data['check_result_text'] = $data->check_result_text;
})
->toArray();
}
/**
* @notes 获取工程监理--见证取样数量
* @return int
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function count(): int
{
$params = $this->request->get();
$where = [];
if(!isset($params['code']) && $params['code'] != ''){
$witness_sampling_ids1 = SupervisionWitnessSampling::where('code','like','%'.$params['code'].'%')->column('id');
$where[] = ['witness_sampling_id','in',$witness_sampling_ids1];
}
if(!isset($params['project_id']) && $params['project_id'] != ''){
$witness_sampling_ids2 = SupervisionWitnessSampling::where('project_id','=',$params['project_id'])->column('id');
$where[] = ['witness_sampling_id','in',$witness_sampling_ids2];
}
if(!isset($params['name']) && $params['name'] != ''){
$material_entry_detail_ids = SupervisionMaterialEntryDetail::where('name','like','%'.$params['name'].'%')->column('id');
$where[] = ['material_entry_detail_id','in',$material_entry_detail_ids];
}
return SupervisionWitnessSampling::where($where)->count();
}
}

View File

@ -0,0 +1,163 @@
<?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\SupervisionProblem;
use app\common\model\supervision_work\SupervisionWitnessSamplingDetail;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 工程监理--见证取样明细逻辑
* Class SupervisionWitnessSamplingDetailLogic
* @package app\adminapi\logic\supervision_work
*/
class SupervisionWitnessSamplingDetailLogic extends BaseLogic
{
/**
* @notes 添加工程监理--见证取样明细
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/29 09:22
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
SupervisionWitnessSamplingDetail::create([
'witness_sampling_id' => $params['witness_sampling_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 09:22
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
SupervisionWitnessSamplingDetail::where('id', $params['id'])->update([
'witness_sampling_id' => $params['witness_sampling_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 {
SupervisionWitnessSamplingDetail::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' => 5,
'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 09:22
*/
public static function delete(array $params): bool
{
$check_problem = SupervisionProblem::where('data_id',$params['id'])->where('data_type',5)->findOrEmpty();
if(!$check_problem->isEmpty()){
self::setError('该内容下存在验收问题数据,请先删除验收问题数据');
return false;
}
return SupervisionWitnessSamplingDetail::destroy($params['id']);
}
/**
* @notes 获取工程监理--见证取样明细详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/02/29 09:22
*/
public static function detail($params): array
{
$data = SupervisionWitnessSamplingDetail::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();
}
}

View File

@ -0,0 +1,164 @@
<?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\auth\Admin;
use app\common\model\supervision_project\SupervisionParticipatingUnits;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionMaterialEntry;
use app\common\model\supervision_work\SupervisionWitnessSampling;
use app\common\logic\BaseLogic;
use app\common\model\supervision_work\SupervisionWitnessSamplingDetail;
use think\facade\Db;
/**
* 工程监理--见证取样逻辑
* Class SupervisionWitnessSamplingLogic
* @package app\adminapi\logic\supervision_work
*/
class SupervisionWitnessSamplingLogic extends BaseLogic
{
/**
* @notes 添加工程监理--见证取样
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/02/29 09:22
*/
public static function add(array $params,$admin_id): bool
{
Db::startTrans();
try {
$res = SupervisionWitnessSampling::create([
'project_id' => $params['project_id'],
'material_entry_id' => $params['material_entry_id'],
'code' => data_unique_code('CLJZ'),
'sampling_date' => !empty($params['sampling_date']) ? strtotime($params['sampling_date']) : 0,
'witness' => $params['witness'],
'sampler' => $params['sampler'],
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'create_user' => $admin_id
]);
if(!empty($params['sampling_detail'])){
foreach($params['sampling_detail'] as $v){
SupervisionWitnessSamplingDetail::create([
'witness_sampling_id' => $res->id,
'material_entry_detail_id' => $v['material_entry_detail_id'],
'num' => $v['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 09:22
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
SupervisionWitnessSampling::where('id', $params['id'])->update([
'project_id' => $params['project_id'],
'material_entry_id' => $params['material_entry_id'],
'sampling_date' => !empty($params['sampling_date']) ? strtotime($params['sampling_date']) : 0,
'witness' => $params['witness'],
'sampler' => $params['sampler'],
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'update_time' => time()
]);
if(!empty($params['sampling_detail'])){
foreach($params['sampling_detail'] as $v){
if(!empty($v['id'])){
SupervisionWitnessSamplingDetail::where('id',$v['id'])->update([
'witness_sampling_id' => $params['id'],
'material_entry_detail_id' => $v['material_entry_detail_id'],
'num' => $v['num'],
'update_time' => time()
]);
}else{
SupervisionWitnessSamplingDetail::create([
'witness_sampling_id' => $params['id'],
'material_entry_detail_id' => $v['material_entry_detail_id'],
'num' => $v['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 09:22
*/
public static function delete(array $params): bool
{
$witness_sampling_detail = SupervisionWitnessSamplingDetail::where('witness_sampling_id',$params['id'])->findOrEmpty();
if(!$witness_sampling_detail->isEmpty()){
self::setError('当前数据下存在材料信息内容,请先删除材料信息内容');
return false;
}
return SupervisionWitnessSampling::destroy($params['id']);
}
/**
* @notes 获取工程监理--见证取样详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/02/29 09:22
*/
public static function detail($params): array
{
$data = SupervisionWitnessSampling::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
$material_entry = SupervisionMaterialEntry::field('company_id,enter_time')->where('id',$data['material_entry_id'])->findOrEmpty();
$company = SupervisionParticipatingUnits::field('unit_name')->where('id',$material_entry['company_id'])->findOrEmpty();
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
$data['project_name'] = $project['project_name'];
$data['company_name'] = $company['unit_name'];
$data['enter_time'] = $material_entry['enter_time'];
$data['create_user_name'] = $create_user['name'];
return $data->toArray();
}
}

View File

@ -0,0 +1,186 @@
<?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\validate\supervision_work;
use app\common\model\dict\DictData;
use app\common\model\supervision_work\SupervisionMaterialEntryDetail;
use app\common\model\supervision_work\SupervisionProblem;
use app\common\model\supervision_work\SupervisionWitnessSampling;
use app\common\model\supervision_work\SupervisionWitnessSamplingDetail;
use app\common\validate\BaseValidate;
/**
* 工程监理--见证取样明细验证器
* Class SupervisionWitnessSamplingDetailValidate
* @package app\adminapi\validate\supervision_work
*/
class SupervisionWitnessSamplingDetailValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'witness_sampling_id' => 'require|checkWitnessSampling',
'material_entry_detail_id' => 'require|checkMaterialEntryDetail',
'num' => 'require|float',
'check_code' => 'require',
'check_result' => 'require|in:1,2',
'check_time' => 'require|dateFormat:Y-m-d',
'check_user' => 'require',
'check_annex' => 'checkAnnex',
'check_problem' => 'checkProblem'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'witness_sampling_id' => '见证取样id',
'material_entry_detail_id' => '材料进场明细id',
'num' => '取样数量',
'check_code' => '报告编号',
'check_result' => '检验结果',
'check_time' => '获得日期',
'check_user' => '操作人',
'check_remark' => '备注',
];
/**
* @notes 添加场景
* @return SupervisionWitnessSamplingDetailValidate
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function sceneAdd()
{
return $this->only(['witness_sampling_id','material_entry_detail_id','num']);
}
/**
* @notes 编辑场景
* @return SupervisionWitnessSamplingDetailValidate
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function sceneEdit()
{
return $this->only(['id','witness_sampling_id','material_entry_detail_id','num']);
}
/**
* @notes 检验场景
* @return SupervisionWitnessSamplingDetailValidate
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function sceneCheck()
{
return $this->only(['id','check_code','check_result','check_time','check_user','check_remark','check_annex','check_problem']);
}
/**
* @notes 删除场景
* @return SupervisionWitnessSamplingDetailValidate
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionWitnessSamplingDetailValidate
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionWitnessSamplingDetail::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkWitnessSampling($value): bool|string
{
$data = SupervisionWitnessSampling::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '见证取样信息不存在';
}
return true;
}
public function checkMaterialEntryDetail($value,$rule,$params): bool|string
{
$witness_sampling = SupervisionWitnessSampling::where('id',$params['witness_sampling_id'])->findOrEmpty();
$data = SupervisionMaterialEntryDetail::where('id',$value)->where('material_entry_id',$witness_sampling['material_entry_id'])->findOrEmpty();
if($data->isEmpty()){
return '材料信息不存在';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != '' && !is_array($value)){
return '附件格式错误';
}
return true;
}
public function checkProblem($value): bool|string
{
if(!isset($value) || $value == '') return true;
if(!is_array($value)) return '检验问题数据格式错误';
foreach($value as $k=>$v){
if(!empty($v['id'])){
$data = SupervisionProblem::where('id',$v['id'])->findOrEmpty();
if($data->isEmpty()){
return '检验问题列表第'.($k+1).'行数据不存在';
}
}
if(empty($v['problem_cate'])){
return '检验问题列表第'.($k+1).'行问题分类为空';
}else{
$dict = DictData::where('type_value','problem_cate')->column('value');
if(!in_array($v['problem_cate'],$dict)) return '检验问题列表第'.($k+1).'行问题分类数据值无效';
}
if(empty($v['problem_description'])) return '检验问题列表第'.($k+1).'行问题说明为空';
if(empty($v['problem_name'])) return '检验问题列表第'.($k+1).'行问题名称为空';
}
return true;
}
}

View File

@ -0,0 +1,171 @@
<?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\validate\supervision_work;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionMaterialEntry;
use app\common\model\supervision_work\SupervisionMaterialEntryDetail;
use app\common\model\supervision_work\SupervisionWitnessSampling;
use app\common\model\supervision_work\SupervisionWitnessSamplingDetail;
use app\common\validate\BaseValidate;
/**
* 工程监理--见证取样验证器
* Class SupervisionWitnessSamplingValidate
* @package app\adminapi\validate\supervision_work
*/
class SupervisionWitnessSamplingValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'project_id' => 'require|checkProject',
'material_entry_id' => 'require|checkMaterialEntry',
'sampling_date' => 'require|dateFormat:Y-m-d',
'sampler' => 'require',
'annex' => 'checkAnnex',
'sampling_detail' => 'checkSamplingDetail'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'project_id' => '项目id',
'material_entry_id' => '来源单据',
'code' => '编号',
'sampling_date' => '取样日期',
'witness' => '见证人',
'sampler' => '取样人',
'create_user' => '创建人',
];
/**
* @notes 添加场景
* @return SupervisionWitnessSamplingValidate
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return SupervisionWitnessSamplingValidate
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return SupervisionWitnessSamplingValidate
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionWitnessSamplingValidate
* @author likeadmin
* @date 2024/02/29 09:22
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionWitnessSampling::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkProject($value): bool|string
{
$data = SupervisionProject::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '项目信息不存在';
}
return true;
}
public function checkMaterialEntry($value,$rule,$params): bool|string
{
$data = SupervisionMaterialEntry::where('id',$value)->where('project_id',$params['project_id'])->findOrEmpty();
if($data->isEmpty()){
return '来源单据信息不存在';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != '' && !is_array($value)){
return '附件格式错误';
}
return true;
}
public function checkSamplingDetail($value,$rule,$params): bool|string
{
if(!isset($value) || $value == '') return true;
if(!is_array($value)) return '材料信息数据格式错误';
foreach($value as $k=>$v) {
if (!empty($v['id'])) {
$data = SupervisionWitnessSamplingDetail::where('id', $v['id'])->findOrEmpty();
if ($data->isEmpty()) {
return '材料信息列表第' . ($k + 1) . '行数据不存在';
}
}
if (empty($v['material_entry_detail_id'])){
return '材料信息列表第' . ($k + 1) . '行材料名称为空';
}else{
$material = SupervisionMaterialEntryDetail::where('id',$v['material_entry_detail_id'])->where('material_entry_id',$params['material_entry_id'])->findOrEmpty();
if($material->isEmpty()) return '材料信息列表第' . ($k + 1) . '行材料数据不存在';
}
if (empty($v['num'])){
return '材料信息列表第' . ($k + 1) . '行取样数量为空';
}else{
if(!is_numeric($v['num'])) return '材料信息列表第' . ($k + 1) . '行取样数量必须是数字';
}
}
return true;
}
}

View File

@ -0,0 +1,41 @@
<?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\common\model\supervision_work;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 工程监理--见证取样模型
* Class SupervisionWitnessSampling
* @package app\common\model\supervision_work
*/
class SupervisionWitnessSampling extends BaseModel
{
use SoftDelete;
protected $name = 'supervision_witness_sampling';
protected $deleteTime = 'delete_time';
public function getSamplingDateAttr($value): string
{
return !empty($value) ? date('Y-m-d',$value) : '';
}
public function getAnnexAttr($value){
return !empty($value) ? json_decode($value,true) : '';
}
}

View File

@ -0,0 +1,48 @@
<?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\common\model\supervision_work;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* 工程监理--见证取样明细模型
* Class SupervisionWitnessSamplingDetail
* @package app\common\model\supervision_work
*/
class SupervisionWitnessSamplingDetail extends BaseModel
{
use SoftDelete;
protected $name = 'supervision_witness_sampling_detail';
protected $deleteTime = 'delete_time';
public function getCheckResultTextAttr($value,$data): string
{
$arr = [0=>'未检验', 1=>'符合标准', 2=>'不符合标准'];
return $arr[$data['check_result']];
}
public function getCheckTimeAttr($value): string
{
return !empty($value) ? date('Y-m-d') : '';
}
public function getCheckAnnexAttr($value)
{
return !empty($value) ? json_decode($value,true) : '';
}
}