新增危大工程监控模块

This commit is contained in:
weiz 2024-03-04 11:43:07 +08:00
parent 9d89a91a7e
commit 9937c217a2
5 changed files with 521 additions and 0 deletions

View File

@ -0,0 +1,111 @@
<?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_dangerous;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\supervision_dangerous\SupervisionDangerousEngineeringMonitoringLists;
use app\adminapi\logic\supervision_dangerous\SupervisionDangerousEngineeringMonitoringLogic;
use app\adminapi\validate\supervision_dangerous\SupervisionDangerousEngineeringMonitoringValidate;
/**
* 工程监理--危大工程监控控制器
* Class SupervisionDangerousEngineeringMonitoringController
* @package app\adminapi\controller\supervision_dangerous
*/
class SupervisionDangerousEngineeringMonitoringController extends BaseAdminController
{
/**
* @notes 获取工程监理--危大工程监控列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function lists()
{
return $this->dataLists(new SupervisionDangerousEngineeringMonitoringLists());
}
/**
* @notes 添加工程监理--危大工程监控
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function add()
{
$params = (new SupervisionDangerousEngineeringMonitoringValidate())->post()->goCheck('add');
$result = SupervisionDangerousEngineeringMonitoringLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(SupervisionDangerousEngineeringMonitoringLogic::getError());
}
/**
* @notes 编辑工程监理--危大工程监控
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function edit()
{
$params = (new SupervisionDangerousEngineeringMonitoringValidate())->post()->goCheck('edit');
$result = SupervisionDangerousEngineeringMonitoringLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(SupervisionDangerousEngineeringMonitoringLogic::getError());
}
/**
* @notes 删除工程监理--危大工程监控
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function delete()
{
$params = (new SupervisionDangerousEngineeringMonitoringValidate())->post()->goCheck('delete');
$result = SupervisionDangerousEngineeringMonitoringLogic::delete($params);
if (true === $result) {
return $this->success('删除成功', [], 1, 1);
}
return $this->fail(SupervisionDangerousEngineeringMonitoringLogic::getError());
}
/**
* @notes 获取工程监理--危大工程监控详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function detail()
{
$params = (new SupervisionDangerousEngineeringMonitoringValidate())->goCheck('detail');
$result = SupervisionDangerousEngineeringMonitoringLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,84 @@
<?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_dangerous;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
use app\common\lists\ListsSearchInterface;
use app\common\model\supervision_project\SupervisionProject;
/**
* 工程监理--危大工程监控列表
* Class SupervisionDangerousEngineeringMonitoringLists
* @package app\adminapi\listssupervision_dangerous
*/
class SupervisionDangerousEngineeringMonitoringLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function setSearch(): array
{
return [
'=' => ['project_id', 'type', 'partial_project'],
'%like%' => ['position'],
];
}
/**
* @notes 获取工程监理--危大工程监控列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function lists(): array
{
return SupervisionDangerousEngineeringMonitoring::where($this->searchWhere)
->field(['id', 'project_id', 'type', 'partial_project', 'planned_construction_time', 'position'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
$data['project_name'] = $project['project_name'];
$data['partial_project_text'] = $data->partial_project_text;
$data['type_text'] = $data->type_text;
})
->toArray();
}
/**
* @notes 获取工程监理--危大工程监控数量
* @return int
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function count(): int
{
return SupervisionDangerousEngineeringMonitoring::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,131 @@
<?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_dangerous;
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
use app\common\logic\BaseLogic;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionCheckItem;
use think\facade\Db;
/**
* 工程监理--危大工程监控逻辑
* Class SupervisionDangerousEngineeringMonitoringLogic
* @package app\adminapi\logic\supervision_dangerous
*/
class SupervisionDangerousEngineeringMonitoringLogic extends BaseLogic
{
/**
* @notes 添加工程监理--危大工程监控
* @param array $params
* @return bool
* @author likeadmin
* @date 2024/03/04 11:05
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
SupervisionDangerousEngineeringMonitoring::create([
'project_id' => $params['project_id'],
'type' => $params['type'],
'partial_project' => $params['partial_project'],
'planned_construction_time' => !empty($params['planned_construction_time']) ? strtotime($params['planned_construction_time']) : 0,
'check_item_id' => $params['check_item_id'],
'position' => $params['position'],
'project_characteristics' => $params['project_characteristics'],
'supervisor' => $params['supervisor'],
'responsible_person' => $params['responsible_person']
]);
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/04 11:05
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
SupervisionDangerousEngineeringMonitoring::where('id', $params['id'])->update([
'project_id' => $params['project_id'],
'type' => $params['type'],
'partial_project' => $params['partial_project'],
'planned_construction_time' => !empty($params['planned_construction_time']) ? strtotime($params['planned_construction_time']) : 0,
'check_item_id' => $params['check_item_id'],
'position' => $params['position'],
'project_characteristics' => $params['project_characteristics'],
'supervisor' => $params['supervisor'],
'responsible_person' => $params['responsible_person'],
'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/04 11:05
*/
public static function delete(array $params): bool
{
// todo
return SupervisionDangerousEngineeringMonitoring::destroy($params['id']);
}
/**
* @notes 获取工程监理--危大工程监控详情
* @param $params
* @return array
* @author likeadmin
* @date 2024/03/04 11:05
*/
public static function detail($params): array
{
$data = SupervisionDangerousEngineeringMonitoring::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
$node = SupervisionCheckItem::field('node_name')->where('id',$data['check_item_id'])->findOrEmpty();
$data['project_name'] = $project['project_name'];
$data['node_name'] = $node['node_name'];
$data['partial_project_text'] = $data->partial_project_text;
$data['type_text'] = $data->type_text;
return $data->toArray();
}
}

View File

@ -0,0 +1,146 @@
<?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_dangerous;
use app\common\model\dict\DictData;
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
use app\common\model\supervision_project\SupervisionProject;
use app\common\model\supervision_work\SupervisionCheckItem;
use app\common\validate\BaseValidate;
/**
* 工程监理--危大工程监控验证器
* Class SupervisionDangerousEngineeringMonitoringValidate
* @package app\adminapi\validate\supervision_dangerous
*/
class SupervisionDangerousEngineeringMonitoringValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'project_id' => 'require|checkProject',
'type' => 'require|in:0,1',
'partial_project' => 'require|checkPartialProject',
'planned_construction_time' => 'require|dateFormat:Y-m-d',
'check_item_id' => 'require|checkCheckItem',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'project_id' => '项目id',
'type' => '危大工程类型',
'partial_project' => '分部分项工程',
'planned_construction_time' => '计划施工时间',
'check_item_id' => '单位工程',
'position' => '施工部位',
'project_characteristics' => '本项目特征',
'supervisor' => '上级监管人员',
'responsible_person' => '负责人',
];
/**
* @notes 添加场景
* @return SupervisionDangerousEngineeringMonitoringValidate
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return SupervisionDangerousEngineeringMonitoringValidate
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return SupervisionDangerousEngineeringMonitoringValidate
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionDangerousEngineeringMonitoringValidate
* @author likeadmin
* @date 2024/03/04 11:05
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionDangerousEngineeringMonitoring::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 checkPartialProject($value): bool|string
{
$dict = DictData::where('type_value','partial_project')->column('value');
if(!in_array($value,$dict)){
return '分部分项工程数据值无效';
}
return true;
}
public function checkCheckItem($value,$rule,$params): bool|string
{
$data = SupervisionCheckItem::where('id',$value)->where('project_id',$params['project_id'])->findOrEmpty();
if($data->isEmpty()){
return '单位工程信息不存在';
}
return true;
}
}

View File

@ -0,0 +1,49 @@
<?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_dangerous;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 工程监理--危大工程监控模型
* Class SupervisionDangerousEngineeringMonitoring
* @package app\common\model\supervision_dangerous
*/
class SupervisionDangerousEngineeringMonitoring extends BaseModel
{
use SoftDelete;
protected $name = 'supervision_dangerous_engineering_monitoring';
protected $deleteTime = 'delete_time';
public function getPartialProjectTextAttr($value,$data){
$dict = DictData::where('type_value','partial_project')->column('name','value');
return !empty($data['partial_project']) ? $dict[$data['partial_project']] : '';
}
public function getTypeTextAttr($value,$data): string
{
$arr = [0=>'超规模工程', 1=>'危险性较大工程'];
return $arr[$data['type']];
}
public function getPlannedConstructionTimeAttr($value): string
{
return !empty($value) ? date('Y-m-d',$value) : '';
}
}