新增危大工程施工列表模块
This commit is contained in:
parent
84a7c47d2d
commit
033ae9f67a
@ -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_dangerous;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\supervision_dangerous\SupervisionDangerousEngineeringConstructionLists;
|
||||
use app\adminapi\logic\supervision_dangerous\SupervisionDangerousEngineeringConstructionLogic;
|
||||
use app\adminapi\validate\supervision_dangerous\SupervisionDangerousEngineeringConstructionValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--危大工程施工列表控制器
|
||||
* Class SupervisionDangerousEngineeringConstructionController
|
||||
* @package app\adminapi\controller\supervision_dangerous
|
||||
*/
|
||||
class SupervisionDangerousEngineeringConstructionController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--危大工程施工列表列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new SupervisionDangerousEngineeringConstructionLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--危大工程施工列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new SupervisionDangerousEngineeringConstructionValidate())->post()->goCheck('add');
|
||||
$result = SupervisionDangerousEngineeringConstructionLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionDangerousEngineeringConstructionLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑工程监理--危大工程施工列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new SupervisionDangerousEngineeringConstructionValidate())->post()->goCheck('edit');
|
||||
$result = SupervisionDangerousEngineeringConstructionLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionDangerousEngineeringConstructionLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除工程监理--危大工程施工列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new SupervisionDangerousEngineeringConstructionValidate())->post()->goCheck('delete');
|
||||
SupervisionDangerousEngineeringConstructionLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--危大工程施工列表详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new SupervisionDangerousEngineeringConstructionValidate())->goCheck('detail');
|
||||
$result = SupervisionDangerousEngineeringConstructionLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
<?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\SupervisionDangerousEngineeringConstruction;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--危大工程施工列表列表
|
||||
* Class SupervisionDangerousEngineeringConstructionLists
|
||||
* @package app\adminapi\listssupervision_dangerous
|
||||
*/
|
||||
class SupervisionDangerousEngineeringConstructionLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['dangerous_engineering_monitoring_id', 'is_notice'],
|
||||
'%like%' => ['notice_user'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--危大工程施工列表列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return SupervisionDangerousEngineeringConstruction::where($this->searchWhere)
|
||||
->field(['id', 'dangerous_engineering_monitoring_id', 'actual_construction_date', 'is_notice', 'notice_user'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$dangerous_engineering_monitoring = SupervisionDangerousEngineeringMonitoring::field('project_id,type,position')->where('id',$data['dangerous_engineering_monitoring_id'])->findOrEmpty();
|
||||
$project = SupervisionProject::field('project_name')->where('id',$dangerous_engineering_monitoring['project_id'])->findOrEmpty();
|
||||
$data['project_name'] = $project['project_name'];
|
||||
$data['type'] = $dangerous_engineering_monitoring->type_text;
|
||||
$data['position'] = $dangerous_engineering_monitoring['position'];
|
||||
$data['is_notice_text'] = $data->is_notice_text;
|
||||
$data['dangerous_engineering_monitoring_title'] = $project['project_name'];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--危大工程施工列表数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return SupervisionDangerousEngineeringConstruction::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
<?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\SupervisionDangerousEngineeringConstruction;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--危大工程施工列表逻辑
|
||||
* Class SupervisionDangerousEngineeringConstructionLogic
|
||||
* @package app\adminapi\logic\supervision_dangerous
|
||||
*/
|
||||
class SupervisionDangerousEngineeringConstructionLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--危大工程施工列表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionDangerousEngineeringConstruction::create([
|
||||
'dangerous_engineering_monitoring_id' => $params['dangerous_engineering_monitoring_id'],
|
||||
'actual_construction_date' => !empty($params['actual_construction_date']) ? strtotime($params['actual_construction_date']) : 0,
|
||||
'is_notice' => $params['is_notice'],
|
||||
'notice_user' => $params['notice_user']
|
||||
]);
|
||||
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 16:02
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionDangerousEngineeringConstruction::where('id', $params['id'])->update([
|
||||
'dangerous_engineering_monitoring_id' => $params['dangerous_engineering_monitoring_id'],
|
||||
'actual_construction_date' => !empty($params['actual_construction_date']) ? strtotime($params['actual_construction_date']) : 0,
|
||||
'is_notice' => $params['is_notice'],
|
||||
'notice_user' => $params['notice_user'],
|
||||
'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 16:02
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return SupervisionDangerousEngineeringConstruction::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--危大工程施工列表详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = SupervisionDangerousEngineeringConstruction::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$dangerous_engineering_monitoring = SupervisionDangerousEngineeringMonitoring::field('project_id,type,partial_project,planned_construction_time,position,project_characteristics,supervisor,responsible_person')->where('id',$data['dangerous_engineering_monitoring_id'])->findOrEmpty();
|
||||
$project = SupervisionProject::field('project_name')->where('id',$dangerous_engineering_monitoring['project_id'])->findOrEmpty();
|
||||
$data['project_name'] = $project['project_name'];
|
||||
$data['type'] = $dangerous_engineering_monitoring->type_text;
|
||||
$data['partial_project'] = $dangerous_engineering_monitoring->partial_project_text;
|
||||
$data['planned_construction_time'] = $dangerous_engineering_monitoring['planned_construction_time'];
|
||||
$data['position'] = $dangerous_engineering_monitoring['position'];
|
||||
$data['project_characteristics'] = $dangerous_engineering_monitoring['project_characteristics'];
|
||||
$data['supervisor'] = $dangerous_engineering_monitoring['supervisor'];
|
||||
$data['responsible_person'] = $dangerous_engineering_monitoring['responsible_person'];
|
||||
$data['is_notice_text'] = $data->is_notice_text;
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -15,6 +15,9 @@
|
||||
namespace app\adminapi\logic\supervision_dangerous;
|
||||
|
||||
|
||||
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringCase;
|
||||
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringConstruction;
|
||||
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringEliminate;
|
||||
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
@ -105,7 +108,21 @@ class SupervisionDangerousEngineeringMonitoringLogic extends BaseLogic
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
// todo
|
||||
$case = SupervisionDangerousEngineeringCase::where('dangerous_engineering_monitoring_id',$params['id'])->findOrEmpty();
|
||||
if(!$case->isEmpty()){
|
||||
self::setError('当前数据下存在危大方案提交信息,须先删除危大方案提交信息');
|
||||
return false;
|
||||
}
|
||||
$eliminate = SupervisionDangerousEngineeringEliminate::where('dangerous_engineering_monitoring_id',$params['id'])->findOrEmpty();
|
||||
if(!$eliminate->isEmpty()){
|
||||
self::setError('当前数据下存在危大工程消除信息,须先删除危大工程消除信息');
|
||||
return false;
|
||||
}
|
||||
$construction = SupervisionDangerousEngineeringConstruction::where('dangerous_engineering_monitoring_id',$params['id'])->findOrEmpty();
|
||||
if(!$construction->isEmpty()){
|
||||
self::setError('当前数据下存在危大工程施工信息,须先删除危大工程施工信息');
|
||||
return false;
|
||||
}
|
||||
return SupervisionDangerousEngineeringMonitoring::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,119 @@
|
||||
<?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\supervision_dangerous\SupervisionDangerousEngineeringConstruction;
|
||||
use app\common\model\supervision_dangerous\SupervisionDangerousEngineeringMonitoring;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--危大工程施工列表验证器
|
||||
* Class SupervisionDangerousEngineeringConstructionValidate
|
||||
* @package app\adminapi\validate\supervision_dangerous
|
||||
*/
|
||||
class SupervisionDangerousEngineeringConstructionValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'dangerous_engineering_monitoring_id' => 'require|checkDangerousEngineeringMonitoring',
|
||||
'actual_construction_date' => 'require|dateFormat:Y-m-d',
|
||||
'is_notice' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'dangerous_engineering_monitoring_id' => '危大工程监控id',
|
||||
'actual_construction_date' => '实际施工日期',
|
||||
'is_notice' => '是否告知 0-否 1-是',
|
||||
'notice_user' => '告知人员',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return SupervisionDangerousEngineeringConstructionValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id',true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return SupervisionDangerousEngineeringConstructionValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return SupervisionDangerousEngineeringConstructionValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return SupervisionDangerousEngineeringConstructionValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/04 16:02
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = SupervisionDangerousEngineeringConstruction::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '数据不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkDangerousEngineeringMonitoring($value): bool|string
|
||||
{
|
||||
$data = SupervisionDangerousEngineeringMonitoring::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '危大工程监控信息不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?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 think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--危大工程施工列表模型
|
||||
* Class SupervisionDangerousEngineeringConstruction
|
||||
* @package app\common\model\supervision_dangerous
|
||||
*/
|
||||
class SupervisionDangerousEngineeringConstruction extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'supervision_dangerous_engineering_construction';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getActualConstructionDateAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d',$value) : '';
|
||||
}
|
||||
|
||||
public function getIsNoticeTextAttr($value,$data): string
|
||||
{
|
||||
$arr = [0=>'否', 1=>'是'];
|
||||
return $arr[$data['is_notice']];
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user