Commit a86ffc53 by cwy

指标详情修改完成

parent f0ccd835
......@@ -61,6 +61,24 @@ class CommonBus extends BaseBus
}
/**
* 根据条件查询多条信息分页
* 示例:['id'=>1,'name'=>'测试']
* @return array|false
*/
public function getConditionalQueryAllPaging($where,$page,$limit)
{
try{
$info = $this->model->getConditionalQueryAllPaging($where,$page,$limit);
if(empty($info)){
return false;
}
return $info->toArray();
} catch(\Exception $e) {
exception($e,$this->className.'.getConditionalQueryAll');
}
}
/**
* 获取多个数据
* @return void
*/
......
......@@ -238,6 +238,12 @@ class ExcelFile extends BaseController
return returnResult(config("config.code.error"),$res['message']);
}
$norm_id = Db::name('norm')->insertGetId($normInfo);
$file = request()->file('file');
// 上传到本地服务器
$savename = \think\facade\Filesystem::putFile( 'import', $file);
$spreadsheet = IOFactory::load('storage/'.$savename);
$objWorksheet = $spreadsheet->getSheet(0); // 只允许读取第一页,多页请分开文档
$res = $this->importFormat($objWorksheet);
$taskInfo = Db::name('task_package')->where('id',$task_id)->find();
$normInfo = Db::name('norm')->where('id',$norm_id)->find();
if(empty($taskInfo)){
......@@ -248,26 +254,16 @@ class ExcelFile extends BaseController
$res['message'] = '获取不到子任务信息';
return returnResult(config("config.code.error"),$res['message']);
}
$file = request()->file('file');
// 上传到本地服务器
$savename = \think\facade\Filesystem::putFile( 'import', $file);
$spreadsheet = IOFactory::load('storage/'.$savename);
$cou = $spreadsheet->getAllSheets();
$num= 0;
$control = 0;
for ($sheetsIndex=0;$sheetsIndex<count($cou);$sheetsIndex++){
$objWorksheet = $spreadsheet->getSheet($sheetsIndex);
$res = $this->importFormat($objWorksheet);
// 格式化信息错误
if($res['status']==0){
return returnResult(config("config.code.error"),'文件第'.($sheetsIndex+1).'页,'.$res['message']);
return returnResult(config("config.code.error"),$res['message']);
}
if(empty($res['data'])){
$res['message'] = '表格内容为空';
return returnResult(config("config.code.error"),'文件第'.($sheetsIndex+1).'页,'.$res['message']);
return returnResult(config("config.code.error"),$res['message']);
}
$num += $res['num'];
// 开启数据库事务
$control =0;
$user_id = 1; //用户ID
$normExtendSql = []; // 指标自定义
// 展时端自定义
......@@ -291,7 +287,6 @@ class ExcelFile extends BaseController
array_push($extendValue,[$kk['value']]);
}
}
// 用户填写端自定义
foreach ($value['userData'] as $kk){
if(in_array($kk['name'],$extendUserName)){
......@@ -332,10 +327,7 @@ class ExcelFile extends BaseController
'extend_value'=>$kk['value'],
'extend_type'=>1
];
$sqlInser = Db::name('norm_list_extend')->insertGetId($arr);
if(empty($sqlInser)){
$control++;
}
Db::name('norm_list_extend')->insertGetId($arr);
}
// 指标领取
......@@ -364,8 +356,6 @@ class ExcelFile extends BaseController
'refer_type'=>$value['refer_type'],
'remark'=>$value['remark'],
'imgPath'=>$value['imgPath'],
'fileListPdf'=>$value['fileListPdf'],
'file_name'=>$value['file_name'],
];
$norm_collects_id = Db::name('norm_collects')->insertGetId($arr);
if(empty($norm_collects_id)){
......@@ -421,24 +411,21 @@ class ExcelFile extends BaseController
];
array_push($normExtendSql,$normExtendArr);
}
foreach ($normExtendSql as $value){
// 指标扩展信息
$sqlInser = Db::name('norm_extend')->insertGetId($value);
$sqlInser = Db::name('norm_extend')->insertAll($normExtendSql);
if(empty($sqlInser)){
$control++;
}
}
}
// 文件格式化有问题
if($res['status']==0 || $control>0){
if($control>0){
$res['message'] = '文件第'.$sheetsIndex.'页入库错误!';
$res['message'] = '数据无法入库!';
}
Db::rollback();
return returnResult(config("config.code.error"),$res['message']);
}else{
Db::commit();
return returnResult(config("config.code.success"),'导入成功,共'.$sheetsIndex.'页'.$num."行",'');
return returnResult(config("config.code.success"),$res['message'],'');
}
}catch (\Exception $e){
Db::rollback();
......
......@@ -221,6 +221,144 @@ class Norm
public function detail()
{
$id = input("param.id");
$page = input("param.page")?input("param.page"):-1;
$limit = input("param.limit")?input("param.limit"):10;
if(empty($id)){
return returnResult(config("config.code.error"),'填写信息错误,请检查!');
}
$normBus = new CommonBus('NormBus'); // 通过公共业务初始化指标类
$data = [];
// 指标详情
$res = $normBus->getConditionalQuery(['id'=>$id]);
// 指标扩展详情
$data['addItem']=$res;
$normExtendBus = new CommonBus('NormExtendBus');
$res = $normExtendBus->getConditionalQueryAll(['norm_id'=>$id]);
$data['custom']=$res;
// 领取信息
$NormReceivesBus = new CommonBus('NormReceivesBus'); // 通过公共业务初始化指标类
if($page == -1){
$data['receivesList'] = $NormReceivesBus->getConditionalQueryAll(['norm_id'=>$id]);
}else{
$list= $NormReceivesBus->getConditionalQueryAllPaging(['norm_id'=>$id],$page,$limit);
// var_dump($list);
$data['receivesList'] = $list['data'];
$data['total'] = $list['total'];
}
if (!empty($data['receivesList'])){
foreach ($data['receivesList'] as $index => $vlues){
$TaskPackageBus = new CommonBus('TaskPackageBus'); // 通过公共业务初始化指标类
$data['receivesList'][$index]['task_info'] = $TaskPackageBus->getConditionalQuery(['id'=>$vlues['task_id']]);
$NormListBus = new CommonBus('NormListBus'); // 通过公共业务初始化指标类
$data['receivesList'][$index]['norm_list_info'] = $NormListBus->getConditionalQuery(['id'=>$vlues['norm_list_id']]);
$NormListExtendBus = new CommonBus('NormListExtendBus'); // 通过公共业务初始化指标类
$data['receivesList'][$index]['norm_list_extend'] = $NormListExtendBus->getConditionalQueryAll(['norm_list_id'=>$vlues['norm_list_id']]);
$NormCollectsBus = new CommonBus('NormCollectsBus'); // 通过公共业务初始化指标类
$collectsInfo = $NormCollectsBus->getConditionalQuery(['norm_receive_id'=>$vlues['id']]);
if ($collectsInfo){
$NormCollectsExtendBus = new CommonBus('NormCollectsExtendBus'); // 通过公共业务初始化指标类
$normCollectsExtend = $NormCollectsExtendBus->getConditionalQueryAll(['norm_collects_id'=>$collectsInfo['id']]);
$data['receivesList'][$index]['refer_type'] = $collectsInfo['refer_type'];
$data['receivesList'][$index]['remark'] = $collectsInfo['remark'];
$data['receivesList'][$index]['imgPath'] = $collectsInfo['imgPath'];
$data['receivesList'][$index]['fileListPdf'] = $collectsInfo['fileListPdf'];
$data['receivesList'][$index]['file_name'] = $collectsInfo['file_name'];
$data['receivesList'][$index]['normCollectsExtend'] = $normCollectsExtend;
}else{
$normExtendBus = new CommonBus('NormExtendBus');
$res = $normExtendBus->getConditionalQueryAll(['norm_id'=>$id,'user_filled'=>1]);
$data['receivesList'][$index]['refer_type'] = '';
$data['receivesList'][$index]['remark'] = '';
$data['receivesList'][$index]['imgPath'] = '';
$data['receivesList'][$index]['fileListPdf'] = $collectsInfo['fileListPdf'];
$data['receivesList'][$index]['file_name'] = $collectsInfo['file_name'];
$data['receivesList'][$index]['normCollectsExtend'] =$res;
}
}
}
if($data){
return returnResult(config("config.code.success"),config("config.describe.success"),$data);
}else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),[]);
}
}
/**
* 返回指标完整详情信息
* @return \josn
*/
public function whole()
{
$id = input("param.id");
$page = input("param.page")?input("param.page"):-1;
$limit = input("param.limit")?input("param.limit"):10;
if(empty($id)){
return returnResult(config("config.code.error"),'填写信息错误,请检查!');
}
$normBus = new CommonBus('NormBus'); // 通过公共业务初始化指标类
$data = [];
// 指标详情
$res = $normBus->getConditionalQuery(['id'=>$id]);
// 指标扩展详情
$data['addItem']=$res;
$normExtendBus = new CommonBus('NormExtendBus');
$res = $normExtendBus->getConditionalQueryAll(['norm_id'=>$id]);
$data['custom']=$res;
// 领取信息
$NormReceivesBus = new CommonBus('NormReceivesBus'); // 通过公共业务初始化指标类
if($page == -1){
$data['receivesList'] = $NormReceivesBus->getConditionalQueryAll(['norm_id'=>$id]);
}else{
$list= $NormReceivesBus->getConditionalQueryAllPaging(['norm_id'=>$id],$page,$limit);
// var_dump($list);
$data['receivesList'] = $list['data'];
$data['total'] = $list['total'];
}
if (!empty($data['receivesList'])){
foreach ($data['receivesList'] as $index => $vlues){
$TaskPackageBus = new CommonBus('TaskPackageBus'); // 通过公共业务初始化指标类
$data['receivesList'][$index]['task_info'] = $TaskPackageBus->getConditionalQuery(['id'=>$vlues['task_id']]);
$NormListBus = new CommonBus('NormListBus'); // 通过公共业务初始化指标类
$data['receivesList'][$index]['norm_list_info'] = $NormListBus->getConditionalQuery(['id'=>$vlues['norm_list_id']]);
$NormListExtendBus = new CommonBus('NormListExtendBus'); // 通过公共业务初始化指标类
$data['receivesList'][$index]['norm_list_extend'] = $NormListExtendBus->getConditionalQueryAll(['norm_list_id'=>$vlues['norm_list_id']]);
$NormCollectsBus = new CommonBus('NormCollectsBus'); // 通过公共业务初始化指标类
$collectsInfo = $NormCollectsBus->getConditionalQuery(['norm_receive_id'=>$vlues['id']]);
if ($collectsInfo){
$NormCollectsExtendBus = new CommonBus('NormCollectsExtendBus'); // 通过公共业务初始化指标类
$normCollectsExtend = $NormCollectsExtendBus->getConditionalQueryAll(['norm_collects_id'=>$collectsInfo['id']]);
$data['receivesList'][$index]['refer_type'] = $collectsInfo['refer_type'];
$data['receivesList'][$index]['remark'] = $collectsInfo['remark'];
$data['receivesList'][$index]['imgPath'] = $collectsInfo['imgPath'];
$data['receivesList'][$index]['fileListPdf'] = $collectsInfo['fileListPdf'];
$data['receivesList'][$index]['file_name'] = $collectsInfo['file_name'];
$data['receivesList'][$index]['normCollectsExtend'] = $normCollectsExtend;
}else{
$normExtendBus = new CommonBus('NormExtendBus');
$res = $normExtendBus->getConditionalQueryAll(['norm_id'=>$id,'user_filled'=>1]);
$data['receivesList'][$index]['refer_type'] = '';
$data['receivesList'][$index]['remark'] = '';
$data['receivesList'][$index]['imgPath'] = '';
$data['receivesList'][$index]['fileListPdf'] = $collectsInfo['fileListPdf'];
$data['receivesList'][$index]['file_name'] = $collectsInfo['file_name'];
$data['receivesList'][$index]['normCollectsExtend'] =$res;
}
}
}
if($data){
return returnResult(config("config.code.success"),config("config.describe.success"),$data);
}else{
return returnResult(config("config.code.success"),config("config.describe.null_data"),[]);
}
}
/**
* 返回指标详情
* @return \josn
*/
public function detail1()
{
$id = input("param.id");
if(empty($id)){
return returnResult(config("config.code.error"),'填写信息错误,请检查!');
}
......
......@@ -61,6 +61,7 @@ Route::rule("taskPackage/delete","TaskPackage/delete"); // 删除任务列表
Route::rule("norm/add","Norm/add"); // 新增指标
Route::rule("norm/list","Norm/list"); // 指标列表
Route::rule("norm/detail","Norm/detail"); // 指标详情
Route::rule("norm/whole","Norm/whole"); // 指标完整详情信息
Route::rule("norm/edit","Norm/edit"); // 指标详情
Route::rule("norm/finalData","Norm/finalData"); // 返回最后的ID
Route::rule("norm/delete","Norm/delete"); // 删除详情
......
......@@ -145,6 +145,31 @@ class NormReceives extends Model
}
/**
* 根据用户条件返回多条信息分页
* @param $where //查询条件
* @return UserInfo|array|false|Model|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*
*/
public function getConditionalQueryAllPaging($where,$page,$limit)
{
try{
return $this->with([
'userInfo' => function($query){
$query->field("id,name");
},
])->where($where)->paginate([
'list_rows'=>$limit,
'page'=>$page
]);
}catch (\Exception $e){
exception($e,'mysql.NormReceives.getFindModel');
}
}
/**
* 根据条件获取多个值
* @param $where
* @return Menu[]|array|\think\Collection|void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment