Tiroble vor 3 Jahren
Ursprung
Commit
2588639389

+ 3 - 4
src/main/java/com/steerinfo/dil/controller/WmsInboundResultController.java

@@ -163,7 +163,7 @@ public class WmsInboundResultController extends BaseRESTfulController {
                 //三、创建一个入库作业实绩
                 WmspInboundResult wmspInboundResult = wmsInboundResultServiceImpl.initAndWmspInboundResult(i+1,personnelWorkshopid,groupId,userName,new BigDecimal(conditionMap.get("distributeId").toString()),houseGrid,item);
                 //改变扫码实绩里面的状态
-                int status= wmsInboundScanResultServiceImpl.updateInboundScanStatus(new BigDecimal(item.get("resultId").toString()));
+                int status= wmsInboundScanResultServiceImpl.updateInboundScanStatus(new BigDecimal(item.get("resultId").toString()),wmspInboundResult.getInboundId());
                 //当都完成的时候就要去改变这一批的状态改为下发状态
                 if(mapList.size()==i+1){
                     int status2= wmsInboundResultServiceImpl.updateInboundStatus(new BigDecimal(conditionMap.get("distributeId").toString()));
@@ -190,11 +190,10 @@ public class WmsInboundResultController extends BaseRESTfulController {
                 //三、创建一个入库作业实绩
                 WmspInboundResult wmspInboundResult = wmsInboundResultServiceImpl.initAndWmspInboundResult(i+1,personnelWorkshopid,groupId,userName,wmspInboundDistribute.getDistributeId(),houseGrid,item);
                 //改变扫码实绩里面的状态
-                int status= wmsInboundScanResultServiceImpl.updateInboundScanStatus(new BigDecimal(item.get("resultId").toString()));
+                int status= wmsInboundScanResultServiceImpl.updateInboundScanStatus(new BigDecimal(item.get("resultId").toString()),wmspInboundResult.getInboundId());
+
                 //创建实时库存
                 wmspGridMaterialService.initInsertWmspGridMaterial(item,houseGrid);
-
-
             }
             return success(null);
         }

+ 93 - 82
src/main/java/com/steerinfo/dil/controller/WmspOutboundResultController.java

@@ -2,6 +2,7 @@ package com.steerinfo.dil.controller;
 
 import com.steerinfo.dil.feign.ESFeign;
 import com.steerinfo.dil.mapper.CommonSeq;
+import com.steerinfo.dil.mapper.WmspInboundScanResultMapper;
 import com.steerinfo.dil.model.WmspOutboundResult;
 import com.steerinfo.dil.model.WmspOutboundScanResult;
 import com.steerinfo.dil.service.IWmspOutboundResultService;
@@ -21,10 +22,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * WmspOutboundResult RESTful接口:
@@ -46,6 +44,8 @@ public class WmspOutboundResultController extends BaseRESTfulController {
     @Autowired
     WmspOutboundResultServiceImpl wmspOutboundResultService;
     @Autowired
+    WmspInboundScanResultMapper wmspInboundScanResultMapper;
+    @Autowired
     CommonSeq commonSeq;
     @Autowired
     ESFeign esFeign;
@@ -150,87 +150,89 @@ public class WmspOutboundResultController extends BaseRESTfulController {
         Map<String,Object> map = new HashMap<>();
         map.put("orderId",orderId);
         map.put("materialId",materialId);
-        int orderNum = wmspOutboundResultService.ExistWmspOutboundResult(map);
         //初始化出库单详情信息
         Map<String, Object> outBoundDetailedInfo=null;
-        if(orderNum == 0){
-            /**创建出库单实体*/
-            WmspOutboundResult wmspOutboundResult = new WmspOutboundResult();
-            /**使用序列号增加生成主键id*/
-            int seq_wmspoutboundresult = commonSeq.getSeqNumber("seq__WMSP_OUTBOUND_RESULT");
-            /**获取到当前时间*/
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
-            /**生成出库单编号*/
-            String resultNumber = "XSCK" + sdf.format(new Date());
-            if(seq_wmspoutboundresult < 10){
-                resultNumber += "0000000" + seq_wmspoutboundresult;
-            }else if(seq_wmspoutboundresult < 100){
-                resultNumber += "000000" + seq_wmspoutboundresult;
-            }else if(seq_wmspoutboundresult < 1000){
-                resultNumber += "00000" + seq_wmspoutboundresult;
-            }else if(seq_wmspoutboundresult < 10000){
-                resultNumber += "0000" + seq_wmspoutboundresult;
-            }else  if(seq_wmspoutboundresult < 100000){
-                resultNumber += "000" + seq_wmspoutboundresult;
-            }else if(seq_wmspoutboundresult < 1000000){
-                resultNumber += "00" + seq_wmspoutboundresult;
-            }else if(seq_wmspoutboundresult < 10000000){
-                resultNumber += "0" + seq_wmspoutboundresult;
-            }else{
-                resultNumber += seq_wmspoutboundresult;
-            }
-            /**拿到运输订单类型*/
-            BigDecimal orderType = (BigDecimal) order.get("orderType");
-            /**运输订单类型判断
-             *    orderType : 1 为普通出库
-             *    orderType : 4 为调拨出库
-             * */
-            String resultOutboundType = "普通出库";
-            if(orderType.intValue() == 4){
-                resultOutboundType = "调拨出库";
-            }
-            /**把出库单主键id添加到出库单实体中*/
-            wmspOutboundResult.setResultId(new BigDecimal(seq_wmspoutboundresult));
-            /**把出库单编号添加到出库单实体中*/
-            wmspOutboundResult.setResultNumber(resultNumber);
-            /**把运输订单主键添加到出库单实体中*/
-            wmspOutboundResult.setBillLadingId(orderId);
-            /**把出库类型添加到出库单实体中*/
-            wmspOutboundResult.setResultOutboundType(resultOutboundType);
-            /**第一次添加为待出库*/
-            wmspOutboundResult.setResultStatus(new BigDecimal(0));
-            //常规字段
-            wmspOutboundResult.setInsertUsername("admin");
-            wmspOutboundResult.setInsertTime(new Date());
-            wmspOutboundResult.setUpdateUsername("admin");
-            wmspOutboundResult.setUpdateTime(new Date());
-            wmspOutboundResult.setInsertUpdateRemark("无");
-            wmspOutboundResult.setDeleted(new BigDecimal(0));
-            //还没装货的物资id的第一条添加到出库单实体中
-            wmspOutboundResult.setMaterialId(materialId);
-            Integer res = wmspOutboundResultService.insertSelective(wmspOutboundResult);
-            if(res == 1){
+        if ("".equals(wmspOutboundResultService.ExistWmspOutboundResult(map))){
+            int orderNum = wmspOutboundResultService.ExistWmspOutboundResult(map);
+            if(orderNum == 0){
+                /**创建出库单实体*/
+                WmspOutboundResult wmspOutboundResult = new WmspOutboundResult();
+                /**使用序列号增加生成主键id*/
+                int seq_wmspoutboundresult = commonSeq.getSeqNumber("seq__WMSP_OUTBOUND_RESULT");
+                /**获取到当前时间*/
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+                /**生成出库单编号*/
+                String resultNumber = "XSCK" + sdf.format(new Date());
+                if(seq_wmspoutboundresult < 10){
+                    resultNumber += "0000000" + seq_wmspoutboundresult;
+                }else if(seq_wmspoutboundresult < 100){
+                    resultNumber += "000000" + seq_wmspoutboundresult;
+                }else if(seq_wmspoutboundresult < 1000){
+                    resultNumber += "00000" + seq_wmspoutboundresult;
+                }else if(seq_wmspoutboundresult < 10000){
+                    resultNumber += "0000" + seq_wmspoutboundresult;
+                }else  if(seq_wmspoutboundresult < 100000){
+                    resultNumber += "000" + seq_wmspoutboundresult;
+                }else if(seq_wmspoutboundresult < 1000000){
+                    resultNumber += "00" + seq_wmspoutboundresult;
+                }else if(seq_wmspoutboundresult < 10000000){
+                    resultNumber += "0" + seq_wmspoutboundresult;
+                }else{
+                    resultNumber += seq_wmspoutboundresult;
+                }
+                /**拿到运输订单类型*/
+                BigDecimal orderType = (BigDecimal) order.get("orderType");
+                /**运输订单类型判断
+                 *    orderType : 1 为普通出库
+                 *    orderType : 4 为调拨出库
+                 * */
+                String resultOutboundType = "普通出库";
+                if(orderType.intValue() == 4){
+                    resultOutboundType = "调拨出库";
+                }
+                /**把出库单主键id添加到出库单实体中*/
+                wmspOutboundResult.setResultId(new BigDecimal(seq_wmspoutboundresult));
+                /**把出库单编号添加到出库单实体中*/
+                wmspOutboundResult.setResultNumber(resultNumber);
+                /**把运输订单主键添加到出库单实体中*/
+                wmspOutboundResult.setBillLadingId(orderId);
+                /**把出库类型添加到出库单实体中*/
+                wmspOutboundResult.setResultOutboundType(resultOutboundType);
+                /**第一次添加为待出库*/
+                wmspOutboundResult.setResultStatus(new BigDecimal(0));
+                //常规字段
+                wmspOutboundResult.setInsertUsername("admin");
+                wmspOutboundResult.setInsertTime(new Date());
+                wmspOutboundResult.setUpdateUsername("admin");
+                wmspOutboundResult.setUpdateTime(new Date());
+                wmspOutboundResult.setInsertUpdateRemark("无");
+                wmspOutboundResult.setDeleted(new BigDecimal(0));
+                //还没装货的物资id的第一条添加到出库单实体中
+                wmspOutboundResult.setMaterialId(materialId);
+                Integer res = wmspOutboundResultService.insertSelective(wmspOutboundResult);
+                if(res == 1){
 
+                    //返回出库单详情信息
+                    outBoundDetailedInfo = wmspOutboundResultService.getOutBoundDetailedInfo(orderId);
+                    outBoundDetailedInfo.put("orderNumber",orderNumber);
+//                outBoundDetailedInfo.put("personnelName",personnelName);
+                    outBoundDetailedInfo.put("materialCode",materialCode);
+                    outBoundDetailedInfo.put("materialName",materialName);
+                    outBoundDetailedInfo.put("materialSpecification",materialSpecification);
+                    outBoundDetailedInfo.put("materialModel",materialModel);
+                    outBoundDetailedInfo.put("materialTheoreticalWeight",materialTheoreticalWeight);
+                }
+            }else{
                 //返回出库单详情信息
                 outBoundDetailedInfo = wmspOutboundResultService.getOutBoundDetailedInfo(orderId);
                 outBoundDetailedInfo.put("orderNumber",orderNumber);
-//                outBoundDetailedInfo.put("personnelName",personnelName);
+//            outBoundDetailedInfo.put("personnelName",personnelName);
                 outBoundDetailedInfo.put("materialCode",materialCode);
                 outBoundDetailedInfo.put("materialName",materialName);
                 outBoundDetailedInfo.put("materialSpecification",materialSpecification);
                 outBoundDetailedInfo.put("materialModel",materialModel);
                 outBoundDetailedInfo.put("materialTheoreticalWeight",materialTheoreticalWeight);
             }
-        }else{
-            //返回出库单详情信息
-            outBoundDetailedInfo = wmspOutboundResultService.getOutBoundDetailedInfo(orderId);
-            outBoundDetailedInfo.put("orderNumber",orderNumber);
-//            outBoundDetailedInfo.put("personnelName",personnelName);
-            outBoundDetailedInfo.put("materialCode",materialCode);
-            outBoundDetailedInfo.put("materialName",materialName);
-            outBoundDetailedInfo.put("materialSpecification",materialSpecification);
-            outBoundDetailedInfo.put("materialModel",materialModel);
-            outBoundDetailedInfo.put("materialTheoreticalWeight",materialTheoreticalWeight);
         }
         return outBoundDetailedInfo;
     }
@@ -286,11 +288,6 @@ public class WmspOutboundResultController extends BaseRESTfulController {
             //通过装卸工工号查询装卸工Id
             BigDecimal personnelId = wmspOutboundResultService.getPersonnelIdByJobnumber(personnelJobNumber);
             //通过出库实绩Id判断出库单已扫描的件数是否等于运输订单物资表的物资件数
-            int EqualMaterialsNumber = wmspOutboundResultService.EqualMaterialsNumber(resultId);
-            if(EqualMaterialsNumber==1){
-                //相等返回装货数量已够
-                return failed("装货数量已够");
-            }else {
                 ///解析物质二维码信息
                 //截取扫描结果,得到物资唯一编码
                 String[] split = resultMaterial.split("-");
@@ -308,6 +305,11 @@ public class WmspOutboundResultController extends BaseRESTfulController {
                 int seq_wmspOutboundScanResult = commonSeq.getSeqNumber("seq__WMSP_OUTBOUND_SCAN_RESULT");
                 //插入主键id
                 wmspOutboundScanResult.setResultId(new BigDecimal(seq_wmspOutboundScanResult));
+                //根据物资id查询相对应的入库实绩ID,并将其赋值给相对应的入库扫描实绩表
+                List<Map<String, Object>> list= wmspInboundScanResultMapper.getInboundResultIdByMaterial(subResultMaterial);
+//                默认以获取到的第一个值作为入库实绩Id
+                Map<String ,Object> map1 = list.get(0);
+                wmspOutboundScanResult.setInboundResultId((BigDecimal) map1.get("inboundResultId"));
                 //插入出库实绩ID
                 wmspOutboundScanResult.setOutboundResultId(resultId);
                 //插入装卸工Id
@@ -325,8 +327,15 @@ public class WmspOutboundResultController extends BaseRESTfulController {
                 wmspOutboundScanResult.setUpdateTime(new Date());
                 wmspOutboundScanResult.setInsertUpdateRemark("无");
                 if(SteelMaterialId.intValue()==OutboundMaterialId.intValue()){
-                    //稽核成功,设定扫描实绩稽核结果为成功
-                    wmspOutboundScanResult.setResultCheck(new BigDecimal(0));
+                    int EqualMaterialsNumber = wmspOutboundResultService.EqualMaterialsNumber(resultId);
+                    if(EqualMaterialsNumber==1){
+                        //相等返回装货数量已够
+                        wmspOutboundScanResult.setResultCheck(new BigDecimal(1));
+                    }else {
+                        //稽核成功,设定扫描实绩稽核结果为成功
+                        wmspOutboundScanResult.setResultCheck(new BigDecimal(0));
+                    }
+
                     //插入扫描实绩
                     wmspOutboundResultService.scanResultInsert(wmspOutboundScanResult);
                 }else {
@@ -346,7 +355,9 @@ public class WmspOutboundResultController extends BaseRESTfulController {
                 //theSameOutboundInfo.put("warehouseName",warehouseName);
                 //2、获取出库扫描实绩数据
                 List<Map<String,Object>> scanAuditSuccessInfo = wmspOutboundResultService.scanAuditSuccessInfo(resultId);
-                //补全出库扫描实绩数据的信息
+                //补全出库扫描实绩数据的信息,对扫描实绩进行去重
+
+
                 for (Map<String, Object> stringObjectMap : scanAuditSuccessInfo) {
                     String resultMaterial1 = (String) stringObjectMap.get("resultMaterial");
                     //截取扫描结果,得到一件物资的详细信息
@@ -381,7 +392,7 @@ public class WmspOutboundResultController extends BaseRESTfulController {
                     stringObjectMap.putAll(theSameOutboundInfo);
                 }
                 return success(scanAuditSuccessInfo);
-            }
+
         }else{
             //返回已扫描并并稽核成功的物资信息
             //1、获取出库单统一信息

+ 4 - 0
src/main/java/com/steerinfo/dil/mapper/WmspInboundResultMapper.java

@@ -50,4 +50,8 @@ public interface WmspInboundResultMapper extends IBaseMapper<WmspInboundResult,
     BigDecimal getGrid(@Param("distributeId") String distributeId,@Param("resultNumber")  int row);
 
     int updateInboundStatus(BigDecimal distributeId);
+//    根据resultId查询对应的物资唯一编码
+    List<Map<String,Object>> getResultMaterialByResultId(Integer resultId);
+//    根据resultMaterialId获取相对应入库实绩和仓储网格
+    List<Map<String,Object>> getInboundResult(String resultMaterial);
 }

+ 3 - 1
src/main/java/com/steerinfo/dil/mapper/WmspInboundScanResultMapper.java

@@ -122,11 +122,13 @@ public interface WmspInboundScanResultMapper extends IBaseMapper<WmspInboundScan
 
     List<Map<String, Object>> noIssueScanResultList(String userName);
 
-    int updataStatusByResultId(BigDecimal resultId);
+    int updataStatusByResultId(BigDecimal resultId ,BigDecimal inboundId);
 
     Integer getResultStatusByResultId(String resultId);
 
     int isExist2(String userName, String resultMaterial);
 
     List<Map<String, Object>> noIssueScanResultList2(String userName);
+//    根据物资Id查询相对应的入库实绩ID
+    List<Map<String, Object>> getInboundResultIdByMaterial(String subResultMaterial);
 }

+ 15 - 0
src/main/java/com/steerinfo/dil/model/WmspOutboundScanResult.java

@@ -81,8 +81,22 @@ public class WmspOutboundScanResult implements IBasePO<BigDecimal> {
     @ApiModelProperty(value="记录创建或修改备注",required=false)
     private String insertUpdateRemark;
 
+    /**
+     * 分组信息
+     */
+    @ApiModelProperty(value="分组信息",required=false)
+    private BigDecimal inboundResultId;
+
     private static final long serialVersionUID = 1L;
 
+    public BigDecimal getInboundResultId() {
+        return inboundResultId;
+    }
+
+    public void setInboundResultId(BigDecimal inboundResultId) {
+        this.inboundResultId = inboundResultId;
+    }
+
     @Override
     public BigDecimal getId() {
         return this.resultId;
@@ -208,6 +222,7 @@ public class WmspOutboundScanResult implements IBasePO<BigDecimal> {
         sb.append(", updateTime=").append(updateTime);
         sb.append(", insertUpdateRemark=").append(insertUpdateRemark);
         sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append(", inboundResultId=").append(inboundResultId);
         sb.append("]");
         return sb.toString();
     }

+ 3 - 0
src/main/java/com/steerinfo/dil/service/IWmsInboundResultService.java

@@ -65,4 +65,7 @@ public interface IWmsInboundResultService {
 
     int updateInboundStatus(BigDecimal distributeId);
 
+//    创建一个方法根据出厂的resultId修改对应的入库实绩和仓储网格Id
+    int updateInboundGridStatus(Integer resultId);
+
 }

+ 1 - 1
src/main/java/com/steerinfo/dil/service/IWmsInboundScanResultService.java

@@ -122,7 +122,7 @@ public interface IWmsInboundScanResultService {
 //    根据index找到对应的成品并改变其入库状态
     int changeInboundIscomplete(BigDecimal index);
     //通过主键改变状态值
-     int updateInboundScanStatus(BigDecimal resultId);
+     int updateInboundScanStatus(BigDecimal resultId,BigDecimal inboundId);
 
     Integer getResultStatusByResultId(String resultId);
     //判断只扫一次的是否已经被扫过了

+ 31 - 3
src/main/java/com/steerinfo/dil/service/impl/WmsInboundResultServiceImpl.java

@@ -1,6 +1,8 @@
 package com.steerinfo.dil.service.impl;
 
+import com.steerinfo.dil.mapper.WmspGridMaterialMapper;
 import com.steerinfo.dil.mapper.WmspInboundResultMapper;
+import com.steerinfo.dil.model.WmspGridMaterial;
 import com.steerinfo.dil.model.WmspInboundResult;
 import com.steerinfo.dil.service.IWmsInboundResultService;
 import com.steerinfo.dil.util.IDUtils;
@@ -23,7 +25,8 @@ public class WmsInboundResultServiceImpl implements IWmsInboundResultService {
 
     @Autowired
     WmspInboundResultMapper wmspInboundResultMapper;
-
+    @Autowired
+    WmspGridMaterialMapper wmspGridMaterialMapper;
     /**
      * 1.展示入库实绩所有信息
      * @param mapValue
@@ -173,6 +176,31 @@ public class WmsInboundResultServiceImpl implements IWmsInboundResultService {
         return wmspInboundResultMapper.updateInboundStatus(distributeId);
     }
 
-
-
+//    根据出库的resultId修改入库实绩的逻辑删除状态和仓储网格的状态
+    @Override
+    public int updateInboundGridStatus(Integer resultId) {
+        int i=0;
+//        根据出库的resultId获取当前的吊刚工扫描结果
+        List<Map<String ,Object>> resultMaterial = wmspInboundResultMapper.getResultMaterialByResultId(resultId);
+        for (Map<String, Object> map1: resultMaterial){
+            String material = (String) map1.get("resultMaterial");
+            //        根据扫描吊牌得到的物资唯一编码修改对应的入库实绩状态和仓储网格状态
+            List<Map<String ,Object>> list =wmspInboundResultMapper.getInboundResult(material);
+            for (Map<String, Object> map:list){
+                BigDecimal inboundId = (BigDecimal) map.get("inboundId");
+                BigDecimal grmId = (BigDecimal) map.get("gmId");
+//        创建入库实绩实体类
+                WmspInboundResult wmspInboundResult = new WmspInboundResult();
+                wmspInboundResult.setInboundId(inboundId);
+                wmspInboundResult.setResultDeleted(new BigDecimal(1));
+                i+= wmspInboundResultMapper.updateByPrimaryKeySelective(wmspInboundResult);
+//        创建仓储网格实体类
+                WmspGridMaterial wmspGridMaterial = new WmspGridMaterial();
+                wmspGridMaterial.setGmId(grmId);
+                wmspGridMaterial.setDeleted(new BigDecimal(1));
+                i+= wmspGridMaterialMapper.updateByPrimaryKeySelective(wmspGridMaterial);
+            }
+        }
+        return i;
+    }
 }

+ 2 - 2
src/main/java/com/steerinfo/dil/service/impl/WmsInboundScanResultServiceImpl.java

@@ -325,8 +325,8 @@ public class WmsInboundScanResultServiceImpl implements IWmsInboundScanResultSer
         return wmspInboundStackResultMapper.updateByPrimaryKeySelective(wmspInboundStackResult);
     }
 
-    public int updateInboundScanStatus(BigDecimal resultId) {
-        return wmspInboundScanResultMapper.updataStatusByResultId(resultId);
+    public int updateInboundScanStatus(BigDecimal resultId,BigDecimal inboundId) {
+        return wmspInboundScanResultMapper.updataStatusByResultId(resultId,inboundId);
     }
 
     @Override

+ 9 - 2
src/main/java/com/steerinfo/dil/service/impl/WmspOutboundResultServiceImpl.java

@@ -3,6 +3,7 @@ package com.steerinfo.dil.service.impl;
 import com.steerinfo.dil.feign.TmstruckFeign;
 import com.steerinfo.dil.mapper.WmspOutboundResultMapper;
 import com.steerinfo.dil.mapper.WmspOutboundScanResultMapper;
+import com.steerinfo.dil.model.WmspInboundResult;
 import com.steerinfo.dil.model.WmspOutboundResult;
 import com.steerinfo.dil.model.WmspOutboundScanResult;
 import com.steerinfo.dil.service.IWmspOutboundResultService;
@@ -36,6 +37,8 @@ public class WmspOutboundResultServiceImpl  implements IWmspOutboundResultServic
 
     @Autowired
     private WmspOutboundScanResultMapper wmspOutboundScanResultMapper;
+    @Autowired
+    private WmsInboundResultServiceImpl wmsInboundResultService;
 
     @Autowired
     private TmstruckFeign tmstruckFeign;
@@ -179,13 +182,17 @@ public class WmspOutboundResultServiceImpl  implements IWmspOutboundResultServic
             // 设置出库实绩为成功、将出库实绩改完已经出库
             WmspOutboundResult wmspOutboundResult = wmspOutboundResultMapper.selectByPrimaryKey(new BigDecimal(resultId));
             wmspOutboundResult.setResultStatus(new BigDecimal(1));
-            result += wmspOutboundResultMapper.updateByPrimaryKeySelective(wmspOutboundResult);
+
             // 调用装货
             BigDecimal orderId = wmspOutboundResult.getBillLadingId();
             //result += tmstruckFeign.addSaleLoadResult(orderId.intValue());
             // 修改实时库存(逻辑删除) grid
             BigDecimal materialId = wmspOutboundResult.getMaterialId();
-            result += wmspOutboundResultMapper.updateGrid(materialId);
+//            创建一个方法用来修改入库实绩id的状态和仓储网格的状态,当且仅当返回值为2的时候是成功的
+            if (wmsInboundResultService.updateInboundGridStatus(resultId)%2 == 0){
+                result += wmspOutboundResultMapper.updateByPrimaryKeySelective(wmspOutboundResult);
+                result += wmspOutboundResultMapper.updateGrid(materialId);
+            }
         }
         return result;
     }

+ 22 - 0
src/main/resources/com/steerinfo/dil/mapper/WmspInboundResultMapper.xml

@@ -1172,8 +1172,30 @@
     <select id="getGrid" resultType="java.math.BigDecimal">
         select "gridId",rownum rm  from (select t.grid_Id "gridId" from WMSP_INBOUND_RESULT t where t.inbound_distribute_id=#{distributeId} and t.RESULT_NUMBER=#{resultNumber} ORDER BY inbound_time DESC )
     </select>
+<!--    根据resultId查询出对应的物资Id-->
+    <select id="getResultMaterialByResultId" resultType="java.util.LinkedHashMap">
+        SELECT  wosr.RESULT_MATERIAL "resultMaterial"
+        FROM WMSP_OUTBOUND_SCAN_RESULT wosr
+        WHERE wosr.RESULT_CHECK = 0
+        AND wosr.OUTBOUND_RESULT_ID = #{resultId}
+    </select>
+    <select id="getInboundResult" resultType="java.util.LinkedHashMap"
+            parameterType="java.util.Map">
+        SELECT
+               wir.INBOUND_ID "inboundId",
+               wgm.GM_ID "gmId"
+        FROM WMSP_INBOUND_RESULT wir
+        JOIN WMSP_INBOUND_SCAN_RESULT wisr
+        ON wisr.INBOUND_RESULT_ID = wir.INBOUND_ID
+        JOIN WMSP_GRID_MATERIAL wgm
+        ON wgm.GRID_ID = wir.GRID_ID
+        WHERE wisr.RESULT_MATERIAL = #{resultMaterial}
+    </select>
+
     <update id="updateInboundStatus">
        update WMSP_INBOUND_RESULT set RESULT_STATUS= 2 where INBOUND_DISTRIBUTE_ID =  #{distributeId}
     </update>
 
+
+
 </mapper>

+ 8 - 1
src/main/resources/com/steerinfo/dil/mapper/WmspInboundScanResultMapper.xml

@@ -568,7 +568,8 @@ where wisr.result_id = #{stackResultId}
     <update id="updataStatusByResultId">
          update wmsp_inbound_scan_result wisr
          set wisr.result_number=0,
-            wisr.result_status_=1
+            wisr.result_status_=1,
+             wisr.INBOUND_RESULT_ID =#{inboundId}
          where wisr.result_id = #{resultId}
     </update>
     <select id="selectScanTagResult" resultType="java.util.Map">
@@ -1064,6 +1065,12 @@ where wisr.result_id = #{stackResultId}
               and wisr.RESULT_STATUS_ = 0
               and wisr.inbound_Group_Id is null
     </select>
+<!--    根据物资Id查询相对应的入库实绩ID-->
+    <select id="getInboundResultIdByMaterial" resultType="java.util.LinkedHashMap">
+        SELECT wisr.INBOUND_RESULT_ID "inboundResultId"
+        FROM WMSP_INBOUND_SCAN_RESULT wisr
+        WHERE wisr.RESULT_MATERIAL = #{subResultMaterial}
+    </select>
 
 
 </mapper>

+ 10 - 3
src/main/resources/com/steerinfo/dil/mapper/WmspOutboundResultMapper.xml

@@ -711,7 +711,7 @@
   <select id="ExistWmspOutboundResult" parameterType="java.util.Map" resultType="int">
     select count(*)
     from WMSP_OUTBOUND_RESULT w_outbound
-    where w_outbound.BILL_LADING_ID=#{orderId} and w_outbound.MATERIAL_ID=#{materialId} and w_outbound.DELETED=0
+    where (w_outbound.DELETED=0 and w_outbound.RESULT_STATUS =1) and w_outbound.BILL_LADING_ID=#{orderId} and w_outbound.MATERIAL_ID=#{materialId}
   </select>
 
   <select id="getOutBoundDetailedInfo" parameterType="java.math.BigDecimal" resultType="java.util.LinkedHashMap">
@@ -754,8 +754,15 @@
   <!--  根据扫描结果查询扫描实绩是否存在-->
   <select id="ExistScanResult" parameterType="String" resultType="int">
     select count(*)
-    from WMSP_OUTBOUND_SCAN_RESULT outbound_scan
-    where outbound_scan.RESULT_MATERIAL = #{resultMaterial}
+    from WMSP_OUTBOUND_SCAN_RESULT wosr
+            join WMSP_OUTBOUND_RESULT wor
+            on wor.RESULT_ID = wosr.OUTBOUND_RESULT_ID
+           join WMSP_INBOUND_SCAN_RESULT wisr
+            on wosr.RESULT_MATERIAL = wisr.RESULT_MATERIAL
+            join WMSP_INBOUND_RESULT wir
+            on wisr.INBOUND_RESULT_ID = wir.INBOUND_ID
+    where  (wir.RESULT_DELETED = 0 or  wor.RESULT_STATUS = 1)
+          or wosr.RESULT_MATERIAL = #{resultMaterial}
   </select>
 
   <!--  通过物资物资唯一编码查询钢材物资表的物资Id-->

+ 31 - 7
src/main/resources/com/steerinfo/dil/mapper/WmspOutboundScanResultMapper.xml

@@ -14,15 +14,16 @@
     <result column="UPDATE_USERNAME" jdbcType="VARCHAR" property="updateUsername" />
     <result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime" />
     <result column="INSERT_UPDATE_REMARK" jdbcType="VARCHAR" property="insertUpdateRemark" />
+    <result column="INBOUND_RESULT_ID" jdbcType="DECIMAL" property="inboundResultId" />
   </resultMap>
   <sql id="columns">
     RESULT_ID, OUTBOUND_RESULT_ID, LOAD_ID, RESULT_MATERIAL, RESULT_LOAD_TIME, OUTBOUND_MATERIAL_NUMBER, 
-    RESULT_CHECK, INSERT_USERNAME, INSERT_TIME, UPDATE_USERNAME, UPDATE_TIME, INSERT_UPDATE_REMARK
+    RESULT_CHECK, INSERT_USERNAME, INSERT_TIME, UPDATE_USERNAME, UPDATE_TIME, INSERT_UPDATE_REMARK,INBOUND_RESULT_ID
   </sql>
   <sql id="columns_alias">
     t.RESULT_ID, t.OUTBOUND_RESULT_ID, t.LOAD_ID, t.RESULT_MATERIAL, t.RESULT_LOAD_TIME, 
     t.OUTBOUND_MATERIAL_NUMBER, t.RESULT_CHECK, t.INSERT_USERNAME, t.INSERT_TIME, t.UPDATE_USERNAME, 
-    t.UPDATE_TIME, t.INSERT_UPDATE_REMARK
+    t.UPDATE_TIME, t.INSERT_UPDATE_REMARK ,t.INBOUND_RESULT_ID
   </sql>
   <sql id="select">
     SELECT <include refid="columns"/> FROM WMSP_OUTBOUND_SCAN_RESULT
@@ -68,6 +69,9 @@
       <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
         and INSERT_UPDATE_REMARK = #{insertUpdateRemark}
       </if>
+      <if test="inboundResultId != null">
+        and INBOUND_RESULT_ID = #{inboundResultId}
+      </if>
     </where>
   </sql>
   <sql id="whereLike">
@@ -108,6 +112,9 @@
       <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
         and INSERT_UPDATE_REMARK LIKE '%${insertUpdateRemark}%'
       </if>
+      <if test="inboundResultId != null and inboundResultId != ''">
+        and INBOUND_RESULT_ID LIKE '%${inboundResultId}%'
+      </if>
     </where>
   </sql>
   <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal">
@@ -150,17 +157,20 @@
       <if test="insertUpdateRemark != null and insertUpdateRemark != ''">
         or INSERT_UPDATE_REMARK = #{insertUpdateRemark}
       </if>
+      <if test="inboundResultId != null and inboundResultId != ''">
+        or INBOUND_RESULT_ID = #{inboundResultId}
+      </if>
   </delete>
   <insert id="insert" parameterType="com.steerinfo.dil.model.WmspOutboundScanResult">
     insert into WMSP_OUTBOUND_SCAN_RESULT (RESULT_ID, OUTBOUND_RESULT_ID, LOAD_ID, 
       RESULT_MATERIAL, RESULT_LOAD_TIME, OUTBOUND_MATERIAL_NUMBER, 
       RESULT_CHECK, INSERT_USERNAME, INSERT_TIME, 
-      UPDATE_USERNAME, UPDATE_TIME, INSERT_UPDATE_REMARK
+      UPDATE_USERNAME, UPDATE_TIME, INSERT_UPDATE_REMARK,INBOUND_RESULT_ID
       )
     values (#{resultId,jdbcType=DECIMAL}, #{outboundResultId,jdbcType=DECIMAL}, #{loadId,jdbcType=DECIMAL}, 
       #{resultMaterial,jdbcType=VARCHAR}, #{resultLoadTime,jdbcType=TIMESTAMP}, #{outboundMaterialNumber,jdbcType=DECIMAL}, 
       #{resultCheck,jdbcType=DECIMAL}, #{insertUsername,jdbcType=VARCHAR}, #{insertTime,jdbcType=TIMESTAMP}, 
-      #{updateUsername,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{insertUpdateRemark,jdbcType=VARCHAR}
+      #{updateUsername,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, #{insertUpdateRemark,jdbcType=VARCHAR},#{inboundResultId,jdbcType=DECIMAL}
       )
   </insert>
   <insert id="insertSelective" parameterType="com.steerinfo.dil.model.WmspOutboundScanResult">
@@ -202,6 +212,9 @@
       <if test="insertUpdateRemark != null">
         INSERT_UPDATE_REMARK,
       </if>
+      <if test="inboundResultId != null">
+        INBOUND_RESULT_ID,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="resultId != null">
@@ -240,6 +253,9 @@
       <if test="insertUpdateRemark != null">
         #{insertUpdateRemark,jdbcType=VARCHAR},
       </if>
+      <if test="inboundResultId != null">
+        #{inboundResultId,jdbcType=DECIMAL},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKey" parameterType="com.steerinfo.dil.model.WmspOutboundScanResult">
@@ -254,7 +270,8 @@
       INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
       UPDATE_USERNAME = #{updateUsername,jdbcType=VARCHAR},
       UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
-      INSERT_UPDATE_REMARK = #{insertUpdateRemark,jdbcType=VARCHAR}
+      INSERT_UPDATE_REMARK = #{insertUpdateRemark,jdbcType=VARCHAR},
+      INBOUND_RESULT_ID = #{inboundResultId,jdbcType=DECIMAL},
     where RESULT_ID = #{resultId,jdbcType=DECIMAL}
   </update>
   <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.dil.model.WmspOutboundScanResult">
@@ -293,6 +310,9 @@
       <if test="insertUpdateRemark != null">
         INSERT_UPDATE_REMARK = #{insertUpdateRemark,jdbcType=VARCHAR},
       </if>
+      <if test="inboundResultId != null">
+        INBOUND_RESULT_ID = #{inboundResultId,jdbcType=DECIMAL},
+      </if>
     </set>
     where RESULT_ID = #{resultId,jdbcType=DECIMAL}
   </update>
@@ -315,7 +335,7 @@
       RESULT_LOAD_TIME, OUTBOUND_MATERIAL_NUMBER, 
       RESULT_CHECK, INSERT_USERNAME, 
       INSERT_TIME, UPDATE_USERNAME, 
-      UPDATE_TIME, INSERT_UPDATE_REMARK
+      UPDATE_TIME, INSERT_UPDATE_REMARK,INBOUND_RESULT_ID
       )
     ( <foreach collection="list" item="item" separator="union all"> 
    select  
@@ -324,7 +344,7 @@
       #{item.resultLoadTime,jdbcType=TIMESTAMP}, #{item.outboundMaterialNumber,jdbcType=DECIMAL}, 
       #{item.resultCheck,jdbcType=DECIMAL}, #{item.insertUsername,jdbcType=VARCHAR}, 
       #{item.insertTime,jdbcType=TIMESTAMP}, #{item.updateUsername,jdbcType=VARCHAR}, 
-      #{item.updateTime,jdbcType=TIMESTAMP}, #{item.insertUpdateRemark,jdbcType=VARCHAR}
+      #{item.updateTime,jdbcType=TIMESTAMP}, #{item.insertUpdateRemark,jdbcType=VARCHAR}, #{item.inboundResultId,jdbcType=DECIMAL}
        from dual  
    </foreach> )
   </insert>
@@ -379,6 +399,10 @@
        <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
           when #{item.resultId,jdbcType=DECIMAL} then #{item.insertUpdateRemark,jdbcType=VARCHAR}
        </foreach>
+      ,INBOUND_RESULT_ID=
+      <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+        when #{item.resultId,jdbcType=DECIMAL} then #{item.inboundResultId,jdbcType=DECIMAL}
+      </foreach>
      where RESULT_ID in 
      <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
     #{item.resultId,jdbcType=DECIMAL}