提交 c11ce3d0 authored 作者: 邓砥奕's avatar 邓砥奕

[业务模块]修改经办人为待办人,修改返回值为String处理判断的bug

上级 b87eaef2
...@@ -46,7 +46,7 @@ public class UnifiedReturnConfig implements ResponseBodyAdvice<Object> { ...@@ -46,7 +46,7 @@ public class UnifiedReturnConfig implements ResponseBodyAdvice<Object> {
ResultObj<Object> result = new ResultObj<>(body, "成功 :)"); ResultObj<Object> result = new ResultObj<>(body, "成功 :)");
// 如果返回的是字符串,则要对其做JSON序列化 // 如果返回的是字符串,则要对其做JSON序列化
if (returnType.getGenericParameterType().equals(String.class)) { if (body.getClass().equals(String.class)) {
try { try {
response.getHeaders().set("Content-Type", "application/json;charset=utf-8"); response.getHeaders().set("Content-Type", "application/json;charset=utf-8");
return objectMapper.writeValueAsString(result); return objectMapper.writeValueAsString(result);
......
...@@ -3,6 +3,8 @@ package com.tykj.dev.device.selfcheck.base; ...@@ -3,6 +3,8 @@ package com.tykj.dev.device.selfcheck.base;
import com.tykj.dev.config.GlobalMap; import com.tykj.dev.config.GlobalMap;
import com.tykj.dev.config.TaskBeanConfig; import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.config.service.SystemVariableService; import com.tykj.dev.config.service.SystemVariableService;
import com.tykj.dev.device.selfcheck.service.SelfCheckBillService;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.task.service.TaskService; import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto; import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.user.subject.dao.UnitsDao; import com.tykj.dev.device.user.subject.dao.UnitsDao;
...@@ -22,9 +24,7 @@ import org.springframework.stereotype.Component; ...@@ -22,9 +24,7 @@ import org.springframework.stereotype.Component;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
/** /**
...@@ -59,6 +59,8 @@ public class SelfCheckSchedulerTask { ...@@ -59,6 +59,8 @@ public class SelfCheckSchedulerTask {
private SystemVariableService systemVariableService = SpringUtils.getBean("systemVariableServiceImpl"); private SystemVariableService systemVariableService = SpringUtils.getBean("systemVariableServiceImpl");
private SelfCheckBillService selfCheckBillService = SpringUtils.getBean("selfCheckBillServiceImpl");
private ScheduledFuture scheduledFuture; private ScheduledFuture scheduledFuture;
public SelfCheckSchedulerTask() { public SelfCheckSchedulerTask() {
...@@ -81,13 +83,41 @@ public class SelfCheckSchedulerTask { ...@@ -81,13 +83,41 @@ public class SelfCheckSchedulerTask {
public class SelfCheckTask implements Runnable{ public class SelfCheckTask implements Runnable{
@Override @Override
public void run() { public void run() {
if (unitsDao != null && taskService!=null) { if (unitsDao != null && taskService!=null && selfCheckBillService!=null) {
List<Units> unitsList = unitsDao.findAll(); List<Units> unitsList = unitsDao.findAll();
unitsList.forEach(units -> { unitsList.forEach(units -> {
//添加账单
SelfCheckBill selfCheckBill = new SelfCheckBill();
selfCheckBill.setCheckStatus(3);
selfCheckBill.setCheckUnit(units.getName());
StringBuffer title = new StringBuffer();
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH)+1;
title.append(year).append("年");
if (cron.equals(cron1)){
title.append(month).append("月自查任务");
selfCheckBill.setCycle(1);
}
else if (cron.equals(cron2)){
title.append(getQuarter(month)).append("自查任务");
selfCheckBill.setCycle(2);
}
else if (cron.equals(cron3)){
title.append("自查任务");
selfCheckBill.setCycle(3);
}
else {
title.append("自查任务");
selfCheckBill.setCycle(0);
}
selfCheckBill.setTitle(title.toString());
SelfCheckBill selfCheckBill1 = selfCheckBillService.addEntity(selfCheckBill);
//发起待自查任务 //发起待自查任务
List<Integer> userIds = new ArrayList<>(); List<Integer> userIds = new ArrayList<>();
userIds.add(0); userIds.add(0);
TaskBto taskBto = new TaskBto(StatusEnum.WAIT_SELF_CHECK.id,"自查业务",null,".",0,4,units.getUnitId(),0,null,userIds); TaskBto taskBto = new TaskBto(StatusEnum.WAIT_SELF_CHECK.id,"自查业务",null,".",selfCheckBill1.getId(),4,units.getUnitId(),0,null,userIds);
taskService.start(taskBto); taskService.start(taskBto);
}); });
} }
...@@ -98,4 +128,19 @@ public class SelfCheckSchedulerTask { ...@@ -98,4 +128,19 @@ public class SelfCheckSchedulerTask {
public void startTask(){ public void startTask(){
scheduledFuture = TaskBeanConfig.getThreadPoolTaskScheduler().schedule(new SelfCheckTask(), triggerContext -> new CronTrigger(cron).nextExecutionTime(triggerContext)); scheduledFuture = TaskBeanConfig.getThreadPoolTaskScheduler().schedule(new SelfCheckTask(), triggerContext -> new CronTrigger(cron).nextExecutionTime(triggerContext));
} }
/**
* 当前月份属于本年第几个季度
*/
public static String getQuarter(int month) {
if (month <= 3) {
return "第一季度";
} else if (month <= 6) {
return "第二季度";
} else if (month <= 9) {
return "第三季度";
} else {
return "第四季度";
}
}
} }
...@@ -254,10 +254,24 @@ public class SelfCheckController { ...@@ -254,10 +254,24 @@ public class SelfCheckController {
@PostMapping(value = "/addBill") @PostMapping(value = "/addBill")
public ResponseEntity addSelfExaminationBill(@RequestBody SelfCheckSaveVo selfCheckSaveVo) { public ResponseEntity addSelfExaminationBill(@RequestBody SelfCheckSaveVo selfCheckSaveVo) {
//添加账单 //添加账单
SelfCheckBill selfExaminationBillEntity = selfCheckSaveVo.toDo(); SelfCheckBill selfExaminationBillEntity;
selfExaminationBillEntity.setTitle(userUtils.getCurrentUserUnitName() + "发起的自查任务"); if (selfCheckSaveVo.getTaskId()!=null){
TaskBto taskBto = taskService.get(selfCheckSaveVo.getTaskId());
selfExaminationBillEntity = selfExaminationBillService.getOne(taskBto.getBillId());
selfExaminationBillEntity.setCheckTime(new Date());
selfExaminationBillEntity.setCheckDetail(selfCheckSaveVo.getCheckDetail());
selfExaminationBillEntity.setCheckResult(selfCheckSaveVo.getCheckResult());
selfExaminationBillEntity.setCheckStatus(0);
selfExaminationBillEntity.setCheckedCount(selfCheckSaveVo.getCheckedCount());
selfExaminationBillEntity.setCheckingCount(selfCheckSaveVo.getCheckingCount());
selfExaminationBillEntity.setUserbId(selfCheckSaveVo.getUserbId());
}
else {
selfExaminationBillEntity = selfCheckSaveVo.toDo();
selfExaminationBillEntity.setTitle(userUtils.getCurrentUserUnitName() + "发起的自查任务");
selfExaminationBillEntity.setCheckUnit(userUtils.getCurrentUserUnitName());
}
selfExaminationBillEntity.setUseraId(userUtils.getCurrentUserId()); selfExaminationBillEntity.setUseraId(userUtils.getCurrentUserId());
selfExaminationBillEntity.setCheckUnit(userUtils.getCurrentUserUnitName());
selfExaminationBillEntity.setCreateUnitId(userUtils.getCurrentUnitId()); selfExaminationBillEntity.setCreateUnitId(userUtils.getCurrentUnitId());
if (selfCheckSaveVo.getNewDeviceList() != null) { if (selfCheckSaveVo.getNewDeviceList() != null) {
//按新增不在系统的装备按rfid卡号拼接保存 //按新增不在系统的装备按rfid卡号拼接保存
...@@ -271,17 +285,24 @@ public class SelfCheckController { ...@@ -271,17 +285,24 @@ public class SelfCheckController {
} }
SelfCheckBill selfExaminationBillEntity1 = selfExaminationBillService.addEntity(selfExaminationBillEntity); SelfCheckBill selfExaminationBillEntity1 = selfExaminationBillService.addEntity(selfExaminationBillEntity);
Integer userId = userUtils.getCurrentUserId(); Integer userId = userUtils.getCurrentUserId();
String deviceIdDetail = selfExaminationBillEntity.getCheckDetail(); String deviceIdDetail = selfCheckSaveVo.getCheckDetail();
String[] strings = deviceIdDetail.split("x"); String[] strings = deviceIdDetail.split("x");
//发起任务 if (selfCheckSaveVo.getTaskId()!=null){
List<Integer> userIds = new ArrayList<>(); //获取任务
userIds.add(userId); TaskBto taskBto = taskService.get(selfCheckSaveVo.getTaskId());
userIds.add(selfExaminationBillEntity1.getUserbId()); //添加涉及人员
TaskBto taskBto = new TaskBto(StatusEnum.SELF_CHECK_CONFIRM.id,"自查业务",null,".",selfExaminationBillEntity1.getId(),4,userUtils.getCurrentUnitId(),1,null,userIds); taskService.addInvolveUser(taskBto,userId);
TaskBto saveEntity = taskService.start(taskBto); //推至下一阶段
//存业务日志 taskService.moveToNext(taskBto,selfCheckSaveVo.getUserbId());
// TaskLogBto taskLogBto = new TaskLogBto(saveEntity.getId(),"发起自查",null); }
// taskLogService.addLog(taskLogBto); else {
//发起任务
List<Integer> userIds = new ArrayList<>();
userIds.add(userId);
userIds.add(selfExaminationBillEntity1.getUserbId());
TaskBto taskBto = new TaskBto(StatusEnum.SELF_CHECK_CONFIRM.id, "自查业务", null, ".", selfExaminationBillEntity1.getId(), 4, userUtils.getCurrentUnitId(), 1, null, userIds);
taskService.start(taskBto);
}
//添加装备日志 //添加装备日志
for (String s:strings) { for (String s:strings) {
if (s.length()>=2) { if (s.length()>=2) {
...@@ -348,13 +369,21 @@ public class SelfCheckController { ...@@ -348,13 +369,21 @@ public class SelfCheckController {
public ResponseEntity selectSelfExaminationBill(@RequestBody SelfCheckSelectVo selfCheckSelectVo) { public ResponseEntity selectSelfExaminationBill(@RequestBody SelfCheckSelectVo selfCheckSelectVo) {
Page<SelfCheckBill> page = selfExaminationBillService.getPage(selfCheckSelectVo, selfCheckSelectVo.getPageable()); Page<SelfCheckBill> page = selfExaminationBillService.getPage(selfCheckSelectVo, selfCheckSelectVo.getPageable());
for (SelfCheckBill s : page.getContent()) { for (SelfCheckBill s : page.getContent()) {
s.setCreateUnit(userPublicService.findByUnitsToname(s.getCreateUnitId())); if (s.getCreateUnitId()!=null) {
String user = userPublicService.getOne(s.getUseraId()).getName(); s.setCreateUnit(userPublicService.findByUnitsToname(s.getCreateUnitId()));
String user2 = userPublicService.getOne(s.getUserbId()).getName(); }
String user3 = userPublicService.getOne(s.getCreateUserId()).getName(); if (s.getUseraId()!=null) {
s.setCheckUser(user); String user = userPublicService.getOne(s.getUseraId()).getName();
s.setConfirmUser(user2); s.setCheckUser(user);
s.setCreateUser(user3); }
if (s.getUserbId()!=null) {
String user2 = userPublicService.getOne(s.getUserbId()).getName();
s.setConfirmUser(user2);
}
if (s.getCreateUserId()!=null) {
String user3 = userPublicService.getOne(s.getCreateUserId()).getName();
s.setCreateUser(user3);
}
} }
return ResultUtil.success(page); return ResultUtil.success(page);
} }
......
...@@ -6,6 +6,7 @@ import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao; ...@@ -6,6 +6,7 @@ import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao;
import com.tykj.dev.device.selfcheck.service.SelfCheckBillService; import com.tykj.dev.device.selfcheck.service.SelfCheckBillService;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill; import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSelectVo; import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSelectVo;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException; import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.ResultUtil; import com.tykj.dev.misc.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -27,6 +28,9 @@ public class SelfCheckBillServiceImpl implements SelfCheckBillService { ...@@ -27,6 +28,9 @@ public class SelfCheckBillServiceImpl implements SelfCheckBillService {
@Autowired @Autowired
private SelfCheckBillDao selfExaminationBillDao; private SelfCheckBillDao selfExaminationBillDao;
@Autowired
private UserUtils userUtils;
@Override @Override
public SelfCheckBill addEntity(SelfCheckBill selfExaminationBillEntity) { public SelfCheckBill addEntity(SelfCheckBill selfExaminationBillEntity) {
return selfExaminationBillDao.save(selfExaminationBillEntity); return selfExaminationBillDao.save(selfExaminationBillEntity);
...@@ -59,6 +63,7 @@ public class SelfCheckBillServiceImpl implements SelfCheckBillService { ...@@ -59,6 +63,7 @@ public class SelfCheckBillServiceImpl implements SelfCheckBillService {
private Specification<SelfCheckBill> getSelectSpecification(SelfCheckSelectVo selfCheckSelectVo) { private Specification<SelfCheckBill> getSelectSpecification(SelfCheckSelectVo selfCheckSelectVo) {
PredicateBuilder<SelfCheckBill> predicateBuilder = Specifications.and(); PredicateBuilder<SelfCheckBill> predicateBuilder = Specifications.and();
predicateBuilder.eq("checkUnit",userUtils.getCurrentUserUnitName());
if (selfCheckSelectVo != null) { if (selfCheckSelectVo != null) {
if (selfCheckSelectVo.getCheckStatus() != null) { if (selfCheckSelectVo.getCheckStatus() != null) {
predicateBuilder.eq("checkStatus", selfCheckSelectVo.getCheckStatus()); predicateBuilder.eq("checkStatus", selfCheckSelectVo.getCheckStatus());
......
...@@ -34,9 +34,9 @@ public class SelfCheckBill { ...@@ -34,9 +34,9 @@ public class SelfCheckBill {
@ApiModelProperty(name = "主键id") @ApiModelProperty(name = "主键id")
private Integer id; private Integer id;
/** /**
* 自查周期(0:月度,1:季度,2:年度) * 自查周期(1:月度,2:季度,3:年度,0:未设定周期)
*/ */
@ApiModelProperty(value = "自查周期(0:月度,1:季度,2:年度)") @ApiModelProperty(value = "自查周期(1:月度,2:季度,3:年度,0:未设定周期)")
private Integer cycle; private Integer cycle;
/** /**
* 自查标题 * 自查标题
...@@ -84,9 +84,9 @@ public class SelfCheckBill { ...@@ -84,9 +84,9 @@ public class SelfCheckBill {
@ApiModelProperty(value = "自查详情(装备主键id+核对结果(0缺失1无误2新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增") @ApiModelProperty(value = "自查详情(装备主键id+核对结果(0缺失1无误2新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增")
private String checkDetail; private String checkDetail;
/** /**
* 自查状态(0:待审核,1:审核失败,2:自查完成) * 自查状态(0:待审核,1:审核失败,2:自查完成,3:未检)
*/ */
@ApiModelProperty(value = "自查状态(0:待审核,1:审核失败,2:自查完成)") @ApiModelProperty(value = "自查状态(0:待审核,1:审核失败,2:自查完成,3:未检)")
private Integer checkStatus; private Integer checkStatus;
/** /**
* 创建用户id * 创建用户id
...@@ -97,7 +97,6 @@ public class SelfCheckBill { ...@@ -97,7 +97,6 @@ public class SelfCheckBill {
/** /**
* 创建单位id * 创建单位id
*/ */
@CreatedBy
@ApiModelProperty(value = "创建单位id") @ApiModelProperty(value = "创建单位id")
private Integer createUnitId; private Integer createUnitId;
/** /**
......
...@@ -18,6 +18,9 @@ import java.util.List; ...@@ -18,6 +18,9 @@ import java.util.List;
@Repository @Repository
public class SelfCheckSaveVo { public class SelfCheckSaveVo {
@ApiModelProperty(name = "任务id", example = "1")
private Integer taskId;
@ApiModelProperty(name = "审核人ID", example = "1") @ApiModelProperty(name = "审核人ID", example = "1")
private Integer userbId; private Integer userbId;
......
...@@ -13,6 +13,7 @@ import com.tykj.dev.device.task.subject.domin.TaskLog; ...@@ -13,6 +13,7 @@ import com.tykj.dev.device.task.subject.domin.TaskLog;
import com.tykj.dev.device.task.subject.vo.TaskSelectVo; import com.tykj.dev.device.task.subject.vo.TaskSelectVo;
import com.tykj.dev.device.task.subject.vo.TaskUserVo; import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import com.tykj.dev.device.task.utils.TaskUtils; import com.tykj.dev.device.task.utils.TaskUtils;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.subject.service.UserPublicService; import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.device.user.util.UserUtils; import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.base.StatusEnum; import com.tykj.dev.misc.base.StatusEnum;
...@@ -371,11 +372,27 @@ public class TaskServiceImpl implements TaskService { ...@@ -371,11 +372,27 @@ public class TaskServiceImpl implements TaskService {
List<Integer> idList = taskUserVo.getUserReadDetailList(); List<Integer> idList = taskUserVo.getUserReadDetailList();
List<Integer> idList2 = taskUserVo.getTopFlagDetailList(); List<Integer> idList2 = taskUserVo.getTopFlagDetailList();
if (taskUserVo.getInvolveUserIdList() != null && taskUserVo.getInvolveUserIdList().size() > 0) { if (taskUserVo.getInvolveUserIdList() != null && taskUserVo.getInvolveUserIdList().size() > 0) {
//筛选出userId大于0的 //获取涉及人员当前指针
List<Integer> userIds = taskUserVo.getInvolveUserIdList().stream().filter(integer -> integer > 0).collect(Collectors.toList()); List<Integer> userIds = taskUserVo.getInvolveUserIdList();
if (userIds.size() > 0) { if (userIds.size() > 0 && taskUserVo.getCurrentPoint()<userIds.size()) {
//List最后一个id即为最新经办人 Integer userId3 = userIds.get(taskUserVo.getCurrentPoint());
taskUserVo.setProcessingUser(userPublicService.getOne(userIds.get(userIds.size() - 1)).getName()); //当前指针userId大于0,待办人即当前id
if (userId3>0) {
taskUserVo.setProcessingUser(userPublicService.getOne(userId3).getName());
}
//当前指针userId等于0,待办人为所属单位下所有用户
else if (userId3==0&&taskUserVo.getOwnUnit()!=null){
StringBuffer stringBuffer = new StringBuffer();
List<User> users = userPublicService.getAllUser();
users.stream().filter(user -> user.getUnitsId().equals(taskUserVo.getOwnUnit())).forEach(user -> {
stringBuffer.append(user.getName()).append(",");
});
stringBuffer.deleteCharAt(stringBuffer.length()-1);
taskUserVo.setProcessingUser(stringBuffer.toString());
}
else {
taskUserVo.setProcessingUser("");
}
} }
} }
//判断当前用户是否已读 //判断当前用户是否已读
...@@ -599,11 +616,27 @@ public class TaskServiceImpl implements TaskService { ...@@ -599,11 +616,27 @@ public class TaskServiceImpl implements TaskService {
List<Integer> idList = taskUserVo.getUserReadDetailList(); List<Integer> idList = taskUserVo.getUserReadDetailList();
List<Integer> idList2 = taskUserVo.getTopFlagDetailList(); List<Integer> idList2 = taskUserVo.getTopFlagDetailList();
if (taskUserVo.getInvolveUserIdList() != null && taskUserVo.getInvolveUserIdList().size() > 0) { if (taskUserVo.getInvolveUserIdList() != null && taskUserVo.getInvolveUserIdList().size() > 0) {
//筛选出userId大于0的 //获取涉及人员当前指针
List<Integer> userIds = taskUserVo.getInvolveUserIdList().stream().filter(integer -> integer > 0).collect(Collectors.toList()); List<Integer> userIds = taskUserVo.getInvolveUserIdList();
if (userIds.size() > 0) { if (userIds.size() > 0 && taskUserVo.getCurrentPoint()<userIds.size()) {
//List最后一个id即为最新经办人 Integer userId3 = userIds.get(taskUserVo.getCurrentPoint());
taskUserVo.setProcessingUser(userPublicService.getOne(userIds.get(userIds.size() - 1)).getName()); //当前指针userId大于0,待办人即当前id
if (userId3>0) {
taskUserVo.setProcessingUser(userPublicService.getOne(userId3).getName());
}
//当前指针userId等于0,待办人为所属单位下所有用户
else if (userId3==0&&taskUserVo.getOwnUnit()!=null){
StringBuffer stringBuffer = new StringBuffer();
List<User> users = userPublicService.getAllUser();
users.stream().filter(user -> user.getUnitsId().equals(taskUserVo.getOwnUnit())).forEach(user -> {
stringBuffer.append(user.getName()).append(",");
});
stringBuffer.deleteCharAt(stringBuffer.length()-1);
taskUserVo.setProcessingUser(stringBuffer.toString());
}
else {
taskUserVo.setProcessingUser("");
}
} }
} }
//判断当前用户是否已读 //判断当前用户是否已读
......
...@@ -67,7 +67,7 @@ public class TaskUserVo { ...@@ -67,7 +67,7 @@ public class TaskUserVo {
@Transient @Transient
private Date userTimeDate; private Date userTimeDate;
@ApiModelProperty(value = "处理人") @ApiModelProperty(value = "待办人")
@Transient @Transient
private String processingUser; private String processingUser;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论