|
@@ -0,0 +1,119 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+namespace app\admin\controller;
|
|
|
+
|
|
|
+
|
|
|
+use think\App;
|
|
|
+use think\facade\Db;
|
|
|
+use think\facade\Validate;
|
|
|
+class ExecStat extends \app\admin\BaseController{
|
|
|
+ public function __construct(App $app) {parent::__construct($app);}
|
|
|
+
|
|
|
+ public function list(){
|
|
|
+ $param=$this->request->param(["name"=>"","type"=>"","status"=>"","companyNo"=>"",'relaComNo'=>'',"page"=>1,"size"=>15],"post","trim");
|
|
|
+ $conditon =[["is_del","=",0],["type","=",3]];
|
|
|
+ if($param['name']!='')$conditon[]=["name","like","%{$param['name']}%"];
|
|
|
+ if($param['status']!=='')$conditon[]=["status","=",$param['status']];
|
|
|
+ $count=Db::name("exec")->where($conditon)->count();
|
|
|
+ $total = ceil($count/$param['size']);
|
|
|
+ $page =$param['page']>=$total ?intval($total) :intval($param['page']);
|
|
|
+ $list=Db::name("exec")->where($conditon)->page($page,intval($param['size']))->select()->toArray();
|
|
|
+ return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function query(){
|
|
|
+ $param=$this->request->param(["name"=>"","status"=>"","companyNo"=>"",'relaComNo'=>'',"type"=>""],"post","trim");
|
|
|
+ $conditon =[["is_del","=",0],["type","=",3]];
|
|
|
+ if($param['name']!='')$conditon[]=["name","like","%{$param['name']}%"];
|
|
|
+ if($param['status']!=='')$conditon[]=["status","=",$param['status']];
|
|
|
+// if($param['companyNo']!='')$conditon[]=["companyNo","=",$param['companyNo']];
|
|
|
+// if($param['relaComNo']!='')$conditon[]=["companyNo","=",$param['relaComNo']];
|
|
|
+ $list=Db::name("exec")->where($conditon)->select()->toArray();
|
|
|
+ return app_show(0,"获取成功",$list);
|
|
|
+ }
|
|
|
+ public function add(){
|
|
|
+ $param=$this->request->param(["name"=>"","companyNo"=>"",'relaComNo'=>'',"action"=>''],"post","trim");
|
|
|
+ $valid=Validate::rule([
|
|
|
+ "name|脚本名称"=>'require|max:255',
|
|
|
+ ]);
|
|
|
+ if($valid->check($param)==false) return error_show(1004,$valid->getError());
|
|
|
+ $ist =Db::name("exec")->where(["name"=>$param['name'],"type"=>3,"is_del"=>0])->findOrEmpty();
|
|
|
+ if(!empty($ist))return error_show(1004,"同类型脚本名称已存在");
|
|
|
+ $data=[
|
|
|
+ "name"=>$param['name'],
|
|
|
+ "apply_name"=>$this->uname,
|
|
|
+ "apply_id"=>$this->uid,
|
|
|
+ "companyNo"=>'',
|
|
|
+ "companyName"=>'',
|
|
|
+ "action"=>$param["action"]??"",
|
|
|
+ "type"=>3,//行政业绩报表
|
|
|
+ "status"=>0,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $insert=Db::name("exec")->insert($data);
|
|
|
+ return $insert? app_show("0","新建成功"):app_show("1004","新建失败");
|
|
|
+ }
|
|
|
+//新建脚本数据
|
|
|
+ public function addlog(){
|
|
|
+ $param=$this->request->param(["id"=>"","start"=>"","end"=>"","companyNo"=>"",'relaComNo'=>'',"type"=>""],"post","trim");
|
|
|
+ $valid=Validate::rule([
|
|
|
+ "id|脚本ID"=>'require|number|gt:0',
|
|
|
+ "start|起始时间"=>'require|dateFormat:Y-m-d',
|
|
|
+ "end|结束时间"=>'require|dateFormat:Y-m-d|gt:start',
|
|
|
+ "type|执行类型"=>'require|number|in:3,4',
|
|
|
+ ]);
|
|
|
+ if($valid->check($param)==false) return error_show(1004,$valid->getError());
|
|
|
+ $exec =Db::name("exec")->where("id",$param['id'])->findOrEmpty();
|
|
|
+ if(empty($exec)) return error_show(1004,'未找到脚本数据');
|
|
|
+ if($exec['action']=='') return error_show(1004,'后端脚本还未上线');
|
|
|
+ $data=[
|
|
|
+ "name"=>$exec['name'],
|
|
|
+ "companyNo"=>'',
|
|
|
+ "companyName"=>'',
|
|
|
+ "start"=>date("Y-m-d 00:00:00",strtotime($param['start'])),
|
|
|
+ "end"=>date("Y-m-d 23:59:59",strtotime($param['end'])),
|
|
|
+ "apply_id"=>$this->uid,
|
|
|
+ "apply_name"=>$this->uname,
|
|
|
+ "action"=>$exec['action'],
|
|
|
+ "down_url"=>'',
|
|
|
+ "status"=>1,
|
|
|
+ "remark"=>'',
|
|
|
+ "type"=>$param["type"],
|
|
|
+ "expiretime"=>$param["type"]==3? date("Y-m-d H:i:s"):date("Y-m-d 22:00:00"),
|
|
|
+ "addtime"=> date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=> date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+
|
|
|
+ $in=Db::name("exec_log")->insert($data);
|
|
|
+ return $in? app_show("0","新建成功"):app_show("1004","新建失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ public function loglist(){
|
|
|
+ $param=$this->request->param(["name"=>"","apply_name"=>"","status"=>"","action"=>"","type"=>"","companyNo"=>"",'relaComNo'=>'',"page"=>1,"size"=>15],"post","trim");
|
|
|
+ $where=[["is_del","=",0],["type","in",[3,4]],["addtime",">=",date("Y-m-d H:i:s",strtotime("-30 day"))]];
|
|
|
+ if($param['name']!='')$where[]=["name","like","%{$param['name']}%"];
|
|
|
+ if($param['apply_name']!='')$where[]=["apply_name","like","%{$param['apply_name']}%"];
|
|
|
+ if($param['type']!='')$where[]=["type","=",$param['type']];
|
|
|
+ if($param['status']!='')$where[]=["status","=",$param['status']];
|
|
|
+ if($param['action']!='')$where[]=["action","=",$param['action']];
|
|
|
+ $count=Db::name("exec_log")->where($where)->count();
|
|
|
+ $total = ceil($count/$param['size']);
|
|
|
+ $page =$param['page']<=$total ? intval($param['page']):intval($total);
|
|
|
+ $list=Db::name("exec_log")->where($where)->page($page,intval($param['size']))->order("id desc")->select()
|
|
|
+ ->toArray();
|
|
|
+ return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
|
|
|
+ }
|
|
|
+ public function actionList(){
|
|
|
+ $ation=[
|
|
|
+
|
|
|
+ ["action"=>"Q","name"=>'产品部门销售业绩'],
|
|
|
+ ["action"=>"R","name"=>'采购部门销售业绩'],
|
|
|
+ ["action"=>"L","name"=>'客服部提成业绩'],
|
|
|
+ ["action"=>"S","name"=>'项目部提成业绩'],
|
|
|
+ ["action"=>"T","name"=>'新媒体提成业绩'],
|
|
|
+ ];
|
|
|
+ return app_show(0,"获取成功",$ation);
|
|
|
+ }
|
|
|
+}
|