Compare commits

..

3 Commits

14 changed files with 361 additions and 83 deletions

View File

@ -1,6 +1,7 @@
package com.wms.config; package com.wms.config;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.Config;
import com.wms.entity.table.Location; import com.wms.entity.table.Location;
import com.wms.entity.table.WorkDate; import com.wms.entity.table.WorkDate;
@ -47,12 +48,26 @@ public class InitLocalConfig implements ApplicationRunner {
@Override @Override
public void run(ApplicationArguments args) { public void run(ApplicationArguments args) {
List<Config> configs = configService.selectConfigs(""); List<Config> configs = configService.selectConfigs("");
if (configs.size() > 0) { if (!configs.isEmpty()) {
for (Config config : configs) { for (Config config : configs) {
configMap.put(config.getConfigKey(), config.getConfigValue()); configMap.put(config.getConfigKey(), config.getConfigValue());
logger.info("导入系统配置成功---{}{}", config.getConfigName(), 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 // 生成库位Map
instantLocationMap = locationService.list().stream().collect(Collectors.toMap(Location::getLocationId, location -> location)); instantLocationMap = locationService.list().stream().collect(Collectors.toMap(Location::getLocationId, location -> location));
logger.info("生成库位Map成功。"); logger.info("生成库位Map成功。");

View File

@ -18,6 +18,18 @@ public class WmsConstants {
public static String MYSQL_JSON_CI = "COLLATE utf8mb4_general_ci"; 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() public static Map<String, String> type_values = ImmutableMap.<String, String>builder()
.put("LR01", "CLC一箱两料") .put("LR01", "CLC一箱两料")
.put("LR02", "CLC一箱一料") .put("LR02", "CLC一箱一料")

View File

@ -14,6 +14,8 @@ public enum ConfigMapKeyEnum {
ALLOW_EMPTY_BACK("ALLOW_EMPTY_BACK"), ALLOW_EMPTY_BACK("ALLOW_EMPTY_BACK"),
SEND_PICK_OUT_TASK("SEND_PICK_OUT_TASK"), SEND_PICK_OUT_TASK("SEND_PICK_OUT_TASK"),
MAX_VEHICLE_NUMS("MAX_VEHICLE_NUMS"),// 线体上最大箱子数 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_STAND_VEHICLE_NUMS("MAX_STAND_VEHICLE_NUMS"),// 每个站台最大箱子数
MAX_WCS_ACCEPT_NUMS("MAX_WCS_ACCEPT_NUMS"), MAX_WCS_ACCEPT_NUMS("MAX_WCS_ACCEPT_NUMS"),
SLOC_FILTER_STRING("SLOC_FILTER_STRING"), SLOC_FILTER_STRING("SLOC_FILTER_STRING"),
@ -25,7 +27,10 @@ public enum ConfigMapKeyEnum {
SETTING_DATE("SETTING_DATE"), SETTING_DATE("SETTING_DATE"),
RATE_MIN_TO_MAX("RATE_MIN_TO_MAX"), RATE_MIN_TO_MAX("RATE_MIN_TO_MAX"),
WORK_PRIORITY("WORK_PRIORITY"), WORK_PRIORITY("WORK_PRIORITY"),
IF_MERGE_TOMORROW("IF_MERGE_TOMORROW"); IF_MERGE_TOMORROW("IF_MERGE_TOMORROW"),
SAME_MACHINE("SAME_MACHINE"),
SAME_AREA("SAME_AREA"),
RATE_TYPE("RATE_TYPE");
private final String configKey; private final String configKey;
ConfigMapKeyEnum(String configKey) { ConfigMapKeyEnum(String configKey) {
this.configKey = configKey; this.configKey = configKey;

View File

@ -2052,19 +2052,21 @@ public class TaskController {
String finishResult = workService.finishWork(standId); String finishResult = workService.finishWork(standId);
if (Objects.equals(finishResult, "")) { if (Objects.equals(finishResult, "")) {
// 锁定当前站台 // 锁定当前站台
String lockMessage; // 暂时先不更改站台状态
if (standService.update(new LambdaUpdateWrapper<Stand>() // String lockMessage;
.set(Stand::getStandStatus, 1) // if (standService.update(new LambdaUpdateWrapper<Stand>()
.set(Stand::getPickVehicleCount, 0) // .set(Stand::getStandStatus, 1)
.eq(Stand::getStandId, standId))) { // .set(Stand::getPickVehicleCount, 0)
lockMessage = "锁定站台成功,整理完大盒子请点击整理结束按钮解锁。"; // .eq(Stand::getStandId, standId))) {
} else { // lockMessage = "锁定站台成功,整理完大盒子请点击整理结束按钮解锁。";
lockMessage = "锁定站台失败,请手动锁定。"; // } else {
} // lockMessage = "锁定站台失败,请手动锁定。";
// }
// 工作完成成功 // 工作完成成功
response.setCode(ResponseCode.OK.getCode()); response.setCode(ResponseCode.OK.getCode());
response.setMessage("确认成功,请至收盒子界面完成后续操作。" + lockMessage); response.setMessage("确认成功,请至收盒子界面完成后续操作。");
// response.setMessage("确认成功,请至收盒子界面完成后续操作。" + lockMessage);
} else { } else {
// 工作完成失败 // 工作完成失败
response.setCode(ResponseCode.ERROR.getCode()); response.setCode(ResponseCode.ERROR.getCode());
@ -3241,8 +3243,9 @@ public class TaskController {
return convertJsonString(response); return convertJsonString(response);
} }
// 更新站台为可用状态 // 更新站台为可用状态
targetStand.setStandStatus(0); // 这里先注释掉通过手动控制状态
standService.updateById(targetStand); // targetStand.setStandStatus(0);
// standService.updateById(targetStand);
logger.info("整理大盒子结束,解锁站台成功。"); logger.info("整理大盒子结束,解锁站台成功。");
response.setCode(ResponseCode.OK.getCode()); response.setCode(ResponseCode.OK.getCode());
response.setMessage("整理大盒子结束,解锁站台成功。"); response.setMessage("整理大盒子结束,解锁站台成功。");

View File

@ -47,4 +47,16 @@ public class GoodsToStation {
*/ */
@TableField("distribute_status") @TableField("distribute_status")
private Integer distributeStatus; private Integer distributeStatus;
/**
* 机型
* 1: 装载机2: 平地机
*/
@TableField("machine_type")
private Integer machineType;
/**
* 区域类型
* 1: 2:
*/
@TableField("area_type")
private Integer areaType;
} }

View File

@ -41,4 +41,16 @@ public class OutsideVehicles {
*/ */
@TableField("out_status") @TableField("out_status")
private Integer outStatus; private Integer outStatus;
/**
* 机型
* 1: 装载机2: 平地机3:共通
*/
@TableField("machine_type")
private Integer machineType;
/**
* 区域类型
* 1: 2: 3:共通
*/
@TableField("area_type")
private Integer areaType;
} }

View File

@ -47,4 +47,16 @@ public class PickTask {
*/ */
@TableField("arrive_time") @TableField("arrive_time")
private LocalDateTime arriveTime; private LocalDateTime arriveTime;
/**
* 机型
* 1: 装载机2: 平地机
*/
@TableField("machine_type")
private Integer machineType;
/**
* 区域类型
* 1: 2:
*/
@TableField("area_type")
private Integer areaType;
} }

View File

@ -47,4 +47,16 @@ public class PickTaskRecord {
*/ */
@TableField("arrive_time") @TableField("arrive_time")
private LocalDateTime arriveTime; private LocalDateTime arriveTime;
/**
* 机型
* 1: 装载机2: 平地机
*/
@TableField("machine_type")
private Integer machineType;
/**
* 区域类型
* 1: 2:
*/
@TableField("area_type")
private Integer areaType;
} }

View File

@ -105,4 +105,16 @@ public class Task {
*/ */
@TableField("pick_stand") @TableField("pick_stand")
private String pickStand; private String pickStand;
/**
* 机型
* 1: 装载机2: 平地机
*/
@TableField("machine_type")
private Integer machineType;
/**
* 区域类型
* 1: 2:
*/
@TableField("area_type")
private Integer areaType;
} }

View File

@ -98,4 +98,16 @@ public class TaskRecord {
*/ */
@TableField("pick_stand") @TableField("pick_stand")
private String pickStand; private String pickStand;
/**
* 机型
* 1: 装载机2: 平地机
*/
@TableField("machine_type")
private Integer machineType;
/**
* 区域类型
* 1: 2:
*/
@TableField("area_type")
private Integer areaType;
} }

View File

@ -2,6 +2,7 @@ package com.wms.service.business;
import com.wms.entity.app.request.TaskInRequest; import com.wms.entity.app.request.TaskInRequest;
import com.wms.entity.app.request.TaskOutRequest; import com.wms.entity.app.request.TaskOutRequest;
import com.wms.entity.table.GoodsToStation;
import com.wms.entity.table.Task; import com.wms.entity.table.Task;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -40,7 +41,7 @@ public interface IWmsTaskService {
*/ */
String genGoodsOutTask(TaskOutRequest taskOutRequest); String genGoodsOutTask(TaskOutRequest taskOutRequest);
BigDecimal callGoods(String goodsId, BigDecimal needNum, String workStation); BigDecimal callGoods(GoodsToStation goodsToStation, BigDecimal needNum, String workStation);
BigDecimal callStocks(String goodsId, BigDecimal needNum, String workStation, Map<Integer, Integer> runningTaskNumToEquipmentMap); BigDecimal callStocks(GoodsToStation goodsToStation, BigDecimal needNum, String workStation, Map<Integer, Integer> runningTaskNumToEquipmentMap);
} }

View File

@ -694,6 +694,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
logger.info("定期清理过期日志数据成功。"); logger.info("定期清理过期日志数据成功。");
} }
} catch (Exception exception) { } catch (Exception exception) {
logger.error("定期清理日志数据时发生异常:{}", convertJsonString(exception));
// 回滚事务 // 回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
} }
@ -914,6 +915,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
logger.info("定期清理DBS完成数据成功。"); logger.info("定期清理DBS完成数据成功。");
} }
} catch (Exception exception) { } catch (Exception exception) {
logger.error("定期清理数据异常:{}", JSON.toJSONString(exception));
// 回滚事务 // 回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
} }
@ -933,15 +935,23 @@ public class WmsJobServiceImplements implements IWmsJobService {
public <T> void doWriteExcel(String fileDesc, String filePath, String sheetName, List<T> list, Class<T> clazz) throws IOException { public <T> void doWriteExcel(String fileDesc, String filePath, String sheetName, List<T> list, Class<T> clazz) throws IOException {
// 内容样式 // 内容样式
HorizontalCellStyleStrategy horizontalCellStyleStrategy = ExcelContentStyle.getContentStyle(); HorizontalCellStyleStrategy horizontalCellStyleStrategy = ExcelContentStyle.getContentStyle();
File file = new File(filePath + File.separator + fileDesc + ".xlsx"); // 判断数据行是不是过多
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");
createFile(file);// 新建文件 createFile(file);// 新建文件
FileOutputStream fos = new FileOutputStream(file); FileOutputStream fos = new FileOutputStream(file);
EasyExcel.write(fos, clazz) EasyExcel.write(fos, clazz)
.excelType(ExcelTypeEnum.XLSX) .excelType(ExcelTypeEnum.XLSX)
.registerWriteHandler(horizontalCellStyleStrategy) .registerWriteHandler(horizontalCellStyleStrategy)
.sheet("库存") .sheet(sheetName)
.doWrite(list); .doWrite(dividedList);
logger.info("保存文件成功:{}。", fileDesc); logger.info("保存文件成功:{}。", fileCounts > 1 ? fileDesc + "_" + i : fileDesc);
}
} }
/** /**
@ -999,13 +1009,28 @@ public class WmsJobServiceImplements implements IWmsJobService {
List<Task> allTasks = taskService.list(waitForDistributeTaskQuery); List<Task> allTasks = taskService.list(waitForDistributeTaskQuery);
if (!allTasks.isEmpty()) { if (!allTasks.isEmpty()) {
String max_vehicle_nums = configMap.get(ConfigMapKeyEnum.MAX_VEHICLE_NUMS.getConfigKey()); 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_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 max_stand_vehicle_nums = configMap.get(ConfigMapKeyEnum.MAX_STAND_VEHICLE_NUMS.getConfigKey());
String minToMax = configMap.get(ConfigMapKeyEnum.RATE_MIN_TO_MAX.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)) { if (StringUtils.isEmpty(max_vehicle_nums) || StringUtils.isEmpty(max_wcs_accept_nums) || StringUtils.isEmpty(max_stand_vehicle_nums)) {
logger.error("配置未生成"); logger.error("允许不同区域时配置未生成");
return; 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);// 线体最大箱子数量 int maxVehicleNums = Integer.parseInt(max_vehicle_nums);// 线体最大箱子数量
List<String> outsideVehicles = outsideVehiclesService.selectDistinctVehicles(); List<String> outsideVehicles = outsideVehiclesService.selectDistinctVehicles();
if (outsideVehicles == null || outsideVehicles.isEmpty()) { if (outsideVehicles == null || outsideVehicles.isEmpty()) {
@ -1015,6 +1040,33 @@ public class WmsJobServiceImplements implements IWmsJobService {
if (remainVehicleNums <= 0) { if (remainVehicleNums <= 0) {
return; 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; int minToMaxRate = 1;
try { try {
@ -1038,7 +1090,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
List<Stand> stands = standService.list(new LambdaQueryWrapper<Stand>() List<Stand> stands = standService.list(new LambdaQueryWrapper<Stand>()
.eq(Stand::getIsLock, 0).eq(Stand::getStandStatus, 0)); .eq(Stand::getIsLock, 0).eq(Stand::getStandStatus, 0));
// 备料站台---从9号站台开始 // 备料站台---从9号站台开始
List<Stand> allPickStands = stands.stream().filter(stand -> stand.getStandType() == 2).sorted(Comparator.comparing(Stand::getStandId).reversed()).toList(); List<Stand> allPickStands = stands.stream().filter(stand -> stand.getStandType() == 2 && thisTimeCanOutStandIds.contains(stand.getStandId())).sorted(Comparator.comparing(Stand::getStandId).reversed()).toList();
// 找出所有可用堆垛机---从5号堆垛机开始 // 找出所有可用堆垛机---从5号堆垛机开始
List<Stand> stackerList = stands.stream().filter(stand -> stand.getStandType() == 3).sorted(Comparator.comparingInt(Stand::getEquipmentId).reversed()).toList(); List<Stand> stackerList = stands.stream().filter(stand -> stand.getStandType() == 3).sorted(Comparator.comparingInt(Stand::getEquipmentId).reversed()).toList();
// 查询特殊表 // 查询特殊表
@ -1050,11 +1102,14 @@ public class WmsJobServiceImplements implements IWmsJobService {
// 能够用的站体的列表 // 能够用的站体的列表
List<Stand> pickStands = new ArrayList<>(); List<Stand> pickStands = new ArrayList<>();
// 判断哪些站台暂时不能下发任务 // 判断哪些站台暂时不能下发任务
Map<String, Integer> standPickCountsMap = new HashMap<>();
for (Stand pickStand : allPickStands) { for (Stand pickStand : allPickStands) {
// 查询这个站台有多少已下发的拣选任务 // 查询这个站台有多少已下发的拣选任务
List<PickTask> thisStandPickCounts = standPickTasks.stream().filter(pickTask -> pickTask.getStandId().equals(pickStand.getStandId()) && pickTask.getPickStatus() >= PickTaskStatusEnum.NEW.getCode()).toList(); 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)) { if (thisStandPickCounts.size() < Integer.parseInt(max_stand_vehicle_nums)) {
pickStands.add(pickStand); pickStands.add(pickStand);
// 保存当前站台有多少箱子已经可用
standPickCountsMap.put(pickStand.getStandId(), thisStandPickCounts.size());
} }
} }
// 处理数据 // 处理数据
@ -1105,6 +1160,9 @@ public class WmsJobServiceImplements implements IWmsJobService {
} }
}); });
String vehicleId; String vehicleId;
// :
if ("1".equals(rateType)) {
if (thisQtyType <= minToMaxRate) { if (thisQtyType <= minToMaxRate) {
// 最少使用的箱子 // 最少使用的箱子
vehicleId = vehicleStandsMap.entrySet().stream() vehicleId = vehicleStandsMap.entrySet().stream()
@ -1118,6 +1176,22 @@ public class WmsJobServiceImplements implements IWmsJobService {
.map(Map.Entry::getKey) .map(Map.Entry::getKey)
.orElse(""); .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)) { if (!StringUtils.isEmpty(vehicleId)) {
// 找到这个箱子的任务 // 找到这个箱子的任务
List<Task> outPickTasks = allTasks.stream().filter(task -> task.getVehicleId().equals(vehicleId) && !pickVehicleIds.contains(task.getVehicleId()) List<Task> outPickTasks = allTasks.stream().filter(task -> task.getVehicleId().equals(vehicleId) && !pickVehicleIds.contains(task.getVehicleId())
@ -1191,21 +1265,27 @@ public class WmsJobServiceImplements implements IWmsJobService {
// 查看下一台堆垛机 // 查看下一台堆垛机
break; break;
} }
// 找到暂存拣选任务最多的站台 // old 找到暂存拣选任务最多的站台
Map<String, Integer> pickTaskNumsOfStandsMap = new HashMap<>(); // Map<String, Integer> pickTaskNumsOfStandsMap = new HashMap<>();
for(Stand pickStand : pickStands) { // for(Stand pickStand : pickStands) {
standPickTasks.forEach(pickTask -> { // standPickTasks.forEach(pickTask -> {
if (Objects.equals(pickTask.getPickStatus(), PickTaskStatusEnum.TEMP.getCode()) // if (Objects.equals(pickTask.getPickStatus(), PickTaskStatusEnum.TEMP.getCode())
&& thisStackerVehicleIds.contains(pickTask.getVehicleId()) // && thisStackerVehicleIds.contains(pickTask.getVehicleId())
&& pickStand.getStandId().equals(pickTask.getStandId())) { // && pickStand.getStandId().equals(pickTask.getStandId())) {
pickTaskNumsOfStandsMap.put(pickTask.getStandId(), pickTaskNumsOfStandsMap.getOrDefault(pickTask.getStandId(), 0) + 1); // pickTaskNumsOfStandsMap.put(pickTask.getStandId(), pickTaskNumsOfStandsMap.getOrDefault(pickTask.getStandId(), 0) + 1);
} // }
}); // });
} // }
String standId = pickTaskNumsOfStandsMap.entrySet().stream() // String standId = pickTaskNumsOfStandsMap.entrySet().stream()
.max(Comparator.comparingInt(Map.Entry::getValue)) // .max(Comparator.comparingInt(Map.Entry::getValue))
// .map(Map.Entry::getKey)
// .orElse("");
// new 查找已下发状态以上最少箱子的站台
String standId = standPickCountsMap.entrySet().stream()
.min(Comparator.comparingInt(Map.Entry::getValue))
.map(Map.Entry::getKey) .map(Map.Entry::getKey)
.orElse(""); .orElse("");
// 查找这个站台未下发的料箱 // 查找这个站台未下发的料箱
List<String> vehicleIds = standPickTasks.stream() List<String> vehicleIds = standPickTasks.stream()
.filter(pickTask -> pickTask.getPickStatus().equals(PickTaskStatusEnum.TEMP.getCode()) .filter(pickTask -> pickTask.getPickStatus().equals(PickTaskStatusEnum.TEMP.getCode())
@ -1274,6 +1354,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
// 已经发送过的vehicleId // 已经发送过的vehicleId
pickVehicleIds.add(vehicleId); pickVehicleIds.add(vehicleId);
availNum--; availNum--;
standPickCountsMap.put(standId, standPickCountsMap.get(standId) + 1);
} }
} }
} }
@ -1283,6 +1364,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
// 没有新任务发送 // 没有新任务发送
return; return;
} }
// simulateSendPickOutTasks(taskGroupIds, pickVehicleIds, needAddStandStackerTasks, needRemoveStandStackerTasks);
// 发送任务 // 发送任务
String url = configMap.get(ConfigMapKeyEnum.URL_WCS_TASK.getConfigKey()); String url = configMap.get(ConfigMapKeyEnum.URL_WCS_TASK.getConfigKey());
if (url != null) { if (url != null) {
@ -1370,4 +1452,35 @@ public class WmsJobServiceImplements implements IWmsJobService {
throw new Exception("向WCS发送拣选出库任务时发生异常。"); 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);
}
} }

View File

@ -1,5 +1,6 @@
package com.wms.service.business.serviceImplements; 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.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.*;
@ -27,6 +28,7 @@ import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.wms.config.InitLocalConfig.configMap;
import static com.wms.config.InitLocalConfig.instantLocationMap; import static com.wms.config.InitLocalConfig.instantLocationMap;
import static com.wms.constants.WmsConstants.MYSQL_JSON_CI; import static com.wms.constants.WmsConstants.MYSQL_JSON_CI;
import static com.wms.utils.StringUtils.convertJsonString; import static com.wms.utils.StringUtils.convertJsonString;
@ -307,16 +309,20 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
@Override @Override
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
public BigDecimal callGoods(String goodsId, BigDecimal needNum, String workStation) { public BigDecimal callGoods(GoodsToStation goodsToStation, BigDecimal needNum, String workStation) {
BigDecimal originNum = needNum;// 原始数量 BigDecimal originNum = needNum;// 原始数量
try { try {
// 判断当前物料是否在流转中 // 判断当前物料是否在流转中
List<OutsideVehicles> outsideVehiclesList = outsideVehiclesService.list(new LambdaQueryWrapper<OutsideVehicles>() List<OutsideVehicles> outsideVehiclesList = outsideVehiclesService.list(new LambdaQueryWrapper<OutsideVehicles>()
.eq(OutsideVehicles::getGoodsId, goodsId) .eq(OutsideVehicles::getGoodsId, goodsToStation.getGoodsId())
.gt(OutsideVehicles::getRemainNum, 0) .gt(OutsideVehicles::getRemainNum, 0)
.ne(OutsideVehicles::getOutStatus, 2)); .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<>(); List<OutsideVehicles> usedOutsideVehiclesList = new ArrayList<>();
if (outsideVehiclesList != null && !outsideVehiclesList.isEmpty()) { if (outsideVehiclesList != null && !outsideVehiclesList.isEmpty()) {
Map<String, Integer> vehicleAreaTypeMap = new HashMap<>();
Map<String, Integer> vehicleMachineTypeMap = new HashMap<>();
// 存在流转中的料箱 // 存在流转中的料箱
for (OutsideVehicles outsideVehicle : outsideVehiclesList) { for (OutsideVehicles outsideVehicle : outsideVehiclesList) {
if (needNum.compareTo(BigDecimal.ZERO) <= 0) {// 需求数量小于等于0 if (needNum.compareTo(BigDecimal.ZERO) <= 0) {// 需求数量小于等于0
@ -325,7 +331,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
// 查询当前料箱当前物料的库存 // 查询当前料箱当前物料的库存
Stock stock = stockService.getOne(new LambdaQueryWrapper<Stock>() Stock stock = stockService.getOne(new LambdaQueryWrapper<Stock>()
.eq(Stock::getVehicleId, outsideVehicle.getVehicleId()) .eq(Stock::getVehicleId, outsideVehicle.getVehicleId())
.apply("goods_related ->> '$.goodsId' = {0}" + MYSQL_JSON_CI, goodsId) .apply("goods_related ->> '$.goodsId' = {0}" + MYSQL_JSON_CI, goodsToStation.getGoodsId())
.apply("goods_related ->> '$.remainNum' > 0") .apply("goods_related ->> '$.remainNum' > 0")
.last("limit 1")); .last("limit 1"));
if (stock == null) { if (stock == null) {
@ -337,6 +343,24 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
outsideVehiclesService.removeById(outsideVehicle); outsideVehiclesService.removeById(outsideVehicle);
continue; 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) { if (outsideVehicle.getRemainNum().compareTo(needNum) > 0) {
// 当前箱子剩余物料数量多于需求数量 // 当前箱子剩余物料数量多于需求数量
outsideVehicle.setRemainNum(outsideVehicle.getRemainNum().subtract(needNum)); outsideVehicle.setRemainNum(outsideVehicle.getRemainNum().subtract(needNum));
@ -348,24 +372,42 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
needNum = needNum.subtract(outsideVehicle.getRemainNum()); needNum = needNum.subtract(outsideVehicle.getRemainNum());
outsideVehicle.setRemainNum(BigDecimal.ZERO); outsideVehicle.setRemainNum(BigDecimal.ZERO);
usedOutsideVehiclesList.add(outsideVehicle); usedOutsideVehiclesList.add(outsideVehicle);
if(needNum.compareTo(BigDecimal.ZERO) == 0){ if (needNum.compareTo(BigDecimal.ZERO) == 0) {
break; break;
} }
} }
} }
} }
if (!usedOutsideVehiclesList.isEmpty()) {
// 更新流转箱表 // 更新流转箱表
outsideVehiclesService.updateBatchById(usedOutsideVehiclesList); outsideVehiclesService.updateBatchById(usedOutsideVehiclesList);
// 生成拣选任务 // 生成拣选任务
List<String> vehicleIds = usedOutsideVehiclesList.stream().map(OutsideVehicles::getVehicleId).distinct().toList(); 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()) { if (!vehicleIds.isEmpty()) {
createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.NEW.getCode()); createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.NEW.getCode(), goodsToStation);
}
} }
} }
return needNum; return needNum;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
logger.error("呼叫物料时发生异常:{}", e.getMessage()); logger.error("呼叫物料时发生异常:{}", JSON.toJSONString(e));
// 回滚事务 // 回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return originNum; return originNum;
@ -375,13 +417,15 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
@Override @Override
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
public BigDecimal callStocks(String goodsId, BigDecimal needNum, String workStation, Map<Integer, Integer> runningTaskNumToEquipmentMap) { public BigDecimal callStocks(GoodsToStation goodsToStation, BigDecimal needNum, String workStation, Map<Integer, Integer> runningTaskNumToEquipmentMap) {
BigDecimal originNum = needNum;// 原始数量 BigDecimal originNum = needNum;// 原始数量
try { try {
// 判断当前这个料是否已经有outsideVehicles // 判断当前这个料是否已经有outsideVehicles
List<OutsideVehicles> outsideVehiclesList = outsideVehiclesService.list(new LambdaQueryWrapper<OutsideVehicles>() List<OutsideVehicles> outsideVehiclesList = outsideVehiclesService.list(new LambdaQueryWrapper<OutsideVehicles>()
.eq(OutsideVehicles::getGoodsId, goodsId) .eq(OutsideVehicles::getGoodsId, goodsToStation.getGoodsId())
.ne(OutsideVehicles::getOutStatus, 2)); .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()) { if (!outsideVehiclesList.isEmpty()) {
// 这些箱子 // 这些箱子
List<String> outsideVehicleIds = outsideVehiclesList.stream().map(OutsideVehicles::getVehicleId).distinct().toList(); List<String> outsideVehicleIds = outsideVehiclesList.stream().map(OutsideVehicles::getVehicleId).distinct().toList();
@ -397,7 +441,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
// 查询库存判断数量是否充足 // 查询库存判断数量是否充足
List<Stock> stockList = stockService.list(new LambdaQueryWrapper<Stock>() List<Stock> stockList = stockService.list(new LambdaQueryWrapper<Stock>()
.eq(Stock::getStockStatus, StockStatus.OK.getCode()) .eq(Stock::getStockStatus, StockStatus.OK.getCode())
.apply("goods_related ->> '$.goodsId' = {0}" + MYSQL_JSON_CI, goodsId) .apply("goods_related ->> '$.goodsId' = {0}" + MYSQL_JSON_CI, goodsToStation.getGoodsId())
.apply("goods_related ->> '$.remainNum' > 0") .apply("goods_related ->> '$.remainNum' > 0")
.orderByAsc(Stock::getCreateTime)); .orderByAsc(Stock::getCreateTime));
if (stockList != null && !stockList.isEmpty()) { if (stockList != null && !stockList.isEmpty()) {
@ -454,14 +498,14 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
waitForOutStockList.add(tempStock); waitForOutStockList.add(tempStock);
// 将堆垛机任务数量更新 // 将堆垛机任务数量更新
runningTaskNumToEquipmentMap.put(equipmentId, runningTaskNumToEquipmentMap.get(equipmentId) + 1); runningTaskNumToEquipmentMap.put(equipmentId, runningTaskNumToEquipmentMap.get(equipmentId) + 1);
if(needNum.compareTo(BigDecimal.ZERO) == 0){ if (needNum.compareTo(BigDecimal.ZERO) == 0) {
break; break;
} }
// break; // break;
} }
if (!waitForOutStockList.isEmpty()) { if (!waitForOutStockList.isEmpty()) {
// 创建任务 // 创建任务
createVehicleOutTaskAndPickTask(waitForOutStockList, workStation); createVehicleOutTaskAndPickTask(waitForOutStockList, workStation, goodsToStation);
} }
} }
return needNum; return needNum;
@ -478,7 +522,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
* *
* @param waitForOutStocks 待出库库存 * @param waitForOutStocks 待出库库存
*/ */
private void createVehicleOutTaskAndPickTask(List<Stock> waitForOutStocks, String workStation) { private void createVehicleOutTaskAndPickTask(List<Stock> waitForOutStocks, String workStation, GoodsToStation goodsToStation) {
// 出库任务列表 // 出库任务列表
List<Task> outTasks = new ArrayList<>(); List<Task> outTasks = new ArrayList<>();
// 流转载具列表 // 流转载具列表
@ -503,6 +547,8 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
tempOutTask.setCreateTime(LocalDateTime.now()); tempOutTask.setCreateTime(LocalDateTime.now());
tempOutTask.setIsPicking(1); tempOutTask.setIsPicking(1);
tempOutTask.setPickStand(workStation); tempOutTask.setPickStand(workStation);
tempOutTask.setMachineType(goodsToStation.getMachineType());
tempOutTask.setAreaType(goodsToStation.getAreaType());
outTasks.add(tempOutTask); outTasks.add(tempOutTask);
// 添加载具列表 // 添加载具列表
vehicleIds.add(tempStock.getVehicleId()); vehicleIds.add(tempStock.getVehicleId());
@ -513,6 +559,8 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
outsideVehicle.setGoodsId(tempStock.getGoodsRelated().getGoodsId()); outsideVehicle.setGoodsId(tempStock.getGoodsRelated().getGoodsId());
outsideVehicle.setRemainNum(tempStock.getGoodsRelated().getRemainNum()); outsideVehicle.setRemainNum(tempStock.getGoodsRelated().getRemainNum());
outsideVehicle.setOutStatus(0); outsideVehicle.setOutStatus(0);
outsideVehicle.setMachineType(goodsToStation.getMachineType());
outsideVehicle.setAreaType(goodsToStation.getAreaType());
outsideVehicles.add(outsideVehicle); outsideVehicles.add(outsideVehicle);
} }
for (String vehicleId : vehicleIds) { for (String vehicleId : vehicleIds) {
@ -532,6 +580,8 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
outsideVehicle.setGoodsId(vehicleStock.getGoodsRelated().getGoodsId()); outsideVehicle.setGoodsId(vehicleStock.getGoodsRelated().getGoodsId());
outsideVehicle.setRemainNum(vehicleStock.getGoodsRelated().getRemainNum()); outsideVehicle.setRemainNum(vehicleStock.getGoodsRelated().getRemainNum());
outsideVehicle.setOutStatus(0); outsideVehicle.setOutStatus(0);
outsideVehicle.setMachineType(goodsToStation.getMachineType());
outsideVehicle.setAreaType(goodsToStation.getAreaType());
outsideVehicles.add(outsideVehicle); outsideVehicles.add(outsideVehicle);
} }
} }
@ -550,7 +600,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
// 保存流转箱信息 // 保存流转箱信息
outsideVehiclesService.saveBatch(outsideVehicles); outsideVehiclesService.saveBatch(outsideVehicles);
// 保存拣选任务至拣选任务表 // 保存拣选任务至拣选任务表
createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.TEMP.getCode()); createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.TEMP.getCode(), goodsToStation);
} }
/** /**
@ -560,7 +610,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
* @param workStation 工作站台 * @param workStation 工作站台
* @param pickStatus 任务状态只接受-10-1暂存不发送0可发送 * @param pickStatus 任务状态只接受-10-1暂存不发送0可发送
*/ */
public void createPickTasks(List<String> vehicleIds, String workStation, Integer pickStatus) { public void createPickTasks(List<String> vehicleIds, String workStation, Integer pickStatus, GoodsToStation goodsToStation) {
if (!Objects.equals(pickStatus, PickTaskStatusEnum.TEMP.getCode()) && !Objects.equals(pickStatus, PickTaskStatusEnum.NEW.getCode())) { if (!Objects.equals(pickStatus, PickTaskStatusEnum.TEMP.getCode()) && !Objects.equals(pickStatus, PickTaskStatusEnum.NEW.getCode())) {
return; return;
} }
@ -592,6 +642,8 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
tempPickTask.setPickTaskId(key); tempPickTask.setPickTaskId(key);
tempPickTask.setVehicleId(vehicleId); tempPickTask.setVehicleId(vehicleId);
tempPickTask.setStandId(workStation); tempPickTask.setStandId(workStation);
tempPickTask.setMachineType(goodsToStation.getMachineType());
tempPickTask.setAreaType(goodsToStation.getAreaType());
if (tempPickVehicles.contains(vehicleId)) { if (tempPickVehicles.contains(vehicleId)) {
tempPickTask.setPickStatus(PickTaskStatusEnum.TEMP.getCode()); tempPickTask.setPickStatus(PickTaskStatusEnum.TEMP.getCode());
} else { } else {

View File

@ -29,6 +29,7 @@ import java.util.stream.Collectors;
import static com.wms.config.InitLocalConfig.*; import static com.wms.config.InitLocalConfig.*;
import static com.wms.constants.WmsConstants.MYSQL_JSON_CI; import static com.wms.constants.WmsConstants.MYSQL_JSON_CI;
import static com.wms.constants.WmsConstants.STAND_AREA;
import static com.wms.utils.WmsUtils.generateId; import static com.wms.utils.WmsUtils.generateId;
/** /**
@ -223,13 +224,13 @@ public class WorkServiceImplements implements IWorkService {
continue; continue;
} }
// 判断当前物料是否在流转中 // 判断当前物料是否在流转中
needNum = wmsTaskService.callGoods(goodsToStation.getGoodsId(), needNum, workStation); needNum = wmsTaskService.callGoods(goodsToStation, needNum, workStation);
// 判断此时需求数量是否为0 // 判断此时需求数量是否为0
if (needNum.compareTo(BigDecimal.ZERO) <= 0) { if (needNum.compareTo(BigDecimal.ZERO) <= 0) {
// 分配完成 // 分配完成
goodsToStation.setDistributeStatus(2); goodsToStation.setDistributeStatus(2);
} else { } else {
needNum = wmsTaskService.callStocks(goodsToStation.getGoodsId(), needNum, workStation, runningTaskNumToEquipmentMap); needNum = wmsTaskService.callStocks(goodsToStation, needNum, workStation, runningTaskNumToEquipmentMap);
if (needNum.compareTo(BigDecimal.ZERO) > 0) { if (needNum.compareTo(BigDecimal.ZERO) > 0) {
// 已分配但未完全分配 // 已分配但未完全分配
goodsToStation.setDistributeStatus(1); goodsToStation.setDistributeStatus(1);
@ -883,6 +884,8 @@ public class WorkServiceImplements implements IWorkService {
newGoodsToStation.setDistributeStatus(0); newGoodsToStation.setDistributeStatus(0);
newGoodsToStation.setDistributedNum(BigDecimal.ZERO); newGoodsToStation.setDistributedNum(BigDecimal.ZERO);
newGoodsToStation.setTotalNum(workFlow.getNeedNum()); newGoodsToStation.setTotalNum(workFlow.getNeedNum());
newGoodsToStation.setMachineType(workFlow.getMachineType());
newGoodsToStation.setAreaType(STAND_AREA.get(thisStandId));
oldGoodsStationsMap.put(workFlow.getGoodsId(), newGoodsToStation); oldGoodsStationsMap.put(workFlow.getGoodsId(), newGoodsToStation);
} }
WorkFlow onlyForUpdateTemp = new WorkFlow(); WorkFlow onlyForUpdateTemp = new WorkFlow();
@ -1051,6 +1054,8 @@ public class WorkServiceImplements implements IWorkService {
newGoodsToStation.setDistributeStatus(0); newGoodsToStation.setDistributeStatus(0);
newGoodsToStation.setDistributedNum(BigDecimal.ZERO); newGoodsToStation.setDistributedNum(BigDecimal.ZERO);
newGoodsToStation.setTotalNum(workFlow.getNeedNum()); newGoodsToStation.setTotalNum(workFlow.getNeedNum());
newGoodsToStation.setMachineType(workFlow.getMachineType());
newGoodsToStation.setAreaType(STAND_AREA.get(thisStandId));
oldGoodsStationsMap.put(workFlow.getGoodsId(), newGoodsToStation); oldGoodsStationsMap.put(workFlow.getGoodsId(), newGoodsToStation);
} }
WorkFlow onlyForUpdateTemp = new WorkFlow(); WorkFlow onlyForUpdateTemp = new WorkFlow();