Browse Source

1.出入库记录条码信息
2.入库解绑解绑解除条码信息
3.出入库条码信息回传ERP中间表

k 1 year ago
parent
commit
4b10df6805

+ 5 - 0
ruoyi-admin/src/main/java/com/ruoyi/init/StartService.java

@@ -86,4 +86,9 @@ public class StartService implements CommandLineRunner {
         redisCache.deleteObject(RedisKey.AGV02_TASK_NUM);
     }
 
+    // 回传ERP条码扫描记录
+    public void callBackSnScanRecord() throws Exception{
+        iSyncService.callBackSnScanRecord();
+    }
+
 }

+ 1 - 0
ruoyi-ui/src/views/wms/barcodes/index.vue

@@ -138,6 +138,7 @@
       <el-table-column label="入库/出库" align="center" prop="type" />
       <el-table-column label="erp单号" align="center" prop="erpNo" />
       <el-table-column label="项次" align="center" prop="erpName" />
+      <el-table-column label="箱号" align="center" prop="userdefine5" />
       <el-table-column label="人员" align="center" prop="userdefine3" />
       <el-table-column label="时间" align="center" prop="userdefine2" />
       <el-table-column label="状态(扫描记录是否有效)" align="center" prop="userdefine1" />

+ 2 - 0
warewms-ams/src/main/java/com/ruoyi/ams/asn/form/StockForm.java

@@ -20,6 +20,8 @@ public class StockForm {
     private String stockTag;
     // 托盘编号
     private String palletNo;
+    // 箱号
+    private String boxNo;
     // 产品条码(唯一,验证条码是否重复扫描)
     private String skuSn;
     // 是否满托

+ 17 - 1
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/impl/WmsDocAsnHeaderServiceImpl.java

@@ -444,6 +444,9 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                             } else {
                                 throw new ServiceException("更新接收数失败");
                             }
+                            // 记录扫码数据
+                            erpBarcodesService.recordErpBarcodeListAsn(details,stockForm.getSkuSn()
+                                    ,"STAGE01",stockForm.getPalletNo(),BigDecimal.ONE,stockForm.getBoxNo());
                             //修改头单状态
                             WmsDocAsnDetails detailsQuery = new WmsDocAsnDetails();
                             detailsQuery.setAsnNo(details.getAsnNo());
@@ -463,7 +466,8 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
 
                             if (stockForm.getStockTag().equals("Y")) {
                                 // 匹配对应出库单 修改出库单备货数量
-                                wmsDocOrderHeaderService.modifystockCompletionStatusAsn(stockForm.getOrderNo(), codeSkuRelationshipVO.getSku(), current);
+                                wmsDocOrderHeaderService.modifystockCompletionStatusAsn(stockForm.getOrderNo(), codeSkuRelationshipVO.getSku(), current
+                                ,stockForm.getSkuSn(),stockForm.getPalletNo(),stockForm.getBoxNo());
                             }
 
                             //生成库存
@@ -706,12 +710,18 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
             return false;
         });
         if (!isCan) {
+            // todo 解绑备货单 删除条码扫描记录
             return AjaxResult.error("备货库存暂时不可解绑!");
         }
         for (InvLotLocId inv : invLotLocIdList) {
+            String erpNo = "";
+            String erpName = "";
             //修改入库单的接收数
             InvLotAtt qtt = invLotAttService.selectInvLotAttByLotnum(inv.getLotnum());
             String asnNo = qtt.getLotatt08();
+            // 单头
+            WmsDocAsnHeader wmsDocAsnHeader = this.selectWmsDocAsnHeaderByAsnNo(asnNo);
+            // 明细
             WmsDocAsnDetails detailsQuery = new WmsDocAsnDetails();
             detailsQuery.setAsnNo(asnNo);
             detailsQuery.setSku(qtt.getSku());
@@ -722,12 +732,18 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
                 if (d.getReceivedQty().compareTo(qty) >= 0) {
                     wmsDocAsnDetailsMapper.updateWmsReceivedQty(d.getAsnNo(), d.getAsnLineNo().intValue()
                             , BigDecimal.valueOf(-1 * inv.getQty().doubleValue()), "30");
+                    erpNo = wmsDocAsnHeader.getAsnReference1();
+                    erpName = d.getdEdi07() == null ? "" : d.getdEdi07();
                     break;
                 }
             }
             //删除库存 todo 物料增加库存的时候如果改成根据相同库存和批次可以累加数量,这边就需要减库存,而不是直接删除
             invLotLocIdMapper.deleteInvLotLocIdBy(inv.getLotnum(), inv.getSku(), inv.getLocationId(), inv.getCustomerId());
             sum = sum + inv.getQty().intValue();
+
+            // 删除条码扫描记录
+            erpBarcodesService.untieRecordErpBarcodeListAsnSo(erpNo,erpName,qtt.getLotatt02());
+
         }
         return AjaxResult.success("解绑成功!" + unlockForm.getSku() + ",数量:" + sum);
     }

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

