Commit f487c48d3ac05c8309da2279bede21d848fda8c1

Authored by 肖超群
1 parent c40a570d

按库区出库, 优化自动出库

ant-design-vue-jeecg/src/views/system/shipment/ShipmentHeaderList.vue
... ... @@ -220,7 +220,7 @@
220 220 <a v-if="((record.firstStatus >= 15 && record.firstStatus != '20' && record.lastStatus <= 200))
221 221 || (flowOff == '0' && record.lastStatus <= 200)" @click="autoShipmentCombine(record)" v-has="'shipmentHeader:autoShipmentCombine'"><a-button type="primary">自动配盘</a-button><a-divider type="vertical"/></a>
222 222 <a v-if="((record.firstStatus >= 15 && record.firstStatus != '20' && record.lastStatus <= 200))
223   - || (flowOff == '0' && record.lastStatus <= 200)" @click="openAutoShipmentCombine(record)" v-has="'shipmentHeader:autoShipment'"><a-button type="primary">自动出库</a-button></a>
  223 + || (flowOff == '0' && record.lastStatus <= 200)" @click="autoShipment(record)" v-has="'shipmentHeader:autoShipment'"><a-button type="primary">自动出库</a-button></a>
224 224 <a-dropdown v-if="(record.firstStatus > 0 && record.firstStatus <= 20 && flowOff=='1') || (record.firstStatus == 0 && record.lastStatus == 0 && record.referCode == null)">
225 225 <a class="ant-dropdown-link"><a-divider type="vertical"/>更多 <a-icon type="down"/></a>
226 226 <a-menu slot="overlay">
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java
... ... @@ -16,6 +16,7 @@ import org.jeecg.modules.wms.config.container.entity.Container;
16 16 import org.jeecg.modules.wms.config.container.service.IContainerService;
17 17 import org.jeecg.modules.wms.config.containerCapacity.entity.ContainerCapacity;
18 18 import org.jeecg.modules.wms.config.containerCapacity.service.IContainerCapacityService;
  19 +import org.jeecg.modules.wms.config.parameterConfiguration.service.IParameterConfigurationService;
19 20 import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail;
20 21 import org.jeecg.modules.wms.inventory.inventoryHeader.mapper.InventoryDetailMapper;
21 22 import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService;
... ... @@ -56,6 +57,9 @@ public class InventoryDetailServiceImpl extends ServiceImpl&lt;InventoryDetailMappe
56 57 @Resource
57 58 private IInventoryHeaderService inventoryHeaderService;
58 59  
  60 + @Resource
  61 + private IParameterConfigurationService parameterConfigurationService;
  62 +
59 63 @Override
60 64 public List<InventoryDetail> selectByMainId(String mainId) {
61 65 return inventoryDetailMapper.selectByMainId(mainId);
... ... @@ -139,6 +143,14 @@ public class InventoryDetailServiceImpl extends ServiceImpl&lt;InventoryDetailMappe
139 143 .eq(StringUtils.isNotEmpty(inventoryDetail.getLot()), InventoryDetail::getLot, inventoryDetail.getLot())
140 144 .eq(StringUtils.isNotEmpty(inventoryDetail.getProject()), InventoryDetail::getProject, inventoryDetail.getLot())
141 145 .eq(InventoryDetail::getCompanyCode, inventoryDetail.getCompanyCode());
  146 +
  147 + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_SHIPMENT_ZONE);
  148 + if (StringUtils.isNotEmpty(value)) {
  149 + int shipmentZoneRule = Integer.parseInt(value);
  150 + if (shipmentZoneRule == QuantityConstant.SHIPMENT_BY_ZONE) {
  151 + inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getZoneCode, inventoryDetail.getZoneCode());
  152 + }
  153 + }
142 154 List<InventoryDetail> inventoryDetailList = list(inventoryDetailLambdaQueryWrapper);
143 155 if (inventoryDetailList.size() == 0) {
144 156 return BigDecimal.ZERO;
... ... @@ -156,6 +168,13 @@ public class InventoryDetailServiceImpl extends ServiceImpl&lt;InventoryDetailMappe
156 168 .eq(StringUtils.isNotEmpty(inventoryDetail.getLot()), InventoryDetail::getLot, inventoryDetail.getLot())
157 169 .eq(StringUtils.isNotEmpty(inventoryDetail.getProject()), InventoryDetail::getProject, inventoryDetail.getLot())
158 170 .eq(InventoryDetail::getCompanyCode, inventoryDetail.getCompanyCode());
  171 + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_SHIPMENT_ZONE);
  172 + if (StringUtils.isNotEmpty(value)) {
  173 + int shipmentZoneRule = Integer.parseInt(value);
  174 + if (shipmentZoneRule == QuantityConstant.SHIPMENT_BY_ZONE) {
  175 + inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getZoneCode, inventoryDetail.getZoneCode());
  176 + }
  177 + }
