Browse Source

永湖bug修复、接收按钮盒信号下发任务开发

zhangxin 1 year ago
parent
commit
936a10a79b

+ 26 - 6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/wcs/WcsController.java

@@ -1,10 +1,15 @@
 package com.ruoyi.web.controller.warewms.wcs;
 package com.ruoyi.web.controller.warewms.wcs;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.ruoyi.ams.agv.ndc.common.ByteUtil;
+import com.ruoyi.ams.agv.ndc.common.CRC16Util;
 import com.ruoyi.ams.agv.ndc.domain.AmsTask;
 import com.ruoyi.ams.agv.ndc.domain.AmsTask;
 import com.ruoyi.ams.agv.ndc.service.IAmsTaskService;
 import com.ruoyi.ams.agv.ndc.service.IAmsTaskService;
+import com.ruoyi.ams.business.BusinessServiceImpl;
 import com.ruoyi.ams.business.IBusinessService;
 import com.ruoyi.ams.business.IBusinessService;
 import com.ruoyi.ams.task.domain.WcsTask;
 import com.ruoyi.ams.task.domain.WcsTask;
+import com.ruoyi.base.constant.Constant;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.web.form.BtnOpForm;
 import com.ruoyi.web.form.BtnOpForm;
@@ -15,6 +20,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
+import java.util.List;
+
 @Slf4j
 @Slf4j
 @RestController
 @RestController
 @RequestMapping("/wcs/ctl")
 @RequestMapping("/wcs/ctl")
@@ -46,12 +53,25 @@ public class WcsController {
             } else if (btnOpForm.getIp().equals("192.168.77.104")) {
             } else if (btnOpForm.getIp().equals("192.168.77.104")) {
                 op = "2";
                 op = "2";
             }
             }
-            WcsTask wcsTask = new WcsTask();
-            wcsTask.setBusinessType(businessType);
-            wcsTask.setPriority(1L);
-            wcsTask.setExt1(op);
-            wcsTask.setTaskNo(System.currentTimeMillis() + "");
-            businessService.sendTask(wcsTask);
+//            WcsTask wcsTask = new WcsTask();
+//            wcsTask.setLocationFrom(Constant.LOC_MIDDLE_CACHE.toString());
+//            wcsTask.setLocationTo(Constant.LOC_SORTATION_CACHE.toString());
+//            wcsTask.setBusinessType(businessType);
+//            wcsTask.setPriority(1L);
+//            wcsTask.setExt1(op);
+//            wcsTask.setTaskNo(System.currentTimeMillis() + "");
+//            businessService.sendTask(wcsTask);
+
+            AmsTask addTaskForm = new AmsTask();
+            addTaskForm.setTaskNo(String.valueOf(System.currentTimeMillis()));
+            addTaskForm.setIkey(Long.parseLong(String.valueOf(CRC16Util.calcCrc16(ByteUtil.string2byteArray(addTaskForm.getTaskNo())))));
+            addTaskForm.setStFrom(Integer.valueOf(Constant.LOC_MIDDLE_CACHE.toString()));
+            addTaskForm.setStTo(Integer.valueOf(Constant.LOC_SORTATION_CACHE.toString()));
+            addTaskForm.setPriority(1);
+            addTaskForm.setBusinessType(businessType);
+            addTaskForm.setExt1(op);
+
+            amsTaskService.insertAmsTask(addTaskForm);
         }
         }
         return AjaxResult.success("");
         return AjaxResult.success("");
     }
     }

+ 1 - 8
warewms-ams/src/main/java/com/ruoyi/ams/business/BusinessServiceImpl.java

@@ -1,13 +1,10 @@
 package com.ruoyi.ams.business;
 package com.ruoyi.ams.business;
 
 
-import com.alibaba.fastjson.JSON;
 import com.ruoyi.ams.agv.ndc.common.ByteUtil;
 import com.ruoyi.ams.agv.ndc.common.ByteUtil;
 import com.ruoyi.ams.agv.ndc.common.CRC16Util;
 import com.ruoyi.ams.agv.ndc.common.CRC16Util;
 import com.ruoyi.ams.agv.ndc.domain.AmsTask;
 import com.ruoyi.ams.agv.ndc.domain.AmsTask;
 import com.ruoyi.ams.agv.ndc.service.IAmsTaskService;
 import com.ruoyi.ams.agv.ndc.service.IAmsTaskService;
-import com.ruoyi.ams.box.domain.WmsBoxInfo;
 import com.ruoyi.ams.box.service.IWmsBoxInfoService;
 import com.ruoyi.ams.box.service.IWmsBoxInfoService;
