Compare commits
No commits in common. "1a33acc5fa71ebdf92640c123fcb8f48da45b96f" and "0a67e7dc502a55988cadc870e488aee14cba5e44" have entirely different histories.
1a33acc5fa
...
0a67e7dc50
|
|
@ -1,7 +1,6 @@
|
|||
package com.wms.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.wms.constants.enums.ConfigMapKeyEnum;
|
||||
import com.wms.entity.table.Config;
|
||||
import com.wms.entity.table.Location;
|
||||
import com.wms.entity.table.WorkDate;
|
||||
|
|
@ -48,26 +47,12 @@ public class InitLocalConfig implements ApplicationRunner {
|
|||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
List<Config> configs = configService.selectConfigs("");
|
||||
if (!configs.isEmpty()) {
|
||||
if (configs.size() > 0) {
|
||||
for (Config config : configs) {
|
||||
configMap.put(config.getConfigKey(), config.getConfigValue());
|
||||
logger.info("导入系统配置成功---{}:{}", config.getConfigName(), config.getConfigValue());
|
||||
}
|
||||
}
|
||||
// 判断几个默认配置,是否设定
|
||||
if (!configMap.containsKey(ConfigMapKeyEnum.SAME_MACHINE.getConfigKey())) {
|
||||
configMap.put(ConfigMapKeyEnum.SAME_MACHINE.getConfigKey(), "1");
|
||||
logger.info("生成系统配置{}成功。", ConfigMapKeyEnum.SAME_MACHINE.getConfigKey());
|
||||
}
|
||||
if (!configMap.containsKey(ConfigMapKeyEnum.SAME_AREA.getConfigKey())) {
|
||||
configMap.put(ConfigMapKeyEnum.SAME_AREA.getConfigKey(), "1");
|
||||
logger.info("生成系统配置{}成功。", ConfigMapKeyEnum.SAME_AREA.getConfigKey());
|
||||
}
|
||||
if (!configMap.containsKey(ConfigMapKeyEnum.RATE_TYPE.getConfigKey())) {
|
||||
// "1"为少:多,0为多:少
|
||||
configMap.put(ConfigMapKeyEnum.RATE_TYPE.getConfigKey(), "1");
|
||||
logger.info("生成系统配置{}成功。", ConfigMapKeyEnum.RATE_TYPE.getConfigKey());
|
||||
}
|
||||
// 生成库位Map
|
||||
instantLocationMap = locationService.list().stream().collect(Collectors.toMap(Location::getLocationId, location -> location));
|
||||
logger.info("生成库位Map成功。");
|
||||
|
|
|
|||
|
|
@ -18,18 +18,6 @@ public class WmsConstants {
|
|||
|
||||
public static String MYSQL_JSON_CI = "COLLATE utf8mb4_general_ci";
|
||||
|
||||
public static Map<String, Integer> STAND_AREA = ImmutableMap.<String, Integer>builder()
|
||||
.put("ASRS-#1", 1)
|
||||
.put("ASRS-#2", 1)
|
||||
.put("ASRS-#3", 1)
|
||||
.put("ASRS-#4", 1)
|
||||
.put("ASRS-#5", 1)
|
||||
.put("ASRS-#6", 2)
|
||||
.put("ASRS-#7", 2)
|
||||
.put("ASRS-#8", 2)
|
||||
.put("ASRS-#9", 2)
|
||||
.build();
|
||||
|
||||
public static Map<String, String> type_values = ImmutableMap.<String, String>builder()
|
||||
.put("LR01", "CLC一箱两料")
|
||||
.put("LR02", "CLC一箱一料")
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ public enum ConfigMapKeyEnum {
|
|||
ALLOW_EMPTY_BACK("ALLOW_EMPTY_BACK"),
|
||||
SEND_PICK_OUT_TASK("SEND_PICK_OUT_TASK"),
|
||||
MAX_VEHICLE_NUMS("MAX_VEHICLE_NUMS"),// 线体上最大箱子数
|
||||
MAX_VEHICLE_BEFORE("MAX_VEHICLE_BEFORE"),
|
||||
MAX_VEHICLE_AFTER("MAX_VEHICLE_AFTER"),
|
||||
MAX_STAND_VEHICLE_NUMS("MAX_STAND_VEHICLE_NUMS"),// 每个站台最大箱子数
|
||||
MAX_WCS_ACCEPT_NUMS("MAX_WCS_ACCEPT_NUMS"),
|
||||
SLOC_FILTER_STRING("SLOC_FILTER_STRING"),
|
||||
|
|
@ -27,10 +25,7 @@ public enum ConfigMapKeyEnum {
|
|||
SETTING_DATE("SETTING_DATE"),
|
||||
RATE_MIN_TO_MAX("RATE_MIN_TO_MAX"),
|
||||
WORK_PRIORITY("WORK_PRIORITY"),
|
||||
IF_MERGE_TOMORROW("IF_MERGE_TOMORROW"),
|
||||
SAME_MACHINE("SAME_MACHINE"),
|
||||
SAME_AREA("SAME_AREA"),
|
||||
RATE_TYPE("RATE_TYPE");
|
||||
IF_MERGE_TOMORROW("IF_MERGE_TOMORROW");
|
||||
private final String configKey;
|
||||
ConfigMapKeyEnum(String configKey) {
|
||||
this.configKey = configKey;
|
||||
|
|
|
|||
|
|
@ -2052,21 +2052,19 @@ public class TaskController {
|
|||
String finishResult = workService.finishWork(standId);
|
||||
if (Objects.equals(finishResult, "")) {
|
||||
// 锁定当前站台
|
||||
// 暂时先不更改站台状态
|
||||
// String lockMessage;
|
||||
// if (standService.update(new LambdaUpdateWrapper<Stand>()
|
||||
// .set(Stand::getStandStatus, 1)
|
||||
// .set(Stand::getPickVehicleCount, 0)
|
||||
// .eq(Stand::getStandId, standId))) {
|
||||
// lockMessage = "锁定站台成功,整理完大盒子请点击整理结束按钮解锁。";
|
||||
// } else {
|
||||
// lockMessage = "锁定站台失败,请手动锁定。";
|
||||
// }
|
||||
String lockMessage;
|
||||
if (standService.update(new LambdaUpdateWrapper<Stand>()
|
||||
.set(Stand::getStandStatus, 1)
|
||||
.set(Stand::getPickVehicleCount, 0)
|
||||
.eq(Stand::getStandId, standId))) {
|
||||
lockMessage = "锁定站台成功,整理完大盒子请点击整理结束按钮解锁。";
|
||||
} else {
|
||||
lockMessage = "锁定站台失败,请手动锁定。";
|
||||
}
|
||||
|
||||
// 工作完成成功
|
||||
response.setCode(ResponseCode.OK.getCode());
|
||||
response.setMessage("确认成功,请至收盒子界面完成后续操作。");
|
||||
// response.setMessage("确认成功,请至收盒子界面完成后续操作。" + lockMessage);
|
||||
response.setMessage("确认成功,请至收盒子界面完成后续操作。" + lockMessage);
|
||||
} else {
|
||||
// 工作完成失败
|
||||
response.setCode(ResponseCode.ERROR.getCode());
|
||||
|
|
@ -3243,9 +3241,8 @@ public class TaskController {
|
|||
return convertJsonString(response);
|
||||
}
|
||||
// 更新站台为可用状态
|
||||
// 这里先注释掉,通过手动控制状态
|
||||
// targetStand.setStandStatus(0);
|
||||
// standService.updateById(targetStand);
|
||||
targetStand.setStandStatus(0);
|
||||
standService.updateById(targetStand);
|
||||
logger.info("整理大盒子结束,解锁站台成功。");
|
||||
response.setCode(ResponseCode.OK.getCode());
|
||||
response.setMessage("整理大盒子结束,解锁站台成功。");
|
||||
|
|
|
|||
|
|
@ -47,16 +47,4 @@ public class GoodsToStation {
|
|||
*/
|
||||
@TableField("distribute_status")
|
||||
private Integer distributeStatus;
|
||||
/**
|
||||
* 机型
|
||||
* 1: 装载机;2: 平地机
|
||||
*/
|
||||
@TableField("machine_type")
|
||||
private Integer machineType;
|
||||
/**
|
||||
* 区域类型
|
||||
* 1: 前;2: 后
|
||||
*/
|
||||
@TableField("area_type")
|
||||
private Integer areaType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,16 +41,4 @@ public class OutsideVehicles {
|
|||
*/
|
||||
@TableField("out_status")
|
||||
private Integer outStatus;
|
||||
/**
|
||||
* 机型
|
||||
* 1: 装载机;2: 平地机;3:共通
|
||||
*/
|
||||
@TableField("machine_type")
|
||||
private Integer machineType;
|
||||
/**
|
||||
* 区域类型
|
||||
* 1: 前;2: 后;3:共通
|
||||
*/
|
||||
@TableField("area_type")
|
||||
private Integer areaType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,16 +47,4 @@ public class PickTask {
|
|||
*/
|
||||
@TableField("arrive_time")
|
||||
private LocalDateTime arriveTime;
|
||||
/**
|
||||
* 机型
|
||||
* 1: 装载机;2: 平地机
|
||||
*/
|
||||
@TableField("machine_type")
|
||||
private Integer machineType;
|
||||
/**
|
||||
* 区域类型
|
||||
* 1: 前;2: 后
|
||||
*/
|
||||
@TableField("area_type")
|
||||
private Integer areaType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,16 +47,4 @@ public class PickTaskRecord {
|
|||
*/
|
||||
@TableField("arrive_time")
|
||||
private LocalDateTime arriveTime;
|
||||
/**
|
||||
* 机型
|
||||
* 1: 装载机;2: 平地机
|
||||
*/
|
||||
@TableField("machine_type")
|
||||
private Integer machineType;
|
||||
/**
|
||||
* 区域类型
|
||||
* 1: 前;2: 后
|
||||
*/
|
||||
@TableField("area_type")
|
||||
private Integer areaType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,16 +105,4 @@ public class Task {
|
|||
*/
|
||||
@TableField("pick_stand")
|
||||
private String pickStand;
|
||||
/**
|
||||
* 机型
|
||||
* 1: 装载机;2: 平地机
|
||||
*/
|
||||
@TableField("machine_type")
|
||||
private Integer machineType;
|
||||
/**
|
||||
* 区域类型
|
||||
* 1: 前;2: 后
|
||||
*/
|
||||
@TableField("area_type")
|
||||
private Integer areaType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,16 +98,4 @@ public class TaskRecord {
|
|||
*/
|
||||
@TableField("pick_stand")
|
||||
private String pickStand;
|
||||
/**
|
||||
* 机型
|
||||
* 1: 装载机;2: 平地机
|
||||
*/
|
||||
@TableField("machine_type")
|
||||
private Integer machineType;
|
||||
/**
|
||||
* 区域类型
|
||||
* 1: 前;2: 后
|
||||
*/
|
||||
@TableField("area_type")
|
||||
private Integer areaType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.wms.service.business;
|
|||
|
||||
import com.wms.entity.app.request.TaskInRequest;
|
||||
import com.wms.entity.app.request.TaskOutRequest;
|
||||
import com.wms.entity.table.GoodsToStation;
|
||||
import com.wms.entity.table.Task;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -41,7 +40,7 @@ public interface IWmsTaskService {
|
|||
*/
|
||||
String genGoodsOutTask(TaskOutRequest taskOutRequest);
|
||||
|
||||
BigDecimal callGoods(GoodsToStation goodsToStation, BigDecimal needNum, String workStation);
|
||||
BigDecimal callGoods(String goodsId, BigDecimal needNum, String workStation);
|
||||
|
||||
BigDecimal callStocks(GoodsToStation goodsToStation, BigDecimal needNum, String workStation, Map<Integer, Integer> runningTaskNumToEquipmentMap);
|
||||
BigDecimal callStocks(String goodsId, BigDecimal needNum, String workStation, Map<Integer, Integer> runningTaskNumToEquipmentMap);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -694,7 +694,6 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
logger.info("定期清理过期日志数据成功。");
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
logger.error("定期清理日志数据时发生异常:{}", convertJsonString(exception));
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
}
|
||||
|
|
@ -915,7 +914,6 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
logger.info("定期清理DBS完成数据成功。");
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
logger.error("定期清理数据异常:{}", JSON.toJSONString(exception));
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
}
|
||||
|
|
@ -935,23 +933,15 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
public <T> void doWriteExcel(String fileDesc, String filePath, String sheetName, List<T> list, Class<T> clazz) throws IOException {
|
||||
// 内容样式
|
||||
HorizontalCellStyleStrategy horizontalCellStyleStrategy = ExcelContentStyle.getContentStyle();
|
||||
// 判断数据行是不是过多
|
||||
int rowCount = list.size();
|
||||
// 每50万行一个文件
|
||||
int rowCountPerFile = 300000;
|
||||
int fileCounts = (rowCount + rowCountPerFile - 1) / rowCountPerFile;
|
||||
for (int i = 1; i <= fileCounts; i++) {
|
||||
List<T> dividedList = list.subList((i - 1) * rowCountPerFile, Math.min(i * rowCountPerFile, rowCount));
|
||||
File file = new File(filePath + File.separator + fileDesc + "_" + i + ".xlsx");
|
||||
File file = new File(filePath + File.separator + fileDesc + ".xlsx");
|
||||
createFile(file);// 新建文件
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
EasyExcel.write(fos, clazz)
|
||||
.excelType(ExcelTypeEnum.XLSX)
|
||||
.registerWriteHandler(horizontalCellStyleStrategy)
|
||||
.sheet(sheetName)
|
||||
.doWrite(dividedList);
|
||||
logger.info("保存文件成功:{}。", fileCounts > 1 ? fileDesc + "_" + i : fileDesc);
|
||||
}
|
||||
.sheet("库存")
|
||||
.doWrite(list);
|
||||
logger.info("保存文件成功:{}。", fileDesc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1009,28 +999,13 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
List<Task> allTasks = taskService.list(waitForDistributeTaskQuery);
|
||||
if (!allTasks.isEmpty()) {
|
||||
String max_vehicle_nums = configMap.get(ConfigMapKeyEnum.MAX_VEHICLE_NUMS.getConfigKey());
|
||||
String max_vehicle_nums_before = configMap.get(ConfigMapKeyEnum.MAX_VEHICLE_BEFORE.getConfigKey());
|
||||
String max_vehicle_nums_after = configMap.get(ConfigMapKeyEnum.MAX_VEHICLE_AFTER.getConfigKey());
|
||||
String max_wcs_accept_nums = configMap.get(ConfigMapKeyEnum.MAX_WCS_ACCEPT_NUMS.getConfigKey());
|
||||
String max_stand_vehicle_nums = configMap.get(ConfigMapKeyEnum.MAX_STAND_VEHICLE_NUMS.getConfigKey());
|
||||
String minToMax = configMap.get(ConfigMapKeyEnum.RATE_MIN_TO_MAX.getConfigKey());
|
||||
String rateType = configMap.get(ConfigMapKeyEnum.RATE_TYPE.getConfigKey());
|
||||
if (StringUtils.isEmpty(rateType)) {
|
||||
rateType = "1";
|
||||
}
|
||||
if (!"1".equals(configMap.get(ConfigMapKeyEnum.SAME_AREA.getConfigKey()))) {
|
||||
if (StringUtils.isEmpty(max_vehicle_nums) || StringUtils.isEmpty(max_wcs_accept_nums) || StringUtils.isEmpty(max_stand_vehicle_nums)) {
|
||||
logger.error("允许不同区域时配置未生成");
|
||||
logger.error("配置未生成");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.isEmpty(max_vehicle_nums_before) || StringUtils.isEmpty(max_vehicle_nums_after) || StringUtils.isEmpty(max_wcs_accept_nums) || StringUtils.isEmpty(max_stand_vehicle_nums)) {
|
||||
logger.error("不允许不同区域时配置未生成");
|
||||
return;
|
||||
}
|
||||
}
|
||||
List<String> thisTimeCanOutStandIds = new ArrayList<>();
|
||||
if (!"1".equals(configMap.get(ConfigMapKeyEnum.SAME_AREA.getConfigKey()))) {
|
||||
int maxVehicleNums = Integer.parseInt(max_vehicle_nums);// 线体最大箱子数量
|
||||
List<String> outsideVehicles = outsideVehiclesService.selectDistinctVehicles();
|
||||
if (outsideVehicles == null || outsideVehicles.isEmpty()) {
|
||||
|
|
@ -1040,33 +1015,6 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
if (remainVehicleNums <= 0) {
|
||||
return;
|
||||
}
|
||||
thisTimeCanOutStandIds.addAll(List.of("ASRS-#1", "ASRS-#2", "ASRS-#3", "ASRS-#4", "ASRS-#5", "ASRS-#6", "ASRS-#7", "ASRS-#8", "ASRS-#9"));
|
||||
} else {
|
||||
int maxVehicleNumsBefore = Integer.parseInt(max_vehicle_nums_before);// 前区线体最大箱子数量
|
||||
int maxVehicleNumsAfter = Integer.parseInt(max_vehicle_nums_after);// 后区线体最大箱子数量
|
||||
List<OutsideVehicles> outsideVehicles = outsideVehiclesService.list(
|
||||
new LambdaQueryWrapper<OutsideVehicles>().eq(OutsideVehicles::getOutStatus, 1)
|
||||
);
|
||||
Map<String, Integer> vehicleMapBefore = new HashMap<>();
|
||||
Map<String, Integer> vehicleMapAfter = new HashMap<>();
|
||||
for (OutsideVehicles outsideVehicle : outsideVehicles) {
|
||||
if ((outsideVehicle.getAreaType() == 1 || outsideVehicle.getAreaType() == 3) && !vehicleMapBefore.containsKey(outsideVehicle.getVehicleId())) {
|
||||
vehicleMapBefore.put(outsideVehicle.getVehicleId(), 1);
|
||||
}
|
||||
if ((outsideVehicle.getAreaType() == 2 || outsideVehicle.getAreaType() == 3) && !vehicleMapAfter.containsKey(outsideVehicle.getVehicleId())) {
|
||||
vehicleMapAfter.put(outsideVehicle.getVehicleId(), 1);
|
||||
}
|
||||
}
|
||||
// 前区可以
|
||||
if (vehicleMapBefore.size() < maxVehicleNumsBefore) {
|
||||
thisTimeCanOutStandIds.addAll(List.of("ASRS-#1", "ASRS-#2", "ASRS-#3", "ASRS-#4", "ASRS-#5"));
|
||||
}
|
||||
// 后区可以
|
||||
if (vehicleMapAfter.size() < maxVehicleNumsAfter) {
|
||||
thisTimeCanOutStandIds.addAll(List.of("ASRS-#6", "ASRS-#7", "ASRS-#8", "ASRS-#9"));
|
||||
}
|
||||
}
|
||||
|
||||
// 少:多的比率
|
||||
int minToMaxRate = 1;
|
||||
try {
|
||||
|
|
@ -1090,7 +1038,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
List<Stand> stands = standService.list(new LambdaQueryWrapper<Stand>()
|
||||
.eq(Stand::getIsLock, 0).eq(Stand::getStandStatus, 0));
|
||||
// 备料站台---从9号站台开始
|
||||
List<Stand> allPickStands = stands.stream().filter(stand -> stand.getStandType() == 2 && thisTimeCanOutStandIds.contains(stand.getStandId())).sorted(Comparator.comparing(Stand::getStandId).reversed()).toList();
|
||||
List<Stand> allPickStands = stands.stream().filter(stand -> stand.getStandType() == 2).sorted(Comparator.comparing(Stand::getStandId).reversed()).toList();
|
||||
// 找出所有可用堆垛机---从5号堆垛机开始
|
||||
List<Stand> stackerList = stands.stream().filter(stand -> stand.getStandType() == 3).sorted(Comparator.comparingInt(Stand::getEquipmentId).reversed()).toList();
|
||||
// 查询特殊表
|
||||
|
|
@ -1102,14 +1050,11 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
// 能够用的站体的列表
|
||||
List<Stand> pickStands = new ArrayList<>();
|
||||
// 判断哪些站台暂时不能下发任务
|
||||
Map<String, Integer> standPickCountsMap = new HashMap<>();
|
||||
for (Stand pickStand : allPickStands) {
|
||||
// 查询这个站台有多少已下发的拣选任务
|
||||
List<PickTask> thisStandPickCounts = standPickTasks.stream().filter(pickTask -> pickTask.getStandId().equals(pickStand.getStandId()) && pickTask.getPickStatus() >= PickTaskStatusEnum.NEW.getCode()).toList();
|
||||
if (thisStandPickCounts.size() < Integer.parseInt(max_stand_vehicle_nums)) {
|
||||
pickStands.add(pickStand);
|
||||
// 保存当前站台有多少箱子已经可用
|
||||
standPickCountsMap.put(pickStand.getStandId(), thisStandPickCounts.size());
|
||||
}
|
||||
}
|
||||
// 处理数据
|
||||
|
|
@ -1160,9 +1105,6 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
}
|
||||
});
|
||||
String vehicleId;
|
||||
|
||||
// 少 : 多
|
||||
if ("1".equals(rateType)) {
|
||||
if (thisQtyType <= minToMaxRate) {
|
||||
// 最少使用的箱子
|
||||
vehicleId = vehicleStandsMap.entrySet().stream()
|
||||
|
|
@ -1176,22 +1118,6 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
.map(Map.Entry::getKey)
|
||||
.orElse("");
|
||||
}
|
||||
} else {// 多 : 少
|
||||
if (thisQtyType <= minToMaxRate) {
|
||||
// 找最多的
|
||||
vehicleId = vehicleStandsMap.entrySet().stream()
|
||||
.max(Comparator.comparingInt(Map.Entry::getValue))
|
||||
.map(Map.Entry::getKey)
|
||||
.orElse("");
|
||||
} else {
|
||||
// 最少使用的箱子
|
||||
vehicleId = vehicleStandsMap.entrySet().stream()
|
||||
.min(Comparator.comparingInt(Map.Entry::getValue))
|
||||
.map(Map.Entry::getKey)
|
||||
.orElse("");
|
||||
}
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(vehicleId)) {
|
||||
// 找到这个箱子的任务
|
||||
List<Task> outPickTasks = allTasks.stream().filter(task -> task.getVehicleId().equals(vehicleId) && !pickVehicleIds.contains(task.getVehicleId())
|
||||
|
|
@ -1265,27 +1191,21 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
// 查看下一台堆垛机
|
||||
break;
|
||||
}
|
||||
// old 找到暂存拣选任务最多的站台
|
||||
// Map<String, Integer> pickTaskNumsOfStandsMap = new HashMap<>();
|
||||
// for(Stand pickStand : pickStands) {
|
||||
// standPickTasks.forEach(pickTask -> {
|
||||
// if (Objects.equals(pickTask.getPickStatus(), PickTaskStatusEnum.TEMP.getCode())
|
||||
// && thisStackerVehicleIds.contains(pickTask.getVehicleId())
|
||||
// && pickStand.getStandId().equals(pickTask.getStandId())) {
|
||||
// pickTaskNumsOfStandsMap.put(pickTask.getStandId(), pickTaskNumsOfStandsMap.getOrDefault(pickTask.getStandId(), 0) + 1);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// String standId = pickTaskNumsOfStandsMap.entrySet().stream()
|
||||
// .max(Comparator.comparingInt(Map.Entry::getValue))
|
||||
// .map(Map.Entry::getKey)
|
||||
// .orElse("");
|
||||
// new 查找已下发状态以上最少箱子的站台
|
||||
String standId = standPickCountsMap.entrySet().stream()
|
||||
.min(Comparator.comparingInt(Map.Entry::getValue))
|
||||
// 找到暂存拣选任务最多的站台
|
||||
Map<String, Integer> pickTaskNumsOfStandsMap = new HashMap<>();
|
||||
for(Stand pickStand : pickStands) {
|
||||
standPickTasks.forEach(pickTask -> {
|
||||
if (Objects.equals(pickTask.getPickStatus(), PickTaskStatusEnum.TEMP.getCode())
|
||||
&& thisStackerVehicleIds.contains(pickTask.getVehicleId())
|
||||
&& pickStand.getStandId().equals(pickTask.getStandId())) {
|
||||
pickTaskNumsOfStandsMap.put(pickTask.getStandId(), pickTaskNumsOfStandsMap.getOrDefault(pickTask.getStandId(), 0) + 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
String standId = pickTaskNumsOfStandsMap.entrySet().stream()
|
||||
.max(Comparator.comparingInt(Map.Entry::getValue))
|
||||
.map(Map.Entry::getKey)
|
||||
.orElse("");
|
||||
|
||||
// 查找这个站台未下发的料箱
|
||||
List<String> vehicleIds = standPickTasks.stream()
|
||||
.filter(pickTask -> pickTask.getPickStatus().equals(PickTaskStatusEnum.TEMP.getCode())
|
||||
|
|
@ -1354,7 +1274,6 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
// 已经发送过的vehicleId
|
||||
pickVehicleIds.add(vehicleId);
|
||||
availNum--;
|
||||
standPickCountsMap.put(standId, standPickCountsMap.get(standId) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1364,7 +1283,6 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
// 没有新任务发送
|
||||
return;
|
||||
}
|
||||
// simulateSendPickOutTasks(taskGroupIds, pickVehicleIds, needAddStandStackerTasks, needRemoveStandStackerTasks);
|
||||
// 发送任务
|
||||
String url = configMap.get(ConfigMapKeyEnum.URL_WCS_TASK.getConfigKey());
|
||||
if (url != null) {
|
||||
|
|
@ -1452,35 +1370,4 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
throw new Exception("向WCS发送拣选出库任务时发生异常。");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟出库发送成功
|
||||
* @param taskGroupIds
|
||||
* @param pickVehicleIds
|
||||
* @param needAddStandStackerTasks
|
||||
* @param needRemoveStandStackerTasks
|
||||
*/
|
||||
void simulateSendPickOutTasks(List<String> taskGroupIds, List<String> pickVehicleIds, List<StandStackerTask> needAddStandStackerTasks, List<StandStackerTask> needRemoveStandStackerTasks) {
|
||||
logger.info("发送WCS拣选出库任务成功。");
|
||||
taskService.update(new LambdaUpdateWrapper<Task>()
|
||||
.set(Task::getTaskStatus, WmsTaskStatus.WAIT.getCode())
|
||||
.in(Task::getTaskGroup, taskGroupIds)
|
||||
.eq(Task::getTaskStatus, WmsTaskStatus.NEW.getCode()));
|
||||
// 流转载具状态变更
|
||||
if (!pickVehicleIds.isEmpty()) {
|
||||
outsideVehiclesService.update(new LambdaUpdateWrapper<OutsideVehicles>()
|
||||
.set(OutsideVehicles::getOutStatus, 1)
|
||||
.in(OutsideVehicles::getVehicleId, pickVehicleIds));
|
||||
}
|
||||
// 更新特殊信息
|
||||
standStackerTaskService.saveBatch(needAddStandStackerTasks);
|
||||
standStackerTaskService.removeBatchByIds(needRemoveStandStackerTasks);
|
||||
List<StandStackerTaskBak> needSaveRecords = new ArrayList<>();
|
||||
for (StandStackerTask standStackerTask : needRemoveStandStackerTasks) {
|
||||
StandStackerTaskBak standStackerTaskBak = BeanUtil.copyProperties(standStackerTask, StandStackerTaskBak.class);
|
||||
standStackerTaskBak.setRecordId(WmsUtils.generateId("STAND_STACKER_TASK_BAK_"));
|
||||
needSaveRecords.add(standStackerTaskBak);
|
||||
}
|
||||
standStackerTaskBakService.saveBatch(needSaveRecords);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.wms.service.business.serviceImplements;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.wms.constants.enums.*;
|
||||
|
|
@ -28,7 +27,6 @@ import java.time.LocalDateTime;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.wms.config.InitLocalConfig.configMap;
|
||||
import static com.wms.config.InitLocalConfig.instantLocationMap;
|
||||
import static com.wms.constants.WmsConstants.MYSQL_JSON_CI;
|
||||
import static com.wms.utils.StringUtils.convertJsonString;
|
||||
|
|
@ -309,20 +307,16 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
public BigDecimal callGoods(GoodsToStation goodsToStation, BigDecimal needNum, String workStation) {
|
||||
public BigDecimal callGoods(String goodsId, BigDecimal needNum, String workStation) {
|
||||
BigDecimal originNum = needNum;// 原始数量
|
||||
try {
|
||||
// 判断当前物料是否在流转中
|
||||
List<OutsideVehicles> outsideVehiclesList = outsideVehiclesService.list(new LambdaQueryWrapper<OutsideVehicles>()
|
||||
.eq(OutsideVehicles::getGoodsId, goodsToStation.getGoodsId())
|
||||
.eq(OutsideVehicles::getGoodsId, goodsId)
|
||||
.gt(OutsideVehicles::getRemainNum, 0)
|
||||
.ne(OutsideVehicles::getOutStatus, 2));
|
||||
// .eq(Objects.equals(configMap.get(ConfigMapKeyEnum.SAME_AREA.getConfigKey()), "1"), OutsideVehicles::getAreaType, goodsToStation.getAreaType())
|
||||
// .eq(Objects.equals(configMap.get(ConfigMapKeyEnum.SAME_MACHINE.getConfigKey()), "1"), OutsideVehicles::getMachineType, goodsToStation.getMachineType()));
|
||||
List<OutsideVehicles> usedOutsideVehiclesList = new ArrayList<>();
|
||||
if (outsideVehiclesList != null && !outsideVehiclesList.isEmpty()) {
|
||||
Map<String, Integer> vehicleAreaTypeMap = new HashMap<>();
|
||||
Map<String, Integer> vehicleMachineTypeMap = new HashMap<>();
|
||||
// 存在流转中的料箱
|
||||
for (OutsideVehicles outsideVehicle : outsideVehiclesList) {
|
||||
if (needNum.compareTo(BigDecimal.ZERO) <= 0) {// 需求数量小于等于0
|
||||
|
|
@ -331,7 +325,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
// 查询当前料箱当前物料的库存
|
||||
Stock stock = stockService.getOne(new LambdaQueryWrapper<Stock>()
|
||||
.eq(Stock::getVehicleId, outsideVehicle.getVehicleId())
|
||||
.apply("goods_related ->> '$.goodsId' = {0}" + MYSQL_JSON_CI, goodsToStation.getGoodsId())
|
||||
.apply("goods_related ->> '$.goodsId' = {0}" + MYSQL_JSON_CI, goodsId)
|
||||
.apply("goods_related ->> '$.remainNum' > 0")
|
||||
.last("limit 1"));
|
||||
if (stock == null) {
|
||||
|
|
@ -343,24 +337,6 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
outsideVehiclesService.removeById(outsideVehicle);
|
||||
continue;
|
||||
}
|
||||
// 设定区域类型
|
||||
if (outsideVehicle.getAreaType() == null) {
|
||||
outsideVehicle.setAreaType(goodsToStation.getAreaType());
|
||||
} else {
|
||||
if (!outsideVehicle.getAreaType().equals(goodsToStation.getAreaType())) {
|
||||
outsideVehicle.setAreaType(3);
|
||||
}
|
||||
}
|
||||
vehicleAreaTypeMap.put(outsideVehicle.getVehicleId(), outsideVehicle.getAreaType());
|
||||
// 设定机型
|
||||
if (outsideVehicle.getMachineType() == null) {
|
||||
outsideVehicle.setMachineType(goodsToStation.getMachineType());
|
||||
} else {
|
||||
if (!outsideVehicle.getMachineType().equals(goodsToStation.getMachineType())) {
|
||||
outsideVehicle.setMachineType(3);
|
||||
}
|
||||
}
|
||||
vehicleMachineTypeMap.put(outsideVehicle.getVehicleId(), outsideVehicle.getMachineType());
|
||||
if (outsideVehicle.getRemainNum().compareTo(needNum) > 0) {
|
||||
// 当前箱子剩余物料数量多于需求数量
|
||||
outsideVehicle.setRemainNum(outsideVehicle.getRemainNum().subtract(needNum));
|
||||
|
|
@ -378,36 +354,18 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!usedOutsideVehiclesList.isEmpty()) {
|
||||
// 更新流转箱表
|
||||
outsideVehiclesService.updateBatchById(usedOutsideVehiclesList);
|
||||
// 生成拣选任务
|
||||
List<String> vehicleIds = usedOutsideVehiclesList.stream().map(OutsideVehicles::getVehicleId).distinct().toList();
|
||||
List<String> outsideIds = usedOutsideVehiclesList.stream().map(OutsideVehicles::getOutsideId).distinct().toList();
|
||||
// 查找到对应的outsideVehicles
|
||||
List<OutsideVehicles> outsideVehicles = outsideVehiclesService.list(new LambdaQueryWrapper<OutsideVehicles>()
|
||||
.notIn(OutsideVehicles::getOutsideId, outsideIds)
|
||||
.in(OutsideVehicles::getVehicleId, vehicleIds));
|
||||
for (OutsideVehicles outsideVehicle : outsideVehicles) {
|
||||
if (vehicleAreaTypeMap.containsKey(outsideVehicle.getVehicleId())) {
|
||||
outsideVehicle.setAreaType(vehicleAreaTypeMap.get(outsideVehicle.getVehicleId()));
|
||||
}
|
||||
if (vehicleMachineTypeMap.containsKey(outsideVehicle.getVehicleId())) {
|
||||
outsideVehicle.setMachineType(vehicleMachineTypeMap.get(outsideVehicle.getVehicleId()));
|
||||
}
|
||||
}
|
||||
// 更新
|
||||
outsideVehiclesService.updateBatchById(outsideVehicles);
|
||||
// 更新对应任务状态
|
||||
if (!vehicleIds.isEmpty()) {
|
||||
createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.NEW.getCode(), goodsToStation);
|
||||
}
|
||||
createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.NEW.getCode());
|
||||
}
|
||||
}
|
||||
return needNum;
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
logger.error("呼叫物料时发生异常:{}", JSON.toJSONString(e));
|
||||
e.printStackTrace();
|
||||
logger.error("呼叫物料时发生异常:{}", e.getMessage());
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return originNum;
|
||||
|
|
@ -417,15 +375,13 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
public BigDecimal callStocks(GoodsToStation goodsToStation, BigDecimal needNum, String workStation, Map<Integer, Integer> runningTaskNumToEquipmentMap) {
|
||||
public BigDecimal callStocks(String goodsId, BigDecimal needNum, String workStation, Map<Integer, Integer> runningTaskNumToEquipmentMap) {
|
||||
BigDecimal originNum = needNum;// 原始数量
|
||||
try {
|
||||
// 判断当前这个料是否已经有outsideVehicles
|
||||
List<OutsideVehicles> outsideVehiclesList = outsideVehiclesService.list(new LambdaQueryWrapper<OutsideVehicles>()
|
||||
.eq(OutsideVehicles::getGoodsId, goodsToStation.getGoodsId())
|
||||
.eq(OutsideVehicles::getGoodsId, goodsId)
|
||||
.ne(OutsideVehicles::getOutStatus, 2));
|
||||
// .eq(Objects.equals(configMap.get(ConfigMapKeyEnum.SAME_MACHINE.getConfigKey()), "1"), OutsideVehicles::getMachineType, goodsToStation.getMachineType())
|
||||
// .eq(Objects.equals(configMap.get(ConfigMapKeyEnum.SAME_AREA.getConfigKey()), "1"), OutsideVehicles::getAreaType, goodsToStation.getAreaType()));
|
||||
if (!outsideVehiclesList.isEmpty()) {
|
||||
// 这些箱子
|
||||
List<String> outsideVehicleIds = outsideVehiclesList.stream().map(OutsideVehicles::getVehicleId).distinct().toList();
|
||||
|
|
@ -441,7 +397,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
// 查询库存,判断数量是否充足
|
||||
List<Stock> stockList = stockService.list(new LambdaQueryWrapper<Stock>()
|
||||
.eq(Stock::getStockStatus, StockStatus.OK.getCode())
|
||||
.apply("goods_related ->> '$.goodsId' = {0}" + MYSQL_JSON_CI, goodsToStation.getGoodsId())
|
||||
.apply("goods_related ->> '$.goodsId' = {0}" + MYSQL_JSON_CI, goodsId)
|
||||
.apply("goods_related ->> '$.remainNum' > 0")
|
||||
.orderByAsc(Stock::getCreateTime));
|
||||
if (stockList != null && !stockList.isEmpty()) {
|
||||
|
|
@ -505,7 +461,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
}
|
||||
if (!waitForOutStockList.isEmpty()) {
|
||||
// 创建任务
|
||||
createVehicleOutTaskAndPickTask(waitForOutStockList, workStation, goodsToStation);
|
||||
createVehicleOutTaskAndPickTask(waitForOutStockList, workStation);
|
||||
}
|
||||
}
|
||||
return needNum;
|
||||
|
|
@ -522,7 +478,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
*
|
||||
* @param waitForOutStocks 待出库库存
|
||||
*/
|
||||
private void createVehicleOutTaskAndPickTask(List<Stock> waitForOutStocks, String workStation, GoodsToStation goodsToStation) {
|
||||
private void createVehicleOutTaskAndPickTask(List<Stock> waitForOutStocks, String workStation) {
|
||||
// 出库任务列表
|
||||
List<Task> outTasks = new ArrayList<>();
|
||||
// 流转载具列表
|
||||
|
|
@ -547,8 +503,6 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
tempOutTask.setCreateTime(LocalDateTime.now());
|
||||
tempOutTask.setIsPicking(1);
|
||||
tempOutTask.setPickStand(workStation);
|
||||
tempOutTask.setMachineType(goodsToStation.getMachineType());
|
||||
tempOutTask.setAreaType(goodsToStation.getAreaType());
|
||||
outTasks.add(tempOutTask);
|
||||
// 添加载具列表
|
||||
vehicleIds.add(tempStock.getVehicleId());
|
||||
|
|
@ -559,8 +513,6 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
outsideVehicle.setGoodsId(tempStock.getGoodsRelated().getGoodsId());
|
||||
outsideVehicle.setRemainNum(tempStock.getGoodsRelated().getRemainNum());
|
||||
outsideVehicle.setOutStatus(0);
|
||||
outsideVehicle.setMachineType(goodsToStation.getMachineType());
|
||||
outsideVehicle.setAreaType(goodsToStation.getAreaType());
|
||||
outsideVehicles.add(outsideVehicle);
|
||||
}
|
||||
for (String vehicleId : vehicleIds) {
|
||||
|
|
@ -580,8 +532,6 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
outsideVehicle.setGoodsId(vehicleStock.getGoodsRelated().getGoodsId());
|
||||
outsideVehicle.setRemainNum(vehicleStock.getGoodsRelated().getRemainNum());
|
||||
outsideVehicle.setOutStatus(0);
|
||||
outsideVehicle.setMachineType(goodsToStation.getMachineType());
|
||||
outsideVehicle.setAreaType(goodsToStation.getAreaType());
|
||||
outsideVehicles.add(outsideVehicle);
|
||||
}
|
||||
}
|
||||
|
|
@ -600,7 +550,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
// 保存流转箱信息
|
||||
outsideVehiclesService.saveBatch(outsideVehicles);
|
||||
// 保存拣选任务至拣选任务表
|
||||
createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.TEMP.getCode(), goodsToStation);
|
||||
createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.TEMP.getCode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -610,7 +560,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
* @param workStation 工作站台
|
||||
* @param pickStatus 任务状态:只接受-1、0。-1:暂存不发送,0:可发送
|
||||
*/
|
||||
public void createPickTasks(List<String> vehicleIds, String workStation, Integer pickStatus, GoodsToStation goodsToStation) {
|
||||
public void createPickTasks(List<String> vehicleIds, String workStation, Integer pickStatus) {
|
||||
if (!Objects.equals(pickStatus, PickTaskStatusEnum.TEMP.getCode()) && !Objects.equals(pickStatus, PickTaskStatusEnum.NEW.getCode())) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -642,8 +592,6 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
|||
tempPickTask.setPickTaskId(key);
|
||||
tempPickTask.setVehicleId(vehicleId);
|
||||
tempPickTask.setStandId(workStation);
|
||||
tempPickTask.setMachineType(goodsToStation.getMachineType());
|
||||
tempPickTask.setAreaType(goodsToStation.getAreaType());
|
||||
if (tempPickVehicles.contains(vehicleId)) {
|
||||
tempPickTask.setPickStatus(PickTaskStatusEnum.TEMP.getCode());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static com.wms.config.InitLocalConfig.*;
|
||||
import static com.wms.constants.WmsConstants.MYSQL_JSON_CI;
|
||||
import static com.wms.constants.WmsConstants.STAND_AREA;
|
||||
import static com.wms.utils.WmsUtils.generateId;
|
||||
|
||||
/**
|
||||
|
|
@ -224,13 +223,13 @@ public class WorkServiceImplements implements IWorkService {
|
|||
continue;
|
||||
}
|
||||
// 判断当前物料是否在流转中
|
||||
needNum = wmsTaskService.callGoods(goodsToStation, needNum, workStation);
|
||||
needNum = wmsTaskService.callGoods(goodsToStation.getGoodsId(), needNum, workStation);
|
||||
// 判断此时需求数量是否为0
|
||||
if (needNum.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
// 分配完成
|
||||
goodsToStation.setDistributeStatus(2);
|
||||
} else {
|
||||
needNum = wmsTaskService.callStocks(goodsToStation, needNum, workStation, runningTaskNumToEquipmentMap);
|
||||
needNum = wmsTaskService.callStocks(goodsToStation.getGoodsId(), needNum, workStation, runningTaskNumToEquipmentMap);
|
||||
if (needNum.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 已分配但未完全分配
|
||||
goodsToStation.setDistributeStatus(1);
|
||||
|
|
@ -884,8 +883,6 @@ public class WorkServiceImplements implements IWorkService {
|
|||
newGoodsToStation.setDistributeStatus(0);
|
||||
newGoodsToStation.setDistributedNum(BigDecimal.ZERO);
|
||||
newGoodsToStation.setTotalNum(workFlow.getNeedNum());
|
||||
newGoodsToStation.setMachineType(workFlow.getMachineType());
|
||||
newGoodsToStation.setAreaType(STAND_AREA.get(thisStandId));
|
||||
oldGoodsStationsMap.put(workFlow.getGoodsId(), newGoodsToStation);
|
||||
}
|
||||
WorkFlow onlyForUpdateTemp = new WorkFlow();
|
||||
|
|
@ -1054,8 +1051,6 @@ public class WorkServiceImplements implements IWorkService {
|
|||
newGoodsToStation.setDistributeStatus(0);
|
||||
newGoodsToStation.setDistributedNum(BigDecimal.ZERO);
|
||||
newGoodsToStation.setTotalNum(workFlow.getNeedNum());
|
||||
newGoodsToStation.setMachineType(workFlow.getMachineType());
|
||||
newGoodsToStation.setAreaType(STAND_AREA.get(thisStandId));
|
||||
oldGoodsStationsMap.put(workFlow.getGoodsId(), newGoodsToStation);
|
||||
}
|
||||
WorkFlow onlyForUpdateTemp = new WorkFlow();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user