Commit 541c336a by 王力

Merge branch 'dev_bugfix_schedue' into 'master'

修改

See merge request !144
2 parents 4b33f23a 5c9cc5fd
...@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -62,11 +63,12 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -62,11 +63,12 @@ public class ScheduleServiceImpl implements ScheduleService {
List<OrderRequest> orders = this.queryOrderRequests(t.getTeamId(), date); List<OrderRequest> orders = this.queryOrderRequests(t.getTeamId(), date);
team.setOrder(this.getTeamOrderSum(orders)); team.setOrder(this.getTeamOrderSum(orders));
List<ScheduleOverviewResp.Item> children = new ArrayList<>(); // 技术员指派单列表
if (orders == null || orders.isEmpty()) { Map<String, List<OrderAppointment>> engineerOrders = new HashMap<>();
team.setChildren(children); if (orders != null && !orders.isEmpty()) {
teams.add(team); List<String> orderRequestIds = orders.stream().map(OrderRequest::getOrderId).collect(Collectors.toList());
continue; List<OrderAppointment> orderAppointments = this.queryOrderAppointments(orderRequestIds, date);
engineerOrders = orderAppointments.stream().collect(Collectors.groupingBy(OrderAppointment::getEngineerCode));
} }
// 获取team技术员列表 // 获取team技术员列表
...@@ -76,16 +78,15 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -76,16 +78,15 @@ public class ScheduleServiceImpl implements ScheduleService {
List<EngineerInfo> engineerInfoList = engineerInfoMPDao.selectByGroupId(t.getGroupId()); List<EngineerInfo> engineerInfoList = engineerInfoMPDao.selectByGroupId(t.getGroupId());
Map<String, List<EngineerInfo>> engineers = engineerInfoList.stream().collect(Collectors.groupingBy(EngineerInfo::getEngineerCode)); Map<String, List<EngineerInfo>> engineers = engineerInfoList.stream().collect(Collectors.groupingBy(EngineerInfo::getEngineerCode));
// 获取技术员对应的订单 List<ScheduleOverviewResp.Item> children = new ArrayList<>();
List<String> orderRequestIds = orders.stream().map(OrderRequest::getOrderId).collect(Collectors.toList()); for (Map.Entry<String, List<EngineerInfo>> entry : engineers.entrySet()) {
List<OrderAppointment> orderAppointments = this.queryOrderAppointments(orderRequestIds, date);
Map<String, List<OrderAppointment>> engineerOrders = orderAppointments.stream().collect(Collectors.groupingBy(OrderAppointment::getEngineerCode));
for (Map.Entry<String, List<OrderAppointment>> entry : engineerOrders.entrySet()) {
ScheduleOverviewResp.Item child = new ScheduleOverviewResp.Item(); ScheduleOverviewResp.Item child = new ScheduleOverviewResp.Item();
String engineerCode = entry.getKey(); String engineerCode = entry.getKey();
List<String> orderIds = entry.getValue().stream().map(OrderAppointment::getOrderId).collect(Collectors.toList()); EngineerInfo engineerInfo = entry.getValue().get(0);
List<String> orderIds = engineerOrders.getOrDefault(engineerCode, new ArrayList<>()).stream().map(OrderAppointment::getOrderId).collect(Collectors.toList());
List<OrderRequest> orders2 = new ArrayList<>(); List<OrderRequest> orders2 = new ArrayList<>();
for (OrderRequest o : orders) { for (OrderRequest o : orders) {
...@@ -94,20 +95,16 @@ public class ScheduleServiceImpl implements ScheduleService { ...@@ -94,20 +95,16 @@ public class ScheduleServiceImpl implements ScheduleService {
} }
} }
// 设置技术员姓名 child.setName(engineerInfo.getName());
List<EngineerInfo> es = engineers.get(engineerCode);
if (es == null || es.isEmpty()) {
child.setName(engineerCode);
} else {
child.setName(es.get(0).getName());
}
child.setValue(engineerCode); child.setValue(engineerCode);
child.setLevel("engineer"); child.setLevel("engineer");
child.setOrder(this.getTeamOrderSum(orders2)); child.setOrder(this.getTeamOrderSum(orders2));
child.setOrderDesc(Integer.toString(orders2.size())); child.setOrderDesc(Integer.toString(orders2.size()));
child.setDistanceDesc(""); child.setDistanceDesc("");
children.add(child); children.add(child);
} }
team.setChildren(children); team.setChildren(children);
team.setOrderDesc(String.format("人均:%d", orders.size() / teamEngineers.size())); team.setOrderDesc(String.format("人均:%d", orders.size() / teamEngineers.size()));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!