Commit 13a582d6 by Ren Ping

Merge remote-tracking branch 'origin/develop' into develop

2 parents d6aa0173 9d837f66
package com.dituhui.pea.order.common; package com.dituhui.pea.order.common;
import cn.hutool.core.util.ObjectUtil;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -49,6 +51,9 @@ public class TimeUtils { ...@@ -49,6 +51,9 @@ public class TimeUtils {
} }
public static final String IsoLocalDateTime2String(LocalDateTime localDateTime) { public static final String IsoLocalDateTime2String(LocalDateTime localDateTime) {
if (ObjectUtil.isNull(localDateTime)) {
return null;
}
return localDateTime.format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT)); return localDateTime.format(DateTimeFormatter.ofPattern(DATE_TIME_FORMAT));
} }
......
...@@ -19,6 +19,8 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS ...@@ -19,6 +19,8 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
List<OrderInfoEntity> findByDtAndEngineerCodeIn(LocalDate date, List<String> engineerCodes); List<OrderInfoEntity> findByDtAndEngineerCodeIn(LocalDate date, List<String> engineerCodes);
List<OrderInfoEntity> findByDtAndEngineerCodeSubIn(LocalDate date, List<String> engineerCodes);
List<OrderInfoEntity> findByDtAndServiceStatusNotAndEngineerCodeIn(LocalDate date, String serviceSatus, List<String> engineerCodes); List<OrderInfoEntity> findByDtAndServiceStatusNotAndEngineerCodeIn(LocalDate date, String serviceSatus, List<String> engineerCodes);
List<OrderInfoEntity> findByDtAndEngineerCode(LocalDate date, String engineerCode); List<OrderInfoEntity> findByDtAndEngineerCode(LocalDate date, String engineerCode);
......
...@@ -100,5 +100,15 @@ public class DispatchEngineerOrderListResp { ...@@ -100,5 +100,15 @@ public class DispatchEngineerOrderListResp {
private Integer isCutoff = 0; private Integer isCutoff = 0;
private String beanTags; private String beanTags;
/**
* 辅助工程师工号
*/
private String engineerCodeSub = "";
/**
* 是否是辅助单
*/
private Boolean isSub = false;
} }
} }
...@@ -3,6 +3,7 @@ package com.dituhui.pea.order.dto; ...@@ -3,6 +3,7 @@ package com.dituhui.pea.order.dto;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -103,6 +104,31 @@ public class OrderServiceDetailResp { ...@@ -103,6 +104,31 @@ public class OrderServiceDetailResp {
* 是否超派,0否 1是,默认0 * 是否超派,0否 1是,默认0
*/ */
private Integer transcend; private Integer transcend;
/**
* 辅助工程师工号
*/
private String engineerCodeSub = "";
/**
* 计划开始时间
*/
private String planStartTime;
/**
* 计划结束时间
*/
private String planEndTime;
/**
* 开始服务时间
*/
private String actualStartTime;
/**
* 结束服务时间
*/
private String actualEndTime;
// //
// @Data // @Data
// @JsonInclude(JsonInclude.Include.NON_NULL) // @JsonInclude(JsonInclude.Include.NON_NULL)
......
...@@ -10,7 +10,6 @@ import com.dituhui.pea.order.common.TimeUtils; ...@@ -10,7 +10,6 @@ import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.common.jackson.JsonUtil; import com.dituhui.pea.order.common.jackson.JsonUtil;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.*; import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.dto.param.CapacityQueryDTO;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.*; import com.dituhui.pea.order.enums.*;
import com.dituhui.pea.order.service.CommonService; import com.dituhui.pea.order.service.CommonService;
...@@ -172,9 +171,9 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -172,9 +171,9 @@ public class DispatchServiceImpl implements DispatchService {
} }
// 获取engineerCodes // 获取engineerCodes
List<String> engineerCodes = engineers.stream().map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList()); List<String> engineerCodes = engineers.stream().map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList());
Set<String> skillGroupCodes = Sets.newConcurrentHashSet();
if (CollectionUtils.isNotEmpty(reqDTO.getOrderIds())) { if (CollectionUtils.isNotEmpty(reqDTO.getOrderIds())) {
List<OrderInfoEntity> infoEntities = orderInfoDao.findAllByOrderIdIn(reqDTO.getOrderIds()); List<OrderInfoEntity> infoEntities = orderInfoDao.findAllByOrderIdIn(reqDTO.getOrderIds());
Set<String> skillGroupCodes = Sets.newConcurrentHashSet();
for (OrderInfoEntity orderInfo : infoEntities) { for (OrderInfoEntity orderInfo : infoEntities) {
//查询对应的技能信息 //查询对应的技能信息
SkillInfoEntity skill = skillInfo.get(String.format("%s%s%s", orderInfo.getBrand(), orderInfo.getType(), orderInfo.getSkill())); SkillInfoEntity skill = skillInfo.get(String.format("%s%s%s", orderInfo.getBrand(), orderInfo.getType(), orderInfo.getSkill()));
...@@ -183,11 +182,12 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -183,11 +182,12 @@ public class DispatchServiceImpl implements DispatchService {
} }
skillGroupCodes.add(skill.getSkillGroupCode()); skillGroupCodes.add(skill.getSkillGroupCode());
} }
engineerCodes = handleEngineerLeave(engineerCodes, date, skillGroupCodes);
} }
engineerCodes = handleEngineerLeave(engineerCodes, date, skillGroupCodes);
// 获取技术员已指派单列表 // 获取技术员已指派单列表
Map<String, List<OrderInfoEntity>> engineerOrders = this.queryEngineerOrders(engineerCodes, date); Map<String, List<OrderInfoEntity>> engineerOrders = this.queryEngineerOrders(engineerCodes, date);
Map<String, List<OrderInfoEntity>> subEngineerOrders = this.querySubEngineerOrders(engineerCodes, date);
// 获取技术员的容量 // 获取技术员的容量
HashMap<String, CapacityEngineerStatEntity> engineerCap = this.queryCapacityEngineerStat(engineerCodes, reqDTO.getDate()); HashMap<String, CapacityEngineerStatEntity> engineerCap = this.queryCapacityEngineerStat(engineerCodes, reqDTO.getDate());
...@@ -202,8 +202,10 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -202,8 +202,10 @@ public class DispatchServiceImpl implements DispatchService {
// 技术员已指派的订单列表 // 技术员已指派的订单列表
List<OrderInfoEntity> records = engineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>()); List<OrderInfoEntity> records = engineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>());
List<OrderInfoEntity> subRecords = subEngineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>());
records.addAll(subRecords);
for (OrderInfoEntity o : records) { for (OrderInfoEntity o : records) {
addOrderToItems(o, items, skillInfo, true); addOrderToItems(o, items, skillInfo, true, e.getEngineerCode());
} }
// 获取容量 // 获取容量
...@@ -245,10 +247,12 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -245,10 +247,12 @@ public class DispatchServiceImpl implements DispatchService {
private List<String> handleEngineerLeave(List<String> engineerCodes, LocalDate targetDate, Set<String> skillGroupCodes) { private List<String> handleEngineerLeave(List<String> engineerCodes, LocalDate targetDate, Set<String> skillGroupCodes) {
List engineerCodes2 = new ArrayList(); List engineerCodes2 = new ArrayList();
for (String engineerCode : engineerCodes) { for (String engineerCode : engineerCodes) {
if (CollectionUtils.isNotEmpty(skillGroupCodes)) {
List skilllEngineerCodes = engineerInfoDao.findByEngineerCodesBySkillCodes(engineerCode, skillGroupCodes); List skilllEngineerCodes = engineerInfoDao.findByEngineerCodesBySkillCodes(engineerCode, skillGroupCodes);
if (skilllEngineerCodes.size() < skillGroupCodes.size()) { if (skilllEngineerCodes.size() < skillGroupCodes.size()) {
continue; continue;
} }
}
//获取工作队休息时间, 判定目标时间是否在工作队休息日中 //获取工作队休息时间, 判定目标时间是否在工作队休息日中
if (!engineerCalendarService.engineerTargetLeave(engineerCode, targetDate)) { if (!engineerCalendarService.engineerTargetLeave(engineerCode, targetDate)) {
engineerCodes2.add(engineerCode); engineerCodes2.add(engineerCode);
...@@ -257,7 +261,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -257,7 +261,7 @@ public class DispatchServiceImpl implements DispatchService {
return engineerCodes2; return engineerCodes2;
} }
private void addOrderToItems(OrderInfoEntity o, List<DispatchEngineerOrderListResp.OrderInfo> items, HashMap<String, SkillInfoEntity> skillInfo, boolean isContinue) { private void addOrderToItems(OrderInfoEntity o, List<DispatchEngineerOrderListResp.OrderInfo> items, HashMap<String, SkillInfoEntity> skillInfo, boolean isContinue, String engineerCode) {
DispatchEngineerOrderListResp.OrderInfo item = new DispatchEngineerOrderListResp.OrderInfo(); DispatchEngineerOrderListResp.OrderInfo item = new DispatchEngineerOrderListResp.OrderInfo();
item.setOrderId(o.getOrderId()); item.setOrderId(o.getOrderId());
item.setDescription(String.format("%s:%s-%s-%s\n%s:%s-%s-%s", o.getOrderId(), o.getBrand(), o.getType(), item.setDescription(String.format("%s:%s-%s-%s\n%s:%s-%s-%s", o.getOrderId(), o.getBrand(), o.getType(),
...@@ -309,11 +313,15 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -309,11 +313,15 @@ public class DispatchServiceImpl implements DispatchService {
item.setIsSpecialTime(o.getIsSpecialTime()); item.setIsSpecialTime(o.getIsSpecialTime());
item.setIsCutoff(o.getIsCutoff()); item.setIsCutoff(o.getIsCutoff());
item.setBeanTags(o.getBeanTags()); item.setBeanTags(o.getBeanTags());
item.setEngineerCodeSub(o.getEngineerCodeSub());
if (StringUtils.isNotBlank(o.getEngineerCodeSub()) && o.getIsMultiple() == 1 && o.getEngineerCodeSub().equals(engineerCode)) {
item.setIsSub(true);
}
if (isContinue && StringUtils.isNotEmpty(o.getMultipleOrders())) { if (isContinue && StringUtils.isNotEmpty(o.getMultipleOrders())) {
List<OrderInfoEntity> byMultipleOrders = orderInfoDao.findByMultipleOrdersAndOrderIdNot(o.getMultipleOrders(), o.getOrderId()); List<OrderInfoEntity> byMultipleOrders = orderInfoDao.findByMultipleOrdersAndOrderIdNot(o.getMultipleOrders(), o.getOrderId());
List<DispatchEngineerOrderListResp.OrderInfo> multipleItems = new ArrayList<>(); List<DispatchEngineerOrderListResp.OrderInfo> multipleItems = new ArrayList<>();
for (OrderInfoEntity info : byMultipleOrders) { for (OrderInfoEntity info : byMultipleOrders) {
addOrderToItems(info, multipleItems, skillInfo, false); addOrderToItems(info, multipleItems, skillInfo, false, engineerCode);
} }
item.setMultipleOrderList(multipleItems); item.setMultipleOrderList(multipleItems);
} }
...@@ -651,7 +659,6 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -651,7 +659,6 @@ public class DispatchServiceImpl implements DispatchService {
private Map<String, List<OrderInfoEntity>> queryEngineerOrders(List<String> engineerCodes, LocalDate date) { private Map<String, List<OrderInfoEntity>> queryEngineerOrders(List<String> engineerCodes, LocalDate date) {
// 获取工程师服务单列表 // 获取工程师服务单列表
List<OrderInfoEntity> records = orderInfoDao.findByDtAndEngineerCodeIn(date, engineerCodes); List<OrderInfoEntity> records = orderInfoDao.findByDtAndEngineerCodeIn(date, engineerCodes);
// 排序 // 排序
records.sort(Comparator.comparing(OrderInfoEntity::getEngineerCode)); records.sort(Comparator.comparing(OrderInfoEntity::getEngineerCode));
records.sort(Comparator.comparing(OrderInfoEntity::getPlanStartTime)); records.sort(Comparator.comparing(OrderInfoEntity::getPlanStartTime));
...@@ -665,6 +672,23 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -665,6 +672,23 @@ public class DispatchServiceImpl implements DispatchService {
} }
private Map<String, List<OrderInfoEntity>> querySubEngineerOrders(List<String> engineerCodes, LocalDate date) {
// 获取工程师服务单列表
List<OrderInfoEntity> subRecords = orderInfoDao.findByDtAndEngineerCodeSubIn(date, engineerCodes);
// 排序
subRecords.sort(Comparator.comparing(OrderInfoEntity::getEngineerCode));
subRecords.sort(Comparator.comparing(OrderInfoEntity::getPlanStartTime));
//过滤
List<OrderInfoEntity> orders = subRecords.stream()
.filter(r -> !r.getOrderStatus().equals(OrderStatusEnum.CANCELED))
.collect(Collectors.toList());
return orders.stream().collect(Collectors.groupingBy(OrderInfoEntity::getEngineerCodeSub));
}
public List<EngineerInfoEntity> queryEngineers(List<String> teamIds, List<String> engineerCodes, String key) { public List<EngineerInfoEntity> queryEngineers(List<String> teamIds, List<String> engineerCodes, String key) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<EngineerInfoEntity> criteriaQuery = criteriaBuilder.createQuery(EngineerInfoEntity.class); CriteriaQuery<EngineerInfoEntity> criteriaQuery = criteriaBuilder.createQuery(EngineerInfoEntity.class);
......
...@@ -439,6 +439,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -439,6 +439,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
MsgDTO msgDTO = new MsgDTO(); MsgDTO msgDTO = new MsgDTO();
msgDTO.setBranchId(branchId); msgDTO.setBranchId(branchId);
msgDTO.setType(0); msgDTO.setType(0);
msgDTO.setTag(orderInfo.getBeanPriority().equals("1") ? 0 : 1);
msgDTO.setOrderIds(orderId); msgDTO.setOrderIds(orderId);
msgDTO.setContent(String.format("有1条预约日期在%s的工单需人工外理,标签是(%s),单号:%S", toLocalDate, String.join(",", OrderUtil.handleTags(orderInfo)), orderId)); msgDTO.setContent(String.format("有1条预约日期在%s的工单需人工外理,标签是(%s),单号:%S", toLocalDate, String.join(",", OrderUtil.handleTags(orderInfo)), orderId));
msgService.add(msgDTO); msgService.add(msgDTO);
......
...@@ -371,7 +371,7 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -371,7 +371,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
teamId = null; teamId = null;
order.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name()); order.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name());
order.setAppointmentStatus(OrderFlowEnum.INIT.name()); order.setAppointmentStatus(OrderFlowEnum.INIT.name());
sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin()); sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin(), order);
} }
} else { } else {
// a.已派人-改约到未来 // a.已派人-改约到未来
...@@ -408,7 +408,7 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -408,7 +408,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
teamId = null; teamId = null;
order.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name()); order.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name());
order.setAppointmentStatus(OrderFlowEnum.INIT.name()); order.setAppointmentStatus(OrderFlowEnum.INIT.name());
sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin()); sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin(), order);
} }
} }
} else if (!isToday && !isBelong) { } else if (!isToday && !isBelong) {
...@@ -424,7 +424,7 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -424,7 +424,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
teamId = null; teamId = null;
order.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name()); order.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name());
order.setAppointmentStatus(OrderFlowEnum.INIT.name()); order.setAppointmentStatus(OrderFlowEnum.INIT.name());
sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin()); sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin(), order);
} }
} }
...@@ -878,7 +878,7 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -878,7 +878,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
order.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name()); order.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name());
order.setAppointmentStatus(OrderFlowEnum.INIT.name()); order.setAppointmentStatus(OrderFlowEnum.INIT.name());
OrgBranchEntity branchEntity = orgBranchDao.findByCitycodeListLike("%" + adminDistrict.getResult().getSubNames().getCity() + "%"); OrgBranchEntity branchEntity = orgBranchDao.findByCitycodeListLike("%" + adminDistrict.getResult().getSubNames().getCity() + "%");
sendMsg(branchEntity.getBranchId(), order.getOrderId(), req.getExpectBegin()); sendMsg(branchEntity.getBranchId(), order.getOrderId(), req.getExpectBegin(), order);
} else { } else {
// 根据分单工作队,填写clusterId/branchId/groupId/teamId等 // 根据分单工作队,填写clusterId/branchId/groupId/teamId等
OrgTeamInfo teamInfo = fendanResult.getResult(); OrgTeamInfo teamInfo = fendanResult.getResult();
...@@ -908,19 +908,19 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -908,19 +908,19 @@ public class OrderInfoServiceImpl implements OrderInfoService {
order.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name()); order.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name());
order.setAppointmentStatus(OrderFlowEnum.INIT.name()); order.setAppointmentStatus(OrderFlowEnum.INIT.name());
//发送通知分部消息 //发送通知分部消息
sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin()); sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin(), order);
} }
} }
return order; return order;
} }
private void sendMsg(String branchId, String orderId, String reservationTime) { private void sendMsg(String branchId, String orderId, String reservationTime, OrderInfoEntity order) {
//发送通知分部消息 //发送通知分部消息
MsgDTO msgDTO = new MsgDTO(); MsgDTO msgDTO = new MsgDTO();
msgDTO.setBranchId(branchId); msgDTO.setBranchId(branchId);
msgDTO.setType(0); msgDTO.setType(0);
msgDTO.setOrderIds(orderId); msgDTO.setOrderIds(orderId);
msgDTO.setTag(1); msgDTO.setTag(order.getBeanPriority().equals("1") ? 0 : 1);
msgDTO.setContent("有1条预约日期在" + reservationTime + "的工单需人工外理"); msgDTO.setContent("有1条预约日期在" + reservationTime + "的工单需人工外理");
msgService.add(msgDTO); msgService.add(msgDTO);
} }
......
...@@ -116,6 +116,11 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -116,6 +116,11 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
res.setMultipleOrders(order.getMultipleOrders()); res.setMultipleOrders(order.getMultipleOrders());
res.setBeanTags(order.getBeanTags()); res.setBeanTags(order.getBeanTags());
res.setTranscend(order.getTranscend()); res.setTranscend(order.getTranscend());
res.setEngineerCodeSub(order.getEngineerCodeSub());
res.setPlanStartTime(TimeUtils.IsoLocalDateTime2String(order.getPlanStartTime()));
res.setPlanEndTime(TimeUtils.IsoLocalDateTime2String(order.getPlanEndTime()));
res.setActualStartTime(TimeUtils.IsoLocalDateTime2String(order.getActualStartTime()));
res.setActualEndTime(TimeUtils.IsoLocalDateTime2String(order.getActualEndTime()));
return Result.success(res); return Result.success(res);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!