Commit 2496fa9ab05bd0de0843d2722a10bea67d7ee98f

Authored by pengyongcheng
1 parent 8a717efc

fix: 传爆管入库调整:先组盘再入库

src/main/java/com/huaheng/pc/inventory/inventoryHeader/controller/InventoryHeaderController.java
... ... @@ -22,6 +22,7 @@ import com.huaheng.pc.config.station.service.StationService;
22 22 import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
23 23 import com.huaheng.pc.inventory.inventoryHeader.domain.CbgInventoryDto;
24 24 import com.huaheng.pc.inventory.inventoryHeader.domain.CbgReceiptDto;
  25 +import com.huaheng.pc.inventory.inventoryHeader.domain.CbgReplenishDto;
25 26 import com.huaheng.pc.inventory.inventoryHeader.domain.InventoryHeader;
26 27 import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService;
27 28 import com.huaheng.pc.system.user.domain.User;
... ... @@ -403,25 +404,18 @@ public class InventoryHeaderController extends BaseController {
403 404 }
404 405  
405 406 /**
406   - * 传爆管入库页面
  407 + * 传爆管组盘页面
407 408 */
408   - @GetMapping("/cbgReceipt/{locationCode}")
409   - public String cbgReceipt(@PathVariable String locationCode, ModelMap modelMap) {
410   - modelMap.put("locationCode", locationCode);
411   - User user = ShiroUtils.getUser();
412   - if (user != null) {
413   - user = userService.selectUserById(user.getId());
414   - }
415   - modelMap.put("user", user);
416   - modelMap.put("stations", stationService.getRenGong());
  409 + @GetMapping("/cbgReceipt")
  410 + public String cbgReceipt(ModelMap modelMap) {
417 411 return prefix + "/cbgReceipt";
418 412 }
419 413  
420 414 /**
421   - * 传爆管入库
  415 + * 传爆管组盘
422 416 */
423 417 @PostMapping("/cbgReceipt")
424   - @Log(title = "传爆管入库", operating = "传爆管入库", action = BusinessType.INSERT)
  418 + @Log(title = "传爆管入库组盘", operating = "传爆管入库组盘", action = BusinessType.INSERT)
425 419 @ResponseBody
426 420 public AjaxResult cbgReceipt(@RequestBody CbgReceiptDto cbgReceiptDto) {
427 421 String shipmentReferCode = cbgReceiptDto.getShipmentReferCode();
... ... @@ -432,10 +426,6 @@ public class InventoryHeaderController extends BaseController {
432 426 if (StringUtils.isEmpty(orderCode)) {
433 427 throw new ServiceException("传爆管入库失败,工单号为空");
434 428 }
435   - String locationCode = cbgReceiptDto.getLocationCode();
436   - if (StringUtils.isEmpty(locationCode)) {
437   - throw new ServiceException("传爆管入库失败,入库库位为空");
438   - }
439 429 List<MaterialData> materialDataList = cbgReceiptDto.getMaterialDataList();
440 430 if (StringUtils.isEmpty(materialDataList)) {
441 431 throw new ServiceException("传爆管入库失败,入库物料信息为空");
... ... @@ -469,6 +459,47 @@ public class InventoryHeaderController extends BaseController {
469 459 }
470 460  
471 461 /**
  462 + * 传爆管补料页面
  463 + */
  464 + @GetMapping("/cbgReplenish/{locationCode}")
  465 + public String cbgReplenish(@PathVariable String locationCode, ModelMap modelMap) {
  466 + modelMap.put("locationCode", locationCode);
  467 + User user = ShiroUtils.getUser();
  468 + if (user != null) {
  469 + user = userService.selectUserById(user.getId());
  470 + }
  471 + modelMap.put("user", user);
  472 + modelMap.put("stations", stationService.getRenGong());
  473 + return prefix + "/cbgReplenish";
  474 + }
  475 +
  476 + /**
  477 + * 传爆管补料
  478 + */
  479 + @PostMapping("/cbgReplenish")
  480 + @Log(title = "传爆管补料", operating = "传爆管补料\"", action = BusinessType.INSERT)
  481 + @ResponseBody
  482 + public AjaxResult cbgReplenish(@RequestBody CbgReplenishDto cbgReplenishDto) {
  483 + String fromPort = cbgReplenishDto.getFromPort();
  484 + String containerCode = cbgReplenishDto.getContainerCode();
  485 + String locationCode = cbgReplenishDto.getLocationCode();
  486 + String vehicleCode = cbgReplenishDto.getVehicleCode();
  487 + if (StringUtils.isEmpty(fromPort)) {
  488 + return AjaxResult.error("上料口为空");
  489 + }
  490 + if (StringUtils.isEmpty(containerCode)) {
  491 + return AjaxResult.error("载具为空");
  492 + }
  493 + if (StringUtils.isEmpty(locationCode)) {
  494 + return AjaxResult.error("目标库位为空");
  495 + }
  496 + if (StringUtils.isEmpty(vehicleCode)) {
  497 + return AjaxResult.error("盛具为空");
  498 + }
  499 + return inventoryHeaderService.cbgReplenishInventory(cbgReplenishDto);
  500 + }
  501 +
  502 + /**
472 503 * 传爆管空托出库
473 504 */
474 505 @GetMapping("/cbgEmptyOut")
... ...
src/main/java/com/huaheng/pc/inventory/inventoryHeader/domain/CbgReceiptDto.java
1 1 package com.huaheng.pc.inventory.inventoryHeader.domain;
2 2  
3 3 import com.huaheng.api.mes.domain.MaterialData;
4   -import com.huaheng.api.mes.domain.MesReceipt;
5 4 import lombok.Data;
6   -import lombok.EqualsAndHashCode;
7 5  
8 6 import java.io.Serializable;
9   -import java.math.BigDecimal;
10 7 import java.util.List;
11 8  
12   -
13 9 /**
14   - * 传爆管立库入库Dto对象
  10 + * 传爆管立库入库组盘Dto类
15 11 */
16 12 @Data
17 13 public class CbgReceiptDto {
... ... @@ -27,22 +23,12 @@ public class CbgReceiptDto {
27 23 private String shipmentReferCode;
28 24  
29 25 /**
30   - * 库位编码
31   - */
32   - private String locationCode;
33   -
34   - /**
35   - * 托盘编码
36   - */
37   - private String containerCode;
38   -
39   - /**
40 26 * 原站台
41 27 */
42 28 private String fromPort;
43 29  
44 30 /**
45   - * 具编码
  31 + * 具编码
46 32 */
47 33 private String vehicleCode;
48 34  
... ...
src/main/java/com/huaheng/pc/inventory/inventoryHeader/domain/CbgReplenishDto.java 0 → 100644
  1 +package com.huaheng.pc.inventory.inventoryHeader.domain;
  2 +
  3 +import com.huaheng.api.mes.domain.MaterialData;
  4 +import lombok.Data;
  5 +
  6 +import java.io.Serializable;
  7 +import java.util.List;
  8 +
  9 +
  10 +/**
  11 + * 传爆管立库补料Dto对象
  12 + */
  13 +@Data
  14 +public class CbgReplenishDto implements Serializable {
  15 +
  16 + private static final long serialVersionUID = 1L;
  17 +
  18 + /**
  19 + * 起始站台
  20 + */
  21 + private String fromPort;
  22 +
  23 + /**
  24 + * 载具编码
  25 + */
  26 + private String containerCode;
  27 +
  28 + /**
  29 + * 盛具编码
  30 + */
  31 + private String vehicleCode;
  32 +
  33 + /**
  34 + * 目标库位
  35 + */
  36 + private String locationCode;
  37 +}
... ...
src/main/java/com/huaheng/pc/inventory/inventoryHeader/service/InventoryHeaderService.java
... ... @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
4 4 import com.huaheng.framework.web.domain.AjaxResult;
5 5 import com.huaheng.pc.inventory.inventoryHeader.domain.CbgInventoryDto;
6 6 import com.huaheng.pc.inventory.inventoryHeader.domain.CbgReceiptDto;
  7 +import com.huaheng.pc.inventory.inventoryHeader.domain.CbgReplenishDto;
7 8 import com.huaheng.pc.inventory.inventoryHeader.domain.InventoryHeader;
8 9 import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
9 10 import org.springframework.stereotype.Service;
... ... @@ -158,4 +159,11 @@ public interface InventoryHeaderService extends IService&lt;InventoryHeader&gt; {
158 159 * @param locationCodeList 库位编码
159 160 */
160 161 void backVirtual(List<String> locationCodeList);
  162 +
  163 + /**
  164 + * 传爆管补料
  165 + * @param cbgReplenishDto 补料dto对象
  166 + * @return 补料结果0
  167 + */
  168 + AjaxResult cbgReplenishInventory(CbgReplenishDto cbgReplenishDto);
161 169 }
162 170 \ No newline at end of file
... ...
src/main/java/com/huaheng/pc/inventory/inventoryHeader/service/InventoryHeaderServiceImpl.java
... ... @@ -24,6 +24,7 @@ import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
24 24 import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
25 25 import com.huaheng.pc.inventory.inventoryHeader.domain.CbgInventoryDto;
26 26 import com.huaheng.pc.inventory.inventoryHeader.domain.CbgReceiptDto;
  27 +import com.huaheng.pc.inventory.inventoryHeader.domain.CbgReplenishDto;
27 28 import com.huaheng.pc.inventory.inventoryHeader.domain.InventoryHeader;
28 29 import com.huaheng.pc.inventory.inventoryHeader.mapper.InventoryHeaderMapper;
29 30 import com.huaheng.pc.inventory.inventoryTransaction.domain.InventoryTransaction;
... ... @@ -972,17 +973,11 @@ public class InventoryHeaderServiceImpl extends ServiceImpl&lt;InventoryHeaderMappe
972 973 @Override
973 974 @Transactional(rollbackFor = Exception.class)
974 975 public AjaxResult cbgReceipt(CbgReceiptDto cbgReceiptDto) {
975   - String containerCode = cbgReceiptDto.getContainerCode();
976   - String locationCode = cbgReceiptDto.getLocationCode();
977 976 String fromPort = cbgReceiptDto.getFromPort();
978 977 String vehicleCode = cbgReceiptDto.getVehicleCode();
979 978 String orderCode = cbgReceiptDto.getOrderCode();
980 979 String shipmentReferCode = cbgReceiptDto.getShipmentReferCode();
981 980 List<MaterialData> materialDataList = cbgReceiptDto.getMaterialDataList();
982   - Location location = locationService.getLocationByCode(locationCode);
983   - if (location == null) {
984   - throw new ServiceException(StringUtils.format("传爆管入库失败,目标库位:{} 不存在", locationCode));
985   - }
986 981 // 1、生成调拨入库单
987 982 String code = receiptHeaderService.createCode(QuantityConstant.RECEIPT_TYPE_ALLOT);
988 983 ReceiptHeader receiptHeader = new ReceiptHeader();
... ... @@ -998,57 +993,28 @@ public class InventoryHeaderServiceImpl extends ServiceImpl&lt;InventoryHeaderMappe
998 993 receiptHeader.setShipmentReferCode(shipmentReferCode);
999 994 boolean success = receiptHeaderService.save(receiptHeader);
1000 995 if (!success) {
1001   - throw new ServiceException("传爆管入库失败,创建调拨入库单失败");
  996 + throw new ServiceException("传爆管入库组盘失败,创建调拨入库单失败");
1002 997 }
1003 998 // 一盘只放一种物料
1004 999 String materialCode = materialDataList.stream().map(MaterialData::getMaterialCode).distinct().findFirst().orElse(null);
1005 1000 Material material = materialService.getByCode(materialCode);
1006 1001 if (material == null) {
1007   - throw new ServiceException(StringUtils.format("传爆管入库失败,根据物料编码:{} 未找到物料", materialCode));
  1002 + throw new ServiceException(StringUtils.format("传爆管入库组盘失败,根据物料编码:{} 未找到物料", materialCode));
1008 1003 }
1009 1004 // 2、生成组盘记录
1010   - Container container = containerService.getByCode(containerCode);
1011   - if (container == null) {
1012   - throw new ServiceException(StringUtils.format("传爆管入库失败,根据载具编码:{} 未找到载具", containerCode));
1013   - }
1014   - if (QuantityConstant.STATUS_CONTAINER_LOCK.equals(container.getStatus())) {
1015   - throw new ServiceException(StringUtils.format("传爆管入库失败,载具:{} 已锁定", containerCode));
1016   - }
1017   - if (StringUtils.isNotEmpty(container.getVehicleCode())) {
1018   - throw new ServiceException(StringUtils.format("传爆管入库失败,载具:{} 已和盛具:{} 绑定", containerCode, container.getVehicleCode()));
1019   - }
  1005 + Container container = containerService.createVirtualContainer();
1020 1006 Vehicle vehicle = vehicleService.getByCode(vehicleCode);
1021 1007 if (vehicle == null) {
1022   - throw new ServiceException(StringUtils.format("传爆管入库失败,根据盛具编码:{} 未找到盛具", vehicleCode));
  1008 + throw new ServiceException(StringUtils.format("传爆管入库组盘失败,根据盛具编码:{} 未找到盛具", vehicleCode));
1023 1009 }
1024 1010 Container containerByVehicle = containerService.getByVehicleCode(vehicleCode);
1025 1011 if (containerByVehicle != null) {
1026   - throw new ServiceException(StringUtils.format("传爆管入库失败,盛具:{} 已和载具:{} 绑定", vehicleCode, containerByVehicle.getCode()));
1027   - }
1028   - if (StringUtils.isNotEmpty(container.getLocationCode())) {
1029   - throw new ServiceException(StringUtils.format("传爆管入库失败,载具:{} 已在库位:{} 上", containerCode, container.getLocationCode()));
1030   - }
1031   - if (StringUtils.isNotEmpty(location.getContainerCode())) {
1032   - throw new ServiceException(StringUtils.format("传爆管入库失败,库位:{} 上已存在载具:{}", locationCode, location.getContainerCode()));
1033   - }
1034   - List<TaskHeader> unCompleteTaskList = taskHeaderService.getUnCompleteTaskList();
1035   - List<String> unCompleteTaskContainerCodeList = unCompleteTaskList.stream()
1036   - .map(TaskHeader::getContainerCode)
1037   - .collect(Collectors.toList());
1038   - if (unCompleteTaskContainerCodeList.contains(containerCode)) {
1039   - throw new ServiceException(StringUtils.format("传爆管入库失败,载具:{} 已存在未完成的任务", containerCode));
1040   - }
1041   - List<ReceiptContainerHeader> unCompleteCombineList = receiptContainerHeaderService.getUnCompleteCombineList();
1042   - List<String> unCompleteCombineContainerCodeList = unCompleteCombineList.stream()
1043   - .map(ReceiptContainerHeader::getContainerCode)
1044   - .collect(Collectors.toList());
1045   - if (unCompleteCombineContainerCodeList.contains(containerCode)) {
1046   - throw new ServiceException(StringUtils.format("传爆管入库失败,载具:{} 已存在未完成的组盘", containerCode));
  1012 + throw new ServiceException(StringUtils.format("传爆管入库组盘失败,盛具:{} 已和载具:{} 绑定", vehicleCode, containerByVehicle.getCode()));
1047 1013 }
1048 1014 ReceiptContainerHeader receiptContainerHeader = new ReceiptContainerHeader();
1049 1015 receiptContainerHeader.setWarehouseCode(QuantityConstant.DEFAULT_WAREHOUSE);
1050 1016 receiptContainerHeader.setCompanyCode(QuantityConstant.DEFAULT_COMPANY_CODE);
1051   - receiptContainerHeader.setContainerCode(containerCode);
  1017 + receiptContainerHeader.setContainerCode(container.getCode());
1052 1018 receiptContainerHeader.setContainerType(container.getContainerType());
1053 1019 receiptContainerHeader.setTaskType(QuantityConstant.TASK_TYPE_WHOLERECEIPT);
1054 1020 receiptContainerHeader.setStatus(QuantityConstant.RECEIPT_CONTAINER_TASK);
... ... @@ -1056,35 +1022,15 @@ public class InventoryHeaderServiceImpl extends ServiceImpl&lt;InventoryHeaderMappe
1056 1022 receiptContainerHeader.setVehicleTypeCode(vehicle.getVehicleType());
1057 1023 receiptContainerHeader.setVehicleCode(vehicle.getCode());
1058 1024 receiptContainerHeader.setPort(fromPort);
1059   - receiptContainerHeader.setToPort(locationCode);
1060   - receiptContainerHeader.setToLocation(locationCode);
1061 1025 receiptContainerHeader.setShipmentReferCode(shipmentReferCode);
1062 1026 if (!receiptContainerHeaderService.save(receiptContainerHeader)) {
1063   - throw new ServiceException("传爆管入库失败,保存入库组盘头表失败");
  1027 + throw new ServiceException("传爆管入库组盘失败,保存入库组盘头表失败");
1064 1028 }
1065 1029 // 组盘后,将载具和盛具绑定
1066 1030 if (!containerService.updateVehicle(container.getCode(), vehicle.getCode(), vehicle.getVehicleType())) {
1067   - throw new ServiceException("传爆管入库失败,载具与盛具绑定失败");
  1031 + throw new ServiceException("传爆管入库组盘失败,载具与盛具绑定失败");
1068 1032 }
1069 1033 List<ReceiptContainerDetail> receiptContainerDetailList = new LinkedList<>();
1070   - List<TaskDetail> taskDetailList = new LinkedList<>();
1071   -
1072   - // 3、创建任务头表:任务类型为入库,内部类型为1000
1073   - TaskHeader taskHeader = new TaskHeader();
1074   - BeanUtils.copyBeanProp(taskHeader, receiptContainerHeader);
1075   - taskHeader.setFromPort(receiptContainerHeader.getPort());
1076   - taskHeader.setPort(locationCode);
1077   - taskHeader.setToLocation(locationCode);
1078   - taskHeader.setZoneCode(location.getZoneCode());
1079   - taskHeader.setVehicleType(receiptContainerHeader.getVehicleTypeCode());
1080   - taskHeader.setAllocationHeadId(receiptContainerHeader.getId());
1081   - taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD);
1082   - taskHeader.setTaskType(QuantityConstant.TASK_TYPE_WHOLERECEIPT);
1083   - taskHeader.setInternalTaskType(QuantityConstant.TASK_INTENERTYPE_OVERSTATION);
1084   - success = taskHeaderService.save(taskHeader);
1085   - if (!success) {
1086   - throw new ServiceException("传爆管入库失败,保存任务头表失败");
1087   - }
1088 1034 materialDataList.forEach(materialData -> {
1089 1035 // 1.1 创建调拨入库单明细
1090 1036 ReceiptDetail receiptDetail = new ReceiptDetail();
... ... @@ -1111,7 +1057,7 @@ public class InventoryHeaderServiceImpl extends ServiceImpl&lt;InventoryHeaderMappe
1111 1057 receiptDetail.setInventorySts(QuantityConstant.INVENTORY_STATUS_OK);
1112 1058 boolean save = receiptDetailService.save(receiptDetail);
1113 1059 if (!save) {
1114   - throw new ServiceException("传爆管入库失败,保存入库单明细失败");
  1060 + throw new ServiceException("传爆管入库组盘失败,保存入库单明细失败");
1115 1061 }
1116 1062 // 2.1 创建组盘明细
1117 1063 ReceiptContainerDetail receiptContainerDetail = new ReceiptContainerDetail();
... ... @@ -1123,42 +1069,11 @@ public class InventoryHeaderServiceImpl extends ServiceImpl&lt;InventoryHeaderMappe
1123 1069 receiptContainerDetail.setContainerCode(receiptContainerHeader.getContainerCode());
1124 1070 receiptContainerDetail.setContainerType(receiptContainerHeader.getContainerType());
1125 1071 receiptContainerDetailList.add(receiptContainerDetail);
1126   -
1127   - // 3.1、创建任务明细
1128   - TaskDetail taskDetail = new TaskDetail();
1129   - BeanUtils.copyBeanProp(taskDetail, receiptContainerDetail);
1130   - taskDetail.setBillDetailId(receiptDetail.getId());
1131   - taskDetail.setBillCode(receiptDetail.getReceiptCode());
1132   - taskDetail.setTaskId(taskHeader.getId());
1133   - taskDetail.setTaskType(taskHeader.getTaskType());
1134   - taskDetail.setInternalTaskType(taskHeader.getInternalTaskType());
1135   - taskDetail.setAllocationId(receiptContainerDetail.getId());
1136   - taskDetail.setVehicleCode(vehicle.getCode());
1137   - taskDetail.setToLocation(locationCode);
1138   - taskDetailList.add(taskDetail);
1139 1072 });
1140   -
1141 1073 success = receiptContainerDetailService.saveBatch(receiptContainerDetailList);
1142 1074 if (!success) {
1143   - throw new ServiceException("传爆管入库失败,保存入库单明细失败");
1144   - }
1145   -
1146   - success = taskDetailService.saveBatch(taskDetailList);
1147   - if (!success) {
1148   - throw new ServiceException("传爆管入库失败,保存任务明细失败");
1149   - }
1150   -
1151   - // 4、锁定载具和库位
1152   - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK);
1153   - if (!success) {
1154   - throw new ServiceException("传爆管入库失败,锁定库位失败");
  1075 + throw new ServiceException("传爆管入库组盘失败,保存入库单明细失败");
1155 1076 }
1156   - success = locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_LOCK);
1157   - if (!success) {
1158   - throw new ServiceException("传爆管入库失败,锁定载具失败");
1159   - }
1160   -
1161   - // 5、更新虚拟库存的锁定数量,任务完成时,依据是否有任务数量删除库存
1162 1077 LambdaQueryWrapper<InventoryDetail> queryWrapper = Wrappers.lambdaQuery();
1163 1078 queryWrapper.eq(InventoryDetail::getMaterialCode, materialCode)
1164 1079 .eq(InventoryDetail::getShipmentReferCode, shipmentReferCode)
... ... @@ -1166,19 +1081,9 @@ public class InventoryHeaderServiceImpl extends ServiceImpl&lt;InventoryHeaderMappe
1166 1081 .apply("qty != taskQty");
1167 1082 List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(queryWrapper);
1168 1083 if (materialDataList.size() > inventoryDetailList.size()) {
1169   - throw new ServiceException(StringUtils.format("传爆管入库失败,调拨数量:{} 大于虚拟库库存可用数量:{}",
  1084 + throw new ServiceException(StringUtils.format("传爆管入库组盘失败,调拨数量:{} 大于虚拟库库存可用数量:{}",
1170 1085 materialDataList.size(), inventoryDetailList.size()));
1171 1086 }
1172   - inventoryDetailList = inventoryDetailList.stream().limit(materialDataList.size()).collect(Collectors.toList());
1173   - inventoryDetailList.forEach(inventoryDetail -> {
1174   - LambdaUpdateWrapper<InventoryDetail> updateWrapper = Wrappers.lambdaUpdate();
1175   - updateWrapper.eq(InventoryDetail::getId, inventoryDetail.getId())
1176   - .set(InventoryDetail::getTaskQty, inventoryDetail.getQty());
1177   - boolean updateSuccess = inventoryDetailService.update(updateWrapper);
1178   - if (!updateSuccess) {
1179   - throw new ServiceException("传爆管入库失败,更新虚拟库库存明细数量失败");
1180   - }
1181   - });
1182 1087 return AjaxResult.success("传爆管入库成功");
1183 1088 }
1184 1089  
... ... @@ -1466,4 +1371,147 @@ public class InventoryHeaderServiceImpl extends ServiceImpl&lt;InventoryHeaderMappe
1466 1371 }
1467 1372 });
1468 1373 }
  1374 +
  1375 + @Override
  1376 + @Transactional(rollbackFor = Exception.class)
  1377 + public AjaxResult cbgReplenishInventory(CbgReplenishDto cbgReplenishDto) {
  1378 + String containerCode = cbgReplenishDto.getContainerCode();
  1379 + String locationCode = cbgReplenishDto.getLocationCode();
  1380 + String vehicleCode = cbgReplenishDto.getVehicleCode();
  1381 + String fromPort = cbgReplenishDto.getFromPort();
  1382 + // 校验载具
  1383 + Container container = containerService.getContainerByCode(containerCode);
  1384 + if (container == null) {
  1385 + throw new ServiceException(StringUtils.format("传爆管入库组盘失败,根据载具编码:{} 未找到载具", containerCode));
  1386 + }
  1387 + if (QuantityConstant.STATUS_CONTAINER_LOCK.equals(container.getStatus())) {
  1388 + throw new ServiceException(StringUtils.format("传爆管入库组盘失败,载具:{} 已锁定", containerCode));
  1389 + }
  1390 + if (StringUtils.isNotEmpty(container.getVehicleCode())) {
  1391 + throw new ServiceException(StringUtils.format("传爆管入库组盘失败,载具:{} 已和盛具:{} 绑定", containerCode, container.getVehicleCode()));
  1392 + }
  1393 + if (StringUtils.isNotEmpty(container.getLocationCode())) {
  1394 + throw new ServiceException(StringUtils.format("传爆管入库组盘失败,载具:{} 已在库位:{} 上", containerCode, container.getLocationCode()));
  1395 + }
  1396 + Location location = locationService.getLocationByCode(locationCode);
  1397 + if (location == null) {
  1398 + throw new ServiceException(StringUtils.format("传爆管入库组盘失败,目标库位:{} 不存在", locationCode));
  1399 + }
  1400 + if (StringUtils.isNotEmpty(location.getContainerCode())) {
  1401 + throw new ServiceException(StringUtils.format("传爆管入库组盘失败,库位:{} 上已存在载具:{}", locationCode, location.getContainerCode()));
  1402 + }
  1403 + List<TaskHeader> unCompleteTaskList = taskHeaderService.getUnCompleteTaskList();
  1404 + List<String> unCompleteTaskContainerCodeList = unCompleteTaskList.stream()
  1405 + .map(TaskHeader::getContainerCode)
  1406 + .collect(Collectors.toList());
  1407 + if (unCompleteTaskContainerCodeList.contains(containerCode)) {
  1408 + throw new ServiceException(StringUtils.format("传爆管补料失败,载具:{} 已存在未完成的任务", containerCode));
  1409 + }
  1410 + // 校验盛具
  1411 + Vehicle vehicle = vehicleService.getVehicleByCode(vehicleCode);
  1412 + if (vehicle == null) {
  1413 + throw new ServiceException(StringUtils.format("传爆管补料失败,根据盛具编码:{} 未找到盛具", vehicleCode));
  1414 + }
  1415 + List<ReceiptContainerHeader> unCompleteCombineList = receiptContainerHeaderService.getUnCompleteCombineList();
  1416 + List<String> unCompleteCombineContainerCodeList = unCompleteCombineList.stream()
  1417 + .map(ReceiptContainerHeader::getContainerCode)
  1418 + .collect(Collectors.toList());
  1419 + if (unCompleteCombineContainerCodeList.contains(containerCode)) {
  1420 + throw new ServiceException(StringUtils.format("传爆管补料失败,载具:{} 已存在未完成的组盘", containerCode));
  1421 + }
  1422 + // 1、根据盛具编码查询组盘头表
  1423 + LambdaQueryWrapper<ReceiptContainerHeader> vehicleQueryWrapper = Wrappers.lambdaQuery();
  1424 + vehicleQueryWrapper
  1425 + .eq(ReceiptContainerHeader::getVehicleCode, vehicleCode)
  1426 + .lt(ReceiptContainerHeader::getStatus, QuantityConstant.RECEIPT_CONTAINER_FINISHED);
  1427 + ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getOne(vehicleQueryWrapper);
  1428 + if (receiptContainerHeader == null) {
  1429 + throw new ServiceException(StringUtils.format("传爆管补料失败,盛具:{} 不存在未完成的组盘", vehicle.getCode()));
  1430 + }
  1431 + ReceiptContainerHeader updateReceiptContainerHeader = new ReceiptContainerHeader();
  1432 + updateReceiptContainerHeader.setId(receiptContainerHeader.getId());
  1433 + updateReceiptContainerHeader.setPort(fromPort);
  1434 + updateReceiptContainerHeader.setContainerCode(containerCode);
  1435 + updateReceiptContainerHeader.setToLocation(locationCode);
  1436 + boolean success = receiptContainerHeaderService.updateById(updateReceiptContainerHeader);
  1437 + // 2、创建任务头表:任务类型为入库,内部类型为1000
  1438 + TaskHeader taskHeader = new TaskHeader();
  1439 + BeanUtils.copyBeanProp(taskHeader, receiptContainerHeader);
  1440 + taskHeader.setFromPort(receiptContainerHeader.getPort());
  1441 + taskHeader.setPort(locationCode);
  1442 + taskHeader.setFromPort(fromPort);
  1443 + taskHeader.setToLocation(locationCode);
  1444 + taskHeader.setContainerCode(containerCode);
  1445 + taskHeader.setZoneCode(location.getZoneCode());
  1446 + taskHeader.setVehicleType(receiptContainerHeader.getVehicleTypeCode());
  1447 + taskHeader.setAllocationHeadId(receiptContainerHeader.getId());
  1448 + taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD);
  1449 + taskHeader.setTaskType(QuantityConstant.TASK_TYPE_WHOLERECEIPT);
  1450 + taskHeader.setInternalTaskType(QuantityConstant.TASK_INTENERTYPE_OVERSTATION);
  1451 + success = taskHeaderService.save(taskHeader);
  1452 + if (!success) {
  1453 + throw new ServiceException("传爆管补料失败,保存任务头表失败");
  1454 + }
  1455 + // 2.1、创建任务明细
  1456 + List<TaskDetail> taskDetailList = new ArrayList<>();
  1457 + List<ReceiptContainerDetail> receiptContainerDetailList = receiptContainerDetailService.getByHeaderId(receiptContainerHeader.getId());
  1458 + receiptContainerDetailList.forEach(receiptContainerDetail -> {
  1459 + TaskDetail taskDetail = new TaskDetail();
  1460 + BeanUtils.copyBeanProp(taskDetail, receiptContainerDetail);
  1461 + taskDetail.setBillDetailId(receiptContainerDetail.getReceiptDetailId());
  1462 + taskDetail.setBillCode(receiptContainerDetail.getReceiptCode());
  1463 + taskDetail.setTaskId(taskHeader.getId());
  1464 + taskDetail.setTaskType(taskHeader.getTaskType());
  1465 + taskDetail.setInternalTaskType(taskHeader.getInternalTaskType());
  1466 + taskDetail.setAllocationId(receiptContainerDetail.getId());
  1467 + taskDetail.setVehicleCode(vehicle.getCode());
  1468 + taskDetail.setToLocation(locationCode);
  1469 + taskDetailList.add(taskDetail);
  1470 + });
  1471 + success = taskDetailService.saveBatch(taskDetailList);
  1472 + if (!success) {
  1473 + throw new ServiceException("传爆管补料失败,保存任务明细失败");
  1474 + }
  1475 + // 3、锁定载具和库位
  1476 + success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK);
  1477 + if (!success) {
  1478 + throw new ServiceException("传爆管补料失败,锁定库位失败");
  1479 + }
  1480 + success = locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_LOCK);
  1481 + if (!success) {
  1482 + throw new ServiceException("传爆管补料失败,锁定载具失败");
  1483 + }
  1484 + // 4、载具和盛具绑定
  1485 + success = containerService.updateVehicle(container.getCode(), vehicle.getCode(), container.getWarehouseCode());
  1486 + if (!success) {
  1487 + throw new ServiceException("传爆管补料失败,载具和盛具绑定失败");
  1488 + }
  1489 + // 5、更新虚拟库存的锁定数量,任务完成时,依据是否有任务数量删除库存
  1490 + // 组盘只有一种物料
  1491 + String materialCode = receiptContainerDetailList.stream()
  1492 + .map(ReceiptContainerDetail::getMaterialCode)
  1493 + .distinct().findFirst()
  1494 + .orElse(null);
  1495 + LambdaQueryWrapper<InventoryDetail> queryWrapper = Wrappers.lambdaQuery();
  1496 + queryWrapper.eq(InventoryDetail::getMaterialCode, materialCode)
  1497 + .eq(InventoryDetail::getShipmentReferCode, receiptContainerHeader.getShipmentReferCode())
  1498 + .eq(InventoryDetail::getOrderCode, receiptContainerHeader.getOrderCode())
  1499 + .apply("qty != taskQty");
  1500 + List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(queryWrapper);
  1501 + if (receiptContainerDetailList.size() > inventoryDetailList.size()) {
  1502 + throw new ServiceException(StringUtils.format("传爆管补料失败,组盘数量:{} 大于虚拟库库存可用数量:{}",
  1503 + receiptContainerDetailList.size(), inventoryDetailList.size()));
  1504 + }
  1505 + inventoryDetailList = inventoryDetailList.stream().limit(receiptContainerDetailList.size()).collect(Collectors.toList());
  1506 + inventoryDetailList.forEach(inventoryDetail -> {
  1507 + LambdaUpdateWrapper<InventoryDetail> updateWrapper = Wrappers.lambdaUpdate();
  1508 + updateWrapper.eq(InventoryDetail::getId, inventoryDetail.getId())
  1509 + .set(InventoryDetail::getTaskQty, inventoryDetail.getQty());
  1510 + boolean updateSuccess = inventoryDetailService.update(updateWrapper);
  1511 + if (!updateSuccess) {
  1512 + throw new ServiceException("传爆管补料失败,更新虚拟库库存明细数量失败");
  1513 + }
  1514 + });
  1515 + return AjaxResult.success("传爆管补料成功");
  1516 + }