-import com.ruoyi.ams.business.domain.FilterLockInvLocationDTO;
 import com.ruoyi.ams.config.domain.AsnSoStrategy;
 import com.ruoyi.ams.config.domain.AsnSoStrategy;
 import com.ruoyi.ams.config.domain.dto.*;
 import com.ruoyi.ams.config.domain.dto.*;
 import com.ruoyi.ams.config.domain.vo.FlowConfigHeaderVO;
 import com.ruoyi.ams.config.domain.vo.FlowConfigHeaderVO;
@@ -805,13 +802,9 @@ public class BusinessServiceImpl implements IBusinessService {
         // 充电任务直接传参数
         // 充电任务直接传参数
         if (wcsTask.getBusinessType().equals(Constant.TASK_BUSINESS_TYPE.TASK_POWER.getValue())) {
         if (wcsTask.getBusinessType().equals(Constant.TASK_BUSINESS_TYPE.TASK_POWER.getValue())) {
             amsTask.setStFrom(Integer.parseInt(wcsTask.getLocationFrom()));
             amsTask.setStFrom(Integer.parseInt(wcsTask.getLocationFrom()));
-        } else {
-            amsTask.setStFrom(locFrom.getAgvStation().intValue());
-        }
-        if (wcsTask.getBusinessType().equals(Constant.TASK_BUSINESS_TYPE.TASK_POWER.getValue())) {
             amsTask.setStTo(Integer.parseInt(wcsTask.getLocationTo()));
             amsTask.setStTo(Integer.parseInt(wcsTask.getLocationTo()));
-
         } else {
         } else {
+            amsTask.setStFrom(locFrom.getAgvStation().intValue());
             amsTask.setStTo(locTo.getAgvStation().intValue());
             amsTask.setStTo(locTo.getAgvStation().intValue());
         }
         }
         amsTask.setExt1(wcsTask.getExt1());
         amsTask.setExt1(wcsTask.getExt1());

+ 16 - 8
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -66,6 +66,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.*;
@@ -1319,7 +1320,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         WmsBoxInfo wmsBoxInfo = wmsBoxInfoService.selectWmsBoxInfoByBoxNo(groupDiskFrom.getBoxNo());
         WmsBoxInfo wmsBoxInfo = wmsBoxInfoService.selectWmsBoxInfoByBoxNo(groupDiskFrom.getBoxNo());
         Optional.ofNullable(wmsBoxInfo).orElseThrow(() -> new BaseException("托盘不存在!"));
         Optional.ofNullable(wmsBoxInfo).orElseThrow(() -> new BaseException("托盘不存在!"));
         if (Constants.YES.equals(wmsBoxInfo.getIsFull())) return AjaxResult.error("该托盘已满托!");
         if (Constants.YES.equals(wmsBoxInfo.getIsFull())) return AjaxResult.error("该托盘已满托!");
-        verifyInvLotAndGetLocationId(groupDiskFrom.getPalletNoTo(), null, groupDiskFrom.getOrderNo());
+        verifyInvLotAndGetLocationId(groupDiskFrom.getPalletNoTo(), null, orderNo);
         return AjaxResult.success();
         return AjaxResult.success();
     }
     }
 
 
@@ -2747,7 +2748,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
      * @return
      * @return
      */
      */
     @Override
     @Override
-    @Transactional
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
     public AjaxResult pdaGroupDiskBH(PdaGroupDiskDTO pdaGroupDiskDTO) {
     public AjaxResult pdaGroupDiskBH(PdaGroupDiskDTO pdaGroupDiskDTO) {
         String palletNoFrom = pdaGroupDiskDTO.getPalletNoFrom(); // 起始托盘
         String palletNoFrom = pdaGroupDiskDTO.getPalletNoFrom(); // 起始托盘
         String palletNoTo = pdaGroupDiskDTO.getPalletNoTo(); // 目标托盘
         String palletNoTo = pdaGroupDiskDTO.getPalletNoTo(); // 目标托盘
@@ -2766,7 +2767,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             throw new BaseException("出库明细未绑定此类产品!");
             throw new BaseException("出库明细未绑定此类产品!");
         }
         }
         //筛选出相同sku并且数量未分配或未分配完的明细信息
         //筛选出相同sku并且数量未分配或未分配完的明细信息
-        List<WmsDocOrderDetails> wmsDocOrderDetailsFilterList = wmsDocOrderDetailsMatchSkuList.stream().filter(item -> CompareUtil.compare(item.getQtyOrdered().subtract(item.getQtyAllocated()), BigDecimal.ZERO) > 0).collect(Collectors.toList());
+        List<WmsDocOrderDetails> wmsDocOrderDetailsFilterList = wmsDocOrderDetailsMatchSkuList.stream()
+                .filter(item -> CompareUtil.compare(item.getQtyOrdered().subtract(item.getQtyAllocated()), BigDecimal.ZERO) > 0).collect(Collectors.toList());
         if (CollectionUtil.isEmpty(wmsDocOrderDetailsFilterList)){
         if (CollectionUtil.isEmpty(wmsDocOrderDetailsFilterList)){
             throw new BaseException("出库单该产品已备货完成!");
             throw new BaseException("出库单该产品已备货完成!");
         }
         }
