Commit 882cb848 by 丁伟峰

在途信息的返回

1 parent f3e5ad02
...@@ -33,11 +33,11 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -33,11 +33,11 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
@Autowired @Autowired
private EngineerBusinessDao engineerBusinessDao; private EngineerBusinessDao engineerBusinessDao;
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");
} }
...@@ -54,51 +54,52 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -54,51 +54,52 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
List<OrderInfoEntity> orders = orderInfoDao.findByDtAndEngineerCodeIn(reqDTO.getDate(), engineerCodes); List<OrderInfoEntity> orders = orderInfoDao.findByDtAndEngineerCodeIn(reqDTO.getDate(), engineerCodes);
HashMap<String, List<EngineersGanttDTO.Slot>> mapEngineers = new HashMap<>(); HashMap<String, List<EngineersGanttDTO.Slot>> mapEngineers = new HashMap<>();
for (OrderInfoEntity e : orders) { for (OrderInfoEntity order : orders) {
// 服务工单本体 // 服务工单本体
EngineersGanttDTO.Slot slot = new EngineersGanttDTO.Slot(); EngineersGanttDTO.Slot slot = new EngineersGanttDTO.Slot();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX // todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
slot.setOrderId(e.getOrderId()); slot.setOrderId(order.getOrderId());
if (checkOrderIsFinish(e.getServiceStatus())) { if (checkOrderIsFinish(order.getServiceStatus())) {
slot.setBtime(getHourMinute(e.getActualStartTime())); slot.setBtime(getHourMinute(order.getActualStartTime()));
slot.setEtime(getHourMinute(e.getActualEndTime())); slot.setEtime(getHourMinute(order.getActualEndTime()));
} else { } else {
slot.setBtime(getHourMinute(e.getPlanStartTime())); slot.setBtime(getHourMinute(order.getPlanStartTime()));
slot.setEtime(getHourMinute(e.getPlanEndTime())); slot.setEtime(getHourMinute(order.getPlanEndTime()));
} }
slot.setTooltip(getOrderTips(e.getOrderId())); slot.setTooltip(getOrderTips(order));
OrderSkillProjection orderSkill = orderInfoDao.getOrderSkillCaptionByOrderId(e.getOrderId()); OrderSkillProjection orderSkill = orderInfoDao.getOrderSkillCaptionByOrderId(order.getOrderId());
if (orderSkill != null) { if (orderSkill != null) {
slot.setText(orderSkill.getSkillCaption()); slot.setText(orderSkill.getSkillCaption());
} }
slot.setBgColor(e.getAppointmentStatus()); slot.setBgColor(order.getAppointmentStatus());
List<EngineersGanttDTO.Slot> slots = null; List<EngineersGanttDTO.Slot> slots = null;
if (mapEngineers.containsKey(e.getEngineerCode())) { if (mapEngineers.containsKey(order.getEngineerCode())) {
slots = mapEngineers.get(e.getEngineerCode()); slots = mapEngineers.get(order.getEngineerCode());
} else { } else {
slots = new ArrayList<>(); slots = new ArrayList<>();
} }
slot.setBgColor(getColor(e.getServiceStatus())); slot.setBgColor(getColor(order.getServiceStatus()));
if (!e.getAppointmentStatus().equals("CONFIRM")) { if (!order.getAppointmentStatus().equals("CONFIRM")) {
slot.setBorderStyle("dashed"); // 未确认的指派,统一加上虚框 slot.setBorderStyle("dashed"); // 未确认的指派,统一加上虚框
} }
slots.add(slot); slots.add(slot);
if(e.getArriveElapsed() > 0) { if (order.getArriveElapsed() > 0) {
// 有在途,起止时间,分别是订单的开始时间减去在途时间、订单的开始时间 // 有在途,起止时间,分别是订单的开始时间减去在途时间、订单的开始时间
slot = new EngineersGanttDTO.Slot(); slot = new EngineersGanttDTO.Slot();
if (checkOrderIsFinish(e.getServiceStatus())) { if (checkOrderIsFinish(order.getServiceStatus())) {
slot.setBtime(getHourMinute(e.getActualStartTime(), -e.getArriveElapsed())); slot.setBtime(getHourMinute(order.getActualStartTime(), -order.getArriveElapsed()));
slot.setEtime(getHourMinute(e.getActualStartTime())); slot.setEtime(getHourMinute(order.getActualStartTime()));
} else { } else {
slot.setBtime(getHourMinute(e.getPlanStartTime(), -e.getArriveElapsed())); slot.setBtime(getHourMinute(order.getPlanStartTime(), -order.getArriveElapsed()));
slot.setEtime(getHourMinute(e.getPlanStartTime())); slot.setEtime(getHourMinute(order.getPlanStartTime()));
} }
slot.setShapeSize("mini"); slot.setShapeSize("mini");
slot.setBgColor(getColor("ONWAY")); slot.setBgColor(getColor("ONWAY"));
slot.setTooltip(getOnwayTips(order));
slots.add(slot); slots.add(slot);
} }
slots.sort(Comparator.comparing(EngineersGanttDTO.Slot::getBtime)); slots.sort(Comparator.comparing(EngineersGanttDTO.Slot::getBtime));
mapEngineers.put(e.getEngineerCode(), slots); mapEngineers.put(order.getEngineerCode(), slots);
} }
log.info("mapEngineers ===> {}", mapEngineers); log.info("mapEngineers ===> {}", mapEngineers);
List<EngineersGanttDTO.GanttChart> engineers = new ArrayList<>(); List<EngineersGanttDTO.GanttChart> engineers = new ArrayList<>();
...@@ -163,15 +164,29 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -163,15 +164,29 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
} }
} }
private List<LabelValueDTO> getOrderTips(String orderId) { private List<LabelValueDTO> getOnwayTips(OrderInfoEntity order) {
// log.info("==> getOrderTips: orderId[{}]", orderId); // log.info("==> getOrderTips: orderId[{}]", orderId);
OrderInfoEntity order = orderInfoDao.getByOrderId(orderId); List<LabelValueDTO> tips = new ArrayList<>();
if (order == null) { tips.add(new LabelValueDTO().setLabel("工单号码").setValue(order.getOrderId()));
log.error("对应的订单不存在!{}", orderId); String btime = null;
return null; String etime = null;
if (checkOrderIsFinish(order.getServiceStatus())) {
btime = getHourMinute(order.getActualStartTime(), -order.getArriveElapsed());
etime = getHourMinute(order.getActualStartTime());
} else {
btime = getHourMinute(order.getPlanStartTime(), -order.getArriveElapsed());
etime = getHourMinute(order.getPlanStartTime());
}
tips.add(new LabelValueDTO().setLabel("在途路程").setValue(String.format("%s米", order.getArriveDistance())));
tips.add(new LabelValueDTO().setLabel("在途时间").setValue(String.format("%s-%s", btime, etime)));
tips.add(new LabelValueDTO().setLabel("在途耗时").setValue(String.format("%s分钟", order.getArriveElapsed())));
return tips;
} }
private List<LabelValueDTO> getOrderTips(OrderInfoEntity order) {
// log.info("==> getOrderTips: orderId[{}]", orderId);
List<LabelValueDTO> tips = new ArrayList<>(); List<LabelValueDTO> tips = new ArrayList<>();
tips.add(new LabelValueDTO().setLabel("工单号码").setValue(orderId)); tips.add(new LabelValueDTO().setLabel("工单号码").setValue(order.getOrderId()));
tips.add(new LabelValueDTO().setLabel("类型/品牌").setValue(String.format("%s %s", order.getBrand(), order.getType()))); tips.add(new LabelValueDTO().setLabel("类型/品牌").setValue(String.format("%s %s", order.getBrand(), order.getType())));
tips.add(new LabelValueDTO().setLabel("电话/地址").setValue(String.format("%s %s\n %s", order.getName(), order.getPhone(), order.getAddress()))); tips.add(new LabelValueDTO().setLabel("电话/地址").setValue(String.format("%s %s\n %s", order.getName(), order.getPhone(), order.getAddress())));
tips.add(new LabelValueDTO().setLabel("标签").setValue(order.getTags())); tips.add(new LabelValueDTO().setLabel("标签").setValue(order.getTags()));
...@@ -187,12 +202,13 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -187,12 +202,13 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
return tips; return tips;
} }
private boolean checkOrderIsFinish(String serviceStatus){
private boolean checkOrderIsFinish(String serviceStatus) {
String[] array = {"FINISHED", "UNFINISHED"}; String[] array = {"FINISHED", "UNFINISHED"};
return Arrays.asList(array).contains(serviceStatus); return Arrays.asList(array).contains(serviceStatus);
} }
private String getColor(String colorType){ private String getColor(String colorType) {
String[][] bgColor = { String[][] bgColor = {
{"INIT", "#FFAA44"}, // 待定 {"INIT", "#FFAA44"}, // 待定
{"FINISHED", "#016FFF"}, //完成 {"FINISHED", "#016FFF"}, //完成
...@@ -205,7 +221,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -205,7 +221,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
{"LEAVE", "#A8ABA9"}, //请假 {"LEAVE", "#A8ABA9"}, //请假
{"WAREHOUSE", "#EDEDED"}, //仓库准备 {"WAREHOUSE", "#EDEDED"}, //仓库准备
}; };
Map<String, String> bgColorMap = Arrays.stream(bgColor).collect(Collectors.toMap(pair -> pair[0], pair->pair[1])); Map<String, String> bgColorMap = Arrays.stream(bgColor).collect(Collectors.toMap(pair -> pair[0], pair -> pair[1]));
return bgColorMap.getOrDefault(colorType, "#016FFF"); return bgColorMap.getOrDefault(colorType, "#016FFF");
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!