|
@ -20,10 +20,7 @@ package com.epmet.service.impl; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
import com.epmet.commons.tools.constant.*; |
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
@ -48,6 +45,7 @@ import com.epmet.entity.ProjectStaffEntity; |
|
|
import com.epmet.feign.*; |
|
|
import com.epmet.feign.*; |
|
|
import com.epmet.redis.ProjectRedis; |
|
|
import com.epmet.redis.ProjectRedis; |
|
|
import com.epmet.service.*; |
|
|
import com.epmet.service.*; |
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
@ -732,7 +730,7 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit |
|
|
int remindTime = 0; |
|
|
int remindTime = 0; |
|
|
//推送时间
|
|
|
//推送时间
|
|
|
String pushTime = "08:00"; |
|
|
String pushTime = "08:00"; |
|
|
if (null != paramList && paramList.size() > NumConstant.ZERO) { |
|
|
if (CollectionUtils.isNotEmpty(paramList)) { |
|
|
for (CustomerProjectParameterDTO dto : paramList) { |
|
|
for (CustomerProjectParameterDTO dto : paramList) { |
|
|
if (ParameterKeyConstant.DETENTION_DAYS.equals(dto.getParameterKey())) { |
|
|
if (ParameterKeyConstant.DETENTION_DAYS.equals(dto.getParameterKey())) { |
|
|
detentionDays = Integer.parseInt(dto.getParameterValue()); |
|
|
detentionDays = Integer.parseInt(dto.getParameterValue()); |
|
@ -748,35 +746,133 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit |
|
|
} |
|
|
} |
|
|
//获取工作人员未处理的节点
|
|
|
//获取工作人员未处理的节点
|
|
|
List<StaffUnHandledDTO> unHandledList = projectStaffService.getStaffUnHandledList(customerId); |
|
|
List<StaffUnHandledDTO> unHandledList = projectStaffService.getStaffUnHandledList(customerId); |
|
|
List<CostDayFormDTO> formDTOS = unHandledList.stream().map(item -> { |
|
|
List<CostDayFormDTO> form = unHandledList.stream().map(item -> { |
|
|
CostDayFormDTO dto = new CostDayFormDTO(); |
|
|
CostDayFormDTO dto = new CostDayFormDTO(); |
|
|
dto.setId(item.getId()); |
|
|
dto.setId(item.getId()); |
|
|
dto.setStaffId(item.getStaffId()); |
|
|
dto.setStaffId(item.getStaffId()); |
|
|
if (null != item.getUpdatedTime()) { |
|
|
if (null != item.getUpdatedTime()) { |
|
|
dto.setStartDate(DateUtils.format(item.getUpdatedTime(), DateUtils.DATE_PATTERN_YYYYMMDD)); |
|
|
dto.setStartDate(item.getUpdatedTime()); |
|
|
} else { |
|
|
} else { |
|
|
dto.setStartDate(DateUtils.format(item.getCreatedTime(), DateUtils.DATE_PATTERN_YYYYMMDD)); |
|
|
dto.setStartDate(item.getCreatedTime()); |
|
|
} |
|
|
} |
|
|
dto.setEndDate(DateUtils.format(new Date(), DateUtils.DATE_PATTERN_YYYYMMDD)); |
|
|
dto.setEndDate(new Date()); |
|
|
return dto; |
|
|
return dto; |
|
|
}).collect(Collectors.toList()); |
|
|
}).collect(Collectors.toList()); |
|
|
List<CostDayResultDTO> costDayList = new ArrayList<>(); |
|
|
List<CostDayResultDTO> costDayList; |
|
|
if (ParameterKeyConstant.WORK.equals(calculation)) { |
|
|
if (ParameterKeyConstant.WORK.equals(calculation)) { |
|
|
//工作日计算
|
|
|
//工作日计算
|
|
|
Result<List<CostDayResultDTO>> result = epmetCommonServiceOpenFeignClient.costWorkDays(formDTOS); |
|
|
Result<List<CostDayResultDTO>> result = epmetCommonServiceOpenFeignClient.costWorkDays(form); |
|
|
if (!result.success()) { |
|
|
if (!result.success()) { |
|
|
throw new RenException(result.getCode(), result.getMsg()); |
|
|
throw new RenException(result.getCode(), result.getMsg()); |
|
|
} |
|
|
} |
|
|
costDayList = result.getData(); |
|
|
costDayList = result.getData(); |
|
|
} else { |
|
|
} else { |
|
|
//日历日计算
|
|
|
//日历日计算
|
|
|
Result<List<CostDayResultDTO>> result = epmetCommonServiceOpenFeignClient.costCalendarDays(formDTOS); |
|
|
Result<List<CostDayResultDTO>> result = epmetCommonServiceOpenFeignClient.costCalendarDays(form); |
|
|
if (!result.success()) { |
|
|
if (!result.success()) { |
|
|
throw new RenException(result.getCode(), result.getMsg()); |
|
|
throw new RenException(result.getCode(), result.getMsg()); |
|
|
} |
|
|
} |
|
|
costDayList = result.getData(); |
|
|
costDayList = result.getData(); |
|
|
} |
|
|
} |
|
|
|
|
|
//即将超期项目
|
|
|
|
|
|
List<StaffUnHandledDTO> overdueList = new ArrayList<>(); |
|
|
|
|
|
//滞留项目
|
|
|
|
|
|
List<StaffUnHandledDTO> delayList = new ArrayList<>(); |
|
|
|
|
|
List<CostDayResultDTO> finalCostDayList = costDayList; |
|
|
|
|
|
List<OverdueAndDelayDTO> list = new ArrayList<>(); |
|
|
|
|
|
int finalDetentionDays = detentionDays; |
|
|
|
|
|
int finalRemindTime = remindTime; |
|
|
|
|
|
unHandledList.forEach(unHandle -> finalCostDayList.stream().filter(cost -> |
|
|
|
|
|
unHandle.getId().equals(cost.getId())).forEach(item -> { |
|
|
|
|
|
int diff = finalDetentionDays - item.getDetentionDays(); |
|
|
|
|
|
OverdueAndDelayDTO dto = new OverdueAndDelayDTO(); |
|
|
|
|
|
if (diff < 0) { |
|
|
|
|
|
dto.setStaffId(unHandle.getStaffId()); |
|
|
|
|
|
list.add(dto); |
|
|
|
|
|
delayList.add(unHandle); |
|
|
|
|
|
} else if (diff <= finalRemindTime) { |
|
|
|
|
|
dto.setStaffId(unHandle.getStaffId()); |
|
|
|
|
|
overdueList.add(unHandle); |
|
|
|
|
|
list.add(dto); |
|
|
|
|
|
} |
|
|
|
|
|
})); |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
|
|
setMessage(customerId, overdueList, delayList, list); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setMessage(String customerId, List<StaffUnHandledDTO> overdueList, List<StaffUnHandledDTO> delayList, List<OverdueAndDelayDTO> list) { |
|
|
|
|
|
list = list.stream().distinct().collect(Collectors.toList()); |
|
|
|
|
|
Map<String, List<StaffUnHandledDTO>> overdueMap = overdueList.stream().collect(Collectors.groupingBy(StaffUnHandledDTO::getStaffId)); |
|
|
|
|
|
Map<String, List<StaffUnHandledDTO>> delayMap = delayList.stream().collect(Collectors.groupingBy(StaffUnHandledDTO::getStaffId)); |
|
|
|
|
|
|
|
|
|
|
|
List<OverdueAndDelayDTO> overdue = overdueMap.entrySet().stream().map(item -> { |
|
|
|
|
|
OverdueAndDelayDTO dto = new OverdueAndDelayDTO(); |
|
|
|
|
|
dto.setStaffId(item.getKey()); |
|
|
|
|
|
dto.setOverdueList(item.getValue()); |
|
|
|
|
|
return dto; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
List<OverdueAndDelayDTO> delay = delayMap.entrySet().stream().map(item -> { |
|
|
|
|
|
OverdueAndDelayDTO dto = new OverdueAndDelayDTO(); |
|
|
|
|
|
dto.setStaffId(item.getKey()); |
|
|
|
|
|
dto.setDelayList(item.getValue()); |
|
|
|
|
|
return dto; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
list.forEach(dto -> overdue.forEach(item -> { |
|
|
|
|
|
if (dto.getStaffId().equals(item.getStaffId())) { |
|
|
|
|
|
dto.setOverdueList(item.getOverdueList()); |
|
|
|
|
|
} |
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
list.forEach(dto -> delay.forEach(item -> { |
|
|
|
|
|
if (dto.getStaffId().equals(item.getStaffId())) { |
|
|
|
|
|
dto.setDelayList(item.getDelayList()); |
|
|
|
|
|
} |
|
|
|
|
|
})); |
|
|
|
|
|
//通知
|
|
|
|
|
|
List<UserMessageFormDTO> msgList = new ArrayList<>(); |
|
|
|
|
|
list.forEach(dto -> { |
|
|
|
|
|
String title; |
|
|
|
|
|
String msg; |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(dto.getOverdueList()) && CollectionUtils.isNotEmpty(dto.getDelayList())) { |
|
|
|
|
|
title = String.format(UserMessageConstant.STAY_REMINDER_TITLE_1, dto.getOverdueList().size(), dto.getDelayList().size()); |
|
|
|
|
|
StringBuilder overdueMsg = new StringBuilder(); |
|
|
|
|
|
StringBuilder delayMsg = new StringBuilder(); |
|
|
|
|
|
for (int i = 0; i < dto.getOverdueList().size(); i++) { |
|
|
|
|
|
overdueMsg.append(i + 1).append(StrConstant.COMMA_ZH).append(dto.getOverdueList().get(i).getTitle()).append("\n"); |
|
|
|
|
|
} |
|
|
|
|
|
for (int i = 0; i < dto.getDelayList().size(); i++) { |
|
|
|
|
|
delayMsg.append(i + 1).append(StrConstant.COMMA_ZH).append(dto.getDelayList().get(i).getTitle()).append("\n"); |
|
|
|
|
|
} |
|
|
|
|
|
msg = String.format(UserMessageConstant.STAY_REMINDER_MSG_1, overdueMsg.toString(), delayMsg.toString()); |
|
|
|
|
|
} else if (CollectionUtils.isNotEmpty(dto.getOverdueList()) && CollectionUtils.isEmpty(dto.getDelayList())) { |
|
|
|
|
|
title = String.format(UserMessageConstant.STAY_REMINDER_TITLE_2, dto.getOverdueList().size()); |
|
|
|
|
|
StringBuilder overdueMsg = new StringBuilder(); |
|
|
|
|
|
for (int i = 0; i < dto.getOverdueList().size(); i++) { |
|
|
|
|
|
overdueMsg.append(i + 1).append(StrConstant.COMMA_ZH).append(dto.getOverdueList().get(i).getTitle()).append("\n"); |
|
|
|
|
|
} |
|
|
|
|
|
msg = String.format(UserMessageConstant.STAY_REMINDER_MSG_2, overdueMsg.toString()); |
|
|
|
|
|
} else { |
|
|
|
|
|
title = String.format(UserMessageConstant.STAY_REMINDER_TITLE_3, dto.getDelayList().size()); |
|
|
|
|
|
StringBuilder delayMsg = new StringBuilder(); |
|
|
|
|
|
for (int i = 0; i < dto.getDelayList().size(); i++) { |
|
|
|
|
|
delayMsg.append(i + 1).append(StrConstant.COMMA_ZH).append(dto.getDelayList().get(i).getTitle()).append("\n"); |
|
|
|
|
|
} |
|
|
|
|
|
msg = String.format(UserMessageConstant.STAY_REMINDER_MSG_3, delayMsg.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
UserMessageFormDTO messageFormDTO = new UserMessageFormDTO(); |
|
|
|
|
|
messageFormDTO.setCustomerId(customerId); |
|
|
|
|
|
messageFormDTO.setApp(ProjectConstant.GOV); |
|
|
|
|
|
messageFormDTO.setGridId(StrConstant.STAR); |
|
|
|
|
|
messageFormDTO.setUserId(dto.getStaffId()); |
|
|
|
|
|
messageFormDTO.setTitle(title); |
|
|
|
|
|
messageFormDTO.setMessageContent(msg); |
|
|
|
|
|
messageFormDTO.setReadFlag(Constant.UNREAD); |
|
|
|
|
|
msgList.add(messageFormDTO); |
|
|
|
|
|
}); |
|
|
|
|
|
System.out.println(msgList); |
|
|
|
|
|
messageFeignClient.saveUserMessageList(msgList); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |