Commit 20a05623 by wenyi.chen

线上

parent 173e63d1
......@@ -16,12 +16,13 @@ use think\facade\Filesystem;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use think\facade\Env;
class ExcelTest extends BaseController
use think\facade\Db;
class ExcelFile extends BaseController
{
public function importFile()
{
try{
$spreadsheet = IOFactory::load('excel_with_image.xlsx');
$spreadsheet = IOFactory::load('import.xlsx');
// $allSheets = $spreadsheet->getAllSheets();
$objWorksheet = $spreadsheet->getSheet(0);
$drawings = $objWorksheet->getDrawingCollection();
......@@ -81,8 +82,8 @@ class ExcelTest extends BaseController
// 创建一个新的 Spreadsheet 对象
$spreadsheet = new Spreadsheet();
$list = [];
for ($i=0;$i<10;$i++){
if($i % 200 == 0){
for ($i=0;$i<100;$i++){
if($i % 2 == 0){
array_push($list,$data[1]);
}else{
array_push($list,$data[0]);
......@@ -124,9 +125,82 @@ class ExcelTest extends BaseController
$drawing->setWidth(80); // 图片宽度,单位为磅
}
}
// 保存 ExcelTest 文件
// 保存 ExcelFile 文件
$writer = new Xlsx($spreadsheet);
$writer->save('excel_with_image.xlsx');
$writer->save('import.xlsx');
}catch (\Exception $e){
var_dump($e->getMessage());
}
}
public function taskExportFile()
{
try{
$task = Db::table('task_package')->where('id', 22)->find();
$norm = Db::table('norm')->where('task_id', 22)->select();
$list = [];
foreach ($norm as $value){
$sheet = ['total'=>0,'data'=>[]];
$normList = Db::table('norm_list')->where('norm_id', $value['id'])->select();
foreach ($normList as $index=> $val){
$total = 0;
$normCollects = Db::table('norm_collects')->where('norm_list_id', $val['id'])->find();
$referType = '无'; // 信源类型
$imgPath = '无'; // 图片
$remark = '无';
$normCollectsId = '';
if ($normCollects){
if($normCollects['refer_type']==1){
$referType = '官网/政府';
}else if ($normCollects['refer_type']==2){
$referType = '权威媒体';
}else{
$referType = '其他可信信源';
}
if ($normCollects['imgPath']){
$imgPath = $normCollects['imgPath'];
}
if ($normCollects['remark']){
$remark = $normCollects['remark'];
}
$normCollectsId = $normCollects['id'];
}
$data = [
$index,
$val['name'],
$val['level'],
$val['refer'],
$val['price'],
$value['guide'],
$value['sort'],
$remark,
$referType,
];
$normListExtend = Db::table('norm_list_extend')->where('norm_list_id', $val['id'])->select();
// 添加展示端
foreach ($normListExtend as $extendValue){
$total +=1;
array_push($data,$extendValue['extend_name']);
array_push($data,$extendValue['extend_value']);
}
// 添加用户端
if($normCollectsId){
$collectsInfo = Db::table('norm_collects_extend')->where('norm_collects_id', $normCollectsId)->select();
foreach ($collectsInfo as $collectsValue){
$total +=1;
array_push($data,$collectsValue['extend_name']);
array_push($data,$collectsValue['extend_value']);
}
}
// 添加图片信息
array_push($data,$imgPath);
// 添加第一条指标信息
$sheet['total'] = $total;
array_push($sheet['data'],$data);
}
array_push($list,$sheet);
}
dump($list);
}catch (\Exception $e){
var_dump($e->getMessage());
}
......
......@@ -13,7 +13,7 @@ use app\api\business\CommonBus as CommonBus; // 指标待领取扩展业务
use think\facade\Db;
class Norm
{
public $num = 1;
public $num = 2;
/**
* 任务列表
* @return \josn|void
......@@ -420,14 +420,10 @@ class Norm
array_push($extend,['name'=>$value['name'],'value'=>$value['value']]);
}
}
$keyName = []; //每个值对应的名称
$ordering= []; // 需要排列组合的数据
foreach ($extend as $value){
$exp = explode(',',$value['value']);
array_push($ordering,$exp);
foreach ($exp as $value1){
array_push($keyName,[$value['name']=>$value1]);
}
}
// 格式化数据
......@@ -436,12 +432,11 @@ class Norm
// 格式化每个数据表需要的数据格式
foreach ($processedData as $value){
$exp = explode(',',$value);
foreach ($exp as $value1){
foreach ($exp as $index=> $value1){
$normList = []; // 指标待领取数据
$normListExtend = []; // 指标待领取数据扩展
$key = \app\common\lib\Arr::deepGetKey($value1,$keyName);
// 添加到用户待领取数据表
if($key=='名称'){
if($index==0){
$normList['task_id'] = $data['task_id'];
$normList['norm_id']=$normId;
$normList['name']=$value1;
......@@ -461,7 +456,7 @@ class Norm
}else{
$normListExtend['norm_id'] = $normId;
$normListExtend['norm_list_id'] = $normListId;
$normListExtend['extend_name'] = $key;
$normListExtend['extend_name'] = $extend[$index]['name'];
$normListExtend['extend_value'] = $value1;
$normListExtend['extend_type'] = 1;
$normListExtendBus = new CommonBus('NormListExtendBus');// 通过公共业务初始化用户待领取指标扩展类
......
......@@ -11,6 +11,7 @@ use think\facade\Db;
class NormReceives extends AuthBase
{
public $num = 2;
/**
* 当前可领取的指标列表
* @return \josn|void
......@@ -176,9 +177,11 @@ class NormReceives extends AuthBase
$NormListBus= new \app\api\business\CommonBus('NormListBus');
$info = $NormListBus->getConditionalQuery(['id'=>$data['norm_list_id']]);
if($info){
$NormListBus->decrementing($data['norm_list_id'],1);
//添加数据
$result = $NormReceivesBus->addData($data);
if ($info['num']>0){
$NormListBus->decrementing($data['norm_list_id'],1);
//添加数据
$result = $NormReceivesBus->addData($data);
}
}else{
return returnResult(config("config.code.error"),'待领取指标ID错误!','');
}
......
......@@ -26,7 +26,7 @@ class Test extends BaseController
$sheet = $spreadsheet->getActiveSheet();
// 设置一些数据到单元格中
$sheet->setCellValue('A1', '带有图片的 ExcelTest 表格');
$sheet->setCellValue('A1', '带有图片的 ExcelFile 表格');
// 创建一个 Drawing 对象,并设置图片的路径
$drawing = new Drawing();
......@@ -40,7 +40,7 @@ class Test extends BaseController
$drawing->setHeight(36); // 图片高度,单位为磅
$drawing->setWidth(32); // 图片宽度,单位为磅
// 保存 ExcelTest 文件
// 保存 ExcelFile 文件
$writer = new Xlsx($spreadsheet);
$writer->save('excel_with_image.xlsx');
}catch (\Exception $e){
......
......@@ -93,6 +93,9 @@ Route::rule("normOrders/list","NormOrders/list"); //结算指标列表
Route::rule("normOrders/detail","NormOrders/detail"); //结算指标列表
Route::rule("test","ExcelTest/importFile"); //结算指标列表
Route::rule("test1","ExcelTest/exportFile"); //结算指标列表
Route::rule("importFile","ExcelFile/importFile"); //结算指标列表
Route::rule("exportFile","ExcelFile/exportFile"); //结算指标列表
Route::rule("taskExportFile","ExcelFile/taskExportFile"); //结算指标列表
//Route::rule("import","ImportFile/import");
\ No newline at end of file
......@@ -115,8 +115,7 @@ class NormReceives extends Model
try{
return $this->with([
'userInfo' => function($query){
$query->field("id,name");
},
$query->field("id,name");},
])->where($where)->find();
}catch (\Exception $e){
exception($e,'mysql.NormReceives.getFindModel');
......
a:1:{s:5:"users";a:10:{s:2:"id";i:4;s:4:"name";s:13:"测试人员2";s:5:"phone";s:4:"2131";s:7:"account";s:7:"test002";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:10:"1708836112";s:5:"email";s:3:"123";s:13:"department_id";i:2;}}
\ No newline at end of file
a:1:{s:5:"users";a:10:{s:2:"id";i:3;s:4:"name";s:10:"管理员1";s:5:"phone";s:11:"18417180202";s:7:"account";s:8:"admin001";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:10:"1709196711";s:5:"email";s:0:"";s:13:"department_id";i:1;}}
\ No newline at end of file
a:1:{s:5:"users";a:10:{s:2:"id";i:1;s:4:"name";s:12:"开发人员";s:5:"phone";s:11:"18417180202";s:7:"account";s:5:"admin";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:1:"1";s:5:"email";s:18:"wesley_prc@163.com";s:13:"department_id";i:1;}}
\ No newline at end of file
a:1:{s:5:"users";a:10:{s:2:"id";i:3;s:4:"name";s:10:"管理员1";s:5:"phone";s:11:"18417180202";s:7:"account";s:8:"admin001";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:10:"1709196711";s:5:"email";s:0:"";s:13:"department_id";i:1;}}
\ No newline at end of file
a:1:{s:5:"users";a:10:{s:2:"id";i:2;s:4:"name";s:13:"测试人员1";s:5:"phone";s:4:"2131";s:7:"account";s:7:"test001";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:10:"1708836112";s:5:"email";s:3:"123";s:13:"department_id";i:2;}}
\ No newline at end of file
a:1:{s:5:"users";a:10:{s:2:"id";i:1;s:4:"name";s:12:"开发人员";s:5:"phone";s:11:"18417180202";s:7:"account";s:5:"admin";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:1:"1";s:5:"email";s:18:"wesley_prc@163.com";s:13:"department_id";i:1;}}
\ No newline at end of file
a:1:{s:5:"users";a:10:{s:2:"id";i:1;s:4:"name";s:12:"开发人员";s:5:"phone";s:11:"18417180202";s:7:"account";s:5:"admin";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:1:"1";s:5:"email";s:18:"wesley_prc@163.com";s:13:"department_id";i:1;}}
\ No newline at end of file
a:1:{s:5:"users";a:10:{s:2:"id";i:1;s:4:"name";s:12:"开发人员";s:5:"phone";s:11:"18417180202";s:7:"account";s:5:"admin";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:1:"1";s:5:"email";s:18:"wesley_prc@163.com";s:13:"department_id";i:1;}}
\ No newline at end of file
a:1:{s:5:"users";a:10:{s:2:"id";i:1;s:4:"name";s:12:"开发人员";s:5:"phone";s:11:"18417180202";s:7:"account";s:5:"admin";s:8:"password";s:32:"e10adc3949ba59abbe56e057f20f883e";s:6:"status";i:1;s:4:"type";i:1;s:11:"create_time";s:1:"1";s:5:"email";s:18:"wesley_prc@163.com";s:13:"department_id";i:1;}}
\ No newline at end of file
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