فهرست منبع

Merge branch 'master' of https://git.steerinfo.com/DAL-DAZHOU2/DAL-DAZHOU-JOIN-API

HUJIANGUO 3 سال پیش
والد
کامیت
f11cebb672

+ 3 - 0
src/main/java/com/steerinfo/dil/controller/TmstruckWeightResultController.java

@@ -66,6 +66,9 @@ public class TmstruckWeightResultController extends BaseRESTfulController {
     @PostMapping("/receiveTmsTruckWeightResultByDaGang")
     public RESTfulResult receiveTmsTruckWeightResultByDaGang(@RequestBody(required = false) List<Map<String, Object>> mapList) {
         String s = tmstruckWeightResultServiceImpl.receiveTmsTruckWeightResultByDaGang(mapList);
+        if(!"成功".equals(s.substring(s.length() - 2))){
+            return failed(s);
+        }
         return success(s);
     }
 

+ 4 - 2
src/main/java/com/steerinfo/dil/mapper/TmstrainWeightResultMapper.java

@@ -13,6 +13,8 @@ public interface TmstrainWeightResultMapper extends IBaseMapper<TmstrainWeightRe
     @Select("select seq_train_weight_result.nextval from dual")
     BigDecimal selectMaxId();
 
-    //通过采购订单号和车皮号查询火运总实绩ID
-    Map<String, Object> getResultIdByPurNoAndWagonNo(Map<String, Object> map);
+    //通过火车运输订单号查询火运总实绩信息
+    Map<String, Object> getTrainResultTotalMes(String transportNum);
+
+    int updateByResultTotalIdSelective(TmstrainWeightResult tmstrainWeightResult);
 }

+ 10 - 0
src/main/java/com/steerinfo/dil/mapper/TmstruckWeightResultMapper.java

@@ -60,5 +60,15 @@ public interface TmstruckWeightResultMapper extends IBaseMapper<TmstruckWeightRe
     //钢材查询下一个未计量的实绩
     List<Map<String, Object>> getNoNetWeightResultId(BigDecimal resultTotalId);
 
+    //通过采购订单号查询采购订单ID  和物资ID
+    Map<String, Object> getAPOMes(String arrivalBillNo);
 
+    //修改普通采购运输订单实绩关联的采购订单ID
+    int updateOmsTruckPlanId(Map<String, Object> mesMap);
+
+    //修改运输订单子表物资ID
+    int updateOmsTruckMaterialId(Map<String, Object> mesMap);
+
+    //修改采购内转的运输订单需求中关联的采购订单Id
+    int updatePurchaseInwordAPOId(Map<String, Object> mesMap);
 }

+ 135 - 0
src/main/java/com/steerinfo/dil/service/impl/TmstrainWeightResultServiceImpl.java

@@ -1,5 +1,7 @@
 package com.steerinfo.dil.service.impl;
 
+import com.steerinfo.dil.mapper.TmstruckWeightResultMapper;
+import com.steerinfo.dil.util.DataChange;
 import com.steerinfo.framework.mapper.IBaseMapper;
 import com.steerinfo.framework.service.impl.BaseServiceImpl;
 import com.steerinfo.dil.model.TmstrainWeightResult;
@@ -7,8 +9,11 @@ import com.steerinfo.dil.mapper.TmstrainWeightResultMapper;
 import com.steerinfo.dil.service.ITmstrainWeightResultService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.math.BigDecimal;
