|
@@ -5,13 +5,16 @@ import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.management.platform.constant.Constant;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.bo.QueryTaskChargePage;
|
|
import com.management.platform.entity.bo.QueryTaskChargePage;
|
|
import com.management.platform.entity.vo.SysRichFunction;
|
|
import com.management.platform.entity.vo.SysRichFunction;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.service.*;
|
|
import com.management.platform.service.*;
|
|
|
|
+import com.management.platform.service.impl.WxCorpInfoServiceImpl;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.MessageUtils;
|
|
import com.management.platform.util.MessageUtils;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
import org.assertj.core.util.Lists;
|
|
import org.assertj.core.util.Lists;
|
|
@@ -46,6 +49,7 @@ import java.util.stream.Collectors;
|
|
*/
|
|
*/
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/task")
|
|
@RequestMapping("/task")
|
|
|
|
+@Slf4j
|
|
public class TaskController {
|
|
public class TaskController {
|
|
@Resource
|
|
@Resource
|
|
private HttpServletRequest request;
|
|
private HttpServletRequest request;
|
|
@@ -187,13 +191,19 @@ public class TaskController {
|
|
User user = userMapper.selectById(userId);
|
|
User user = userMapper.selectById(userId);
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ int isInsert=0;
|
|
//新建的任务,需要设置创建人,创建时间
|
|
//新建的任务,需要设置创建人,创建时间
|
|
if (task.getId() == null) {
|
|
if (task.getId() == null) {
|
|
|
|
+ isInsert=1;
|
|
task.setCreateDate(LocalDate.now());
|
|
task.setCreateDate(LocalDate.now());
|
|
task.setCreaterId(userId);
|
|
task.setCreaterId(userId);
|
|
task.setCreaterName(user.getName());
|
|
task.setCreaterName(user.getName());
|
|
task.setCreatorColor(user.getColor());
|
|
task.setCreatorColor(user.getColor());
|
|
task.setCompanyId(user.getCompanyId());
|
|
task.setCompanyId(user.getCompanyId());
|
|
|
|
+
|
|
|
|
+ if (user.getCompanyId()==Constant.MLD_COMPANY_ID&&task.getIsTaskPlan()==1){
|
|
|
|
+ task.setTaskStatus(3);
|
|
|
|
+ }
|
|
// TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
// TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
// Integer taskFileCharge = timeType.getTaskFileCharge();
|
|
// Integer taskFileCharge = timeType.getTaskFileCharge();
|
|
// if(1 == taskFileCharge){
|
|
// if(1 == taskFileCharge){
|
|
@@ -444,8 +454,45 @@ public class TaskController {
|
|
if ((oldTask.getTaskType() == 1 && task.getTaskType() != 1) || (oldTask.getTaskType() != 1 && task.getTaskType() == 1)) {
|
|
if ((oldTask.getTaskType() == 1 && task.getTaskType() != 1) || (oldTask.getTaskType() != 1 && task.getTaskType() == 1)) {
|
|
needRecalculateProgress = true;
|
|
needRecalculateProgress = true;
|
|
}
|
|
}
|
|
|
|
+ // 未驳回之前 第一审核人 修改工作计划
|
|
|
|
+ if (user.getCompanyId()==Constant.MLD_COMPANY_ID
|
|
|
|
+ &&task.getIsTaskPlan()==1
|
|
|
|
+ && org.apache.commons.lang3.StringUtils.isNotEmpty(task.getCheckFirstId())
|
|
|
|
+ &&task.getCheckFirstId().equals(userId)
|
|
|
|
+ &&task.getTaskStatus()==3){
|
|
|
|
+ task.setTaskStatus(4);//待第二审核人审核
|
|
|
|
+ } else if (user.getCompanyId() == Constant.MLD_COMPANY_ID
|
|
|
|
+ && task.getIsTaskPlan() == 1
|
|
|
|
+ && org.apache.commons.lang3.StringUtils.isNotEmpty(task.getCheckSecondId())
|
|
|
|
+ && task.getCheckSecondId().equals(userId)
|
|
|
|
+ &&task.getTaskStatus()==4) {
|
|
|
|
+ task.setTaskStatus(0);//变化为进行中
|
|
|
|
+ task.setIsTaskPlan(0);//不再是计划
|
|
|
|
+ }
|
|
|
|
+ // 未驳回之前 第一审核人 修改工作计划
|
|
|
|
+ if (user.getCompanyId()==Constant.MLD_COMPANY_ID
|
|
|
|
+ &&task.getIsTaskPlan()==1
|
|
|
|
+ &&task.getTaskStatus()==5){
|
|
|
|
+ task.setTaskStatus(3);//待第一审核人审核
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ boolean saved = taskService.saveOrUpdate(task);
|
|
|
|
+ //新增成功,给第一审核人发送信息提醒
|
|
|
|
+ if (saved&&isInsert==1){
|
|
|
|
+ if (user.getCompanyId()==Constant.MLD_COMPANY_ID&&task.getIsTaskPlan()==1&& org.apache.commons.lang3.StringUtils.isNotEmpty(task.getCheckFirstId())){
|
|
|
|
+ //给第一审核人发送信息提醒
|
|
|
|
+ log.info("添加工作计划,给第一审核人发送信息提醒");
|
|
|
|
+ User owner = userMapper.selectById(task.getCheckFirstId());
|
|
|
|
+ if (wxCorpInfo != null) {
|
|
|
|
+ //推送到企业微信
|
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
+ stringBuilder.append("$userName="+owner.getCorpwxUserid()+"$")
|
|
|
|
+ .append(":有新的工作计划待审核");
|
|
|
|
+ wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,owner.getCorpwxUserid(), stringBuilder.toString(), "task",
|
|
|
|
+ WxCorpInfoServiceImpl.TEXT_CARD_MSG_TASK_PLAN_NEED_CHECK);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- taskService.saveOrUpdate(task);
|
|
|
|
if (task.getExecutorId() == null) {
|
|
if (task.getExecutorId() == null) {
|
|
//清空执行人
|
|
//清空执行人
|
|
if (!isNew) {
|
|
if (!isNew) {
|
|
@@ -482,30 +529,32 @@ public class TaskController {
|
|
informationService.save(new Information().setType(1).setContent(String.valueOf(task.getProjectId())).setUserId(msgRecepient));
|
|
informationService.save(new Information().setType(1).setContent(String.valueOf(task.getProjectId())).setUserId(msgRecepient));
|
|
});
|
|
});
|
|
List<User> recpUserList = userMapper.selectList(new QueryWrapper<User>().in("id", msgRecepientList));
|
|
List<User> recpUserList = userMapper.selectList(new QueryWrapper<User>().in("id", msgRecepientList));
|
|
- if (recpUserList.size() > 0) {
|
|
|
|
- if (recpUserList.get(0).getDingdingUserid() != null) {
|
|
|
|
- //钉钉用户
|
|
|
|
- CompanyDingding dingding = companyDingdingService.getOne(new QueryWrapper<CompanyDingding>().eq("company_id", user.getCompanyId()));
|
|
|
|
- LocalDate endDate = task.getEndDate();
|
|
|
|
- String endStr = "";
|
|
|
|
- if (endDate != null) {
|
|
|
|
- endStr = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(endDate);
|
|
|
|
|
|
+ if(user.getCompanyId()!=Constant.MLD_COMPANY_ID||task.getIsTaskPlan()!=1) {
|
|
|
|
+ if (recpUserList.size() > 0) {
|
|
|
|
+ if (recpUserList.get(0).getDingdingUserid() != null) {
|
|
|
|
+ //钉钉用户
|
|
|
|
+ CompanyDingding dingding = companyDingdingService.getOne(new QueryWrapper<CompanyDingding>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ LocalDate endDate = task.getEndDate();
|
|
|
|
+ String endStr = "";
|
|
|
|
+ if (endDate != null) {
|
|
|
|
+ endStr = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(endDate);
|
|
|
|
+ }
|
|
|
|
+ companyDingdingService.sendNewTaskMsg(dingding, recpUserList.stream().map(User::getDingdingUserid).collect(Collectors.joining(",")),
|
|
|
|
+ task.getName(), endStr);
|
|
|
|
+ } else if (recpUserList.get(0).getCorpwxUserid() != null) {
|
|
|
|
+ String corpUid = recpUserList.stream().map(User::getCorpwxUserid).distinct().collect(Collectors.joining("|"));
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ JSONArray dataJson = new JSONArray();
|
|
|
|
+ JSONObject jsonObj = new JSONObject();
|
|
|
|
+ jsonObj.put("key", "任务内容");
|
|
|
|
+ jsonObj.put("value", task.getName());
|
|
|
|
+ dataJson.add(jsonObj);
|
|
|
|
+ json.put("template_id", "tty9TkCAAAovv416zsWtn0e06CJ635HA");
|
|
|
|
+ json.put("url", "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=task#wechat_redirect");
|
|
|
|
+ json.put("content_item", dataJson);
|
|
|
|
+ //todo:发送消息提醒任务
|
|
|
|
+ wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo, corpUid, json);
|
|
}
|
|
}
|
|
- companyDingdingService.sendNewTaskMsg(dingding, recpUserList.stream().map(User::getDingdingUserid).collect(Collectors.joining(",")),
|
|
|
|
- task.getName(), endStr);
|
|
|
|
- } else if (recpUserList.get(0).getCorpwxUserid() != null) {
|
|
|
|
- String corpUid = recpUserList.stream().map(User::getCorpwxUserid).distinct().collect(Collectors.joining("|"));
|
|
|
|
- JSONObject json=new JSONObject();
|
|
|
|
- JSONArray dataJson=new JSONArray();
|
|
|
|
- JSONObject jsonObj=new JSONObject();
|
|
|
|
- jsonObj.put("key", "任务内容");
|
|
|
|
- jsonObj.put("value",task.getName());
|
|
|
|
- dataJson.add(jsonObj);
|
|
|
|
- json.put("template_id","tty9TkCAAAovv416zsWtn0e06CJ635HA");
|
|
|
|
- json.put("url", "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=task#wechat_redirect");
|
|
|
|
- json.put("content_item",dataJson);
|
|
|
|
- //todo:发送消息提醒任务
|
|
|
|
- wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo, corpUid, json);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1410,6 +1459,10 @@ public class TaskController {
|
|
if(pageIndex!=null&&pageSize!=null){
|
|
if(pageIndex!=null&&pageSize!=null){
|
|
pageStart = (pageIndex - 1) * pageSize;
|
|
pageStart = (pageIndex - 1) * pageSize;
|
|
}
|
|
}
|
|
|
|
+ if (companyId==Constant.MLD_COMPANY_ID){
|
|
|
|
+ //美莱德 任务计划状态是1
|
|
|
|
+ queryWrapper.ne("is_task_plan",1);
|
|
|
|
+ }
|
|
List<Task> list = taskMapper.getTaskWithProjectName(queryWrapper,pageStart, pageSize,companyId,branchDepartment);
|
|
List<Task> list = taskMapper.getTaskWithProjectName(queryWrapper,pageStart, pageSize,companyId,branchDepartment);
|
|
List<Integer> collect = list.stream().map(l -> l.getId()).distinct().collect(Collectors.toList());
|
|
List<Integer> collect = list.stream().map(l -> l.getId()).distinct().collect(Collectors.toList());
|
|
collect.add(-1);
|
|
collect.add(-1);
|