Commit 9cb3db32 by 张晓

分解到order-info时,抹掉技术员的也要更新

1 parent e9cbc096
......@@ -15,9 +15,9 @@ public interface DispatchOrderRepository extends CrudRepository<DispatchOrder, L
List<DispatchOrder> findNotAssigned(String groupId, String batchNo);
// 查看算法指派成功非confirm状态的
@Query("from DispatchOrder where groupId=?1 and batchNo=?2 and status !='CONFIRM' and ( engineerCode is not null and engineerCode!='') ")
List<DispatchOrder> findAssigned(String groupId, String batchNo);
// 查看算法指派成功(也有抹掉技术员、时间情况),非confirm状态的
@Query("from DispatchOrder where groupId=?1 and batchNo=?2 and status !='CONFIRM' ")
List<DispatchOrder> findAllWithoutConfirm(String groupId, String batchNo);
Optional<DispatchOrder> findByGroupIdAndBatchNoAndOrderIdAndDt(String groupId, String batchNo, String orderId, String dt);
}
\ No newline at end of file
......@@ -5,9 +5,10 @@ import cn.hutool.core.date.DateUtil;
import com.dituhui.pea.dispatch.dao.*;
import com.dituhui.pea.dispatch.entity.*;
import com.dituhui.pea.dispatch.service.ExtractService;
import com.mysql.cj.util.StringUtils;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
......@@ -73,7 +74,7 @@ public class ExtractServiceImpl implements ExtractService {
Map<String, EngineerInfo> engineerInfoMap = engineerInfoRepo.findByGroupId(groupId).stream().collect(Collectors.toMap(EngineerInfo::getEngineerCode, y -> y));
List<DispatchOrder> dispatchOrderList = dispatchOrderRepo.findAssigned(groupId, batchNo);
List<DispatchOrder> dispatchOrderList = dispatchOrderRepo.findAllWithoutConfirm(groupId, batchNo);
log.info("算法结果更新到工单, step1-开始处理, groupId:{}, batchNo:{}, order-size:{}", groupId, batchNo, dispatchOrderList.size());
......@@ -81,8 +82,9 @@ public class ExtractServiceImpl implements ExtractService {
dispatchOrderList.forEach(dispatchOrder -> {
int idx = atomicInteger.getAndIncrement();
String orderId = dispatchOrder.getOrderId();
String engCode = dispatchOrder.getEngineerCode();
String dt = dispatchOrder.getDt();
String engCode = dispatchOrder.getEngineerCode();
log.info("算法结果更新到工单, step1.1-loop, {}/{}, groupId:{}, batchNo:{}, orderId:{}, dt:{}, engCode:{}",
idx, dispatchOrderList.size(), groupId, batchNo, orderId, dt, engCode);
......@@ -99,52 +101,66 @@ public class ExtractServiceImpl implements ExtractService {
if (!("OPEN".equals(orderInfo.getBeanStatus()) &&
Set.of("AUTO_NOW", "AUTO_BATCH").contains(orderInfo.getAppointmentMethod()) &&
Set.of("INIT", "VIRTUAL", "PRE").contains(orderInfo.getAppointmentStatus()) &&
"NORMAL".equals(orderInfo.getOrderStatus()) &&
"INIT".equals(orderInfo.getServiceStatus())
"NORMAL".equals(orderInfo.getOrderStatus()) && "INIT".equals(orderInfo.getServiceStatus()))) {
)) {
log.warn("算法结果更新到工单, step1.1-loop, 工单状态异常, groupId:{}, batchNo:{}, orderId:{}, bean-status:{}, appointment-status:{}, order-status:{}, service-status:{}",
groupId, batchNo, orderId, orderInfo.getBeanStatus(), orderInfo.getAppointmentStatus(), orderInfo.getOrderStatus(), orderInfo.getServiceStatus());
return;
}
EngineerInfo engineerInfo = engineerInfoMap.get(engCode);
if (engineerInfo == null) {
log.warn("算法结果更新到工单, step1.1-loop, 未找到技术员, groupId:{}, batchNo:{}, engCode:{}",
groupId, batchNo, engCode);
return;
}
String engName = engineerInfo.getName();
String phone = engineerInfo.getPhone();
/*int age = 0;
if (!StringUtils.isNullOrEmpty(engineerInfo.getBirth())) {
DateTime birthDate = DateUtil.parse(engineerInfo.getBirth(), "yyyy-MM-dd");
age = DateUtil.age(birthDate.toJdkDate(), DateUtil.date());
}*/
orderInfo.setEngineerCode(engCode);
orderInfo.setEngineerName(engName);
orderInfo.setEngineerPhone(phone);
orderInfo.setPlanStartTime(dispatchOrder.getTimeBegin());
orderInfo.setPlanEndTime(dispatchOrder.getTimeEnd());
orderInfo.setArriveElapsed(dispatchOrder.getPathTime());
orderInfo.setArriveDistance(dispatchOrder.getPathDistance());
orderInfo.setAppointmentStatus(isConfirm ? "CONFIRM" : "PRE");
orderInfo.setUpdateTime(LocalDateTime.now());
orderInfoRepo.save(orderInfo);
OrderLog orderLog = new OrderLog().setOrderId(orderId).setSuborderId(orderInfo.getSubId()).setSource("PEA-DISPATCH").setOperator("DISPATCH")
.setContent(String.format("批量自动指派:<%s,%s>", engCode, engName)).setContentOld("")
.setMemo("批量自动指派").setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderLogRepo.save(orderLog);
if (isConfirm) {
OrderEvent orderEvent = new OrderEvent().setOrderId(orderId).setSuborderId(orderInfo.getSubId()).setHappen(LocalDateTime.now())
.setEvent("批量自动指派").setOperator("DISPATCH").setOperatorName("算法批量指派").setSource("PEA-DISPATCH")
.setDescription(String.format("批量自动指派:<%s,%s>", engCode, engName)).setMemo("")
.setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderEventRepo.save(orderEvent);
// 未分配技术员时,清理原分配的信息
if (!StrUtil.isEmpty(engCode)) {
EngineerInfo engineerInfo = engineerInfoMap.get(engCode);
if (engineerInfo == null) {
log.warn("算法结果更新到工单, step1.1-loop, 未找到技术员, groupId:{}, batchNo:{}, engCode:{}",
groupId, batchNo, engCode);
return;
}
String engName = engineerInfo.getName();
String phone = engineerInfo.getPhone();
/*int age = 0;
if (!StringUtils.isNullOrEmpty(engineerInfo.getBirth())) {
DateTime birthDate = DateUtil.parse(engineerInfo.getBirth(), "yyyy-MM-dd");
age = DateUtil.age(birthDate.toJdkDate(), DateUtil.date());
}*/
orderInfo.setEngineerCode(engCode);
orderInfo.setEngineerName(engName);
orderInfo.setEngineerPhone(phone);
orderInfo.setPlanStartTime(dispatchOrder.getTimeBegin());
orderInfo.setPlanEndTime(dispatchOrder.getTimeEnd());
orderInfo.setArriveElapsed(dispatchOrder.getPathTime());
orderInfo.setArriveDistance(dispatchOrder.getPathDistance());
orderInfo.setAppointmentStatus(isConfirm ? "CONFIRM" : "PRE");
orderInfo.setUpdateTime(LocalDateTime.now());
orderInfoRepo.save(orderInfo);
if (isConfirm) {
OrderEvent orderEvent = new OrderEvent().setOrderId(orderId).setSuborderId(orderInfo.getSubId()).setHappen(LocalDateTime.now())
.setEvent("批量自动指派").setOperator("DISPATCH").setOperatorName("算法批量指派").setSource("PEA-DISPATCH")
.setDescription(String.format("批量自动指派:<%s,%s>", engCode, engName)).setMemo("")
.setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderEventRepo.save(orderEvent);
}
OrderLog orderLog = new OrderLog().setOrderId(orderId).setSuborderId(orderInfo.getSubId()).setSource("PEA-DISPATCH").setOperator("DISPATCH")
.setContent(String.format("批量自动指派:<%s,%s>", engCode, engName)).setContentOld("")
.setMemo("批量自动指派").setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now());
orderLogRepo.save(orderLog);
} else {
log.warn("算法结果更新到工单, step1.2-loop, 未能分配到技术员, groupId:{}, batchNo:{}, orderId:{}, dt:{}",
groupId, batchNo, orderId, dt);
orderInfo.setEngineerCode("");
orderInfo.setEngineerName("");
orderInfo.setEngineerPhone("");
orderInfo.setPlanStartTime(null);
orderInfo.setPlanEndTime(null);
orderInfo.setArriveElapsed(0);
orderInfo.setArriveDistance(0);
orderInfo.setAppointmentStatus("INIT");
orderInfo.setUpdateTime(LocalDateTime.now());
orderInfoRepo.save(orderInfo);
}
});
......
......@@ -137,7 +137,7 @@ public class SolveServiceImpl implements SolveService {
customerList.add(customer);
});
log.info("组织问题对象, customer-list, groupId:{}, batchNo:{}, customer-list:{}", groupId, batchNo, customerList);
log.info("组织问题对象, customer-list, groupId:{}, batchNo:{}, customer-list:{}", groupId, batchNo, customerList.size());
// depotlist 技术员中收点列表
ArrayList<Depot> depotList = new ArrayList<Depot>();
......@@ -166,7 +166,6 @@ public class SolveServiceImpl implements SolveService {
log.info("组织问题对象, depotList-list, groupId:{}, batchNo:{}, depotList-list:{}", groupId, batchNo, depotList.size());
log.info("组织问题对象, technician-list, groupId:{}, batchNo:{}, technician-list:{}", groupId, batchNo, technicianList.size());
log.info("组织问题对象, technician-list, groupId:{}, batchNo:{}, customer-list:{}", groupId, batchNo, customerList.size());
//locationlist
List<Location> locationList = Stream.concat(depotList.stream().map(Depot::getLocation), customerList.stream().map(Customer::getLocation)).collect(Collectors.toList());
......
......@@ -54,7 +54,7 @@ class SolveServiceTest {
SolverConfig solverConfig = new SolverConfig().withSolutionClass(DispatchSolution.class);
solverConfig.withEntityClassList(Arrays.asList(Technician.class, Customer.class));// 这里不能漏掉,否则约束不生效
solverConfig.withConstraintProviderClass(DispatchConstraintProvider.class);
solverConfig.withTerminationSpentLimit(Duration.ofSeconds(20));
solverConfig.withTerminationSpentLimit(Duration.ofSeconds(10));
solverFactory = SolverFactory.create(solverConfig);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!