Commit d2916970 by wangli

修改

1 parent 935d4bdf
...@@ -36,6 +36,12 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -36,6 +36,12 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
@Autowired @Autowired
private OrderEventMPDao orderEventMPDao; private OrderEventMPDao orderEventMPDao;
@Autowired
private OrgGroupMPDao orgGroupMPDao;
@Autowired
private ProductCategoryMPDao productCategoryMPDao;
@Transactional @Transactional
@Override @Override
public Result<?> getOrderServiceDetail(String orderId) { public Result<?> getOrderServiceDetail(String orderId) {
...@@ -81,7 +87,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -81,7 +87,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 查询预约单列表 // 查询预约单列表
List<OrderAppointment> appoints = this.queryOrderAppointments(orderId); List<OrderAppointment> appoints = this.queryOrderAppointments(orderId);
if(appoints.isEmpty()){ if (appoints.isEmpty()) {
// 没有指派单列表,返回 // 没有指派单列表,返回
res.setOrderId(orderId); res.setOrderId(orderId);
res.setOrders(List.of()); res.setOrders(List.of());
...@@ -94,8 +100,15 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -94,8 +100,15 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 获取工程师基础信息列表 // 获取工程师基础信息列表
HashMap<String, EngineerInfo> egInfo = this.getEngineerInfos(egCodes); HashMap<String, EngineerInfo> egInfo = this.getEngineerInfos(egCodes);
// 获取groupIds 和 group信息
List<String> groupIds = egInfo.values().stream().map(EngineerInfo::getGroupId).collect(Collectors.toList());
HashMap<String, OrgGroup> groups = this.queryOrgGroups(groupIds);
// 获取工程师技能列表 // 获取工程师技能列表
HashMap<String, EngineerSkill> egSkill = this.getEngineerSkills(egCodes); Map<String, List<EngineerSkill>> egSkill = this.getEngineerSkills(egCodes);
// 获取所有技能列表
HashMap<String, String> skills = this.queryAllSkills();
// 获取subOrder订单timeline // 获取subOrder订单timeline
Map<String, List<OrderTimeline>> timelines = this.getOrderTimelines(orderId); Map<String, List<OrderTimeline>> timelines = this.getOrderTimelines(orderId);
...@@ -103,36 +116,38 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -103,36 +116,38 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 对指派单列表按照subOrderId降序排序, 获取排序的subOrderId列表, 然后根据subOrderId分组 // 对指派单列表按照subOrderId降序排序, 获取排序的subOrderId列表, 然后根据subOrderId分组
Comparator<OrderAppointment> sbDesc = Comparator.comparing(OrderAppointment::getSuborderId, String.CASE_INSENSITIVE_ORDER).reversed(); Comparator<OrderAppointment> sbDesc = Comparator.comparing(OrderAppointment::getSuborderId, String.CASE_INSENSITIVE_ORDER).reversed();
List<OrderAppointment> results = appoints.stream().sorted(sbDesc).collect(Collectors.toList()); List<OrderAppointment> results = appoints.stream().sorted(sbDesc).collect(Collectors.toList());
// 根据subOrderId分组
// Map<String, List<OrderAppointment>> appointOrders = results.stream().collect(Collectors.groupingBy(OrderAppointment::getSuborderId));
/*
String lastSubOrderId = results.get(0).getSuborderId(); String lastSubOrderId = results.get(0).getSuborderId();
for(OrderAppointment o: results) { List<OrderAppointmentListResp.OrderAppointment> items = new ArrayList<>();
for (OrderAppointment o : results) {
String subOrderId = o.getSuborderId(); String subOrderId = o.getSuborderId();
EngineerInfo eg = egInfo.getOrDefault(o.getEngineerCode(), null); EngineerInfo eg = egInfo.getOrDefault(o.getEngineerCode(), null);
EngineerSkill es = egSkill.getOrDefault(o.getEngineerCode(), null); List<EngineerSkill> es = egSkill.getOrDefault(o.getEngineerCode(), null);
// 获取工程师姓名 // 获取工程师姓名
String engineerName = (eg != null) ? eg.getName(): o.getEngineerCode(); String engineerName = (eg != null) ? eg.getName() : o.getEngineerCode();
// 获取title // 获取title
String title = engineerName; String title = engineerName;
if (lastSubOrderId.equals(subOrderId)) { if (!lastSubOrderId.equals(subOrderId)) {
title = String.format("%s_%s", engineerName, this.Timestamp2Datetime(o.getExpectTime(), "yyyyMMdd")); title = String.format("%s_%s", engineerName, this.Timestamp2Datetime(o.getExpectTime(), "yyyyMMdd"));
} }
OrderAppointmentListResp.OrderAppointment op = new OrderAppointmentListResp.OrderAppointment(); OrderAppointmentListResp.OrderAppointment item = new OrderAppointmentListResp.OrderAppointment();
op.setTitle(title); item.setTitle(title);
op.setEngineerCode(o.getEngineerCode()); item.setEngineerCode(o.getEngineerCode());
op.setExpectTime(o.getExpectTime().toString()); item.setExpectTime(o.getExpectTime().toString());
op.setTimelines(this.packOrderTimeline(timelines.get(subOrderId))); item.setTimelines(this.packOrderTimeline(timelines.get(subOrderId)));
op.setItems(this.packEngineerInfos(eg, es)); item.setItems(this.packEngineerItems(eg, es, groups.get(eg.getGroupId()), skills));
items.add(item);
} }
*/
return null; res.setOrderId(orderId);
res.setOrders(items);
return Result.success(res);
} }
@Transactional @Transactional
...@@ -171,39 +186,56 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -171,39 +186,56 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return orderEventMPDao.selectList(lqw); return orderEventMPDao.selectList(lqw);
} }
private HashMap<String, EngineerInfo> getEngineerInfos(List<String> egCodes){ private HashMap<String, OrgGroup> queryOrgGroups(List<String> groupIds) {
HashMap<String, OrgGroup> map = new HashMap<>();
if (groupIds.isEmpty()) {
return map;
}
LambdaQueryWrapper<OrgGroup> lqw = new LambdaQueryWrapper<>();
lqw.in(OrgGroup::getGroupId, groupIds);
List<OrgGroup> records = orgGroupMPDao.selectList(lqw);
for (OrgGroup r : records) {
map.put(r.getGroupId(), r);
}
return map;
}
private HashMap<String, EngineerInfo> getEngineerInfos(List<String> egCodes) {
// 获取工程师信息列表 // 获取工程师信息列表
HashMap<String, EngineerInfo> map = new HashMap<>(); HashMap<String, EngineerInfo> map = new HashMap<>();
if (egCodes.isEmpty()) { if (egCodes.isEmpty()) {
return map; return map;
} }
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
lqw.in(EngineerInfo::getEngineerCode, egCodes); lqw.in(EngineerInfo::getEngineerCode, egCodes);
List<EngineerInfo> rows = engineerInfoMPDao.selectList(lqw); List<EngineerInfo> rows = engineerInfoMPDao.selectList(lqw);
for (EngineerInfo row: rows){ for (EngineerInfo row : rows) {
map.put(row.getEngineerCode(), row); map.put(row.getEngineerCode(), row);
} }
return map; return map;
} }
private HashMap<String, EngineerSkill> getEngineerSkills(List<String> egCodes) { private Map<String, List<EngineerSkill>> getEngineerSkills(List<String> egCodes) {
// 获取工程师技能列表 // 获取工程师技能列表
HashMap<String, EngineerSkill> map = new HashMap<>(); Map<String, List<EngineerSkill>> map = new HashMap<>();
if (egCodes.isEmpty()) { if (egCodes.isEmpty()) {
return map; return map;
} }
LambdaQueryWrapper<EngineerSkill> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<EngineerSkill> lqw = new LambdaQueryWrapper<>();
lqw.in(EngineerSkill::getEngineerCode, egCodes); lqw.in(EngineerSkill::getEngineerCode, egCodes);
lqw.eq(EngineerSkill::getBean_status, 1);
lqw.eq(EngineerSkill::getStatus, 1);
List<EngineerSkill> rows = engineerSkillMPDao.selectList(lqw); List<EngineerSkill> rows = engineerSkillMPDao.selectList(lqw);
for (EngineerSkill row: rows){ // 根据engineerCode排序
map.put(row.getEngineerCode(), row); Comparator<EngineerSkill> cmp = Comparator.comparing(EngineerSkill::getEngineerCode);
} List<EngineerSkill> results = rows.stream().sorted(cmp).collect(Collectors.toList());
return map;
// 根据engineerCode分组
return results.stream().collect(Collectors.groupingBy(EngineerSkill::getEngineerCode));
} }
private Map<String, List<OrderTimeline>> getOrderTimelines(String orderId) { private Map<String, List<OrderTimeline>> getOrderTimelines(String orderId) {
...@@ -213,7 +245,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -213,7 +245,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
lqw.eq(OrderTimeline::getOrderId, orderId); lqw.eq(OrderTimeline::getOrderId, orderId);
List<OrderTimeline> timelines = orderTimelineMPDao.selectList(lqw); List<OrderTimeline> timelines = orderTimelineMPDao.selectList(lqw);
// 根据subOrderId + happend字段排序 // 根据subOrderId + happen字段排序
Comparator<OrderTimeline> sb = Comparator.comparing(OrderTimeline::getSuborderId, String.CASE_INSENSITIVE_ORDER); Comparator<OrderTimeline> sb = Comparator.comparing(OrderTimeline::getSuborderId, String.CASE_INSENSITIVE_ORDER);
Comparator<OrderTimeline> happen = Comparator.comparing(OrderTimeline::getHappen); Comparator<OrderTimeline> happen = Comparator.comparing(OrderTimeline::getHappen);
Comparator<OrderTimeline> comp = sb.thenComparing(happen); Comparator<OrderTimeline> comp = sb.thenComparing(happen);
...@@ -223,31 +255,68 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -223,31 +255,68 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return results.stream().collect(Collectors.groupingBy(OrderTimeline::getSuborderId)); return results.stream().collect(Collectors.groupingBy(OrderTimeline::getSuborderId));
} }
private List<KV> packEngineerInfos(EngineerInfo eg, EngineerSkill skill) { private HashMap<String, String> queryAllSkills() {
HashMap<String, String> map = new HashMap<>();
List<ProductCategory> records = productCategoryMPDao.selectList(null);
for (ProductCategory r : records) {
map.put(r.getProductCategoryId(), String.format("%s%s", r.getType(), r.getSkill()));
}
return map;
}
private List<KV> packEngineerItems(EngineerInfo eg, List<EngineerSkill> egSkill, OrgGroup group, HashMap<String, String> skills) {
// 获取工程师信息 // 获取工程师信息
List<KV> items = new ArrayList<>(); List<KV> items = new ArrayList<>();
if (eg == null && skill == null) { if (eg == null && egSkill == null) {
return items; return items;
} }
if (eg != null) { if (eg != null) {
String groupName = "";
String kind = "";
if (group != null) {
groupName = group.getGroupName();
switch (group.getKind()) {
case 1:
kind = "分站";
break;
case 2:
kind = "外围";
break;
case 3:
kind = "小组";
break;
case 4:
kind = "网点";
break;
case 5:
kind = "自保点";
break;
default:
break;
}
}
items.add(this.packEngineer("技术员:", eg.getName(), "engineer")); items.add(this.packEngineer("技术员:", eg.getName(), "engineer"));
items.add(this.packEngineer("工号:", eg.getEngineerCode(), "" )); items.add(this.packEngineer("小组:", groupName, ""));
items.add(this.packEngineer("类型:", (eg.getKind() == 1) ? "全职" : "兼职", "")); items.add(this.packEngineer("类型:", kind, ""));
items.add(this.packEngineer("性别:", eg.getGender(), ""));
items.add(this.packEngineer("工号:", eg.getEngineerCode(), ""));
items.add(this.packEngineer("手机号:", eg.getPhone(), "")); items.add(this.packEngineer("手机号:", eg.getPhone(), ""));
} }
String age = ""; if (egSkill != null) {
List<String> rows = new ArrayList<>();
if (age.isEmpty()) { for (EngineerSkill s : egSkill) {
age="未知"; String skill = skills.getOrDefault(s.getCategoryId(), "");
} else { if (skill.isEmpty()) {
age = eg.getBirth(); continue;
}
rows.add(skill);
}
items.add(this.packEngineer("技能", String.join("、", rows), ""));
} }
items.add(this.packEngineer("小组:", "老王组", ""));
items.add(this.packEngineer("性别/年龄:", eg.getGender()+"/"+age, ""));
items.add(this.packEngineer("技能:", "TODO", "")); // TODO
return items; return items;
} }
...@@ -266,13 +335,13 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -266,13 +335,13 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return items; return items;
} }
private List<OrderServiceDynamicsResp.Dynamics> packOrderDynamics(List<OrderEvent> events){ private List<OrderServiceDynamicsResp.Dynamics> packOrderDynamics(List<OrderEvent> events) {
List<OrderServiceDynamicsResp.Dynamics> dynamics = new ArrayList<>(); List<OrderServiceDynamicsResp.Dynamics> dynamics = new ArrayList<>();
// 根据happen排序 // 根据happen排序
Comparator<OrderEvent> happen = Comparator.comparing(OrderEvent::getHappen); Comparator<OrderEvent> happen = Comparator.comparing(OrderEvent::getHappen);
List<OrderEvent> results = events.stream().sorted(happen).collect(Collectors.toList()); List<OrderEvent> results = events.stream().sorted(happen).collect(Collectors.toList());
for(OrderEvent o: results) { for (OrderEvent o : results) {
OrderServiceDynamicsResp.Dynamics d = new OrderServiceDynamicsResp.Dynamics(); OrderServiceDynamicsResp.Dynamics d = new OrderServiceDynamicsResp.Dynamics();
d.setTitle(o.getEvent()); d.setTitle(o.getEvent());
d.setSubTitle(String.format("操作人: %s", o.getOperatorName())); d.setSubTitle(String.format("操作人: %s", o.getOperatorName()));
...@@ -288,7 +357,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail { ...@@ -288,7 +357,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
if (timelines == null) { if (timelines == null) {
return items; return items;
} }
for (OrderTimeline o:timelines) { for (OrderTimeline o : timelines) {
items.add(this.packTimeline(o.getEvent(), o.getHappen(), o.getStatus().toString())); items.add(this.packTimeline(o.getEvent(), o.getHappen(), o.getStatus().toString()));
} }
return items; return items;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!