@@ -800,7 +800,7 @@ public class BusinessServiceImpl implements IBusinessService {
         amsTask.setIsDelete(0);
         amsTask.setAciAccept(0);
         amsTask.setIkey((long) geniKey(amsTask.getTaskNo()));
-        amsTask.setPriority(wcsTask.getPriority().intValue());
+        amsTask.setPriority(10);
         // 充电任务直接传参数
         if (wcsTask.getBusinessType().equals(Constant.TASK_BUSINESS_TYPE.TASK_POWER.getValue())) {
             amsTask.setStFrom(Integer.parseInt(wcsTask.getLocationFrom()));

+ 8 - 7
warewms-ams/src/main/java/com/ruoyi/ams/erp/mapper/ErpBarcodesMapper.java

@@ -6,15 +6,15 @@ import java.util.List;
 
 /**
  * 条码扫描记录表Mapper接口
- * 
+ *
  * @author ruoyi
  * @date 2023-03-10
  */
-public interface ErpBarcodesMapper 
+public interface ErpBarcodesMapper
 {
     /**
      * 查询条码扫描记录表
-     * 
+     *
      * @param id 条码扫描记录表主键
      * @return 条码扫描记录表
      */
@@ -30,7 +30,7 @@ public interface ErpBarcodesMapper
 
     /**
      * 新增条码扫描记录表
-     * 
+     *
      * @param erpBarcodes 条码扫描记录表
      * @return 结果
      */
@@ -38,15 +38,16 @@ public interface ErpBarcodesMapper
 
     /**
      * 修改条码扫描记录表
-     * 
+     *
      * @param erpBarcodes 条码扫描记录表
      * @return 结果
      */
      int updateErpBarcodes(ErpBarcodes erpBarcodes);
+     int updateErpBarcodesBySn(ErpBarcodes erpBarcodes);
 
     /**
      * 删除条码扫描记录表
-     * 
+     *
      * @param id 条码扫描记录表主键
      * @return 结果
      */
@@ -54,7 +55,7 @@ public interface ErpBarcodesMapper
 
     /**
      * 批量删除条码扫描记录表
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */

+ 57 - 15
warewms-ams/src/main/java/com/ruoyi/ams/erp/service/IErpBarcodesService.java

@@ -1,32 +1,35 @@
 package com.ruoyi.ams.erp.service;
 
+import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
 import com.ruoyi.ams.erp.domain.ErpBarcodes;
+import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
+import com.ruoyi.common.core.domain.AjaxResult;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
  * 条码扫描记录表Service接口
- * 
+ *
  * @author ruoyi
  * @date 2023-03-10
  */
-public interface IErpBarcodesService 
-{
+public interface IErpBarcodesService {
     /**
      * 查询条码扫描记录表
-     * 
+     *
      * @param id 条码扫描记录表主键
      * @return 条码扫描记录表
      */
-     ErpBarcodes selectErpBarcodesById(Long id);
+    ErpBarcodes selectErpBarcodesById(Long id);
 
     /**
      * 查询条码扫描记录表列表
-     * 
+     *
      * @param erpBarcodes 条码扫描记录表
      * @return 条码扫描记录表集合
      */
-     List<ErpBarcodes> selectErpBarcodesList(ErpBarcodes erpBarcodes);
+    List<ErpBarcodes> selectErpBarcodesList(ErpBarcodes erpBarcodes);
 
     /**
      * 查询条码扫描记录表
@@ -38,33 +41,72 @@ public interface IErpBarcodesService
 
     /**
      * 新增条码扫描记录表
-     * 
+     *
      * @param erpBarcodes 条码扫描记录表
      * @return 结果
      */
-     int insertErpBarcodes(ErpBarcodes erpBarcodes);
+    int insertErpBarcodes(ErpBarcodes erpBarcodes);
 
     /**
      * 修改条码扫描记录表
-     * 
+     *
      * @param erpBarcodes 条码扫描记录表
      * @return 结果
      */
-     int updateErpBarcodes(ErpBarcodes erpBarcodes);
+    int updateErpBarcodes(ErpBarcodes erpBarcodes);
+    int updateErpBarcodesBySn(ErpBarcodes erpBarcodes);
 
     /**
      * 批量删除条码扫描记录表
-     * 
+     *
      * @param ids 需要删除的条码扫描记录表主键集合
      * @return 结果
      */
-     int deleteErpBarcodesByIds(Long[] ids);
+    int deleteErpBarcodesByIds(Long[] ids);
 
     /**
      * 删除条码扫描记录表信息
-     * 
+     *
      * @param id 条码扫描记录表主键
      * @return 结果
      */
-     int deleteErpBarcodesById(Long id);
+    int deleteErpBarcodesById(Long id);
+
+    /**
+     * 入库扫码记录扫描信息
+     *
+     * @param details
+     * @param sn
+     * @param locationNo
+     * @param palletNo
+     * @param qty
+     * @param boxNo
+     * @return
+     */
+    AjaxResult recordErpBarcodeListAsn(WmsDocAsnDetails details, String sn, String locationNo
+            , String palletNo, BigDecimal qty,String boxNo);
+
+    /**
+     * 备货,出库扫码记录扫描信息
+     *
+     * @param details
+     * @param sn
+     * @param locationNo
+     * @param palletNo
+     * @param qty
+     * @param boxNo
+     * @return
+     */
+    AjaxResult recordErpBarcodeListSo(WmsDocOrderDetails details, String sn, String locationNo
+            , String palletNo, BigDecimal qty, String boxNo);
+
+    /**
+     * 入库扫码记录扫描信息 解绑
+     *
+     * @param erpNo
+     * @param erpName
+     * @param sn
+     * @return
+     */
+    AjaxResult untieRecordErpBarcodeListAsnSo(String erpNo,String erpName,String sn);
 }

+ 4 - 0
warewms-ams/src/main/java/com/ruoyi/ams/erp/service/ISyncService.java

@@ -17,9 +17,13 @@ public interface ISyncService {
 
     boolean writeBack(List<ErpBarCodeList> erpBarCodeListList) throws Exception;
 
+    boolean writeBackU(ErpBarCodeList erpBarCodeList) throws Exception;
+
     boolean updateErpOrderStatus(ErpOrderList erpOrderList) throws Exception;
 
     void callBackAsn() throws Exception;
 
     void callBackOrder() throws Exception;
+
+    void callBackSnScanRecord() throws Exception;
 }

+ 152 - 24
warewms-ams/src/main/java/com/ruoyi/ams/erp/service/impl/ErpBarcodesServiceImpl.java

@@ -1,47 +1,60 @@
 package com.ruoyi.ams.erp.service.impl;
 
+import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
+import com.ruoyi.ams.asn.domain.WmsDocAsnHeader;
+import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
 import com.ruoyi.ams.erp.domain.ErpBarcodes;
 import com.ruoyi.ams.erp.mapper.ErpBarcodesMapper;
 import com.ruoyi.ams.erp.service.IErpBarcodesService;
+import com.ruoyi.ams.inv.domain.InvLotAtt;
+import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
+import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
+import com.ruoyi.ams.order.service.IWmsDocOrderDetailsService;
+import com.ruoyi.ams.order.service.IWmsDocOrderHeaderService;
+import com.ruoyi.base.constant.Constant;
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
  * 条码扫描记录表Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2023-03-10
  */
 @Service
-public class ErpBarcodesServiceImpl implements IErpBarcodesService
-{
+public class ErpBarcodesServiceImpl implements IErpBarcodesService {
     @Autowired
     private ErpBarcodesMapper erpBarcodesMapper;
+    @Autowired
+    private IWmsDocAsnHeaderService iWmsDocAsnHeaderService;
+    @Autowired
+    private IWmsDocOrderHeaderService wmsDocOrderHeaderService;
 
     /**
      * 查询条码扫描记录表
-     * 
+     *
      * @param id 条码扫描记录表主键
      * @return 条码扫描记录表
      */
     @Override
-    public ErpBarcodes selectErpBarcodesById(Long id)
-    {
+    public ErpBarcodes selectErpBarcodesById(Long id) {
         return erpBarcodesMapper.selectErpBarcodesById(id);
     }
 
     /**
      * 查询条码扫描记录表列表
-     * 
+     *
      * @param erpBarcodes 条码扫描记录表
      * @return 条码扫描记录表
      */
     @Override
-    public List<ErpBarcodes> selectErpBarcodesList(ErpBarcodes erpBarcodes)
-    {
+    public List<ErpBarcodes> selectErpBarcodesList(ErpBarcodes erpBarcodes) {
         return erpBarcodesMapper.selectErpBarcodesList(erpBarcodes);
     }
 
@@ -52,10 +65,9 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService
      * @return 条码扫描记录表
      */
     @Override
-    public ErpBarcodes selectErpBarcodesByModel(ErpBarcodes erpBarcodes)
-    {
+    public ErpBarcodes selectErpBarcodesByModel(ErpBarcodes erpBarcodes) {
         List<ErpBarcodes> list = erpBarcodesMapper.selectErpBarcodesList(erpBarcodes);
-        if (list!=null && list.size()>0) {
+        if (list != null && list.size() > 0) {
             return list.get(0);
         } else {
             return null;
@@ -64,51 +76,167 @@ public class ErpBarcodesServiceImpl implements IErpBarcodesService
 
     /**
      * 新增条码扫描记录表
-     * 
+     *
      * @param erpBarcodes 条码扫描记录表
      * @return 结果
      */
     @Override
-    public int insertErpBarcodes(ErpBarcodes erpBarcodes)
-    {
+    public int insertErpBarcodes(ErpBarcodes erpBarcodes) {
         erpBarcodes.setCreateTime(DateUtils.getNowDate());
         return erpBarcodesMapper.insertErpBarcodes(erpBarcodes);
     }
 
     /**
      * 修改条码扫描记录表
-     * 
+     *
      * @param erpBarcodes 条码扫描记录表
      * @return 结果
      */
     @Override
-    public int updateErpBarcodes(ErpBarcodes erpBarcodes)
-    {
+    public int updateErpBarcodes(ErpBarcodes erpBarcodes) {
         erpBarcodes.setUpdateTime(DateUtils.getNowDate());
         return erpBarcodesMapper.updateErpBarcodes(erpBarcodes);
     }
 
+    /**
+     * 修改条码扫描记录表
+     *
+     * @param erpBarcodes 条码扫描记录表
+     * @return 结果
+     */
+    @Override
+    public int updateErpBarcodesBySn(ErpBarcodes erpBarcodes) {
+        erpBarcodes.setUpdateTime(DateUtils.getNowDate());
+        return erpBarcodesMapper.updateErpBarcodesBySn(erpBarcodes);
+    }
+
     /**
      * 批量删除条码扫描记录表
-     * 
+     *
      * @param ids 需要删除的条码扫描记录表主键
      * @return 结果
      */
     @Override
-    public int deleteErpBarcodesByIds(Long[] ids)
-    {
+    public int deleteErpBarcodesByIds(Long[] ids) {
         return erpBarcodesMapper.deleteErpBarcodesByIds(ids);
     }
 
     /**
      * 删除条码扫描记录表信息
-     * 
+     *
      * @param id 条码扫描记录表主键
      * @return 结果
      */
     @Override
-    public int deleteErpBarcodesById(Long id)
-    {
+    public int deleteErpBarcodesById(Long id) {
         return erpBarcodesMapper.deleteErpBarcodesById(id);
     }
+
+    @Override
+    public AjaxResult recordErpBarcodeListAsn(WmsDocAsnDetails details, String sn, String locationNo
+            , String palletNo, BigDecimal qty, String boxNo) {
+        String asnNo = details.getAsnNo();
+        WmsDocAsnHeader wmsDocAsnHeader = iWmsDocAsnHeaderService.selectWmsDocAsnHeaderByAsnNo(asnNo);
+        String erpNo = wmsDocAsnHeader.getAsnReference1();
+        //先查一下有没有
+        String erpName = details.getdEdi07() == null ? "" : details.getdEdi07();
+        ErpBarcodes erpBarcodesS = new ErpBarcodes();
+        erpBarcodesS.setErpNo(erpNo);
+        erpBarcodesS.setErpName(erpName);
+        erpBarcodesS.setBarcode(sn);
+        ErpBarcodes erpBarcodesG = this.selectErpBarcodesByModel(erpBarcodesS);
+        if (erpBarcodesG != null) {
+            this.untieRecordErpBarcodeList(erpNo, erpName, sn);
+            return AjaxResult.success("");
+        }
+        // 插入新的
+        ErpBarcodes erpBarcodes = new ErpBarcodes();
+        erpBarcodes.setUserdefine4(asnNo); // WMS单号
+        erpBarcodes.setBarcode(sn); // 条码
+        erpBarcodes.setStockId(details.getdEdi05() == null ? "" : details.getdEdi05()); // 仓库编码
+        erpBarcodes.setLocationNo(locationNo); // 货架编号
+        erpBarcodes.setBoxNo(palletNo); // 托盘号
+        erpBarcodes.setQty(qty); // 数量
+        erpBarcodes.setType(details.getdEdi09() == null ? "" : details.getdEdi09()); // 出入库类型
+        erpBarcodes.setErpNo(erpNo); // ERP单号
+        erpBarcodes.setErpName(details.getdEdi07() == null ? "" : details.getdEdi07());
+        erpBarcodes.setUserdefine7(details.getdEdi08() == null ? "" : details.getdEdi08()); // ERP单据类型
+        erpBarcodes.setUserdefine5(boxNo); // 箱号
+        erpBarcodes.setUserdefine3(details.getdEdi11() == null ? "" : details.getdEdi11()); // 人员
+        erpBarcodes.setUserdefine2(DateUtils.getTime());
+        erpBarcodes.setUserdefine1("Y"); // 状态(扫描记录是否有效)
+        erpBarcodes.setUserdefine8("N"); // 回传ERP标识
+        this.insertErpBarcodes(erpBarcodes);
+        return AjaxResult.success();
+    }
+
+    @Override
+    public AjaxResult recordErpBarcodeListSo(WmsDocOrderDetails details, String sn, String locationNo
+            , String palletNo, BigDecimal qty, String boxNo) {
+        String orderNo = details.getOrderNo();
+        WmsDocOrderHeader wmsDocOrderHeader = wmsDocOrderHeaderService.selectDocOrderHeaderByOrderNo(orderNo);
+        String erpNo = wmsDocOrderHeader.getSoReference1();
+        //先查一下有没有
+        String erpName = details.getdEdi07() == null ? "" : details.getdEdi07();
+        if (StringUtils.isEmpty(erpName)) {
+            return AjaxResult.success();
+        }
+        ErpBarcodes erpBarcodesS = new ErpBarcodes();
+        erpBarcodesS.setErpNo(erpNo);
+        erpBarcodesS.setErpName(erpName);
+        erpBarcodesS.setBarcode(sn);
+        ErpBarcodes erpBarcodesG = this.selectErpBarcodesByModel(erpBarcodesS);
+        if (erpBarcodesG != null) {
+            this.untieRecordErpBarcodeList(erpNo, erpName, sn);
+            return AjaxResult.success("");
+        }
+        ErpBarcodes erpBarcodes = new ErpBarcodes();
+        erpBarcodes.setUserdefine4(orderNo); // WMS单号
+        erpBarcodes.setBarcode(sn); // 条码
+        erpBarcodes.setStockId(details.getdEdi05() == null ? "" : details.getdEdi05()); // 仓库编码
+        erpBarcodes.setLocationNo(locationNo); // 货架编号
+        erpBarcodes.setBoxNo(palletNo); // 托盘号
+        erpBarcodes.setQty(qty); // 数量
+        erpBarcodes.setType(details.getdEdi09() == null ? "" : details.getdEdi09()); // 出入库类型
+        erpBarcodes.setErpNo(erpNo); // ERP单号
+        erpBarcodes.setErpName(details.getdEdi07() == null ? "" : details.getdEdi07());
+        erpBarcodes.setUserdefine7(details.getdEdi08() == null ? "" : details.getdEdi08()); // ERP单据类型
+        erpBarcodes.setUserdefine5(boxNo); // 箱号
+        erpBarcodes.setUserdefine3(details.getdEdi11() == null ? "" : details.getdEdi11()); // 人员
+        erpBarcodes.setUserdefine2(DateUtils.getTime());
+        erpBarcodes.setUserdefine1("Y"); // 状态(扫描记录是否有效)
+        erpBarcodes.setUserdefine8("N"); // 回传ERP标识
+        this.insertErpBarcodes(erpBarcodes);
+        return AjaxResult.success();
+    }
+
+
+    private AjaxResult untieRecordErpBarcodeList(String erpNo, String erpName, String sn) {
+        if (StringUtils.isEmpty(erpName)) {
+            return AjaxResult.success();
+        }
+        ErpBarcodes erpBarcodes = new ErpBarcodes();
+        erpBarcodes.setErpNo(erpNo);
+        erpBarcodes.setErpName(erpName);
+        erpBarcodes.setBarcode(sn);
+        erpBarcodes.setUserdefine1("Y");
+        erpBarcodes.setUserdefine8("N");
+        this.updateErpBarcodesBySn(erpBarcodes);
+        return AjaxResult.success();
+    }
+
+    @Override
+    public AjaxResult untieRecordErpBarcodeListAsnSo(String erpNo, String erpName, String sn) {
+        if (StringUtils.isEmpty(erpName)) {
+            return AjaxResult.success();
+        }
+        ErpBarcodes erpBarcodes = new ErpBarcodes();
+        erpBarcodes.setErpNo(erpNo);
+        erpBarcodes.setErpName(erpName);
+        erpBarcodes.setBarcode(sn);
+        erpBarcodes.setUserdefine1("N");
+        erpBarcodes.setUserdefine8("N");
+        this.updateErpBarcodesBySn(erpBarcodes);
+        return AjaxResult.success();
+    }
 }

+ 74 - 3
warewms-ams/src/main/java/com/ruoyi/ams/erp/service/impl/SyncServiceImpl.java

@@ -7,7 +7,9 @@ import com.ruoyi.ams.asn.domain.WmsDocAsnHeader;
 import com.ruoyi.ams.asn.service.IWmsDocAsnDetailsService;
 import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
 import com.ruoyi.ams.erp.domain.ErpBarCodeList;
+import com.ruoyi.ams.erp.domain.ErpBarcodes;
 import com.ruoyi.ams.erp.domain.ErpOrderList;
+import com.ruoyi.ams.erp.service.IErpBarcodesService;
 import com.ruoyi.ams.erp.service.ISyncService;
 import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
 import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
@@ -21,16 +23,14 @@ import com.ruoyi.base.service.IBaseSkuService;
 import com.ruoyi.base.service.IBaseSkuTypeService;
 import com.ruoyi.base.service.ICodeSkuRelationshipService;
 import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.http.HttpRequest;
-import com.ruoyi.common.utils.http.HttpUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -42,6 +42,7 @@ public class SyncServiceImpl implements ISyncService {
 
     public static final String ERP_SYNC_URL = "http://localhost:8089/warewms/erp/erpWriteData/erpSync";
     public static final String ERP_WRITE_BACK_URL = "http://localhost:8089/warewms/erp/erpWriteData/writeData";
+    public static final String ERP_WRITE_U_BACK_URL = "http://localhost:8089/warewms/erp/erpWriteData/writeDataU";
     public static final String ERP_UPDATE_STATUS_URL = "http://localhost:8089/warewms/erp/erpWriteData/updateOrderStatus";
     @Autowired
     private IBaseSkuTypeService baseSkuTypeService;
@@ -59,6 +60,8 @@ public class SyncServiceImpl implements ISyncService {
     IWmsDocAsnDetailsService wmsDocAsnDetailsService;
     @Autowired
     IWmsDocOrderDetailsService wmsDocOrderDetailsService;
+    @Autowired
+    private IErpBarcodesService erpBarcodesService;
 
     @Override
     public void syncSkuType() {
@@ -198,6 +201,13 @@ public class SyncServiceImpl implements ISyncService {
         return result.equals("200");
     }
 
+    @Override
+    public boolean writeBackU(ErpBarCodeList erpBarCodeList) throws Exception {
+        String jsonString = JSON.toJSONString(erpBarCodeList);
+        String result = HttpRequest.postData(SyncServiceImpl.ERP_WRITE_U_BACK_URL, jsonString);
+        return result.equals("200");
+    }
+
     @Override
     public boolean updateErpOrderStatus(ErpOrderList erpOrderList) throws Exception {
         String jsonString = JSON.toJSONString(erpOrderList);
@@ -268,4 +278,65 @@ public class SyncServiceImpl implements ISyncService {
             wmsDocOrderHeaderService.updateWmsDocOrderHeader(wmsDocOrderHeader1);
         }
     }
+
+    @Override
+    public void callBackSnScanRecord() throws Exception {
+        // 查询出需要回传的条码记录
+        ErpBarcodes erpBarcodesU = new ErpBarcodes();
+        erpBarcodesU.setUserdefine8("N");
+        List<ErpBarcodes> erpBarcodes = erpBarcodesService.selectErpBarcodesList(erpBarcodesU);
+        if (erpBarcodes.size() == 0) {
+            return;
+        }
+        for (ErpBarcodes erpBarcode : erpBarcodes) {
+            String userdefine6 = erpBarcode.getUserdefine6(); // 扫码记录是否新增
+            if (!"1".equals(userdefine6)) {
+                List<ErpBarCodeList> erpBarCodeListList = new ArrayList<>();
+                ErpBarCodeList erpBarCodeList = new ErpBarCodeList();
+                erpBarCodeList.setBarcode(erpBarcode.getBarcode());
+                erpBarCodeList.setOrderName(erpBarcode.getErpNo());
+                erpBarCodeList.setOrderNo(Integer.valueOf(erpBarcode.getErpName()));
+                erpBarCodeList.setQty(BigDecimal.ONE);
+                erpBarCodeList.setOrder_type(erpBarcode.getUserdefine7());
+                erpBarCodeList.setInOut(erpBarcode.getType());
+                erpBarCodeList.setStockId(erpBarcode.getStockId());
+                erpBarCodeList.setBoxNo(erpBarcode.getBoxNo());
+                erpBarCodeList.setErpResult("");
+                erpBarCodeList.setVaild(erpBarcode.getUserdefine1());
+                erpBarCodeList.setCreateUser(erpBarcode.getUserdefine3());
+                erpBarCodeList.setCreateDate(erpBarcode.getUserdefine2());
+                erpBarCodeList.setAlterUser("");
+                erpBarCodeList.setAlterDate("");
+                erpBarCodeListList.add(erpBarCodeList);
+//                boolean b = this.writeBack(erpBarCodeListList);
+                if (false) {
+                    log.error("条码记录表回传失败,单据号:" + erpBarcode.getErpNo());
+                    continue;
+                }
+                // 修改记录已经回传
+                ErpBarcodes erpBarcodeUpdate = new ErpBarcodes();
+                erpBarcodeUpdate.setId(erpBarcode.getId());
+                erpBarcodeUpdate.setUserdefine8("Y");
+                erpBarcodeUpdate.setUserdefine6("1"); // 新增
+                erpBarcodesService.updateErpBarcodes(erpBarcodeUpdate);
+
+            } else {
+                ErpBarCodeList erpBarCodeList = new ErpBarCodeList();
+                erpBarCodeList.setBarcode(erpBarcode.getBarcode());
+                erpBarCodeList.setOrderName(erpBarcode.getErpNo());
+                erpBarCodeList.setOrderNo(Integer.valueOf(erpBarcode.getErpName()));
+                erpBarCodeList.setVaild(erpBarcode.getUserdefine1());
+//                boolean b = this.writeBackU(erpBarCodeList);
+                if (false) {
+                    log.error("条码记录表修改失败,单据号:" + erpBarcode.getErpNo());
+                }
+                // 修改记录已经回传
+                ErpBarcodes erpBarcodeUpdate = new ErpBarcodes();
+                erpBarcodeUpdate.setId(erpBarcode.getId());
+                erpBarcodeUpdate.setUserdefine8("Y");
+                erpBarcodesService.updateErpBarcodes(erpBarcodeUpdate);
+            }
+        }
+
+    }
 }

+ 4 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/form/GroupDiskFrom.java

@@ -18,6 +18,10 @@ public class GroupDiskFrom {
      * 目标托盘
      */
     private String palletNoTo;
+    /**
+     * 箱子
+     */
+    private String boxNo;
     /**
      * 条码号
      */

+ 4 - 2
warewms-ams/src/main/java/com/ruoyi/ams/order/service/IWmsDocOrderHeaderService.java

@@ -375,7 +375,8 @@ public interface IWmsDocOrderHeaderService {
      * @param qty
      * @return
      */
-    AjaxResult modifystockCompletionStatus(String orderNo, String sku, BigDecimal qty);
+    AjaxResult modifystockCompletionStatus(String orderNo, String sku, BigDecimal qty
+            ,String sn,String palletNo,String boxNo);
 
     /**
      * 入库备货修改备货单备货状态
@@ -385,6 +386,7 @@ public interface IWmsDocOrderHeaderService {
      * @param qty
      * @return
      */
-    AjaxResult modifystockCompletionStatusAsn(String orderNo, String sku, BigDecimal qty);
+    AjaxResult modifystockCompletionStatusAsn(String orderNo, String sku, BigDecimal qty
+            ,String sn,String palletNo,String boxNo);
 
 }

+ 32 - 4
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -824,6 +824,9 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         }
         wmsDocOrderHeader.setOrderStatus(orderSts);
         wmsDocOrderHeaderService.updateWmsDocOrderHeader(wmsDocOrderHeader);
+        // 记录扫码数据
+        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetails,sn
+                ,"SORTATION01",palletNo,BigDecimal.ONE,"");
 
         return AjaxResult.success("拣货成功!" + endMsg);
     }
@@ -1299,6 +1302,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         String palletNoTo = groupDiskFrom.getPalletNoTo(); // 目标托盘
         String sn = groupDiskFrom.getSn(); // 条码号
         String orderNo = ""; // 出库单号(备货才会传入)
+        String boxNo = groupDiskFrom.getBoxNo() == null ?"":groupDiskFrom.getBoxNo(); //箱号
         String sku = ""; // 物料编码
         Double qty = Double.valueOf(groupDiskFrom.getQty()); // 数量
         boolean isAllUpdate = false; // 库存转移类型,是全部修改,还是拆分
@@ -1451,7 +1455,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                         }
                     }
                     // 更新出库单备货数量
-                    wmsDocOrderHeaderService.modifystockCompletionStatus(orderNo, sku, new BigDecimal(toQty));
+                    wmsDocOrderHeaderService.modifystockCompletionStatus(orderNo, sku, new BigDecimal(toQty)
+                    ,sn,palletNoFrom,boxNo);
                 }
 
             }
@@ -1476,6 +1481,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         String palletNoFrom = groupDiskFrom.getPalletNoFrom(); // 起始托盘
         String palletNoTo = groupDiskFrom.getPalletNoTo(); // 目标托盘
         String sn = groupDiskFrom.getSn(); // 条码号
+        String boxNo = groupDiskFrom.getBoxNo() == null ?"":groupDiskFrom.getBoxNo(); //箱号
         String orderNo = ""; // 出库单号
         String sku = ""; // 物料编码
         Double qty = Double.valueOf(groupDiskFrom.getQty()); // 数量
@@ -1494,6 +1500,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
             qty = 1.0; //产品默认为1
         }
         toQty = qty;
+        // todo 验证当前托盘sku原本分配了几个 现在已经备货了几个 如果相等了就不能备货了
         // 根据起始托盘,物料号查出库存
         InvLocIdSearchFrom locIdSearchFrom = new InvLocIdSearchFrom();
         locIdSearchFrom.setSku(sku);
@@ -1605,7 +1612,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                         invLotLocIdService.updateInvLotLocId(invLotLocIdUpdate);
                     }
                     // 更新出库单备货数量
-                    wmsDocOrderHeaderService.modifystockCompletionStatus(orderNo, sku, new BigDecimal(toQty));
+                    wmsDocOrderHeaderService.modifystockCompletionStatus(orderNo, sku, new BigDecimal(toQty)
+                            , sn, palletNoFrom, boxNo);
                 }
 
             }
@@ -2241,7 +2249,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
 
     @Transactional
-    public AjaxResult modifystockCompletionStatus(String orderNo, String sku, BigDecimal qty) {
+    public AjaxResult modifystockCompletionStatus(String orderNo, String sku, BigDecimal qty
+            ,String sn,String palletNo,String boxNo) {
         WmsDocOrderHeader docOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
         // 明细
         List<WmsDocOrderDetails> wmsDocOrderDetails = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByOrderNo(orderNo);
@@ -2267,6 +2276,9 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                             detailsUpdate.setLineStatus(Constant.ORDER_STS.STS23.getValue());
                         }
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
+                        // 记录扫码数据
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
+                                ,"SORTATION01",palletNo,BigDecimal.ONE,boxNo);
                         break;
                     } else if (qty.compareTo(toQty) == 1) {
                         qty = qty.subtract(toQty);
@@ -2275,9 +2287,15 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                             detailsUpdate.setLineStatus(Constant.ORDER_STS.STS23.getValue());
                         }
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
+                        // 记录扫码数据
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
+                                ,"SORTATION01",palletNo,BigDecimal.ONE,boxNo);
                     } else {
                         detailsUpdate.setQtySoftAllocated(wmsDocOrderDetail.getQtySoftAllocated().add(qty));
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
+                        // 记录扫码数据
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
+                                ,"SORTATION01",palletNo,BigDecimal.ONE,boxNo);
                         break;
                     }
                 }
@@ -2302,7 +2320,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     }
 
     @Transactional
-    public AjaxResult modifystockCompletionStatusAsn(String orderNo, String sku, BigDecimal qty) {
+    public AjaxResult modifystockCompletionStatusAsn(String orderNo, String sku, BigDecimal qty
+    ,String sn,String palletNo,String boxNo) {
         WmsDocOrderHeader docOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
         // 明细
         List<WmsDocOrderDetails> wmsDocOrderDetails = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByOrderNo(orderNo);
@@ -2330,6 +2349,9 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                             detailsUpdate.setLineStatus(Constant.ORDER_STS.STS20.getValue());
                         }
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
+                        // 记录扫码数据
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
+                                ,"STAGE01",palletNo,BigDecimal.ONE,boxNo);
                         break;
                         // 完全分配
                     } else if (qty.compareTo(toQty) == 1) {
@@ -2343,12 +2365,18 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
                             detailsUpdate.setLineStatus(Constant.ORDER_STS.STS20.getValue());
                         }
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
+                        // 记录扫码数据
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
+                                ,"SORTATION01",palletNo,BigDecimal.ONE,boxNo);
                         // 部分分配
                     } else {
                         detailsUpdate.setQtyAllocated(wmsDocOrderDetail.getQtyAllocated().add(qty));
                         detailsUpdate.setQtySoftAllocated(wmsDocOrderDetail.getQtySoftAllocated().add(qty));
                         detailsUpdate.setLineStatus(Constant.ORDER_STS.STS10.getValue());
                         wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(detailsUpdate);
+                        // 记录扫码数据
+                        erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetail,sn
+                                ,"SORTATION01",palletNo,BigDecimal.ONE,boxNo);
                         break;
                     }
                 }