1469 1517 }
1470 1518 \ No newline at end of file
... ...
src/main/resources/templates/inventory/inventoryHeader/cbgReceipt.html
... ... @@ -24,34 +24,12 @@
24 24 </div>
25 25 </div>
26 26 <div class="form-group">
27   - <label class="col-sm-1 control-label">载具编码:</label>
28   - <div class="col-sm-5">
29   - <input class="form-control" type="text" style="width: 370px; float: left" placeholder="请扫描载具编码" name="containerCode"
30   - id="containerCode"/>
31   - </div>
32 27 <label class="col-sm-1 control-label">盛具编码:</label>
33 28 <div class="col-sm-5">
34 29 <input class="form-control" placeholder="请扫描盛具编码" style="width: 370px; float: left" name="vehicleCode"
35 30 id="vehicleCode"/>
36 31 </div>
37 32 </div>
38   - <div class="form-group">
39   - <label class="col-sm-1 control-label">上料口:</label>
40   - <div class="col-sm-5">
41   - <select id="fromPort" name="fromPort" class="form-control" style="width: 370px; float: left" disabled="disabled">
42   - <option>请选择上料口</option>
43   - <option th:each="item : ${stations}"
44   - th:text="${item['name']}"
45   - th:value="${item['code']}"
46   - th:selected="${item['code'] eq user.station}">
47   - </option>
48   - </select>
49   - </div>
50   - <label class="col-sm-1 control-label">库位编码:</label>
51   - <div class="col-sm-5">
52   - <input th:value="${locationCode}" class="form-control" style="width: 370px; float: left" disabled="disabled" id="locationCode" name="locationCode" type="text">
53   - </div>
54   - </div>
55 33 <div class="col-sm-12 select-info">
56 34 <div id="myTabContent" class="tab-content">
57 35 <div class="tab-pane fade in active" id="tab1">
... ... @@ -294,10 +272,7 @@
294 272 function cbgReceipt() {
295 273 let orderCode = $("#orderCode").val();
296 274 let shipmentReferCode = $("#shipmentReferCode").val();
297   - let containerCode = $("#containerCode").val()
298 275 let vehicleCode = $("#vehicleCode").val()
299   - // let locationCode = $("#locationCode option:selected").val()
300   - let locationCode = $("#locationCode").val()
301 276 let fromPort = $("#fromPort option:selected").val()
302 277 let materialDataList = []
303 278 if (isEmpty(orderCode)) {
... ... @@ -308,20 +283,12 @@
308 283 $.modal.msgWarning("请选择或输入领料单号");
309 284 return;
310 285 }
311   - if (isEmpty(containerCode)) {
312   - $.modal.msgWarning("请扫描载具编码");
313   - return;
314   - }
315 286 if (isEmpty(vehicleCode)) {
316 287 $.modal.msgWarning("请扫描盛具编码");
317 288 return;
318 289 }
319   - if (isEmpty(fromPort)) {
320   - $.modal.msgWarning("请选择上料口");
321   - return;
322   - }
323 290 if (isEmpty(tableDataList)) {
324   - $.modal.msgWarning("入库物料为空");
  291 + $.modal.msgWarning("入库物料信息为空");
325 292 return;
326 293 }
327 294 tableDataList.forEach(data => {
... ... @@ -338,10 +305,8 @@
338 305 let json = {
339 306 "orderCode": orderCode,
340 307 "shipmentReferCode": shipmentReferCode,
341   - "containerCode": containerCode,
342 308 "vehicleCode": vehicleCode,
343 309 "fromPort": fromPort,
344   - "locationCode": locationCode,
345 310 "materialDataList": materialDataList
346 311 }
347 312 $.ajax({
... ... @@ -393,15 +358,6 @@
393 358 }
394 359 }
395 360  
396   - // 清除表格信息
397   - function clearTableData() {
398   - tableDataList = [];
399   - if (!isEmpty(vehicle)) {
400   - tempCoordinateList = JSON.parse(JSON.stringify(forwardSortXY(vehicle.coordinateList)));
401   - }
402   - loadTable();
403   - }
404   -
405 361 /**
406 362 * 对坐标进行排序
407 363 * 规则:先 y 正向排序,后x 正向排序,
... ... @@ -430,7 +386,6 @@
430 386 $("#vehicleCode").focus();
431 387 $.modal.msgWarning("请先扫描盛具码")
432 388 clearTracingNo();
433   - clearQty();
434 389 return true;
435 390 }
436 391 return false;
... ...
src/main/resources/templates/inventory/inventoryHeader/cbgReplenish.html 0 → 100644
  1 +<!DOCTYPE HTML>
  2 +<html lang="zh" xmlns:th="http://www.thymeleaf.org">
  3 +<meta charset="utf-8">
  4 +<head>
  5 + <th:block th:include="include :: header"/>
  6 + <th:block th:include="include :: select2-css"/>
  7 + <script src="/wms/js/jquery.min.js"></script>
  8 +</head>
  9 +<body class="white-bg">
  10 +<div class="wrapper wrapper-content animated fadeInRight ibox-content">
  11 + <form class="form-horizontal m" id="form-cbgReplenish">
  12 + <div class="form-group">
  13 + <label class="col-sm-3 control-label">载具编码:</label>
  14 + <div class="col-sm-8">
  15 + <input id="containerCode" placeholder="请扫描或输入载具编码" name="containerCode" class="form-control"
  16 + type="text">
  17 + </div>
  18 + </div>
  19 + <div class="form-group">
  20 + <label class="col-sm-3 control-label">盛具编码:</label>
  21 + <div class="col-sm-8">
  22 + <input id="vehicleCode" placeholder="请扫描或输入盛具编码" name="vehicleCode" class="form-control"
  23 + type="text">
  24 + </div>
  25 + </div>
  26 + <div class="form-group">
  27 + <label class="col-sm-3 control-label">库位编码:</label>
  28 + <div class="col-sm-8">
  29 + <input th:value="${locationCode}" class="form-control" readonly="readonly" id="locationCode" name="locationCode" type="text">
  30 + </div>
  31 + </div>
  32 + <div class="form-group">
  33 + <label class="col-sm-3 control-label">上料口:</label>
  34 + <div class="col-sm-8">
  35 + <select id="fromPort" name="fromPort" class="form-control">
  36 + <option>请选择上料口</option>
  37 + <option th:each="item : ${stations}"
  38 + th:text="${item['name']}"
  39 + th:value="${item['code']}"
  40 + th:selected="${item['code'] eq user.station}">
  41 + </option>
  42 + </select>
  43 + </div>
  44 + </div>
  45 + <div class="form-group">
  46 + <div class="form-control-static col-sm-offset-9" style="margin-left:62%; margin-top: 20%">
  47 + <button type="submit" class="btn btn-primary">提交</button>
  48 + <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
  49 + </div>
  50 + </div>
  51 + </form>
  52 +</div>
  53 +<th:block th:include="include :: footer"/>
  54 +<th:block th:include="include :: select2-js"/>
  55 +<script type="text/javascript">
  56 + var prefix = ctx + "inventory/inventoryHeader"
  57 + $("#form-cbgReplenish").validate({
  58 + rules: {
  59 + containerCode: {
  60 + required: true,
  61 + },
  62 + vehicleCode: {
  63 + required: true,
  64 + },
  65 + },
  66 + submitHandler: function () {
  67 + let $fromPort = $('#fromPort');
  68 + if ($fromPort.val() === null || $fromPort.val() === undefined || $fromPort.val() === "") {
  69 + $.modal.msgWarning("请选择上料口");
  70 + return
  71 + }
  72 + let obj = {
  73 + containerCode: $("#containerCode").val(),
  74 + vehicleCode: $("#vehicleCode").val(),
  75 + fromPort: $fromPort.val(),
  76 + locationCode: $("#locationCode").val(),
  77 + }
  78 + $.ajax({
  79 + cache: true,
  80 + type: "POST",
  81 + dataType: "json",
  82 + url: "/wms/inventory/inventoryHeader/cbgReplenish",
  83 + async: false,
  84 + data: JSON.stringify(obj),
  85 + contentType: "application/json",
  86 + error: function (result) {
  87 + $.operate.ajaxSuccess(result);
  88 + },
  89 + success: function (result) {
  90 + if (result.code === web_status.SUCCESS) {
  91 + layer.msg("保存成功,正在刷新数据请稍后……", {
  92 + icon: $.modal.icon(modal_status.SUCCESS),
  93 + time: 500,
  94 + shade: [0.1, '#8F8F8F']
  95 + }
  96 + )
  97 + $.modal.close();
  98 + } else {
  99 + $.modal.alertError(result.msg);
  100 + }
  101 + }
  102 + });
  103 + }
  104 + });
  105 +</script>
  106 +</body>
  107 +</html>
... ...
src/main/resources/templates/inventory/inventoryHeader/inventoryHeaderCbgSolid.html
... ... @@ -12,6 +12,9 @@
12 12 <a class="btn btn-outline btn-info btn-rounded" onclick="backVirtual()">
13 13 <i class="fa fa-trash"></i> 退回虚拟库
14 14 </a>
  15 + <a class="btn btn-outline btn-info btn-rounded" onclick="cbgReceipt()">
  16 + <i class="fa fa-trash"></i> 传爆管组盘
  17 + </a>
15 18 </div>
16 19 <div class="col-sm-12 select-table">
17 20 <ul id="myTab" class="nav nav-tabs">
... ... @@ -117,7 +120,7 @@
117 120 align: 'center',
118 121 formatter: function (value, row, index) {
119 122 let actions = [];
120   - actions.push('<a class="btn btn-success btn-xs" href="#" onclick="cbgReceipt(\'' + row.locationCode + '\')"><i class="fa fa-edit"></i>补料</a> ');
  123 + actions.push('<a class="btn btn-success btn-xs" href="#" onclick="replenish(\'' + row.locationCode + '\')"><i class="fa fa-edit"></i>补料</a> ');
121 124 return actions.join('');
122 125 }
123 126 }
... ... @@ -126,10 +129,6 @@
126 129 $.table.init(options);
127 130 });
128 131  
129   - function cbgReceipt(locationCode) {
130   - $.modal.openFull("传爆管入库", prefix + "/cbgReceipt/" + locationCode)
131   - }
132   -
133 132 // 空托出库
134 133 function cbgEmptyOut() {
135 134 $.modal.confirm("确定将空托盘都出库吗?", function () {
... ... @@ -185,6 +184,14 @@
185 184 })
186 185 }
187 186  
  187 + function cbgReceipt() {
  188 + $.modal.openFull("传爆管组盘", prefix + "/cbgReceipt")
  189 + }
  190 +
  191 + function replenish(locationCode) {
  192 + $.modal.open("传爆管入库", prefix + "/cbgReplenish/" + locationCode)
  193 + }
  194 +
188 195 // 查询条件
189 196 function queryParams(params) {
190 197 return {
... ...