liyg 1 jaar geleden
bovenliggende
commit
2090660d6e
1 gewijzigde bestanden met toevoegingen van 74 en 28 verwijderingen
  1. 74 28
      src/main/java/com/steerinfo/dil/service/impl/AmsSaleOrderServiceImpl.java

+ 74 - 28
src/main/java/com/steerinfo/dil/service/impl/AmsSaleOrderServiceImpl.java

@@ -3330,41 +3330,87 @@ public class AmsSaleOrderServiceImpl implements IAmsSaleOrderService {
      */
     @Override
     public int batchPushCarNumberToEas(List<Map<String, Object>> mapList) throws Exception {
-            Map<String, Object> input = joinFeign.findCarNumberByOrderList(mapList);
-            Map<String, Object> totalMap = new HashMap<>();
-            totalMap.putAll(easCapacityTestUtil.getTotalMap());
-            totalMap.put("input", input);
-            Map<String, Object> s = joinFeign.pushCarNumberToEas(totalMap);
-            System.out.println(totalMap);
-            String json = JSONUtils.toJSONString(totalMap);
-            System.out.println(json);
-            totalMap.put("output", s);
-            System.out.println(totalMap);
+        Map<String, Object> input = joinFeign.findCarNumberByOrderList(mapList);
+        Map<String, Object> totalMap = new HashMap<>();
+        totalMap.putAll(easCapacityTestUtil.getTotalMap());
+        totalMap.put("input", input);
+        Map<String, Object> s = joinFeign.pushCarNumberToEas(totalMap);
+        System.out.println(totalMap);
+        String json = JSONUtils.toJSONString(totalMap);
+        System.out.println(json);
+        totalMap.put("output", s);
+        System.out.println(totalMap);
+        try {
+            newFileTool.newFile("pushCarNumberToEas:" + totalMap, "金蝶通讯报文");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        if (s == null || s.size() == 0) {
+            throw new Exception("登录金蝶失败!请重试派车!");
+        } else {
             try {
-                newFileTool.newFile("pushCarNumberToEas:" + totalMap, "金蝶通讯报文");
+                JSONObject result = new JSONObject(s);
+                //如果status不为1,抛出异常
+                if (!result.getJSONObject("res").getString("status").equals("1")) {
+                    throw new Exception("上传金蝶失败!请重试派车:" + result.getJSONObject("requestException").getString("message"));
+                }
             } catch (Exception e) {
                 e.printStackTrace();
+                //只抛出自定义异常
+                if (e.getMessage().contains("Exception")) {
+                    throw new Exception("上传金蝶失败!请重试派车!");
+                } else {
+                    throw new Exception(e.getMessage());
+                }
+
             }
-            if (s == null || s.size() == 0) {
-                throw new Exception("登录金蝶失败!请重试派车!");
-            } else {
-                try {
-                    JSONObject result = new JSONObject(s);
-                    //如果status不为1,抛出异常
-                    if (!result.getJSONObject("res").getString("status").equals("1")) {
-                        throw new Exception("上传金蝶失败!请重试派车:" + result.getJSONObject("requestException").getString("message"));
-                    }
-                } catch (Exception e) {
-                    e.printStackTrace();
-                    //只抛出自定义异常
-                    if (e.getMessage().contains("Exception")) {
-                        throw new Exception("上传金蝶失败!请重试派车!");
-                    } else {
-                        throw new Exception(e.getMessage());
-                    }
 
+        }
+
+        try{
+            //存在capacityId则判断是否取消或撤销取消
+            for(Map<String, Object> map : mapList){
+                if(map.get("capacityId")!=null){
+                    //新车号、当前车号、旧车号
+                    String capacityId ="" + map.get("capacityId");
+                    Map<String,Object>  capacityDetails=  amsSaleOrderMapper.getCapacityDetailByAsom(mapList.get(0));
+                    Map<String, Object> cancelOrderMap = new HashMap<>();
+                    cancelOrderMap.put("orderID",capacityDetails.get("orderNumber"));
+                    if(capacityDetails!=null && capacityDetails.get("nowCapcaityId")!=null){
+                        //存在当前车号,判断是否存在取消或撤销取消
+                        String nowCapcaityId ="" + capacityDetails.get("nowCapcaityId");
+                        if(capacityId.equals("35128") && !capacityId.equals(nowCapcaityId)){
+                            //判断是否正常转取消:新车号为取消且不等于旧车号
+//                            input.put("cancel",true);
+                            cancelOrderMap.put("changeStatus",1);
+                            cancelOrderMap.put("content","取消");
+                            System.out.println("联动计量取消:" + map.get("oldCapacityNumber"));
+                        }else if(capacityDetails.get("oldCapacityIds")!=null){
+                            //存在旧车号,判断是否撤销取消:当前车号为取消,且最近的旧车号等于新车号
+                            String[] oldCapacityIds =("" + capacityDetails.get("oldCapacityIds")).split(",");
+                            String lastOldCapacity = oldCapacityIds[0];
+                            if(nowCapcaityId.equals("35128") && lastOldCapacity.equals(capacityId)){
+//                                input.put("unCancel",true);
+                                cancelOrderMap.put("changeStatus",2);
+                                cancelOrderMap.put("content",map.get("capacityNo"));
+                                System.out.println("联动计量撤销取消:" + map.get("oldCapacityNumber"));
+                            }
+                        }
+                        //发送给计量
+                        if(cancelOrderMap.get("changeStatus")!=null ){
+                            String url = "http://172.16.33.122:44325/api/logistics/CancleOrdersBill";
+                            JSONObject cancelOrderJson = new JSONObject(cancelOrderMap);
+                            System.out.println("联动计量撤销取消报文:" + cancelOrderJson);
+                            String sendUrl = url ;
+                            String jsonData =  HTTPRequestUtils.send(sendUrl, cancelOrderJson,"utf-8");
+                            System.out.println("联动计量撤销取消响应:" + jsonData);
+                        }
+                    }
                 }
 
+            }
+            }catch (Exception e){
+            e.printStackTrace();
         }
         return 1;
     }