+ 12 - 6
warewms-ams/src/main/resources/mapper/erp/ErpBarcodesMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.ams.erp.mapper.ErpBarcodesMapper">
-    
+
     <resultMap type="ErpBarcodes" id="ErpBarcodesResult">
         <result property="id"    column="id"    />
         <result property="barcode"    column="barcode"    />
@@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectErpBarcodesList" parameterType="ErpBarcodes" resultMap="ErpBarcodesResult">
         <include refid="selectErpBarcodesVo"/>
-        <where>  
+        <where>
             <if test="barcode != null  and barcode != ''"> and barcode = #{barcode}</if>
             <if test="stockId != null  and stockId != ''"> and stock_id = #{stockId}</if>
             <if test="locationNo != null  and locationNo != ''"> and location_no = #{locationNo}</if>
@@ -57,12 +57,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userdefine8 != null  and userdefine8 != ''"> and userdefine8 = #{userdefine8}</if>
         </where>
     </select>
-    
+
     <select id="selectErpBarcodesById" parameterType="Long" resultMap="ErpBarcodesResult">
         <include refid="selectErpBarcodesVo"/>
         where id = #{id}
     </select>
-        
+
     <insert id="insertErpBarcodes" parameterType="ErpBarcodes" useGeneratedKeys="true" keyProperty="id">
         insert into erp_barcodes
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -144,14 +144,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </update>
 
+    <update id="updateErpBarcodesBySn" parameterType="ErpBarcodes">
+        update erp_barcodes
+        set userdefine1 = #{userdefine1},userdefine8 = #{userdefine8}
+        where barcode = #{barcode} and erp_no = #{erpNo} and erp_name = #{erpName}
+    </update>
+
     <delete id="deleteErpBarcodesById" parameterType="Long">
         delete from erp_barcodes where id = #{id}
     </delete>
 
     <delete id="deleteErpBarcodesByIds" parameterType="String">
-        delete from erp_barcodes where id in 
+        delete from erp_barcodes where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-</mapper>
+</mapper>