Commit b908cb37 by 丁伟峰

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

2 parents e3a3c765 ba1593a2
package com.alibaba.cloud.integration.order.dao;
import com.alibaba.cloud.integration.order.entity.CapacityEngineerStat;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CapacityEngineerStatMPDao extends BaseMapper<CapacityEngineerStat> {
}
package com.alibaba.cloud.integration.order.entity;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class CapacityEngineerStat {
private long id;
private String workDay;
private String engineerCode;
private Integer capTotal;
private Integer capUsed;
private Integer capUsedTravel;
private Integer capLeft;
private Integer orderCount;
private Integer maxDuration;
private Integer memo;
private Timestamp createTime;
private Timestamp updateTime;
}
...@@ -41,6 +41,9 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -41,6 +41,9 @@ public class DispatchServiceImpl implements DispatchService {
@Autowired @Autowired
private ProductCategoryMPDao productCategoryMPDao; private ProductCategoryMPDao productCategoryMPDao;
@Autowired
private CapacityEngineerStatMPDao capacityEngineerStatMPDao;
@Transactional @Transactional
@Override @Override
public Result<?> getDispatchOrderList(String levelType, List<String> levelIds, String date, String groupTagId) { public Result<?> getDispatchOrderList(String levelType, List<String> levelIds, String date, String groupTagId) {
...@@ -106,6 +109,9 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -106,6 +109,9 @@ public class DispatchServiceImpl implements DispatchService {
// 获取技术员已指派单列表 // 获取技术员已指派单列表
Map<String, List<OrderAppointment>> engineerOrders = this.queryEngineerOrders(engineerCodes, date); Map<String, List<OrderAppointment>> engineerOrders = this.queryEngineerOrders(engineerCodes, date);
// 获取技术员的容量
HashMap<String, CapacityEngineerStat> engineerCap = this.queryCapacityEngineerStat(engineerCodes, date);
// 获取订单ID // 获取订单ID
Set<String> orderIds = new HashSet<>(); Set<String> orderIds = new HashSet<>();
for (String k : engineerOrders.keySet()) { for (String k : engineerOrders.keySet()) {
...@@ -155,13 +161,26 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -155,13 +161,26 @@ public class DispatchServiceImpl implements DispatchService {
items.add(item); items.add(item);
} }
// 获取容量
int capUsed = 0;
int capTotal = 0;
String capacityStatus = "less";
CapacityEngineerStat cap = engineerCap.get(e.getEngineerCode());
if (cap != null) {
capUsed = cap.getCapUsed();
capTotal = cap.getCapTotal();
if (capTotal > 0 && (float) capUsed / capTotal < 0.8) {
capacityStatus = "normal";
}
}
DispatchEngineerOrderListResp.EngineerInfo eg = new DispatchEngineerOrderListResp.EngineerInfo(); DispatchEngineerOrderListResp.EngineerInfo eg = new DispatchEngineerOrderListResp.EngineerInfo();
eg.setOrders(items); eg.setOrders(items);
eg.setEngineerCode(e.getEngineerCode()); eg.setEngineerCode(e.getEngineerCode());
eg.setEngineerName(e.getName()); eg.setEngineerName(e.getName());
eg.setCapacity("");
eg.setCapacityStatus("");
eg.setCertificate(e.getCredentials()); eg.setCertificate(e.getCredentials());
eg.setCapacity(String.format("%d/%d", capUsed, capTotal));
eg.setCapacityStatus(capacityStatus);
egs.add(eg); egs.add(eg);
} }
...@@ -245,6 +264,19 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -245,6 +264,19 @@ public class DispatchServiceImpl implements DispatchService {
return map; return map;
} }
private HashMap<String, CapacityEngineerStat> queryCapacityEngineerStat(List<String> engineerCodes, String date) {
LambdaQueryWrapper<CapacityEngineerStat> lqw = new LambdaQueryWrapper<>();
lqw.eq(CapacityEngineerStat::getWorkDay, date);
lqw.in(CapacityEngineerStat::getEngineerCode, engineerCodes);
List<CapacityEngineerStat> records = capacityEngineerStatMPDao.selectList(lqw);
HashMap<String, CapacityEngineerStat> map = new HashMap<>();
for (CapacityEngineerStat r : records) {
map.put(r.getEngineerCode(), r);
}
return map;
}
public Timestamp getTimestampFromDate(String date, String time) { public Timestamp getTimestampFromDate(String date, String time) {
return Timestamp.valueOf(date + " " + time); return Timestamp.valueOf(date + " " + time);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!