Commit 7b2db42d by 张晓

Merge branch 'develop' of https://gitlab.dituhui.com/bsh/project/project into develop

2 parents 9cb3db32 dc59e8c0
package com.dituhui.pea.order.common; package com.dituhui.pea.order.common;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import lombok.Data; import lombok.Data;
...@@ -21,11 +22,6 @@ import java.util.stream.Collectors; ...@@ -21,11 +22,6 @@ import java.util.stream.Collectors;
@Component @Component
@Slf4j @Slf4j
public class OrderAssignCheck { public class OrderAssignCheck {
@Autowired
OrderRequestMPDao orderRequestMPDao;
@Autowired
OrderAppointmentMPDao orderAppointmentMPDao;
@Autowired @Autowired
SkillInfoMPDao skillInfoMPDao; SkillInfoMPDao skillInfoMPDao;
...@@ -39,6 +35,9 @@ public class OrderAssignCheck { ...@@ -39,6 +35,9 @@ public class OrderAssignCheck {
@Autowired @Autowired
OrgGroupMPDao orgGroupMPDao; OrgGroupMPDao orgGroupMPDao;
@Autowired
OrderInfoMPDao orderInfoMPDao;
@Data @Data
public class Result { public class Result {
private Boolean canAssign; private Boolean canAssign;
...@@ -63,7 +62,7 @@ public class OrderAssignCheck { ...@@ -63,7 +62,7 @@ public class OrderAssignCheck {
public Result orderAssignCheck(String orderId, String engineerCode) { public Result orderAssignCheck(String orderId, String engineerCode) {
log.info("begin orderAssignCheck:orderId={}, engineerCode={}", orderId, engineerCode); log.info("begin orderAssignCheck:orderId={}, engineerCode={}", orderId, engineerCode);
OrderRequest order = orderRequestMPDao.getByOrderId(orderId); OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
double curX = Double.parseDouble(order.getX()); double curX = Double.parseDouble(order.getX());
double curY = Double.parseDouble(order.getY()); double curY = Double.parseDouble(order.getY());
...@@ -142,33 +141,22 @@ public class OrderAssignCheck { ...@@ -142,33 +141,22 @@ public class OrderAssignCheck {
private List<OrderSegment> getEngineerOrderSegments(String engineerCode, LocalDate dt) { private List<OrderSegment> getEngineerOrderSegments(String engineerCode, LocalDate dt) {
List<OrderSegment> orderSegments = new ArrayList<>(); List<OrderSegment> orderSegments = new ArrayList<>();
List<OrderAppointment> appointments = orderAppointmentMPDao.selectByEngineerCodeAndDt(engineerCode, dt); LambdaQueryWrapper<OrderInfo> lqw = new LambdaQueryWrapper<>();
List<String> orderIds = new ArrayList<>(); lqw.eq(OrderInfo::getDt, dt);
for (OrderAppointment o: appointments) { lqw.eq(OrderInfo::getEngineerCode, engineerCode);
// 过滤掉已经取消的订单 lqw.eq(OrderInfo::getOrderStatus, "NORMAL");
if(o.getStatus().equals("NOT_ASSIGNED") || o.getStatus().equals("CANCELED")) { lqw.in(OrderInfo::getAppointmentStatus, List.of("PRE", "CONFIRM"));
continue; List<OrderInfo> appointments = orderInfoMPDao.selectList(lqw);
} if(appointments.isEmpty()){
orderIds.add(o.getOrderId());
}
if(orderIds.isEmpty()){
return orderSegments; return orderSegments;
} }
for(OrderInfo o: appointments) {
Map<String, List<OrderAppointment>> m = appointments.stream().collect(Collectors.groupingBy(OrderAppointment::getOrderId));
List<OrderRequest> orderRequests = orderRequestMPDao.selectByOrderIds(orderIds);
for(OrderRequest o: orderRequests) {
List<OrderAppointment> tmp = m.getOrDefault(o.getOrderId(), new ArrayList<>());
if(tmp.isEmpty()) {
continue;
}
OrderAppointment oa = tmp.get(0);
OrderSegment seg = new OrderSegment(); OrderSegment seg = new OrderSegment();
seg.setOrderId(o.getOrderId()); seg.setOrderId(o.getOrderId());
seg.setX(Double.parseDouble(o.getX())); seg.setX(Double.parseDouble(o.getX()));
seg.setY(Double.parseDouble(o.getY())); seg.setY(Double.parseDouble(o.getY()));
seg.setStart(this.timestamp2Point(oa.getExpectStartTime())); seg.setStart(this.timestamp2Point(o.getPlanStartTime()));
seg.setEnd(this.timestamp2Point(oa.getExpectEndTime())); seg.setEnd(this.timestamp2Point(o.getPlanEndTime()));
orderSegments.add(seg); orderSegments.add(seg);
} }
......
...@@ -24,10 +24,8 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -24,10 +24,8 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
@Autowired @Autowired
private CapacityEngineerStatDao capacityEngineerStatDao; private CapacityEngineerStatDao capacityEngineerStatDao;
@Autowired @Autowired
private EngineerInfoDao engineerInfoDao; private EngineerInfoDao engineerInfoDao;
@Autowired @Autowired
private EngineerUtils engineerUtils; private EngineerUtils engineerUtils;
@Autowired @Autowired
...@@ -38,9 +36,11 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -38,9 +36,11 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
private String getHourMinute(LocalDateTime time){ private String getHourMinute(LocalDateTime time){
return this.getHourMinute(time, 0); return this.getHourMinute(time, 0);
} }
private String getHourMinute(LocalDateTime time, int deltaMinute){ private String getHourMinute(LocalDateTime time, int deltaMinute){
return DateUtils.formatDateTime(time.plusMinutes(deltaMinute), "HH:mm"); return DateUtils.formatDateTime(time.plusMinutes(deltaMinute), "HH:mm");
} }
@Override @Override
public Result<?> getEngineersGanttList(EngineersGanttDTO.Request reqDTO) { public Result<?> getEngineersGanttList(EngineersGanttDTO.Request reqDTO) {
// 按日期返回技术员们当天的服务甘特图,不需要翻页 // 按日期返回技术员们当天的服务甘特图,不需要翻页
...@@ -59,8 +59,13 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -59,8 +59,13 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
EngineersGanttDTO.Slot slot = new EngineersGanttDTO.Slot(); EngineersGanttDTO.Slot slot = new EngineersGanttDTO.Slot();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX // todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
slot.setOrderId(e.getOrderId()); slot.setOrderId(e.getOrderId());
slot.setBtime(getHourMinute(e.getPlanStartTime())); if (checkOrderIsFinish(e.getServiceStatus())) {
slot.setEtime(getHourMinute(e.getPlanEndTime())); slot.setBtime(getHourMinute(e.getActualStartTime()));
slot.setEtime(getHourMinute(e.getActualEndTime()));
} else {
slot.setBtime(getHourMinute(e.getPlanStartTime()));
slot.setEtime(getHourMinute(e.getPlanEndTime()));
}
slot.setTooltip(getOrderTips(e.getOrderId())); slot.setTooltip(getOrderTips(e.getOrderId()));
OrderSkillProjection orderSkill = orderInfoDao.getOrderSkillCaptionByOrderId(e.getOrderId()); OrderSkillProjection orderSkill = orderInfoDao.getOrderSkillCaptionByOrderId(e.getOrderId());
if (orderSkill != null) { if (orderSkill != null) {
...@@ -78,8 +83,13 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -78,8 +83,13 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
if(e.getArriveElapsed() > 0) { if(e.getArriveElapsed() > 0) {
// 有在途,起止时间,分别是订单的开始时间减去在途时间、订单的开始时间 // 有在途,起止时间,分别是订单的开始时间减去在途时间、订单的开始时间
slot = new EngineersGanttDTO.Slot(); slot = new EngineersGanttDTO.Slot();
slot.setBtime(getHourMinute(e.getPlanStartTime(), -e.getArriveElapsed())); if (checkOrderIsFinish(e.getServiceStatus())) {
slot.setEtime(getHourMinute(e.getPlanStartTime())); slot.setBtime(getHourMinute(e.getActualStartTime(), -e.getArriveElapsed()));
slot.setEtime(getHourMinute(e.getActualStartTime()));
} else {
slot.setBtime(getHourMinute(e.getPlanStartTime(), -e.getArriveElapsed()));
slot.setEtime(getHourMinute(e.getPlanStartTime()));
}
slot.setShapeSize("mini"); slot.setShapeSize("mini");
slot.setBgColor(getColor("ONWAY")); slot.setBgColor(getColor("ONWAY"));
slots.add(slot); slots.add(slot);
...@@ -150,12 +160,6 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -150,12 +160,6 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
} }
} }
public Map<String, OrderInfoEntity> getOrdersByOrderIds(List<String> orderIds) {
List<OrderInfoEntity> orders = orderInfoDao.findAllByOrderIdIn(orderIds);
return orders.stream().collect(Collectors.toMap(OrderInfoEntity::getOrderId, order -> order));
}
private List<LabelValueDTO> getOrderTips(String orderId) { private List<LabelValueDTO> getOrderTips(String orderId) {
// log.info("==> getOrderTips: orderId[{}]", orderId); // log.info("==> getOrderTips: orderId[{}]", orderId);
OrderInfoEntity order = orderInfoDao.getByOrderId(orderId); OrderInfoEntity order = orderInfoDao.getByOrderId(orderId);
...@@ -174,6 +178,10 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -174,6 +178,10 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
return tips; return tips;
} }
private boolean checkOrderIsFinish(String serviceStatus){
String[] array = {"FINISHED", "UNFINISHED"};
return Arrays.asList(array).contains(serviceStatus);
}
private String getColor(String colorType){ private String getColor(String colorType){
String[][] bgColor = { String[][] bgColor = {
......
...@@ -149,7 +149,7 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -149,7 +149,7 @@ public class OrderAssignImpl implements OrderAssign {
Timestamp planStartTime = Timestamp.valueOf(result.getStart()); Timestamp planStartTime = Timestamp.valueOf(result.getStart());
Timestamp planEndTime = Timestamp.valueOf(result.getEnd()); Timestamp planEndTime = Timestamp.valueOf(result.getEnd());
// 更新order_request表状态 // 更新order_info表状态
LambdaUpdateWrapper<OrderInfo> wrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<OrderInfo> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(OrderInfo::getAppointmentStatus, "CONFIRM"); wrapper.set(OrderInfo::getAppointmentStatus, "CONFIRM");
wrapper.set(OrderInfo::getAppointmentMethod, "MANUAL"); wrapper.set(OrderInfo::getAppointmentMethod, "MANUAL");
......
...@@ -3,6 +3,7 @@ package com.dituhui.pea.order.service.impl; ...@@ -3,6 +3,7 @@ package com.dituhui.pea.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dituhui.pea.common.BusinessException; import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.ListUtils;
import com.dituhui.pea.order.common.TimeUtils; import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.*; import com.dituhui.pea.order.dto.*;
...@@ -127,11 +128,18 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -127,11 +128,18 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
Comparator<OrderInfo> dtDesc = Comparator.comparing(OrderInfo::getDt).reversed(); Comparator<OrderInfo> dtDesc = Comparator.comparing(OrderInfo::getDt).reversed();
List<OrderInfo> results = orders.stream().sorted(dtDesc).collect(Collectors.toList()); List<OrderInfo> results = orders.stream().sorted(dtDesc).collect(Collectors.toList());
LocalDate lastDt = results.get(0).getDt(); LocalDate lastDt = results.get(0).getDt(); //最新预约
List<OrderAppointmentListResp.OrderAppointment> items = new ArrayList<>(); List<OrderAppointmentListResp.OrderAppointment> items = new ArrayList<>();
for (OrderInfo o : results) { for (OrderInfo o : results) {
EngineerInfo eg = egInfo.getOrDefault(o.getEngineerCode(), null); EngineerInfo eg = egInfo.getOrDefault(o.getEngineerCode(), null);
if(eg == null) {
log.warn("未获得工程师{}基础信息, 订单:{}", o.getEngineerCode(), o.getOrderId());
continue;
}
String skill = egSkill.getOrDefault(o.getEngineerCode(), null); String skill = egSkill.getOrDefault(o.getEngineerCode(), null);
if(skill == null) {
log.warn("未获得工程师{}基础技能, 订单:{}", o.getEngineerCode(), o.getOrderId());
}
// 获取工程师姓名 // 获取工程师姓名
String engineerName = (eg != null) ? eg.getName() : o.getEngineerCode(); String engineerName = (eg != null) ? eg.getName() : o.getEngineerCode();
...@@ -146,7 +154,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -146,7 +154,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
item.setTitle(title); item.setTitle(title);
item.setEngineerCode(o.getEngineerCode()); item.setEngineerCode(o.getEngineerCode());
item.setExpectTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeBegin())); item.setExpectTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeBegin()));
item.setTimelines(this.packOrderTimeline(timelines.get(o.getSubId()))); item.setTimelines(this.packOrderTimeline(timelines.getOrDefault(o.getSubId(), null)));
item.setItems(this.packEngineerItems(eg, skill, groups.get(eg.getGroupId()))); item.setItems(this.packEngineerItems(eg, skill, groups.get(eg.getGroupId())));
items.add(item); items.add(item);
...@@ -365,7 +373,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -365,7 +373,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
private List<KV> packOrderTimeline(List<OrderTimeline> timelines) { private List<KV> packOrderTimeline(List<OrderTimeline> timelines) {
List<KV> items = new ArrayList<>(); List<KV> items = new ArrayList<>();
if (timelines == null) { if(ListUtils.isEmpty(timelines)){
return items; return items;
} }
for (OrderTimeline o : timelines) { for (OrderTimeline o : timelines) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!