+import java.util.Map;
 
 /**
  * TmstrainWeightResult服务实现:
@@ -29,4 +34,134 @@ public class TmstrainWeightResultServiceImpl implements ITmstrainWeightResultSer
     @Autowired
     private TmstrainWeightResultMapper tmstrainWeightResultMapper;
 
+    @Autowired
+    private TmstruckWeightResultMapper tmstruckWeightResultMapper;
+
+
+    final private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    /**
+     * 添加火车计量实绩
+     * @param map
+     * @return
+     */
+    public String addTrainWeightResult(Map<String, Object> map){
+        String transportNum = String.valueOf(map.get("orderNumber"));
+        Map<String, Object> mesMap = tmstrainWeightResultMapper.getTrainResultTotalMes(transportNum);
+        if(mesMap == null){
+            return "错误";
+        }
+        map.putAll(mesMap);
+        TmstrainWeightResult tmstrainWeightResult = null;
+        try {
+            tmstrainWeightResult = generateTrainWeightResult(map);
+        } catch (Exception e) {
+            return e.getMessage(); //捕获异常信息
+        }
+        Object resultCrossWeightTime = map.get("resultCrossWeightTime");
+        if(resultCrossWeightTime == null || "".equals(resultCrossWeightTime)){
+            //如果没有毛重时间 则进行新增
+            tmstrainWeightResultMapper.insertSelective(tmstrainWeightResult);
+        }else {
+            //反之则进行更新  根据总实绩ID进行更新
+            tmstrainWeightResultMapper.updateByResultTotalIdSelective(tmstrainWeightResult);
+        }
+        return "成功";
+    }
+
+    /**
+     * 生成火运计量实体
+     * @param map
+     * @return
+     */
+    public TmstrainWeightResult generateTrainWeightResult(Map<String, Object> map) throws Exception {
+
+        TmstrainWeightResult tmstrainWeightResult = new TmstrainWeightResult();
+        //磅单号
+        tmstrainWeightResult.setResultPoundNo((String) map.get("resultPoundNo"));
+        //添加火运总实绩ID
+        tmstrainWeightResult.setResultTotalId(DataChange.dataToBigDecimal(map.get("resultTotalId")));
+        //设置物资ID
+        Object materialId = map.get("materialId");
+        if(materialId != null && !"".equals(materialId)){
+            tmstrainWeightResult.setMaterialId(DataChange.dataToBigDecimal(materialId));
+        }
+        //如果没有计毛时间 则是第一次计量
+        String resultCrossWeightTime = (String) map.get("resultCrossWeightTime");
+        if(resultCrossWeightTime == null || resultCrossWeightTime.length() == 0){
+            //执行新增主键
+            tmstrainWeightResult.setResultId(tmstrainWeightResultMapper.selectMaxId());
+            //设置毛重时间
+            tmstrainWeightResult.setResultGrossWeightTime(DataChange.dataToDate(map.get("resultTareWeightTime")));
+            //添加毛重轨道衡
+            Integer tareId = tmstruckWeightResultMapper.selectTruckCalculateId(String.valueOf(map.get("resultTareCalculateNumber")));
+            if(tareId == null){
+                throw new Exception("没有此计量衡:" + map.get("resultTareCalculateNumber"));
+            }
+            tmstrainWeightResult.setResultGrossPlaceId(new BigDecimal(tareId));
+            //设置毛重
+            tmstrainWeightResult.setResultGrossWeight(DataChange.dataToBigDecimal(map.get("resultTareWeight")));
+            tmstrainWeightResult.setInsertTime(new Date());
+            tmstrainWeightResult.setInsertUsername("admin");
+        }else {
+            //设置皮重汽车衡
+            String resultTareCalculateNumber = (String) map.get("resultTareCalculateNumber");
+            if(resultTareCalculateNumber != null){
+                if(!"".equals(resultTareCalculateNumber)){
+                    Integer tareId = tmstruckWeightResultMapper.selectTruckCalculateId(resultTareCalculateNumber);
+                    if(tareId == null){
+                        throw new Exception("没有此皮重汽车衡:" + map.get("resultTareCalculateNumber"));
+                    }
+                    tmstrainWeightResult.setResultTarePlaceId(new BigDecimal(tareId));
+                }
+            }
+            //设置毛重汽车衡
+            String resultCrossCalculateNumber = (String) map.get("resultCrossCalculateNumber");
+            if(resultCrossCalculateNumber != null){
+                if(!"".equals(resultCrossCalculateNumber)){
+                    Integer crossId = tmstruckWeightResultMapper.selectTruckCalculateId(resultCrossCalculateNumber);
+                    if(crossId == null){
+                        throw new Exception("没有此毛重汽车衡:" + map.get("resultCrossCalculateNumber"));
+                    }
+                    tmstrainWeightResult.setResultGrossPlaceId(new BigDecimal(crossId));
+                }
+            }
+            //毛重
+            if(map.get("resultCrossWeight") != null){
+                String resultCrossWeight = String.valueOf(map.get("resultCrossWeight"));
+                if(!"".equals(resultCrossWeight))
+                    tmstrainWeightResult.setResultGrossWeight(DataChange.dataToBigDecimal(resultCrossWeight));
+            }
+            //皮重
+            if(map.get("resultTareWeight") != null){
+                String resultTareWeight = String.valueOf(map.get("resultTareWeight"));
+                if(!"".equals(resultTareWeight))
+                    tmstrainWeightResult.setResultTareWeight(DataChange.dataToBigDecimal(resultTareWeight));
+            }
+            //净重
+            if(map.get("resultNetWeight") != null){
+                String resultNetWeight = String.valueOf(map.get("resultNetWeight"));
+                if(!"".equals(resultNetWeight)){
+                    tmstrainWeightResult.setResultNetWeight(DataChange.dataToBigDecimal(resultNetWeight));
+                }
+            }
+            //设置皮重时间
+            if(map.get("resultTareWeightTime") != null){
+                String resultTareWeightTime = (String) map.get("resultTareWeightTime");
+                if(!"".equals(resultTareWeightTime)){
+                    tmstrainWeightResult.setResultTareWeightTime(sdf.parse(resultTareWeightTime));
+                }
+            }
+            //设置毛重时间
+            if(map.get("resultCrossWeightTime") != null){
+                String resultGrossWeightTime = (String) map.get("resultCrossWeightTime");
+                if(!"".equals(resultGrossWeightTime)){
+                    tmstrainWeightResult.setResultGrossWeightTime(sdf.parse(resultGrossWeightTime));
+                }
+            }
+            tmstrainWeightResult.setUpdateTime(new Date());
+            tmstrainWeightResult.setUpdateUsername("admin");
+        }
+        return tmstrainWeightResult;
+    }
+
 }

