Commit a55dfd99 by huangjinxin

fix:工单列表返回添加工程师出发地

1 parent 5d7a522a
...@@ -107,4 +107,19 @@ public class OrderServiceList { ...@@ -107,4 +107,19 @@ public class OrderServiceList {
private String planStartTime; private String planStartTime;
private String planEndTime; private String planEndTime;
/**
* 常规出发地,1配件仓,2家庭住址,3工作地址 默认工作地址
*/
private Integer departure;
/**
* 出发地点x
*/
private String departureX;
/**
* 出发地点y
*/
private String departureY;
} }
...@@ -8,6 +8,7 @@ import com.dituhui.pea.common.Result; ...@@ -8,6 +8,7 @@ import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.ListUtils; 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.EngineerBusinessListResp;
import com.dituhui.pea.order.dto.OrderServiceList; import com.dituhui.pea.order.dto.OrderServiceList;
import com.dituhui.pea.order.dto.OrderServiceListReq; import com.dituhui.pea.order.dto.OrderServiceListReq;
import com.dituhui.pea.order.dto.OrderServiceListResp; import com.dituhui.pea.order.dto.OrderServiceListResp;
...@@ -37,6 +38,12 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -37,6 +38,12 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
@Autowired @Autowired
private OrderInfoDao orderInfoDao; private OrderInfoDao orderInfoDao;
@Autowired
private EngineerBusinessDao engineerBusinessDao;
@Autowired
private OrgWarehouseInfoDao orgWarehouseInfoDao;
@Transactional @Transactional
@Override @Override
public Result<OrderServiceListResp> getOrderServiceList(OrderServiceListReq reqDTO) throws BusinessException { public Result<OrderServiceListResp> getOrderServiceList(OrderServiceListReq reqDTO) throws BusinessException {
...@@ -61,17 +68,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -61,17 +68,8 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderInfo::getOrgTeamId, reqDTO.getTeamIds()); lqw.in(ListUtils.isNotEmpty(reqDTO.getTeamIds()), OrderInfo::getOrgTeamId, reqDTO.getTeamIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderInfo::getAppointmentMethod, reqDTO.getAppointmentType()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderInfo::getAppointmentMethod, reqDTO.getAppointmentType());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderInfo::getAppointmentStatus, reqDTO.getAppointmentStatus()); lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderInfo::getAppointmentStatus, reqDTO.getAppointmentStatus());
lqw.in(ListUtils.isNotEmpty(reqDTO.getPriorities()), OrderInfo::getBeanPriority, reqDTO.getPriorities());
lqw.orderByDesc(OrderInfo::getCreateTime); lqw.orderByDesc(OrderInfo::getCreateTime);
if (ListUtils.isNotEmpty(reqDTO.getPriorities())) {
List<Integer> p = reqDTO.getPriorities();
if (p.contains(0) && p.contains(1)) {
lqw.ge(OrderInfo::getPriority, 1);
} else if (p.contains(0) && !p.contains(1)) {
lqw.le(OrderInfo::getPriority, 1);
} else if (p.contains(1) && !p.contains(0)) {
lqw.ge(OrderInfo::getPriority, 5);
}
}
if (ListUtils.isNotEmpty(reqDTO.getEngineerCodes())) { if (ListUtils.isNotEmpty(reqDTO.getEngineerCodes())) {
lqw.and(w -> lqw.and(w ->
...@@ -105,7 +103,9 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -105,7 +103,9 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
List<OrderInfo> orders = pg.getRecords(); List<OrderInfo> orders = pg.getRecords();
// 获取技术员姓名 // 获取技术员姓名
Map<String, String> engineerNames = this.getEngineerNames(orders); Map<String, EngineerInfoEntity> engineerNames = this.getEngineerNames(orders);
// 获取技术员业务信息
Map<String, EngineerBusinessEntity> engineerBusiness = this.getEngineerBusiness(engineerNames);
// 获取branch // 获取branch
Map<String, String> branchNames = this.getBranchNames(orders); Map<String, String> branchNames = this.getBranchNames(orders);
...@@ -134,6 +134,12 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -134,6 +134,12 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
List<String> names = this.getOrderEngineerNames(o.getEngineerCode(), o.getEngineerCodeSub(), engineerNames); List<String> names = this.getOrderEngineerNames(o.getEngineerCode(), o.getEngineerCodeSub(), engineerNames);
record.setEngineerNum(names.size()); //工程师数量 record.setEngineerNum(names.size()); //工程师数量
record.setEngineerNames(String.join("、", names)); //工程师姓名列表 record.setEngineerNames(String.join("、", names)); //工程师姓名列表
if (engineerBusiness.containsKey(o.getEngineerCode())) {
EngineerBusinessEntity businessEntity = engineerBusiness.get(o.getEngineerCode());
record.setDepartureX(businessEntity.getX());
record.setDepartureY(businessEntity.getY());
record.setDeparture(businessEntity.getDeparture());
}
} }
record.setExpectTimeBegin(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeBegin())); record.setExpectTimeBegin(TimeUtils.IsoTimestamp2DateTime(o.getExpectTimeBegin()));
...@@ -169,7 +175,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -169,7 +175,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
List<OrderInfoEntity> byMultipleOrders = orderInfoDao.findByMultipleOrdersAndOrderIdNot(o.getMultipleOrders(), o.getOrderId()); List<OrderInfoEntity> byMultipleOrders = orderInfoDao.findByMultipleOrdersAndOrderIdNot(o.getMultipleOrders(), o.getOrderId());
List<OrderServiceList> multipleItems = new ArrayList<>(); List<OrderServiceList> multipleItems = new ArrayList<>();
for (OrderInfoEntity info : byMultipleOrders) { for (OrderInfoEntity info : byMultipleOrders) {
multipleItems.add(toMultipleOrders(info, branchNames, engineerNames)); multipleItems.add(toMultipleOrders(info, branchNames, engineerNames, engineerBusiness));
} }
record.setMultipleOrderList(multipleItems); record.setMultipleOrderList(multipleItems);
} }
...@@ -187,7 +193,47 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -187,7 +193,47 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
return Result.success(res); return Result.success(res);
} }
private OrderServiceList toMultipleOrders(OrderInfoEntity o, Map<String, String> branchNames, Map<String, String> engineerNames) { /**
* 获取团队配件仓地址
*
* @param orders
* @return
*/
private Map<String, OrgWarehouseInfoEntity> getTeamWarehouseInfo(List<OrderInfo> orders) {
Map<String, OrgWarehouseInfoEntity> orgWarehouseInfoEntityMap = new HashMap<>();
for (OrderInfo r : orders) {
if (StringUtils.isEmpty(r.getOrgTeamId())) {
continue;
}
if (orgWarehouseInfoEntityMap.containsKey(r.getOrgTeamId())) {
continue;
}
OrgWarehouseInfoEntity byTeamAssigned = orgWarehouseInfoDao.getByTeamAssigned(r.getOrgTeamId());
if (ObjectUtil.isNull(byTeamAssigned)) {
continue;
}
orgWarehouseInfoEntityMap.put(r.getOrgTeamId(), byTeamAssigned);
}
return orgWarehouseInfoEntityMap;
}
private Map<String, EngineerBusinessEntity> getEngineerBusiness(Map<String, EngineerInfoEntity> engineerNames) {
// 获取技术员姓名
Set<String> engineerCodes = new HashSet<>();
for (String engineerCode : engineerNames.keySet()) {
if (StringUtils.isNotEmpty(engineerCode)) {
engineerCodes.add(engineerCode);
}
}
if (engineerCodes.isEmpty()) {
return new HashMap<>();
}
List<EngineerBusinessEntity> engineers = engineerBusinessDao.findByEngineerCodeIn(new ArrayList<>(engineerCodes));
return engineers.stream().collect(Collectors.toMap(EngineerBusinessEntity::getEngineerCode, e -> e));
}
private OrderServiceList toMultipleOrders(OrderInfoEntity o, Map<String, String> branchNames, Map<String, EngineerInfoEntity> engineerNames, Map<String, EngineerBusinessEntity> engineerBusiness) {
OrderServiceList record = new OrderServiceList(); OrderServiceList record = new OrderServiceList();
record.setOrderId(o.getOrderId()); record.setOrderId(o.getOrderId());
record.setType(o.getType()); record.setType(o.getType());
...@@ -210,6 +256,12 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -210,6 +256,12 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
List<String> names = this.getOrderEngineerNames(o.getEngineerCode(), o.getEngineerCodeSub(), engineerNames); List<String> names = this.getOrderEngineerNames(o.getEngineerCode(), o.getEngineerCodeSub(), engineerNames);
record.setEngineerNum(names.size()); //工程师数量 record.setEngineerNum(names.size()); //工程师数量
record.setEngineerNames(String.join("、", names)); //工程师姓名列表 record.setEngineerNames(String.join("、", names)); //工程师姓名列表
if (engineerBusiness.containsKey(o.getEngineerCode())) {
EngineerBusinessEntity businessEntity = engineerBusiness.get(o.getEngineerCode());
record.setDepartureX(businessEntity.getX());
record.setDepartureY(businessEntity.getY());
record.setDeparture(businessEntity.getDeparture());
}
} }
record.setExpectTimeBegin(TimeUtils.IsoLocalDateTime2String(o.getExpectTimeBegin())); record.setExpectTimeBegin(TimeUtils.IsoLocalDateTime2String(o.getExpectTimeBegin()));
...@@ -232,7 +284,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -232,7 +284,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
return record; return record;
} }
private Map<String, String> getEngineerNames(List<OrderInfo> orders) { private Map<String, EngineerInfoEntity> getEngineerNames(List<OrderInfo> orders) {
// 获取技术员姓名 // 获取技术员姓名
Set<String> engineerCodes = new HashSet<>(); Set<String> engineerCodes = new HashSet<>();
for (OrderInfo r : orders) { for (OrderInfo r : orders) {
...@@ -247,7 +299,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -247,7 +299,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
return new HashMap<>(); return new HashMap<>();
} }
List<EngineerInfoEntity> engineers = engineerInfoDao.findByEngineerCodeIn(new ArrayList<>(engineerCodes)); List<EngineerInfoEntity> engineers = engineerInfoDao.findByEngineerCodeIn(new ArrayList<>(engineerCodes));
return engineers.stream().collect(Collectors.toMap(EngineerInfoEntity::getEngineerCode, EngineerInfoEntity::getName)); return engineers.stream().collect(Collectors.toMap(EngineerInfoEntity::getEngineerCode, e -> e));
} }
private Map<String, String> getBranchNames(List<OrderInfo> orders) { private Map<String, String> getBranchNames(List<OrderInfo> orders) {
...@@ -265,7 +317,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -265,7 +317,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
return records.stream().collect(Collectors.toMap(OrgBranchEntity::getBranchId, OrgBranchEntity::getBranchName)); return records.stream().collect(Collectors.toMap(OrgBranchEntity::getBranchId, OrgBranchEntity::getBranchName));
} }
private List<String> getOrderEngineerNames(String engineerCode, String engineerCodeSub, Map<String, String> engineerNames) { private List<String> getOrderEngineerNames(String engineerCode, String engineerCodeSub, Map<String, EngineerInfoEntity> engineerNames) {
// 获取订单技术员姓名信息 // 获取订单技术员姓名信息
List<String> names = new ArrayList<>(); List<String> names = new ArrayList<>();
List<String> codes = new ArrayList<>() { List<String> codes = new ArrayList<>() {
...@@ -275,9 +327,9 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -275,9 +327,9 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
} }
}; };
for (String code : codes) { for (String code : codes) {
String name = engineerNames.getOrDefault(code, ""); EngineerInfoEntity engineerInfo = engineerNames.getOrDefault(code, null);
if (StringUtils.isNotEmpty(name)) { if (ObjectUtil.isNotNull(engineerInfo)) {
names.add(name); names.add(engineerInfo.getName());
} }
} }
return names; return names;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!