Commit 2ab5ae94 authored by hujun's avatar hujun

考核

parent 666fb131
...@@ -5,6 +5,7 @@ namespace app\api_broker\controller; ...@@ -5,6 +5,7 @@ namespace app\api_broker\controller;
use app\api_broker\extend\Basic; use app\api_broker\extend\Basic;
use app\api_broker\service\RedisCacheService;
use app\model\RWorkLearningModel; use app\model\RWorkLearningModel;
class uploadWorkLearning extends Basic class uploadWorkLearning extends Basic
...@@ -45,11 +46,17 @@ class uploadWorkLearning extends Basic ...@@ -45,11 +46,17 @@ class uploadWorkLearning extends Basic
if (file_put_contents($url, $img)) { if (file_put_contents($url, $img)) {
$agent_report = new RWorkLearningModel(); $agent_report = new RWorkLearningModel();
$s_redis = new RedisCacheService();
$agent_data = $s_redis->getRedisCache(2, $this->params['agent_id']);
$data['agent_name'] = $agent_data['name'];
$data['agent_id'] = $this->params['agent_id']; $data['agent_id'] = $this->params['agent_id'];
$data['img_url'] = $img_name; $data['img_url'] = $img_name;
$data['type'] = $this->params['type']; //0素质测评 1方法分析 2价值观考核 $data['type'] = $this->params['type']; //0素质测评 1方法分析 2价值观考核
$data['img_name'] = IMAGES_URL.$url; $data['img_name'] = IMAGES_URL.$url;
$agent_report->editData($data); $agent_report->editData($data);
unset($agent_data);
unset($data);
} else { } else {
$code = 101; $code = 101;
$msg = '生成图片失败'; $msg = '生成图片失败';
......
...@@ -5,37 +5,102 @@ namespace app\index\controller; ...@@ -5,37 +5,102 @@ namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\model\RWorkLearningModel;
class WorkLearning extends Basic class WorkLearning extends Basic
{ {
/** /**
* 素质测评 * 素质测评
* *
* @return \think\response\View * @return \think\Response|\think\response\View
*/ */
public function qualityAssessment() public function qualityAssessment()
{ {
return view('work_learning/qualityAssessment'); if (!$this->request->isAjax()) {
return view('work_learning/qualityAssessment');
}
$data = $this->getList($this->params, 0);
return $this->response($data['code'], $data['msg'], $data['data']);
} }
/** /**
* 方法分析 * 方法分析
* *
* @return \think\response\View * @return \think\Response|\think\response\View
*/ */
public function methodOfAnalysis() public function methodOfAnalysis()
{ {
return view('work_learning/methodOfAnalysis'); if (!$this->request->isAjax()) {
return view('work_learning/methodOfAnalysis');
}
$data = $this->getList($this->params, 1);
return $this->response($data['code'], $data['msg'], $data['data']);
} }
/** /**
* 价值观考核 * 价值观考核
* *
* @return \think\response\View * @return \think\Response|\think\response\View
*/ */
public function valueAssessment() public function valueAssessment()
{ {
return view('work_learning/valueAssessment'); if (!$this->request->isAjax()) {
return view('work_learning/valueAssessment');
}
$data = $this->getList($this->params, 2);
return $this->response($data['code'], $data['msg'], $data['data']);
}
/**
* @param $params
* @param $type
* @return mixed
*/
private function getList($params, $type)
{
$page_no = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$page_size = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
// 时间筛选
if (!empty($params['start_date']) && !empty($params['end_date'])) {
$where['a.create_time'] = ['between', [$params['start_date'] . ' 00:00:00', $params['end_date'] . ' 23:59:59']];
}
// 部门筛选
if (!empty($params['district_id'])) {
$where['b.district_id'] = $params['district_id'];
}
// 门店筛选
if (!empty($params['store_id'])) {
$where['b.store_id'] = $params['store_id'];
}
// 经纪人筛选
if (!empty($params['agent_id'])) {
$where['b.id'] = $params['agent_id'];
}
// 日报周报筛选 10业务员 20店长 30总监
if (!empty($params['site_id'])) {
$where['b.site_id'] = $params['site_id'];
}
$where['a.type'] = $type;//0素质测评 1方法分析 2价值观考核
$where['a.is_del'] = 0;
try {
$work = new RWorkLearningModel();
$field = 'a.create_time,a.img_url,b.agent_name';
$list = $work->getWordAgentList($page_no, $page_size, 'id desc', $field, $where);
$result['data']['list'] = $list;
$result['data']['total'] = $work->getWorkAgentListTotal($where);
$result['code'] = 200;
$result['msg'] = '';
} catch (\Exception $e) {
$result['code'] = 101;
$result['msg'] = '内部错误:'.$e->getMessage();
}
return $result;
} }
} }
\ No newline at end of file
...@@ -9,7 +9,7 @@ use think\Db; ...@@ -9,7 +9,7 @@ use think\Db;
class RWorkLearningModel extends BaseModel class RWorkLearningModel extends BaseModel
{ {
protected $table = 'r_work_learning'; protected $table = 'r_work_learning';
private $db_; private $db_;
public function __construct($data = []) public function __construct($data = [])
{ {
...@@ -17,4 +17,44 @@ class RWorkLearningModel extends BaseModel ...@@ -17,4 +17,44 @@ class RWorkLearningModel extends BaseModel
$this->db_ = Db::name($this->table); $this->db_ = Db::name($this->table);
} }
/**
* @param $pageNo
* @param $pageSize
* @param $field
* @param $params
* @param $order
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getWordAgentList($pageNo, $pageSize, $order, $field, $params)
{
$result = $this
->field($field)
->alias('a')
->join('a_agents b', 'a.agent_id=b.id', 'left')
->where($params)
->limit($pageSize)
->page($pageNo)
->order($order)
->select();
return $result;
}
/**
* @param $field
* @param $params
* @param $order
* @return int|string
*/
public function getWorkAgentListTotal($params)
{
$result = $this
->alias('a')
->join('a_agents b', 'a.agent_id=b.id', 'left')
->where($params)
->count('a.id');
return $result;
}
} }
\ 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