1. 修改分配任务逻辑,增加装载机的独立性。

2. 修改整理大盒子部分逻辑。
This commit is contained in:
梁州 2025-04-15 13:20:38 +08:00
parent 691c4234ce
commit 3c1f3a3c37
3 changed files with 42 additions and 28 deletions

View File

@ -9,17 +9,14 @@ import com.wms.constants.enums.ResponseCode;
import com.wms.entity.app.ResponseEntity; import com.wms.entity.app.ResponseEntity;
import com.wms.entity.app.dto.PageDto; import com.wms.entity.app.dto.PageDto;
import com.wms.entity.app.dto.StockOfGoodsDto; import com.wms.entity.app.dto.StockOfGoodsDto;
import com.wms.entity.app.dto.extend.KanbanEntity;
import com.wms.entity.app.request.*; import com.wms.entity.app.request.*;
import com.wms.entity.app.vo.*; import com.wms.entity.app.vo.*;
import com.wms.entity.table.*; import com.wms.entity.table.*;
import com.wms.service.*; import com.wms.service.*;
import com.wms.utils.HttpUtils; import com.wms.utils.HttpUtils;
import com.wms.utils.StringUtils; import com.wms.utils.StringUtils;
import com.wms.utils.excel.vo.ClcKanbanRequirementExcelVo;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.joda.time.LocalDate;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -842,19 +839,30 @@ public class KateWorkQueryController {
} }
// 返回结果 // 返回结果
Map<String, BigBoxVo> bigBoxVoMap = new HashMap<>(); Map<String, BigBoxVo> bigBoxVoMap = new HashMap<>();
// 查询到当前站台所有的大盒子 // 找出本次工作的标签位
List<WorkStationConfig> stationConfigs = workStationConfigService.list(new LambdaQueryWrapper<WorkStationConfig>()
.eq(WorkStationConfig::getWorkStation, standId));
for (WorkStationConfig currentBigBoxConfig : stationConfigs) {
// 当前配置的工单数/大盒子
int orderQuantity = currentBigBoxConfig.getOrderQuantity();
// 查询这个大盒子对应的小盒子
List<String> smallBoxListOfAll = stationConfigs.stream().map(WorkStationConfig::getSmallBox).distinct().toList();
// 找出本次工作中的标签位
List<ELocationConfigLast> eConfigLastList = eLocationConfigLastService.list(new LambdaQueryWrapper<ELocationConfigLast>() List<ELocationConfigLast> eConfigLastList = eLocationConfigLastService.list(new LambdaQueryWrapper<ELocationConfigLast>()
.eq(ELocationConfigLast::getWorkStation, standId) .eq(ELocationConfigLast::getWorkStation, standId));
.in(ELocationConfigLast::getWorkCenter, smallBoxListOfAll)); // 整理出所有的小盒子号
if (eConfigLastList.isEmpty()) { List<String> smallBoxList = eConfigLastList.stream().map(ELocationConfigLast::getWorkCenter).distinct().toList();
// 查询出对应小盒子的工站配置
List<WorkStationConfig> stationConfigs = workStationConfigService.list(new LambdaQueryWrapper<WorkStationConfig>()
.in(WorkStationConfig::getSmallBox, smallBoxList));
// 整理出每个大盒子的工单数
Map<String, Integer> bigBoxOrderQuantityMap = new HashMap<>();
for (WorkStationConfig currentBigBoxConfig : stationConfigs) {
if (!bigBoxOrderQuantityMap.containsKey(currentBigBoxConfig.getBigBox())) {
// 添加大盒子-工单数
bigBoxOrderQuantityMap.put(currentBigBoxConfig.getBigBox(), currentBigBoxConfig.getOrderQuantity());
}
}
// 生成结果集
for (String bigBox : bigBoxOrderQuantityMap.keySet()) {
int orderQuantity = bigBoxOrderQuantityMap.get(bigBox);
// 查询这个大盒子对应的小盒子
List<String> smallBoxListOfAll = stationConfigs.stream().filter(currentBigBoxConfig -> currentBigBoxConfig.getBigBox().equals(bigBox)).map(WorkStationConfig::getSmallBox).distinct().toList();
// 找出本次工作中的标签位
List<ELocationConfigLast> thisBigBoxEConfigLastList = eConfigLastList.stream().filter(currentEConfigLast -> smallBoxListOfAll.contains(currentEConfigLast.getWorkCenter())).toList();
if (thisBigBoxEConfigLastList.isEmpty()) {
continue; continue;
} }
// 设置返回结果 // 设置返回结果
@ -863,21 +871,16 @@ public class KateWorkQueryController {
boxQuantity = 1; boxQuantity = 1;
} else { } else {
// 根据这些小盒子号找到对应的工单 // 根据这些小盒子号找到对应的工单
List<String> orderIds = eConfigLastList.stream().map(ELocationConfigLast::getWorkOrder).distinct().toList(); List<String> orderIds = thisBigBoxEConfigLastList.stream().map(ELocationConfigLast::getWorkOrder).distinct().toList();
boxQuantity = boxQuantity + (orderIds.size() / orderQuantity); boxQuantity = (orderIds.size() + orderQuantity - 1) / orderQuantity;
} }
// //
String key = currentBigBoxConfig.getWorkStation() + "_" + currentBigBoxConfig.getBigBox(); if (!bigBoxVoMap.containsKey(bigBox)) {
if (bigBoxVoMap.containsKey(key)) {
BigBoxVo bigBoxVo = bigBoxVoMap.get(key);
bigBoxVo.setBoxQuantity(bigBoxVo.getBoxQuantity() + boxQuantity);
bigBoxVoMap.replace(key, bigBoxVo);
} else {
BigBoxVo bigBoxVo = new BigBoxVo(); BigBoxVo bigBoxVo = new BigBoxVo();
bigBoxVo.setStandId(standId); bigBoxVo.setStandId(standId);
bigBoxVo.setBigBoxNo(currentBigBoxConfig.getBigBox()); bigBoxVo.setBigBoxNo(bigBox);
bigBoxVo.setBoxQuantity(boxQuantity); bigBoxVo.setBoxQuantity(boxQuantity);
bigBoxVoMap.put(key, bigBoxVo); bigBoxVoMap.put(bigBox, bigBoxVo);
} }
} }

