java110 лет назад: 2
Родитель
Сommit
14267f1fdb

+ 34 - 0
service-api/src/main/java/com/java110/api/controller/app/smartWeter/NotifySmartMeterController.java

@@ -20,6 +20,40 @@ public class NotifySmartMeterController extends BaseController{
     @Autowired
     private INotifySmartMeterV1InnerServiceSMO notifySmartWeterV1InnerServiceSMOImpl;
 
+    /**
+     * <p>支付回调Api</p>
+     *
+     * @param request
+     * @throws Exception
+     */
+    @RequestMapping(path = "/{implBean}", method = RequestMethod.POST)
+    public ResponseEntity<String> notifyTq(
+            @PathVariable String implBean,
+            @RequestBody String postInfo,
+            HttpServletRequest request) {
+        String appId = "992020051967020024";
+
+        //todo 为啥写的这么挫 因为拓强的电表 回调路径太长 他会失败
+        switch (implBean) {
+            case "a":
+                implBean = "tqDianBiaoDanxiangDanFeiLvFactoryAdaptImpl";
+                break;
+            case "b":
+                implBean = "tqDianBiaoRemoteDanFeiLvPreFactoryAdaptImpl";
+                break;
+            case "c":
+                implBean = "tqShuiBiaoLoraReadFactoryAdaptImpl";
+                break;
+            case "d":
+                implBean = "tqShuiBiaoLoraRechargeFactoryAdaptImpl";
+                break;
+            default:
+        }
+
+        return notifySmartWeterV1InnerServiceSMOImpl.notifySmartMater(new NotifyMeterWaterOrderDto(appId, postInfo, implBean));
+
+    }
+
     /**
      * <p>支付回调Api</p>
      *

+ 3 - 0
service-common/src/main/java/com/java110/common/smartMeter/SmartMeterCoreReadImpl.java

@@ -271,6 +271,9 @@ public class SmartMeterCoreReadImpl implements ISmartMeterCoreRead {
         if(ResultVo.CODE_OK != resultVo.getCode()){
             return 0.0;
         }
+        if(resultVo.getData() == null){
+            return 0.0;
+        }
         return Double.parseDouble(resultVo.getData().toString());
     }
 

+ 1 - 1
service-common/src/main/java/com/java110/common/smartMeter/factory/Tdshuibiao/TqShuiBiaoLoraReadFactoryAdaptImpl.java

@@ -34,7 +34,7 @@ import java.util.Map;
 @Service("tqShuiBiaoLoraReadFactoryAdaptImpl")
 public class TqShuiBiaoLoraReadFactoryAdaptImpl implements ISmartMeterFactoryAdapt {
     private static final String READ_URL = "http://api2.tqdianbiao.com/Api_v2/water_read";
-    private static final String NOTIFY_URL = "/app/smartMeter/notify/tqShuiBiaoLoraReadFactoryAdaptImpl/992020051967020024";
+    private static final String NOTIFY_URL = "/app/smartMeter/notify/c";
 
     @Autowired
     private IMeterMachineSpecV1InnerServiceSMO meterMachineSpecV1InnerServiceSMOImpl;

+ 2 - 2
service-common/src/main/java/com/java110/common/smartMeter/factory/Tdshuibiao/TqShuiBiaoLoraRechargeFactoryAdaptImpl.java

@@ -35,7 +35,7 @@ public class TqShuiBiaoLoraRechargeFactoryAdaptImpl implements ISmartMeterFactor
 
     private static final String RECHARGE_URL = "http://api2.tqdianbiao.com/Api_v2/water_security/recharge";
 
-    private static final String NOTIFY_URL = "/app/smartMeter/notify/tqShuiBiaoLoraRechargeFactoryAdaptImpl/992020051967020024";
+    private static final String NOTIFY_URL = "/app/smartMeter/notify/d";
     @Autowired
     private IMeterMachineSpecV1InnerServiceSMO meterMachineSpecV1InnerServiceSMOImpl;
 
@@ -136,7 +136,7 @@ public class TqShuiBiaoLoraRechargeFactoryAdaptImpl implements ISmartMeterFactor
         String detailId = GenerateCodeFactory.getGeneratorId("11");
         Map<String, Object> item = new HashMap<>();
         item.put("opr_id", detailId);
-        item.put("time_out", 0);
+        item.put("time_out", 3);
         item.put("must_online", true);
         item.put("retry_times", 1);
         item.put("cid", meterMachineSpecDtos.get(0).getSpecValue());

+ 1 - 1
service-common/src/main/java/com/java110/common/smartMeter/factory/tqdianbiao/TqDianBiaoDanxiangDanFeiLvFactoryAdaptImpl.java

@@ -29,7 +29,7 @@ import java.util.*;
 public class TqDianBiaoDanxiangDanFeiLvFactoryAdaptImpl implements ISmartMeterFactoryAdapt {
     private static final String READ_URL = "http://api2.tqdianbiao.com/Api_v2/ele_read";
 
-    private static final String NOTIFY_URL = "/app/smartMeter/notify/tqDianBiaoFactoryAdaptImpl/992020051967020024";
+    private static final String NOTIFY_URL = "/app/smartMeter/notify/a";
 
     @Autowired
     private IMeterMachineSpecV1InnerServiceSMO meterMachineSpecV1InnerServiceSMOImpl;

+ 4 - 4
service-common/src/main/java/com/java110/common/smartMeter/factory/tqdianbiao/TqDianBiaoRemoteDanFeiLvPreFactoryAdaptImpl.java

@@ -34,7 +34,7 @@ public class TqDianBiaoRemoteDanFeiLvPreFactoryAdaptImpl implements ISmartMeterF
 
     private static final String RECHARGE_URL = "http://api2.tqdianbiao.com/Api_v2/ele_security/recharge";
 
-    private static final String NOTIFY_URL = "/app/smartMeter/notify/tqDianBiaoRemoteDanFeiLvPreFactoryAdaptImpl/992020051967020024";
+    private static final String NOTIFY_URL = "/app/smartMeter/notify/b";
     @Autowired
     private IMeterMachineSpecV1InnerServiceSMO meterMachineSpecV1InnerServiceSMOImpl;
 
@@ -136,12 +136,12 @@ public class TqDianBiaoRemoteDanFeiLvPreFactoryAdaptImpl implements ISmartMeterF
         String detailId = GenerateCodeFactory.getGeneratorId("11");
         Map<String, Object> item = new HashMap<>();
         item.put("opr_id", detailId);
-        item.put("time_out", 0);
+        item.put("time_out", 3);
         item.put("must_online", true);
         item.put("retry_times", 1);
         item.put("cid", meterMachineSpecDtos.get(0).getSpecValue());
         item.put("address", meterMachineDto.getAddress());
-        item.put("type", 3);
+        item.put("type", 22);
         req.add(item);
         List<MeterMachineDetailPo> meterMachineDetailPos = new ArrayList<>();
         MeterMachineDetailPo meterMachineDetailPo = new MeterMachineDetailPo();
@@ -176,7 +176,7 @@ public class TqDianBiaoRemoteDanFeiLvPreFactoryAdaptImpl implements ISmartMeterF
         if (meterMachineDetailPos.size() > 0) {
             meterMachineDetailV1InnerServiceSMOImpl.saveMeterMachineDetails(meterMachineDetailPos);
         }
-        return new ResultVo(ResultVo.CODE_OK, "提交重置");
+        return new ResultVo(ResultVo.CODE_OK, "提交查询");
     }
 
     @Override

+ 49 - 6
springboot/src/main/java/com/java110/boot/controller/app/smartWeter/NotifySmartMeterController.java

@@ -1,5 +1,6 @@
 package com.java110.boot.controller.app.smartWeter;
 
+import com.alibaba.fastjson.JSONObject;
 import com.java110.core.base.controller.BaseController;
 import com.java110.core.log.LoggerFactory;
 import com.java110.dto.meter.NotifyMeterWaterOrderDto;
@@ -13,13 +14,55 @@ import javax.servlet.http.HttpServletRequest;
 
 @RestController
 @RequestMapping(path = "/app/smartMeter/notify")
-public class NotifySmartMeterController extends BaseController{
+public class NotifySmartMeterController extends BaseController {
 
     private final static Logger logger = LoggerFactory.getLogger(NotifySmartMeterController.class);
 
     @Autowired
     private INotifySmartMeterV1InnerServiceSMO notifySmartWeterV1InnerServiceSMOImpl;
 
+    /**
+     * <p>支付回调Api</p>
+     *
+     * @param request
+     * @throws Exception
+     */
+    @RequestMapping(path = "/{implBean}", method = RequestMethod.POST)
+    public ResponseEntity<String> notifyTq(
+            @PathVariable String implBean,
+            @RequestBody String postInfo,
+            HttpServletRequest request) {
+        String appId = "992020051967020024";
+
+        JSONObject paramIn = new JSONObject();
+        for (String key : request.getParameterMap().keySet()) {
+            paramIn.put(key, request.getParameter(key));
+            logger.debug("拓强回调报文form" + key + ":: " + request.getParameter(key));
+        }
+        logger.debug("拓强回调报文" + paramIn.toJSONString());
+
+        //todo 为啥写的这么挫 因为拓强的电表 回调路径太长 他会失败
+        switch (implBean) {
+            case "a":
+                implBean = "tqDianBiaoDanxiangDanFeiLvFactoryAdaptImpl";
+                break;
+            case "b":
+                implBean = "tqDianBiaoRemoteDanFeiLvPreFactoryAdaptImpl";
+                break;
+            case "c":
+                implBean = "tqShuiBiaoLoraReadFactoryAdaptImpl";
+                break;
+            case "d":
+                implBean = "tqShuiBiaoLoraRechargeFactoryAdaptImpl";
+                break;
+            default:
+        }
+
+
+        return notifySmartWeterV1InnerServiceSMOImpl.notifySmartMater(new NotifyMeterWaterOrderDto(appId, paramIn.toJSONString(), implBean));
+
+    }
+
     /**
      * <p>支付回调Api</p>
      *
@@ -28,12 +71,12 @@ public class NotifySmartMeterController extends BaseController{
      */
     @RequestMapping(path = "/{implBean}/{appId}", method = RequestMethod.POST)
     public ResponseEntity<String> notify(
-                                          @PathVariable String implBean,
-                                          @PathVariable String appId,
-                                          @RequestBody String postInfo,
-                                          HttpServletRequest request) {
+            @PathVariable String implBean,
+            @PathVariable String appId,
+            @RequestBody String postInfo,
+            HttpServletRequest request) {
 
-        return notifySmartWeterV1InnerServiceSMOImpl.notifySmartMater(new NotifyMeterWaterOrderDto(appId,postInfo,implBean));
+        return notifySmartWeterV1InnerServiceSMOImpl.notifySmartMater(new NotifyMeterWaterOrderDto(appId, postInfo, implBean));
 
     }