+ 34 - 105
src/main/java/com/steerinfo/dil/service/impl/TmstruckWeightResultServiceImpl.java

@@ -1,10 +1,8 @@
 package com.steerinfo.dil.service.impl;
 
-import com.steerinfo.dil.feign.BmsTruckFeign;
 import com.steerinfo.dil.feign.OmsFeign;
 import com.steerinfo.dil.feign.TmstruckFeign;
 import com.steerinfo.dil.mapper.*;
-import com.steerinfo.dil.model.TmstrainWeightResult;
 import com.steerinfo.dil.model.TmstruckReceiveResult;
 import com.steerinfo.dil.model.TmstruckWeightResult;
 import com.steerinfo.dil.service.ITmstruckWeightResultService;
@@ -55,9 +53,9 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
     @Autowired
     TmstruckReceiveResultMapper tmstruckReceiveResultMapper;
 
-    @Autowired
-    TmstrainWeightResultMapper tmstrainWeightResultMapper;
 
+    @Autowired
+    TmstrainWeightResultServiceImpl tmstrainWeightResultService;
 
     //属于采购订单的订单类型(先计毛后计皮)
     final private List<Integer> judgeOrderTypeList = Arrays.asList(5, 6, 7, 8, 9, 12, 15, 17, 18);
@@ -90,10 +88,10 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
             String resultTareCalculateNumber = (String) map.get("resultTareCalculateNumber");
             //如果计量衡名字中含有铁专线 则代表是轨道衡 走轨道衡路线
             if(resultTareCalculateNumber.contains("铁专线")){
-                sb.append(addTrainWeightResult(map));
+                sb.append(tmstrainWeightResultService.addTrainWeightResult(map));
             }else {
                 //走汽车衡
-                map.put("needCheckToKD", "1"); //老厂区专属变量 用于区分新、老厂区 老厂区需要给金蝶传输数据
+                map.put("needCheckToKD", "1"); //老厂区专属变量 用于区分新、老厂区 老厂区部分秤需要给金蝶传输数据
                 sb.append(addTruckWeightResult(map));
             }
         }
@@ -130,9 +128,13 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
             return map.get("orderNumber") + "系统无此订单";
         }
         int orderType= DataChange.dataToBigDecimal(oneMap.get("orderType")).intValue();
