Commit 5c08350f by 张晓

Merge branch 'feature-dispatch-zx' into develop

2 parents 5da780c4 28d370cc
...@@ -4,7 +4,6 @@ package com.dituhui.pea.dispatch.controller; ...@@ -4,7 +4,6 @@ package com.dituhui.pea.dispatch.controller;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.dispatch.constraint.DispatchConstraintProvider; 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.Customer;
import com.dituhui.pea.dispatch.pojo.DispatchSolution; import com.dituhui.pea.dispatch.pojo.DispatchSolution;
import com.dituhui.pea.dispatch.pojo.Technician; import com.dituhui.pea.dispatch.pojo.Technician;
...@@ -66,9 +65,11 @@ public class PrepareController { ...@@ -66,9 +65,11 @@ public class PrepareController {
* 运行批次任务,直接返回结果(不重新进行数据准备) * 运行批次任务,直接返回结果(不重新进行数据准备)
*/ */
@GetMapping("/solveTest/{groupId}/{batchNo}") @GetMapping("/solveTest/{groupId}/{batchNo}")
public Result<?> prepareAndSolve(@PathVariable String groupId, @PathVariable String batchNo) { public Result<?> prepareAndSolve(@PathVariable String groupId, @PathVariable String day) {
log.info("prepareSolve, groupId:{}, day:{}", groupId, batchNo); log.info("prepareSolve, groupId:{}, day:{}", groupId, day);
DispatchSolution solution = solveService.prepareAndSolveSolution(groupId, batchNo); 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<Technician> technicianList = solution.getTechnicianList();
List<Customer> customerList = solution.getCustomerList(); List<Customer> customerList = solution.getCustomerList();
HardSoftLongScore score = solution.getScore(); HardSoftLongScore score = solution.getScore();
...@@ -83,8 +84,7 @@ public class PrepareController { ...@@ -83,8 +84,7 @@ public class PrepareController {
@GetMapping("/solveStart/{groupId}/{day}") @GetMapping("/solveStart/{groupId}/{day}")
public Result<?> solveAsync(@PathVariable String groupId, @PathVariable String day) { public Result<?> solveAsync(@PathVariable String groupId, @PathVariable String day) {
log.info("调用引擎处理-异步处理, groupId:{}, day:{}", groupId, day); log.info("调用引擎处理-异步处理, groupId:{}, day:{}", groupId, day);
String batchNo = null; String batchNo = batchService.buildBatchData(groupId, day);
batchNo = batchService.buildBatchData(groupId, day);
// DispatchBatch newBatch= batchService.queryBatchInfoByDay(groupId, day); // DispatchBatch newBatch= batchService.queryBatchInfoByDay(groupId, day);
// log.info("newBatch:{}", newBatch); // log.info("newBatch:{}", newBatch);
...@@ -93,7 +93,10 @@ public class PrepareController { ...@@ -93,7 +93,10 @@ public class PrepareController {
log.info("调用引擎处理, groupId:{}, day:{}, batchNo:{}", groupId, day, batchNo); log.info("调用引擎处理, groupId:{}, day:{}, batchNo:{}", groupId, day, batchNo);
DispatchSolution problem = solveService.prepareSolution(groupId, 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); DispatchSolution solution = solver.solve(problem);
solveService.saveSolutionWrp(solution); solveService.saveSolutionWrp(solution);
......
...@@ -17,7 +17,7 @@ public interface SolveService { ...@@ -17,7 +17,7 @@ public interface SolveService {
* 按小组、批次号组装问题对象 * 按小组、批次号组装问题对象
* 调用optaplaner计算输出结果 * 调用optaplaner计算输出结果
* */ * */
DispatchSolution prepareAndSolveSolution(String groupId, String batchNo); DispatchSolution prepareAndSolveTest(String groupId, String batchNo);
UUID generateProblemId(String groupId, String batchNo); UUID generateProblemId(String groupId, String batchNo);
......
...@@ -110,7 +110,6 @@ public class SolveServiceImpl implements SolveService { ...@@ -110,7 +110,6 @@ public class SolveServiceImpl implements SolveService {
if (dispatchOrderList.isEmpty()) { if (dispatchOrderList.isEmpty()) {
log.error("组织问题对象, 未查询到工单信息 ,groupId:{}, batchNo:{}", groupId, batchNo); log.error("组织问题对象, 未查询到工单信息 ,groupId:{}, batchNo:{}", groupId, batchNo);
throw new RuntimeException(String.format("组织问题对象, 未查询到工单信息 ,groupId:%s, batchNo:%s", groupId, batchNo));
} }
dispatchOrderList.forEach(order -> { dispatchOrderList.forEach(order -> {
...@@ -195,11 +194,15 @@ public class SolveServiceImpl implements SolveService { ...@@ -195,11 +194,15 @@ public class SolveServiceImpl implements SolveService {
* 调用optaplaner计算输出结果 * 调用optaplaner计算输出结果
* */ * */
@Override @Override
public DispatchSolution prepareAndSolveSolution(String groupId, String batchNo) { public DispatchSolution prepareAndSolveTest(String groupId, String batchNo) {
log.info("组织问题对象/调用引擎处理, groupId:{}, batchNo:{}", groupId, batchNo); log.info("组织问题对象/调用引擎处理, groupId:{}, batchNo:{}", groupId, batchNo);
// Load the problem // Load the problem
DispatchSolution problem = prepareSolution(groupId, batchNo); 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); SolverConfig solverConfig = new SolverConfig().withSolutionClass(DispatchSolution.class);
......
...@@ -57,7 +57,7 @@ class SolveServiceTest { ...@@ -57,7 +57,7 @@ class SolveServiceTest {
log.info("init"); log.info("init");
DispatchSolution solution = solveService.prepareAndSolveSolution(groupId, batchNo); DispatchSolution solution = solveService.prepareAndSolveTest(groupId, batchNo);
log.info("result:{}", solution); 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!