代码更新:

1. 修复备料错误
2. 增加堆垛机可用性变更
This commit is contained in:
梁州 2024-08-29 19:15:03 +08:00
parent 91d224b18c
commit 0cc57c91b8
13 changed files with 339 additions and 121 deletions

View File

@ -14,7 +14,6 @@ import com.wms.entity.app.dto.StockOfGoodsDto;
import com.wms.entity.app.dto.extend.KanbanEntity; import com.wms.entity.app.dto.extend.KanbanEntity;
import com.wms.entity.app.request.*; import com.wms.entity.app.request.*;
import com.wms.entity.app.vo.FileVo; import com.wms.entity.app.vo.FileVo;
import com.wms.entity.app.vo.LocationVo;
import com.wms.entity.app.vo.UploadRecordVo; import com.wms.entity.app.vo.UploadRecordVo;
import com.wms.entity.table.*; import com.wms.entity.table.*;
import com.wms.service.*; import com.wms.service.*;
@ -314,7 +313,6 @@ public class ExcelController {
HorizontalCellStyleStrategy horizontalCellStyleStrategy = ExcelContentStyle.getContentStyle(); HorizontalCellStyleStrategy horizontalCellStyleStrategy = ExcelContentStyle.getContentStyle();
// 获取导出结果 // 获取导出结果
List<ClcKanbanRequirementExcelVo> clcKanbanRequirementExcelVoList = new ArrayList<>(); List<ClcKanbanRequirementExcelVo> clcKanbanRequirementExcelVoList = new ArrayList<>();
// TODO 需要处理获得数据
// 查询物料库存信息 // 查询物料库存信息
List<StockOfGoodsDto> stockOfGoodsDtoList = stockService.selectSumOfGoods(""); List<StockOfGoodsDto> stockOfGoodsDtoList = stockService.selectSumOfGoods("");
if (stockOfGoodsDtoList == null || stockOfGoodsDtoList.isEmpty()) { if (stockOfGoodsDtoList == null || stockOfGoodsDtoList.isEmpty()) {

View File

@ -241,7 +241,7 @@ public class LocationController {
try { try {
List<ETagLocation> eLocations = new ArrayList<>(); List<ETagLocation> eLocations = new ArrayList<>();
for (int i = 1; i <= 9; i++) { for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 48; j++) { for (int j = 1; j <= 96; j++) {
ETagLocation eTagLocation = new ETagLocation(); ETagLocation eTagLocation = new ETagLocation();
eTagLocation.setELocationId(i + "-" + StringUtils.padLeft(String.valueOf(j), 2, "0")); eTagLocation.setELocationId(i + "-" + StringUtils.padLeft(String.valueOf(j), 2, "0"));
eTagLocation.setAreaId(String.valueOf(i)); eTagLocation.setAreaId(String.valueOf(i));
@ -287,7 +287,8 @@ public class LocationController {
Page<Vehicle> vehiclePage = vehicleService.page(page, new LambdaQueryWrapper<Vehicle>() Page<Vehicle> vehiclePage = vehicleService.page(page, new LambdaQueryWrapper<Vehicle>()
.like(StringUtils.isNotEmpty(vehicleQuery.getVehicleId()), Vehicle::getVehicleId, vehicleQuery.getVehicleId()) .like(StringUtils.isNotEmpty(vehicleQuery.getVehicleId()), Vehicle::getVehicleId, vehicleQuery.getVehicleId())
.eq(vehicleQuery.getVehicleStatus() != null, Vehicle::getVehicleStatus, vehicleQuery.getVehicleStatus()) .eq(vehicleQuery.getVehicleStatus() != null, Vehicle::getVehicleStatus, vehicleQuery.getVehicleStatus())
.eq(vehicleQuery.getIsEmpty() != null, Vehicle::getIsEmpty, vehicleQuery.getIsEmpty())); .eq(vehicleQuery.getIsEmpty() != null, Vehicle::getIsEmpty, vehicleQuery.getIsEmpty())
.orderByDesc(Vehicle::getLastInTime));
PageDto<VehicleVO> pageDto = PageDto.of(vehiclePage, vehicle -> BeanUtil.copyProperties(vehicle, VehicleVO.class)); PageDto<VehicleVO> pageDto = PageDto.of(vehiclePage, vehicle -> BeanUtil.copyProperties(vehicle, VehicleVO.class));
response.setCode(ResponseCode.OK.getCode()); response.setCode(ResponseCode.OK.getCode());

View File

@ -11,6 +11,7 @@ import com.wms.entity.app.dto.PageDto;
import com.wms.entity.app.dto.StandDto; import com.wms.entity.app.dto.StandDto;
import com.wms.entity.app.request.StandQuery; import com.wms.entity.app.request.StandQuery;
import com.wms.entity.app.vo.StandVo; import com.wms.entity.app.vo.StandVo;
import com.wms.entity.app.wcs.DdjStatusChangeRequest;
import com.wms.entity.table.Stand; import com.wms.entity.table.Stand;
import com.wms.service.StandService; import com.wms.service.StandService;
import com.wms.utils.HttpUtils; import com.wms.utils.HttpUtils;
@ -27,6 +28,9 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import static com.wms.utils.StringUtils.convertJsonString; import static com.wms.utils.StringUtils.convertJsonString;
/** /**
@ -130,4 +134,67 @@ public class StandController {
return convertJsonString(rsp); return convertJsonString(rsp);
} }
} }
/**
* 堆垛机状态变更
*
* @param request 请求信息
* @return 结果
*/
@PostMapping("/ddjStatusChange")
@ResponseBody
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
public String ddjStatusChange(@RequestBody List<DdjStatusChangeRequest> request) {
// 创建响应信息
ResponseEntity rsp = new ResponseEntity();
try {
if (request == null || request.isEmpty()) {
// 返回其他异常
rsp.setCode(ResponseCode.ERROR.getCode());
rsp.setMessage("请求信息不完整。");
return convertJsonString(rsp);
}
List<Stand> modifiedStands = new ArrayList<>();
for (DdjStatusChangeRequest tempDDJ : request) {
// 查询对应的堆垛机
Stand stand = standService.getOne(new LambdaQueryWrapper<Stand>().eq(Stand::getEquipmentId, tempDDJ.getEquipment())
.eq(Stand::getStandType, 3)
.last("limit 1"));
if (stand == null) {
continue;
}
if (stand.getIsLock() == 0 && tempDDJ.getError() != 0) {
stand.setIsLock(1);
modifiedStands.add(stand);
}
if (stand.getIsLock() == 1 && tempDDJ.getError() == 0) {
stand.setIsLock(0);
modifiedStands.add(stand);
}
}
if (!modifiedStands.isEmpty()) {
if (standService.updateBatchById(modifiedStands)) {
logger.info("更新堆垛机状态成功: {}", convertJsonString(request));
rsp.setCode(ResponseCode.OK.getCode());
rsp.setMessage("更新堆垛机状态成功。");
} else {
logger.error("更新堆垛机状态失败: {}", convertJsonString(request));
rsp.setCode(ResponseCode.ERROR.getCode());
rsp.setMessage("更新堆垛机状态失败。");
}
} else {
rsp.setCode(ResponseCode.OK.getCode());
rsp.setMessage("没有堆垛机变更状态。");
}
return convertJsonString(rsp);
} catch (Exception e) {
// 回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
// 返回其他异常
rsp.setCode(ResponseCode.ERROR.getCode());
rsp.setMessage("堆垛机状态变更发生异常");
return convertJsonString(rsp);
}
}
} }

View File

@ -73,7 +73,8 @@ public class StockController {
.eq(StringUtils.isNotEmpty(stockQuery.getLocationId()), Stock::getLocationId, stockQuery.getLocationId()) .eq(StringUtils.isNotEmpty(stockQuery.getLocationId()), Stock::getLocationId, stockQuery.getLocationId())
.eq(stockQuery.getStockStatus() != null, Stock::getStockStatus, stockQuery.getStockStatus()) .eq(stockQuery.getStockStatus() != null, Stock::getStockStatus, stockQuery.getStockStatus())
.apply(StringUtils.isNotEmpty(stockQuery.getGoodsId()), "goods_related ->> '$.goodsId' like concat('%', {0}, '%')", stockQuery.getGoodsId()) .apply(StringUtils.isNotEmpty(stockQuery.getGoodsId()), "goods_related ->> '$.goodsId' like concat('%', {0}, '%')", stockQuery.getGoodsId())
.apply(StringUtils.isNotEmpty(stockQuery.getGoodsName()), "goods_related ->> '$.goodsName' like concat('%', {0}, '%')", stockQuery.getGoodsName())); .apply(StringUtils.isNotEmpty(stockQuery.getGoodsName()), "goods_related ->> '$.goodsName' like concat('%', {0}, '%')", stockQuery.getGoodsName())
.orderByDesc(Stock::getLastUpdateTime));
PageDto<StockVo> pageDto = PageDto.of(stockPage, StockVo::of); PageDto<StockVo> pageDto = PageDto.of(stockPage, StockVo::of);
response.setCode(ResponseCode.OK.getCode()); response.setCode(ResponseCode.OK.getCode());

View File

@ -9,6 +9,7 @@ import com.wms.annotation.MyLog;
import com.wms.constants.enums.*; import com.wms.constants.enums.*;
import com.wms.entity.app.*; 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.extend.StockDetailInfo; import com.wms.entity.app.dto.extend.StockDetailInfo;
import com.wms.entity.app.request.*; import com.wms.entity.app.request.*;
import com.wms.entity.app.vo.BoxPrintData; import com.wms.entity.app.vo.BoxPrintData;
@ -125,6 +126,10 @@ public class TaskController {
* DBS服务 * DBS服务
*/ */
private final KateDBSService kateDBSService; private final KateDBSService kateDBSService;
/**
* 工单服务
*/
private final KateOrdersService kateOrdersService;
/** /**
* 上一次标签配置的服务 * 上一次标签配置的服务
*/ */
@ -906,6 +911,9 @@ public class TaskController {
BigDecimal realNum = stock.getGoodsRelated().getRemainNum(); BigDecimal realNum = stock.getGoodsRelated().getRemainNum();
List<ETaskData> eTaskDataList = new ArrayList<>(); List<ETaskData> eTaskDataList = new ArrayList<>();
for (WorkFlow tempWork : workFlows) { for (WorkFlow tempWork : workFlows) {
if (realNum.compareTo(BigDecimal.ZERO) <= 0) {// 当前物料数量不足
break;
}
if (tempWork.getLightStatus() != 0) { if (tempWork.getLightStatus() != 0) {
// 不是未亮灯的状态 // 不是未亮灯的状态
// 当次拣选数量 // 当次拣选数量
@ -913,9 +921,6 @@ public class TaskController {
realNum = realNum.subtract(thisPickNum); realNum = realNum.subtract(thisPickNum);
continue; continue;
} }
if (realNum.compareTo(BigDecimal.ZERO) <= 0) {// 当前物料数量不足
break;
}
// 查找对应的标签配置 // 查找对应的标签配置
ELocationConfig eConfig = eLocationConfigService.getOne(new LambdaQueryWrapper<ELocationConfig>() ELocationConfig eConfig = eLocationConfigService.getOne(new LambdaQueryWrapper<ELocationConfig>()
.eq(ELocationConfig::getWorkStation, standId) .eq(ELocationConfig::getWorkStation, standId)
@ -975,14 +980,14 @@ public class TaskController {
.set(ETagLocation::getTaskType, wcsETaskRequest.getTaskType()) .set(ETagLocation::getTaskType, wcsETaskRequest.getTaskType())
.set(ETagLocation::getVehicleNo, wcsETaskRequest.getVehicleNo()) .set(ETagLocation::getVehicleNo, wcsETaskRequest.getVehicleNo())
.in(ETagLocation::getELocationId, eTaskDataList.stream().map(ETaskData::getLocation).collect(Collectors.toList()))); .in(ETagLocation::getELocationId, eTaskDataList.stream().map(ETaskData::getLocation).collect(Collectors.toList())));
}
}
}
// 更新站台数据 // 更新站台数据
standService.update(new LambdaUpdateWrapper<Stand>() standService.update(new LambdaUpdateWrapper<Stand>()
.set(Stand::getPickGoods, workQuery.getGoodsId()) .set(Stand::getPickGoods, workQuery.getGoodsId())
.set(Stand::getPickVehicle, vehicleId) .set(Stand::getPickVehicle, vehicleId)
.eq(Stand::getStandId, standId)); .eq(Stand::getStandId, standId));
}
}
}
// 生成前台VO // 生成前台VO
StandPickVo standPickVo = new StandPickVo(); StandPickVo standPickVo = new StandPickVo();
standPickVo.setStandId(standId); standPickVo.setStandId(standId);
@ -1318,7 +1323,7 @@ public class TaskController {
List<String> goodsIdList = new ArrayList<>(); List<String> goodsIdList = new ArrayList<>();
if (outsideVehicles != null && !outsideVehicles.isEmpty()) { if (outsideVehicles != null && !outsideVehicles.isEmpty()) {
for (OutsideVehicles outsideVehicle : outsideVehicles) { for (OutsideVehicles outsideVehicle : outsideVehicles) {
// 料号不对应 // 当前确认料号
if (Objects.equals(outsideVehicle.getGoodsId(), workConfirmRequest.getGoodsId())) { if (Objects.equals(outsideVehicle.getGoodsId(), workConfirmRequest.getGoodsId())) {
continue; continue;
} }
@ -1522,7 +1527,7 @@ public class TaskController {
// 删除当前拣选任务 // 删除当前拣选任务
pickTaskService.removeById(pickTask); pickTaskService.removeById(pickTask);
// 不需要放行 // 不需要放行
wcsService.sendWcsDisposeVehicle(new WcsDisposeVehicleRequest(targetStand.getStandId(), pickTask.getVehicleId())); // wcsService.sendWcsDisposeVehicle(new WcsDisposeVehicleRequest(targetStand.getStandId(), pickTask.getVehicleId()));
// 判断是不是已经完成工作 // 判断是不是已经完成工作
if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>() if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, targetStand.getStandId()) .eq(WorkFlow::getWorkStation, targetStand.getStandId())
@ -1555,7 +1560,7 @@ public class TaskController {
// 删除当前拣选任务 // 删除当前拣选任务
pickTaskService.removeById(pickTask); pickTaskService.removeById(pickTask);
// 放行 // 放行
wcsService.sendWcsDisposeVehicle(new WcsDisposeVehicleRequest(targetStand.getStandId(), pickTask.getVehicleId())); // wcsService.sendWcsDisposeVehicle(new WcsDisposeVehicleRequest(targetStand.getStandId(), pickTask.getVehicleId()));
// 判断是不是已经完成工作 // 判断是不是已经完成工作
if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>() if (workFlowService.exists(new LambdaQueryWrapper<WorkFlow>()
.eq(WorkFlow::getWorkStation, targetStand.getStandId()) .eq(WorkFlow::getWorkStation, targetStand.getStandId())
@ -2076,6 +2081,13 @@ public class TaskController {
logger.info("请求整理盒子:{}ip地址{}", convertJsonString(sortBoxRequest), HttpUtils.getIpAddr(servletRequest)); logger.info("请求整理盒子:{}ip地址{}", convertJsonString(sortBoxRequest), HttpUtils.getIpAddr(servletRequest));
ResponseEntity response = new ResponseEntity(); ResponseEntity response = new ResponseEntity();
try { try {
// 判断请求参数是否正确
if (sortBoxRequest == null || StringUtils.isEmpty(sortBoxRequest.getBigBoxNo()) || sortBoxRequest.getOrderOfOrders() == null) {
logger.error("请求参数不全。");
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("请求参数不全。");
return convertJsonString(response);
}
// 获取站台号 // 获取站台号
String standId = ""; String standId = "";
if (StringUtils.isNotEmpty(sortBoxRequest.getStandId())) { if (StringUtils.isNotEmpty(sortBoxRequest.getStandId())) {
@ -2117,15 +2129,27 @@ public class TaskController {
response.setMessage("请将已亮灯的盒子取走并灭灯后重试。"); response.setMessage("请将已亮灯的盒子取走并灭灯后重试。");
return convertJsonString(response); return convertJsonString(response);
} }
// 生成工位列表 // 筛选小盒子号
List<String> workCenterList = stationConfigs.stream().map(WorkStationConfig::getWorkCenter).distinct().toList(); List<String> smallBoxListOfAll = stationConfigs.stream().map(WorkStationConfig::getSmallBox).distinct().toList();
// 查询该盒子下面所有的工单
List<KateOrders> orders = kateOrdersService.list(new LambdaQueryWrapper<KateOrders>()
.in(KateOrders::getSupplyArea, smallBoxListOfAll));
List<String> orderIds = orders.stream().map(KateOrders::getOrderId).distinct().toList();
// 查询DBS
List<KateDBS> dbsList = kateDBSService.list(new LambdaQueryWrapper<KateDBS>()
.in(KateDBS::getWorkOrder, orderIds)
.orderByAsc(KateDBS::getWorkSequence));
if (dbsList.isEmpty()) {
logger.error("DBS查询不到对应信息。");
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("DBS查询不到对应信息。");
return convertJsonString(response);
}
// 获取要打印的工单号
String currentOrderId = dbsList.get(sortBoxRequest.getOrderOfOrders() - 1).getWorkOrder();
List<String> smallBoxList = orders.stream().filter(order -> order.getWorkOrder().equals(currentOrderId)).map(KateOrders::getSupplyArea).distinct().toList();
// 亮灯列表 // 亮灯列表
List<ETaskData> eTaskDataList = new ArrayList<>(); List<ETaskData> eTaskDataList = new ArrayList<>();
for (String workCenter : workCenterList) {
if (!eTaskDataList.isEmpty()) {
break;
}
List<String> smallBoxList = stationConfigs.stream().filter(stationConfig -> stationConfig.getWorkCenter().equals(workCenter)).map(WorkStationConfig::getSmallBox).distinct().toList();
for (String smallBox : smallBoxList) { for (String smallBox : smallBoxList) {
// 查找对应的标签配置 // 查找对应的标签配置
ELocationConfigLast eConfigLast = eLocationConfigLastService.getOne(new LambdaQueryWrapper<ELocationConfigLast>() ELocationConfigLast eConfigLast = eLocationConfigLastService.getOne(new LambdaQueryWrapper<ELocationConfigLast>()
@ -2151,7 +2175,7 @@ public class TaskController {
.eq(ETagLocation::getELocationId, eConfigLast.getELocationId())); .eq(ETagLocation::getELocationId, eConfigLast.getELocationId()));
} }
} }
} if (!eTaskDataList.isEmpty()) {
// 发送亮灯 // 发送亮灯
WcsETaskRequest wcsETaskRequest = new WcsETaskRequest(); WcsETaskRequest wcsETaskRequest = new WcsETaskRequest();
wcsETaskRequest.setTaskGroup(generateId(sortBoxRequest.getBigBoxNo() + "_")); wcsETaskRequest.setTaskGroup(generateId(sortBoxRequest.getBigBoxNo() + "_"));
@ -2181,6 +2205,11 @@ public class TaskController {
logger.info("处理整理盒子请求成功。"); logger.info("处理整理盒子请求成功。");
response.setCode(ResponseCode.OK.getCode()); response.setCode(ResponseCode.OK.getCode());
response.setMessage("请根据灯光拣选盒子。"); response.setMessage("请根据灯光拣选盒子。");
} else {
logger.info("没有可亮灯的数据。");
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("没有可亮灯的数据。");
}
return convertJsonString(response); return convertJsonString(response);
} catch (Exception e) { } catch (Exception e) {
// 回滚事务 // 回滚事务
@ -2206,6 +2235,13 @@ public class TaskController {
logger.info("直接物料非计划领料:{}ip地址{}", convertJsonString(noPlanRequest), HttpUtils.getIpAddr(servletRequest)); logger.info("直接物料非计划领料:{}ip地址{}", convertJsonString(noPlanRequest), HttpUtils.getIpAddr(servletRequest));
ResponseEntity response = new ResponseEntity(); ResponseEntity response = new ResponseEntity();
try { try {
if (StringUtils.isEmpty(noPlanRequest.getGoodsId())
|| noPlanRequest.getNeedNum() == null || noPlanRequest.getNeedNum().compareTo(BigDecimal.ZERO) <= 0) {
logger.error("非计划领料,请输入料号和数量。");
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("非计划领料,请输入料号和数量。");
return convertJsonString(response);
}
// 获取站台号 // 获取站台号
Stand targetStand; Stand targetStand;
if (StringUtils.isNotEmpty(noPlanRequest.getStandId())) { if (StringUtils.isNotEmpty(noPlanRequest.getStandId())) {
@ -2225,13 +2261,62 @@ public class TaskController {
return convertJsonString(response); return convertJsonString(response);
} }
// 查询库存 // 查询库存
// TODO 非计划领料待确认 List<Stock> stockList = stockService.list(new LambdaQueryWrapper<Stock>()
// Task中的isPicking=1 .eq(Stock::getStockStatus, StockStatus.OK.getCode())
.apply("goods_related ->> '$.goodsId' = {0}", noPlanRequest.getGoodsId())
.apply("goods_related ->> '$.remainNum' > 0")
.orderByAsc(Stock::getCreateTime));
// 查询应该的库存总数
List<StockOfGoodsDto> stockOfGoodsList = stockService.selectSumOfGoods(noPlanRequest.getGoodsId());
// 总数量
BigDecimal stockNum = stockOfGoodsList.stream().map(StockOfGoodsDto::getRemainNumSum).reduce(BigDecimal.ZERO, BigDecimal::add);
if (stockList != null && !stockList.isEmpty()) {
List<Stock> waitForOutStockList = new ArrayList<>();
// TODO 生成出库任务
// 尝试生成出库任务
// 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);
// 非计划领料记录生成
NoPlanRecord noPlanRecord = new NoPlanRecord();
noPlanRecord.setRecordId(generateId("CLC-NO-PLAN_"));
noPlanRecord.setCallType(1);
noPlanRecord.setGoodsId(noPlanRequest.getGoodsId());
noPlanRecord.setNeedNum(noPlanRequest.getNeedNum());
noPlanRecord.setStockNum(stockNum);
} else {
if (stockNum.compareTo(BigDecimal.ZERO) > 0) {
logger.error("所有库存在站台备料中。");
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("所有库存在站台备料中。");
} else {
logger.error("非计划领料没有库存。");
response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("非计划领料没有库存。");
}
return convertJsonString(response);
}
logger.info("处理整理盒子请求成功。"); logger.info("处理整理盒子请求成功。");
response.setCode(ResponseCode.OK.getCode()); response.setCode(ResponseCode.OK.getCode());
@ -2240,9 +2325,9 @@ public class TaskController {
} catch (Exception e) { } catch (Exception e) {
// 回滚事务 // 回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
logger.error("处理整理盒子请求异常,{}", convertJsonString(e)); logger.error("处理直接物料非计划领料请求异常,{}", convertJsonString(e));
response.setCode(ResponseCode.ERROR.getCode()); response.setCode(ResponseCode.ERROR.getCode());
response.setMessage("处理整理盒子请求异常。"); response.setMessage("处理直接物料非计划领料请求异常。");
return convertJsonString(response); return convertJsonString(response);
} }
} }
@ -2256,9 +2341,9 @@ public class TaskController {
@PostMapping("/clcNoPlanConfirmBack") @PostMapping("/clcNoPlanConfirmBack")
@ResponseBody @ResponseBody
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
@MyLog(logTitle = "直接物料非计划领料", logMethod = "clcNoPlanConfirmBack") @MyLog(logTitle = "直接物料非计划领料确认回库", logMethod = "clcNoPlanConfirmBack")
public String clcNoPlanConfirmBack(@RequestBody NoPlanRequest noPlanRequest) { public String clcNoPlanConfirmBack(@RequestBody NoPlanRequest noPlanRequest) {
logger.info("直接物料非计划领料{}ip地址{}", convertJsonString(noPlanRequest), HttpUtils.getIpAddr(servletRequest)); logger.info("直接物料非计划领料确认回库{}ip地址{}", convertJsonString(noPlanRequest), HttpUtils.getIpAddr(servletRequest));
ResponseEntity response = new ResponseEntity(); ResponseEntity response = new ResponseEntity();
try { try {
// 获取站台号 // 获取站台号
@ -2283,10 +2368,6 @@ public class TaskController {
// Task中的isPicking=1 // Task中的isPicking=1
logger.info("处理整理盒子请求成功。"); logger.info("处理整理盒子请求成功。");
response.setCode(ResponseCode.OK.getCode()); response.setCode(ResponseCode.OK.getCode());
response.setMessage("请根据灯光拣选盒子。"); response.setMessage("请根据灯光拣选盒子。");

View File

@ -61,7 +61,8 @@ public class WmsLogController {
.or().like(StringUtils.isNotEmpty(logQuery.getQueryParam()), WmsLog::getLogRequest, logQuery.getQueryParam()) .or().like(StringUtils.isNotEmpty(logQuery.getQueryParam()), WmsLog::getLogRequest, logQuery.getQueryParam())
.or().like(StringUtils.isNotEmpty(logQuery.getQueryParam()), WmsLog::getLogResponse, logQuery.getQueryParam()) .or().like(StringUtils.isNotEmpty(logQuery.getQueryParam()), WmsLog::getLogResponse, logQuery.getQueryParam())
.or().like(StringUtils.isNotEmpty(logQuery.getQueryParam()), WmsLog::getLogIp, logQuery.getQueryParam()) .or().like(StringUtils.isNotEmpty(logQuery.getQueryParam()), WmsLog::getLogIp, logQuery.getQueryParam())
.or().like(StringUtils.isNotEmpty(logQuery.getQueryParam()), WmsLog::getLogUser, logQuery.getQueryParam())); .or().like(StringUtils.isNotEmpty(logQuery.getQueryParam()), WmsLog::getLogUser, logQuery.getQueryParam())
.orderByDesc(WmsLog::getLogTime));
PageDto<WmsLogVo> pageDto = PageDto.of(logPage, log -> BeanUtil.copyProperties(log, WmsLogVo.class)); PageDto<WmsLogVo> pageDto = PageDto.of(logPage, log -> BeanUtil.copyProperties(log, WmsLogVo.class));
response.setCode(ResponseCode.OK.getCode()); response.setCode(ResponseCode.OK.getCode());

View File

@ -0,0 +1,20 @@
package com.wms.entity.app.wcs;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DdjStatusChangeRequest extends BaseWcsRequest {
/**
* 设备号
*/
@JsonProperty("equipment")
private Integer equipment;
/**
* 错误
*/
@JsonProperty("error")
private Integer error;
}

View File

@ -310,19 +310,32 @@ public class WmsTaskServiceImplements implements IWmsTaskService {
if (needNum.compareTo(BigDecimal.ZERO) <= 0) {// 需求数量小于等于0 if (needNum.compareTo(BigDecimal.ZERO) <= 0) {// 需求数量小于等于0
break; break;
} }
if (outsideVehicle.getRemainNum().compareTo(needNum) > 0) { // 查询当前料箱当前物料的库存
Stock stock = stockService.getOne(new LambdaQueryWrapper<Stock>()
.eq(Stock::getVehicleId, outsideVehicle.getVehicleId())
.apply("goods_related ->> '$.goodsId' = {0}", goodsId)
.apply("goods_related ->> '$.remainNum' > 0")
.last("limit 1"));
if (stock == null) {
// 没有库存那么就要移除当前的outsideVehicles
outsideVehiclesService.removeById(outsideVehicle.getOutsideId());
} else {
StockDetailInfo goodsRelated = stock.getGoodsRelated();
if (goodsRelated.getRemainNum().compareTo(needNum) > 0) {
// 当前箱子剩余物料数量多于需求数量 // 当前箱子剩余物料数量多于需求数量
needNum = BigDecimal.ZERO; needNum = BigDecimal.ZERO;
outsideVehicle.setRemainNum(outsideVehicle.getRemainNum().subtract(needNum)); outsideVehicle.setRemainNum(goodsRelated.getRemainNum().subtract(needNum));
usedOutsideVehiclesList.add(outsideVehicle); usedOutsideVehiclesList.add(outsideVehicle);
break; break;
} else { } else {
// 当前箱子物料剩余数量少于需求数量 // 当前箱子物料剩余数量少于需求数量
needNum = needNum.subtract(outsideVehicle.getRemainNum()); needNum = needNum.subtract(goodsRelated.getRemainNum());
outsideVehicle.setRemainNum(BigDecimal.ZERO); outsideVehicle.setRemainNum(BigDecimal.ZERO);
usedOutsideVehiclesList.add(outsideVehicle); usedOutsideVehiclesList.add(outsideVehicle);
} }
} }
}
// 更新流转箱表 // 更新流转箱表
outsideVehiclesService.updateBatchById(usedOutsideVehiclesList); outsideVehiclesService.updateBatchById(usedOutsideVehiclesList);
// 生成拣选任务 // 生成拣选任务

View File

@ -42,7 +42,8 @@ public class WorkServiceImplements implements IWorkService {
private final WorkSummaryService workSummaryService;// 工作总结服务 private final WorkSummaryService workSummaryService;// 工作总结服务
private final ELocationConfigLastService eLocationConfigLastService;// 上一次标签配置的服务 private final ELocationConfigLastService eLocationConfigLastService;// 上一次标签配置的服务
private final StockService stockService;// 库存服务 private final StockService stockService;// 库存服务
private final IWmsTaskService wmsTaskService; private final IWmsTaskService wmsTaskService;// 任务服务
private final PickTaskService pickTaskService;// 拣选任务服务
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<>();// 当前正在完成任务的站台
@ -190,14 +191,19 @@ public class WorkServiceImplements implements IWorkService {
.eq(GoodsToStation::getDistributeStatus, 0) .eq(GoodsToStation::getDistributeStatus, 0)
.or().eq(GoodsToStation::getDistributeStatus, 1)); .or().eq(GoodsToStation::getDistributeStatus, 1));
if (goodsToStationList == null || goodsToStationList.isEmpty()) { if (goodsToStationList == null || goodsToStationList.isEmpty()) {
// 查询是否还有这个站台的拣选任务
if (!pickTaskService.exists(new LambdaQueryWrapper<PickTask>()
.eq(PickTask::getStandId, workStation))) {
// 已经不存在未分配的任务且没有拣选任务可视为完成
// 更新工作流状态-->完成 // 更新工作流状态-->完成
List<String> workFlowIds = currentWorkFlowList.stream().map(WorkFlow::getWorkFlowId).distinct().toList(); List<String> workFlowIds = currentWorkFlowList.stream().map(WorkFlow::getWorkFlowId).distinct().toList();
workFlowService.update(new LambdaUpdateWrapper<WorkFlow>() workFlowService.update(new LambdaUpdateWrapper<WorkFlow>()
.set(WorkFlow::getWorkStatus, 2) .set(WorkFlow::getWorkStatus, 2)
.set(WorkFlow::getFinishTime, LocalDateTime.now()) .set(WorkFlow::getFinishTime, LocalDateTime.now())
.set(WorkFlow::getOpUser, "库存等原因,系统自动完成") .set(WorkFlow::getOpUser, "系统自动完成")
.in(WorkFlow::getWorkFlowId, workFlowIds) .in(WorkFlow::getWorkFlowId, workFlowIds)
.ne(WorkFlow::getWorkStatus, 2)); .ne(WorkFlow::getWorkStatus, 2));
}
return; return;
} }
for (GoodsToStation goodsToStation : goodsToStationList) { for (GoodsToStation goodsToStation : goodsToStationList) {
@ -224,8 +230,11 @@ public class WorkServiceImplements implements IWorkService {
} else { } else {
needNum = wmsTaskService.callStocks(goodsToStation.getGoodsId(), needNum, workStation); needNum = wmsTaskService.callStocks(goodsToStation.getGoodsId(), needNum, workStation);
if (needNum.compareTo(BigDecimal.ZERO) > 0) { if (needNum.compareTo(BigDecimal.ZERO) > 0) {
// 分配完成但库存缺料 // 已分配但未完全分配
goodsToStation.setDistributeStatus(1); goodsToStation.setDistributeStatus(1);
} else {
// 分配完成
goodsToStation.setDistributeStatus(2);
} }
} }
// 更新已分配数量 // 更新已分配数量

View File

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener; import com.alibaba.excel.read.listener.ReadListener;
import com.alibaba.excel.util.ListUtils; import com.alibaba.excel.util.ListUtils;
import com.wms.entity.app.dto.extend.KanbanEntity;
import com.wms.entity.table.Goods; import com.wms.entity.table.Goods;
import com.wms.service.GoodsService; import com.wms.service.GoodsService;
import com.wms.utils.StringUtils; import com.wms.utils.StringUtils;
@ -23,9 +24,9 @@ import static com.wms.utils.StringUtils.convertJsonString;
public class UploadGoodsListener implements ReadListener<GoodsExcelVo> { public class UploadGoodsListener implements ReadListener<GoodsExcelVo> {
private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());
/** /**
* 每隔5条存储数据库实际使用中可以100然后清理list 方便内存回收 * 每隔5条存储数据库实际使用中可以1000然后清理list 方便内存回收
*/ */
private static final int BATCH_COUNT = 100; private static final int BATCH_COUNT = 1000;
/** /**
* 保存数据总数 * 保存数据总数
*/ */
@ -84,6 +85,9 @@ public class UploadGoodsListener implements ReadListener<GoodsExcelVo> {
List<Goods> goodsList = new ArrayList<>(); List<Goods> goodsList = new ArrayList<>();
for (GoodsExcelVo goodsExcelVo : cachedDataList) { for (GoodsExcelVo goodsExcelVo : cachedDataList) {
Goods currentGoods = BeanUtil.copyProperties(goodsExcelVo, Goods.class); Goods currentGoods = BeanUtil.copyProperties(goodsExcelVo, Goods.class);
// 设置看板
List<KanbanEntity> kanbanList = goodsExcelVo.convertToKanbanList();
currentGoods.setKanbanList(kanbanList);
currentGoods.setLastUpdateTime(LocalDateTime.now()); currentGoods.setLastUpdateTime(LocalDateTime.now());
currentGoods.setLastUpdateUser(uploadUser); currentGoods.setLastUpdateUser(uploadUser);
goodsList.add(currentGoods); goodsList.add(currentGoods);

View File

@ -3,14 +3,12 @@ package com.wms.utils.excel.vo;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat; import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.wms.entity.app.dto.extend.KanbanEntity;
import com.wms.entity.table.Goods; import com.wms.entity.table.Goods;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
/** /**
* 物料excel * 物料excel

View File

@ -2,9 +2,11 @@ package com.wms.utils.excel.vo;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.wms.entity.app.dto.extend.KanbanEntity; import com.wms.entity.app.dto.extend.KanbanEntity;
import com.wms.utils.StringUtils;
import lombok.Data; import lombok.Data;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -142,4 +144,27 @@ public class KanbanExcelVo {
} }
} }
} }
/**
* 设定看板
*/
public List<KanbanEntity> convertToKanbanList() {
List<KanbanEntity> kanbanList = new ArrayList<>();
for (Field field : this.getClass().getDeclaredFields()) {
if (field.getName().startsWith("KANBAN")) {
try {
field.setAccessible(true);
if (StringUtils.isNotEmpty(String.valueOf(field.get(this)))) {
KanbanEntity kanbanEntity = new KanbanEntity();
kanbanEntity.setKanbanId(String.valueOf(field.get(this)));
kanbanList.add(kanbanEntity);
}
} catch (IllegalAccessException e) {
// 捕捉异常
System.out.println("转化看板数据配置时发生异常:" + e.getMessage());
}
}
}
return kanbanList;
}
} }

View File

@ -8,20 +8,20 @@ spring:
# 主库 # 主库
master: master:
# 卡特数据库服务器 # 卡特数据库服务器
# url: jdbc:mysql://10.90.36.71:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true url: jdbc:mysql://10.90.36.71:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
# username: developer username: developer
# password: developer password: developer
# driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
# 宝开服务器--内网 # 宝开服务器--内网
# url: jdbc:mysql://192.168.3.254:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true # url: jdbc:mysql://192.168.3.254:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
# username: coder # username: coder
# password: coder # password: coder
# driver-class-name: com.mysql.cj.jdbc.Driver # driver-class-name: com.mysql.cj.jdbc.Driver
# # 本地环境 # # 本地环境
url: jdbc:mysql://localhost:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true # url: jdbc:mysql://localhost:3306/wms_kate_suzhou?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
username: developer # username: developer
password: developer # password: developer
driver-class-name: com.mysql.cj.jdbc.Driver # driver-class-name: com.mysql.cj.jdbc.Driver
# 从库 # 从库
# slave_1: # slave_1:
# url: jdbc:mysql://localhost:3306/wms_aaa?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true # url: jdbc:mysql://localhost:3306/wms_aaa?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true