Commit a7a5faab by 张晓

补充回写逻辑

1 parent d5696b02
......@@ -78,7 +78,7 @@ public class PrepareController {
VehicleRoutingSolution problem= solveService.prepareSolution(groupId, batchNo);
solverManager.solveAndListen(problemId, id -> problem,
this.prepareService::saveSolutionToDispatch);
this.prepareService::saveAndExtractSolution);
log.error("调用引擎处理-异步处理, 已触发异步, groupId:{}, batchNo:{}", groupId, batchNo);
......
......@@ -17,9 +17,16 @@ public interface PrepareService {
/*
* 将计算结果回写到dispatch2个表、以及order两个表
* 是下面两个方法的包装
* */
void saveAndExtractSolution(VehicleRoutingSolution solution) throws RuntimeException;
/*
* 将计算结果回写到dispatch_order表(更新补充技术员工号、上门时间)
* */
void saveSolutionToDispatch(VehicleRoutingSolution solution) throws RuntimeException;
void saveSolutionToDispatch(String groupId, String batchNo, VehicleRoutingSolution solution) throws RuntimeException;
/*
* 将dispath_order 中的计算结果,回写到 order_request, order_appointment
......@@ -28,4 +35,6 @@ public interface PrepareService {
* */
void extractDispatchToOrder(String groupId, String batchNo) throws SQLException;
}
......@@ -62,32 +62,46 @@ public class PrepareServiceImpl implements PrepareService {
OrderAppointmentRepository orderAppointmentRepo;
/*
* 将计算结果回写到dispatch2个表、以及order两个表
* */
@Override
public void saveAndExtractSolution(VehicleRoutingSolution solution) throws RuntimeException{
String groupId = solution.getGroupId();
String batchNo = solution.getBatchNo();
log.info("算法结果回写包装方法, groupId:{}, batchNo:{}", groupId, batchNo);
this.saveSolutionToDispatch(groupId, batchNo, solution);
try {
this.extractDispatchToOrder(solution.getGroupId(), solution.getBatchNo());
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
/**
* 将计算结果回写到dispatch_order表(更新补充技术员工号、上门时间)
*/
@Override
public void saveSolutionToDispatch(VehicleRoutingSolution solution) throws RuntimeException {
String groupId = solution.getGroupId();
String batchNo = solution.getBatchNo();
log.info("算法结果回写, groupId:{}, batchNo:{}", groupId, batchNo);
public void saveSolutionToDispatch(String groupId, String batchNo, VehicleRoutingSolution solution) throws RuntimeException {
log.info("算法结果回写dispatch, groupId:{}, batchNo:{}", groupId, batchNo);
// 清理当前批次指派结果
log.info("算法结果回写, step1-清除历史, groupId:{}, batchNo:{}", groupId, batchNo);
log.info("算法结果回写dispatch, step1-清除历史, groupId:{}, batchNo:{}", groupId, batchNo);
Object[] paramClear = {groupId, batchNo};
try {
queryRunner.update(" update dispatch_order set engineer_code='' , seq=0, time_begin=null ,time_end=null where group_id=? and batch_no=? ", paramClear);
} catch (SQLException e) {
log.info("算法结果回写, step1-清除历史异常, groupId:{}, batchNo:{}", groupId, batchNo);
log.info("算法结果回写dispatch, step1-清除历史异常, groupId:{}, batchNo:{}", groupId, batchNo);
throw new RuntimeException(e);
}
String sql = "update dispatch_order set engineer_code=? , seq=?, time_begin=? ,time_end=? where group_id=? and batch_no=? and order_id=? ";
log.info("算法结果回写, step2-开始回写, groupId:{}, batchNo:{}", groupId, batchNo);
log.info("算法结果回写dispatch, step2-开始回写, groupId:{}, batchNo:{}", groupId, batchNo);
// 保存当前批次指派结果
solution.getVehicleList().forEach(vehicle -> {
log.info("算法结果回写, step2.1-按技术员逐个回写, groupId:{}, batchNo:{}, employ: {}, max-minute:{}, customlist.size:{}",
log.info("算法结果回写dispatch, step2.1-按技术员逐个回写, groupId:{}, batchNo:{}, employ: {}, max-minute:{}, customlist.size:{}",
groupId, batchNo, vehicle.getId(), vehicle.getMaxMinute(), vehicle.getCustomerList().size());
AtomicInteger seq = new AtomicInteger();
......@@ -112,7 +126,7 @@ public class PrepareServiceImpl implements PrepareService {
LocalDateTime localEndTime = localExpectBegin.plusMinutes(dOrder.getTakeTime());
Date end = Date.from(localEndTime.atZone(ZoneId.systemDefault()).toInstant());
log.info("算法结果回写, step3-逐个客户处理, groupId:{}, batchNo:{}, employ: {}, customer:{}, customer-duration:{} ",
log.info("算法结果回写dispatch, step3-逐个客户处理, groupId:{}, batchNo:{}, employ: {}, customer:{}, customer-duration:{} ",
groupId, batchNo, vehicle.getId(), customer.getId(), customer.getDuration());
Object[] param = {vehicle.getId(), idx, expectBegin[0], end, groupId, batchNo, customer.getId()};
......@@ -120,7 +134,7 @@ public class PrepareServiceImpl implements PrepareService {
try {
queryRunner.update(sql, param);
} catch (SQLException e) {
log.error("算法结果回写, step3-逐个客户处理, sqlerror", e);
log.error("算法结果回写dispatch, step3-逐个客户处理, sqlerror", e);
throw new RuntimeException(e);
}
......@@ -132,7 +146,7 @@ public class PrepareServiceImpl implements PrepareService {
});
log.info("算法结果回写完成, groupId:{}, batchNo:{}", groupId, batchNo);
log.info("算法结果回写dispatch完成, groupId:{}, batchNo:{}", groupId, batchNo);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!