View File

@ -2595,8 +2595,7 @@ public class TaskController {
} }
// 判断大盒子号是否正确 // 判断大盒子号是否正确
List<WorkStationConfig> stationConfigs = workStationConfigService.list(new LambdaQueryWrapper<WorkStationConfig>() List<WorkStationConfig> stationConfigs = workStationConfigService.list(new LambdaQueryWrapper<WorkStationConfig>()
.eq(WorkStationConfig::getBigBox, sortBoxRequest.getBigBoxNo()) .eq(WorkStationConfig::getBigBox, sortBoxRequest.getBigBoxNo()));
.eq(WorkStationConfig::getWorkStation, standId));
if (stationConfigs == null || stationConfigs.isEmpty()) { if (stationConfigs == null || stationConfigs.isEmpty()) {
logger.error("请输入正确的大盒子号。"); logger.error("请输入正确的大盒子号。");
response.setCode(ResponseCode.ERROR.getCode()); response.setCode(ResponseCode.ERROR.getCode());
@ -2695,8 +2694,7 @@ public class TaskController {
} }
// 判断大盒子号是否正确 // 判断大盒子号是否正确
List<WorkStationConfig> stationConfigs = workStationConfigService.list(new LambdaQueryWrapper<WorkStationConfig>() List<WorkStationConfig> stationConfigs = workStationConfigService.list(new LambdaQueryWrapper<WorkStationConfig>()
.eq(WorkStationConfig::getBigBox, sortBoxRequest.getBigBoxNo()) .eq(WorkStationConfig::getBigBox, sortBoxRequest.getBigBoxNo()));
.eq(WorkStationConfig::getWorkStation, standId));
if (stationConfigs == null || stationConfigs.isEmpty()) { if (stationConfigs == null || stationConfigs.isEmpty()) {
logger.error("请输入正确的大盒子号。"); logger.error("请输入正确的大盒子号。");
response.setCode(ResponseCode.ERROR.getCode()); response.setCode(ResponseCode.ERROR.getCode());

View File

@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.wms.constants.enums.*; import com.wms.constants.enums.*;
import com.wms.entity.app.dto.KateOrdersDto; import com.wms.entity.app.dto.KateOrdersDto;
import com.wms.entity.app.dto.WorkCenterAndOrderDto;
import com.wms.entity.app.dto.extend.StockDetailInfo; import com.wms.entity.app.dto.extend.StockDetailInfo;
import com.wms.entity.table.*; import com.wms.entity.table.*;
import com.wms.service.*; import com.wms.service.*;
@ -861,6 +860,7 @@ public class WorkServiceImplements implements IWorkService {
// .eq(WorkFlow::getWorkStation, workStation) // .eq(WorkFlow::getWorkStation, workStation)
// .eq(WorkFlow::getMachineType, 1) // .eq(WorkFlow::getMachineType, 1)
// .ne(WorkFlow::getWorkStatus, -1)); // .ne(WorkFlow::getWorkStatus, -1));
int currentWorkType = -1;
if (!StringUtils.isEmpty(workPriority) && workPriority.equals("1")) { if (!StringUtils.isEmpty(workPriority) && workPriority.equals("1")) {
// 当前工作优先级为先平地机后装载机 // 当前工作优先级为先平地机后装载机
// 查询当前站台是否还有装载机的任务没做完 // 查询当前站台是否还有装载机的任务没做完
@ -909,8 +909,10 @@ public class WorkServiceImplements implements IWorkService {
return; return;
} }
needDistributeWorks.addAll(mwlWorks); needDistributeWorks.addAll(mwlWorks);
currentWorkType = 1;// 装载机
} else { } else {
needDistributeWorks.addAll(oldWorkFlows); needDistributeWorks.addAll(oldWorkFlows);
currentWorkType = 2;// 平地机
} }
} else { } else {
// 默认优先级为先装载机后平地机 // 默认优先级为先装载机后平地机
@ -956,8 +958,10 @@ public class WorkServiceImplements implements IWorkService {
return; return;
} }
needDistributeWorks.addAll(mgWorks); needDistributeWorks.addAll(mgWorks);
currentWorkType = 2;// 平地机
} else { } else {
needDistributeWorks.addAll(oldWorkFlows); needDistributeWorks.addAll(oldWorkFlows);
currentWorkType = 1;// 装载机
} }
} }
// 最终需要存储的数据 // 最终需要存储的数据
@ -986,7 +990,16 @@ public class WorkServiceImplements implements IWorkService {
// 然后获取大盒子-订单的map // 然后获取大盒子-订单的map
Map<String, List<WorkFlow>> workFlowsByBigBoxMap = new HashMap<>(); Map<String, List<WorkFlow>> workFlowsByBigBoxMap = new HashMap<>();
// 获取工站配置 // 获取工站配置
List<WorkStationConfig> workStationConfigs = workStationConfigService.list(); LambdaQueryWrapper<WorkStationConfig> wsConfigQueryWrapper = new LambdaQueryWrapper<>();
if (currentWorkType == 1) {
// 当前是装载机工作装载机要区分站台
wsConfigQueryWrapper.eq(WorkStationConfig::getWorkStation, workStation)
.eq(WorkStationConfig::getModel, "MWL");
} else {
// 当前是平地机工作
wsConfigQueryWrapper.ne(WorkStationConfig::getModel, "MWL");
}
List<WorkStationConfig> workStationConfigs = workStationConfigService.list(wsConfigQueryWrapper);
// 根据小盒子号生成map // 根据小盒子号生成map
Map<String, String> smallBoxToBigBoxConfigMap = workStationConfigs.stream().collect(Collectors.toMap(WorkStationConfig::getSmallBox, WorkStationConfig::getBigBox)); Map<String, String> smallBoxToBigBoxConfigMap = workStationConfigs.stream().collect(Collectors.toMap(WorkStationConfig::getSmallBox, WorkStationConfig::getBigBox));
for (WorkFlow workFlow : needDistributeWorks) { for (WorkFlow workFlow : needDistributeWorks) {