Commit a7aa9448 by wangli

修改,数据库表转化为OrderInfo表

1 parent 74f7ebe3
...@@ -22,10 +22,7 @@ import java.util.stream.Collectors; ...@@ -22,10 +22,7 @@ import java.util.stream.Collectors;
public class OrderServiceDetailImpl implements OrderServiceDetail { public class OrderServiceDetailImpl implements OrderServiceDetail {
@Autowired @Autowired
private OrderRequestMPDao orderRequestMPDao; private OrderInfoMPDao orderInfoMPDao;
@Autowired
private OrderAppointmentMPDao orderAppointmentMPDao;
@Autowired @Autowired
private EngineerInfoMPDao engineerInfoMPDao; private EngineerInfoMPDao engineerInfoMPDao;
...@@ -45,11 +42,12 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -45,11 +42,12 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
@Autowired @Autowired
private SkillInfoMPDao skillInfoMPDao; private SkillInfoMPDao skillInfoMPDao;
@Transactional @Transactional
@Override @Override
public Result<?> getOrderServiceDetail(String orderId) { public Result<?> getOrderServiceDetail(String orderId) {
OrderRequest order = orderRequestMPDao.getByOrderId(orderId); OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
List<KV> items = this.packOrderDetail(order); List<KV> items = this.packOrderDetail(order);
...@@ -66,8 +64,8 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -66,8 +64,8 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
res.setOrderId(orderId); res.setOrderId(orderId);
res.setRisk(""); res.setRisk("");
res.setRiskDesc(""); res.setRiskDesc("");
res.setStatusDesc("打开"); res.setStatusDesc("正常");
res.setStatus(order.getStatus()); res.setStatus(order.getOrderStatus());
res.setAppointmentStatus(order.getAppointmentStatus()); res.setAppointmentStatus(order.getAppointmentStatus());
res.setLocation(String.format("%s,%s", order.getX(), order.getY())); res.setLocation(String.format("%s,%s", order.getX(), order.getY()));
res.setReschedulingParams(detail); res.setReschedulingParams(detail);
...@@ -94,52 +92,44 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -94,52 +92,44 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
@Transactional @Transactional
@Override @Override
public Result<?> getOrderAppointmentList(String orderId) throws BusinessException{ public Result<?> getOrderAppointmentList(String orderId) throws BusinessException {
// 获取预约单里列表 // 获取预约单里列表
OrderAppointmentListResp res = new OrderAppointmentListResp(); OrderAppointmentListResp res = new OrderAppointmentListResp();
OrderRequest order = orderRequestMPDao.getByOrderId(orderId);
if(order == null){
throw new BusinessException("订单不存在");
}
LocalDate curDate = order.getDt();
// 查询预约单列表 // 查询预约单列表
List<OrderAppointment> appoints = orderAppointmentMPDao.selectByOrderId(orderId); List<OrderInfo> orders = orderInfoMPDao.selectByOrderId(orderId);
if (appoints.isEmpty()) { if (orders.isEmpty()) {
// 没有指派单列表,返回 // 没有指派单列表,返回
res.setOrderId(orderId); res.setOrderId(orderId);
res.setOrders(new ArrayList<>()); res.setOrders(new ArrayList<>());
return Result.success(res); return Result.success(res);
} }
// 工程师ID列表
List<String> egCodes = appoints.stream().map(OrderAppointment::getEngineerCode).collect(Collectors.toList());
// 获取工程师基础信息列表 // 获取工程师基础信息列表
HashMap<String, EngineerInfo> egInfo = this.getEngineerInfos(egCodes); Set<String> set = new HashSet<>();
orders.stream().map(OrderInfo::getEngineerCode).forEach(set::add);
orders.stream().map(OrderInfo::getEngineerCodeSub).forEach(set::add);
List<String> engineerCodes = new ArrayList<>(set);
HashMap<String, EngineerInfo> egInfo = this.getEngineerInfos(engineerCodes);
// 获取groupIds 和 group信息 // 获取groupIds 和 group信息
List<String> groupIds = egInfo.values().stream().map(EngineerInfo::getGroupId).collect(Collectors.toList()); List<String> groupIds = egInfo.values().stream().map(EngineerInfo::getGroupId).collect(Collectors.toList());
HashMap<String, OrgGroup> groups = this.queryOrgGroups(groupIds); HashMap<String, OrgGroup> groups = this.queryOrgGroups(groupIds);
// 获取工程师技能列表<engineerCode, skills> // 获取工程师技能列表<engineerCode, skills>
Map<String, String> egSkill = this.getEngineerSkills(egCodes); Map<String, String> egSkill = this.getEngineerSkills(engineerCodes);
// 获取subOrder订单timeline // 获取subOrder订单timeline
Map<String, List<OrderTimeline>> timelines = this.getOrderTimelines(orderId); Map<String, List<OrderTimeline>> timelines = this.getOrderTimelines(orderId);
// 对指派单列表按照subOrderId降序排序, 获取排序的subOrderId列表, 然后根据subOrderId分组 Comparator<OrderInfo> dtDesc = Comparator.comparing(OrderInfo::getDt).reversed();
Comparator<OrderAppointment> sbDesc = Comparator.comparing(OrderAppointment::getSuborderId, String.CASE_INSENSITIVE_ORDER).reversed(); List<OrderInfo> results = orders.stream().sorted(dtDesc).collect(Collectors.toList());
List<OrderAppointment> results = appoints.stream().sorted(sbDesc).collect(Collectors.toList());
String lastSubOrderId = results.get(0).getSuborderId(); LocalDate lastDt = results.get(0).getDt();
List<OrderAppointmentListResp.OrderAppointment> items = new ArrayList<>(); List<OrderAppointmentListResp.OrderAppointment> items = new ArrayList<>();
for (OrderAppointment o : results) { for (OrderInfo o : results) {
String subOrderId = o.getSuborderId();
EngineerInfo eg = egInfo.getOrDefault(o.getEngineerCode(), null); EngineerInfo eg = egInfo.getOrDefault(o.getEngineerCode(), null);
String skill = egSkill.getOrDefault(o.getEngineerCode(), null); String skill = egSkill.getOrDefault(o.getEngineerCode(), null);
...@@ -148,15 +138,15 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -148,15 +138,15 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 获取title // 获取title
String title = engineerName; String title = engineerName;
if (!lastSubOrderId.equals(subOrderId) || o.getDt().isBefore(curDate)) { if (o.getDt().isBefore(lastDt)) {
title = String.format("%s_%s", engineerName, TimeUtils.IsoLocalDate2String(o.getDt())); title = String.format("%s_%s", engineerName, TimeUtils.IsoLocalDate2String(o.getDt()));
} }
OrderAppointmentListResp.OrderAppointment item = new OrderAppointmentListResp.OrderAppointment(); OrderAppointmentListResp.OrderAppointment item = new OrderAppointmentListResp.OrderAppointment();
item.setTitle(title); item.setTitle(title);
item.setEngineerCode(o.getEngineerCode()); item.setEngineerCode(o.getEngineerCode());
item.setExpectTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectStartTime())); item.setExpectTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeBegin()));
item.setTimelines(this.packOrderTimeline(timelines.get(subOrderId))); item.setTimelines(this.packOrderTimeline(timelines.get(o.getSubId())));
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);
...@@ -173,7 +163,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -173,7 +163,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
List<String> block = new ArrayList<>(); List<String> block = new ArrayList<>();
// 获取订单详情 // 获取订单详情
OrderRequest order = orderRequestMPDao.getByOrderId(orderId); OrderInfo order = orderInfoMPDao.getByOrderId(orderId);
OrderTeamBlockResp res = new OrderTeamBlockResp(); OrderTeamBlockResp res = new OrderTeamBlockResp();
res.setOrderId(orderId); res.setOrderId(orderId);
...@@ -236,7 +226,6 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -236,7 +226,6 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
Comparator<EngineerSkillGroup> cmp = Comparator.comparing(EngineerSkillGroup::getEngineerCode); Comparator<EngineerSkillGroup> cmp = Comparator.comparing(EngineerSkillGroup::getEngineerCode);
List<EngineerSkillGroup> sortedResults = rows.stream().sorted(cmp).collect(Collectors.toList()); List<EngineerSkillGroup> sortedResults = rows.stream().sorted(cmp).collect(Collectors.toList());
// 根据engineerCode分组 // 根据engineerCode分组
Map<String, List<EngineerSkillGroup>> results = sortedResults.stream().collect(Collectors.groupingBy(EngineerSkillGroup::getEngineerCode)); Map<String, List<EngineerSkillGroup>> results = sortedResults.stream().collect(Collectors.groupingBy(EngineerSkillGroup::getEngineerCode));
...@@ -339,11 +328,11 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -339,11 +328,11 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return items; return items;
} }
private List<KV> packOrderDetail(OrderRequest order) { private List<KV> packOrderDetail(OrderInfo order) {
List<KV> items = new ArrayList<>(); List<KV> items = new ArrayList<>();
items.add(this.packOrderItem("客户姓名", order.getName())); items.add(this.packOrderItem("客户姓名", order.getName()));
items.add(this.packOrderItem("客户电话", order.getPhone())); items.add(this.packOrderItem("客户电话", order.getPhone()));
items.add(this.packOrderItem("客户地址", String.format("%s%s%s",order.getCity(), order.getCounty(), order.getAddress()))); items.add(this.packOrderItem("客户地址", String.format("%s%s%s", order.getCity(), order.getCounty(), order.getAddress())));
items.add(this.packOrderItem("品牌", order.getBrand())); items.add(this.packOrderItem("品牌", order.getBrand()));
items.add(this.packOrderItem("设备", order.getType())); items.add(this.packOrderItem("设备", order.getType()));
items.add(this.packOrderItem("服务", order.getSkill())); items.add(this.packOrderItem("服务", order.getSkill()));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!