159 178 List<InventoryDetail> inventoryDetailList = list(inventoryDetailLambdaQueryWrapper);
160 179 if (inventoryDetailList.size() == 0) {
161 180 return BigDecimal.ZERO;
... ... @@ -176,6 +195,13 @@ public class InventoryDetailServiceImpl extends ServiceImpl&lt;InventoryDetailMappe
176 195 .eq(StringUtils.isNotEmpty(inventoryDetail.getProject()), InventoryDetail::getProject, inventoryDetail.getLot())
177 196 .eq(InventoryDetail::getEnable, QuantityConstant.INVENTORY_DETAIL_STATUS_ENABLE)
178 197 .eq(InventoryDetail::getContainerStatus, QuantityConstant.STATUS_CONTAINER_EMPTY).eq(InventoryDetail::getCompanyCode, inventoryDetail.getCompanyCode());
  198 + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_SHIPMENT_ZONE);
  199 + if (StringUtils.isNotEmpty(value)) {
  200 + int shipmentZoneRule = Integer.parseInt(value);
  201 + if (shipmentZoneRule == QuantityConstant.SHIPMENT_BY_ZONE) {
  202 + inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getZoneCode, inventoryDetail.getZoneCode());
  203 + }
  204 + }
179 205 List<InventoryDetail> inventoryDetailList = list(inventoryDetailLambdaQueryWrapper);
180 206 if (inventoryDetailList.size() == 0) {
181 207 return BigDecimal.ZERO;
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java
... ... @@ -130,6 +130,13 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
130 130 .eq(InventoryDetail::getEnable, QuantityConstant.INVENTORY_DETAIL_STATUS_ENABLE)
131 131 .eq(StringUtils.isNotEmpty(zoneCode), InventoryDetail::getZoneCode, zoneCode)
132 132 .eq(InventoryDetail::getContainerStatus, QuantityConstant.STATUS_CONTAINER_EMPTY);
  133 + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_SHIPMENT_ZONE);
  134 + if (StringUtils.isNotEmpty(value)) {
  135 + int shipmentZoneRule = Integer.parseInt(value);
  136 + if (shipmentZoneRule == QuantityConstant.SHIPMENT_BY_ZONE) {
  137 + inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getZoneCode, zoneCode);
  138 + }
  139 + }
133 140 List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
134 141 return inventoryDetailList;
135 142 }
... ... @@ -159,6 +166,13 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
159 166 .eq(InventoryDetail::getEnable, QuantityConstant.INVENTORY_DETAIL_STATUS_ENABLE)
160 167 .eq(StringUtils.isNotEmpty(zoneCode), InventoryDetail::getZoneCode, zoneCode).eq(InventoryDetail::getContainerCode, containerCode)
161 168 .eq(InventoryDetail::getContainerStatus, QuantityConstant.STATUS_CONTAINER_EMPTY);
  169 + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_SHIPMENT_ZONE);
  170 + if (StringUtils.isNotEmpty(value)) {
  171 + int shipmentZoneRule = Integer.parseInt(value);
  172 + if (shipmentZoneRule == QuantityConstant.SHIPMENT_BY_ZONE) {
  173 + inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getZoneCode, zoneCode);
  174 + }
  175 + }
162 176 List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
163 177 return inventoryDetailList;
164 178 }
... ... @@ -170,6 +184,7 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
170 184 String companyCode = shipmentDetail.getCompanyCode();
171 185 String materialCode = shipmentDetail.getMaterialCode();
172 186 String inventoryStatus = shipmentDetail.getInventoryStatus();
  187 + String zoneCode = shipmentDetail.getZoneCode();
173 188 if (StringUtils.isEmpty(warehouseCode)) {
174 189 throw new JeecgBootException("寻找库存详情时,出库详情没有仓库编码");
175 190 }
... ... @@ -186,6 +201,13 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
186 201 inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getWarehouseCode, warehouseCode).eq(InventoryDetail::getCompanyCode, companyCode)
187 202 .eq(InventoryDetail::getMaterialCode, materialCode).eq(InventoryDetail::getInventoryStatus, inventoryStatus)
188 203 .eq(InventoryDetail::getEnable, QuantityConstant.INVENTORY_DETAIL_STATUS_ENABLE);
  204 + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_SHIPMENT_ZONE);
  205 + if (StringUtils.isNotEmpty(value)) {
  206 + int shipmentZoneRule = Integer.parseInt(value);
  207 + if (shipmentZoneRule == QuantityConstant.SHIPMENT_BY_ZONE) {
  208 + inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getZoneCode, zoneCode);
  209 + }
  210 + }
