feat(入库任务): 增加入库判断高度
This commit is contained in:
parent
eec010ca76
commit
7810dc37ad
|
|
@ -20,6 +20,22 @@ public class WmsConstants {
|
||||||
|
|
||||||
public static String ROOT_MENU_ID = "0";
|
public static String ROOT_MENU_ID = "0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 固定空托盘编号
|
||||||
|
*/
|
||||||
|
public static String EMPTY_VEHICHLE_ID = "B0000001";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 高度为1 去一层
|
||||||
|
*/
|
||||||
|
public static String LOW_FLOOR = "1";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 高度为2 去234层
|
||||||
|
*/
|
||||||
|
public static String HIGH_FLOOR= "2";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 虚拟库位设备号
|
* 虚拟库位设备号
|
||||||
|
|
|
||||||
37
src/main/java/com/wms/constants/enums/AreaEnum.java
Normal file
37
src/main/java/com/wms/constants/enums/AreaEnum.java
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.wms.constants.enums;
|
||||||
|
|
||||||
|
import com.wms.utils.StringUtils;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Classname AreaEnum
|
||||||
|
* @Date 2025-02-22 14:53
|
||||||
|
* @Created by luyifan
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum AreaEnum {
|
||||||
|
METAAREA("毛坯区域","A"),
|
||||||
|
WAITAREA("待置区域","B"),
|
||||||
|
GOODSAREA("物料区域","C");
|
||||||
|
|
||||||
|
|
||||||
|
private String desc;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
AreaEnum(String desc, String value) {
|
||||||
|
this.desc = desc;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
// 根据value获取枚举
|
||||||
|
public static AreaEnum getEnumByValue(String value) {
|
||||||
|
if (StringUtils.isEmpty(value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (AreaEnum areaEnum : AreaEnum.values()) {
|
||||||
|
if (areaEnum.getValue().equals(value)) {
|
||||||
|
return areaEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.wms.service.serviceImplements.parent;
|
package com.wms.service.serviceImplements.parent;
|
||||||
|
|
||||||
import com.wms.bussiness.TaskOperation;
|
import com.wms.bussiness.TaskOperation;
|
||||||
|
import com.wms.constants.WmsConstants;
|
||||||
import com.wms.constants.enums.*;
|
import com.wms.constants.enums.*;
|
||||||
import com.wms.entity.app.ResponseEntity;
|
import com.wms.entity.app.ResponseEntity;
|
||||||
import com.wms.entity.app.container.*;
|
import com.wms.entity.app.container.*;
|
||||||
|
|
@ -85,8 +86,8 @@ public class ContainerImplement implements ContainerService {
|
||||||
* @param request 请求信息
|
* @param request 请求信息
|
||||||
* @return 响应信息
|
* @return 响应信息
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
|
||||||
public CreateInstoreTaskResponse createInstoreTask(CreateInstoreTaskRequest request) {
|
public CreateInstoreTaskResponse createInstoreTask(CreateInstoreTaskRequest request) {
|
||||||
//进行MD5加密的验证
|
//进行MD5加密的验证
|
||||||
String md5 = StringUtils.containerMd5(request.getRequestId());
|
String md5 = StringUtils.containerMd5(request.getRequestId());
|
||||||
|
|
@ -95,93 +96,13 @@ public class ContainerImplement implements ContainerService {
|
||||||
}
|
}
|
||||||
CreateInstoreTaskResponse success = new CreateInstoreTaskResponse();
|
CreateInstoreTaskResponse success = new CreateInstoreTaskResponse();
|
||||||
|
|
||||||
// 判断是否为有判断好 B0000001代表无托盘号
|
|
||||||
if("B0000001".equals(request.getPalletNo())) {
|
|
||||||
String virtualVehicleNo = WmsUtils.generateUUIDString();
|
|
||||||
log.info("无托盘号,生成虚拟托盘号{}",virtualVehicleNo);
|
|
||||||
// 设置虚拟托盘号
|
|
||||||
AppOrderIn appOrderIn = new AppOrderIn();
|
|
||||||
String rowId = UUID.randomUUID().toString();
|
|
||||||
String Guid = UUID.randomUUID().toString();
|
|
||||||
appOrderIn.setRowId(rowId);
|
|
||||||
appOrderIn.setGuid(Guid);
|
|
||||||
appOrderIn.setInType(1);
|
|
||||||
appOrderIn.setBatchNo(null);
|
|
||||||
appOrderIn.setVehicleNo(virtualVehicleNo);
|
|
||||||
appOrderIn.setGoodsId("00000");
|
|
||||||
appOrderIn.setGoodsNum(null);
|
|
||||||
appOrderIn.setWareHouse("A");
|
|
||||||
appOrderIn.setOrderStatus(0);
|
|
||||||
appOrderIn.setCreateTime(LocalDateTime.now());
|
|
||||||
appOrderIn.setCreatePerson("WMS");
|
|
||||||
appOrderIn.setUpdateTime(LocalDateTime.now());
|
|
||||||
appOrderIn.setRemark("空托盘入库");
|
|
||||||
//appOrderIn.setProductionDate(request.abcSelect);
|
|
||||||
int insert = appOrderInMapper.insert(appOrderIn);
|
|
||||||
if (insert <= 0) {
|
|
||||||
return new CreateInstoreTaskResponse("400", "创建入库单失败");
|
|
||||||
}
|
|
||||||
/* 查找可用库位 */
|
|
||||||
List<Location> canUseLocations = locationUtils.getNewLocation(2,appOrderIn).stream().filter(location -> location.getLayer() == 1).collect(Collectors.toList());
|
|
||||||
if(canUseLocations.isEmpty()){
|
|
||||||
log.info("无可用库位");
|
|
||||||
return new CreateInstoreTaskResponse("400", "没有可用库位");
|
|
||||||
}
|
|
||||||
Location useLocation = locationUtils.checkCanUse(canUseLocations);
|
|
||||||
// 筛选出可用区域为第一层的库位
|
|
||||||
if(useLocation == null) {
|
|
||||||
log.info("暂没有可以直接使用的库位,因为存在互锁的库位,请等待当前任务都执行完成后再试");
|
|
||||||
return new CreateInstoreTaskResponse("400", "暂没有可以直接使用的库位,因为存在互锁的库位,请等待当前任务都执行完成后再试");
|
|
||||||
}
|
|
||||||
|
|
||||||
Task newInTask = new Task();
|
|
||||||
newInTask.setTaskId(String.valueOf(Calendar.getInstance().getTimeInMillis()));
|
|
||||||
newInTask.setTaskGroup(UUID.randomUUID().toString());
|
|
||||||
newInTask.setTaskType(TaskType.IN.getCode());
|
|
||||||
newInTask.setTaskStatus(WmsTaskStatus.WAIT.getCode()); // 因为任务是直接返回去的,所以直接是已下发状态
|
|
||||||
newInTask.setOrigin(request.getFromCellNo());
|
|
||||||
newInTask.setDestination(useLocation.getLocationId());
|
|
||||||
newInTask.setGoodsId("00000");
|
|
||||||
newInTask.setWeight(Double.valueOf(request.getWeight()));
|
|
||||||
newInTask.setCreateTime(new java.util.Date());
|
|
||||||
newInTask.setUserName("四向车API");
|
|
||||||
newInTask.setVehicleSize(Integer.valueOf(request.getHeight()));
|
|
||||||
newInTask.setVehicleNo(virtualVehicleNo);
|
|
||||||
newInTask.setTaskPriority(1);
|
|
||||||
newInTask.setProductionDate(null);
|
|
||||||
int insertTaskResult = taskMapper.addTask(newInTask);
|
|
||||||
if(insertTaskResult < 1) {
|
|
||||||
log.info("生成任务失败,无法插入新的入库任务");
|
|
||||||
return new CreateInstoreTaskResponse("400", "生成任务失败,无法插入新的入库任务");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新入库单状态
|
|
||||||
AppOrderIn updateAppOrderIn = new AppOrderIn();
|
|
||||||
updateAppOrderIn.setRowId(rowId);
|
|
||||||
updateAppOrderIn.setOrderStatus(OrderInStatusEnum.IN.getCode());
|
|
||||||
updateAppOrderIn.setUpdateTime(LocalDateTime.now());
|
|
||||||
appOrderInMapper.update(updateAppOrderIn);
|
|
||||||
|
|
||||||
// 修改库位信息
|
|
||||||
Location location = new Location();
|
|
||||||
location.setLocationId(useLocation.getLocationId());
|
|
||||||
location.setLocationStatus(LocationStatus.OCCUPY.getCode());
|
|
||||||
location.setVehicleId(virtualVehicleNo);
|
|
||||||
locationMapper.modifyLocation(location);
|
|
||||||
|
|
||||||
success.setCode("200");
|
|
||||||
success.setMessage("生成入库任务成功");
|
|
||||||
success.setWmsTaskId(newInTask.getTaskId());
|
|
||||||
success.setPalletNo(virtualVehicleNo);
|
|
||||||
success.setFromCellNo(request.getFromCellNo());
|
|
||||||
success.setToCellNo(useLocation.getLocationId());
|
|
||||||
}else {
|
|
||||||
// 查询待入库的批次号
|
// 查询待入库的批次号
|
||||||
AppOrderIn waitInStockQuery = new AppOrderIn();
|
AppOrderIn waitInStockQuery = new AppOrderIn();
|
||||||
waitInStockQuery.setVehicleNo(request.getPalletNo());
|
waitInStockQuery.setVehicleNo(request.getPalletNo());
|
||||||
//waitInStockQuery.setOrderStatus(OrderInStatusEnum.CREATE.getCode());
|
//waitInStockQuery.setOrderStatus(OrderInStatusEnum.CREATE.getCode());
|
||||||
List<AppOrderIn> waitInStockList = appOrderInMapper.select(waitInStockQuery); // 查找待入库的批次号
|
List<AppOrderIn> waitInStockList = appOrderInMapper.select(waitInStockQuery); // 查找待入库的批次号
|
||||||
if(waitInStockList.isEmpty()) {
|
if(waitInStockList.isEmpty()) {
|
||||||
|
log.error("条码:{} 不存在待入库的任务", request.getPalletNo());
|
||||||
return new CreateInstoreTaskResponse("400", String.format("条码:%s 不存在待入库的任务", request.getPalletNo()));
|
return new CreateInstoreTaskResponse("400", String.format("条码:%s 不存在待入库的任务", request.getPalletNo()));
|
||||||
}
|
}
|
||||||
AppOrderIn appOrderIn = waitInStockList.get(0);
|
AppOrderIn appOrderIn = waitInStockList.get(0);
|
||||||
|
|
@ -190,6 +111,15 @@ public class ContainerImplement implements ContainerService {
|
||||||
if(canUseLocations.isEmpty()){
|
if(canUseLocations.isEmpty()){
|
||||||
return new CreateInstoreTaskResponse("400", "没有可用库位");
|
return new CreateInstoreTaskResponse("400", "没有可用库位");
|
||||||
}
|
}
|
||||||
|
// 判断高度来决定物料去低层还是高层
|
||||||
|
if (WmsConstants.LOW_FLOOR.equals(request.getHeight())) {
|
||||||
|
canUseLocations = canUseLocations.stream().filter(l -> l.getLayer() == 1).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WmsConstants.HIGH_FLOOR.equals(request.getHeight())) {
|
||||||
|
canUseLocations = canUseLocations.stream().filter(l -> l.getLayer() != 1).toList();
|
||||||
|
}
|
||||||
|
|
||||||
Location useLocation = locationUtils.checkCanUse(canUseLocations);
|
Location useLocation = locationUtils.checkCanUse(canUseLocations);
|
||||||
if(useLocation == null) {
|
if(useLocation == null) {
|
||||||
return new CreateInstoreTaskResponse("400", "暂没有可以直接使用的库位,因为存在互锁的库位,请等待当前任务都执行完成后再试");
|
return new CreateInstoreTaskResponse("400", "暂没有可以直接使用的库位,因为存在互锁的库位,请等待当前任务都执行完成后再试");
|
||||||
|
|
@ -213,11 +143,17 @@ public class ContainerImplement implements ContainerService {
|
||||||
newInTask.setCreateTime(new java.util.Date());
|
newInTask.setCreateTime(new java.util.Date());
|
||||||
newInTask.setUserName("四向车API");
|
newInTask.setUserName("四向车API");
|
||||||
newInTask.setVehicleSize(Integer.valueOf(request.getHeight()));
|
newInTask.setVehicleSize(Integer.valueOf(request.getHeight()));
|
||||||
|
if(WmsConstants.EMPTY_VEHICHLE_ID.equals(request.getPalletNo())){
|
||||||
|
// 生成空托盘的虚拟id
|
||||||
|
newInTask.setVehicleNo(WmsUtils.generateUUIDString());
|
||||||
|
}else {
|
||||||
newInTask.setVehicleNo(request.getPalletNo());
|
newInTask.setVehicleNo(request.getPalletNo());
|
||||||
|
}
|
||||||
newInTask.setTaskPriority(1);
|
newInTask.setTaskPriority(1);
|
||||||
newInTask.setProductionDate(null);
|
newInTask.setProductionDate(null);
|
||||||
int insertTaskResult = taskMapper.addTask(newInTask); // 添加入库任务
|
int insertTaskResult = taskMapper.addTask(newInTask); // 添加入库任务
|
||||||
if(insertTaskResult < 1) {
|
if(insertTaskResult < 1) {
|
||||||
|
log.error("生成任务失败,无法插入新的入库任务");
|
||||||
return new CreateInstoreTaskResponse("400", "生成任务失败,无法插入新的入库任务");
|
return new CreateInstoreTaskResponse("400", "生成任务失败,无法插入新的入库任务");
|
||||||
}
|
}
|
||||||
// 更新库存中的待入库记录为入库中,并将库位更新进去
|
// 更新库存中的待入库记录为入库中,并将库位更新进去
|
||||||
|
|
@ -228,6 +164,7 @@ public class ContainerImplement implements ContainerService {
|
||||||
updateAppOrderIn.setUpdateTime(LocalDateTime.now());
|
updateAppOrderIn.setUpdateTime(LocalDateTime.now());
|
||||||
appOrderInMapper.update(updateAppOrderIn);
|
appOrderInMapper.update(updateAppOrderIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 占用库位
|
// 占用库位
|
||||||
Location location = new Location();
|
Location location = new Location();
|
||||||
location.setLocationId(useLocation.getLocationId());
|
location.setLocationId(useLocation.getLocationId());
|
||||||
|
|
@ -241,7 +178,6 @@ public class ContainerImplement implements ContainerService {
|
||||||
success.setPalletNo(request.getPalletNo());
|
success.setPalletNo(request.getPalletNo());
|
||||||
success.setFromCellNo(request.getFromCellNo());
|
success.setFromCellNo(request.getFromCellNo());
|
||||||
success.setToCellNo(useLocation.getLocationId());
|
success.setToCellNo(useLocation.getLocationId());
|
||||||
}
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -283,7 +219,6 @@ public class ContainerImplement implements ContainerService {
|
||||||
}
|
}
|
||||||
return new ContainerApiLocalResponse("400", String.format("不支持的任务状态:%s", request.getTaskState()));
|
return new ContainerApiLocalResponse("400", String.format("不支持的任务状态:%s", request.getTaskState()));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,8 +111,5 @@ public class MyPassword {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String pwd = decrypt("812C0C84E2970FA98456DDC5B0B59594");
|
|
||||||
System.out.println(pwd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
spring:
|
spring:
|
||||||
# 本地测试环境
|
# 本地测试环境
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql://localhost:3306/test?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||||
|
username: root
|
||||||
|
password: "000000"
|
||||||
|
|
||||||
|
# 在线环境
|
||||||
# datasource:
|
# datasource:
|
||||||
# url: jdbc:mysql://localhost:3306/wms_fdbk_xuzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
# url: jdbc:mysql://localhost:3306/wms_fdbk_xuzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||||
# username: root
|
# username: root
|
||||||
# password: "000000"
|
# password: 123456
|
||||||
|
|
||||||
# 在线环境
|
|
||||||
datasource:
|
|
||||||
url: jdbc:mysql://localhost:3306/wms_fdbk_xuzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
|
||||||
username: root
|
|
||||||
password: 123456
|
|
||||||
|
|
||||||
profiles:
|
profiles:
|
||||||
active: online
|
active: online
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user