Ver código fonte

优化计量接口

txf 3 anos atrás
pai
commit
2ce2f6c1a7

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

@@ -1,6 +1,7 @@
 package com.steerinfo.dil.controller;
 
 import com.steerinfo.dil.feign.TmstruckFeign;
+import com.steerinfo.dil.service.ITmstruckWeightResultService;
 import com.steerinfo.dil.service.impl.TmstruckWeightResultServiceImpl;
 import com.steerinfo.dil.util.BaseRESTfulController;
 import com.steerinfo.framework.controller.RESTfulResult;
@@ -63,14 +64,8 @@ public class TmstruckWeightResultController extends BaseRESTfulController {
     )
     @PostMapping("/receiveTmsTruckWeightResult")
     public RESTfulResult receiveTmsTruckWeightResult(@RequestBody(required = false) List<Map<String, Object>> mapList) {
-        int i = 0;
-        try {
-            i = tmstruckWeightResultServiceImpl.receiveTmsTruckWeightResult(mapList);
-        } catch (Exception e) {
-            String message = e.getMessage();
-            return failed(message);
-        }
-        return success(i);
+        String s = tmstruckWeightResultServiceImpl.receiveTmsTruckWeightResult(mapList);
+        return success(s);
     }
 
 

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

@@ -29,5 +29,5 @@ public interface ITmstruckWeightResultService {
      * @param mapList
      * @return
      */
-    int receiveTmsTruckWeightResult(List<Map<String, Object>> mapList) throws Exception;
+    String receiveTmsTruckWeightResult(List<Map<String, Object>> mapList);
 }

+ 25 - 13
src/main/java/com/steerinfo/dil/service/impl/TmstruckWeightResultServiceImpl.java

@@ -73,20 +73,21 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
      * @return
      */
     @Override
-    public int receiveTmsTruckWeightResult(List<Map<String, Object>> mapList) throws Exception {
+    public String receiveTmsTruckWeightResult(List<Map<String, Object>> mapList){
         //遍历列表
-        int count = 0;
+        StringBuilder sb = new StringBuilder();
         for (Map<String, Object> map : mapList) {
+            sb.append(" ");
             String resultTareCalculateNumber = (String) map.get("resultTareCalculateNumber");
             //如果计量衡名字中含有铁专线 则代表是轨道衡 走轨道衡路线
             if(resultTareCalculateNumber.contains("铁专线")){
-                count += addTrainWeightResult(map);
+                sb.append(addTrainWeightResult(map));
             }else {
                 //走汽车衡
-                count += addTruckWeightResult(map);
+                sb.append(addTruckWeightResult(map));
             }
         }
-        return count;
+        return sb.toString();
     }
 
     /**
@@ -94,14 +95,19 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
      * @param map
      * @return
      */
-    public int addTruckWeightResult(Map<String, Object> map) throws Exception {
+    public String addTruckWeightResult(Map<String, Object> map) {
         //通过传来的运输订单号 与 物资ID查询计重实绩ID
         Map<String, Object> stringObjectMap = tmstruckWeightResultMapper.selectTotalIdByOrderNo(map);
         if(stringObjectMap == null){
-            throw new Exception(map.get("orderNumber") + "没有此订单信息或物资信息(" + map.get("materialId") + ")错误");
+            return map.get("orderNumber") + "没有此订单信息或物资信息(" + map.get("materialId") + ")错误";
         }
         map.putAll(stringObjectMap);
-        TmstruckWeightResult tmstruckWeightResult = generateWeightResult(map);
+        TmstruckWeightResult tmstruckWeightResult = null;
+        try {
+            tmstruckWeightResult = generateWeightResult(map);
+        } catch (Exception e) {
+            return e.getMessage();
+        }
         int i = tmstruckWeightResultMapper.updateByPrimaryKeySelective(tmstruckWeightResult);
         BigDecimal orderType = DataChange.dataToBigDecimal(map.get("orderTypee"));
         if("5678".contains(orderType.toString())){
@@ -114,7 +120,7 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
         utilsService.updateOrderLineSequence(map);
         //推送数据
         utilsService.pushMesToWebsocket((String) stringObjectMap.get("capacityNumber"), "计量");
-        return i;
+        return map.get("orderNumber") + "成功";
     }
 
 
@@ -204,14 +210,20 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
      * @param map
      * @return
      */
-    public int addTrainWeightResult(Map<String, Object> map) throws Exception {
+    public String addTrainWeightResult(Map<String, Object> map){
         //通过****查询火运总实绩ID和物资ID --遗留问题
         Map<String, Object> totalAndMaterialIdMap = null;
         if(totalAndMaterialIdMap == null){
-            throw new Exception("没有此车皮信息");
+            return "没有此车皮信息";
+        }
+        TmstrainWeightResult tmstrainWeightResult = null;
+        try {
+            tmstrainWeightResult = generateTrainWeightResult(map);
+        } catch (Exception e) {
+            return e.getMessage(); //捕获异常信息
         }
-        TmstrainWeightResult tmstrainWeightResult = generateTrainWeightResult(map);
-        return tmstrainWeightResultMapper.insertSelective(tmstrainWeightResult);
+        tmstrainWeightResultMapper.insertSelective(tmstrainWeightResult);
+        return "" + "成功";
     }
 
     /**