-        if(orderType == 11){
+        if(orderType == 11 || orderType == 15 || orderType == 16){
             return insertWeightResultBy11(map, oneMap);
         }
+        //为1的时候计量重新更新单据
+        if(DataChange.dataToBigDecimal(map.get("WLReUpdateFlag")).intValue() == 1){
+            return linkUpdateAPO(map, orderType);
+        }
         //通过运输订单号查询计量实绩Id
         Map<String, Object> stringObjectMap = tmstruckWeightResultMapper.selectWeightIdByOrderId(map);
         if(stringObjectMap == null){
@@ -520,104 +522,6 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
 
 
 
-
-/*======================================================================================================================================================================
-============================================================================火运火运火运==================================================================================
-======================================================================================================================================================================*/
-
-
-    /**
-     * 添加火车计量实绩
-     * @param map
-     * @return
-     */
-    public String addTrainWeightResult(Map<String, Object> map){
-        //通过采购订单号和车皮号 查询火运总实绩ID和物资ID
-        Map<String, Object> totalIdAndMateMap = tmstrainWeightResultMapper.getResultIdByPurNoAndWagonNo(map);
-        if(totalIdAndMateMap == null){
-            return "采购订单号"+ map.get("purchaseOrderNo")+"或车皮信息"+ map.get("orderNumber")+"错误";
-        }
-        if(totalIdAndMateMap.get("resultTotalId") == null){
-            return "采购订单号"+ map.get("purchaseOrderNo")+"或车皮信息"+ map.get("orderNumber")+"错误";
-        }
-        map.putAll(totalIdAndMateMap);
-        TmstrainWeightResult tmstrainWeightResult = null;
-        try {
-            tmstrainWeightResult = generateTrainWeightResult(map);
-        } catch (Exception e) {
-            return e.getMessage(); //捕获异常信息
-        }
-        tmstrainWeightResultMapper.insertSelective(tmstrainWeightResult);
-        return map.get("orderNumber") + "成功";
-    }
-
-    /**
-     * 生成火运计量实体
-     * @param map
-     * @return
-     */
-    public TmstrainWeightResult generateTrainWeightResult(Map<String, Object> map) throws Exception {
-
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        TmstrainWeightResult tmstrainWeightResult = new TmstrainWeightResult();
-        tmstrainWeightResult.setResultId(tmstrainWeightResultMapper.selectMaxId());
-        //磅单号
-        tmstrainWeightResult.setResultPoundNo((String) map.get("resultPoundNo"));
-        //添加火运总实绩ID
-        tmstrainWeightResult.setResultTotalId(DataChange.dataToBigDecimal(map.get("resultTotalId")));
-        //设置物资ID
-        tmstrainWeightResult.setMaterialId(DataChange.dataToBigDecimal(map.get("materialId")));
-        //如果没有计毛时间 则是第一次计量
-        String resultCrossWeightTime = (String) map.get("resultCrossWeightTime");
-        if(resultCrossWeightTime == null || resultCrossWeightTime.length() == 0){
-            //设置毛重时间
-            String firstTime = (String) map.get("resultTareWeightTime");
-            tmstrainWeightResult.setResultGrossWeightTime(sdf.parse(firstTime));
-            //添加毛重轨道衡
-            Integer tareId = tmstruckWeightResultMapper.selectTruckCalculateId((String) map.get("resultTareCalculateNumber"));
-            if(tareId == null){
-                throw new Exception("没有此计量衡:" + map.get("resultTareCalculateNumber"));
-            }
-            tmstrainWeightResult.setResultGrossPlaceId(new BigDecimal(tareId));
-            //设置毛重
-            BigDecimal resultTareWeight = DataChange.dataToBigDecimal(map.get("resultTareWeight"));
-            tmstrainWeightResult.setResultGrossWeight(resultTareWeight);
-            tmstrainWeightResult.setInsertTime(new Date());
-            tmstrainWeightResult.setInsertUsername("admin");
-        }else {
-            //设置皮重轨道衡
-            Integer tareId = tmstruckWeightResultMapper.selectTruckCalculateId((String) map.get("resultTareCalculateNumber"));
-            if(tareId == null){
-                throw new Exception("没有此计量衡:" + map.get("resultTareCalculateNumber"));
-            }
-            tmstrainWeightResult.setResultTarePlaceId(new BigDecimal(tareId));
-            //设置毛重轨道衡
-            Integer crossId = tmstruckWeightResultMapper.selectTruckCalculateId((String) map.get("resultCrossCalculateNumber"));
-            if(crossId == null){
-                throw new Exception("没有此计量衡:" + map.get("resultCrossCalculateNumber"));
-            }
-            tmstrainWeightResult.setResultGrossPlaceId(new BigDecimal(crossId));
-            //毛重
-            BigDecimal resultCrossWeight = DataChange.dataToBigDecimal(map.get("resultCrossWeight"));
-            tmstrainWeightResult.setResultGrossWeight(resultCrossWeight);
-            //皮重
-            BigDecimal resultTareWeight = DataChange.dataToBigDecimal(map.get("resultTareWeight"));
-            tmstrainWeightResult.setResultTareWeight(resultTareWeight);
-            //净重
-            tmstrainWeightResult.setResultNetWeight(DataChange.dataToBigDecimal(map.get("resultNetWeight")));
-            //设置皮重时间
-            String resultTareWeightTime = (String) map.get("resultTareWeightTime");
-            tmstrainWeightResult.setResultTareWeightTime(sdf.parse(resultTareWeightTime));
-            //设置毛重时间
-            String resultGrossWeightTime = (String) map.get("resultCrossWeightTime");
-            tmstrainWeightResult.setResultGrossWeightTime(sdf.parse(resultGrossWeightTime));
-            tmstrainWeightResult.setUpdateTime(new Date());
-            tmstrainWeightResult.setUpdateUsername("admin");
-        }
-        return tmstrainWeightResult;
-    }
-
-
     /**
      * 回传数据给金蝶方法
      * @Author TXF
@@ -660,4 +564,29 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
         }
         return "success";
     }
+
+    /**
+     * 计量联动修改方法(修改关联的采购订单,以及同步修改运输订单物资子表的物资)
+     * @param map
+     * @param orderType
+     * @return
+     */
+    public String linkUpdateAPO(Map<String, Object> map, Integer orderType){
+            //如果等于1 则代表是需要变更采购订单号的订单
+            Map<String, Object> mesMap = tmstruckWeightResultMapper.getAPOMes(String.valueOf(map.get("ArrivalBillNo")));
+            if (mesMap == null){
+                return map.get("ArrivalBillNo") + "系统没有此订单号!失败";
+            }
+            mesMap.put("orderNumber", map.get("orderNumber"));
+            if(orderType == 20){
+                //20订单修改的表不一样呀
+                tmstruckWeightResultMapper.updatePurchaseInwordAPOId(mesMap);
+                tmstruckWeightResultMapper.updateOmsTruckMaterialId(mesMap);
+            }else{
+                //修改订单管理采购订单ID 以及物资子表 物资ID
+                tmstruckWeightResultMapper.updateOmsTruckPlanId(mesMap);
+                tmstruckWeightResultMapper.updateOmsTruckMaterialId(mesMap);
+            }
+        return mesMap.get("orderNumber") + "数据修改成功";
+    }
 }

+ 117 - 16
src/main/java/com/steerinfo/dil/util/DataChange.java

@@ -7,6 +7,7 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Pattern;
 
 /**
  * @ author    :TXF
@@ -17,24 +18,45 @@ public class DataChange {
 
 
     /**
-     * 解析前端传来的日期字符串
+     * 时间转换类
+     * 处理了三种类型 yyyy-MM-dd HH:mm:ss  yyyy/MM/dd HH:mm:ss  时间戳类型(带毫秒数时间戳13位)
      * @param vueDate
      * @return
      */
     public static Date dataToDate(Object vueDate){
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        Date parseDate = null;
-        if (vueDate != null){
+        if(vueDate instanceof Date){
+            return (Date) vueDate;
+        } else {
             try {
-                String date = (String) vueDate;
-                parseDate = sdf.parse(date);
-            } catch (ParseException e) {
-                e.printStackTrace();
+                String str = String.valueOf(vueDate);
+                if(judgeNumber(str) && str.length() == 13){
+                    return new Date(Long.parseLong(str));
+                }else if(str.contains("-")){
+                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                    return sdf.parse(str);
+                }else if(str.contains("/")){
+                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+                    return sdf.parse(str);
+                }
+            }catch (Exception e){
+                System.out.println("时间解析错误!返回null");
+                return null;
             }
         }
-        return parseDate;
+        return null;
     }
 
+    /**
+     * 判断是否纯数字(不带小数点)仅供上面方法使用
+     * @param str
+     * @return
+     */
+    public static boolean judgeNumber(String str){
+        Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
+        return pattern.matcher(str).matches();
+    }
+
+
     /**
      * 数据转换成BigDecimal
      * @param data
@@ -51,7 +73,7 @@ public class DataChange {
                     try {
                         decimal = new BigDecimal(str);
                     } catch (Exception e) {
-                        e.printStackTrace();
+                        System.out.println(data + ":数据解析失败!返回0");
                         return new BigDecimal(0);
                     }
                 }
@@ -72,7 +94,7 @@ public class DataChange {
         if(date == null)
             return null;
         try{
-             changeDate = (Date) date;
+            changeDate = (Date) date;
         }catch (Exception e){
             e.printStackTrace();
         }
@@ -90,7 +112,12 @@ public class DataChange {
             for (String s : key) {
                 //从map中取 date的值 并转换成字符串类型的日期
                 String stringDate = dateToDayDate(map.get(s));
-                map.put(s, stringDate);
+                if(stringDate.length() == 0){
+                    break;
+                }else {
+                    //修改map中的值
+                    map.put(s, stringDate);
+                }
             }
         }
     }
@@ -101,14 +128,18 @@ public class DataChange {
      * @param key
      */
     public static void dataTo2Number(List<Map<String, Object>> list, String ...key){
+        DecimalFormat df =  new DecimalFormat("0.00");
         //遍历List
         for (Map<String, Object> map : list) {
             for (String s : key) {
                 //修改数据为带两位小数
-                BigDecimal oldDate = (BigDecimal) map.get(s);
-                DecimalFormat df =  new DecimalFormat("0.00");
-                String resultDeduction = df.format(oldDate.doubleValue());
-                map.put(s, resultDeduction);
+                try {
+                    BigDecimal oldDate = dataToBigDecimal(map.get(s));
+                    String resultDeduction = df.format(oldDate.doubleValue());
+                    map.put(s, resultDeduction);
+                } catch (Exception e) {
+                    System.out.println("原料扣减量数据有误");
+                }
             }
         }
     }
@@ -156,4 +187,74 @@ public class DataChange {
         return sb.toString();
     }
 
+    /**
+     * 根据时间段查询数据 支持只选择单个时间
+     * @Author TXF
+     * @Date 2022/1/10 23:21
+     * @param startTime
+     * @param endTime
+     * @param map
+     * @param sdf
+     * @return
+     **/
+    public static void queryDataByDate(String startTime, String endTime, Map<String, Object> map, SimpleDateFormat sdf){
+        if (startTime != null && !"null".equals(startTime) && endTime != null && !"null".equals(endTime)) {
+            map.put("startDate", sdf.format(new Date(Long.parseLong(startTime))));
+            map.put("endDate", sdf.format(new Date(Long.parseLong(endTime) + 86400000)));
+        } else if (startTime != null && !"null".equals(startTime)) {
+            map.put("oneDate", sdf.format(new Date(Long.parseLong(startTime))));
+        } else if (endTime != null && !"null".equals(endTime)) {
+            map.put("oneDate", sdf.format(new Date(Long.parseLong(endTime))));
+        } else {
+            map.put("oneDate", sdf.format(new Date()));
+        }
+    }
+
+    /**
+     * 只支持两个时间查询
+     * @Author TXF
+     * @Date 2022/1/15 9:08
+     * @param startTime
+     * @param endTime
+     * @param sdf
+     * @return
+     **/
+    public static void queryDataByDateTime(String startTime, String endTime, Map<String, Object> map,SimpleDateFormat sdf){
+        SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
+        if (startTime != null && !"null".equals(startTime) && endTime != null && !"null".equals(endTime)) {
+            map.put("startDate", sdf.format(new Date(Long.parseLong(startTime))));
+            map.put("endDate", sdf.format(new Date(Long.parseLong(endTime))));
+        }
+        //如果开始时间和结束时间有且只有一个为空 则只查那天的数据
+        else if((startTime != null && !"null".equals(startTime)) || (endTime != null && !"null".equals(endTime))){
+            if(startTime != null && !"null".equals(startTime)){
+                queryDataByTwoDateSon(map, startTime, sdfDate);
+            }
+            if(endTime != null && !"null".equals(endTime)){
+                queryDataByTwoDateSon(map, endTime, sdfDate);
+            }
+        }else {
+            //如果两者时间都为空,则查询当天数据
+            String nowDate = sdfDate.format(new Date());
+            map.put("oneDate", nowDate + " 00:00:00");
+        }
+    }
+
+    /**
+     * 上面方法的儿子方法 如果只传入了一个时间 则查询那天的数据
+     * @Author TXF
+     * @Date 2022/1/17 16:17
+     * @param map
+     * @param time
+     * @param sdfDate
+     * @return
+     **/
+    private static void queryDataByTwoDateSon(Map<String, Object> map, String time, SimpleDateFormat sdfDate){
+        Date date1 = new Date(Long.parseLong(time));
+        Date date2 = new Date(Long.parseLong(time) + 86400000);
+        String dayStartTime = sdfDate.format(date1);
+        String dayEndTime = sdfDate.format(date2);
+        map.put("startDate", dayStartTime + " 00:00:00");
+        map.put("endDate", dayEndTime + " 00:00:00");
+    }
 }

+ 76 - 12
src/main/resources/com/steerinfo/dil/mapper/TmstrainWeightResultMapper.xml

@@ -630,18 +630,82 @@
   <!-- 友情提示!!!-->
   <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
 
-<!-- 通过采购订单号和车皮号查询火运总实绩ID和物资ID -->
-  <select id="getResultIdByPurNoAndWagonNo" parameterType="java.util.Map" resultType="java.util.Map">
-    select TTR.TOTAL_RESULT_ID "resultTotalId",
-           DB.MATERIAL_ID   "materialId"
-    from TMSTRAIN_LOADING_RESULT TLR
-        left join TMSTRAIN_TOTAL_RESULT TTR
-        on TTR.LOADING_ID = TLR.RESULT_ID
-        left join AMS_PURCHASE_ORDER APO
-            on APO.PURCHASE_ORDER_ID = TLR.PURCHASE_ORDER_RAIL_PLAN_ID
-        left join DIL_BATCH DB
-            on DB.BATCH_ID = APO.BATCH_ID
-    where TLR.RESULT_WAGON_NO = #{orderNumber} and APO.PURCHASE_ORDER_NO = #{purchaseOrderNo}
+
+  <select id="getTrainResultTotalMes" parameterType="string" resultType="java.util.Map">
+    select TTR.TOTAL_RESULT_ID  "resultTotalId",
+           TTR.LOADING_ID       "loadingId",
+           TTR.UNLOADING_ID     "unloadingId"
+    from TMSTRAIN_TOTAL_RESULT TTR
+    where TRANSPORT_NUM = #{transportNum}
   </select>
 
+
+  <update id="updateByResultTotalIdSelective" parameterType="com.steerinfo.dil.model.TmstrainWeightResult">
+    update TMSTRAIN_WEIGHT_RESULT
+    <set>
+      <if test="resultTotalId != null">
+        RESULT_TOTAL_ID = #{resultTotalId,jdbcType=DECIMAL},
+      </if>
+      <if test="resultPoundNo != null">
+        RESULT_POUND_NO = #{resultPoundNo,jdbcType=VARCHAR},
+      </if>
+      <if test="materialId != null">
+        MATERIAL_ID = #{materialId,jdbcType=DECIMAL},
+      </if>
+      <if test="resultGrossPlaceId != null">
+        RESULT_GROSS_PLACE_ID = #{resultGrossPlaceId,jdbcType=DECIMAL},
+      </if>
+      <if test="resultGrossWeight != null">
+        RESULT_GROSS_WEIGHT = #{resultGrossWeight,jdbcType=DECIMAL},
+      </if>
+      <if test="resultGrossWeightTime != null">
+        RESULT_GROSS_WEIGHT_TIME = #{resultGrossWeightTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="resultTarePlaceId != null">
+        RESULT_TARE_PLACE_ID = #{resultTarePlaceId,jdbcType=DECIMAL},
+      </if>
+      <if test="resultTareWeight != null">
+        RESULT_TARE_WEIGHT = #{resultTareWeight,jdbcType=DECIMAL},
+      </if>
+      <if test="resultTareWeightTime != null">
+        RESULT_TARE_WEIGHT_TIME = #{resultTareWeightTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="resultNetWeight != null">
+        RESULT_NET_WEIGHT = #{resultNetWeight,jdbcType=DECIMAL},
+      </if>
+      <if test="insertUsername != null">
+        INSERT_USERNAME = #{insertUsername,jdbcType=VARCHAR},
+      </if>
+      <if test="insertTime != null">
+        INSERT_TIME = #{insertTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateUsername != null">
+        UPDATE_USERNAME = #{updateUsername,jdbcType=VARCHAR},
+      </if>
+      <if test="updateTime != null">
+        UPDATE_TIME = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="insertUpdateRemark != null">
+        INSERT_UPDATE_REMARK = #{insertUpdateRemark,jdbcType=VARCHAR},
+      </if>
+      <if test="deleteName != null">
+        DELETE_NAME = #{deleteName,jdbcType=VARCHAR},
+      </if>
+      <if test="deleteTime != null">
+        DELETE_TIME = #{deleteTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="isdeduct != null">
+        ISDEDUCT = #{isdeduct,jdbcType=DECIMAL},
+      </if>
+      <if test="isquality != null">
+        ISQUALITY = #{isquality,jdbcType=DECIMAL},
+      </if>
+      <if test="resultIsQuality != null">
+        RESULT_IS_QUALITY = #{resultIsQuality,jdbcType=DECIMAL},
+      </if>
+    </set>
+    where RESULT_TOTAL_ID = #{resultTotalId,jdbcType=DECIMAL}
+  </update>
+
+
 </mapper>

+ 32 - 0
src/main/resources/com/steerinfo/dil/mapper/TmstruckWeightResultMapper.xml

@@ -894,4 +894,36 @@
         WHERE ROWNUM &lt;= 2
     </select>
 
+    <select id="getAPOMes" parameterType="string" resultType="map">
+        select APO.PURCHASE_ORDER_ID    "purchaseOrderId",
+               DB.MATERIAL_ID       "materialId"
+        from AMS_PURCHASE_ORDER APO
+        left join DIL_BATCH DB on APO.BATCH_ID = DB.BATCH_ID
+        where APO.PURCHASE_ORDER_NO = #{arrivalBillNo}
+    </select>
+
+    <update id="updateOmsTruckPlanId" parameterType="map">
+        update OMSTRUCK_ORDER
+        set ORDER_PLAN_ID = #{purchaseOrderId}
+        where ORDER_NUMBER = #{orderNumber}
+    </update>
+
+    <update id="updateOmsTruckMaterialId" parameterType="map">
+        update OMSTRUCK_ORDER_MATERIAL
+        set MATERIAL_ID = #{materialId}
+        where ORDER_ID = (select ORDER_ID from OMSTRUCK_ORDER where ORDER_NUMBER = #{orderNumber})
+    </update>
+
+    <update id="updatePurchaseInwordAPOId" parameterType="map">
+        update AMSTRUCK_INWARD_REQUIREMENT AIR
+        set AIR.PURCHASE_ORDER_ID = #{purchaseOrderId}
+        where AIR.REQUIREMENT_ID = (
+            select air.REQUIREMENT_ID
+            from OMSTRUCK_ORDER OO
+                     left join AMSTRUCK_INWARD_PLAN AIP on aip.plan_id = oo.order_plan_id
+                     LEFT JOIN amstruck_requirement_plan arp ON arp.plan_id = aip.plan_id
+                     LEFT JOIN amstruck_inward_requirement air ON air.requirement_id = arp.requirement_id
+            where OO.ORDER_NUMBER = #{orderNumber}
+            )
+    </update>
 </mapper>