Files
oms/back/application/api/controller/Work.php
2026-03-10 18:45:36 +08:00

826 lines
34 KiB
PHP

<?php
namespace app\api\controller;
use app\api\controller\User;
use think\Config;
use think\Controller;
use think\Db;
use think\Log;
use think\Model;
use think\Request;
use think\cache\driver\Memcache;
header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Methods:GET, POST, OPTIONS, DELETE");
header("Access-Control-Allow-Headers:DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept-Language, Origin, Accept-Encoding");
class Work extends Common
{
//获取内部客户参与的项目
public function GetWorkInfoByLoginId()
{
$param = request()->post();
$user_id = $param['user_id'];
$user = new User();
$project_work = $this->GetProjectList($user_id);
for ($i = 0; $i < count($project_work); $i++) {
$involve_manager = $project_work[$i]['involve_manager'];
$info = $user->GetUserInfoByLoginId($involve_manager);
if ($info && isset($info['name'])) {
$project_work[$i]['issue_creator_name'] = $info['name'];
}
}
return $this->sendSuccess($project_work);
}
//获取外部客户合作项目
public function GetWorkInfoByLoginProject()
{
$param = request()->post();
$user = new User();
$user_id = $param['user_id'];
$user_info = db('system_user')->where('id', $user_id)->find();
if ($user_info) {
$user_project = explode(',', $user_info['user_project']);
$project_info = db('project_info')->alias('p')
->join('project_state s', 's.id =p.project_state', 'left')
->whereIn('project_id', $user_project)
->where('p.project_state', '<', 10) // 未关闭的项目
// ->where('p.project_type', 3) //合作类项目
->field('p.*, s.desp as project_state_name,1 as project_types')
->select();
foreach ($project_info as &$info) {
$involve_manager = $info['involve_manager'];
$userInfo = $user->GetUserInfoByLoginId($involve_manager);
if ($userInfo && isset($userInfo['name'])) {
$info['issue_creator_name'] = $userInfo['name'];
}
$info['issue_count'] = $this->GetProjectIssueCount($user_id, $info['project_id']);
$info['task_count'] = $this->GetProjectTaskCount($user_id, $info['project_id']);
}
unset($info);
return $this->sendSuccess($project_info);
}
}
//获取业主客户参与的项目
public function GetWorkInfoByLoginProjectCustomer()
{
$param = request()->post();
$user = new User();
$user_id = $param['user_id'];
$user_info = db('system_user')->where('id', $user_id)->find();
if ($user_info) {
$user_project = explode(',', $user_info['user_project']);
$project_info = db('project_info')->alias('p')
->join('project_state s', 's.id =p.project_state', 'left')
->whereIn('project_id', $user_project)
->where('p.project_state', '<', 10) // 未关闭的项目
->where('p.project_type', 1) //销售类项目
->field('p.*, s.desp as project_state_name,1 as project_types')
->select();
foreach ($project_info as &$info) {
$involve_manager = $info['involve_manager'];
$userInfo = $user->GetUserInfoByLoginId($involve_manager);
if ($userInfo && isset($userInfo['name'])) {
$info['issue_creator_name'] = $userInfo['name'];
}
$info['issue_count'] = $this->GetProjectIssueCountCustomer($user_id, $info['project_id']);
$info['task_count'] = $this->GetProjectTaskCountCustomer($user_id, $info['project_id']);
}
unset($info);
return $this->sendSuccess($project_info);
}
}
public function GetProjectIssueCountCustomer($user_id, $project_id)
{
$count = db('project_issues')->alias('s')
->join('project_info i', 'i.project_id =s.project_id', 'left')
->join('project_issue_state t', 't.id =s.issue_state', 'left')
->where('s.project_id', $project_id)
->where('s.issue_state', '<', 10)
->field('s.*, i.project_name, i.project_number, t.desp as issue_state_name')
->count();
return $count;
}
public function GetProjectTaskCountCustomer($user_id, $project_id)
{
$count = db('work_task_info')->alias('s')
->join('work_story_info x', 'x.story_id =s.story_id', 'left')
->join('project_info i', 'i.project_id =x.work_id', 'left')
->join('work_task_state t', 't.id =s.task_state', 'left')
->where('x.work_id', $project_id)
->count();
return $count;
}
//获取参与的客户项目列表
public function GetProjectList($user_id)
{
//判断登录用户的角色,如果是管理员,就获取所有的项目信息
$user_info = db('system_user')->where('id', $user_id)->find();
$ret = [];
if (1 == $user_info['user_role'])
{
$ret = db('project_info')->alias('p')
->join('project_state s', 's.id =p.project_state', 'left')
->where('p.project_state', '<', 10) //未关闭的项目
->field('p.*, s.desp as project_state_name,1 as project_types')
->select();
}
else
{
$ret = db('project_info')->alias('p')
->join('project_state s', 's.id =p.project_state', 'left')
->where('p.project_state', '<', 10) //未关闭的项目
->where(function ($query) use ($user_id) {
$query->where('p.involve_manager', $user_id)
->whereor('p.involve_members', 'like', $user_id . ',%')
->whereor('p.involve_members', 'like', '%,' . $user_id . ',%')
->whereor('p.involve_members', 'like', $user_id . '')
->whereor('p.involve_members', 'like', '%,' . $user_id);
})
->field('p.*, s.desp as project_state_name,1 as project_types')
->select();
}
//统计每个项目与登录用户有关的任务数
for ($i = 0; $i < count($ret); $i++) {
$ret[$i]['issue_count'] = $this->GetProjectIssueCount($user_id, $ret[$i]['project_id']);
$ret[$i]['task_count'] = $this->GetProjectTaskCount($user_id, $ret[$i]['project_id']);
}
return $ret;
}
public function GetProjectIssueList()
{
$param = request()->post();
$user = new User();
$user_id = $param['user_id'];// = 60;
$project_id = $param['project_id']; // = 122;
$issue_state = $param['issue_state']; // = 0;
$user_info = db('system_user')->where('id', $user_id)->find();
$count = 0;
if (1 == $user_info['user_role'])
{
$where = [];
if ($issue_state == 1) {
$where['s.issue_state'] = array('<', 10); //未关闭
} else if ($issue_state == 2) {
$where['s.issue_state'] = array('>', 10);//已关闭
}
//负责处理的问题
$ret = db('project_issues')->alias('s')
->join('project_info i', 'i.project_id =s.project_id', 'left')
->join('project_issue_state t', 't.id =s.issue_state', 'left')
->where('s.project_id', $project_id)
->where($where)
->field('s.*, i.project_name, i.project_number, t.desp as issue_state_name, i.involve_manager,1 as project_types')
->select();
for ($i = 0; $i < count($ret); $i++) {
$info = $user->GetUserInfoByLoginId($ret[$i]['issue_processor']);
if ($info != "")
{
$ret[$i]['issue_processor_name'] = $info['name'];
}
else
{
$ret[$i]['issue_processor_name'] = '-';
}
$info = $user->GetUserInfoByLoginId($ret[$i]['issue_creator']);
$ret[$i]['issue_creator_name'] = $info['name'];
}
return $this->sendSuccess($ret);
}else{
$where = [];
if ($issue_state == 1) {
$where['s.issue_state'] = array('<', 10); //未关闭
} else if ($issue_state == 2) {
$where['s.issue_state'] = array('>', 10);//已关闭
}
//负责处理的问题
$ret = db('project_issues')->alias('s')
->join('project_info i', 'i.project_id =s.project_id', 'left')
->join('project_issue_state t', 't.id =s.issue_state', 'left')
->where('s.project_id', $project_id)
->where(function ($query) use ($user_id) {
$query->where('s.issue_processor', $user_id)
->whereor('s.issue_creator', $user_id)
->whereor('i.involve_manager', $user_id);
})
->where($where)
->field('s.*, i.project_name, i.project_number, t.desp as issue_state_name, i.involve_manager,1 as project_types')
->select();
for ($i = 0; $i < count($ret); $i++) {
$info = $user->GetUserInfoByLoginId($ret[$i]['issue_processor']);
if ($info != "")
{
$ret[$i]['issue_processor_name'] = $info['name'];
}
else
{
$ret[$i]['issue_processor_name'] = '-';
}
$info = $user->GetUserInfoByLoginId($ret[$i]['issue_creator']);
$ret[$i]['issue_creator_name'] = $info['name'];
}
return $this->sendSuccess($ret);
}
}
public function GetProjectIssueCount($user_id, $project_id)
{
$user_info = db('system_user')->where('id', $user_id)->find();
$count = 0;
// dump($user_info['user_role']);
if (1 == $user_info['user_role'])
{
$count = db('project_issues')->alias('s')
->join('project_info i', 'i.project_id =s.project_id', 'left')
->join('project_issue_state t', 't.id =s.issue_state', 'left')
->where('s.project_id', $project_id)
->where('s.issue_state', '<', 10)
->field('s.*, i.project_name, i.project_number, t.desp as issue_state_name')
->count();
}
else
{
$count = db('project_issues')->alias('s')
->join('project_info i', 'i.project_id =s.project_id', 'left')
->join('project_issue_state t', 't.id =s.issue_state', 'left')
->where('s.project_id', $project_id)
->where(function ($query) use ($user_id) {
$query->where('s.issue_processor', $user_id)
->whereor('s.issue_creator', $user_id)
->whereor('i.involve_manager', $user_id);
})
->where('s.issue_state', '<', 10)
->field('s.*, i.project_name, i.project_number, t.desp as issue_state_name')
->count();
}
return $count;
}
public function GetProjectTaskList()
{
$param = request()->post();
$user = new User();
$user_id = $param['user_id'];
$project_id = $param['project_id'];
$user_info = db('system_user')->where('id', $user_id)->find();
if (1 == $user_info['user_role'])
{
$where = [];
if($param['task_state'] != ''){
$where['s.task_state'] = $param['task_state'];
}
if($param['task_processor'] != ''){
$where['s.task_processor'] = $param['task_processor'];
}
$ret = db('work_task_info')->alias('s')
->join('work_story_info y', 'y.story_id =s.story_id', 'left')
->join('system_user u', 'u.id =s.task_processor', 'left')
->join('work_task_state p', 'p.id =s.task_state', 'left')
->where('y.work_id', $project_id)
->where($where)
->field('s.*, p.desp as task_state_desp, y.story_id,2 as project_types,y.story_manager')
->select();
$user = new User();
for ($i=0; $i<count($ret); $i++)
{
//根据登录账号获取用户姓名
$user_info = $user->GetUserInfoByLoginId($ret[$i]['task_processor']);
$ret[$i]['task_processor_name'] = $user_info['name'];
}
return $this->sendSuccess($ret);
}else{
$where = [];
if($param['task_state'] != ''){
$where['s.task_state'] = $param['task_state'];
}
$ret = db('work_task_info')->alias('s')
->join('work_story_info y', 'y.story_id =s.story_id', 'left')
->join('system_user u', 'u.id =s.task_processor', 'left')
->join('work_task_state p', 'p.id =s.task_state', 'left')
->where('y.work_id', $project_id)
->where($where)
->where(function ($query) use ($user_id) {
$query->where('s.task_processor', $user_id)
->whereor('y.story_manager', $user_id);
})
->field('s.*, p.desp as task_state_desp, y.story_id,2 as project_types,y.story_manager')
->select();
$user = new User();
for ($i=0; $i<count($ret); $i++)
{
//根据登录账号获取用户姓名
$user_info = $user->GetUserInfoByLoginId($ret[$i]['task_processor']);
$ret[$i]['task_processor_name'] = $user_info['name'];
}
return $this->sendSuccess($ret);
}
}
public function GetProjectTaskCount($user_id, $project_id)
{
$user_info = db('system_user')->where('id', $user_id)->find();
$count = 0;
if (1 == $user_info['user_role'])
{
$count = db('work_task_info')->alias('s')
->join('work_story_info x', 'x.story_id =s.story_id', 'left')
->join('project_info i', 'i.project_id =x.work_id', 'left')
->join('work_task_state t', 't.id =s.task_state', 'left')
->where('x.work_id', $project_id)
->where('s.task_state', '<', 4)
->count();
}
else
{
$count = db('work_task_info')->alias('s')
->join('work_story_info x', 'x.story_id =s.story_id', 'left')
->join('project_info i', 'i.project_id =x.work_id', 'left')
->join('work_task_state t', 't.id =s.task_state', 'left')
->where('x.work_id', $project_id)
->where('s.task_state', '<', 4)
->where(function ($query) use ($user_id) {
$query->where('s.task_processor', $user_id)
->whereor('x.story_manager', $user_id);
})
->count();
}
return $count;
}
public function GetProjectDevelopProcessor()
{
$param = request()->post();
if (!$param) {
return [];
}
$member_ids = [];
$array = [];
if ($param['project_types'] === 1) {
$project_info = db('project_info')->where('project_id', $param['project_id'])->find();
if ($project_info && !empty($project_info['involve_members'])) {
$member_ids = explode(',', $project_info['involve_members']);
}
} elseif ($param['project_types'] === 2) {
$develop_info = db('develop_project')->where('project_id', $param['project_id'])
->field('project_members')->find();
if ($develop_info && !empty($develop_info['project_members'])) {
$member_ids = explode(',', $develop_info['project_members']);
}
}
for ($i = 0; $i < count($member_ids); $i++){
$ret = db('system_user')->alias('su')
->join('hr_staff hs', 'su.user_id = hs.staff_id')
->whereIn('su.id', $member_ids[$i])
->field('su.id, hs.staff_name')
->find();
$array[] = $ret;
}
return $this->sendSuccess($array);
}
public function UpdateProDeveProcessor()
{
$param = request()->post();
if($param){
if($param['project_types']===1){
$ret= db('project_issues')
->where('issue_id',$param['issue_id'])
->update(['issue_processor'=>$param['processor'] ,'issue_state' => 2]);
if($ret){
return $this->sendSuccess('分配成功');
}else{
return $this->sendError('分配失败');
}
}else if($param['project_types']===2){
$ret = db('develop_issues')
->where('issue_id',$param['issue_id'])
->update(['issue_processor'=>$param['processor'],'issue_state' => 2]);
if($ret){
return $this->sendSuccess('分配成功');
}else{
return $this->sendError('分配失败');
}
}
}
}
public function GetOperationTaskList()
{
$param = request()->post();
$user = new User();
$user_id = $param['user_id'];
$story_id = $param['story_id'];
$user_info = db('system_user')->where('id', $user_id)->find();
if (1 == $user_info['user_role'])
{
$where = [];
if($param['task_state'] != ''){
$where['s.task_state'] = $param['task_state'];
}
$ret = db('work_task_info')->alias('s')
->join('work_story_info y', 'y.story_id =s.story_id', 'left')
->join('system_user u', 'u.id =s.task_processor', 'left')
->join('work_task_state p', 'p.id =s.task_state', 'left')
->where('y.story_type', 2)
->where('y.story_id', $story_id)
->where($where)
->field('s.*, p.desp as task_state_desp, y.story_id,2 as project_types')
->select();
$user = new User();
for ($i=0; $i<count($ret); $i++)
{
//根据登录账号获取用户姓名
$user_info = $user->GetUserInfoByLoginId($ret[$i]['task_processor']);
$ret[$i]['task_processor_name'] = $user_info['name'];
}
return $this->sendSuccess($ret);
}else{
$where = [];
if($param['task_state'] != ''){
$where['s.task_state'] = $param['task_state'];
}
$ret = db('work_task_info')->alias('s')
->join('work_story_info y', 'y.story_id =s.story_id', 'left')
->join('system_user u', 'u.id =s.task_processor', 'left')
->join('work_task_state p', 'p.id =s.task_state', 'left')
->where('y.story_type', 2)
->where('y.story_id', $story_id)
->where($where)
->where(function ($query) use ($user_id) {
$query->where('s.task_processor', $user_id)
->whereor('y.story_manager', $user_id);
})
->field('s.*, p.desp as task_state_desp, y.story_id,2 as project_types')
->select();
$user = new User();
for ($i=0; $i<count($ret); $i++)
{
//根据登录账号获取用户姓名
$user_info = $user->GetUserInfoByLoginId($ret[$i]['task_processor']);
$ret[$i]['task_processor_name'] = $user_info['name'];
}
return $this->sendSuccess($ret);
}
}
public function GetOperationStoryList()
{
$param = request()->post();
$user = new User();
$user_id = $param['user_id'];
$user_info = db('system_user')->where('id', $user_id)->find();
if (1 == $user_info['user_role'])
{
$where = [];
if(isset($param['story_state']) && $param['story_state'] != ''){
$where['s.story_state'] = $param['story_state'];
}
$ret = db('work_story_info')->alias('y')
->join('work_story_state p', 'p.id =y.story_state', 'left')
->where('y.story_type', 2)
->where('y.story_state', '<', 4) //未完成的Story
->where($where)
->field('y.*, p.desp as story_state_desp')
->select();
$user = new User();
for ($i=0; $i<count($ret); $i++)
{
//根据登录账号获取Story管理员用户姓名
$user_info = $user->GetUserInfoByLoginId($ret[$i]['story_manager']);
$ret[$i]['story_manager_name'] = $user_info['name'];
$ret[$i]['story_tasks'] = $this->GetOperationTaskCount($user_id,$ret[$i]['story_id']);
}
//dump($ret);
return $this->sendSuccess($ret);
}else{
$where = [];
if(isset($param['story_state']) && $param['story_state'] != ''){
$where['s.story_state'] = $param['story_state'];
}
$ret = db('work_story_info')->alias('y')
->join('work_story_state p', 'p.id =y.story_state', 'left')
->where('y.story_type', 2)
->where('y.story_state', '<', 4) //未完成的Story
->where($where)
->where(function ($query) use ($user_id) {
$query->where('y.story_manager', $user_id)
->whereor('y.story_member', 'like', $user_id . ',%')
->whereor('y.story_member', 'like', '%,' . $user_id . ',%')
->whereor('y.story_member', $user_id)
->whereor('y.story_member', 'like', '%,' . $user_id);
})
->field('y.*, p.desp as story_state_desp')
->select();
$user = new User();
for ($i=0; $i<count($ret); $i++)
{
//根据登录账号获取Story管理员用户姓名
$user_info = $user->GetUserInfoByLoginId($ret[$i]['story_manager']);
$ret[$i]['story_manager_name'] = $user_info['name'];
$ret[$i]['story_tasks'] = $this->GetOperationTaskCount($user_id,$ret[$i]['story_id']);
}
//dump($ret);
return $this->sendSuccess($ret);
}
}
public function GetOperationTaskCount($user_id,$story_id)
{
$param = request()->post();
$user = new User();
$user_info = db('system_user')->where('id', $user_id)->find();
if (1 == $user_info['user_role'])
{
$where = [];
if($param['task_state'] != ''){
$where['s.task_state'] = $param['task_state'];
}
$ret = db('work_task_info')->alias('s')
->join('work_story_info y', 'y.story_id =s.story_id', 'left')
->join('system_user u', 'u.id =s.task_processor', 'left')
->join('work_task_state p', 'p.id =s.task_state', 'left')
->where('y.story_type', 2)
->where('y.story_id', $story_id)
->where($where)
->count();
return $ret;
}else{
$where = [];
if($param['task_state'] != ''){
$where['s.task_state'] = $param['task_state'];
}
$ret = db('work_task_info')->alias('s')
->join('work_story_info y', 'y.story_id =s.story_id', 'left')
->join('system_user u', 'u.id =s.task_processor', 'left')
->join('work_task_state p', 'p.id =s.task_state', 'left')
->where('y.story_type', 2)
->where('y.story_id', $story_id)
->where($where)
->where(function ($query) use ($user_id) {
$query->where('s.task_processor', $user_id)
->whereor('y.story_manager', $user_id);
})
->count();
return $ret;
}
}
public function getEmployeeWorkStatistics()
{
$param = request()->post();
$timeRange = $param['timeRange'] ?? 'month';
$startDate = '';
$endDate = '';
if ($timeRange === 'week') {
$startDate = date('Y-m-d', strtotime('this week'));
$endDate = date('Y-m-d', strtotime('this week +6 days'));
} elseif ($timeRange === 'month') {
$startDate = date('Y-m-01');
$endDate = date('Y-m-t');
} elseif ($timeRange === 'year') {
$startDate = date('Y-01-01');
$endDate = date('Y-12-31');
}
$StaffList = db('system_user')->alias('u')
->join('hr_staff s', 's.staff_id = u.user_id', 'left')
->where('u.user_type', 1)
->field('u.id as staff_id, s.staff_name, s.staff_dept')
->select();
$user = new User();
$statistics = [];
foreach ($StaffList as $employee) {
$staffId = $employee['staff_id'];
$employeeName = $employee['staff_name'];
$staffDept = $employee['staff_dept'];
$totalTaskCount = 0;
$totalIssueCount = 0;
$onTimeCount = 0;
$overTimeCount = 0;
$project_work = $this->GetProjectListState($staffId, $startDate, $endDate);
foreach ($project_work as $work) {
$involve_manager = $work['involve_manager'];
$info = $user->GetUserInfoByLoginId($involve_manager);
if ($info && isset($info['name'])) {
$work['issue_creator_name'] = $info['name'];
}
if (isset($work['task_count'])) {
$totalTaskCount += $work['task_count']['task_count'];
}
if (isset($work['issue_count'])) {
$totalIssueCount += $work['issue_count']['issue_count'];
}
if (isset($work['issue_count'])) {
$onTimeCount += $work['issue_count']['on_count'] + $work['task_count']['on_count'];
}
if (isset($work['task_count'])) {
$overTimeCount += $work['task_count']['over_count'] + $work['task_count']['over_count'];
}
}
$deptIds = explode(',', $staffDept);
if (in_array(2, $deptIds)) {
$operationTaskCount = $this->GetOperationWorkTaskCount($staffId, $startDate, $endDate);
$totalTaskCount += $operationTaskCount['2Type_count'];
$onTimeCount += $operationTaskCount['on_count'];
$overTimeCount += $operationTaskCount['over_count'];
}
$statistics[] = [
'employeeName' => $employeeName,
'taskCount' => $totalTaskCount,
'issueCount' => $totalIssueCount,
'onTimeCount' => $onTimeCount,
'overTimeCount' => $overTimeCount,
];
}
return $this->sendSuccess($statistics);
}
public function GetProjectListState($user_id, $startDate, $endDate)
{
$ret = db('project_info')->alias('p')
->join('project_state s', 's.id =p.project_state', 'left')
->where(function ($query) use ($user_id) {
$query->where('p.involve_manager', $user_id)
->whereor('p.involve_members', 'like', $user_id . ',%')
->whereor('p.involve_members', 'like', '%,' . $user_id . ',%')
->whereor('p.involve_members', 'like', $user_id . '')
->whereor('p.involve_members', 'like', '%,' . $user_id);
})
// ->whereBetween('p.create_time', [$startDate, $endDate])
->field('p.*, s.desp as project_state_name,1 as project_types')
->select();
//统计每个项目与登录用户有关的任务数
for ($i = 0; $i < count($ret); $i++) {
$ret[$i]['issue_count'] = $this->GetProjectIssueCounts($user_id, $ret[$i]['project_id'], $startDate, $endDate);
$ret[$i]['task_count'] = $this->GetProjectTaskCounts($user_id, $ret[$i]['project_id'], $startDate, $endDate);
}
return $ret;
}
public function GetProjectIssueCounts($user_id, $project_id, $startDate, $endDate)
{
$count = db('project_issues')->alias('s')
->join('project_info i', 'i.project_id =s.project_id', 'left')
->join('project_issue_state t', 't.id =s.issue_state', 'left')
->where('s.project_id', $project_id)
->where(function ($query) use ($user_id) {
$query->where('s.issue_processor', $user_id)
->whereor('s.issue_creator', $user_id)
->whereor('i.involve_manager', $user_id);
})
->whereBetween('s.create_time', [$startDate, $endDate])
->count();
$OnCount = db('project_issues')->alias('s')
->join('project_info i', 'i.project_id =s.project_id', 'left')
->join('project_issue_state t', 't.id =s.issue_state', 'left')
->where('s.project_id', $project_id)
->where(function ($query) use ($user_id) {
$query->where('s.issue_processor', $user_id)
->whereor('s.issue_creator', $user_id)
->whereor('i.involve_manager', $user_id);
})
->whereBetween('s.create_time', [$startDate, $endDate])
->where('s.real_close_time','exp','<= s.plan_close_time')
->count();
$OverCount = db('project_issues')->alias('s')
->join('project_info i', 'i.project_id = s.project_id', 'left')
->join('project_issue_state t', 't.id = s.issue_state', 'left')
->where('s.project_id', $project_id)
->where(function ($query) use ($user_id) {
$query->where('s.issue_processor', $user_id)
->whereor('s.issue_creator', $user_id)
->whereor('i.involve_manager', $user_id);
})
->whereBetween('s.create_time', [$startDate, $endDate])
->where('s.real_close_time','exp','> s.plan_close_time')
->count();
$ret = [];
$ret['issue_count'] = $count;
$ret['on_count'] = $OnCount;
$ret['over_count'] = $OverCount;
return $ret;
}
public function GetProjectTaskCounts($user_id, $project_id, $startDate, $endDate)
{
$count = db('work_task_info')->alias('s')
->join('work_story_info x', 'x.story_id =s.story_id', 'left')
->join('project_info i', 'i.project_id =x.work_id', 'left')
->join('work_task_state t', 't.id =s.task_state', 'left')
->where('x.work_id', $project_id)
->where(function ($query) use ($user_id) {
$query->where('s.task_processor', $user_id)
->whereor('x.story_manager', $user_id);
})
->whereBetween('s.create_time', [$startDate, $endDate])
->count();
$OnCount = db('work_task_info')->alias('s')
->join('work_story_info x', 'x.story_id =s.story_id', 'left')
->join('project_info i', 'i.project_id =x.work_id', 'left')
->join('work_task_state t', 't.id =s.task_state', 'left')
->where('x.work_id', $project_id)
->where(function ($query) use ($user_id) {
$query->where('s.task_processor', $user_id)
->whereor('x.story_manager', $user_id);
})
->whereBetween('s.create_time', [$startDate, $endDate])
->where('s.real_close_time','exp','<= s.plan_close_time')
->count();
$OverCount = db('work_task_info')->alias('s')
->join('work_story_info x', 'x.story_id =s.story_id', 'left')
->join('project_info i', 'i.project_id =x.work_id', 'left')
->join('work_task_state t', 't.id =s.task_state', 'left')
->where('x.work_id', $project_id)
->where(function ($query) use ($user_id) {
$query->where('s.task_processor', $user_id)
->whereor('x.story_manager', $user_id);
})
->whereBetween('s.create_time', [$startDate, $endDate])
->where('s.real_close_time','exp','> s.plan_close_time')
->count();
$ret = [];
$ret['task_count'] = $count;
$ret['on_count'] = $OnCount;
$ret['over_count'] = $OverCount;
return $ret;
}
public function GetOperationWorkTaskCount($user_id, $startDate, $endDate)
{
$count = db('work_task_info')
->where('task_processor', $user_id)
->whereBetween('create_time', [$startDate, $endDate])
->count();
$On_Count = db('work_task_info')
->where('task_processor', $user_id)
->whereBetween('create_time', [$startDate, $endDate])
->where('real_close_time','exp','<= plan_close_time')
->count();
$Over_count = db('work_task_info')
->where('task_processor', $user_id)
->whereBetween('create_time', [$startDate, $endDate])
->where('real_close_time','exp','> plan_close_time')
->count();
$ret = [];
$ret['2Type_count'] = $count;
$ret['on_count'] = $On_Count;
$ret['over_count'] = $Over_count;
return $ret;
}
}