代码更新
This commit is contained in:
parent
1281754432
commit
cfd2c9ba90
|
|
@ -1,6 +1,5 @@
|
||||||
package com.wms;
|
package com.wms;
|
||||||
|
|
||||||
import com.wms.utils.MailUtils;
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
import org.springframework.boot.ApplicationArguments;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.wms.controller;
|
package com.wms.controller;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.wms.annotation.MyLog;
|
||||||
import com.wms.constants.enums.ResponseCode;
|
import com.wms.constants.enums.ResponseCode;
|
||||||
import com.wms.entity.app.ResponseEntity;
|
import com.wms.entity.app.ResponseEntity;
|
||||||
import com.wms.entity.table.Config;
|
import com.wms.entity.table.Config;
|
||||||
|
|
@ -20,6 +21,8 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.wms.utils.StringUtils.convertJsonString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WMS系统配置控制类
|
* WMS系统配置控制类
|
||||||
* @author 梁州
|
* @author 梁州
|
||||||
|
|
@ -60,8 +63,9 @@ public class ConfigController{
|
||||||
@PostMapping("/updateConfig")
|
@PostMapping("/updateConfig")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
|
@MyLog(logTitle = "更新配置", logMethod = "updateConfig")
|
||||||
public String updateConfig(@RequestBody Config config) {
|
public String updateConfig(@RequestBody Config config) {
|
||||||
logger.info("更新系统配置,{}:{},请求ip:{}", config.getConfigName(), config.getConfigValue(), HttpUtils.getIpAddr(servletRequest));
|
logger.info("更新系统配置,{},请求ip:{}", convertJsonString(config), HttpUtils.getIpAddr(servletRequest));
|
||||||
// 创建响应信息
|
// 创建响应信息
|
||||||
ResponseEntity rsp = new ResponseEntity();
|
ResponseEntity rsp = new ResponseEntity();
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ public class JobComponent {
|
||||||
public void detectWork() {
|
public void detectWork() {
|
||||||
// 轮询工作站台,判断是否需要下发任务
|
// 轮询工作站台,判断是否需要下发任务
|
||||||
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::getStandType, 2));
|
.eq(Stand::getStandType, 2));
|
||||||
for (Stand workStation : stands) {
|
for (Stand workStation : stands) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -208,11 +208,12 @@ public class LocationController {
|
||||||
for (int j = 1; j <= locationQuery.getWCol(); j++) {
|
for (int j = 1; j <= locationQuery.getWCol(); j++) {
|
||||||
for (int k = 1; k <= locationQuery.getWLayer(); k++) {
|
for (int k = 1; k <= locationQuery.getWLayer(); k++) {
|
||||||
Location location = new Location();
|
Location location = new Location();
|
||||||
location.setLocationId(StringUtils.padLeft(String.valueOf(i), 2, "0") + "-" + StringUtils.padLeft(String.valueOf(j), 2, "0") + "-" + StringUtils.padLeft(String.valueOf(k), 2, "0"));
|
location.setLocationId(StringUtils.padLeft(String.valueOf(i), 2, "0") + "-" + StringUtils.padLeft(String.valueOf(j), 2, "0") + "-" + StringUtils.padLeft(String.valueOf(k), 2, "0") + "-01");
|
||||||
location.setAreaId(1);
|
location.setAreaId(1);
|
||||||
location.setWRow(i);
|
location.setWRow(i);
|
||||||
location.setWCol(j);
|
location.setWCol(j);
|
||||||
location.setWLayer(k);
|
location.setWLayer(k);
|
||||||
|
location.setWDepth(1);
|
||||||
location.setLocationType(1);
|
location.setLocationType(1);
|
||||||
location.setLocationStatus(0);
|
location.setLocationStatus(0);
|
||||||
location.setIsLock(0);
|
location.setIsLock(0);
|
||||||
|
|
@ -235,6 +236,7 @@ public class LocationController {
|
||||||
}
|
}
|
||||||
locationService.saveBatch(locations);
|
locationService.saveBatch(locations);
|
||||||
|
|
||||||
|
logger.info("生成库位成功。");
|
||||||
rsp.setCode(ResponseCode.OK.getCode());
|
rsp.setCode(ResponseCode.OK.getCode());
|
||||||
rsp.setMessage("生成库位成功。");
|
rsp.setMessage("生成库位成功。");
|
||||||
return convertJsonString(rsp);
|
return convertJsonString(rsp);
|
||||||
|
|
|
||||||
|
|
@ -366,6 +366,7 @@ public class TaskController {
|
||||||
} else {
|
} else {
|
||||||
newVehicle.setIsEmpty(1);
|
newVehicle.setIsEmpty(1);
|
||||||
}
|
}
|
||||||
|
newVehicle.setLastInTime(LocalDateTime.now());
|
||||||
vehicleService.save(newVehicle);
|
vehicleService.save(newVehicle);
|
||||||
} else {
|
} else {
|
||||||
// 更新载具
|
// 更新载具
|
||||||
|
|
@ -381,6 +382,7 @@ public class TaskController {
|
||||||
} else {
|
} else {
|
||||||
currentVehicle.setIsEmpty(1);
|
currentVehicle.setIsEmpty(1);
|
||||||
}
|
}
|
||||||
|
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()));
|
||||||
}
|
}
|
||||||
// 添加任务记录
|
// 添加任务记录
|
||||||
|
|
@ -502,11 +504,11 @@ public class TaskController {
|
||||||
* @param wcsVehicleInRequest 载具入库请求
|
* @param wcsVehicleInRequest 载具入库请求
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping("/WcsVehicleIn")
|
@PostMapping("/wcsVehicleIn")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
@MyLog(logTitle = "Wcs请求载具入库", logMethod = "WcsVehicleIn")
|
@MyLog(logTitle = "Wcs请求载具入库", logMethod = "wcsVehicleIn")
|
||||||
public String WcsVehicleInRequest(@RequestBody WcsVehicleInRequest wcsVehicleInRequest) {
|
public String wcsVehicleInRequest(@RequestBody WcsVehicleInRequest wcsVehicleInRequest) {
|
||||||
logger.info("接收到Wcs请求载具入库:{},ip地址:{}", convertJsonString(wcsVehicleInRequest), HttpUtils.getIpAddr(servletRequest));
|
logger.info("接收到Wcs请求载具入库:{},ip地址:{}", convertJsonString(wcsVehicleInRequest), HttpUtils.getIpAddr(servletRequest));
|
||||||
// 创建响应信息
|
// 创建响应信息
|
||||||
ResponseEntity response = new ResponseEntity();
|
ResponseEntity response = new ResponseEntity();
|
||||||
|
|
@ -551,7 +553,8 @@ public class TaskController {
|
||||||
LambdaUpdateWrapper<Task> lambdaUpdateWrapperOfTask = new LambdaUpdateWrapper<Task>()
|
LambdaUpdateWrapper<Task> lambdaUpdateWrapperOfTask = new LambdaUpdateWrapper<Task>()
|
||||||
.set(Task::getDestination, nextLocationId)
|
.set(Task::getDestination, nextLocationId)
|
||||||
.set(Task::getTaskStatus, WmsTaskStatus.NEW.getCode())
|
.set(Task::getTaskStatus, WmsTaskStatus.NEW.getCode())
|
||||||
.eq(Task::getVehicleId, wcsVehicleInRequest.getVehicleNo());
|
.eq(Task::getVehicleId, wcsVehicleInRequest.getVehicleNo())
|
||||||
|
.eq(Task::getTaskStatus, WmsTaskStatus.TEMP.getCode());
|
||||||
if (!taskService.update(lambdaUpdateWrapperOfTask)) {
|
if (!taskService.update(lambdaUpdateWrapperOfTask)) {
|
||||||
// 回退库位锁定
|
// 回退库位锁定
|
||||||
locationService.update(new LambdaUpdateWrapper<Location>()
|
locationService.update(new LambdaUpdateWrapper<Location>()
|
||||||
|
|
@ -855,7 +858,7 @@ public class TaskController {
|
||||||
.eq(WorkFlow::getGoodsId, workQuery.getGoodsId())
|
.eq(WorkFlow::getGoodsId, workQuery.getGoodsId())
|
||||||
.eq(WorkFlow::getWorkStatus, 1)
|
.eq(WorkFlow::getWorkStatus, 1)
|
||||||
.ne(WorkFlow::getLightStatus, 2)
|
.ne(WorkFlow::getLightStatus, 2)
|
||||||
.apply("picked_num < needNum")
|
.apply("picked_num < need_num")
|
||||||
.orderByDesc(WorkFlow::getLightStatus));
|
.orderByDesc(WorkFlow::getLightStatus));
|
||||||
if (workFlows == null || workFlows.isEmpty()) {
|
if (workFlows == null || workFlows.isEmpty()) {
|
||||||
logger.error("当前站台当前物料查询不到对应的工作");
|
logger.error("当前站台当前物料查询不到对应的工作");
|
||||||
|
|
@ -919,9 +922,9 @@ public class TaskController {
|
||||||
StandPickVo standPickVo = new StandPickVo();
|
StandPickVo standPickVo = new StandPickVo();
|
||||||
standPickVo.setStandId(standId);
|
standPickVo.setStandId(standId);
|
||||||
standPickVo.setGoodsId(workQuery.getGoodsId());
|
standPickVo.setGoodsId(workQuery.getGoodsId());
|
||||||
standPickVo.setGoodsUnit(goodsInfo != null ? goodsInfo.getGoodsUnit() : "");
|
|
||||||
standPickVo.setPlanPickNum(originNum.subtract(realNum));
|
standPickVo.setPlanPickNum(originNum.subtract(realNum));
|
||||||
standPickVo.setActualDifference(BigDecimal.ZERO);
|
standPickVo.setRemainNumOrigin(realNum);
|
||||||
|
standPickVo.setRemainNumReal(realNum);
|
||||||
try {
|
try {
|
||||||
// 获取当前站台已完成数量
|
// 获取当前站台已完成数量
|
||||||
List<WorkFlow> allWorkFlows = workFlowService.list();
|
List<WorkFlow> allWorkFlows = workFlowService.list();
|
||||||
|
|
@ -971,7 +974,7 @@ public class TaskController {
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
@MyLog(logTitle = "获取电子标签反馈", logMethod = "getETaskFeedBack")
|
@MyLog(logTitle = "获取电子标签反馈", logMethod = "getETaskFeedBack")
|
||||||
public String getETaskFeedBack(@RequestBody WcsETaskFeedbackRequest eTaskFeedbackRequest) {
|
public String getETaskFeedBack(@RequestBody WcsETaskFeedbackRequest eTaskFeedbackRequest) {
|
||||||
logger.info("接收到获取备料工作信息请求:{},ip地址:{}", convertJsonString(eTaskFeedbackRequest), HttpUtils.getIpAddr(servletRequest));
|
logger.info("获取电子标签反馈:{},ip地址:{}", convertJsonString(eTaskFeedbackRequest), HttpUtils.getIpAddr(servletRequest));
|
||||||
ResponseEntity response = new ResponseEntity();
|
ResponseEntity response = new ResponseEntity();
|
||||||
try {
|
try {
|
||||||
if (eTaskFeedbackRequest == null || StringUtils.isEmpty(eTaskFeedbackRequest.getTaskId()) || eTaskFeedbackRequest.getTaskType() == null) {
|
if (eTaskFeedbackRequest == null || StringUtils.isEmpty(eTaskFeedbackRequest.getTaskId()) || eTaskFeedbackRequest.getTaskType() == null) {
|
||||||
|
|
@ -1003,8 +1006,23 @@ public class TaskController {
|
||||||
workFlow.setLightStatus(1);// 已亮灯
|
workFlow.setLightStatus(1);// 已亮灯
|
||||||
workFlow.setWorkStatus(1);// 正在做
|
workFlow.setWorkStatus(1);// 正在做
|
||||||
} else {
|
} else {
|
||||||
|
// TODO 继续向库存要料
|
||||||
|
// 当前物料当前站台需求数量
|
||||||
|
BigDecimal needNum = workFlow.getNeedNum().subtract(workFlow.getPickedNum());
|
||||||
|
// 判断当前物料是否在流转中
|
||||||
|
needNum = wmsTaskService.callGoods(workFlow.getGoodsId(), needNum, workFlow.getWorkStation());
|
||||||
|
// 判断此时需求数量是否为0
|
||||||
|
if (needNum.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
// 向库存请求
|
||||||
|
needNum = wmsTaskService.callStocks(workFlow.getGoodsId(), needNum, workFlow.getWorkStation());
|
||||||
|
}
|
||||||
|
if (needNum.compareTo(workFlow.getNeedNum().subtract(workFlow.getPickedNum())) == 0) {
|
||||||
workFlow.setLightStatus(2);// 已拍灯
|
workFlow.setLightStatus(2);// 已拍灯
|
||||||
workFlow.setWorkStatus(2);// 已完成
|
workFlow.setWorkStatus(2);// 正在做
|
||||||
|
} else {
|
||||||
|
workFlow.setLightStatus(1);// 已亮灯
|
||||||
|
workFlow.setWorkStatus(1);// 正在做
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
workFlow.setLightStatus(2);// 已拍灯
|
workFlow.setLightStatus(2);// 已拍灯
|
||||||
|
|
@ -1292,7 +1310,7 @@ public class TaskController {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 回滚事务
|
// 回滚事务
|
||||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
logger.error("Wcs请求释放箱子异常");
|
logger.error("Wcs请求释放箱子异常:{}", convertJsonString(e));
|
||||||
response.setCode(ResponseCode.ERROR.getCode());
|
response.setCode(ResponseCode.ERROR.getCode());
|
||||||
response.setMessage("Wcs请求释放箱子异常");
|
response.setMessage("Wcs请求释放箱子异常");
|
||||||
return convertJsonString(response);
|
return convertJsonString(response);
|
||||||
|
|
@ -1339,6 +1357,13 @@ public class TaskController {
|
||||||
try {
|
try {
|
||||||
// 获取当前站台已完成数量
|
// 获取当前站台已完成数量
|
||||||
List<WorkFlow> allWorkFlows = workFlowService.list();
|
List<WorkFlow> allWorkFlows = workFlowService.list();
|
||||||
|
if (allWorkFlows == null || allWorkFlows.isEmpty()) {
|
||||||
|
standPickFinishVo.setTip("当前站台没有工作");
|
||||||
|
standPickFinishVo.setPlanRows(0);
|
||||||
|
standPickFinishVo.setActualRows(0);
|
||||||
|
standPickFinishVo.setPlanCounts(BigDecimal.ZERO);
|
||||||
|
standPickFinishVo.setActualCounts(BigDecimal.ZERO);
|
||||||
|
} else {
|
||||||
int finishedRows = 0;
|
int finishedRows = 0;
|
||||||
BigDecimal finishedCounts = BigDecimal.ZERO;
|
BigDecimal finishedCounts = BigDecimal.ZERO;
|
||||||
BigDecimal planCounts = BigDecimal.ZERO;
|
BigDecimal planCounts = BigDecimal.ZERO;
|
||||||
|
|
@ -1363,6 +1388,7 @@ public class TaskController {
|
||||||
} else {
|
} else {
|
||||||
standPickFinishVo.setRemark("正常");
|
standPickFinishVo.setRemark("正常");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
response.setCode(ResponseCode.OK.getCode());
|
response.setCode(ResponseCode.OK.getCode());
|
||||||
response.setMessage("获取工作信息成功");
|
response.setMessage("获取工作信息成功");
|
||||||
response.setReturnData(standPickFinishVo);
|
response.setReturnData(standPickFinishVo);
|
||||||
|
|
@ -1547,7 +1573,7 @@ public class TaskController {
|
||||||
@PostMapping("/requestBack")
|
@PostMapping("/requestBack")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
@MyLog(logTitle = "呼叫空箱", logMethod = "requestBack")
|
@MyLog(logTitle = "Wcs请求箱子是否回库", logMethod = "requestBack")
|
||||||
public String requestBack(@RequestBody RequestBackQuery requestBackQuery) {
|
public String requestBack(@RequestBody RequestBackQuery requestBackQuery) {
|
||||||
logger.info("Wcs请求箱子是否回库:{},ip地址:{}", convertJsonString(requestBackQuery), HttpUtils.getIpAddr(servletRequest));
|
logger.info("Wcs请求箱子是否回库:{},ip地址:{}", convertJsonString(requestBackQuery), HttpUtils.getIpAddr(servletRequest));
|
||||||
ResponseEntity response = new ResponseEntity();
|
ResponseEntity response = new ResponseEntity();
|
||||||
|
|
@ -1567,21 +1593,56 @@ public class TaskController {
|
||||||
boolean hasBackTask = taskService.exists(new LambdaQueryWrapper<Task>()
|
boolean hasBackTask = taskService.exists(new LambdaQueryWrapper<Task>()
|
||||||
.eq(Task::getVehicleId, requestBackQuery.getVehicleId())
|
.eq(Task::getVehicleId, requestBackQuery.getVehicleId())
|
||||||
.eq(Task::getTaskType, TaskType.IN.getCode())
|
.eq(Task::getTaskType, TaskType.IN.getCode())
|
||||||
.likeLeft(Task::getTaskId, "HK"));
|
.likeRight(Task::getTaskId, "HK_"));
|
||||||
if (!hasBackTask) {
|
if (!hasBackTask) {
|
||||||
|
// 寻找库位
|
||||||
|
String nextLocationId = "";
|
||||||
|
for (int i = 0; i < locationService.count(new LambdaQueryWrapper<Location>().eq(Location::getLocationStatus, LocationStatus.EMPTY.getCode())); i++) {
|
||||||
|
Map<String, String> resultMap = locationService.getOneLocation("", "");
|
||||||
|
if (resultMap.isEmpty() || !resultMap.containsKey("nextLocationId")) {
|
||||||
|
logger.error("暂无可用库位");
|
||||||
|
response.setCode(ResponseCode.ERROR.getCode());
|
||||||
|
response.setMessage("暂无可用库位!");
|
||||||
|
return convertJsonString(response);
|
||||||
|
} else {
|
||||||
|
Location nextLocation = locationService.getOne(new LambdaQueryWrapper<Location>().eq(Location::getLocationId, resultMap.get("nextLocationId")));
|
||||||
|
LambdaUpdateWrapper<Location> updateLocationWrapper = new LambdaUpdateWrapper<Location>()
|
||||||
|
.set(Location::getLocationStatus, LocationStatus.OCCUPY.getCode())
|
||||||
|
.set(Location::getVehicleId, requestBackQuery.getVehicleId())
|
||||||
|
.eq(Location::getLocationId, nextLocation.getLocationId())
|
||||||
|
.eq(Location::getLocationStatus, LocationStatus.EMPTY.getCode());
|
||||||
|
if (locationService.update(updateLocationWrapper)) {
|
||||||
|
nextLocationId = resultMap.get("nextLocationId");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Objects.equals(nextLocationId, "")) {
|
||||||
|
logger.error("暂无可用库位");
|
||||||
|
response.setCode(ResponseCode.ERROR.getCode());
|
||||||
|
response.setMessage("暂无可用库位!");
|
||||||
|
return convertJsonString(response);
|
||||||
|
}
|
||||||
// 生成回库任务
|
// 生成回库任务
|
||||||
Task backTask = new Task();
|
Task backTask = new Task();
|
||||||
backTask.setTaskId(generateId("HK_"));
|
backTask.setTaskId(generateId("HK_"));
|
||||||
backTask.setTaskGroup(generateId(""));
|
backTask.setTaskGroup(generateId(""));
|
||||||
backTask.setTaskType(TaskType.IN.getCode());
|
backTask.setTaskType(TaskType.IN.getCode());
|
||||||
backTask.setTaskStatus(WmsTaskStatus.TEMP.getCode());
|
backTask.setTaskStatus(WmsTaskStatus.NEW.getCode());
|
||||||
backTask.setVehicleId(requestBackQuery.getVehicleId());
|
backTask.setVehicleId(requestBackQuery.getVehicleId());
|
||||||
|
backTask.setDestination(nextLocationId);
|
||||||
backTask.setVehicleSize(1);
|
backTask.setVehicleSize(1);
|
||||||
backTask.setWeight(BigDecimal.ZERO);
|
backTask.setWeight(BigDecimal.ZERO);
|
||||||
backTask.setTaskPriority(1);
|
backTask.setTaskPriority(1);
|
||||||
backTask.setUserName("WMS");
|
backTask.setUserName("WMS");
|
||||||
backTask.setCreateTime(LocalDateTime.now());
|
backTask.setCreateTime(LocalDateTime.now());
|
||||||
if (!taskService.save(backTask)) {
|
if (!taskService.save(backTask)) {
|
||||||
|
// 回退库位锁定
|
||||||
|
locationService.update(new LambdaUpdateWrapper<Location>()
|
||||||
|
.set(Location::getLocationStatus, LocationStatus.EMPTY.getCode())
|
||||||
|
.set(Location::getVehicleId, "")
|
||||||
|
.eq(Location::getLocationId, nextLocationId)
|
||||||
|
.eq(Location::getLocationStatus, LocationStatus.OCCUPY.getCode()));
|
||||||
logger.error("生成回库任务失败,箱号:{}", requestBackQuery.getVehicleId());
|
logger.error("生成回库任务失败,箱号:{}", requestBackQuery.getVehicleId());
|
||||||
response.setCode(ResponseCode.ERROR.getCode());
|
response.setCode(ResponseCode.ERROR.getCode());
|
||||||
response.setMessage("生成回库任务失败。");
|
response.setMessage("生成回库任务失败。");
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.wms.controller;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.wms.annotation.MyLog;
|
||||||
import com.wms.constants.enums.ResponseCode;
|
import com.wms.constants.enums.ResponseCode;
|
||||||
import com.wms.entity.app.dto.MenuDto;
|
import com.wms.entity.app.dto.MenuDto;
|
||||||
import com.wms.entity.app.dto.UserDto;
|
import com.wms.entity.app.dto.UserDto;
|
||||||
|
|
@ -10,9 +11,13 @@ import com.wms.entity.app.vo.MenuEntity;
|
||||||
import com.wms.entity.app.ResponseEntity;
|
import com.wms.entity.app.ResponseEntity;
|
||||||
import com.wms.entity.app.vo.UserConfigEntity;
|
import com.wms.entity.app.vo.UserConfigEntity;
|
||||||
import com.wms.service.MenuService;
|
import com.wms.service.MenuService;
|
||||||
|
import com.wms.service.StandService;
|
||||||
import com.wms.service.UserService;
|
import com.wms.service.UserService;
|
||||||
import com.wms.constants.WmsConstants;
|
import com.wms.constants.WmsConstants;
|
||||||
|
import com.wms.utils.HttpUtils;
|
||||||
import com.wms.utils.StringUtils;
|
import com.wms.utils.StringUtils;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -36,22 +41,25 @@ import static com.wms.utils.StringUtils.convertJsonString;
|
||||||
@Controller
|
@Controller
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@RequestMapping(value = "/wms/user")
|
@RequestMapping(value = "/wms/user")
|
||||||
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
public class UserController {
|
public class UserController {
|
||||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
/**
|
||||||
|
* 请求头部信息
|
||||||
|
*/
|
||||||
|
private final HttpServletRequest servletRequest;
|
||||||
/**
|
/**
|
||||||
* 用户服务
|
* 用户服务
|
||||||
*/
|
*/
|
||||||
final UserService userService;
|
private final UserService userService;
|
||||||
/**
|
/**
|
||||||
* 菜单服务
|
* 菜单服务
|
||||||
*/
|
*/
|
||||||
final MenuService menuService;
|
private final MenuService menuService;
|
||||||
|
/**
|
||||||
@Autowired
|
* 站台服务
|
||||||
public UserController(UserService userService, MenuService menuService) {
|
*/
|
||||||
this.userService = userService;
|
private final StandService standService;
|
||||||
this.menuService = menuService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 带密码登录
|
* 带密码登录
|
||||||
|
|
@ -61,8 +69,9 @@ public class UserController {
|
||||||
@PostMapping("/loginWithAuth")
|
@PostMapping("/loginWithAuth")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
|
@MyLog(logTitle = "带密码登录", logMethod = "loginWithAuth")
|
||||||
public String loginWithAuth(@RequestBody UserQuery userQuery) {
|
public String loginWithAuth(@RequestBody UserQuery userQuery) {
|
||||||
logger.info("请求登录,登录账户名:{}", userQuery.getLoginAccount());
|
logger.info("请求登录,登录账户名:{},登录ip:{}", userQuery.getLoginAccount(), HttpUtils.getIpAddr(servletRequest));
|
||||||
// 创建响应信息
|
// 创建响应信息
|
||||||
ResponseEntity rsp = new ResponseEntity();
|
ResponseEntity rsp = new ResponseEntity();
|
||||||
try {
|
try {
|
||||||
|
|
@ -88,7 +97,7 @@ public class UserController {
|
||||||
rsp.setCode(ResponseCode.OK.getCode());
|
rsp.setCode(ResponseCode.OK.getCode());
|
||||||
rsp.setMessage("登录成功");
|
rsp.setMessage("登录成功");
|
||||||
// 返回用户数据
|
// 返回用户数据
|
||||||
rsp.setReturnData(generateUserInfo(validatedUser));
|
rsp.setReturnData(generateUserInfo(validatedUser, HttpUtils.getIpAddr(servletRequest)));
|
||||||
return JSON.toJSONString(rsp);
|
return JSON.toJSONString(rsp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 回滚事务
|
// 回滚事务
|
||||||
|
|
@ -109,8 +118,9 @@ public class UserController {
|
||||||
@PostMapping("/loginWithoutAuth")
|
@PostMapping("/loginWithoutAuth")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||||
|
@MyLog(logTitle = "无密码登录", logMethod = "loginWithoutAuth")
|
||||||
public String loginWithoutAuth(@RequestBody UserQuery userQuery) {
|
public String loginWithoutAuth(@RequestBody UserQuery userQuery) {
|
||||||
logger.info("请求无密码登录,登录账户名:{}", userQuery.getLoginAccount());
|
logger.info("请求无密码登录,登录账户名:{},登录ip:{}", userQuery.getLoginAccount(), HttpUtils.getIpAddr(servletRequest));
|
||||||
// 创建响应信息
|
// 创建响应信息
|
||||||
ResponseEntity rsp = new ResponseEntity();
|
ResponseEntity rsp = new ResponseEntity();
|
||||||
try {
|
try {
|
||||||
|
|
@ -136,7 +146,7 @@ public class UserController {
|
||||||
rsp.setCode(ResponseCode.OK.getCode());
|
rsp.setCode(ResponseCode.OK.getCode());
|
||||||
rsp.setMessage("登录成功");
|
rsp.setMessage("登录成功");
|
||||||
// 返回用户数据
|
// 返回用户数据
|
||||||
rsp.setReturnData(generateUserInfo(validatedUser));
|
rsp.setReturnData(generateUserInfo(validatedUser, HttpUtils.getIpAddr(servletRequest)));
|
||||||
return JSON.toJSONString(rsp);
|
return JSON.toJSONString(rsp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 回滚事务
|
// 回滚事务
|
||||||
|
|
@ -152,9 +162,10 @@ public class UserController {
|
||||||
/**
|
/**
|
||||||
* 构造用户信息(菜单、按钮等权限)
|
* 构造用户信息(菜单、按钮等权限)
|
||||||
* @param currentUser 当前用户
|
* @param currentUser 当前用户
|
||||||
|
* @param ip ip地址
|
||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
private UserConfigEntity generateUserInfo (UserDto currentUser) {
|
private UserConfigEntity generateUserInfo (UserDto currentUser, String ip) {
|
||||||
UserConfigEntity userConfigEntity = new UserConfigEntity();
|
UserConfigEntity userConfigEntity = new UserConfigEntity();
|
||||||
try {
|
try {
|
||||||
if (currentUser.getRoleId() == null) {
|
if (currentUser.getRoleId() == null) {
|
||||||
|
|
@ -206,6 +217,7 @@ public class UserController {
|
||||||
// 设置返回信息
|
// 设置返回信息
|
||||||
userConfigEntity.setUser(BeanUtil.copyProperties(currentUser, UserDto.class));
|
userConfigEntity.setUser(BeanUtil.copyProperties(currentUser, UserDto.class));
|
||||||
userConfigEntity.setMenuList(menuList);
|
userConfigEntity.setMenuList(menuList);
|
||||||
|
userConfigEntity.setStandId(standService.getStandIdByIp(ip));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("构造用户信息失败,当前用户:{}", currentUser.getUserName());
|
logger.error("构造用户信息失败,当前用户:{}", currentUser.getUserName());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
45
src/main/java/com/wms/entity/app/request/ConfigQuery.java
Normal file
45
src/main/java/com/wms/entity/app/request/ConfigQuery.java
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.wms.entity.app.request;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置查询
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class ConfigQuery extends PageQuery {
|
||||||
|
/**
|
||||||
|
* 配置ID
|
||||||
|
*/
|
||||||
|
@JsonProperty("configId")
|
||||||
|
private Integer configId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置键
|
||||||
|
*/
|
||||||
|
@JsonProperty("configKey")
|
||||||
|
private String configKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置值
|
||||||
|
*/
|
||||||
|
@JsonProperty("configValue")
|
||||||
|
private String configValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置展示类型
|
||||||
|
*/
|
||||||
|
@JsonProperty("configType")
|
||||||
|
private String configType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置名称
|
||||||
|
*/
|
||||||
|
@JsonProperty("configName")
|
||||||
|
private String configName;
|
||||||
|
}
|
||||||
|
|
@ -20,49 +20,19 @@ public class WorkConfirmRequest {
|
||||||
*/
|
*/
|
||||||
@JsonProperty("goodsId")
|
@JsonProperty("goodsId")
|
||||||
private String goodsId;
|
private String goodsId;
|
||||||
/**
|
|
||||||
* 物料单位
|
|
||||||
*/
|
|
||||||
@JsonProperty("goodsUnit")
|
|
||||||
private String goodsUnit;
|
|
||||||
/**
|
/**
|
||||||
* 计划拣选数量
|
* 计划拣选数量
|
||||||
*/
|
*/
|
||||||
@JsonProperty("planPickNum")
|
@JsonProperty("planPickNum")
|
||||||
private BigDecimal planPickNum;
|
private BigDecimal planPickNum;
|
||||||
/**
|
/**
|
||||||
* 实际数量差异
|
* 理论剩余数量
|
||||||
*/
|
*/
|
||||||
@JsonProperty("actualDifference")
|
@JsonProperty("remainNumOrigin")
|
||||||
private BigDecimal actualDifference;
|
private BigDecimal remainNumOrigin;
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 实际剩余数量
|
||||||
*/
|
*/
|
||||||
@JsonProperty("remark")
|
@JsonProperty("remainNumReal")
|
||||||
private String remark;
|
private BigDecimal remainNumReal;
|
||||||
/**
|
|
||||||
* 已完成行数
|
|
||||||
*/
|
|
||||||
@JsonProperty("finishedRows")
|
|
||||||
private Integer finishedRows;
|
|
||||||
/**
|
|
||||||
* 总行数
|
|
||||||
*/
|
|
||||||
@JsonProperty("totalRows")
|
|
||||||
private Integer totalRows;
|
|
||||||
/**
|
|
||||||
* 已完成数量
|
|
||||||
*/
|
|
||||||
@JsonProperty("finishedCounts")
|
|
||||||
private BigDecimal finishedCounts;
|
|
||||||
/**
|
|
||||||
* 总数量
|
|
||||||
*/
|
|
||||||
@JsonProperty("totalCounts")
|
|
||||||
private BigDecimal totalCounts;
|
|
||||||
/**
|
|
||||||
* 提示
|
|
||||||
*/
|
|
||||||
@JsonProperty("tip")
|
|
||||||
private String tip;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,21 +20,21 @@ public class StandPickVo {
|
||||||
*/
|
*/
|
||||||
@JsonProperty("goodsId")
|
@JsonProperty("goodsId")
|
||||||
private String goodsId;
|
private String goodsId;
|
||||||
/**
|
|
||||||
* 物料单位
|
|
||||||
*/
|
|
||||||
@JsonProperty("goodsUnit")
|
|
||||||
private String goodsUnit;
|
|
||||||
/**
|
/**
|
||||||
* 计划拣选数量
|
* 计划拣选数量
|
||||||
*/
|
*/
|
||||||
@JsonProperty("planPickNum")
|
@JsonProperty("planPickNum")
|
||||||
private BigDecimal planPickNum;
|
private BigDecimal planPickNum;
|
||||||
/**
|
/**
|
||||||
* 实际数量差异
|
* 理论剩余数量
|
||||||
*/
|
*/
|
||||||
@JsonProperty("actualDifference")
|
@JsonProperty("remainNumOrigin")
|
||||||
private BigDecimal actualDifference;
|
private BigDecimal remainNumOrigin;
|
||||||
|
/**
|
||||||
|
* 实际剩余数量
|
||||||
|
*/
|
||||||
|
@JsonProperty("remainNumReal")
|
||||||
|
private BigDecimal remainNumReal;
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,29 @@
|
||||||
package com.wms.entity.app.vo;
|
package com.wms.entity.app.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.wms.entity.app.dto.UserDto;
|
import com.wms.entity.app.dto.UserDto;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
@ApiModel(value = "用户信息")
|
@ApiModel(value = "用户信息")
|
||||||
public class UserConfigEntity {
|
public class UserConfigEntity {
|
||||||
/**
|
/**
|
||||||
* 用户认证信息
|
* 用户认证信息
|
||||||
*/
|
*/
|
||||||
|
@JsonProperty("user")
|
||||||
private UserDto user;
|
private UserDto user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单及各种按钮信息
|
* 菜单及各种按钮信息
|
||||||
*/
|
*/
|
||||||
|
@JsonProperty("menuList")
|
||||||
private List<MenuEntity> menuList;
|
private List<MenuEntity> menuList;
|
||||||
|
/**
|
||||||
public UserDto getUser() {
|
* 对应站台号
|
||||||
return user;
|
*/
|
||||||
}
|
@JsonProperty("standId")
|
||||||
|
private String standId;
|
||||||
public void setUser(UserDto user) {
|
|
||||||
this.user = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<MenuEntity> getMenuList() {
|
|
||||||
return menuList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMenuList(List<MenuEntity> menuList) {
|
|
||||||
this.menuList = menuList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public class WcsDisposeVehicleRequest {
|
||||||
/**
|
/**
|
||||||
* 载具号
|
* 载具号
|
||||||
*/
|
*/
|
||||||
@JsonProperty("vehicleId")
|
@JsonProperty("vehicleNo")
|
||||||
private String vehicleId;
|
private String vehicleId;
|
||||||
|
|
||||||
public WcsDisposeVehicleRequest(String location, String vehicleId) {
|
public WcsDisposeVehicleRequest(String location, String vehicleId) {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ public class WcsETaskRequest {
|
||||||
/**
|
/**
|
||||||
* 任务类型
|
* 任务类型
|
||||||
*/
|
*/
|
||||||
@JsonProperty("taskGroup")
|
@JsonProperty("taskType")
|
||||||
private Integer taskType;
|
private Integer taskType;
|
||||||
/**
|
/**
|
||||||
* 载具号
|
* 载具号
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public class WcsTaskResultRequest {
|
||||||
/**
|
/**
|
||||||
* 载具号
|
* 载具号
|
||||||
*/
|
*/
|
||||||
@JsonProperty("vehicleId")
|
@JsonProperty("vehicleNo")
|
||||||
private String vehicleId;
|
private String vehicleId;
|
||||||
/**
|
/**
|
||||||
* 任务状态
|
* 任务状态
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,11 @@ public interface StandService extends IService<Stand> {
|
||||||
* @return 验证结果
|
* @return 验证结果
|
||||||
*/
|
*/
|
||||||
boolean validateStand(String standId, Integer taskType);
|
boolean validateStand(String standId, Integer taskType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ip地址获取站台号
|
||||||
|
* @param ip ip地址
|
||||||
|
* @return 站台号
|
||||||
|
*/
|
||||||
|
String getStandIdByIp(String ip);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ 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.Task;
|
import com.wms.entity.table.Task;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WMS任务服务接口
|
* WMS任务服务接口
|
||||||
*/
|
*/
|
||||||
|
|
@ -36,4 +38,8 @@ public interface IWmsTaskService {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
String genGoodsOutTask(TaskOutRequest taskOutRequest);
|
String genGoodsOutTask(TaskOutRequest taskOutRequest);
|
||||||
|
|
||||||
|
BigDecimal callGoods(String goodsId, BigDecimal needNum, String workStation);
|
||||||
|
|
||||||
|
BigDecimal callStocks(String goodsId, BigDecimal needNum, String workStation);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,8 @@ public class ValidateServiceImplements implements IValidateService {
|
||||||
// 判断当前载具号是否存在任务
|
// 判断当前载具号是否存在任务
|
||||||
LambdaQueryWrapper<Task> queryWrapper = new LambdaQueryWrapper<Task>()
|
LambdaQueryWrapper<Task> queryWrapper = new LambdaQueryWrapper<Task>()
|
||||||
.eq(Task::getVehicleId, wcsVehicleInRequest.getVehicleNo())
|
.eq(Task::getVehicleId, wcsVehicleInRequest.getVehicleNo())
|
||||||
.eq(Task::getTaskType, TaskType.IN.getCode());
|
.eq(Task::getTaskType, TaskType.IN.getCode())
|
||||||
|
.eq(Task::getTaskStatus, WmsTaskStatus.TEMP.getCode());
|
||||||
if (!taskService.exists(queryWrapper)) {
|
if (!taskService.exists(queryWrapper)) {
|
||||||
return "当前载具没有入库或回库任务";
|
return "当前载具没有入库或回库任务";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,8 @@ package com.wms.service.business.serviceImplements;
|
||||||
|
|
||||||
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.StockStatus;
|
import com.wms.constants.enums.*;
|
||||||
import com.wms.constants.enums.TaskType;
|
import com.wms.entity.app.dto.extend.StockDetailInfo;
|
||||||
import com.wms.constants.enums.VehicleStatus;
|
|
||||||
import com.wms.constants.enums.WmsTaskStatus;
|
|
||||||
import com.wms.entity.app.dto.extend.TaskDetailInfo;
|
import com.wms.entity.app.dto.extend.TaskDetailInfo;
|
||||||
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;
|
||||||
|
|
@ -41,6 +39,8 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
||||||
private final LocationService locationService;// 库位服务
|
private final LocationService locationService;// 库位服务
|
||||||
private final StockService stockService;// 库存服务
|
private final StockService stockService;// 库存服务
|
||||||
private final GoodsService goodsService;// 物料服务
|
private final GoodsService goodsService;// 物料服务
|
||||||
|
private final OutsideVehiclesService outsideVehiclesService;// 流转中的箱子服务
|
||||||
|
private final PickTaskService pickTaskService;// 拣选任务服务
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -296,4 +296,179 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal callGoods(String goodsId, BigDecimal needNum, String workStation) {
|
||||||
|
// 判断当前物料是否在流转中
|
||||||
|
List<OutsideVehicles> outsideVehiclesList = outsideVehiclesService.list(new LambdaQueryWrapper<OutsideVehicles>()
|
||||||
|
.eq(OutsideVehicles::getGoodsId, goodsId)
|
||||||
|
.gt(OutsideVehicles::getRemainNum, 0));
|
||||||
|
List<OutsideVehicles> usedOutsideVehiclesList = new ArrayList<>();
|
||||||
|
if (outsideVehiclesList != null && !outsideVehiclesList.isEmpty()) {
|
||||||
|
// 存在流转中的料箱
|
||||||
|
for (OutsideVehicles outsideVehicle : outsideVehiclesList) {
|
||||||
|
if (needNum.compareTo(BigDecimal.ZERO) <= 0) {// 需求数量小于等于0
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (outsideVehicle.getRemainNum().compareTo(needNum) > 0) {
|
||||||
|
// 当前箱子剩余物料数量多于需求数量
|
||||||
|
needNum = BigDecimal.ZERO;
|
||||||
|
outsideVehicle.setRemainNum(outsideVehicle.getRemainNum().subtract(needNum));
|
||||||
|
usedOutsideVehiclesList.add(outsideVehicle);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
// 当前箱子物料剩余数量少于需求数量
|
||||||
|
needNum = needNum.subtract(outsideVehicle.getRemainNum());
|
||||||
|
outsideVehicle.setRemainNum(BigDecimal.ZERO);
|
||||||
|
usedOutsideVehiclesList.add(outsideVehicle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 更新流转箱表
|
||||||
|
outsideVehiclesService.updateBatchById(usedOutsideVehiclesList);
|
||||||
|
// 生成拣选任务
|
||||||
|
List<String> vehicleIds = usedOutsideVehiclesList.stream().map(OutsideVehicles::getVehicleId).toList();
|
||||||
|
createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.NEW.getCode());
|
||||||
|
}
|
||||||
|
return needNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal callStocks(String goodsId, BigDecimal needNum, String workStation) {
|
||||||
|
// 查询库存,判断数量是否充足
|
||||||
|
List<Stock> stockList = stockService.list(new LambdaQueryWrapper<Stock>()
|
||||||
|
.eq(Stock::getStockStatus, StockStatus.OK.getCode())
|
||||||
|
.apply("goods_related ->> '$.goodsId' = {0}", goodsId));
|
||||||
|
if (stockList != null && !stockList.isEmpty()) {
|
||||||
|
List<Stock> waitForOutStockList = new ArrayList<>();
|
||||||
|
// 尝试生成出库任务
|
||||||
|
for (Stock tempStock : stockList) {
|
||||||
|
if (needNum.compareTo(BigDecimal.ZERO) <= 0) {// 需求数量小于等于0
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (tempStock.getGoodsRelated().getRemainNum().compareTo(needNum) > 0) {
|
||||||
|
// 当前箱子剩余物料数量多于需求数量
|
||||||
|
needNum = BigDecimal.ZERO;
|
||||||
|
// 设置剩余数量
|
||||||
|
StockDetailInfo goodsRelated = tempStock.getGoodsRelated();
|
||||||
|
goodsRelated.setRemainNum(goodsRelated.getRemainNum().subtract(needNum));
|
||||||
|
tempStock.setGoodsRelated(goodsRelated);
|
||||||
|
waitForOutStockList.add(tempStock);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
// 当前箱子物料剩余数量少于需求数量
|
||||||
|
needNum = needNum.subtract(tempStock.getGoodsRelated().getRemainNum());
|
||||||
|
// 设置剩余数量
|
||||||
|
StockDetailInfo goodsRelated = tempStock.getGoodsRelated();
|
||||||
|
goodsRelated.setRemainNum(BigDecimal.ZERO);
|
||||||
|
tempStock.setGoodsRelated(goodsRelated);
|
||||||
|
waitForOutStockList.add(tempStock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createVehicleOutTaskAndPickTask(waitForOutStockList, workStation);
|
||||||
|
}
|
||||||
|
return needNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成出库任务,同时生成拣选任务
|
||||||
|
*
|
||||||
|
* @param waitForOutStocks 待出库库存
|
||||||
|
*/
|
||||||
|
private void createVehicleOutTaskAndPickTask(List<Stock> waitForOutStocks, String workStation) {
|
||||||
|
// 出库任务列表
|
||||||
|
List<Task> outTasks = new ArrayList<>();
|
||||||
|
// 流转载具列表
|
||||||
|
List<OutsideVehicles> outsideVehicles = new ArrayList<>();
|
||||||
|
// 载具列表
|
||||||
|
List<String> vehicleIds = new ArrayList<>();
|
||||||
|
for (Stock tempStock : waitForOutStocks) {
|
||||||
|
if (vehicleIds.contains(tempStock.getVehicleId())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 创建出库任务
|
||||||
|
Task tempOutTask = new Task();
|
||||||
|
tempOutTask.setTaskId(generateId("CK_"));
|
||||||
|
tempOutTask.setTaskType(TaskType.OUT.getCode());
|
||||||
|
tempOutTask.setTaskGroup(generateId(""));
|
||||||
|
tempOutTask.setTaskStatus(WmsTaskStatus.NEW.getCode());
|
||||||
|
tempOutTask.setTaskPriority(1);
|
||||||
|
tempOutTask.setVehicleId(tempStock.getVehicleId());
|
||||||
|
tempOutTask.setUserName("WMS_AUTO");
|
||||||
|
tempOutTask.setOrigin(tempStock.getLocationId());
|
||||||
|
tempOutTask.setDestination("");
|
||||||
|
tempOutTask.setCreateTime(LocalDateTime.now());
|
||||||
|
tempOutTask.setIsPicking(1);
|
||||||
|
outTasks.add(tempOutTask);
|
||||||
|
// 添加载具列表
|
||||||
|
vehicleIds.add(tempStock.getVehicleId());
|
||||||
|
// 添加流转箱数据
|
||||||
|
OutsideVehicles outsideVehicle = new OutsideVehicles();
|
||||||
|
outsideVehicle.setOutsideId(generateId("OUTSIDE_"));
|
||||||
|
outsideVehicle.setVehicleId(tempStock.getVehicleId());
|
||||||
|
outsideVehicle.setGoodsId(tempStock.getGoodsRelated().getGoodsId());
|
||||||
|
outsideVehicle.setRemainNum(tempStock.getGoodsRelated().getRemainNum());
|
||||||
|
outsideVehicles.add(outsideVehicle);
|
||||||
|
}
|
||||||
|
for (String vehicleId : vehicleIds) {
|
||||||
|
// 查询到对应的库存信息
|
||||||
|
List<Stock> vehicleStocks = stockService.list(new LambdaQueryWrapper<Stock>()
|
||||||
|
.eq(Stock::getVehicleId, vehicleId)
|
||||||
|
.eq(Stock::getStockStatus, 0));
|
||||||
|
for (Stock vehicleStock : vehicleStocks) {
|
||||||
|
if (outsideVehicles.stream().anyMatch(outsideVehicle -> outsideVehicle.getVehicleId().equals(vehicleStock.getVehicleId()) && outsideVehicle.getGoodsId().equals(vehicleStock.getGoodsRelated().getGoodsId()))) {
|
||||||
|
// 已经生成过
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 添加流转箱数据
|
||||||
|
OutsideVehicles outsideVehicle = new OutsideVehicles();
|
||||||
|
outsideVehicle.setOutsideId(generateId("OUTSIDE_"));
|
||||||
|
outsideVehicle.setVehicleId(vehicleStock.getVehicleId());
|
||||||
|
outsideVehicle.setGoodsId(vehicleStock.getGoodsRelated().getGoodsId());
|
||||||
|
outsideVehicle.setRemainNum(vehicleStock.getGoodsRelated().getRemainNum());
|
||||||
|
outsideVehicles.add(outsideVehicle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 保存出库任务至任务表
|
||||||
|
taskService.saveBatch(outTasks);
|
||||||
|
// 更新载具信息
|
||||||
|
vehicleService.update(new LambdaUpdateWrapper<Vehicle>()
|
||||||
|
.set(Vehicle::getVehicleStatus, VehicleStatus.OUT.getCode())
|
||||||
|
.in(Vehicle::getVehicleId, vehicleIds)
|
||||||
|
.eq(Vehicle::getVehicleStatus, VehicleStatus.ON.getCode()));
|
||||||
|
// 更新库存信息
|
||||||
|
stockService.update(new LambdaUpdateWrapper<Stock>()
|
||||||
|
.set(Stock::getStockStatus, StockStatus.OUT.getCode())
|
||||||
|
.in(Stock::getVehicleId, vehicleIds)
|
||||||
|
.eq(Stock::getStockStatus, StockStatus.OK.getCode()));
|
||||||
|
// 保存流转箱信息
|
||||||
|
outsideVehiclesService.saveBatch(outsideVehicles);
|
||||||
|
// 保存拣选任务至拣选任务表
|
||||||
|
createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.TEMP.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成拣选任务
|
||||||
|
*
|
||||||
|
* @param vehicleIds 载具列表
|
||||||
|
* @param workStation 工作站台
|
||||||
|
* @param pickStatus 任务状态:只接受-1、0。-1:暂存不发送,0:可发送
|
||||||
|
*/
|
||||||
|
public void createPickTasks(List<String> vehicleIds, String workStation, Integer pickStatus) {
|
||||||
|
if (!Objects.equals(pickStatus, PickTaskStatusEnum.TEMP.getCode()) && !Objects.equals(pickStatus, PickTaskStatusEnum.NEW.getCode())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 拣选任务暂存列表
|
||||||
|
List<PickTask> pickTasks = new ArrayList<>();
|
||||||
|
vehicleIds.forEach(vehicleId -> {
|
||||||
|
// 暂存拣选任务
|
||||||
|
PickTask tempPickTask = new PickTask();
|
||||||
|
tempPickTask.setPickTaskId(generateId("PICK_"));
|
||||||
|
tempPickTask.setVehicleId(vehicleId);
|
||||||
|
tempPickTask.setStandId(workStation);
|
||||||
|
tempPickTask.setPickStatus(pickStatus);
|
||||||
|
tempPickTask.setLastUpdateTime(LocalDateTime.now());
|
||||||
|
pickTasks.add(tempPickTask);
|
||||||
|
});
|
||||||
|
// 添加数据库
|
||||||
|
pickTaskService.saveBatch(pickTasks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,10 @@ package com.wms.service.business.serviceImplements;
|
||||||
|
|
||||||
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.entity.app.dto.WorkCenterAndOrderDto;
|
import com.wms.entity.app.dto.WorkCenterAndOrderDto;
|
||||||
import com.wms.entity.app.dto.extend.StockDetailInfo;
|
|
||||||
import com.wms.entity.table.*;
|
import com.wms.entity.table.*;
|
||||||
import com.wms.service.*;
|
import com.wms.service.*;
|
||||||
|
import com.wms.service.business.IWmsTaskService;
|
||||||
import com.wms.service.business.IWorkService;
|
import com.wms.service.business.IWorkService;
|
||||||
import com.wms.utils.StringUtils;
|
import com.wms.utils.StringUtils;
|
||||||
import com.wms.utils.WmsUtils;
|
import com.wms.utils.WmsUtils;
|
||||||
|
|
@ -19,7 +18,6 @@ import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static com.wms.config.InitLocalConfig.configMap;
|
import static com.wms.config.InitLocalConfig.configMap;
|
||||||
import static com.wms.utils.WmsUtils.generateId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工作服务接口的实现
|
* 工作服务接口的实现
|
||||||
|
|
@ -35,12 +33,9 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
private final ELocationConfigService eLocationConfigService;// 电子标签配置服务
|
private final ELocationConfigService eLocationConfigService;// 电子标签配置服务
|
||||||
private final GoodsToStationService goodsToStationService;// 站台要料服务
|
private final GoodsToStationService goodsToStationService;// 站台要料服务
|
||||||
private final OutsideVehiclesService outsideVehiclesService;// 流转中的箱子服务
|
private final OutsideVehiclesService outsideVehiclesService;// 流转中的箱子服务
|
||||||
private final StockService stockService;// 库存服务
|
|
||||||
private final TaskService taskService;// 任务服务
|
|
||||||
private final PickTaskService pickTaskService;// 拣选任务服务
|
|
||||||
private final VehicleService vehicleService;// 载具服务
|
|
||||||
private final WorkSummaryService workSummaryService;// 工作总结服务
|
private final WorkSummaryService workSummaryService;// 工作总结服务
|
||||||
private final ELocationConfigLastService eLocationConfigLastService;// 上一次标签配置的服务
|
private final ELocationConfigLastService eLocationConfigLastService;// 上一次标签配置的服务
|
||||||
|
private final IWmsTaskService wmsTaskService;
|
||||||
private final List<String> workCreatingStations = new ArrayList<>();// 当前正在创建任务的站台
|
private final List<String> workCreatingStations = new ArrayList<>();// 当前正在创建任务的站台
|
||||||
private final List<String> workDoingStations = new ArrayList<>();// 当前正在执行任务的站台
|
private final List<String> workDoingStations = new ArrayList<>();// 当前正在执行任务的站台
|
||||||
private final List<String> workFinishingStations = new ArrayList<>();// 当前正在完成任务的站台
|
private final List<String> workFinishingStations = new ArrayList<>();// 当前正在完成任务的站台
|
||||||
|
|
@ -110,6 +105,7 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
goodsToStation.setGoodsId(goodsId);
|
goodsToStation.setGoodsId(goodsId);
|
||||||
goodsToStation.setWorkStation(workStation);
|
goodsToStation.setWorkStation(workStation);
|
||||||
goodsToStation.setDistributeStatus(0);
|
goodsToStation.setDistributeStatus(0);
|
||||||
|
goodsToStation.setDistributedNum(BigDecimal.ZERO);
|
||||||
goodsToStation.setTotalNum(needGoodsMap.get(goodsId));
|
goodsToStation.setTotalNum(needGoodsMap.get(goodsId));
|
||||||
goodsToStationList.add(goodsToStation);
|
goodsToStationList.add(goodsToStation);
|
||||||
}
|
}
|
||||||
|
|
@ -189,72 +185,13 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
// 当前物料当前站台需求数量
|
// 当前物料当前站台需求数量
|
||||||
BigDecimal needNum = goodsToStation.getTotalNum().subtract(goodsToStation.getDistributedNum());
|
BigDecimal needNum = goodsToStation.getTotalNum().subtract(goodsToStation.getDistributedNum());
|
||||||
// 判断当前物料是否在流转中
|
// 判断当前物料是否在流转中
|
||||||
List<OutsideVehicles> outsideVehiclesList = outsideVehiclesService.list(new LambdaQueryWrapper<OutsideVehicles>()
|
needNum = wmsTaskService.callGoods(goodsToStation.getGoodsId(), needNum, workStation);
|
||||||
.eq(OutsideVehicles::getGoodsId, goodsToStation.getGoodsId())
|
|
||||||
.gt(OutsideVehicles::getRemainNum, 0));
|
|
||||||
List<OutsideVehicles> usedOutsideVehiclesList = new ArrayList<>();
|
|
||||||
if (outsideVehiclesList != null && !outsideVehiclesList.isEmpty()) {
|
|
||||||
// 存在流转中的料箱
|
|
||||||
for (OutsideVehicles outsideVehicle : outsideVehiclesList) {
|
|
||||||
if (needNum.compareTo(BigDecimal.ZERO) <= 0) {// 需求数量小于等于0
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (outsideVehicle.getRemainNum().compareTo(needNum) > 0) {
|
|
||||||
// 当前箱子剩余物料数量多于需求数量
|
|
||||||
needNum = BigDecimal.ZERO;
|
|
||||||
outsideVehicle.setRemainNum(outsideVehicle.getRemainNum().subtract(needNum));
|
|
||||||
usedOutsideVehiclesList.add(outsideVehicle);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
// 当前箱子物料剩余数量少于需求数量
|
|
||||||
needNum = needNum.subtract(outsideVehicle.getRemainNum());
|
|
||||||
outsideVehicle.setRemainNum(BigDecimal.ZERO);
|
|
||||||
usedOutsideVehiclesList.add(outsideVehicle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 更新流转箱表
|
|
||||||
outsideVehiclesService.updateBatchById(usedOutsideVehiclesList);
|
|
||||||
// 生成拣选任务
|
|
||||||
List<String> vehicleIds = usedOutsideVehiclesList.stream().map(OutsideVehicles::getVehicleId).toList();
|
|
||||||
createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.NEW.getCode());
|
|
||||||
}
|
|
||||||
// 判断此时需求数量是否为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);
|
||||||
List<Stock> stockList = stockService.list(new LambdaQueryWrapper<Stock>()
|
|
||||||
.eq(Stock::getStockStatus, StockStatus.OK.getCode())
|
|
||||||
.apply("goods_related ->> '$.goodsId' = {0}", goodsToStation.getGoodsId()));
|
|
||||||
if (stockList != null && !stockList.isEmpty()) {
|
|
||||||
List<Stock> waitForOutStockList = new ArrayList<>();
|
|
||||||
// 尝试生成出库任务
|
|
||||||
for (Stock tempStock : stockList) {
|
|
||||||
if (needNum.compareTo(BigDecimal.ZERO) <= 0) {// 需求数量小于等于0
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (tempStock.getGoodsRelated().getRemainNum().compareTo(needNum) > 0) {
|
|
||||||
// 当前箱子剩余物料数量多于需求数量
|
|
||||||
needNum = BigDecimal.ZERO;
|
|
||||||
// 设置剩余数量
|
|
||||||
StockDetailInfo goodsRelated = tempStock.getGoodsRelated();
|
|
||||||
goodsRelated.setRemainNum(goodsRelated.getRemainNum().subtract(needNum));
|
|
||||||
tempStock.setGoodsRelated(goodsRelated);
|
|
||||||
waitForOutStockList.add(tempStock);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
// 当前箱子物料剩余数量少于需求数量
|
|
||||||
needNum = needNum.subtract(tempStock.getGoodsRelated().getRemainNum());
|
|
||||||
// 设置剩余数量
|
|
||||||
StockDetailInfo goodsRelated = tempStock.getGoodsRelated();
|
|
||||||
goodsRelated.setRemainNum(BigDecimal.ZERO);
|
|
||||||
tempStock.setGoodsRelated(goodsRelated);
|
|
||||||
waitForOutStockList.add(tempStock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
createVehicleOutTaskAndPickTask(waitForOutStockList, workStation);
|
|
||||||
}
|
|
||||||
if (needNum.compareTo(BigDecimal.ZERO) > 0) {
|
if (needNum.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
// 分配完成但库存缺料
|
// 分配完成但库存缺料
|
||||||
goodsToStation.setDistributeStatus(3);
|
goodsToStation.setDistributeStatus(3);
|
||||||
|
|
@ -412,7 +349,7 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
}
|
}
|
||||||
for (KateOrders kateWorkOrder : kateWorkOrders) {
|
for (KateOrders kateWorkOrder : kateWorkOrders) {
|
||||||
KateDBS kateDBS;
|
KateDBS kateDBS;
|
||||||
if (!ordersAndDBSMap.containsKey(kateWorkOrder.getWorkOrder())) {
|
if (ordersAndDBSMap.containsKey(kateWorkOrder.getWorkOrder())) {
|
||||||
kateDBS = ordersAndDBSMap.get(kateWorkOrder.getWorkOrder());
|
kateDBS = ordersAndDBSMap.get(kateWorkOrder.getWorkOrder());
|
||||||
} else {
|
} else {
|
||||||
// 从DBS表查询对应的工单以及开工时间
|
// 从DBS表查询对应的工单以及开工时间
|
||||||
|
|
@ -467,108 +404,4 @@ public class WorkServiceImplements implements IWorkService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成出库任务,同时生成拣选任务
|
|
||||||
*
|
|
||||||
* @param waitForOutStocks 待出库库存
|
|
||||||
*/
|
|
||||||
private void createVehicleOutTaskAndPickTask(List<Stock> waitForOutStocks, String workStation) {
|
|
||||||
// 出库任务列表
|
|
||||||
List<Task> outTasks = new ArrayList<>();
|
|
||||||
// 流转载具列表
|
|
||||||
List<OutsideVehicles> outsideVehicles = new ArrayList<>();
|
|
||||||
// 载具列表
|
|
||||||
List<String> vehicleIds = new ArrayList<>();
|
|
||||||
for (Stock tempStock : waitForOutStocks) {
|
|
||||||
if (vehicleIds.contains(tempStock.getVehicleId())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// 创建出库任务
|
|
||||||
Task tempOutTask = new Task();
|
|
||||||
tempOutTask.setTaskId(generateId("CK_"));
|
|
||||||
tempOutTask.setTaskType(TaskType.OUT.getCode());
|
|
||||||
tempOutTask.setTaskGroup(generateId(""));
|
|
||||||
tempOutTask.setTaskStatus(WmsTaskStatus.NEW.getCode());
|
|
||||||
tempOutTask.setTaskPriority(1);
|
|
||||||
tempOutTask.setVehicleId(tempStock.getVehicleId());
|
|
||||||
tempOutTask.setUserName("WMS_AUTO");
|
|
||||||
tempOutTask.setOrigin(tempStock.getLocationId());
|
|
||||||
tempOutTask.setDestination("");
|
|
||||||
tempOutTask.setCreateTime(LocalDateTime.now());
|
|
||||||
tempOutTask.setIsPicking(1);
|
|
||||||
outTasks.add(tempOutTask);
|
|
||||||
// 添加载具列表
|
|
||||||
vehicleIds.add(tempStock.getVehicleId());
|
|
||||||
// 添加流转箱数据
|
|
||||||
OutsideVehicles outsideVehicle = new OutsideVehicles();
|
|
||||||
outsideVehicle.setOutsideId(generateId("OUTSIDE_"));
|
|
||||||
outsideVehicle.setVehicleId(tempStock.getVehicleId());
|
|
||||||
outsideVehicle.setGoodsId(tempStock.getGoodsRelated().getGoodsId());
|
|
||||||
outsideVehicle.setRemainNum(tempStock.getGoodsRelated().getRemainNum());
|
|
||||||
outsideVehicles.add(outsideVehicle);
|
|
||||||
}
|
|
||||||
for (String vehicleId : vehicleIds) {
|
|
||||||
// 查询到对应的库存信息
|
|
||||||
List<Stock> vehicleStocks = stockService.list(new LambdaQueryWrapper<Stock>()
|
|
||||||
.eq(Stock::getVehicleId, vehicleId)
|
|
||||||
.eq(Stock::getStockStatus, 0));
|
|
||||||
for (Stock vehicleStock : vehicleStocks) {
|
|
||||||
if (outsideVehicles.stream().anyMatch(outsideVehicle -> outsideVehicle.getVehicleId().equals(vehicleStock.getVehicleId()) && outsideVehicle.getGoodsId().equals(vehicleStock.getGoodsRelated().getGoodsId()))) {
|
|
||||||
// 已经生成过
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// 添加流转箱数据
|
|
||||||
OutsideVehicles outsideVehicle = new OutsideVehicles();
|
|
||||||
outsideVehicle.setOutsideId(generateId("OUTSIDE_"));
|
|
||||||
outsideVehicle.setVehicleId(vehicleStock.getVehicleId());
|
|
||||||
outsideVehicle.setGoodsId(vehicleStock.getGoodsRelated().getGoodsId());
|
|
||||||
outsideVehicle.setRemainNum(vehicleStock.getGoodsRelated().getRemainNum());
|
|
||||||
outsideVehicles.add(outsideVehicle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 保存出库任务至任务表
|
|
||||||
taskService.saveBatch(outTasks);
|
|
||||||
// 更新载具信息
|
|
||||||
vehicleService.update(new LambdaUpdateWrapper<Vehicle>()
|
|
||||||
.set(Vehicle::getVehicleStatus, VehicleStatus.OUT.getCode())
|
|
||||||
.in(Vehicle::getVehicleId, vehicleIds)
|
|
||||||
.eq(Vehicle::getVehicleStatus, VehicleStatus.ON.getCode()));
|
|
||||||
// 更新库存信息
|
|
||||||
stockService.update(new LambdaUpdateWrapper<Stock>()
|
|
||||||
.set(Stock::getStockStatus, StockStatus.OUT.getCode())
|
|
||||||
.in(Stock::getVehicleId, vehicleIds)
|
|
||||||
.eq(Stock::getStockStatus, StockStatus.OK.getCode()));
|
|
||||||
// 保存流转箱信息
|
|
||||||
outsideVehiclesService.saveBatch(outsideVehicles);
|
|
||||||
// 保存拣选任务至拣选任务表
|
|
||||||
createPickTasks(vehicleIds, workStation, PickTaskStatusEnum.TEMP.getCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成拣选任务
|
|
||||||
*
|
|
||||||
* @param vehicleIds 载具列表
|
|
||||||
* @param workStation 工作站台
|
|
||||||
* @param pickStatus 任务状态:只接受-1、0。-1:暂存不发送,0:可发送
|
|
||||||
*/
|
|
||||||
private void createPickTasks(List<String> vehicleIds, String workStation, Integer pickStatus) {
|
|
||||||
if (!Objects.equals(pickStatus, PickTaskStatusEnum.TEMP.getCode()) && !Objects.equals(pickStatus, PickTaskStatusEnum.NEW.getCode())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 拣选任务暂存列表
|
|
||||||
List<PickTask> pickTasks = new ArrayList<>();
|
|
||||||
vehicleIds.forEach(vehicleId -> {
|
|
||||||
// 暂存拣选任务
|
|
||||||
PickTask tempPickTask = new PickTask();
|
|
||||||
tempPickTask.setPickTaskId(generateId("PICK_"));
|
|
||||||
tempPickTask.setVehicleId(vehicleId);
|
|
||||||
tempPickTask.setStandId(workStation);
|
|
||||||
tempPickTask.setPickStatus(pickStatus);
|
|
||||||
tempPickTask.setLastUpdateTime(LocalDateTime.now());
|
|
||||||
pickTasks.add(tempPickTask);
|
|
||||||
});
|
|
||||||
// 添加数据库
|
|
||||||
pickTaskService.saveBatch(pickTasks);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,4 +43,18 @@ public class StandServiceImplements extends ServiceImpl<StandMapper, Stand> impl
|
||||||
}
|
}
|
||||||
return standMapper.exists(lambdaQueryWrapper);
|
return standMapper.exists(lambdaQueryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ip地址获取站台号
|
||||||
|
* @param ip ip地址
|
||||||
|
* @return 站台id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getStandIdByIp(String ip) {
|
||||||
|
if (StringUtils.isEmpty(ip)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
Stand stand = standMapper.selectOne(new LambdaQueryWrapper<Stand>().eq(Stand::getStandIp, ip));
|
||||||
|
return stand != null ? stand.getStandId() : "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user