Commit 935790b3 by 丁伟峰

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

2 parents d4bdaab6 5a166684
package com.dituhui.pea.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.service.OrderServiceDetail;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -26,9 +26,6 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
private OrderAppointmentMPDao orderAppointmentMPDao;
@Autowired
private EngineerSkillMPDao engineerSkillMPDao;
@Autowired
private EngineerInfoMPDao engineerInfoMPDao;
@Autowired
......@@ -41,7 +38,10 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
private OrgGroupMPDao orgGroupMPDao;
@Autowired
private ProductCategoryMPDao productCategoryMPDao;
private EngineerSkillGroupMPDao engineerSkillGroupMPDao;
@Autowired
private SkillInfoMPDao skillInfoMPDao;
@Transactional
@Override
......@@ -54,7 +54,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
// 设置订单详情信息
OrderServiceDetailResp.OrderDetail detail = new OrderServiceDetailResp.OrderDetail();
detail.setAddress(String.format("%s%s%s", order.getCity(), order.getCounty(), order.getAddress()));
detail.setLocation(String.format("%s,%s", order.getX(),order.getY()));
detail.setLocation(String.format("%s,%s", order.getX(), order.getY()));
detail.setDate(TimeUtils.IsoLocalDate2String(order.getDt()));
detail.setBrand(order.getBrand());
detail.setType(order.getType());
......@@ -116,11 +116,8 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
List<String> groupIds = egInfo.values().stream().map(EngineerInfo::getGroupId).collect(Collectors.toList());
HashMap<String, OrgGroup> groups = this.queryOrgGroups(groupIds);
// 获取工程师技能列表
Map<String, List<EngineerSkill>> egSkill = this.getEngineerSkills(egCodes);
// 获取所有技能列表
HashMap<String, String> skills = this.queryAllSkills();
// 获取工程师技能列表<engineerCode, skills>
Map<String, String> egSkill = this.getEngineerSkills(egCodes);
// 获取subOrder订单timeline
Map<String, List<OrderTimeline>> timelines = this.getOrderTimelines(orderId);
......@@ -136,7 +133,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
String subOrderId = o.getSuborderId();
EngineerInfo eg = egInfo.getOrDefault(o.getEngineerCode(), null);
List<EngineerSkill> es = egSkill.getOrDefault(o.getEngineerCode(), null);
String skill = egSkill.getOrDefault(o.getEngineerCode(), null);
// 获取工程师姓名
String engineerName = (eg != null) ? eg.getName() : o.getEngineerCode();
......@@ -152,7 +149,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
item.setEngineerCode(o.getEngineerCode());
item.setExpectTime(TimeUtils.IsoTimestamp2DateTime(o.getExpectStartTime()));
item.setTimelines(this.packOrderTimeline(timelines.get(subOrderId)));
item.setItems(this.packEngineerItems(eg, es, groups.get(eg.getGroupId()), skills));
item.setItems(this.packEngineerItems(eg, skill, groups.get(eg.getGroupId())));
items.add(item);
}
......@@ -214,26 +211,42 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
return map;
}
private Map<String, List<EngineerSkill>> getEngineerSkills(List<String> egCodes) {
private Map<String, String> getEngineerSkills(List<String> egCodes) {
// 获取工程师技能列表
Map<String, List<EngineerSkill>> map = new HashMap<>();
Map<String, String> map = new HashMap<>();
if (egCodes.isEmpty()) {
return map;
}
LambdaQueryWrapper<EngineerSkill> lqw = new LambdaQueryWrapper<>();
lqw.in(EngineerSkill::getEngineerCode, egCodes);
lqw.eq(EngineerSkill::getBean_status, 1);
lqw.eq(EngineerSkill::getStatus, 1);
List<EngineerSkill> rows = engineerSkillMPDao.selectList(lqw);
LambdaQueryWrapper<EngineerSkillGroup> lqw = new LambdaQueryWrapper<>();
lqw.select(EngineerSkillGroup::getEngineerCode, EngineerSkillGroup::getSkillGroupCode);
lqw.in(EngineerSkillGroup::getEngineerCode, egCodes);
lqw.eq(EngineerSkillGroup::getStatus, 1);
List<EngineerSkillGroup> rows = engineerSkillGroupMPDao.selectList(lqw);
// 根据engineerCode排序
Comparator<EngineerSkill> cmp = Comparator.comparing(EngineerSkill::getEngineerCode);
List<EngineerSkill> results = rows.stream().sorted(cmp).collect(Collectors.toList());
Comparator<EngineerSkillGroup> cmp = Comparator.comparing(EngineerSkillGroup::getEngineerCode);
List<EngineerSkillGroup> sortedResults = rows.stream().sorted(cmp).collect(Collectors.toList());
// 根据engineerCode分组
return results.stream().collect(Collectors.groupingBy(EngineerSkill::getEngineerCode));
Map<String, List<EngineerSkillGroup>> results = sortedResults.stream().collect(Collectors.groupingBy(EngineerSkillGroup::getEngineerCode));
// 获取所有技能
HashMap<String, String> skills = this.queryAllSkills();
for (Map.Entry<String, List<EngineerSkillGroup>> entry : results.entrySet()) {
String engineerCode = entry.getKey();
List<String> engineerSkills = new ArrayList<>();
for (EngineerSkillGroup r : entry.getValue()) {
String skill = skills.getOrDefault(r.getSkillGroupCode(), "");
if (skill.isEmpty()) {
continue;
}
engineerSkills.add(skill);
}
map.put(engineerCode, String.join("、", engineerSkills));
}
return map;
}
private Map<String, List<OrderTimeline>> getOrderTimelines(String orderId) {
......@@ -255,18 +268,28 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
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()));
List<SkillInfo> records = skillInfoMPDao.selectList(null);
Comparator<SkillInfo> cmp = Comparator.comparing(SkillInfo::getSkillGroupCode);
List<SkillInfo> sortedResults = records.stream().sorted(cmp).collect(Collectors.toList());
Map<String, List<SkillInfo>> results = sortedResults.stream().collect(Collectors.groupingBy(SkillInfo::getSkillGroupCode));
for (Map.Entry<String, List<SkillInfo>> entry : results.entrySet()) {
String skillGroupCode = entry.getKey();
HashSet<String> categories = new HashSet<>();
for (SkillInfo s : entry.getValue()) {
categories.add(String.format("%s%s", s.getTypeCategory(), s.getSkillCategory()));
}
List<String> skills = new ArrayList<>(categories);
map.put(skillGroupCode, String.join("、", skills));
}
return map;
}
private List<KV> packEngineerItems(EngineerInfo eg, List<EngineerSkill> egSkill, OrgGroup group, HashMap<String, String> skills) {
private List<KV> packEngineerItems(EngineerInfo eg, String skill, OrgGroup group) {
// 获取工程师信息
List<KV> items = new ArrayList<>();
if (eg == null && egSkill == null) {
if (eg == null && skill == null) {
return items;
}
......@@ -303,18 +326,8 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
items.add(this.packEngineer("工号", eg.getEngineerCode(), ""));
items.add(this.packEngineer("手机号", eg.getPhone(), ""));
}
items.add(this.packEngineer("技能", skill, ""));
if (egSkill != null) {
List<String> rows = new ArrayList<>();
for (EngineerSkill s : egSkill) {
String skill = skills.getOrDefault(s.getCategoryId(), "");
if (skill.isEmpty()) {
continue;
}
rows.add(skill);
}
items.add(this.packEngineer("技能", String.join("、", rows), ""));
}
return items;
}
......@@ -328,7 +341,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
items.add(this.packOrderItem("故障描述", order.getFaultDescribe()));
items.add(this.packOrderItem("备注", order.getApplyNote()));
log.info("======= 意向时间111 {}", order.getExpectTimeBegin());
items.add(this.packOrderItem("意向时间", TimeUtils.IsoTimestamp2DateTime(order.getExpectTimeBegin())));
items.add(this.packOrderItem("意向时间", TimeUtils.IsoTimestamp2DateTime(order.getExpectTimeBegin())));
log.info("======= 意向时间222 {}", TimeUtils.IsoTimestamp2DateTime(order.getExpectTimeBegin()));
items.add(this.packOrderItem("时间要求", order.getExpectTimeDesc()));
items.add(this.packOrderItem("预约方式", order.getSource()));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!