代码更新:
1. 间接物料功能增加
This commit is contained in:
parent
ae69b6625c
commit
cc7abccc47
|
|
@ -1,8 +1,11 @@
|
||||||
package com.wms.constants.enums;
|
package com.wms.constants.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 载具状态
|
* 载具状态
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public enum VehicleStatus {
|
public enum VehicleStatus {
|
||||||
IN(1, "入库中"),
|
IN(1, "入库中"),
|
||||||
ON(2, "在库中"),
|
ON(2, "在库中"),
|
||||||
|
|
@ -19,11 +22,4 @@ public enum VehicleStatus {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import com.wms.entity.app.*;
|
||||||
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.StockDetailInfo;
|
import com.wms.entity.app.dto.extend.StockDetailInfo;
|
||||||
|
import com.wms.entity.app.dto.extend.VehicleDetailInfo;
|
||||||
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.app.wcs.*;
|
import com.wms.entity.app.wcs.*;
|
||||||
|
|
@ -188,7 +189,7 @@ public class TaskController {
|
||||||
response.setMessage("入库请求验证错误!" + validationInfo);
|
response.setMessage("入库请求验证错误!" + validationInfo);
|
||||||
return convertJsonString(response);
|
return convertJsonString(response);
|
||||||
}
|
}
|
||||||
// 查找当前箱子是否有其他等待入库的箱子
|
// 查找当前箱子是否有其他等待入库的任务
|
||||||
Task sameVehicleTempTask = taskService.getOne(new LambdaQueryWrapper<Task>()
|
Task sameVehicleTempTask = taskService.getOne(new LambdaQueryWrapper<Task>()
|
||||||
.eq(Task::getVehicleId, taskInRequest.getVehicleId())
|
.eq(Task::getVehicleId, taskInRequest.getVehicleId())
|
||||||
.eq(Task::getTaskStatus, WmsTaskStatus.TEMP.getCode())
|
.eq(Task::getTaskStatus, WmsTaskStatus.TEMP.getCode())
|
||||||
|
|
@ -356,6 +357,7 @@ public class TaskController {
|
||||||
newStock.setIsInventory(0);
|
newStock.setIsInventory(0);
|
||||||
newStock.setCreateTime(LocalDateTime.now());
|
newStock.setCreateTime(LocalDateTime.now());
|
||||||
newStock.setWeight(inTask.getWeight());
|
newStock.setWeight(inTask.getWeight());
|
||||||
|
newStock.setGoodsType(inTask.getGoodsRelated().getGoodsType());
|
||||||
StockDetailInfo detailInfo = new StockDetailInfo();
|
StockDetailInfo detailInfo = new StockDetailInfo();
|
||||||
detailInfo.setGoodsId(inTask.getGoodsRelated().getGoodsId());
|
detailInfo.setGoodsId(inTask.getGoodsRelated().getGoodsId());
|
||||||
detailInfo.setGoodsName(inTask.getGoodsRelated().getGoodsName());
|
detailInfo.setGoodsName(inTask.getGoodsRelated().getGoodsName());
|
||||||
|
|
@ -433,6 +435,16 @@ public class TaskController {
|
||||||
} else {
|
} else {
|
||||||
newVehicle.setIsEmpty(1);
|
newVehicle.setIsEmpty(1);
|
||||||
}
|
}
|
||||||
|
// 设置当前料箱的类型
|
||||||
|
if (inTask.getGoodsRelated() != null && inTask.getGoodsRelated().getGoodsType() != null && inTask.getGoodsRelated().getGoodsId() != null) {
|
||||||
|
newVehicle.setVehicleType(inTask.getGoodsRelated().getGoodsType());
|
||||||
|
if (Objects.equals(newVehicle.getVehicleType(), "间接物料")) {
|
||||||
|
// 如果是间接物料,则设置配对物料
|
||||||
|
List<VehicleDetailInfo> vehicleDetailInfos = new ArrayList<>();
|
||||||
|
vehicleDetailInfos.add(new VehicleDetailInfo(inTask.getGoodsRelated().getGoodsId()));
|
||||||
|
newVehicle.setDetails(vehicleDetailInfos);
|
||||||
|
}
|
||||||
|
}
|
||||||
newVehicle.setLastInTime(LocalDateTime.now());
|
newVehicle.setLastInTime(LocalDateTime.now());
|
||||||
vehicleService.save(newVehicle);
|
vehicleService.save(newVehicle);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -449,6 +461,17 @@ public class TaskController {
|
||||||
} else {
|
} else {
|
||||||
currentVehicle.setIsEmpty(1);
|
currentVehicle.setIsEmpty(1);
|
||||||
}
|
}
|
||||||
|
if (inTask.getGoodsRelated() != null && inTask.getGoodsRelated().getGoodsType() != null && inTask.getGoodsRelated().getGoodsId() != null) {
|
||||||
|
currentVehicle.setVehicleType(inTask.getGoodsRelated().getGoodsType());
|
||||||
|
if (Objects.equals(currentVehicle.getVehicleType(), "间接物料")) {
|
||||||
|
// 如果是间接物料,则设置配对物料
|
||||||
|
List<VehicleDetailInfo> vehicleDetailInfos = currentVehicle.getDetails() == null ? new ArrayList<>() : currentVehicle.getDetails();
|
||||||
|
if (!vehicleDetailInfos.stream().map(VehicleDetailInfo::getGoodsId).toList().contains(inTask.getGoodsRelated().getGoodsId())) {
|
||||||
|
vehicleDetailInfos.add(new VehicleDetailInfo(inTask.getGoodsRelated().getGoodsId()));
|
||||||
|
currentVehicle.setDetails(vehicleDetailInfos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
currentVehicle.setLastInTime(LocalDateTime.now());
|
currentVehicle.setLastInTime(LocalDateTime.now());
|
||||||
vehicleService.update(currentVehicle, new LambdaUpdateWrapper<Vehicle>().eq(Vehicle::getVehicleId, currentVehicle.getVehicleId()));
|
vehicleService.update(currentVehicle, new LambdaUpdateWrapper<Vehicle>().eq(Vehicle::getVehicleId, currentVehicle.getVehicleId()));
|
||||||
}
|
}
|
||||||
|
|
@ -472,6 +495,8 @@ public class TaskController {
|
||||||
// 非出库任务跳过
|
// 非出库任务跳过
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// 查询到当前料箱
|
||||||
|
Vehicle outVehicle = vehicleService.getOne(new LambdaQueryWrapper<Vehicle>().eq(Vehicle::getVehicleId, outTask.getVehicleId()));
|
||||||
if (outTask.getIsPicking() == 1) {
|
if (outTask.getIsPicking() == 1) {
|
||||||
// 当前载具设置为出库中状态
|
// 当前载具设置为出库中状态
|
||||||
vehicleService.update(new LambdaUpdateWrapper<Vehicle>()
|
vehicleService.update(new LambdaUpdateWrapper<Vehicle>()
|
||||||
|
|
@ -513,12 +538,14 @@ public class TaskController {
|
||||||
// 删除出库任务
|
// 删除出库任务
|
||||||
taskService.remove(new LambdaQueryWrapper<Task>().eq(Task::getTaskId, outTask.getTaskId()));
|
taskService.remove(new LambdaQueryWrapper<Task>().eq(Task::getTaskId, outTask.getTaskId()));
|
||||||
// 释放原来的库位
|
// 释放原来的库位
|
||||||
|
if (outVehicle == null || !Objects.equals(outVehicle.getVehicleType(), "间接物料")) {
|
||||||
locationService.update(new LambdaUpdateWrapper<Location>()
|
locationService.update(new LambdaUpdateWrapper<Location>()
|
||||||
.set(Location::getLocationStatus, LocationStatus.EMPTY.getCode())
|
.set(Location::getLocationStatus, LocationStatus.EMPTY.getCode())
|
||||||
.set(Location::getVehicleId, "")
|
.set(Location::getVehicleId, "")
|
||||||
.eq(Location::getLocationId, outTask.getOrigin()));
|
.eq(Location::getLocationId, outTask.getOrigin()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 移库任务完成
|
// 移库任务完成
|
||||||
if (taskType == TaskType.MOVE.getCode()) {
|
if (taskType == TaskType.MOVE.getCode()) {
|
||||||
// 对所有任务组里面的移库任务进行处理
|
// 对所有任务组里面的移库任务进行处理
|
||||||
|
|
@ -608,7 +635,7 @@ public class TaskController {
|
||||||
// 请求可用库位
|
// 请求可用库位
|
||||||
String nextLocationId = "";
|
String nextLocationId = "";
|
||||||
for (int i = 0; i < locationService.count(new LambdaQueryWrapper<Location>().eq(Location::getLocationStatus, LocationStatus.EMPTY.getCode())); i++) {
|
for (int i = 0; i < locationService.count(new LambdaQueryWrapper<Location>().eq(Location::getLocationStatus, LocationStatus.EMPTY.getCode())); i++) {
|
||||||
Map<String, String> resultMap = locationService.getOneLocation("", "");
|
Map<String, String> resultMap = locationService.getOneLocation("", wcsVehicleInRequest.getVehicleNo(), "");
|
||||||
if (resultMap.isEmpty() || !resultMap.containsKey("nextLocationId")) {
|
if (resultMap.isEmpty() || !resultMap.containsKey("nextLocationId")) {
|
||||||
logger.error("暂无可用库位");
|
logger.error("暂无可用库位");
|
||||||
response.setCode(ResponseCode.ERROR.getCode());
|
response.setCode(ResponseCode.ERROR.getCode());
|
||||||
|
|
@ -616,6 +643,10 @@ public class TaskController {
|
||||||
return convertJsonString(response);
|
return convertJsonString(response);
|
||||||
} else {
|
} else {
|
||||||
Location nextLocation = locationService.getOne(new LambdaQueryWrapper<Location>().eq(Location::getLocationId, resultMap.get("nextLocationId")).last("limit 1"));
|
Location nextLocation = locationService.getOne(new LambdaQueryWrapper<Location>().eq(Location::getLocationId, resultMap.get("nextLocationId")).last("limit 1"));
|
||||||
|
if (Objects.equals(nextLocation.getLocationStatus(), LocationStatus.OCCUPY.getCode()) && nextLocation.getVehicleId().equals(wcsVehicleInRequest.getVehicleNo())) {
|
||||||
|
nextLocationId = resultMap.get("nextLocationId");
|
||||||
|
break;
|
||||||
|
}
|
||||||
LambdaUpdateWrapper<Location> updateLocationWrapper = new LambdaUpdateWrapper<Location>()
|
LambdaUpdateWrapper<Location> updateLocationWrapper = new LambdaUpdateWrapper<Location>()
|
||||||
.set(Location::getLocationStatus, LocationStatus.OCCUPY.getCode())
|
.set(Location::getLocationStatus, LocationStatus.OCCUPY.getCode())
|
||||||
.set(Location::getVehicleId, wcsVehicleInRequest.getVehicleNo())
|
.set(Location::getVehicleId, wcsVehicleInRequest.getVehicleNo())
|
||||||
|
|
@ -695,7 +726,7 @@ public class TaskController {
|
||||||
// 请求可用库位
|
// 请求可用库位
|
||||||
String nextLocationId = "";
|
String nextLocationId = "";
|
||||||
for (int i = 0; i < locationService.count(new LambdaQueryWrapper<Location>().eq(Location::getLocationStatus, LocationStatus.EMPTY.getCode())); i++) {
|
for (int i = 0; i < locationService.count(new LambdaQueryWrapper<Location>().eq(Location::getLocationStatus, LocationStatus.EMPTY.getCode())); i++) {
|
||||||
Map<String, String> resultMap = locationService.getOneLocation("", "");
|
Map<String, String> resultMap = locationService.getOneLocation("", duplicateLocationRequest.getVehicleId(), "");
|
||||||
if (resultMap.isEmpty() || !resultMap.containsKey("nextLocationId")) {
|
if (resultMap.isEmpty() || !resultMap.containsKey("nextLocationId")) {
|
||||||
logger.error("暂无可用库位");
|
logger.error("暂无可用库位");
|
||||||
response.setCode(ResponseCode.ERROR.getCode());
|
response.setCode(ResponseCode.ERROR.getCode());
|
||||||
|
|
@ -703,6 +734,10 @@ public class TaskController {
|
||||||
return convertJsonString(response);
|
return convertJsonString(response);
|
||||||
} else {
|
} else {
|
||||||
Location nextLocation = locationService.getOne(new LambdaQueryWrapper<Location>().eq(Location::getLocationId, resultMap.get("nextLocationId")).last("limit 1"));
|
Location nextLocation = locationService.getOne(new LambdaQueryWrapper<Location>().eq(Location::getLocationId, resultMap.get("nextLocationId")).last("limit 1"));
|
||||||
|
if (Objects.equals(nextLocation.getLocationStatus(), LocationStatus.OCCUPY.getCode()) && nextLocation.getVehicleId().equals(duplicateLocationRequest.getVehicleId())) {
|
||||||
|
nextLocationId = resultMap.get("nextLocationId");
|
||||||
|
break;
|
||||||
|
}
|
||||||
LambdaUpdateWrapper<Location> updateLocationWrapper = new LambdaUpdateWrapper<Location>()
|
LambdaUpdateWrapper<Location> updateLocationWrapper = new LambdaUpdateWrapper<Location>()
|
||||||
.set(Location::getLocationStatus, LocationStatus.OCCUPY.getCode())
|
.set(Location::getLocationStatus, LocationStatus.OCCUPY.getCode())
|
||||||
.set(Location::getVehicleId, duplicateLocationRequest.getVehicleId())
|
.set(Location::getVehicleId, duplicateLocationRequest.getVehicleId())
|
||||||
|
|
@ -2289,11 +2324,15 @@ public class TaskController {
|
||||||
String nextLocationId = "";
|
String nextLocationId = "";
|
||||||
int emptyLocationSize = (int) locationService.count(new LambdaQueryWrapper<Location>().eq(Location::getLocationStatus, LocationStatus.EMPTY.getCode()));
|
int emptyLocationSize = (int) locationService.count(new LambdaQueryWrapper<Location>().eq(Location::getLocationStatus, LocationStatus.EMPTY.getCode()));
|
||||||
for (int i = 0; i < emptyLocationSize; i++) {
|
for (int i = 0; i < emptyLocationSize; i++) {
|
||||||
Map<String, String> resultMap = locationService.getOneLocation("", "");
|
Map<String, String> resultMap = locationService.getOneLocation("", vehicleId, "");
|
||||||
if (resultMap.isEmpty() || !resultMap.containsKey("nextLocationId")) {
|
if (resultMap.isEmpty() || !resultMap.containsKey("nextLocationId")) {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
Location nextLocation = locationService.getOne(new LambdaQueryWrapper<Location>().eq(Location::getLocationId, resultMap.get("nextLocationId")).last("limit 1"));
|
Location nextLocation = locationService.getOne(new LambdaQueryWrapper<Location>().eq(Location::getLocationId, resultMap.get("nextLocationId")).last("limit 1"));
|
||||||
|
if (Objects.equals(nextLocation.getLocationStatus(), LocationStatus.OCCUPY.getCode()) && nextLocation.getVehicleId().equals(vehicleId)) {
|
||||||
|
nextLocationId = resultMap.get("nextLocationId");
|
||||||
|
break;
|
||||||
|
}
|
||||||
LambdaUpdateWrapper<Location> updateLocationWrapper = new LambdaUpdateWrapper<Location>()
|
LambdaUpdateWrapper<Location> updateLocationWrapper = new LambdaUpdateWrapper<Location>()
|
||||||
.set(Location::getLocationStatus, LocationStatus.OCCUPY.getCode())
|
.set(Location::getLocationStatus, LocationStatus.OCCUPY.getCode())
|
||||||
.set(Location::getVehicleId, vehicleId)
|
.set(Location::getVehicleId, vehicleId)
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,8 @@ public class TaskDetailInfo {
|
||||||
* 原库存剩余数量
|
* 原库存剩余数量
|
||||||
*/
|
*/
|
||||||
private BigDecimal originNum;
|
private BigDecimal originNum;
|
||||||
|
/**
|
||||||
|
* 物料类型
|
||||||
|
*/
|
||||||
|
private String goodsType;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,14 @@
|
||||||
package com.wms.entity.app.dto.extend;
|
package com.wms.entity.app.dto.extend;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 料箱详细信息
|
* 料箱详细信息
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
public class VehicleDetailInfo {
|
public class VehicleDetailInfo {
|
||||||
/// 上
|
/// 料号
|
||||||
private String up;
|
private String goodsId;
|
||||||
/// 下
|
|
||||||
private String down;
|
|
||||||
/// 左右
|
|
||||||
private String left;
|
|
||||||
/// 右
|
|
||||||
private String right;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,11 @@ public class StockVo {
|
||||||
*/
|
*/
|
||||||
@JsonProperty("totalNum")
|
@JsonProperty("totalNum")
|
||||||
private BigDecimal totalNum;
|
private BigDecimal totalNum;
|
||||||
|
/**
|
||||||
|
* 物料类型
|
||||||
|
*/
|
||||||
|
@JsonProperty("goodsType")
|
||||||
|
private String goodsType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从数据库实体转换为前端显示
|
* 从数据库实体转换为前端显示
|
||||||
|
|
@ -122,6 +127,7 @@ public class StockVo {
|
||||||
stockVo.setGoodsStatus(stockPo.getGoodsRelated().getGoodsStatus());
|
stockVo.setGoodsStatus(stockPo.getGoodsRelated().getGoodsStatus());
|
||||||
stockVo.setRemainNum(stockPo.getGoodsRelated().getRemainNum());
|
stockVo.setRemainNum(stockPo.getGoodsRelated().getRemainNum());
|
||||||
stockVo.setTotalNum(stockPo.getGoodsRelated().getTotalNum());
|
stockVo.setTotalNum(stockPo.getGoodsRelated().getTotalNum());
|
||||||
|
stockVo.setGoodsType(stockPo.getGoodsType());
|
||||||
return stockVo;
|
return stockVo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import lombok.Data;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 载具VO
|
* 载具VO
|
||||||
|
|
@ -35,7 +36,7 @@ public class VehicleVO {
|
||||||
/**
|
/**
|
||||||
* 额外信息
|
* 额外信息
|
||||||
*/
|
*/
|
||||||
private VehicleDetailInfo details;
|
private List<VehicleDetailInfo> details;
|
||||||
/**
|
/**
|
||||||
* 上次入库时间
|
* 上次入库时间
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -66,4 +66,9 @@ public class Location {
|
||||||
*/
|
*/
|
||||||
@TableField("vehicle_id")
|
@TableField("vehicle_id")
|
||||||
private String vehicleId;
|
private String vehicleId;
|
||||||
|
/**
|
||||||
|
* 物料类型
|
||||||
|
*/
|
||||||
|
@TableField("goods_type")
|
||||||
|
private String goodsType;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,4 +77,9 @@ public class Stock {
|
||||||
*/
|
*/
|
||||||
@TableField(value = "goods_related", typeHandler = Fastjson2TypeHandler.class)
|
@TableField(value = "goods_related", typeHandler = Fastjson2TypeHandler.class)
|
||||||
private StockDetailInfo goodsRelated;
|
private StockDetailInfo goodsRelated;
|
||||||
|
/**
|
||||||
|
* 物料类型
|
||||||
|
*/
|
||||||
|
@TableField("goods_type")
|
||||||
|
private String goodsType;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.wms.entity.app.dto.extend.VehicleDetailInfo;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 载具
|
* 载具
|
||||||
|
|
@ -44,7 +45,7 @@ public class Vehicle {
|
||||||
* 额外信息
|
* 额外信息
|
||||||
*/
|
*/
|
||||||
@TableField(value = "details", typeHandler = Fastjson2TypeHandler.class)
|
@TableField(value = "details", typeHandler = Fastjson2TypeHandler.class)
|
||||||
private VehicleDetailInfo details;
|
private List<VehicleDetailInfo> details;
|
||||||
/**
|
/**
|
||||||
* 上次入库时间
|
* 上次入库时间
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,9 @@ public interface LocationService extends IService<Location> {
|
||||||
/**
|
/**
|
||||||
* 查找一个可用库位
|
* 查找一个可用库位
|
||||||
* @param inPoint 入库站点
|
* @param inPoint 入库站点
|
||||||
|
* @param vehicleId 箱号
|
||||||
* @param goodsId 物料编号--可选
|
* @param goodsId 物料编号--可选
|
||||||
* @return 结果 nextLocationId, preTaskId
|
* @return 结果 nextLocationId, preTaskId
|
||||||
*/
|
*/
|
||||||
Map<String, String> getOneLocation(String inPoint, String goodsId);
|
Map<String, String> getOneLocation(String inPoint, String vehicleId, String goodsId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.wms.service.business.serviceImplements;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.wms.constants.enums.*;
|
import com.wms.constants.enums.*;
|
||||||
|
import com.wms.entity.app.dto.extend.VehicleDetailInfo;
|
||||||
import com.wms.entity.app.request.GoodsInRequest;
|
import com.wms.entity.app.request.GoodsInRequest;
|
||||||
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;
|
||||||
|
|
@ -20,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static com.wms.constants.WmsConstants.MYSQL_JSON_CI;
|
import static com.wms.constants.WmsConstants.MYSQL_JSON_CI;
|
||||||
|
|
@ -54,8 +57,8 @@ public class ValidateServiceImplements implements IValidateService {
|
||||||
return TaskInValidationEnum.NO_VEHICLE_ID.getErrorMessage();
|
return TaskInValidationEnum.NO_VEHICLE_ID.getErrorMessage();
|
||||||
}
|
}
|
||||||
// 验证载具号是否重复入库
|
// 验证载具号是否重复入库
|
||||||
if (vehicleService.exists(new LambdaQueryWrapper<Vehicle>().eq(Vehicle::getVehicleId, taskInRequest.getVehicleId())
|
Vehicle existVehicle = vehicleService.getOne(new LambdaQueryWrapper<Vehicle>().eq(Vehicle::getVehicleId, taskInRequest.getVehicleId()).last("limit 1"));
|
||||||
.and(wrapper -> wrapper.eq(Vehicle::getVehicleStatus, VehicleStatus.ON.getCode())))) {
|
if (existVehicle != null && Objects.equals(existVehicle.getVehicleStatus(), VehicleStatus.ON.getCode())) {
|
||||||
return TaskInValidationEnum.DUPLICATE_VEHICLE_ID.getErrorMessage();
|
return TaskInValidationEnum.DUPLICATE_VEHICLE_ID.getErrorMessage();
|
||||||
}
|
}
|
||||||
// 如果这个箱子还有拣选任务,不允许操作
|
// 如果这个箱子还有拣选任务,不允许操作
|
||||||
|
|
@ -71,15 +74,41 @@ public class ValidateServiceImplements implements IValidateService {
|
||||||
}
|
}
|
||||||
// 验证物料信息
|
// 验证物料信息
|
||||||
if (taskInRequest.getGoodsList() != null && !taskInRequest.getGoodsList().isEmpty()) {
|
if (taskInRequest.getGoodsList() != null && !taskInRequest.getGoodsList().isEmpty()) {
|
||||||
|
// 判断当前入库的箱子是什么类型
|
||||||
|
int goodsType = 0;
|
||||||
|
List<String> canInGoodsIdList = new ArrayList<>();
|
||||||
|
if (existVehicle != null) {
|
||||||
|
if (!Objects.equals(existVehicle.getVehicleType(), "间接物料")) {
|
||||||
|
goodsType = 1;
|
||||||
|
} else {
|
||||||
|
goodsType = 2;
|
||||||
|
if (existVehicle.getDetails() != null) {
|
||||||
|
canInGoodsIdList = existVehicle.getDetails().stream().map(VehicleDetailInfo::getGoodsId).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for (GoodsInRequest goodsInRequest : taskInRequest.getGoodsList()) {
|
for (GoodsInRequest goodsInRequest : taskInRequest.getGoodsList()) {
|
||||||
// 验证物料编号
|
// 验证物料编号
|
||||||
if (StringUtils.isEmpty(goodsInRequest.getGoodsId())) {
|
if (StringUtils.isEmpty(goodsInRequest.getGoodsId())) {
|
||||||
return TaskInValidationEnum.NO_GOODS_ID.getErrorMessage();
|
return TaskInValidationEnum.NO_GOODS_ID.getErrorMessage();
|
||||||
} else {
|
} else {
|
||||||
|
if (!canInGoodsIdList.isEmpty() && !canInGoodsIdList.contains(goodsInRequest.getGoodsId())) {
|
||||||
|
return "当前料箱是间接物料料箱,当前物料不在绑定物料内。";
|
||||||
|
}
|
||||||
Goods goods = goodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, goodsInRequest.getGoodsId()));
|
Goods goods = goodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, goodsInRequest.getGoodsId()));
|
||||||
if (goods == null) {
|
if (goods == null) {
|
||||||
return TaskInValidationEnum.ERROR_GOODS_ID.getErrorMessage();
|
return TaskInValidationEnum.ERROR_GOODS_ID.getErrorMessage();
|
||||||
}
|
}
|
||||||
|
if (goodsType == 0) {
|
||||||
|
goodsType = Objects.equals(goods.getGoodsType(), "间接物料") ? 2 : 1;
|
||||||
|
} else {
|
||||||
|
if (goodsType == 1 && Objects.equals(goods.getGoodsType(), "间接物料")) {
|
||||||
|
return "间接物料和直接物料无法一起入库。";
|
||||||
|
}
|
||||||
|
if (goodsType == 2 && !Objects.equals(goods.getGoodsType(), "间接物料")) {
|
||||||
|
return "直接物料和间接物料无法一起入库。";
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO 超重验证
|
// TODO 超重验证
|
||||||
// // 验证重量
|
// // 验证重量
|
||||||
// BigDecimal max_weight = BigDecimal.valueOf(10000000);
|
// BigDecimal max_weight = BigDecimal.valueOf(10000000);
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
||||||
goodsRelatedInfo.setGoodsName(goods.getGoodsName());
|
goodsRelatedInfo.setGoodsName(goods.getGoodsName());
|
||||||
goodsRelatedInfo.setOpNum(goodsInRequest.getGoodsNum());
|
goodsRelatedInfo.setOpNum(goodsInRequest.getGoodsNum());
|
||||||
goodsRelatedInfo.setOriginNum(BigDecimal.ZERO);
|
goodsRelatedInfo.setOriginNum(BigDecimal.ZERO);
|
||||||
|
goodsRelatedInfo.setGoodsType(goods.getGoodsType());
|
||||||
tempInTask.setGoodsRelated(goodsRelatedInfo);
|
tempInTask.setGoodsRelated(goodsRelatedInfo);
|
||||||
|
|
||||||
tempTasks.add(tempInTask);
|
tempTasks.add(tempInTask);
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.wms.constants.enums.StockStatus;
|
import com.wms.constants.enums.StockStatus;
|
||||||
import com.wms.constants.enums.TaskType;
|
import com.wms.constants.enums.TaskType;
|
||||||
import com.wms.constants.enums.WmsTaskStatus;
|
import com.wms.constants.enums.WmsTaskStatus;
|
||||||
import com.wms.entity.table.Location;
|
import com.wms.entity.table.*;
|
||||||
import com.wms.entity.table.Stand;
|
import com.wms.mapper.*;
|
||||||
import com.wms.entity.table.Stock;
|
|
||||||
import com.wms.entity.table.Task;
|
|
||||||
import com.wms.mapper.LocationMapper;
|
|
||||||
import com.wms.mapper.StandMapper;
|
|
||||||
import com.wms.mapper.StockMapper;
|
|
||||||
import com.wms.mapper.TaskMapper;
|
|
||||||
import com.wms.service.LocationService;
|
import com.wms.service.LocationService;
|
||||||
import com.wms.utils.StringUtils;
|
import com.wms.utils.StringUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
@ -45,17 +39,22 @@ public class LocationServiceImplements extends ServiceImpl<LocationMapper, Locat
|
||||||
* 任务
|
* 任务
|
||||||
*/
|
*/
|
||||||
private final TaskMapper taskMapper;
|
private final TaskMapper taskMapper;
|
||||||
|
/**
|
||||||
|
* 料箱Mapper
|
||||||
|
*/
|
||||||
|
private final VehicleMapper vehicleMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找一个可用库位
|
* 查找一个可用库位
|
||||||
*
|
*
|
||||||
* @param inPoint 入库站点
|
* @param inPoint 入库站点
|
||||||
|
* @param vehicleId 箱号
|
||||||
* @param goodsId 物料编号--可选
|
* @param goodsId 物料编号--可选
|
||||||
* @return 结果
|
* @return 结果
|
||||||
* nextLocationId 下一个可用库位
|
* nextLocationId 下一个可用库位
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getOneLocation(String inPoint, String goodsId) {
|
public Map<String, String> getOneLocation(String inPoint, String vehicleId, String goodsId) {
|
||||||
Map<String, String> resultMap = new HashMap<>();
|
Map<String, String> resultMap = new HashMap<>();
|
||||||
// 添加对应设备的查询条件
|
// 添加对应设备的查询条件
|
||||||
int equipmentId = -1;
|
int equipmentId = -1;
|
||||||
|
|
@ -71,7 +70,7 @@ public class LocationServiceImplements extends ServiceImpl<LocationMapper, Locat
|
||||||
}
|
}
|
||||||
// 指定设备号
|
// 指定设备号
|
||||||
if (equipmentId != -1) {
|
if (equipmentId != -1) {
|
||||||
return getOneLocationByEquipmentId(resultMap, equipmentId);
|
return getOneLocationByEquipmentId(resultMap, equipmentId, vehicleId);
|
||||||
} else {// 未指定设备号
|
} else {// 未指定设备号
|
||||||
// 轮询堆垛机状态
|
// 轮询堆垛机状态
|
||||||
List<Stand> stackerList = standMapper.selectList(new LambdaQueryWrapper<Stand>()
|
List<Stand> stackerList = standMapper.selectList(new LambdaQueryWrapper<Stand>()
|
||||||
|
|
@ -109,13 +108,8 @@ public class LocationServiceImplements extends ServiceImpl<LocationMapper, Locat
|
||||||
// 跳出循环
|
// 跳出循环
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
getOneLocationByEquipmentId(resultMap, mostEmptyStackerId);
|
getOneLocationByEquipmentId(resultMap, mostEmptyStackerId, vehicleId);
|
||||||
if (!resultMap.isEmpty()) {
|
if (!resultMap.isEmpty()) {
|
||||||
// 更新最近使用时间
|
|
||||||
standMapper.update(new LambdaUpdateWrapper<Stand>()
|
|
||||||
.set(Stand::getLastUseTime, LocalDateTime.now())
|
|
||||||
.eq(Stand::getEquipmentId, mostEmptyStackerId)
|
|
||||||
.eq(Stand::getStandType, 3));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
runningTaskNumToEquipmentMap.remove(mostEmptyStackerId);
|
runningTaskNumToEquipmentMap.remove(mostEmptyStackerId);
|
||||||
|
|
@ -159,8 +153,61 @@ public class LocationServiceImplements extends ServiceImpl<LocationMapper, Locat
|
||||||
* @param equipmentId 设备号
|
* @param equipmentId 设备号
|
||||||
* @return 查询结果
|
* @return 查询结果
|
||||||
*/
|
*/
|
||||||
private Map<String, String> getOneLocationByEquipmentId(Map<String, String> resultMap, int equipmentId) {
|
private Map<String, String> getOneLocationByEquipmentId(Map<String, String> resultMap, int equipmentId, String vehicleId) {
|
||||||
resultMap.clear();
|
resultMap.clear();
|
||||||
|
// 查询当前的料箱是否存在
|
||||||
|
if (StringUtils.isNotEmpty(vehicleId)) {
|
||||||
|
Vehicle exsitVehicle = vehicleMapper.selectOne(new LambdaQueryWrapper<Vehicle>()
|
||||||
|
.eq(Vehicle::getVehicleId, vehicleId).last("limit 1"));
|
||||||
|
if (exsitVehicle != null) {
|
||||||
|
if (Objects.equals(exsitVehicle.getVehicleType(), "间接物料")) {
|
||||||
|
LambdaQueryWrapper<Location> locationQueryWrapper = new LambdaQueryWrapper<Location>().eq(Location::getLocationId, exsitVehicle.getCurrentLocation());
|
||||||
|
List<Location> availableLocations = locationMapper.selectList(locationQueryWrapper);
|
||||||
|
for (Location oneAvailableLocation : availableLocations) {
|
||||||
|
resultMap.put("nextLocationId", oneAvailableLocation.getLocationId());
|
||||||
|
standMapper.update(new LambdaUpdateWrapper<Stand>()
|
||||||
|
.set(Stand::getLastUseTime, LocalDateTime.now())
|
||||||
|
.eq(Stand::getEquipmentId, equipmentId)
|
||||||
|
.eq(Stand::getStandType, 3));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 判断当前料箱是不是承载的是间接物料的任务
|
||||||
|
List<Task> tasks = taskMapper.selectList(new LambdaQueryWrapper<Task>()
|
||||||
|
.eq(Task::getVehicleId, vehicleId)
|
||||||
|
.eq(Task::getTaskType, TaskType.IN.getCode()));
|
||||||
|
boolean isIndirect = false;
|
||||||
|
for (Task task : tasks) {
|
||||||
|
if (Objects.equals(task.getGoodsRelated().getGoodsType(), "间接物料")) {
|
||||||
|
isIndirect = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isIndirect) {
|
||||||
|
LambdaQueryWrapper<Location> locationQueryWrapper = new LambdaQueryWrapper<Location>()
|
||||||
|
.eq(Location::getGoodsType, "间接物料")
|
||||||
|
.eq(Location::getAreaId, 1)
|
||||||
|
.eq(Location::getLocationStatus, 0)
|
||||||
|
.eq(Location::getLocationType, 1)
|
||||||
|
.eq(Location::getIsLock, 0)
|
||||||
|
.eq(Location::getEquipmentId, equipmentId)
|
||||||
|
.orderByDesc(Location::getWDepth)
|
||||||
|
.orderByAsc(List.of(Location::getWCol, Location::getWLayer, Location::getWRow));
|
||||||
|
List<Location> availableLocations = locationMapper.selectList(locationQueryWrapper);
|
||||||
|
for (Location oneAvailableLocation : availableLocations) {
|
||||||
|
resultMap.put("nextLocationId", oneAvailableLocation.getLocationId());
|
||||||
|
standMapper.update(new LambdaUpdateWrapper<Stand>()
|
||||||
|
.set(Stand::getLastUseTime, LocalDateTime.now())
|
||||||
|
.eq(Stand::getEquipmentId, equipmentId)
|
||||||
|
.eq(Stand::getStandType, 3));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
LambdaQueryWrapper<Location> locationQueryWrapper = new LambdaQueryWrapper<Location>()
|
LambdaQueryWrapper<Location> locationQueryWrapper = new LambdaQueryWrapper<Location>()
|
||||||
.eq(Location::getAreaId, 1)
|
.eq(Location::getAreaId, 1)
|
||||||
.eq(Location::getLocationStatus, 0)
|
.eq(Location::getLocationStatus, 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user