新增项目重大信息上报模块
This commit is contained in:
parent
8fa6babeff
commit
93861a3c8a
@ -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_connect;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\supervision_connect\SupervisionProjectInfoReportLists;
|
||||
use app\adminapi\logic\supervision_connect\SupervisionProjectInfoReportLogic;
|
||||
use app\adminapi\validate\supervision_connect\SupervisionProjectInfoReportValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--项目重大信息上报控制器
|
||||
* Class SupervisionProjectInfoReportController
|
||||
* @package app\adminapi\controller\supervision_connect
|
||||
*/
|
||||
class SupervisionProjectInfoReportController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--项目重大信息上报列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new SupervisionProjectInfoReportLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--项目重大信息上报
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new SupervisionProjectInfoReportValidate())->post()->goCheck('add');
|
||||
$result = SupervisionProjectInfoReportLogic::add($params,$this->adminId);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionProjectInfoReportLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑工程监理--项目重大信息上报
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new SupervisionProjectInfoReportValidate())->post()->goCheck('edit');
|
||||
$result = SupervisionProjectInfoReportLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionProjectInfoReportLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除工程监理--项目重大信息上报
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new SupervisionProjectInfoReportValidate())->post()->goCheck('delete');
|
||||
SupervisionProjectInfoReportLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--项目重大信息上报详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new SupervisionProjectInfoReportValidate())->goCheck('detail');
|
||||
$result = SupervisionProjectInfoReportLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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_connect;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\supervision_connect\SupervisionProjectInfoReport;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--项目重大信息上报列表
|
||||
* Class SupervisionProjectInfoReportLists
|
||||
* @package app\adminapi\listssupervision_connect
|
||||
*/
|
||||
class SupervisionProjectInfoReportLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['project_id', 'severity'],
|
||||
'%like%' => ['abstract', 'giver'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--项目重大信息上报列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return SupervisionProjectInfoReport::withoutField('create_user,create_time,update_time,delete_time')->where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$project = SupervisionProject::field('project_name,project_manager')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$data['project_name'] = $project['project_name'];
|
||||
$data['project_manager'] = $project['project_manager'];
|
||||
$data['severity_text'] = $data->severity_text;
|
||||
$data['info_cate_text'] = $data->info_cate_text;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--项目重大信息上报数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return SupervisionProjectInfoReport::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -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_connect;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\supervision_connect\SupervisionProjectInfoReport;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--项目重大信息上报逻辑
|
||||
* Class SupervisionProjectInfoReportLogic
|
||||
* @package app\adminapi\logic\supervision_connect
|
||||
*/
|
||||
class SupervisionProjectInfoReportLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--项目重大信息上报
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public static function add(array $params,$admin_id): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionProjectInfoReport::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'abstract' => $params['abstract'],
|
||||
'happen_date' => !empty($params['happen_date']) ? strtotime($params['happen_date']) : 0,
|
||||
'severity' => $params['severity'],
|
||||
'info_cate' => $params['info_cate'] ? json_encode($params['info_cate']) : null,
|
||||
'info_content' => $params['info_content'],
|
||||
'opinions' => $params['opinions'],
|
||||
'giver' => $params['giver'],
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
'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/03/05 10:53
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionProjectInfoReport::where('id', $params['id'])->update([
|
||||
'project_id' => $params['project_id'],
|
||||
'abstract' => $params['abstract'],
|
||||
'happen_date' => !empty($params['happen_date']) ? strtotime($params['happen_date']) : 0,
|
||||
'severity' => $params['severity'],
|
||||
'info_cate' => $params['info_cate'] ? json_encode($params['info_cate']) : null,
|
||||
'info_content' => $params['info_content'],
|
||||
'opinions' => $params['opinions'],
|
||||
'giver' => $params['giver'],
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
'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/05 10:53
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return SupervisionProjectInfoReport::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--项目重大信息上报详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = SupervisionProjectInfoReport::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$project = SupervisionProject::field('project_name,project_manager')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty();
|
||||
$data['project_name'] = $project['project_name'];
|
||||
$data['project_manager'] = $project['project_manager'];
|
||||
$data['create_user_name'] = $create_user['name'];
|
||||
$data['severity_text'] = $data->severity_text;
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
<?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_connect;
|
||||
|
||||
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\supervision_connect\SupervisionProjectInfoReport;
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--项目重大信息上报验证器
|
||||
* Class SupervisionProjectInfoReportValidate
|
||||
* @package app\adminapi\validate\supervision_connect
|
||||
*/
|
||||
class SupervisionProjectInfoReportValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'project_id' => 'require|checkProject',
|
||||
'abstract' => 'require',
|
||||
'happen_date' => 'require|dateFormat:Y-m-d',
|
||||
'severity' => 'require|checkSeverity',
|
||||
'info_cate' => 'checkInfoCate',
|
||||
'annex' => 'checkAnnex'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'project_id' => '项目id',
|
||||
'abstract' => '信息摘要',
|
||||
'happen_date' => '发生日期',
|
||||
'severity' => '严重程度',
|
||||
'info_content' => '信息内容',
|
||||
'opinions' => '项目部意见',
|
||||
'giver' => '主送人',
|
||||
'create_user' => '创建人',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return SupervisionProjectInfoReportValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id',true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return SupervisionProjectInfoReportValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return SupervisionProjectInfoReportValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return SupervisionProjectInfoReportValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 10:53
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = SupervisionProjectInfoReport::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 checkSeverity($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','severity')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
return '严重程度数据值无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkInfoCate($value): bool|string
|
||||
{
|
||||
if(empty($value)) return true;
|
||||
if(!is_array($value)) return '信息类别数据格式错误';
|
||||
$dict = DictData::where('type_value','info_cate')->column('value');
|
||||
foreach($value as $v){
|
||||
if(!in_array($v,$dict)){
|
||||
return '信息类别数据值无效';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAnnex($value): bool|string
|
||||
{
|
||||
if(!empty($value) && $value != '' && !is_array($value)){
|
||||
return '附件格式错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?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_connect;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\dict\DictData;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--项目重大信息上报模型
|
||||
* Class SupervisionProjectInfoReport
|
||||
* @package app\common\model\supervision_connect
|
||||
*/
|
||||
class SupervisionProjectInfoReport extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'supervision_project_info_report';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getAnnexAttr($value){
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
|
||||
public function getInfoCateAttr($value){
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
|
||||
public function getInfoCateTextAttr($value,$data): string
|
||||
{
|
||||
$dict = DictData::where('type_value','info_cate')->whereIn('value',json_decode($data['info_cate'],true))->column('name');
|
||||
return !empty($data['info_cate']) ? implode(',',$dict) : '';
|
||||
}
|
||||
|
||||
public function getHappenDateAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d',$value) : '';
|
||||
}
|
||||
|
||||
public function getSeverityTextAttr($value,$data){
|
||||
$dict = DictData::where('type_value','severity')->column('name','value');
|
||||
return !empty($data['severity']) ? $dict[$data['severity']] : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user