Commit 03b43a78edbf16c45eb58547939eabade97d80ab
1 parent
b2e0ce4a
批量出库,按照出库单详情出
Showing
4 changed files
with
109 additions
and
2 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/controller/InventoryHeaderController.java
... | ... | @@ -374,9 +374,22 @@ public class InventoryHeaderController extends JeecgController<InventoryHeader, |
374 | 374 | @ResponseBody |
375 | 375 | public Result shipmentInventoryHeader(@RequestBody List<InventoryHeader> inventoryHeaderList, HttpServletRequest req) { |
376 | 376 | if (StringUtils.isEmpty(inventoryHeaderList)) { |
377 | - return Result.error("库存明细为空"); | |
377 | + return Result.error("库存头为空"); | |
378 | 378 | } |
379 | 379 | String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); |
380 | 380 | return inventoryHeaderService.shipmentInventoryHeader(inventoryHeaderList, warehouseCode); |
381 | 381 | } |
382 | + | |
383 | + @AutoLog("库存头-批量出库存详情") | |
384 | + @ApiOperation(value = "批量出库存详情", notes = "批量出库存详情") | |
385 | + @ApiLogger(apiName = "批量出库存详情") | |
386 | + @PostMapping("/shipmentInventoryDetail") | |
387 | + @ResponseBody | |
388 | + public Result shipmentInventoryDetail(@RequestBody List<InventoryDetail> inventoryDetailList, HttpServletRequest req) { | |
389 | + if (StringUtils.isEmpty(inventoryDetailList)) { | |
390 | + return Result.error("库存明细为空"); | |
391 | + } | |
392 | + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); | |
393 | + return inventoryHeaderService.shipmentInventoryDetail(inventoryDetailList, warehouseCode); | |
394 | + } | |
382 | 395 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/entity/InventoryDetail.java
... | ... | @@ -154,6 +154,8 @@ public class InventoryDetail implements Serializable { |
154 | 154 | /** 更新日期 */ |
155 | 155 | @ApiModelProperty(value = "更新日期") |
156 | 156 | private Date updateTime; |
157 | + @TableField(exist = false) | |
158 | + private String toPortCode; | |
157 | 159 | |
158 | 160 | public void setQty(BigDecimal qty) { |
159 | 161 | if (qty.compareTo(BigDecimal.ZERO) < 0) { |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryHeaderService.java
... | ... | @@ -5,6 +5,7 @@ import java.util.Collection; |
5 | 5 | import java.util.List; |
6 | 6 | |
7 | 7 | import org.jeecg.common.api.vo.Result; |
8 | +import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail; | |
8 | 9 | import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryHeader; |
9 | 10 | |
10 | 11 | import com.baomidou.mybatisplus.extension.service.IService; |
... | ... | @@ -40,4 +41,6 @@ public interface IInventoryHeaderService extends IService<InventoryHeader> { |
40 | 41 | boolean updateLocationCodeById(String locationCode, Integer id); |
41 | 42 | |
42 | 43 | Result shipmentInventoryHeader(List<InventoryHeader> inventoryHeaderList, String warehouseCode); |
44 | + | |
45 | + Result shipmentInventoryDetail(List<InventoryDetail> inventoryDetailList, String warehouseCode); | |
43 | 46 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryHeaderServiceImpl.java
... | ... | @@ -187,6 +187,7 @@ public class InventoryHeaderServiceImpl extends ServiceImpl<InventoryHeaderMappe |
187 | 187 | if (!result.isSuccess()) { |
188 | 188 | throw new JeecgBootException("批量快速出库,创建出库单失败:".concat(result.getMessage())); |
189 | 189 | } |
190 | + | |
190 | 191 | List<ShipmentDetail> shipmentDetailList = new ArrayList<>(); |
191 | 192 | for (InventoryDetail inventoryDetail : inventoryDetails) { |
192 | 193 | ShipmentDetail shipmentDetail = new ShipmentDetail(); |
... | ... | @@ -202,6 +203,7 @@ public class InventoryHeaderServiceImpl extends ServiceImpl<InventoryHeaderMappe |
202 | 203 | shipmentDetail = shipmentDetailService.getById(shipmentDetail.getId()); |
203 | 204 | shipmentDetailList.add(shipmentDetail); |
204 | 205 | } |
206 | + | |
205 | 207 | for (int i = 0; i < inventoryDetails.size(); i++) { |
206 | 208 | InventoryDetail inventoryDetail = inventoryDetails.get(i); |
207 | 209 | ShipmentDetail shipmentDetail = shipmentDetailList.get(i); |
... | ... | @@ -214,11 +216,98 @@ public class InventoryHeaderServiceImpl extends ServiceImpl<InventoryHeaderMappe |
214 | 216 | throw new JeecgBootException("批量快速出库,配盘失败:".concat(result.getMessage())); |
215 | 217 | } |
216 | 218 | } |
219 | + | |
220 | + List<ShipmentContainerDetail> shipmentContainerDetailList = | |
221 | + shipmentContainerDetailService.getShipmentContainerDetailListByShipmentCode(shipmentHeader.getCode()); | |
222 | + if (StringUtils.isEmpty(shipmentContainerDetailList)) { | |
223 | + throw new JeecgBootException("批量快速出库,根据出库单没有找到配盘详情"); | |
224 | + } | |
225 | + | |
226 | + List<Integer> shipmentContainerHeaderIdList = | |
227 | + shipmentContainerDetailList.stream().map(ShipmentContainerDetail::getShipmentContainerId).collect(Collectors.toList()); | |
228 | + long shipmentOrder = System.currentTimeMillis(); | |
229 | + int sequenceNumber = shipmentContainerHeaderIdList.size(); | |
230 | + int sequence = 0; | |
231 | + for (int shipmentContainerId : shipmentContainerHeaderIdList) { | |
232 | + sequence++; | |
233 | + ShipmentContainerHeader shipmentContainerHeader = shipmentContainerHeaderService.getById(shipmentContainerId); | |
234 | + if (shipmentContainerHeader == null) { | |
235 | + throw new JeecgBootException("批量快速出库,没有找到出库表头:" + shipmentContainerId); | |
236 | + } | |
237 | + shipmentContainerHeader.setToPort(toPortCode); | |
238 | + boolean success = shipmentContainerHeaderService.updateById(shipmentContainerHeader); | |
239 | + if (!success) { | |
240 | + throw new JeecgBootException("批量快速出库,更新出库组盘头失败"); | |
241 | + } | |
242 | + result = shipmentCombinationService.createShipmentTask(shipmentContainerHeader, warehouseCode, shipmentOrder, sequence, sequenceNumber); | |
243 | + if (!result.isSuccess()) { | |
244 | + throw new JeecgBootException(result.getMessage()); | |
245 | + } | |
246 | + } | |
247 | + | |
248 | + return Result.OK("批量快速出库成功"); | |
249 | + } | |
250 | + | |
251 | + @Override | |
252 | + @Transactional(rollbackFor = JeecgBootException.class) | |
253 | + public Result shipmentInventoryDetail(List<InventoryDetail> inventoryDetailList, String warehouseCode) { | |
254 | + if (StringUtils.isEmpty(inventoryDetailList)) { | |
255 | + return Result.error("批量快速出库,所选库存详情为空"); | |
256 | + } | |
257 | + String toPortCode = inventoryDetailList.get(0).getToPortCode(); | |
258 | + if (StringUtils.isEmpty(toPortCode)) { | |
259 | + return Result.error("批量快速出库,出库站台编码为空"); | |
260 | + } | |
261 | + inventoryDetailList = | |
262 | + inventoryDetailList.stream().filter((item) -> item.getContainerStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)).collect(Collectors.toList()); | |
263 | + if (StringUtils.isEmpty(inventoryDetailList)) { | |
264 | + return Result.error("批量快速出库, 排除锁定库存后没有可出库存详情"); | |
265 | + } | |
266 | + | |
267 | + ShipmentHeader shipmentHeader = new ShipmentHeader(); | |
268 | + shipmentHeader.setWarehouseCode(warehouseCode); | |
269 | + shipmentHeader.setType(QuantityConstant.SHIPMENT_BILL_TYPE_QTC); | |
270 | + shipmentHeader.setRemark("快速出库"); | |
271 | + Result result = shipmentHeaderService.saveShipmentHeader(shipmentHeader); | |
272 | + if (!result.isSuccess()) { | |
273 | + throw new JeecgBootException("批量快速出库,创建出库单失败:".concat(result.getMessage())); | |
274 | + } | |
275 | + | |
276 | + List<ShipmentDetail> shipmentDetailList = new ArrayList<>(); | |
277 | + for (InventoryDetail inventoryDetail : inventoryDetailList) { | |
278 | + ShipmentDetail shipmentDetail = new ShipmentDetail(); | |
279 | + shipmentDetail.setShipmentId(shipmentHeader.getId()); | |
280 | + shipmentDetail.setMaterialCode(inventoryDetail.getMaterialCode()); | |
281 | + shipmentDetail.setInventoryStatus(inventoryDetail.getInventoryStatus()); | |
282 | + shipmentDetail.setQty(inventoryDetail.getQty()); | |
283 | + shipmentDetail.setBatch(inventoryDetail.getBatch()); | |
284 | + result = shipmentDetailService.saveShipmentDetail(shipmentDetail); | |
285 | + if (!result.isSuccess()) { | |
286 | + throw new JeecgBootException("批量快速出库,创建出库详情失败:".concat(result.getMessage())); | |
287 | + } | |
288 | + shipmentDetail = shipmentDetailService.getById(shipmentDetail.getId()); | |
289 | + shipmentDetailList.add(shipmentDetail); | |
290 | + } | |
291 | + | |
292 | + for (int i = 0; i < inventoryDetailList.size(); i++) { | |
293 | + InventoryDetail inventoryDetail = inventoryDetailList.get(i); | |
294 | + ShipmentDetail shipmentDetail = shipmentDetailList.get(i); | |
295 | + CombinationModel combinationModel = new CombinationModel(); | |
296 | + combinationModel.setInventoryDetail(inventoryDetail); | |
297 | + combinationModel.setShipmentDetail(shipmentDetail); | |
298 | + combinationModel.setShipQty(inventoryDetail.getQty()); | |
299 | + result = shipmentCombinationService.combination(combinationModel); | |
300 | + if (!result.isSuccess()) { | |
301 | + throw new JeecgBootException("批量快速出库,配盘失败:".concat(result.getMessage())); | |
302 | + } | |
303 | + } | |
304 | + | |
217 | 305 | List<ShipmentContainerDetail> shipmentContainerDetailList = |
218 | 306 | shipmentContainerDetailService.getShipmentContainerDetailListByShipmentCode(shipmentHeader.getCode()); |
219 | 307 | if (StringUtils.isEmpty(shipmentContainerDetailList)) { |
220 | 308 | throw new JeecgBootException("批量快速出库,根据出库单没有找到配盘详情"); |
221 | 309 | } |
310 | + | |
222 | 311 | List<Integer> shipmentContainerHeaderIdList = |
223 | 312 | shipmentContainerDetailList.stream().map(ShipmentContainerDetail::getShipmentContainerId).collect(Collectors.toList()); |
224 | 313 | long shipmentOrder = System.currentTimeMillis(); |
... | ... | @@ -235,7 +324,7 @@ public class InventoryHeaderServiceImpl extends ServiceImpl<InventoryHeaderMappe |
235 | 324 | if (!success) { |
236 | 325 | throw new JeecgBootException("批量快速出库,更新出库组盘头失败"); |
237 | 326 | } |
238 | - result = huahengMultiHandlerService.createShipmentTask(shipmentContainerHeader, warehouseCode, shipmentOrder, sequence, sequenceNumber); | |
327 | + result = shipmentCombinationService.createShipmentTask(shipmentContainerHeader, warehouseCode, shipmentOrder, sequence, sequenceNumber); | |
239 | 328 | if (!result.isSuccess()) { |
240 | 329 | throw new JeecgBootException(result.getMessage()); |
241 | 330 | } |
... | ... |