189 211 List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
190 212 return inventoryDetailList;
191 213 }
... ... @@ -316,6 +338,18 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
316 338 if (inventoryDetail == null) {
317 339 return Result.error("配盘时,库存未找到");
318 340 }
  341 + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_SHIPMENT_ZONE);
  342 + if (StringUtils.isNotEmpty(value)) {
  343 + int shipmentZoneRule = Integer.parseInt(value);
  344 + if (shipmentZoneRule == QuantityConstant.SHIPMENT_BY_ZONE) {
  345 + if (StringUtils.isEmpty(inventoryDetail.getZoneCode())) {
  346 + return Result.error("配盘时,库存没有库区");
  347 + }
  348 + if (!inventoryDetail.getZoneCode().equals(shipmentDetail.getZoneCode())) {
  349 + return Result.error("配盘时,库存和库区不匹配");
  350 + }
  351 + }
  352 + }
319 353 String locationCode = inventoryDetail.getLocationCode();
320 354 String containerCode = inventoryDetail.getContainerCode();
321 355 String warehouseCode = inventoryDetail.getWarehouseCode();
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java
... ... @@ -214,6 +214,7 @@ public class ShipmentHeaderController extends JeecgController&lt;ShipmentHeader, IS
214 214 inventoryDetail.setWarehouseCode(shipmentDetail1.getWarehouseCode());
215 215 inventoryDetail.setInventoryStatus(shipmentDetail1.getInventoryStatus());
216 216 inventoryDetail.setCompanyCode(shipmentDetail1.getCompanyCode());
  217 + inventoryDetail.setZoneCode(shipmentDetail1.getZoneCode());
217 218 inventoryDetail.setBatch(shipmentDetail1.getBatch());
218 219 inventoryDetail.setProject(shipmentDetail1.getProject());
219 220 inventoryDetail.setLot(shipmentDetail1.getLot());
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/impl/ShipmentHeaderServiceImpl.java
... ... @@ -123,6 +123,7 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl&lt;ShipmentHeaderMapper,
123 123 this.delMain(id.toString());
124 124 }
125 125 }
  126 +
