2026-03-10 18:45:36 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
|
|
|
|
use DateTime;
|
|
|
|
|
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 Project extends Common
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//获取资产类型列表
|
|
|
|
|
public function GetProjectList()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
$query = [];
|
|
|
|
|
|
|
|
|
|
if (false == isset($param['type']))
|
|
|
|
|
{
|
|
|
|
|
$query['project_type'] = 1;
|
|
|
|
|
if ($param['state'] == 1)
|
|
|
|
|
{
|
|
|
|
|
$query['project_state'] = 1;
|
|
|
|
|
}
|
|
|
|
|
else if ($param['state'] == 2)
|
|
|
|
|
{
|
|
|
|
|
$query['project_state'] = array(array('>', 1), array('<', 9));
|
|
|
|
|
}
|
|
|
|
|
else if ($param['state'] == 3)
|
|
|
|
|
{
|
|
|
|
|
$query['project_state'] = 9;
|
|
|
|
|
}
|
|
|
|
|
else if ($param['state'] == 4)
|
|
|
|
|
{
|
|
|
|
|
$query['project_state'] = 10;
|
|
|
|
|
}
|
|
|
|
|
else if ($param['state'] ==''){
|
|
|
|
|
$query['project_state'] = array(array('>', 0), array('<', 10));
|
|
|
|
|
unset($query['project_type']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$query['project_type'] = $param['type'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ret = db('project_info')->where($query)->select();
|
|
|
|
|
|
|
|
|
|
return $this->sendSuccess($ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据资产类型获取资产列表
|
|
|
|
|
public function GetProjectInfoList()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
$ProjectInfoList = db('project_info')->alias('i')
|
|
|
|
|
->where('i.project_type', $param['type'])
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
return $this->sendSuccess($ProjectInfoList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//添加合同类型
|
|
|
|
|
public function AddProjectType()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
$insert = [];
|
|
|
|
|
$insert['type_name'] = $param['type_name'];
|
|
|
|
|
$insert['super_type_id'] = $param['super_type_id'];
|
|
|
|
|
$insert['create_time'] = date('Y-m-d H:i:s');
|
|
|
|
|
db('project_type')->insert($insert);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function GetCutomerMemberInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
$MemberInfo = db('project_info')->alias('i')
|
|
|
|
|
->join('customer_info c', 'c.customer_id =i.customer_id', 'left')
|
|
|
|
|
->join('customer_visitor v', 'v.visitorid =i.c.customer_id', 'left')
|
|
|
|
|
->where('i.project_id', $param['project_id'])
|
|
|
|
|
->field('v.*')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->sendSuccess($MemberInfo);
|
|
|
|
|
//$param['project_id']
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*public function AddProjectInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
$ret = db('project_type')->where('type_id', $param['project_type'])->field('type_id,super_type_id')->find();
|
|
|
|
|
if ($ret != null) {
|
|
|
|
|
$insert_info = [];
|
|
|
|
|
$insert_info['project_number'] = $param['project_number'];
|
|
|
|
|
$insert_info['project_name'] = $param['project_name'];
|
|
|
|
|
$insert_info['create_time'] = $param['create_time'];
|
|
|
|
|
$insert_info['project_price'] = $param['project_price'];
|
|
|
|
|
$insert_info['project_type'] = $param['project_type']; //合同父类型ID
|
|
|
|
|
$insert_info['project_category']= $param['project_category'];
|
|
|
|
|
if($param['project_url'] == ''){
|
|
|
|
|
$insert_info['project_url'] = '';
|
|
|
|
|
}else{
|
|
|
|
|
$insert_info['project_url'] = $param['project_url'];
|
|
|
|
|
}
|
|
|
|
|
db('project_info')->insert($insert_info);
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
public function AddProjectInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
$insert_info = [];
|
|
|
|
|
$insert_info['project_number'] = $param['project_number'];
|
|
|
|
|
$insert_info['project_name'] = $param['project_name'];
|
|
|
|
|
$insert_info['create_time'] = $param['create_time'];
|
|
|
|
|
$insert_info['customer_id'] = $param['customer_id'];
|
|
|
|
|
$insert_info['project_intro'] = $param['project_intro'];
|
|
|
|
|
$insert_info['project_state'] = $param['project_state'];
|
|
|
|
|
db('project_info')->insert($insert_info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function EditProjectInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param != null){
|
|
|
|
|
$update = [];
|
|
|
|
|
$update['project_number'] = $param['project_number'];
|
|
|
|
|
$update['project_name'] = $param['project_name'];
|
|
|
|
|
$update['create_time'] = $param['create_time'];
|
|
|
|
|
$update['project_intro'] = $param['project_intro'];
|
|
|
|
|
$update['project_state'] = $param['project_state'];
|
|
|
|
|
$ret = db('project_info')->where('project_id',$param['project_id'])->update($update);
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('修改成功');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('修改失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function GetProjectInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
$ProjectInfo = db('project_info')->alias('i')
|
|
|
|
|
->join('partner_company c', 'c.company_id =i.customer_id', 'left')
|
|
|
|
|
->join('project_state s', 's.id =i.project_state', 'left')
|
|
|
|
|
->where('i.project_id', $param['project_id'])
|
|
|
|
|
->field('i.*, c.company_name as company_name, s.desp as project_state_desp ')
|
|
|
|
|
->find();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$members = explode(',', $ProjectInfo['involve_members']);
|
|
|
|
|
$ProjectInfo['project_members']='';
|
|
|
|
|
|
|
|
|
|
if (count($members)>0)
|
|
|
|
|
{
|
|
|
|
|
$ret = db('system_user')->alias('u')
|
|
|
|
|
->join('hr_staff s','s.staff_id=u.user_id', 'left')
|
|
|
|
|
->where('u.user_type', 1)
|
|
|
|
|
->where('u.id', 'in', $members)
|
|
|
|
|
->column('s.staff_name');
|
|
|
|
|
|
|
|
|
|
$ProjectInfo['project_members'] = implode(',', $ret); //数组转字符串
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ProjectInfo['project_manager'] = '';
|
|
|
|
|
|
|
|
|
|
$ret = db('system_user')->alias('u')
|
|
|
|
|
->join('hr_staff s','s.staff_id=u.user_id', 'left')
|
|
|
|
|
->where('u.user_type', 1)
|
|
|
|
|
->where('u.id', $ProjectInfo['involve_manager'])
|
|
|
|
|
->find();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (null != $ret)
|
|
|
|
|
{
|
|
|
|
|
$ProjectInfo['project_manager'] = $ret['staff_name'];
|
|
|
|
|
}
|
2026-03-18 14:02:51 +08:00
|
|
|
$ProjectInfo['sale_name'] = '';
|
|
|
|
|
if (!empty($ProjectInfo['sale_manager'])){
|
|
|
|
|
$retSale = db('system_user')->alias('u')
|
|
|
|
|
->join('hr_staff s','s.staff_id=u.user_id', 'left')
|
|
|
|
|
->where('u.user_type', 1)
|
|
|
|
|
->where('u.id', $ProjectInfo['sale_manager'])
|
|
|
|
|
->find();
|
|
|
|
|
if (null != $retSale)
|
|
|
|
|
{
|
|
|
|
|
$ProjectInfo['sale_name'] = $retSale['staff_name'];
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-10 18:45:36 +08:00
|
|
|
return $this->sendSuccess($ProjectInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function GetProjectStateList()
|
|
|
|
|
{
|
|
|
|
|
$Ret = db('project_state')->select();
|
|
|
|
|
return $this->sendSuccess($Ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function updateProjectInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param != null){
|
|
|
|
|
$update = [];
|
|
|
|
|
$update['project_name'] = $param['project_name'];
|
|
|
|
|
$update['project_category'] = $param['project_category'];
|
|
|
|
|
$update['project_number'] = $param['project_number'];
|
|
|
|
|
if($param['project_url'] != '')
|
|
|
|
|
{
|
|
|
|
|
$update['project_url'] = $param['project_url'];
|
|
|
|
|
}
|
|
|
|
|
$update['project_price'] = $param['project_price'];
|
|
|
|
|
$update['create_time'] = $param['create_time'];
|
|
|
|
|
$ret = db('project_info')->where('project_id',$param['project_id'])->update($update);
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('修改成功');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('修改失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function StartProject()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param != null){
|
|
|
|
|
$update = [];
|
|
|
|
|
$update['involve_members'] = implode(',', $param['members']); //数组转字符串
|
|
|
|
|
//$update['involve_manager'] = $param['manager'];
|
|
|
|
|
$update['project_state'] = 2;
|
|
|
|
|
//$update['tech_protocol'] = $param['tech_protocol'];
|
|
|
|
|
|
|
|
|
|
//$update['create_time'] = $param['create_time'];
|
|
|
|
|
$ret = db('project_info')->where('project_id',$param['project_id'])->update($update);
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('启动成功');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('启动失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function RemoveProjectMember()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
$project_id = $param['project_id'];
|
|
|
|
|
$remove_member = $param['staff_id'].'';
|
2026-03-18 14:02:51 +08:00
|
|
|
|
|
|
|
|
|
2026-03-10 18:45:36 +08:00
|
|
|
$ret = db('project_info')->where('project_id', $project_id)->find();
|
|
|
|
|
$member_arr = explode(',', $ret['involve_members']);
|
2026-03-18 14:02:51 +08:00
|
|
|
|
2026-03-10 18:45:36 +08:00
|
|
|
// 使用array_filter()函数删除指定值
|
|
|
|
|
$resultArray = array_filter($member_arr, function ($value) use ($remove_member) {
|
|
|
|
|
return $value !== $remove_member;
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-18 14:02:51 +08:00
|
|
|
|
|
|
|
|
$update['involve_members'] = implode(',', $resultArray);
|
2026-03-10 18:45:36 +08:00
|
|
|
$ret = db('project_info')->where('project_id',$project_id)->update($update);
|
2026-03-18 14:02:51 +08:00
|
|
|
|
2026-03-10 18:45:36 +08:00
|
|
|
return $this->sendSuccess('移除成功');
|
|
|
|
|
}
|
2026-03-18 14:02:51 +08:00
|
|
|
|
|
|
|
|
|
2026-03-10 18:45:36 +08:00
|
|
|
public function UpdateProjectMember()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
2026-03-18 14:02:51 +08:00
|
|
|
|
2026-03-10 18:45:36 +08:00
|
|
|
$update['involve_members'] = implode(',', $param['involve_members']); //数组转字符串
|
|
|
|
|
$ret = db('project_info')->where('project_id',$param['project_id'])->update($update);
|
|
|
|
|
return $this->sendSuccess('更新成功');
|
|
|
|
|
}
|
2026-03-18 14:02:51 +08:00
|
|
|
public function UpdateSaleManager()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
$update['sale_manager'] = $param['sale_manager']; //数组转字符串
|
|
|
|
|
$ret = db('project_info')->where('project_id',$param['project_id'])->update($update);
|
|
|
|
|
return $this->sendSuccess('更新成功');
|
|
|
|
|
}
|
2026-03-10 18:45:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function UpdateProjectManager()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
$update['involve_manager'] = $param['involve_manager']; //数组转字符串
|
|
|
|
|
$ret = db('project_info')->where('project_id',$param['project_id'])->update($update);
|
|
|
|
|
return $this->sendSuccess('更新成功');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//添加项目外部成员
|
|
|
|
|
public function AddProjectExternalMember()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
$insert = [];
|
|
|
|
|
$insert['project_id'] = $param['project_id'];
|
|
|
|
|
//$insert['contacts_type'] = $param['contacts_type'];
|
|
|
|
|
$insert['contacts_customer'] = $param['contacts_customer'];
|
|
|
|
|
$insert['contacts_id'] = $param['contacts_id'];
|
|
|
|
|
db('project_contacts')->insert($insert);
|
|
|
|
|
|
|
|
|
|
return $this->sendSuccess('添加成功');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取项目外部成员
|
|
|
|
|
public function GetProjectExternalMember()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
$ret = db('project_contacts')->where('project_id', $param['project_id'])->column('contacts_id');
|
|
|
|
|
|
|
|
|
|
$member = db('partner_contacts')->alias('i')
|
|
|
|
|
->join('partner_company c', 'c.company_id =i.company_id', 'left')
|
|
|
|
|
->where('i.contacts_id', 'in', $ret)
|
|
|
|
|
->field('i.contacts_name, i.contacts_idcard, i.contacts_phone, i.contacts_position, c.company_name as company_name')
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
return $this->sendSuccess($member);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//添加项目资料
|
|
|
|
|
public function AddProjectMaterialsInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
$insert_info = [];
|
|
|
|
|
$insert_info['project_id'] = $param['project_id'];
|
|
|
|
|
$insert_info['materials_intro'] = $param['materials_intro'];
|
|
|
|
|
$insert_info['materials_url'] = $param['materials_url'];
|
|
|
|
|
$insert_info['create_time'] = $param['create_time'];
|
|
|
|
|
$insert_info['materials_type'] = $param['materials_type'];
|
|
|
|
|
db('materials_info')->insert($insert_info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//编辑项目资料
|
|
|
|
|
public function EditProjectMaterialsInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param != null){
|
|
|
|
|
$update = [];
|
|
|
|
|
$update['materials_intro'] = $param['materials_intro'];
|
|
|
|
|
if ($param['materials_url'] != '')
|
|
|
|
|
{
|
|
|
|
|
$update['materials_url'] = $param['materials_url'];
|
|
|
|
|
}
|
|
|
|
|
$update['materials_type'] = $param['materials_type'];
|
|
|
|
|
$update['create_time'] = $param['create_time'];
|
|
|
|
|
$update['materials_file_name'] = $param['materials_file_name'];
|
|
|
|
|
$ret = db('materials_info')->where('materials_id',$param['materials_id'])->update($update);
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('修改成功');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('修改失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//添加项目资料
|
|
|
|
|
public function GetProjectMaterialsList()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
if ( $param['materials_type'] > 1)
|
|
|
|
|
{
|
|
|
|
|
$param['issue_id'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$MaterialsInfoList = db('materials_info')->where('project_id', $param['project_id'])
|
|
|
|
|
->where('issue_id', $param['issue_id'])
|
|
|
|
|
->where('materials_type', $param['materials_type'])
|
|
|
|
|
->order('create_time desc')
|
|
|
|
|
->select();
|
|
|
|
|
return $this->sendSuccess($MaterialsInfoList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function DelProMaterialsInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param){
|
|
|
|
|
$ret = db('materials_info')->where('materials_id', $param['materials_id'])->delete();
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('删除成功!');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('删除失败!');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetIssueTypeList()
|
|
|
|
|
{
|
|
|
|
|
$ret = db('project_issue_state')->select();
|
|
|
|
|
return $this->sendSuccess($ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function CreateIssueInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
$insert_info = [];
|
|
|
|
|
$insert_info['project_id'] = $param['project_id'];
|
|
|
|
|
$insert_info['issue_desp'] = $param['issue_desp'];
|
|
|
|
|
$insert_info['issue_level'] = $param['issue_level'];
|
|
|
|
|
$insert_info['issue_creator'] = $param['issue_creator'];
|
|
|
|
|
$insert_info['issue_processor'] = $param['issue_processor'];
|
|
|
|
|
$insert_info['create_time'] = date('Y-m-d H:i:s');
|
|
|
|
|
$insert_info['plan_close_time'] = $param['plan_close_time'];
|
|
|
|
|
|
|
|
|
|
$issue_id = db('project_issues')->insertGetId($insert_info);
|
|
|
|
|
$log_file_array = [];
|
|
|
|
|
$logfile = $param['issue_log'];
|
|
|
|
|
for ($i=0; $i<count($logfile); $i++)
|
|
|
|
|
{
|
|
|
|
|
$insert_info = [];
|
|
|
|
|
$insert_info['materials_owner'] = $issue_id;
|
|
|
|
|
$insert_info['materials_class'] = 2;
|
|
|
|
|
$insert_info['materials_intro'] = '问题日志文件';
|
|
|
|
|
$insert_info['materials_url'] = $logfile[$i]['url'];
|
|
|
|
|
$insert_info['create_time'] = date('Y-m-d H:i:s');
|
|
|
|
|
$insert_info['materials_type'] = 1; //问题日志文件
|
|
|
|
|
$id = db('materials_info')->insertGetId($insert_info);
|
|
|
|
|
$log_file_array[] = $id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//日志文件先插入资料表
|
|
|
|
|
$update_info = [];
|
|
|
|
|
$update_info['issue_log'] = implode(',', $log_file_array);
|
|
|
|
|
db('project_issues')->where('issue_id', $issue_id)->update($update_info);
|
|
|
|
|
return $this->sendSuccess("创建成功");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function CreateProjectMaterialsInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param){
|
|
|
|
|
$insert_info = [];
|
|
|
|
|
$insert_info['materials_class'] = 2;
|
|
|
|
|
$insert_info['materials_owner'] = $param['issue_id'];
|
|
|
|
|
$insert_info['materials_intro'] = $param['materials_intro'];
|
|
|
|
|
$insert_info['materials_url'] = $param['material_url'];
|
|
|
|
|
$insert_info['create_time'] = date('Y-m-d H:i:s');
|
|
|
|
|
$insert_info['materials_type'] = 1; //问题日志文件
|
|
|
|
|
$insert_info['materials_file_name'] = $param['materials_file_name'];
|
|
|
|
|
$id = db('materials_info')->insertGetId($insert_info);
|
|
|
|
|
$log_file_array[] = $id;
|
|
|
|
|
|
|
|
|
|
$originalIssueLog = db('project_issues')->where('issue_id', $param['issue_id'])->value('issue_log');
|
|
|
|
|
|
|
|
|
|
if (empty($originalIssueLog)) {
|
|
|
|
|
$newIssueLog = implode(',', $log_file_array);
|
|
|
|
|
} else {
|
|
|
|
|
$newIssueLog = $originalIssueLog . ',' . implode(',', $log_file_array);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$update_info = [];
|
|
|
|
|
$update_info['issue_log'] = $newIssueLog;
|
|
|
|
|
$ret = db('project_issues')->where('issue_id', $param['issue_id'])->update($update_info);
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess("创建成功");
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('',"创建失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->sendError("创建失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetProjectIssueList()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
$user = new User();
|
|
|
|
|
$where = [];
|
|
|
|
|
$where['i.project_id'] = $param['project_id'];
|
|
|
|
|
if (isset($param['issue_state']))
|
|
|
|
|
{
|
|
|
|
|
if (1 == $param['issue_state']) //小于10的为未解决
|
|
|
|
|
{
|
|
|
|
|
$where['i.issue_state'] = array('<', 10);
|
|
|
|
|
}
|
|
|
|
|
else if (2 == $param['issue_state']) //大于等于10的为已关闭
|
|
|
|
|
{
|
|
|
|
|
$where['i.issue_state'] = array('>=', 10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$staff_list = db('hr_staff')->select();
|
|
|
|
|
$ret = db('project_issues')->alias('i')
|
|
|
|
|
->join('project_issue_state s', 's.id =i.issue_state', 'left')
|
|
|
|
|
->where($where)
|
|
|
|
|
->field('i.*, s.desp as issue_state_name')
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
for ($i=0; $i<count($ret); $i++)
|
|
|
|
|
{
|
|
|
|
|
for ($j=0; $j<count($staff_list); $j++)
|
|
|
|
|
{
|
|
|
|
|
$create_user = $user->GetUserInfoByLoginId($ret[$i]['issue_creator']);
|
|
|
|
|
if ($create_user != null)
|
|
|
|
|
{
|
|
|
|
|
$ret[$i]['issue_creator'] = $create_user['id'];
|
|
|
|
|
$ret[$i]['issue_creator_name'] = $create_user['name'];
|
|
|
|
|
}else{
|
|
|
|
|
$ret[$i]['issue_creator_name'] = '未分配';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$processor_user = $user->GetUserInfoByLoginId($ret[$i]['issue_processor']);
|
|
|
|
|
if ($processor_user != null)
|
|
|
|
|
{
|
|
|
|
|
$ret[$i]['issue_processor'] = $processor_user['id'];
|
|
|
|
|
$ret[$i]['issue_processor_name'] = $processor_user['name'];
|
|
|
|
|
}else{
|
|
|
|
|
$ret[$i]['issue_processor_name'] = '未分配';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->sendSuccess($ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetIssueListByStaff()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
$user = new User();
|
|
|
|
|
$currPage = empty($param['currPage']) ? 1 : $param['currPage'];
|
|
|
|
|
$pageSize = empty($param['pageSize']) ? 10 : $param['pageSize'];
|
|
|
|
|
$project_issues = db('project_issues')->alias('pi')
|
|
|
|
|
->join('project_issue_state ps', 'ps.id = pi.issue_state')
|
|
|
|
|
->where('pi.issue_creator', $param['issue_creator'])
|
|
|
|
|
->field('pi.* ,ps.desp, 1 as project_types')
|
|
|
|
|
->page($currPage, $pageSize)
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$count = db('project_issues')->alias('pi')
|
|
|
|
|
->join('project_issue_state ps', 'ps.id = pi.issue_state')
|
|
|
|
|
->where('pi.issue_creator', $param['issue_creator'])
|
|
|
|
|
->field('pi.* ,ps.desp, 1 as project_types')
|
|
|
|
|
->count();
|
|
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($project_issues); $i++) {
|
|
|
|
|
$processorInfo = $user->GetUserInfoByLoginId($project_issues[$i]['issue_processor']);
|
|
|
|
|
if ($processorInfo !== null && isset($processorInfo['name'])) {
|
|
|
|
|
$project_issues[$i]['issue_processor_name'] = $processorInfo['name'];
|
|
|
|
|
} else {
|
|
|
|
|
$project_issues[$i]['issue_processor_name'] = '未分配';
|
|
|
|
|
}
|
|
|
|
|
$creatorInfo = $user->GetUserInfoByLoginId($project_issues[$i]['issue_creator']);
|
|
|
|
|
if ($creatorInfo !== null && isset($creatorInfo['name'])) {
|
|
|
|
|
$project_issues[$i]['issue_creator_name'] = $creatorInfo['name'];
|
|
|
|
|
} else {
|
|
|
|
|
$project_issues[$i]['issue_creator_name'] = '未分配';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ret = [];
|
|
|
|
|
$ret['data'] = $project_issues;
|
|
|
|
|
$ret['total'] = $count;
|
|
|
|
|
return $this->sendSuccess($ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function GetHomeMyProjectInfo()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
$ret = Db::query('SELECT * FROM wdq_project_info WHERE FIND_IN_SET(:involve_members, involve_members) OR involve_manager = :involve_manager', [
|
|
|
|
|
'involve_manager' => $param['involve_manager'],
|
|
|
|
|
'involve_members' => $param['involve_manager']
|
|
|
|
|
]);
|
|
|
|
|
return $this->sendSuccess($ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetProjectMember()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
$project_id = $param['project_id'];
|
|
|
|
|
|
|
|
|
|
//获取内部用户(姓名)
|
|
|
|
|
$project = db('project_info')->where('project_id', $project_id)
|
|
|
|
|
->find();
|
|
|
|
|
|
|
|
|
|
$staffs = explode(',', $project['involve_members']);
|
|
|
|
|
|
|
|
|
|
$member_inner = db('system_user')->alias('u')
|
|
|
|
|
->join('hr_staff s', 'u.user_id=s.staff_id', 'left')
|
|
|
|
|
->where('u.id', 'in', $staffs)
|
|
|
|
|
->field('s.staff_name as name, u.id as id')
|
|
|
|
|
->select();
|
|
|
|
|
//获取外部用户
|
|
|
|
|
$member_outer = db('system_user')->alias('u')
|
|
|
|
|
->join('partner_contacts c', 'u.user_id=c.contacts_id', 'left')
|
|
|
|
|
->where(function ($query) use ($project_id) {
|
|
|
|
|
$query->where('u.user_project', $project_id)
|
|
|
|
|
->whereor('u.user_project', 'like', $project_id . ',%')
|
|
|
|
|
->whereor('u.user_project', 'like', '%,' . $project_id . ',%')
|
|
|
|
|
->whereor('u.user_project', 'like', '%,' . $project_id);
|
|
|
|
|
})
|
|
|
|
|
->field('c.contacts_name as name, u.id as id')
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$members = array_merge($member_inner, $member_outer);
|
|
|
|
|
|
|
|
|
|
return $this->sendSuccess($members);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetProjectGoodsList()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if ($param) {
|
|
|
|
|
$projectGoods = db('project_goods')
|
|
|
|
|
->where('project_id', $param['project_id'])
|
|
|
|
|
->where('goods_state', $param['goods_state'])
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
foreach ($projectGoods as &$projectGood) {
|
|
|
|
|
$ret_name = db('system_user')->alias('u')
|
|
|
|
|
->join('hr_staff s','s.staff_id=u.user_id', 'left')
|
|
|
|
|
->where('u.id', $projectGood['staff_id'])
|
|
|
|
|
->value('s.staff_name');
|
|
|
|
|
$projectGood['goods_staff_name'] = $ret_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$members = explode(',', $projectGood['processor_id']);
|
|
|
|
|
if (count($members) > 0) {
|
|
|
|
|
$ret = db('hr_staff')
|
|
|
|
|
->whereIn('staff_id', $members)
|
|
|
|
|
->column('staff_name');
|
|
|
|
|
$projectGood['goods_processor_name'] = implode(',', $ret);
|
|
|
|
|
} else {
|
|
|
|
|
$projectGood['goods_processor_name'] = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->sendSuccess($projectGoods);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function AddProjectGoods()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param){
|
|
|
|
|
$insert = [];
|
|
|
|
|
$insert['project_id'] = $param['project_id'];
|
|
|
|
|
$insert['staff_id'] = $param['staff_id'];
|
|
|
|
|
$insert['processor_id'] = implode(',', $param['processor_id']);
|
|
|
|
|
$insert['goods_number'] = $param['goods_number'];
|
|
|
|
|
$insert['goods_name'] = $param['goods_name'];
|
|
|
|
|
$insert['goods_num'] = $param['goods_num'];
|
|
|
|
|
$insert['goods_price'] = $param['goods_price'];
|
|
|
|
|
$insert['create_time'] = date('Y-m-d H:i:s');
|
|
|
|
|
$ret = db('project_goods')->insert($insert);
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('添加成功');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('400','添加失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function UpdateProjectGoods()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param){
|
|
|
|
|
$param['processor_id'] = implode(',', $param['processor_id']);
|
|
|
|
|
$ret = db('project_goods')->where('goods_id',$param['goods_id'])->update($param);
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('修改成功');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('400','修改失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function UpdateTaskProcessor()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param){
|
|
|
|
|
$ret = db('work_task_info')->where('task_id', $param['task_id'])->update($param);
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('修改成功');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('400','修改失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function DelTask()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param){
|
|
|
|
|
$ret = db('work_task_info')->where('task_id', $param['task_id'])->delete();
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('删除成功');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('400','删除失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function UpdateProjectIssues()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param){
|
|
|
|
|
$ret = db('project_issues')->where('issue_id', $param['issue_id'])->update($param);
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('修改成功');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('400','修改失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function DelProjectIssues()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param){
|
|
|
|
|
$ret = db('project_issues')->where('issue_id', $param['issue_id'])->delete();
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('删除成功');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('400','删除失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function HandleIssue()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if($param){
|
|
|
|
|
if($param['project_types'] === 1){
|
|
|
|
|
$update = [];
|
|
|
|
|
if($param['issue_state'] === 11){
|
|
|
|
|
$issues_info = db('project_issues')->where('issue_id',$param['issue_id'])->find();
|
|
|
|
|
if($issues_info){
|
|
|
|
|
//$createTime = $issues_info['create_time'];
|
|
|
|
|
//$createTimestamp = strtotime($createTime);
|
|
|
|
|
//$currentTimestamp = time();
|
|
|
|
|
//$timeDifference = $currentTimestamp - $createTimestamp;
|
|
|
|
|
$update['real_close_time'] = date('Y-m-d H:i:s');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if($param['issue_state'] === 9){
|
|
|
|
|
$issues_info = db('project_issues')->where('issue_id',$param['issue_id'])->find();
|
|
|
|
|
if($issues_info){
|
|
|
|
|
$update['issue_processor'] = $issues_info['issue_creator'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$update['issue_id'] = $param['issue_id'];
|
|
|
|
|
$update['issue_state'] = $param['issue_state'];
|
|
|
|
|
$ret = db('project_issues')->where('issue_id',$param['issue_id'])->update($update);
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess("修改成功");
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('',"修改失败");
|
|
|
|
|
}
|
|
|
|
|
}else if ($param['project_types'] === 2){
|
|
|
|
|
$update = [];
|
|
|
|
|
$update['issue_id'] = $param['issue_id'];
|
|
|
|
|
$update['issue_state'] = $param['issue_state'];
|
|
|
|
|
$ret = db('develop_issues')->where('issue_id',$param['issue_id'])->update($update);
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess("修改成功");
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('',"修改失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->sendError('',"失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetProjectPlan()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if (isset($param['project_id'])) {
|
|
|
|
|
$projectId = $param['project_id'];
|
|
|
|
|
// 关联查询
|
|
|
|
|
$ret = Db::name('project_plan')->alias('pp')
|
|
|
|
|
->join('project_phase ppd', 'pp.project_phase = ppd.id')
|
|
|
|
|
->where('pp.project_id', $projectId)
|
|
|
|
|
->field('pp.*, ppd.desp as phase_name')
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
$projectPhases = [];
|
|
|
|
|
foreach ($ret as $row) {
|
|
|
|
|
$phase = [
|
|
|
|
|
'id' => $row['id'],
|
|
|
|
|
'phaseName' => $row['phase_name'],
|
|
|
|
|
'progress' => $row['project_rate'],
|
|
|
|
|
'plannedDateRange' => [
|
|
|
|
|
date('m-d', strtotime($row['phase_plan_start_time'])),
|
|
|
|
|
date('m-d', strtotime($row['phase_plan_close_time']))
|
|
|
|
|
],
|
|
|
|
|
'actualDateRange' => [
|
|
|
|
|
date('m-d', strtotime($row['phase_real_start_time'])),
|
|
|
|
|
date('m-d', strtotime($row['phase_real_close_time']))
|
|
|
|
|
],
|
|
|
|
|
'markedDays' => [
|
|
|
|
|
'planned' => json_decode($row['planned_marked_days'], true) ?: [],
|
|
|
|
|
'actual' => json_decode($row['actual_marked_days'], true) ?: []
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
$projectPhases[] = $phase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->sendSuccess($projectPhases);
|
|
|
|
|
}
|
|
|
|
|
return $this->sendError('缺少 project_id 参数');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function UpdateProjectPhase()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
|
|
|
|
|
if (!isset($param['id'])) {
|
|
|
|
|
return $this->sendError('缺少 id 参数');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$phaseId = $param['id'];
|
|
|
|
|
|
|
|
|
|
// 处理勾选状态数据
|
|
|
|
|
$plannedMarkedDays = isset($param['markedDays']['planned']) ? json_encode($param['markedDays']['planned']) : null;
|
|
|
|
|
$actualMarkedDays = isset($param['markedDays']['actual']) ? json_encode($param['markedDays']['actual']) : null;
|
|
|
|
|
|
|
|
|
|
$updateData = [
|
|
|
|
|
'project_rate' => $param['progress'] ?? 0,
|
|
|
|
|
'phase_plan_start_time' => $this->convertDateRangeToDateTime($param['plannedDateRange'][0] ?? null),
|
|
|
|
|
'phase_plan_close_time' => $this->convertDateRangeToDateTime($param['plannedDateRange'][1] ?? null),
|
|
|
|
|
'phase_real_start_time' => $this->convertDateRangeToDateTime($param['actualDateRange'][0] ?? null),
|
|
|
|
|
'phase_real_close_time' => $this->convertDateRangeToDateTime($param['actualDateRange'][1] ?? null),
|
|
|
|
|
'planned_marked_days' => $plannedMarkedDays,
|
|
|
|
|
'actual_marked_days' => $actualMarkedDays
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$result = Db::name('project_plan')->where('id', $phaseId)->update($updateData);
|
|
|
|
|
|
|
|
|
|
if ($result !== false) {
|
|
|
|
|
return $this->sendSuccess('项目阶段信息更新成功');
|
|
|
|
|
} else {
|
|
|
|
|
return $this->sendError('', '项目阶段信息更新失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function convertDateRangeToDateTime($dateStr)
|
|
|
|
|
{
|
|
|
|
|
if ($dateStr) {
|
|
|
|
|
$date = DateTime::createFromFormat('m-d', $dateStr);
|
|
|
|
|
return $date? $date->format('Y-m-d') : null;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetProjectPhase()
|
|
|
|
|
{
|
|
|
|
|
$ret = db('project_phase')->select();
|
|
|
|
|
return $this->sendSuccess($ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function CreateProjectPlan()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if ($param) {
|
|
|
|
|
$project_phase = explode(',', $param['project_phase']);
|
|
|
|
|
$project_id = $param['project_id'];
|
|
|
|
|
|
|
|
|
|
foreach ($project_phase as $phase) {
|
|
|
|
|
$insert = [
|
|
|
|
|
'project_id' => $project_id,
|
|
|
|
|
'project_phase' => $phase,
|
|
|
|
|
'phase_plan_start_time' => date('Y-m-d'),
|
|
|
|
|
'phase_plan_close_time' => date('Y-m-d'),
|
|
|
|
|
'phase_real_start_time' => date('Y-m-d'),
|
|
|
|
|
'phase_real_close_time' => date('Y-m-d')
|
|
|
|
|
];
|
|
|
|
|
$ret = db('project_plan')->insert($insert);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($ret){
|
|
|
|
|
return $this->sendSuccess('成功');
|
|
|
|
|
}else{
|
|
|
|
|
return $this->sendError('','失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->sendError('','失败');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function DeleteProjectPhase()
|
|
|
|
|
{
|
|
|
|
|
$param = request()->post();
|
|
|
|
|
if (isset($param['ids'])) {
|
|
|
|
|
$ids = $param['ids'];
|
|
|
|
|
$result = db('project_plan')->whereIn('id', $ids)->delete();
|
|
|
|
|
if ($result!== false) {
|
|
|
|
|
return $this->sendSuccess('项目阶段删除成功');
|
|
|
|
|
} else {
|
|
|
|
|
return $this->sendError('', '项目阶段删除失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->sendError('缺少 ids 参数');
|
|
|
|
|
}
|
|
|
|
|
}
|