@@ -2783,6 +2785,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         invLotAttService.insertInvLotAtt(buildInvLotAtt(lotNum, palletNoTo, orderNo, sn, sku, asnNo));
         invLotAttService.insertInvLotAtt(buildInvLotAtt(lotNum, palletNoTo, orderNo, sn, sku, asnNo));
         BigDecimal qtyAllocated = ObjectUtil.isNotNull(invLotLocId.getQtyallocated()) ? invLotLocId.getQtyallocated() : BigDecimal.ZERO;
         BigDecimal qtyAllocated = ObjectUtil.isNotNull(invLotLocId.getQtyallocated()) ? invLotLocId.getQtyallocated() : BigDecimal.ZERO;
         BigDecimal invLotLocQty = invLotLocId.getQty().subtract(qtyAllocated);
         BigDecimal invLotLocQty = invLotLocId.getQty().subtract(qtyAllocated);
+        locationId = StringUtils.isNotBlank(locationId) ? locationId : invLotLocId.getLocationId();
         if (CompareUtil.compare(qty, invLotLocQty) >= 0) {
         if (CompareUtil.compare(qty, invLotLocQty) >= 0) {
             invLotLocIdService.updateInvLotLocId(invLotLocId.getLotnum(), lotNum, invLotLocQty, sku, locationId);
             invLotLocIdService.updateInvLotLocId(invLotLocId.getLotnum(), lotNum, invLotLocQty, sku, locationId);
         } else {
         } else {
@@ -2818,7 +2821,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         // 更新托盘
         // 更新托盘
         wmsBoxInfoService.updateWmsBoxLocationIdByBoxNo(boxNo, Long.parseLong(locationId));
         wmsBoxInfoService.updateWmsBoxLocationIdByBoxNo(boxNo, Long.parseLong(locationId));
         List<WmsDocOrderDetails> wmsDocOrderDetailsByOrderNo = wmsDocOrderDetailsService.queryWmsDocOrderDetailsByOrderNo(orderNo);
         List<WmsDocOrderDetails> wmsDocOrderDetailsByOrderNo = wmsDocOrderDetailsService.queryWmsDocOrderDetailsByOrderNo(orderNo);
-        List<WmsDocOrderDetails> docOrderDetailsList = wmsDocOrderDetailsByOrderNo.stream().filter(item -> CompareUtil.compare(item.getLineStatus(), Constant.ORDER_STS.STS20.getValue()) != 0).collect(Collectors.toList());
+        List<WmsDocOrderDetails> docOrderDetailsList = wmsDocOrderDetailsByOrderNo.stream()
+                .filter(item -> CompareUtil.compare(item.getLineStatus(), Constant.ORDER_STS.STS20.getValue()) != 0).collect(Collectors.toList());
         wmsDocOrderHeaderMapper.update(new WmsDocOrderHeader(), Wrappers.<WmsDocOrderHeader>lambdaUpdate()
         wmsDocOrderHeaderMapper.update(new WmsDocOrderHeader(), Wrappers.<WmsDocOrderHeader>lambdaUpdate()
                 .set(WmsDocOrderHeader::getOrderStatus, CollectionUtil.isNotEmpty(docOrderDetailsList) ? Constant.ORDER_STS.STS22.getValue() : Constant.ORDER_STS.STS23.getValue()).eq(WmsDocOrderHeader::getOrderNo, orderNo));
                 .set(WmsDocOrderHeader::getOrderStatus, CollectionUtil.isNotEmpty(docOrderDetailsList) ? Constant.ORDER_STS.STS22.getValue() : Constant.ORDER_STS.STS23.getValue()).eq(WmsDocOrderHeader::getOrderNo, orderNo));
         return AjaxResult.success("当前托盘备货成功!托盘数量: " + invLotAttService.queryPalletTotal(palletNoTo));
         return AjaxResult.success("当前托盘备货成功!托盘数量: " + invLotAttService.queryPalletTotal(palletNoTo));
@@ -2827,16 +2831,18 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     private String verifyInvLotAndGetLocationId(String palletNoTo, String sn, String orderNo) {
     private String verifyInvLotAndGetLocationId(String palletNoTo, String sn, String orderNo) {
         List<InvLotAtt> palletNoToInvLotAttList = invLotAttService.queryInvLotAtt(palletNoTo);
         List<InvLotAtt> palletNoToInvLotAttList = invLotAttService.queryInvLotAtt(palletNoTo);
         if (CollectionUtil.isEmpty(palletNoToInvLotAttList)) return null;
         if (CollectionUtil.isEmpty(palletNoToInvLotAttList)) return null;
-        if (StringUtils.isNotBlank(sn) && CollectionUtil.isNotEmpty(palletNoToInvLotAttList.stream().filter(item -> StringUtils.isBlank(item.getLotatt08()) && item.getLotatt02().equals(sn)).collect(Collectors.toList()))) {
+        if (StringUtils.isNotBlank(sn) && CollectionUtil.isNotEmpty(palletNoToInvLotAttList.stream()
+                .filter(item -> StringUtils.isBlank(item.getLotatt08()) && item.getLotatt02().equals(sn)).collect(Collectors.toList()))) {
             throw new BaseException("该条码已生成批次");
             throw new BaseException("该条码已生成批次");
         }
         }
         //验证是否已经有不同出库单备货了
         //验证是否已经有不同出库单备货了
         List<InvLotLocId> invLotLocIdList = invLotLocIdService.queryInvLotLocIdByLotnum(palletNoToInvLotAttList.stream().map(InvLotAtt::getLotnum).collect(Collectors.toList()));
         List<InvLotLocId> invLotLocIdList = invLotLocIdService.queryInvLotLocIdByLotnum(palletNoToInvLotAttList.stream().map(InvLotAtt::getLotnum).collect(Collectors.toList()));
         if (CollectionUtil.isEmpty(invLotLocIdList)) return null;
         if (CollectionUtil.isEmpty(invLotLocIdList)) return null;
-        List<InvLotAtt> invLotAttList = palletNoToInvLotAttList.stream().filter(item -> invLotLocIdList.stream().map(InvLotLocId::getLotnum).collect(Collectors.toList()).contains(item.getLotnum())).collect(Collectors.toList());
+        List<InvLotAtt> invLotAttList = palletNoToInvLotAttList.stream().filter(item ->
+                invLotLocIdList.stream().map(InvLotLocId::getLotnum).collect(Collectors.toList()).contains(item.getLotnum())).collect(Collectors.toList());
         List<InvLotAtt> invLotAttFilterList = invLotAttList.stream().filter(item -> StringUtils.isNotBlank(item.getLotatt14()) && !item.getLotatt14().equals(orderNo)).collect(Collectors.toList());
         List<InvLotAtt> invLotAttFilterList = invLotAttList.stream().filter(item -> StringUtils.isNotBlank(item.getLotatt14()) && !item.getLotatt14().equals(orderNo)).collect(Collectors.toList());
         if (CollectionUtil.isNotEmpty(invLotAttFilterList)) throw new BaseException("该托盘已备货其他出库单: " + invLotAttFilterList.stream().map(InvLotAtt::getLotatt14).collect(Collectors.joining(",")));
         if (CollectionUtil.isNotEmpty(invLotAttFilterList)) throw new BaseException("该托盘已备货其他出库单: " + invLotAttFilterList.stream().map(InvLotAtt::getLotatt14).collect(Collectors.joining(",")));
-        return invLotLocIdList.stream().map(InvLotLocId::getLocationId).findFirst().orElseThrow(() -> new BaseException("指向托盘库位信息丢失!"));
+        return invLotLocIdList.stream().filter(item -> StringUtils.isNotBlank(item.getLocationId())).map(InvLotLocId::getLocationId).findFirst().orElseThrow(() -> new BaseException("指向托盘库位信息丢失!"));
     }
     }
 
 
     private InvLotLocId buildInvLotLocId(String lotNum, BigDecimal qty, String locationId, String traceId, String sku) {
     private InvLotLocId buildInvLotLocId(String lotNum, BigDecimal qty, String locationId, String traceId, String sku) {
@@ -2911,7 +2917,9 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         if (CollectionUtil.isEmpty(wmsDocOrderHeaderFilterList)) {
         if (CollectionUtil.isEmpty(wmsDocOrderHeaderFilterList)) {
             throw new BaseException("出库单状态不可进行库存匹配!");
             throw new BaseException("出库单状态不可进行库存匹配!");
         }
         }
-        List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetailsByOrderNo(wmsDocOrderHeaderFilterList.stream().filter(item -> StringUtils.isNotBlank(item.getOrderNo())).map(WmsDocOrderHeader::getOrderNo).collect(Collectors.toList()));
+        List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetailsByOrderNo(
+                wmsDocOrderHeaderFilterList.stream().filter(item -> StringUtils.isNotBlank(item.getOrderNo()))
+                        .map(WmsDocOrderHeader::getOrderNo).collect(Collectors.toList()));
         if (CollectionUtil.isEmpty(wmsDocOrderDetailsList)) {
         if (CollectionUtil.isEmpty(wmsDocOrderDetailsList)) {
             throw new BaseException("出库单明细为空!");
             throw new BaseException("出库单明细为空!");
         }
         }