luobang 1 年之前
父节点
当前提交
c8ee3b0b9e

+ 1 - 1
pom.xml

@@ -194,7 +194,7 @@
                     <!--包名-->
                     <targetPackage>com.steerinfo.dil</targetPackage>
                     <tables>
-<!--                        <table>OMSTRAIN_ORDER</table>-->
+                        <table>TMSTRUCK_WEIGHT_BATCH</table>
                     </tables>
                 </configuration>
                 <executions>

+ 23 - 0
src/main/java/com/steerinfo/dil/mapper/TmstruckWeightBatchMapper.java

@@ -0,0 +1,23 @@
+package com.steerinfo.dil.mapper;
+
+import com.steerinfo.dil.model.TmstruckWeightBatch;
+//import com.steerinfo.dil.tmstruckweightbatch.model;
+import com.steerinfo.framework.mapper.IBaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+@Mapper
+public interface TmstruckWeightBatchMapper extends IBaseMapper<TmstruckWeightBatch, BigDecimal> {
+
+
+    @Select("select seq_tms_weight_batch.nextval from dual")
+    BigDecimal weightBatchID();
+
+    int updateFluMes(Map<String, Object> weightMap);
+
+    int updateOmMes(Map<String, Object> weightMap);
+
+}

+ 138 - 0
src/main/java/com/steerinfo/dil/model/TmstruckWeightBatch.java

