Commit 8261210f18ca2dc741a8628ccfdc34c30d33906b

Authored by 肖超群
1 parent e5a9cd0c

配盘完成以后 平库出库

ant-design-vue-jeecg/src/api/api.js
... ... @@ -280,6 +280,8 @@ export const createShipmentTaskByAgv = (params) => postAction('/shipment/shipmen
280 280 export const createBatchShipmentTaskByAgv = (params) => postAction('/shipment/shipmentCombination/createBatchShipmentTaskByAgv', params);
281 281 //创建出库任务和AGV去接
282 282 export const createShipmentTaskAndAgvTask = (params) => postAction('/shipment/shipmentCombination/createShipmentTaskAndAgvTask', params);
  283 +//完成平库出库
  284 +export const completeFlatShipment = (params) => postAction('/shipment/shipmentCombination/completeFlatShipment', params);
283 285  
284 286 // 中转HTTP请求
285 287 export const transitRESTful = {
... ...
ant-design-vue-jeecg/src/views/system/inventory/InventoryHeaderList.vue
... ... @@ -206,11 +206,6 @@ export default {
206 206 dataIndex: 'containerCode'
207 207 },
208 208 {
209   - title: '物料编码',
210   - align: "center",
211   - dataIndex: 'materialCode'
212   - },
213   - {
214 209 title: '容器状态',
215 210 align: "center",
216 211 dataIndex: 'containerStatus_dictText',
... ...
ant-design-vue-jeecg/src/views/system/shipment/ShipmentContainerHeaderList.vue
... ... @@ -124,6 +124,7 @@
124 124 <span slot="action" slot-scope="text, record">
125 125 <a v-if="record.status == 0 && record.zoneType =='A'" @click="openCreateShipmentTaskAndAgvTask(record)"><a-button type="primary">生成任务</a-button><a-divider type="vertical"/></a>
126 126 <a v-if="record.status == 0 && record.zoneType =='L'" @click="selectPort(record)"><a-button type="primary">生成任务</a-button><a-divider type="vertical"/></a>
  127 + <a v-if="record.status == 0 && record.zoneType =='P'" @click="completeFlatShipment(record)"><a-button type="primary">平库出库</a-button><a-divider type="vertical"/></a>
127 128 <!-- <a v-if="record.status == 0 && record.zoneType =='L'" @click="openCreateShipmentTaskAgv(record)"><a-button type="primary">生成任务</a-button><a-divider type="vertical"/></a>-->
128 129 <a-popconfirm v-if="record.status == 0" v-has="'shipmentContainerHeader:delete'" title="确定取消配盘吗?" @confirm="() => handleDelete(record.id)">
129 130 <a><a-button type="danger">取消配盘</a-button> <a-divider type="vertical"/></a>
... ... @@ -154,7 +155,16 @@ import {deleteAction, getAction} from &#39;@/api/manage&#39;
154 155 import ShipmentContainerDetailList from './ShipmentContainerDetailList'
155 156 import {initDictOptions, filterMultiDictText} from '@/components/dict/JDictSelectUtil'
156 157 import '@/assets/less/TableExpand.less'
157   -import {createShipmentTask, execute, getCompanyList, getCustomerList, getShipmentTypeList, getZoneList} from '@/api/api'
  158 +import {
  159 + createShipmentTask,
  160 + createShipmentTaskAndAgvTask,
  161 + execute,
  162 + getCompanyList,
  163 + getCustomerList,
  164 + getShipmentTypeList,
  165 + completeFlatShipment,
  166 + getZoneList
  167 +} from '@/api/api'
158 168 import {selectSortingPort, createShipmentTaskByAgv} from '@/api/api'
159 169 import ShipmentContainerSelectModal from "./modules/ShipmentContainerSelectModal";
160 170 import CreateShipmentTaskByAgvModal from "./modules/CreateShipmentTaskByAgvModal";
... ... @@ -356,6 +366,20 @@ export default {
356 366 this.$refs.modalForm4.edit(record);
357 367 this.$refs.modalForm4.title = "选择出库口";
358 368 },
  369 + completeFlatShipment(record) {
  370 + const that = this;
  371 + that.confirmLoading = true;
  372 + completeFlatShipment(record).then((res) => {
  373 + if (res.success) {
  374 + that.$message.success(res.message);
  375 + } else {
  376 + that.$message.warning(res.message);
  377 + }
  378 + that.searchQuery();
  379 + }).finally(() => {
  380 + that.confirmLoading = false;
  381 + });
  382 + },
359 383 createBatchTask() {
360 384 if (this.selectedRowKeys.length <= 0) {
361 385 this.$message.warning('至少选择一条记录!')
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/controller/ShipmentCombinationController.java
... ... @@ -14,12 +14,14 @@ import org.jeecg.modules.wms.config.port.entity.Port;
14 14 import org.jeecg.modules.wms.config.port.service.IPortService;
15 15 import org.jeecg.modules.wms.config.zone.entity.Zone;
16 16 import org.jeecg.modules.wms.config.zone.service.IZoneService;
  17 +import org.jeecg.modules.wms.framework.controller.HuahengBaseController;
17 18 import org.jeecg.modules.wms.framework.service.IHuahengMultiHandlerService;
18 19 import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService;
19 20 import org.jeecg.modules.wms.shipment.shipmentCombination.entity.FlatShipment;
20 21 import org.jeecg.modules.wms.shipment.shipmentCombination.entity.Shipment;
21 22 import org.jeecg.modules.wms.shipment.shipmentCombination.service.IShipmentCombinationService;
22 23 import org.jeecg.modules.wms.shipment.shipmentContainerHeader.entity.ShipmentContainerHeader;
  24 +import org.jeecg.modules.wms.shipment.shipmentContainerHeader.service.IShipmentContainerDetailService;
23 25 import org.jeecg.modules.wms.shipment.shipmentHeader.entity.CombinationParam;
24 26 import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentDetail;
25 27 import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentHeader;
... ... @@ -43,7 +45,7 @@ import lombok.extern.slf4j.Slf4j;
43 45 @RestController
44 46 @RequestMapping("/shipment/shipmentCombination")
45 47 @Slf4j
46   -public class ShipmentCombinationController {
  48 +public class ShipmentCombinationController extends HuahengBaseController {
47 49  
48 50 @Resource
49 51 private IShipmentDetailService shipmentDetailService;
... ... @@ -52,6 +54,8 @@ public class ShipmentCombinationController {
52 54 @Resource
53 55 private IShipmentCombinationService shipmentCombinationService;
54 56 @Resource
  57 + private IShipmentContainerDetailService shipmentContainerDetailService;
  58 + @Resource
55 59 private ILocationService locationService;
56 60 @Resource
57 61 private IZoneService zoneService;
... ... @@ -212,7 +216,7 @@ public class ShipmentCombinationController {
212 216 }
213 217  
214 218 /**
215   - * 平库出库,有托盘号
  219 + * 平库出库,通过托盘号,包括配盘和出库
216 220 * @return
217 221 */
218 222 @AutoLog(value = "平库出库,通过托盘")
... ... @@ -226,7 +230,7 @@ public class ShipmentCombinationController {
226 230 }
227 231  
228 232 /**
229   - * 平库出库,有托盘号
  233 + * 平库出库,通过库位号,包括配盘和出库
230 234 * @return
231 235 */
232 236 @AutoLog(value = "平库出库,通过库位")
... ... @@ -240,6 +244,26 @@ public class ShipmentCombinationController {
240 244 }
241 245  
242 246 /**
  247 + * 平库出库
  248 + * @return
  249 + */
  250 + @ApiOperation(value = "平库出库", notes = "平库出库")
  251 + @PostMapping("/completeFlatShipment")
  252 + @ResponseBody
  253 + public Result completeFlatShipment(@RequestBody ShipmentContainerHeader shipmentContainerHeader, HttpServletRequest req) {
  254 + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req);
  255 + String lockKey = warehouseCode;
  256 + Result result = handleMultiProcess("createShipmentTaskAndAgvTask", lockKey, new MultiProcessListener() {
  257 + @Override
  258 + public Result<?> doProcess() {
  259 + Result result = shipmentCombinationService.completeFlatShipment(shipmentContainerHeader);
  260 + return result;
  261 + }
  262 + });
  263 + return result;
  264 + }
  265 +
  266 + /**
243 267 * 立库区
244 268 * 创建出库任务, 出库任务完成以后,AGV去接
245 269 * @return
... ... @@ -282,7 +306,15 @@ public class ShipmentCombinationController {
282 306 @ResponseBody
283 307 public Result createShipmentTaskAndAgvTask(@RequestBody ShipmentContainerHeader shipmentContainerHeader, HttpServletRequest req) {
284 308 String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req);
285   - Result result = shipmentCombinationService.createShipmentTaskAndAgvTask(shipmentContainerHeader, QuantityConstant.TASK_TYPE_WHOLESHIPMENT, warehouseCode);
  309 + String lockKey = warehouseCode;
  310 + Result result = handleMultiProcess("createShipmentTaskAndAgvTask", lockKey, new MultiProcessListener() {
  311 + @Override
  312 + public Result<?> doProcess() {
  313 + Result result =
  314 + shipmentCombinationService.createShipmentTaskAndAgvTask(shipmentContainerHeader, QuantityConstant.TASK_TYPE_WHOLESHIPMENT, warehouseCode);
  315 + return result;
  316 + }
  317 + });
286 318 return result;
287 319 }
288 320 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/IShipmentCombinationService.java
... ... @@ -56,4 +56,9 @@ public interface IShipmentCombinationService {
56 56 * @return
57 57 */
58 58 Result flatShipmentByLocationCode(String locationCode, List<FlatShipment> flatShipments, String warehouseCode);
  59 +
  60 + /**
  61 + * 根据配盘信息,完成平库出库
  62 + */
  63 + Result completeFlatShipment(ShipmentContainerHeader shipmentContainerHeader);
59 64 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java
... ... @@ -638,7 +638,7 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
638 638 }
639 639 // 出库数量
640 640 BigDecimal shipmentQty = shipmentDetail.getQty().subtract(shipmentDetail.getTaskQty());
641   - // 判断是否还有需要出库的物料,如果没有就跳过该物料
  641 + // 判断是否还有需要出库的物 料,如果没有就跳过该物料
642 642 if (shipmentQty.compareTo(BigDecimal.ZERO) <= 0) {
643 643 throw new JeecgBootException("平库出库失败,出库数量必须大于0");
644 644 }
... ... @@ -844,6 +844,157 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
844 844 return reuslt;
845 845 }
846 846  
  847 + /**
  848 + * 根据配盘信息,完成平库出库
  849 + * @param shipmentContainerHeader
  850 + * @return
  851 + */
  852 + @Override
  853 + @Transactional(rollbackFor = JeecgBootException.class)
  854 + public Result completeFlatShipment(ShipmentContainerHeader shipmentContainerHeader) {
  855 + String warehouseCode = shipmentContainerHeader.getWarehouseCode();
  856 + String fromLocationCode = shipmentContainerHeader.getFromLocationCode();
  857 + String toLocationCode = shipmentContainerHeader.getToLocationCode();
  858 + String containerCode = shipmentContainerHeader.getContainerCode();
  859 + String zoneCode = shipmentContainerHeader.getZoneCode();
  860 + boolean success = false;
  861 + InventoryHeader inventoryHeader = inventoryHeaderService.getInventoryHeaderByContainerCode(containerCode, warehouseCode);
  862 + if (inventoryHeader == null) {
  863 + return Result.error("完成平库出库失败, 没有找到库存头" + containerCode);
  864 + }
  865 + List<InventoryTransaction> inventoryTransactionList = new ArrayList<>();
  866 + List<Integer> shipmentIdList = new ArrayList<>();
  867 + List<ShipmentDetail> shipmentDetailList = new ArrayList<>();
  868 + List<ShipmentDetail> updateStatusShipmentDetailList = new ArrayList<>();
  869 + List<ShipmentContainerDetail> shipmentContainerDetailList =
  870 + shipmentContainerDetailService.getShipmentContainerDetailListByHeaderId(shipmentContainerHeader.getId());
  871 + if (CollectionUtils.isEmpty(shipmentContainerDetailList)) {
  872 + return Result.error("完成平库出库失败, 配盘明细为空");
  873 + }
  874 + for (ShipmentContainerDetail shipmentContainerDetail : shipmentContainerDetailList) {
  875 + if (shipmentContainerDetail == null) {
  876 + throw new JeecgBootException("完成平库出库失败, 没有找到出库组盘详情");
  877 + }
  878 + ShipmentDetail shipmentDetail = shipmentDetailService.getById(shipmentContainerDetail.getShipmentDetailId());
  879 + if (shipmentDetail == null) {
  880 + throw new JeecgBootException("完成平库出库失败, 没有找到出库详情" + shipmentContainerDetail.getShipmentDetailId());
  881 + }
  882 + ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId());
  883 + if (shipmentHeader == null) {
  884 + throw new JeecgBootException("完成平库出库失败, 没有找到出库单" + shipmentDetail.getShipmentId());
  885 + }
  886 + int shipmentDetailId = shipmentDetail.getId();
  887 + BigDecimal shipmentQty = shipmentDetail.getShipmentQty();
  888 + shipmentQty = shipmentQty.add(shipmentContainerDetail.getQty());
  889 + int status = QuantityConstant.SHIPMENT_HEADER_COMPLETED;
  890 + if (shipmentDetail.getQty().compareTo(shipmentQty) == 0) {
  891 + status = QuantityConstant.SHIPMENT_HEADER_COMPLETED;
  892 + } else if (shipmentDetail.getQty().compareTo(shipmentQty) > 0) {
  893 + status = QuantityConstant.SHIPMENT_HEADER_OFF_SHELF;
  894 + } else if (shipmentDetail.getQty().compareTo(shipmentQty) < 0) {
  895 + throw new JeecgBootException("完成平库出库失败, 出库单 单据数量不能小于出库数量");
  896 + }
  897 + shipmentDetailList.add(shipmentDetail);
  898 + ShipmentDetail updateStatusShipmentDetail = new ShipmentDetail();
  899 + updateStatusShipmentDetail.setId(shipmentDetailId);
  900 + updateStatusShipmentDetail.setStatus(status);
  901 + updateStatusShipmentDetail.setShipmentQty(shipmentQty);
  902 + updateStatusShipmentDetailList.add(updateStatusShipmentDetail);
  903 + InventoryDetail inventoryDetail = inventoryDetailService.getById(shipmentContainerDetail.getInventoryDetailId());
  904 + if (inventoryDetail == null) {
  905 + throw new JeecgBootException("完成平库出库失败,出库任务没有找到库存详情" + shipmentContainerDetail.getInventoryDetailId());
  906 + }
  907 + BigDecimal taskQty = inventoryDetail.getTaskQty().subtract(shipmentContainerDetail.getQty());
  908 + BigDecimal qty = inventoryDetail.getQty().subtract(shipmentContainerDetail.getQty());
  909 + inventoryDetail.setTaskQty(taskQty);
  910 + inventoryDetail.setQty(qty);
  911 + inventoryDetail.setLocationCode(toLocationCode);
  912 + // 扣减后的库存不能小于0
  913 + if (inventoryDetail.getQty().compareTo(BigDecimal.ZERO) < 0) {
  914 + throw new JeecgBootException("完成平库出库失败,扣减库存大于wms库存");
  915 + }
  916 + if (inventoryDetail.getQty().compareTo(BigDecimal.ZERO) == 0) {
  917 + if (inventoryDetail.getTaskQty().compareTo(BigDecimal.ZERO) != 0) {
  918 + throw new JeecgBootException("完成平库出库失败,已无库存量可以扣减");
  919 + }
  920 + success = inventoryDetailService.removeById(inventoryDetail.getId());
  921 + if (!success) {
  922 + throw new JeecgBootException("完成平库出库失败,删除库存详情失败");
  923 + }
  924 + } else {
  925 + success = inventoryDetailService.updateQtyAndTaskQtyAndLocationCode(qty, taskQty, toLocationCode, inventoryDetail.getId());
  926 + if (!success) {
  927 + throw new JeecgBootException("完成平库出库失败,更新库存详情失败");
  928 + }
  929 + }
  930 +
  931 + InventoryTransaction inventoryTransaction = new InventoryTransaction();
  932 + inventoryTransaction.setType(QuantityConstant.INVENTORY_TRANSACTION_SHIPMENT);
  933 + inventoryTransaction.setWarehouseCode(warehouseCode);
  934 + inventoryTransaction.setCompanyCode(inventoryDetail.getCompanyCode());
  935 + inventoryTransaction.setContainerCode(containerCode);
  936 + inventoryTransaction.setZoneCode(zoneCode);
  937 + inventoryTransaction.setFromLocationCode(fromLocationCode);
  938 + inventoryTransaction.setToLocationCode(toLocationCode);
  939 + inventoryTransaction.setMaterialCode(inventoryDetail.getMaterialCode());
  940 + inventoryTransaction.setMaterialName(inventoryDetail.getMaterialName());
  941 + inventoryTransaction.setMaterialSpec(inventoryDetail.getMaterialSpec());
  942 + inventoryTransaction.setMaterialUnit(inventoryDetail.getMaterialUnit());
  943 + inventoryTransaction.setInventoryStatus(inventoryDetail.getInventoryStatus());
  944 + inventoryTransaction.setShipmentId(shipmentContainerDetail.getShipmentId());
  945 + inventoryTransaction.setShipmentCode(shipmentHeader.getCode());
  946 + inventoryTransaction.setShipmentType(shipmentHeader.getType());
  947 + inventoryTransaction.setShipmentDetailId(shipmentContainerDetail.getShipmentDetailId());
  948 + inventoryTransaction.setShipmentContainerDetailId(shipmentContainerDetail.getId());
  949 + inventoryTransaction.setBatch(inventoryDetail.getBatch());
  950 + inventoryTransaction.setLot(inventoryDetail.getLot());
  951 + inventoryTransaction.setProject(inventoryDetail.getProject());
  952 + inventoryTransaction.setQty(shipmentContainerDetail.getQty());
  953 + inventoryTransaction.setShipmentQty(shipmentContainerDetail.getQty());
  954 + BigDecimal inventoryQty = inventoryDetailService.getInventorySumQty(inventoryDetail);
  955 + inventoryTransaction.setInventoryQty(inventoryQty);
  956 + inventoryTransactionList.add(inventoryTransaction);
  957 + shipmentIdList.add(shipmentContainerDetail.getShipmentId());
  958 + }
  959 + success = inventoryTransactionService.saveBatch(inventoryTransactionList);
  960 + if (!success) {
  961 + throw new JeecgBootException("完成平库出库失败,保存库存详情失败");
  962 + }
  963 + List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByInventoryHeaderId(inventoryHeader.getId());
  964 + if (inventoryDetailList.size() == 0) {
  965 + success = inventoryHeaderService.removeById(inventoryHeader.getId());
  966 + if (!success) {
  967 + throw new JeecgBootException("完成平库出库失败,删除库存头失败");
  968 + }
  969 + }
  970 + if (shipmentContainerHeader == null) {
  971 + throw new JeecgBootException("完成平库出库失败,获取出库组盘头失败");
  972 + }
  973 + shipmentContainerHeader.setStatus(QuantityConstant.SHIPMENT_CONTAINER_FINISHED);
  974 + success = shipmentContainerHeaderService.updateStatusById(QuantityConstant.SHIPMENT_CONTAINER_FINISHED, shipmentContainerHeader.getId());
  975 + if (!success) {
  976 + throw new JeecgBootException("完成平库出库失败,更新出库组盘头失败");
  977 + }
  978 + inventoryDetailList = inventoryDetailService.getInventoryDetailListByInventoryHeaderId(inventoryHeader.getId());
  979 + if (inventoryDetailList.size() != 0) {
  980 + if (!taskHeaderService.combineInventoryDetail(containerCode, warehouseCode)) {
  981 + throw new JeecgBootException("完成平库出库失败, 合并入库库存失败");
  982 + }
  983 + }
  984 + success = shipmentDetailService.updateBatchById(updateStatusShipmentDetailList);
  985 + if (!success) {
  986 + throw new JeecgBootException("完成平库出库失败,更新出库详情失败");
  987 + }
  988 + shipmentIdList = shipmentIdList.stream().distinct().collect(Collectors.toList());
  989 + for (Integer shipmentId : shipmentIdList) {
  990 + success = shipmentHeaderService.updateShipmentHeaderStatus(shipmentId);
  991 + if (!success) {
  992 + throw new JeecgBootException("完成平库出库失败,更新出库单头失败");
  993 + }
  994 + }
  995 + return Result.OK("完成平库出库");
  996 + }
  997 +
847 998 @Override
848 999 @Transactional(rollbackFor = JeecgBootException.class)
849 1000 @OperationLog(bizId = "''", bizType = "'出库单追踪'", tag = "'出库任务生成'", extra = "#extraJsonString1",
... ...