Commit 28d370cc by 张晓

fix 无工单时异常

1 parent e54b9dbe
......@@ -4,7 +4,6 @@ package com.dituhui.pea.dispatch.controller;
import cn.hutool.core.map.MapUtil;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.dispatch.constraint.DispatchConstraintProvider;
import com.dituhui.pea.dispatch.entity.DispatchBatch;
import com.dituhui.pea.dispatch.pojo.Customer;
import com.dituhui.pea.dispatch.pojo.DispatchSolution;
import com.dituhui.pea.dispatch.pojo.Technician;
......@@ -66,9 +65,11 @@ public class PrepareController {
* 运行批次任务,直接返回结果(不重新进行数据准备)
*/
@GetMapping("/solveTest/{groupId}/{batchNo}")
public Result<?> prepareAndSolve(@PathVariable String groupId, @PathVariable String batchNo) {
log.info("prepareSolve, groupId:{}, day:{}", groupId, batchNo);
DispatchSolution solution = solveService.prepareAndSolveSolution(groupId, batchNo);
public Result<?> prepareAndSolve(@PathVariable String groupId, @PathVariable String day) {
log.info("prepareSolve, groupId:{}, day:{}", groupId, day);
String batchNo = batchService.buildBatchData(groupId, day);
log.info("调用引擎处理, groupId:{}, day:{}, batchNo:{}", groupId, day, batchNo);
DispatchSolution solution = solveService.prepareAndSolveTest(groupId, batchNo);
List<Technician> technicianList = solution.getTechnicianList();
List<Customer> customerList = solution.getCustomerList();
HardSoftLongScore score = solution.getScore();
......@@ -83,8 +84,7 @@ public class PrepareController {
@GetMapping("/solveStart/{groupId}/{day}")
public Result<?> solveAsync(@PathVariable String groupId, @PathVariable String day) {
log.info("调用引擎处理-异步处理, groupId:{}, day:{}", groupId, day);
String batchNo = null;
batchNo = batchService.buildBatchData(groupId, day);
String batchNo = batchService.buildBatchData(groupId, day);
// DispatchBatch newBatch= batchService.queryBatchInfoByDay(groupId, day);
// log.info("newBatch:{}", newBatch);
......@@ -93,7 +93,10 @@ public class PrepareController {
log.info("调用引擎处理, groupId:{}, day:{}, batchNo:{}", groupId, day, batchNo);
DispatchSolution problem = solveService.prepareSolution(groupId, batchNo);
if (problem.getCustomerList().size() <= 0) {
log.info("dispatchRun no order , group:{}, day:{}, batch:{}, order-size:{}", groupId, day, batchNo, problem.getCustomerList().size());
return Result.failed("当前批次没有工单数据");
}
DispatchSolution solution = solver.solve(problem);
solveService.saveSolutionWrp(solution);
......
......@@ -17,7 +17,7 @@ public interface SolveService {
* 按小组、批次号组装问题对象
* 调用optaplaner计算输出结果
* */
DispatchSolution prepareAndSolveSolution(String groupId, String batchNo);
DispatchSolution prepareAndSolveTest(String groupId, String batchNo);
UUID generateProblemId(String groupId, String batchNo);
......
......@@ -110,7 +110,6 @@ public class SolveServiceImpl implements SolveService {
if (dispatchOrderList.isEmpty()) {
log.error("组织问题对象, 未查询到工单信息 ,groupId:{}, batchNo:{}", groupId, batchNo);
throw new RuntimeException(String.format("组织问题对象, 未查询到工单信息 ,groupId:%s, batchNo:%s", groupId, batchNo));
}
dispatchOrderList.forEach(order -> {
......@@ -195,11 +194,15 @@ public class SolveServiceImpl implements SolveService {
* 调用optaplaner计算输出结果
* */
@Override
public DispatchSolution prepareAndSolveSolution(String groupId, String batchNo) {
public DispatchSolution prepareAndSolveTest(String groupId, String batchNo) {
log.info("组织问题对象/调用引擎处理, groupId:{}, batchNo:{}", groupId, batchNo);
// Load the problem
DispatchSolution problem = prepareSolution(groupId, batchNo);
if (problem.getCustomerList().size() <= 0) {
log.info("dispatchRun no order , group:{}, batch:{}, order-size:{}", groupId, batchNo, problem.getCustomerList().size());
throw new RuntimeException("当前批次没有工单信息");
}
SolverConfig solverConfig = new SolverConfig().withSolutionClass(DispatchSolution.class);
......
......@@ -57,7 +57,7 @@ class SolveServiceTest {
log.info("init");
DispatchSolution solution = solveService.prepareAndSolveSolution(groupId, batchNo);
DispatchSolution solution = solveService.prepareAndSolveTest(groupId, batchNo);
log.info("result:{}", solution);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!