@@ -0,0 +1,138 @@
+package com.steerinfo.dil.model;
+
+import com.steerinfo.framework.model.IBasePO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@ApiModel(value="计量批次表")
+public class TmstruckWeightBatch implements IBasePO<BigDecimal> {
+    /**
+     * 计量批次ID(WEIGHT_BATCH_ID,DECIMAL,38)
+     */
+    @ApiModelProperty(value="计量批次ID",required=true)
+    private BigDecimal weightBatchId;
+
+    /**
+     * 净重(BATCH_NET_WEIGHT,DECIMAL,38)
+     */
+    @ApiModelProperty(value="净重",required=false)
+    private BigDecimal batchNetWeight;
+
+    /**
+     * 毛重(BATCH_GROSS_WEIGHT,DECIMAL,38)
+     */
+    @ApiModelProperty(value="毛重",required=false)
+    private BigDecimal batchGrossWeight;
+
+    /**
+     * 皮重(BATCH_TARE_WEIGHT,DECIMAL,38)
+     */
+    @ApiModelProperty(value="皮重",required=false)
+    private BigDecimal batchTareWeight;
+
+    /**
+     * 皮重时间(BATCH_TARE_WEIGHT_TIME,TIMESTAMP,7)
+     */
+    @ApiModelProperty(value="皮重时间",required=false)
+    private Date batchTareWeightTime;
+
+    /**
+     * 备注(BATCH_REMARK,VARCHAR,200)
+     */
+    @ApiModelProperty(value="备注",required=false)
+    private String batchRemark;
+
+    /**
+     * 毛重时间(BATCH_GROSS_WEIGHT_TIME,TIMESTAMP,7)
+     */
+    @ApiModelProperty(value="毛重时间",required=false)
+    private Date batchGrossWeightTime;
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public BigDecimal getId() {
+        return this.weightBatchId;
+    }
+
+    @Override
+    public void setId(BigDecimal weightBatchId) {
+        this.weightBatchId = weightBatchId;
+    }
+
+    public BigDecimal getWeightBatchId() {
+        return weightBatchId;
+    }
+
+    public void setWeightBatchId(BigDecimal weightBatchId) {
+        this.weightBatchId = weightBatchId;
+    }
+
+    public BigDecimal getBatchNetWeight() {
+        return batchNetWeight;
+    }
+
+    public void setBatchNetWeight(BigDecimal batchNetWeight) {
+        this.batchNetWeight = batchNetWeight;
+    }
+
+    public BigDecimal getBatchGrossWeight() {
+        return batchGrossWeight;
+    }
+
+    public void setBatchGrossWeight(BigDecimal batchGrossWeight) {
+        this.batchGrossWeight = batchGrossWeight;
+    }
+
+    public BigDecimal getBatchTareWeight() {
+        return batchTareWeight;
+    }
+
+    public void setBatchTareWeight(BigDecimal batchTareWeight) {
+        this.batchTareWeight = batchTareWeight;
+    }
+
+    public Date getBatchTareWeightTime() {
+        return batchTareWeightTime;
+    }
+
+    public void setBatchTareWeightTime(Date batchTareWeightTime) {
+        this.batchTareWeightTime = batchTareWeightTime;
+    }
+
+    public String getBatchRemark() {
+        return batchRemark;
+    }
+
+    public void setBatchRemark(String batchRemark) {
+        this.batchRemark = batchRemark == null ? null : batchRemark.trim();
+    }
+
+    public Date getBatchGrossWeightTime() {
+        return batchGrossWeightTime;
+    }
+
+    public void setBatchGrossWeightTime(Date batchGrossWeightTime) {
+        this.batchGrossWeightTime = batchGrossWeightTime;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", weightBatchId=").append(weightBatchId);
+        sb.append(", batchNetWeight=").append(batchNetWeight);
+        sb.append(", batchGrossWeight=").append(batchGrossWeight);
+        sb.append(", batchTareWeight=").append(batchTareWeight);
+        sb.append(", batchTareWeightTime=").append(batchTareWeightTime);
+        sb.append(", batchRemark=").append(batchRemark);
+        sb.append(", batchGrossWeightTime=").append(batchGrossWeightTime);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 150 - 136
src/main/java/com/steerinfo/dil/service/impl/TmstruckWeightResultServiceImpl.java

@@ -6,6 +6,7 @@ import com.steerinfo.dil.feign.TmstruckFeign;
 import com.steerinfo.dil.mapper.*;
 import com.steerinfo.dil.model.OmstruckOrder;
 import com.steerinfo.dil.model.TmstruckReceiveResult;
+import com.steerinfo.dil.model.TmstruckWeightBatch;
 import com.steerinfo.dil.model.TmstruckWeightResult;
 import com.steerinfo.dil.service.ITmstruckWeightResultService;
 import com.steerinfo.dil.util.DataChange;
@@ -73,6 +74,9 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
     @Autowired
     SaleLogUtil saleLogUtil;
 
+    @Autowired
+    TmstruckWeightBatchMapper tmstruckWeightBatchMapper;
+
     //属于采购订单的订单类型(先计毛后计皮)
     final private List<Integer> judgeOrderTypeList = Arrays.asList(5, 6, 7, 8, 9, 12, 15, 17, 18,23,24,19);
 
@@ -299,154 +303,114 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
         //String FLID = (String) map.get("FLID");
         Object resultNetWeight = map.get("resultNetWeight");
         Object FLID = map.get("FLID");
-        //判断该车有没有净重
-        if (resultNetWeight  != null && !"".equals(resultNetWeight) && FLID  != null && !"".equals(FLID)) {
-            String flId = FLID.toString();
-            map.put("flId",flId);
-            BigDecimal orderIdByFLID = omstruckOrderMapper.selectOrderIdByFLID(FLID);
-            BigDecimal saleMaterialId = tmstruckWeightResultMapper.getSaleMaterialId(map);
-            //首先判断该分录有没有净重
-            Map<String,Object> orderMesBySaleMaterialId = tmstruckWeightResultMapper.getOrderMesBySaleMaterialIdHaveWeight(saleMaterialId);
-            if(orderMesBySaleMaterialId == null) {
-                //根据分录id和车号去找
-                Map<String,Object> orderMesByOrderIdByFLID = tmstruckWeightResultMapper.getOrderMesBySaleMaterialId(orderIdByFLID);
-                if(orderMesByOrderIdByFLID != null) {
-                    map.putAll(orderMesByOrderIdByFLID);
-                    map.put("saleMaterialId",saleMaterialId);
-                }else{
-                    throw new Exception("该分录对应的订单没有净重可供填充!");
-                }
-            }else{
-                map.putAll(orderMesBySaleMaterialId);
+        List<Map<String,Object>> weightMapList = new ArrayList<>();
+        if(resultNetWeight  != null && !"".equals(resultNetWeight) && FLID  != null && !"".equals(FLID)) {
+            //物资
+            Object good = map.get("good");
+            //物资数量
+            Object goodNum = map.get("goodNum");
+            //理重
+            Object theoryWeight = map.get("theoryWeight");
+            String[] goodList = good.toString().split("、");
+            String[] flIdList = FLID.toString().split("&");
+            String[] goodNumList = goodNum.toString().split("、");
+            String[] theoryWeightList = theoryWeight.toString().split("、");
+            for(int i = 0 ; i < flIdList.length ; i ++) {
+                Map<String, Object> codeMap = new HashMap<>();
+                codeMap.putAll(map);
+                codeMap.put("FLID",flIdList[i]);
+                codeMap.put("good",goodList[i]);
+                codeMap.put("goodNum",goodNumList[i]);
+                codeMap.put("theoryWeight",theoryWeightList[i]);
+                weightMapList.add(codeMap);
             }
-        }else{
-            Map<String,Object> orderMes = tmstruckWeightResultMapper.getOrderMes(carNo);
-            if (orderMes == null) {
-                throw new Exception("该车无分录ID且无正在运行中的订单,系统无法匹配数据");
+            if(weightMapList.size() > 1) {
+                weightMapList.get(weightMapList.size() - 1).put("resultNetWeight",0);
+                weightMapList.get(weightMapList.size() - 1).put("resultTareWeight",0);
+                weightMapList.get(weightMapList.size() - 1).put("resultCrossWeight",0);
             }
-            map.putAll(orderMes);
-        }
-        //不能影响皮重
-        //if (orderMes == null){
-        //    Object FLID = map.get("FLID");
-        //    if(FLID != null && !"".equals(FLID)) {
-        //        //存在分录id,说明有整条数据,且该车又没有正在运行中的信息,那么就去找该分录id对应的运单的信息
-        //        BigDecimal orderIdByFLID = omstruckOrderMapper.selectOrderIdByFLID(FLID);
-        //        if(orderIdByFLID != null) {
-        //            Map<String,Object> orderMesByFLIDMap = tmstruckWeightResultMapper.getOrderMesByOrderId(orderIdByFLID);
-        //            if(orderMesByFLIDMap != null) {
-        //                map.putAll(orderMesByFLIDMap);
-        //            }else{
-        //                Map<String,Object> orderMesByFLIDMapNoWeight = tmstruckWeightResultMapper.getOrderMesByOrderIdNoWeight(orderIdByFLID);
-        //                throw new Exception("没有可进行填充的计量实绩");
-        //            }
-        //        }else{
-        //            throw new Exception("该分录没有对应的订单");
-        //        }
-        //    }else{
-        //        throw new Exception("没有正在运行中的订单");
-        //    }
-        //}
-        tmstruckWeightResult.setId(DataChange.dataToBigDecimal(map.get("weightTaskResultId")));
-        int orderType = DataChange.dataToBigDecimal(map.get("orderTypee")).intValue();
-        //磅单号
-        tmstruckWeightResult.setResultPoundNo((String) map.get("resultPoundNo"));
-        String resultCrossWeightTime = (String) map.get("resultCrossWeightTime");
-        if(map.get("orderNumber") != null) {
-            tmstruckWeightResult.setInsertUpdateRemark((String)map.get("orderNumber"));
+            map.put("weightMapList",weightMapList);
+            addWeightBatchResult(map);
+        }else{
+            weightMapList.add(map);
         }
-        if(resultNetWeight  != null && !"".equals(resultNetWeight)) {
-            BigDecimal materialId = tmstruckWeightResultMapper.getMaterialId(map);
-            if(materialId == null){
-                throw new Exception("系统找不到该物资");
-            }
-            map.put("materialId",materialId);
-            try {
-                Map<String,Object> weightSaleMes = tmstruckWeightResultMapper.getWeightAndSaleMaterialId(map);
-                if(weightSaleMes != null && DataChange.dataToBigDecimal(weightSaleMes.get("materialIdSale")).compareTo(materialId) == 0) {
-                    map.putAll(weightSaleMes);
-                    tmstruckWeightResult.setId(DataChange.dataToBigDecimal(map.get("weightTaskResultId")));
+        for(Map<String,Object> codeMap : weightMapList) {
+            //判断该车有没有净重
+            BigDecimal saleMaterialId = null;
+            if (resultNetWeight  != null && !"".equals(resultNetWeight) && codeMap.get("FLID")  != null && !"".equals(codeMap.get("FLID"))) {
+                String flId = codeMap.get("FLID").toString();
+                codeMap.put("flId",flId);
+                BigDecimal orderIdByFLID = omstruckOrderMapper.selectOrderIdByFLID(codeMap.get("FLID"));
+                saleMaterialId = tmstruckWeightResultMapper.getSaleMaterialId(codeMap);
+                codeMap.put("saleMaterialId",saleMaterialId);
+                //首先判断该分录有没有净重
+                Map<String,Object> orderMesBySaleMaterialId = tmstruckWeightResultMapper.getOrderMesBySaleMaterialIdHaveWeight(saleMaterialId);
+                if(orderMesBySaleMaterialId == null) {
+                    //根据分录id和车号去找
+                    Map<String,Object> orderMesByOrderIdByFLID = tmstruckWeightResultMapper.getOrderMesBySaleMaterialId(orderIdByFLID);
+                    if(orderMesByOrderIdByFLID != null) {
+                        codeMap.putAll(orderMesByOrderIdByFLID);
+                    }else{
+                        throw new Exception("该分录对应的订单没有净重可供填充!");
+                    }
+                }else{
+                    codeMap.putAll(orderMesBySaleMaterialId);
                 }
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-            //判断此物资是不是已经有净重了,如果有抛出异常
-            //int netWeightCount = tmstruckWeightResultMapper.getHaveNetWeightByMaterial(map);
-            //if(netWeightCount != 0){
-            //    throw new Exception("该物资已有净重,不能再次录入");
-            //}
-            tmstruckWeightResult.setMaterialId(materialId);
-            tmstruckWeightResult.setMaterialNum(DataChange.dataToBigDecimal(map.get("goodNum")));
-            if(map.get("saleMaterialId") != null) {
-                tmstruckWeightResult.setSaleMaterialId(DataChange.dataToBigDecimal(map.get("saleMaterialId")));
-            }
-            BigDecimal materialNum = DataChange.dataToBigDecimal(map.get("goodNum"));
-            //通过订单ID和物资id,查询当单个物资的理重方便后续计算
-            Map<String, Object> saleMaterialMes = tmstruckWeightResultMapper.getSaleOrderMaterialNum(map);
-            if(saleMaterialMes == null) {
-                throw new Exception("该订单没有该物资分录");
-            }
-            BigDecimal saleMaterialId = DataChange.dataToBigDecimal(saleMaterialMes.get("saleMaterialId"));//销售订单存放物资子表id
-            BigDecimal orderMaterialId = DataChange.dataToBigDecimal(saleMaterialMes.get("orderMaterialId"));
-            BigDecimal materialWeight = DataChange.dataToBigDecimal(saleMaterialMes.get("materialWeight"));//旧总理重
-            tmstruckWeightResult.setSaleMaterialId(saleMaterialId);
-            map.put("orderMaterialId",orderMaterialId);
-            map.put("saleMaterialId",saleMaterialId);
-            BigDecimal newWeight = null;
-            if (materialWeight.intValue() != 0) { //如果总重量不为0,才进行重量更新
-                BigDecimal orderMaterialNumber = DataChange.dataToBigDecimal(saleMaterialMes.get("orderMaterialNumber"));//旧件数
-                BigDecimal theoreticalWeight = materialWeight.multiply(materialNum);
-                newWeight =  theoreticalWeight.divide(orderMaterialNumber,3,4);//得到现有理重
-                map.put("newWeight",newWeight);
-                //更新运输订单物资子表的件数和理论重量
+            }else{
+                Map<String,Object> orderMes = tmstruckWeightResultMapper.getOrderMes(carNo);
+                if (orderMes == null) {
+                    throw new Exception("该车无分录ID且无正在运行中的订单,系统无法匹配数据");
+                }
+                codeMap.putAll(orderMes);
             }
-            if(map.get("theoryWeight") != null && !"".equals(map.get("theoryWeight"))) {
-                newWeight = DataChange.dataToBigDecimal(map.get("theoryWeight"));
-                map.put("newWeight",newWeight);
+            tmstruckWeightResult.setId(DataChange.dataToBigDecimal(codeMap.get("weightTaskResultId")));
+            int orderType = DataChange.dataToBigDecimal(codeMap.get("orderTypee")).intValue();
+            //磅单号
+            tmstruckWeightResult.setResultPoundNo((String) codeMap.get("resultPoundNo"));
+            String resultCrossWeightTime = (String) codeMap.get("resultCrossWeightTime");
+            if(codeMap.get("orderNumber") != null) {
+                tmstruckWeightResult.setInsertUpdateRemark((String)codeMap.get("orderNumber"));
             }
-            tmstruckWeightResultMapper.updateOrderMaterial(map);
-            tmstruckWeightResultMapper.updateSaleMaterialId(saleMaterialId,materialNum,newWeight);
-            //去掉该实绩下没有净重的有分录id的
-            tmstruckWeightResultMapper.updateQuitSaleMaterialId(map);
-        }else{
-            //根据运单id查询其中一个物资id,确保报表能有数据
-            //查询没有净重的,不影响之前代码
-            //首先看没有净重的实绩里面有没有有分录id的
-            List<BigDecimal> weightSaleMaterialIds = tmstruckWeightResultMapper.getWeightTaskIdCopy(DataChange.dataToBigDecimal(map.get("resultTotalId")));
-            if(weightSaleMaterialIds.size() == 0) {
-                //如果没有,那么就找一个saleMaterialId放进去
-                BigDecimal saleMaterialIds = tmstruckWeightResultMapper.getMaterialIdByOrderId(DataChange.dataToBigDecimal(map.get("orderId")));
-                if(saleMaterialIds != null) {
-                    tmstruckWeightResult.setSaleMaterialId(saleMaterialIds);
+            if(resultNetWeight  != null && !"".equals(resultNetWeight) && codeMap.get("saleMaterialId") != null) {
+                codeMap.put("good",codeMap.get("goodspa") + "" + codeMap.get("good"));
+                BigDecimal materialId = tmstruckWeightResultMapper.getMaterialId(codeMap);
+                if(materialId == null){
+                    throw new Exception("系统找不到该物资");
                 }
+                codeMap.put("materialId",materialId);
+                tmstruckWeightResult.setMaterialId(materialId);
+                tmstruckWeightResult.setMaterialNum(DataChange.dataToBigDecimal(codeMap.get("goodNum")));
+                tmstruckWeightResult.setSaleMaterialId(DataChange.dataToBigDecimal(codeMap.get("saleMaterialId")));
+                tmstruckWeightResult.setSaleMaterialId(saleMaterialId);
             }
-        }
-        addWeightResult(tmstruckWeightResult, map); //添加计量实绩数据
-        // 更新订单中路段顺序号,如果毛重时间为空则为计皮:也就是销售第一次计皮,反之有毛重时间则为计毛
-        if(resultCrossWeightTime == null || resultCrossWeightTime.length() == 0){
-            map.put("segmentSqe", map.get("tareSegmentSqe")); //皮重路段顺序
-        }else{
-            //查询有净重的路段顺序号最大的
-            BigDecimal orderLineSqe = tmstruckWeightResultMapper.selectOrderLineSqe(DataChange.dataToBigDecimal(map.get("resultTotalId")));
-            if(orderLineSqe != null && orderLineSqe.compareTo(DataChange.dataToBigDecimal(map.get("grossSegmentSqe"))) > 0){
-                map.put("segmentSqe",orderLineSqe);
+            addWeightResult(tmstruckWeightResult, codeMap); //添加计量实绩数据
+            // 更新订单中路段顺序号,如果毛重时间为空则为计皮:也就是销售第一次计皮,反之有毛重时间则为计毛
+            if(resultCrossWeightTime == null || resultCrossWeightTime.length() == 0){
+                codeMap.put("segmentSqe", codeMap.get("tareSegmentSqe")); //皮重路段顺序
             }else{
-                map.put("segmentSqe", map.get("grossSegmentSqe")); //毛重路段顺序
+                //查询有净重的路段顺序号最大的
+                BigDecimal orderLineSqe = tmstruckWeightResultMapper.selectOrderLineSqe(DataChange.dataToBigDecimal(codeMap.get("resultTotalId")));
+                if(orderLineSqe != null && orderLineSqe.compareTo(DataChange.dataToBigDecimal(codeMap.get("grossSegmentSqe"))) > 0){
+                    codeMap.put("segmentSqe",orderLineSqe);
+                }else{
+                    codeMap.put("segmentSqe", codeMap.get("grossSegmentSqe")); //毛重路段顺序
+                }
             }
-        }
-        if(orderType == 1 || orderType == 4){
-            //如果是钢材订单,获取下一个还没计量的实绩 将毛重数据作为下一个计量实绩的皮重
-            //并且是第二次传入重量才执行
-            List<Map<String, Object>> steelMapList = tmstruckWeightResultMapper.getNoNetWeightResultId(DataChange.dataToBigDecimal(map.get("resultTotalId")));
-            if(steelMapList.size() >= 2){ //当前更新还未提交所以如果是拼装需要查询两个出来 以第二个为准
-                Map<String, Object> steelMap = steelMapList.get(1);
-                if(resultNetWeight  != null && !"".equals(resultNetWeight)){
-                    updateSteelAssemble(map, steelMap); //更新下一拼实绩
-                    map.put("segmentSqe", steelMap.get("tareSegmentSqe")); // 修改路段顺序号直接到下一皮重路段顺序
+            if(orderType == 1 || orderType == 4){
+                //如果是钢材订单,获取下一个还没计量的实绩 将毛重数据作为下一个计量实绩的皮重
+                //并且是第二次传入重量才执行
+                List<Map<String, Object>> steelMapList = tmstruckWeightResultMapper.getNoNetWeightResultId(DataChange.dataToBigDecimal(codeMap.get("resultTotalId")));
+                if(steelMapList.size() >= 2){ //当前更新还未提交所以如果是拼装需要查询两个出来 以第二个为准
+                    Map<String, Object> steelMap = steelMapList.get(1);
+                    if(resultNetWeight  != null && !"".equals(resultNetWeight)){
+                        updateSteelAssemble(codeMap, steelMap); //更新下一拼实绩
+                        codeMap.put("segmentSqe", steelMap.get("tareSegmentSqe")); // 修改路段顺序号直接到下一皮重路段顺序
+                    }
                 }
             }
+            utilsService.updateOrderLineSequence(codeMap);
         }
-        utilsService.updateOrderLineSequence(map);
+
         return tmstruckWeightResult;
     }
 
@@ -915,6 +879,7 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
                 if(map.get("good") != null && !"".equals(map.get("good"))){
                     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                     //查询物资
+                    map.put("good",map.get("goodspa") + "" + map.get("good"));
                     BigDecimal materialId = tmstruckWeightResultMapper.getMaterialId(map);
                     if(materialId == null) {
                         return "没有找到该物资,返回failed";
@@ -1050,7 +1015,7 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
                 if(weightTaskResultId != null && saleMaterialId != null) {
                     //更新计量实绩
                     System.out.println("更新计量实绩校验");
-                    tmstruckWeightResultMapper.updateWeightTaskBySaleMaterialId(weightTaskResultId,saleMaterialId);
+                    //tmstruckWeightResultMapper.updateWeightTaskBySaleMaterialId(weightTaskResultId,saleMaterialId);
                 }
                 if (j == 0) {
                         //如果是自提,则更换规格
@@ -1242,4 +1207,53 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
         return mapList;
 
     }
+
+
+    public void addWeightBatchResult(Map<String,Object> map) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        TmstruckWeightBatch tmstruckWeightBatch = new TmstruckWeightBatch();
+        BigDecimal weightBatchId = tmstruckWeightBatchMapper.weightBatchID();
+        tmstruckWeightBatch.setId(weightBatchId);
+        //皮重
+        if(map.get("resultTareWeight") != null && !"".equals(map.get("resultTareWeight"))) {
+            tmstruckWeightBatch.setBatchTareWeight(DataChange.dataToBigDecimal(map.get("resultTareWeight")));
+        }
+        //毛重
+        if(map.get("resultCrossWeight") != null && !"".equals(map.get("resultCrossWeight"))) {
+            tmstruckWeightBatch.setBatchGrossWeight(DataChange.dataToBigDecimal(map.get("resultCrossWeight")));
+        }
+        //净重
+        if(map.get("resultNetWeight") != null && !"".equals(map.get("resultNetWeight"))) {
+            tmstruckWeightBatch.setBatchNetWeight(DataChange.dataToBigDecimal(map.get("resultNetWeight")));
+        }
+        //毛重时间
+        if(map.get("resultCrossWeightTime") != null && !"".equals(map.get("resultCrossWeightTime"))) {
+            try {
+                tmstruckWeightBatch.setBatchGrossWeightTime(sdf.parse(map.get("resultCrossWeightTime").toString()));
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
+        //皮重时间
+        if(map.get("resultTareWeightTime") != null && !"".equals(map.get("resultTareWeightTime"))) {
+            try {
+                tmstruckWeightBatch.setBatchTareWeightTime(sdf.parse(map.get("resultTareWeightTime").toString()));
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
+        //绑定批次表与分录id的关系
+        List<Map<String,Object>> weightMapList = (List<Map<String, Object>>) map.get("weightMapList");
+        //改分录表
+        for (Map<String,Object> weightMap : weightMapList) {
+            weightMap.put("weightBatchId",weightBatchId);
+            tmstruckWeightBatchMapper.updateFluMes(weightMap);
+        }
+        for (Map<String,Object> weightMap : weightMapList) {
+            weightMap.put("weightBatchId",weightBatchId);
+            tmstruckWeightBatchMapper.updateOmMes(weightMap);
+        }
+        tmstruckWeightBatchMapper.insertSelective(tmstruckWeightBatch);
+
+    }
 }

+ 295 - 0
src/main/resources/com/steerinfo/dil/mapper/TmstruckWeightBatchMapper.xml

@@ -0,0 +1,295 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.steerinfo.dil.mapper.TmstruckWeightBatchMapper">
+  <resultMap id="BaseResultMap" type="com.steerinfo.dil.model.TmstruckWeightBatch">
+    <id column="WEIGHT_BATCH_ID" jdbcType="DECIMAL" property="weightBatchId" />
+    <result column="BATCH_NET_WEIGHT" jdbcType="DECIMAL" property="batchNetWeight" />
+    <result column="BATCH_GROSS_WEIGHT" jdbcType="DECIMAL" property="batchGrossWeight" />
+    <result column="BATCH_TARE_WEIGHT" jdbcType="DECIMAL" property="batchTareWeight" />
+    <result column="BATCH_TARE_WEIGHT_TIME" jdbcType="TIMESTAMP" property="batchTareWeightTime" />
+    <result column="BATCH_REMARK" jdbcType="VARCHAR" property="batchRemark" />
+    <result column="BATCH_GROSS_WEIGHT_TIME" jdbcType="TIMESTAMP" property="batchGrossWeightTime" />
+  </resultMap>
+  <sql id="columns">
+    WEIGHT_BATCH_ID, BATCH_NET_WEIGHT, BATCH_GROSS_WEIGHT, BATCH_TARE_WEIGHT, BATCH_TARE_WEIGHT_TIME, 
+    BATCH_REMARK, BATCH_GROSS_WEIGHT_TIME
+  </sql>
+  <sql id="columns_alias">
+    t.WEIGHT_BATCH_ID, t.BATCH_NET_WEIGHT, t.BATCH_GROSS_WEIGHT, t.BATCH_TARE_WEIGHT, 
+    t.BATCH_TARE_WEIGHT_TIME, t.BATCH_REMARK, t.BATCH_GROSS_WEIGHT_TIME
+  </sql>
+  <sql id="select">
+    SELECT <include refid="columns" /> FROM TMSTRUCK_WEIGHT_BATCH
+  </sql>
+  <sql id="select_alias">
+    SELECT <include refid="columns_alias" /> FROM TMSTRUCK_WEIGHT_BATCH t
+  </sql>
+  <sql id="where">
+    <where>
+      <if test="weightBatchId != null">
+        and WEIGHT_BATCH_ID = #{weightBatchId}
+      </if>
+      <if test="batchNetWeight != null">
+        and BATCH_NET_WEIGHT = #{batchNetWeight}
+      </if>
+      <if test="batchGrossWeight != null">
+        and BATCH_GROSS_WEIGHT = #{batchGrossWeight}
+      </if>
+      <if test="batchTareWeight != null">
+        and BATCH_TARE_WEIGHT = #{batchTareWeight}
+      </if>
+      <if test="batchTareWeightTime != null">
+        and TO_CHAR(BATCH_TARE_WEIGHT_TIME,'yyyy-MM-dd') = #{batchTareWeightTime}
+      </if>
+      <if test="batchRemark != null and batchRemark != ''">
+        and BATCH_REMARK = #{batchRemark}
+      </if>
+      <if test="batchGrossWeightTime != null">
+        and TO_CHAR(BATCH_GROSS_WEIGHT_TIME,'yyyy-MM-dd') = #{batchGrossWeightTime}
+      </if>
+    </where>
+  </sql>
+  <sql id="whereLike">
+    <where>
+      <if test="weightBatchId != null">
+        and WEIGHT_BATCH_ID = #{weightBatchId}
+      </if>
+      <if test="batchNetWeight != null">
+        and BATCH_NET_WEIGHT = #{batchNetWeight}
+      </if>
+      <if test="batchGrossWeight != null">
+        and BATCH_GROSS_WEIGHT = #{batchGrossWeight}
+      </if>
+      <if test="batchTareWeight != null">
+        and BATCH_TARE_WEIGHT = #{batchTareWeight}
+      </if>
+      <if test="batchTareWeightTime != null">
+        and TO_CHAR(BATCH_TARE_WEIGHT_TIME,'yyyy-MM-dd') = #{batchTareWeightTime}
+      </if>
+      <if test="batchRemark != null and batchRemark != ''">
+        and BATCH_REMARK LIKE '%${batchRemark}%'
+      </if>
+      <if test="batchGrossWeightTime != null">
+        and TO_CHAR(BATCH_GROSS_WEIGHT_TIME,'yyyy-MM-dd') = #{batchGrossWeightTime}
+      </if>
+    </where>
+  </sql>
+  <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal">
+    delete from TMSTRUCK_WEIGHT_BATCH
+    where WEIGHT_BATCH_ID = #{weightBatchId,jdbcType=DECIMAL}
+  </delete>
+  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
+    delete from TMSTRUCK_WEIGHT_BATCH
+    where 1!=1
+    <if test="batchNetWeight != null">
+      or BATCH_NET_WEIGHT = #{batchNetWeight}
+    </if>
+    <if test="batchGrossWeight != null">
+      or BATCH_GROSS_WEIGHT = #{batchGrossWeight}
+    </if>
+    <if test="batchTareWeight != null">
+      or BATCH_TARE_WEIGHT = #{batchTareWeight}
+    </if>
+    <if test="batchTareWeightTime != null">
+      or TO_CHAR(BATCH_TARE_WEIGHT_TIME,'yyyy-MM-dd') = '#{batchTareWeightTime}'
+    </if>
+    <if test="batchRemark != null and batchRemark != ''">
+      or BATCH_REMARK = #{batchRemark}
+    </if>
+    <if test="batchGrossWeightTime != null">
+      or TO_CHAR(BATCH_GROSS_WEIGHT_TIME,'yyyy-MM-dd') = '#{batchGrossWeightTime}'
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.steerinfo.dil.model.TmstruckWeightBatch">
+    insert into TMSTRUCK_WEIGHT_BATCH (WEIGHT_BATCH_ID, BATCH_NET_WEIGHT, BATCH_GROSS_WEIGHT,
+                                       BATCH_TARE_WEIGHT, BATCH_TARE_WEIGHT_TIME,
+                                       BATCH_REMARK, BATCH_GROSS_WEIGHT_TIME)
+    values (#{weightBatchId,jdbcType=DECIMAL}, #{batchNetWeight,jdbcType=DECIMAL}, #{batchGrossWeight,jdbcType=DECIMAL},
+            #{batchTareWeight,jdbcType=DECIMAL}, #{batchTareWeightTime,jdbcType=TIMESTAMP},
+            #{batchRemark,jdbcType=VARCHAR}, #{batchGrossWeightTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.steerinfo.dil.model.TmstruckWeightBatch">
+    insert into TMSTRUCK_WEIGHT_BATCH
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="weightBatchId != null">
+        WEIGHT_BATCH_ID,
+      </if>
+      <if test="batchNetWeight != null">
+        BATCH_NET_WEIGHT,
+      </if>
+      <if test="batchGrossWeight != null">
+        BATCH_GROSS_WEIGHT,
+      </if>
+      <if test="batchTareWeight != null">
+        BATCH_TARE_WEIGHT,
+      </if>
+      <if test="batchTareWeightTime != null">
+        BATCH_TARE_WEIGHT_TIME,
+      </if>
+      <if test="batchRemark != null">
+        BATCH_REMARK,
+      </if>
+      <if test="batchGrossWeightTime != null">
+        BATCH_GROSS_WEIGHT_TIME,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="weightBatchId != null">
+        #{weightBatchId,jdbcType=DECIMAL},
+      </if>
+      <if test="batchNetWeight != null">
+        #{batchNetWeight,jdbcType=DECIMAL},
+      </if>
+      <if test="batchGrossWeight != null">
+        #{batchGrossWeight,jdbcType=DECIMAL},
+      </if>
+      <if test="batchTareWeight != null">
+        #{batchTareWeight,jdbcType=DECIMAL},
+      </if>
+      <if test="batchTareWeightTime != null">
+        #{batchTareWeightTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="batchRemark != null">
+        #{batchRemark,jdbcType=VARCHAR},
+      </if>
+      <if test="batchGrossWeightTime != null">
+        #{batchGrossWeightTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKey" parameterType="com.steerinfo.dil.model.TmstruckWeightBatch">
+    update TMSTRUCK_WEIGHT_BATCH
+    set BATCH_NET_WEIGHT = #{batchNetWeight,jdbcType=DECIMAL},
+        BATCH_GROSS_WEIGHT = #{batchGrossWeight,jdbcType=DECIMAL},
+        BATCH_TARE_WEIGHT = #{batchTareWeight,jdbcType=DECIMAL},
+        BATCH_TARE_WEIGHT_TIME = #{batchTareWeightTime,jdbcType=TIMESTAMP},
+        BATCH_REMARK = #{batchRemark,jdbcType=VARCHAR},
+        BATCH_GROSS_WEIGHT_TIME = #{batchGrossWeightTime,jdbcType=TIMESTAMP}
+    where WEIGHT_BATCH_ID = #{weightBatchId,jdbcType=DECIMAL}
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.dil.model.TmstruckWeightBatch">
+    update TMSTRUCK_WEIGHT_BATCH
+    <set>
+      <if test="batchNetWeight != null">
+        BATCH_NET_WEIGHT = #{batchNetWeight,jdbcType=DECIMAL},
+      </if>
+      <if test="batchGrossWeight != null">
+        BATCH_GROSS_WEIGHT = #{batchGrossWeight,jdbcType=DECIMAL},
+      </if>
+      <if test="batchTareWeight != null">
+        BATCH_TARE_WEIGHT = #{batchTareWeight,jdbcType=DECIMAL},
+      </if>
+      <if test="batchTareWeightTime != null">
+        BATCH_TARE_WEIGHT_TIME = #{batchTareWeightTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="batchRemark != null">
+        BATCH_REMARK = #{batchRemark,jdbcType=VARCHAR},
+      </if>
+      <if test="batchGrossWeightTime != null">
+        BATCH_GROSS_WEIGHT_TIME = #{batchGrossWeightTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where WEIGHT_BATCH_ID = #{weightBatchId,jdbcType=DECIMAL}
+  </update>
+  <select id="selectByPrimaryKey" parameterType="java.math.BigDecimal" resultMap="BaseResultMap">
+    <include refid="select" />
+    where WEIGHT_BATCH_ID = #{weightBatchId,jdbcType=DECIMAL}
+  </select>
+  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+    <include refid="select" />
+    <include refid="where" />
+  </select>
+  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+    <include refid="select" />
+    <include refid="whereLike" />
+  </select>
+  <insert id="batchInsert" parameterType="java.util.List">
+    insert into TMSTRUCK_WEIGHT_BATCH
+    (WEIGHT_BATCH_ID,
+    BATCH_NET_WEIGHT, BATCH_GROSS_WEIGHT,
+    BATCH_TARE_WEIGHT, BATCH_TARE_WEIGHT_TIME,
+    BATCH_REMARK, BATCH_GROSS_WEIGHT_TIME
+    )
+    ( <foreach collection="list" item="item" separator="union all">
+    select
+    #{item.weightBatchId,jdbcType=DECIMAL},
+    #{item.batchNetWeight,jdbcType=DECIMAL}, #{item.batchGrossWeight,jdbcType=DECIMAL},
+    #{item.batchTareWeight,jdbcType=DECIMAL}, #{item.batchTareWeightTime,jdbcType=TIMESTAMP},
+    #{item.batchRemark,jdbcType=VARCHAR}, #{item.batchGrossWeightTime,jdbcType=TIMESTAMP}
+    from dual
+  </foreach> )
+  </insert>
+  <update id="batchUpdate" parameterType="java.util.List">
+    update TMSTRUCK_WEIGHT_BATCH
+    set
+    WEIGHT_BATCH_ID=
+    <foreach close="end" collection="list" index="index" item="item" open="case WEIGHT_BATCH_ID" separator=" ">
+      when #{item.weightBatchId,jdbcType=DECIMAL} then #{item.weightBatchId,jdbcType=DECIMAL}
+    </foreach>
+    ,BATCH_NET_WEIGHT=
+    <foreach close="end" collection="list" index="index" item="item" open="case WEIGHT_BATCH_ID" separator=" ">
+      when #{item.weightBatchId,jdbcType=DECIMAL} then #{item.batchNetWeight,jdbcType=DECIMAL}
+    </foreach>
+    ,BATCH_GROSS_WEIGHT=
+    <foreach close="end" collection="list" index="index" item="item" open="case WEIGHT_BATCH_ID" separator=" ">
+      when #{item.weightBatchId,jdbcType=DECIMAL} then #{item.batchGrossWeight,jdbcType=DECIMAL}
+    </foreach>
+    ,BATCH_TARE_WEIGHT=
+    <foreach close="end" collection="list" index="index" item="item" open="case WEIGHT_BATCH_ID" separator=" ">
+      when #{item.weightBatchId,jdbcType=DECIMAL} then #{item.batchTareWeight,jdbcType=DECIMAL}
+    </foreach>
+    ,BATCH_TARE_WEIGHT_TIME=
+    <foreach close="end" collection="list" index="index" item="item" open="case WEIGHT_BATCH_ID" separator=" ">
+      when #{item.weightBatchId,jdbcType=DECIMAL} then #{item.batchTareWeightTime,jdbcType=TIMESTAMP}
+    </foreach>
+    ,BATCH_REMARK=
+    <foreach close="end" collection="list" index="index" item="item" open="case WEIGHT_BATCH_ID" separator=" ">
+      when #{item.weightBatchId,jdbcType=DECIMAL} then #{item.batchRemark,jdbcType=VARCHAR}
+    </foreach>
+    ,BATCH_GROSS_WEIGHT_TIME=
+    <foreach close="end" collection="list" index="index" item="item" open="case WEIGHT_BATCH_ID" separator=" ">
+      when #{item.weightBatchId,jdbcType=DECIMAL} then #{item.batchGrossWeightTime,jdbcType=TIMESTAMP}
+    </foreach>
+    where WEIGHT_BATCH_ID in
+    <foreach close=")" collection="list" index="index" item="item" open="(" separator=",">
+      #{item.weightBatchId,jdbcType=DECIMAL}
+    </foreach>
+  </update>
+
+    <delete id="batchDelete" parameterType="java.util.List">
+    delete from TMSTRUCK_WEIGHT_BATCH
+    where WEIGHT_BATCH_ID in
+    <foreach close=")" collection="list" item="id" open="(" separator=",">
+      #{id}
+    </foreach>
+  </delete>
+  <!-- 友情提示!!!-->
+  <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
+  <update id="updateFluMes">
+    UPDATE AMS_SALE_MATERIAL ASM
+    SET ASM.INSERT_UPDATE_REMARK = '绑定计量批次ID'
+    <if test="goodNum != null">
+      ,ASM.MATERIAL_NUMBER = #{goodNum}
+    </if>
+    <if test="theoryWeight != null">
+      ,ASM.MATERIAL_WEIGHT = #{theoryWeight}
+    </if>
+    <if test="weightBatchId != null">
+      ,ASM.weight_batch_id = #{weightBatchId}
+    </if>
+
+    WHERE ASM.EAS_PRIMARY_ID = #{FLID}
+  </update>
+  <update id="updateOmMes">
+    UPDATE OMSTRUCK_ORDER_MATERIAL OOM
+    SET OOM.INSERT_UPDATE_REMARK = '修改理重、件数'
+    <if test="goodNum != null">
+      ,OOM.ORDER_MATERIAL_NUMBER = #{goodNum}
+    </if>
+    <if test="theoryWeight != null">
+      ,OOM.ORDER_MATERIAL_WEIGHT = #{theoryWeight}
+    </if>
+    WHERE OOM.SALE_MATERIAL_ID = (SELECT ASM.SALE_MATERIAL_ID FROM AMS_SALE_MATERIAL ASM
+    WHERE ASM.EAS_PRIMARY_ID = #{FLID})
+  </update>
+</mapper>

+ 1 - 2
src/main/resources/com/steerinfo/dil/mapper/TmstruckWeightResultMapper.xml

@@ -1026,8 +1026,7 @@
 
     <select id="getMaterialId" resultType="java.math.BigDecimal" parameterType="java.util.Map">
         select RM.MATERIAL_ID from RMS_MATERIAL RM
-        WHERE RM.MATERIAL_NAME = #{good}
-        AND RM.MATERIAL_SPECIFICATION || '(' ||  RM.MATERIAL_MODEL || ')' = #{goodspa}
+        WHERE  RM.MATERIAL_SPECIFICATION || '(' ||  RM.MATERIAL_MODEL || ')' || RM.MATERIAL_NAME = #{good}
     </select>
     <select id="getSaleOrderMaterialNum" resultType="java.util.Map" parameterType="map">
         select