126 127 @Override
127 128 @Transactional(rollbackFor = JeecgBootException.class)
128 129 @OperationLog(bizId = "#shipmentHeader == null ? '' : #shipmentHeader.getCode()", bizType = "'出库单追踪'", tag = "'出库单新增'",
... ... @@ -351,24 +352,28 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl&lt;ShipmentHeaderMapper,
351 352 if (StringUtils.isEmpty(shipmentCode)) {
352 353 return Result.error("自动出库, 出库单编码为空");
353 354 }
354   - if (StringUtils.isEmpty(toPort)) {
355   - return Result.error("自动出库, 出库口为空");
356   - }
  355 +// if (StringUtils.isEmpty(toPort)) {
  356 +// return Result.error("自动出库, 出库口为空");
  357 +// }
357 358 if (StringUtils.isEmpty(warehouseCode)) {
358 359 return Result.error("自动出库, 仓库编码为空");
359 360 }
360   - Port port = portService.getPortByCode(toPort, warehouseCode);
361   - if (port == null) {
362   - return Result.error("自动出库, 没有找到出库口");
363   - }
364   - int type = Integer.parseInt(port.getType());
365   - if (type == QuantityConstant.PORT_TYPE_IN) {
366   - return Result.error("自动出库, 不能选择入库口来出库");
367   - }
  361 +// Port port = portService.getPortByCode(toPort, warehouseCode);
  362 +// if (port == null) {
  363 +// return Result.error("自动出库, 没有找到出库口");
  364 +// }
  365 +// int type = Integer.parseInt(port.getType());
  366 +// if (type == QuantityConstant.PORT_TYPE_IN) {
  367 +// return Result.error("自动出库, 不能选择入库口来出库");
  368 +// }
368 369 Result result = shipmentCombinationService.autoCombination(shipmentCode, warehouseCode);
369 370 if (!result.isSuccess()) {
370 371 throw new JeecgBootException("自动出库," + result.getMessage());
371 372 }
  373 + ShipmentHeader shipmentHeader = shipmentHeaderService.getShipmentHeaderByCode(shipmentCode, warehouseCode);
  374 + if (shipmentHeader == null) {
  375 + throw new JeecgBootException("自动出库, 没有找到出库单");
  376 + }
372 377 List<ShipmentContainerDetail> shipmentContainerDetailList = shipmentContainerDetailService.getShipmentContainerDetailListByShipmentCode(shipmentCode);
373 378 if (shipmentContainerDetailList == null) {
374 379 throw new JeecgBootException("自动出库, 没有找到出库配盘详情");
... ... @@ -384,7 +389,18 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl&lt;ShipmentHeaderMapper,
384 389 if (shipmentContainerHeader == null) {
385 390 throw new JeecgBootException("自动出库, 没有找到出库表头:" + shipmentContainerId);
386 391 }
387   - shipmentContainerHeader.setToPort(toPort);
  392 + String zoneCode = shipmentHeader.getZoneCode();
  393 + int taskType = shipmentContainerHeader.getTaskType();
  394 + int type = QuantityConstant.PORT_TYPE_PICK;
  395 + if (taskType == QuantityConstant.TASK_TYPE_WHOLESHIPMENT) {
  396 + type = QuantityConstant.PORT_TYPE_OUT;
  397 + }
  398 + List<Port> portList = portService.getPortListByType(type, zoneCode, warehouseCode);
  399 + if (portList == null) {
  400 + throw new JeecgBootException("自动出库, 没有合适的出库口");
  401 + }
  402 + Port port = portList.get(0);
  403 + shipmentContainerHeader.setToPort(port.getCode());
388 404 boolean success = shipmentContainerHeaderService.updateById(shipmentContainerHeader);
389 405 if (!success) {
390 406 throw new JeecgBootException("自动出库, 更新出库组盘头失败");
... ... @@ -401,16 +417,6 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl&lt;ShipmentHeaderMapper,
401 417 if (taskHeader == null) {
402 418 throw new JeecgBootException("自动出库, 没有找到容器号对应任务" + containerCode);
403 419 }
404   - if (taskHeader.getTaskType() == QuantityConstant.TASK_TYPE_WHOLESHIPMENT) {
405   - if (type != QuantityConstant.PORT_TYPE_OUT) {
406   - throw new JeecgBootException("自动出库, 出库口和整出任务不匹配" + toPort);
407   - }
408   - }
409   - if (taskHeader.getTaskType() == QuantityConstant.TASK_TYPE_SORTINGSHIPMENT) {
410   - if (type != QuantityConstant.PORT_TYPE_PICK) {
411   - throw new JeecgBootException("自动出库, 出库口和分拣任务不匹配" + toPort);
412   - }
413   - }
414 420 }
415 421 return Result.OK("自动出库成功");
416 422 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java
... ... @@ -318,6 +318,14 @@ public interface ITaskHeaderService extends IService&lt;TaskHeader&gt; {
318 318 boolean updateStatusById(int status, int id);
319 319  
320 320 /**
  321 + * 更新出库口
  322 + * @param toPortCode
  323 + * @param id
  324 + * @return
  325 + */
  326 + boolean updateToPortCodeById(String toPortCode, int id);
  327 +
  328 + /**
321 329 * 更新
322 330 * @param status
323 331 * @param id
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
... ... @@ -2786,6 +2786,15 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
2786 2786 }
2787 2787  
2788 2788 @Override
  2789 + public boolean updateToPortCodeById(String toPortCode, int id) {
  2790 + TaskHeader taskHeader = new TaskHeader();
  2791 + taskHeader.setToPortCode(toPortCode);
  2792 + taskHeader.setId(id);
  2793 + boolean success = taskHeaderService.updateById(taskHeader);
  2794 + return success;
  2795 + }
  2796 +
  2797 + @Override
2789 2798 public boolean updateExceptionStateById(int exceptionState, int id) {
2790 2799 TaskHeader taskHeader = new TaskHeader();
2791 2800 taskHeader.setExceptionState(exceptionState);
... ...
huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java
... ... @@ -495,10 +495,20 @@ public class QuantityConstant {
495 495 public static final String RULE_CANCEL_TASK = "cancelTask";
496 496 public static final String RULE_DOWN_ADDRESS = "downAdress";
497 497 public static final String TV_VERSION = "Tv-Ver";
  498 + public static final String RULE_SHIPMENT_ZONE = "shipmentZoneRule";
498 499  
499 500 public static final int DOUBLE_FORK = 1;
500 501 public static final int SINGLE_FORK = 0;
501 502  
  503 + /**
  504 + * 出库不依赖库区
  505 + */
  506 + public static final int NOT_SHIPMENT_BY_ZONE = 0;
  507 + /**
  508 + * 出库依赖库区
  509 + */
  510 + public static final int SHIPMENT_BY_ZONE = 1;
  511 +
502 512 // 取消任务,不取消配盘
503 513 public static final int RULE_TASK_CANCEL_NORMAL = 0;
504 514 // 取消任务,顺便取消配盘
... ... @@ -605,7 +615,7 @@ public class QuantityConstant {
605 615 /* 受控 */
606 616 public static final int INVENTORY_DETAIL_STATUS_CONTAINER = 1;
607 617  
608   - //库存锁定
  618 + // 库存锁定
609 619 public static final String STATUS_INVENTORY_LOCK = "lock";
610 620  
611 621 public static final int HTTP_OK = 200;
... ...