From b4e8dc09c2af2a331b477904f9d7b205a7224890 Mon Sep 17 00:00:00 2001
From: CZT <czt18638530771@163.com>
Date: 星期一, 06 十一月 2023 16:21:25 +0800
Subject: [PATCH] 优化广东省接口

---
 src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java |   68 ++++++++++++++++++++++++++++++---
 1 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java b/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java
index 1dc9881..8bfb601 100644
--- a/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java
+++ b/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java
@@ -16,6 +16,7 @@
 import com.fzzy.push.gd2022.dto.Gd2022Api1208;
 import com.fzzy.push.gd2022.dto.Gd2022Api1307;
 import com.fzzy.push.gd2022.dto.Gd2022Api1308;
+import com.fzzy.push.sh2023.SH2023Constant;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -24,6 +25,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.lang.reflect.Field;
 import java.util.*;
 
 /**
@@ -51,6 +53,11 @@
     @Override
     public String getProtocol() {
         return PushProtocol.SB_GD_2022.getCode();
+    }
+
+    @Override
+    public ResponseDto pushData(ApiParam param, Object data) {
+        return pushData(param, null, data);
     }
 
     @Override
@@ -115,17 +122,11 @@
             ResponseDto resd = new ResponseDto();
             resd.setSuccess(responseDto.getCode() == 200 ? 0 : responseDto.getCode());
             resd.setMsg(responseDto.getMsg());
-            //updateGD2022AuthToken(responseDto,conf, token);
             return resd;
         } catch (Exception e) {
             log.error(e.getMessage(), e);
             return new ResponseDto(99, e.getMessage());
         }
-    }
-
-    @Override
-    public ResponseDto pushData(ApiParam param, Object data) {
-        return pushData(param, null, data);
     }
 
     /**
@@ -266,12 +267,59 @@
         }
     }
 
+    private Object changeObject(Object object) {
+        // 浣跨敤鍙嶅皠鑾峰彇灞炴�у垪琛� object涓哄疄浣撳璞″悕
+        Field[] fields = object.getClass().getDeclaredFields();
+        for (Field field : fields) {
+            field.setAccessible(true);
+            try {
+                // 鍒ゆ柇灞炴�у�兼槸鍚︿负null
+                if (field.get(object) == null || field.get(object) == "") {
+                    //鏍规嵁绫诲瀷璁剧疆榛樿鍊�
+                    if (field.getType() == String.class) {
+                        field.set(object, "0");
+                    }
+                    if (field.getType() == Integer.class) {
+                        field.set(object, 0);
+                    }
+                    if (field.getType() == Double.class) {
+                        field.set(object, 0.0);
+                    }
+                    if (field.getType() == Date.class) {
+                        field.set(object, new Date());
+                    }
+                }
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+        return object;
+    }
+
     private String getJsonData(String inteId, Object data, String url, GD2022AuthToken authToken) throws Exception {
         if (Constant.API_CODE_1101.equals(inteId)) {
             Gd2022Api1101 api1101 = new Gd2022Api1101();
             BeanUtils.copyProperties(data, api1101);
             return JSON.toJSONString(api1101);
-        } else if (Constant.API_CODE_1109.equals(inteId)) {
+        } else if (Constant.API_CODE_1102.equals(inteId)) {
+            Gd2022Api1102 api1102 = new Gd2022Api1102();
+            BeanUtils.copyProperties(data, api1102);
+            return JSON.toJSONString(api1102);
+        } else if (Constant.API_CODE_1103.equals(inteId)) {
+            Gd2022Api1103 api1103 = new Gd2022Api1103();
+            BeanUtils.copyProperties(data, api1103);
+            changeObject(api1103);
+            return JSON.toJSONString(api1103);
+        } else if (Constant.API_CODE_1104.equals(inteId)) {
+            Gd2022Api1104 api1104 = new Gd2022Api1104();
+            BeanUtils.copyProperties(data, api1104);
+            changeObject(api1104);
+            return JSON.toJSONString(api1104);
+        } else if (Constant.API_CODE_1105.equals(inteId)) {
+            Gd2022Api1105 api1105 = new Gd2022Api1105();
+            BeanUtils.copyProperties(data, api1105);
+            return JSON.toJSONString(api1105);
+        }else if (Constant.API_CODE_1109.equals(inteId)) {
             //灏佽鏁版嵁
             Gd2022Api1109 api1109 = new Gd2022Api1109();
             BeanUtils.copyProperties(data, api1109);
@@ -281,9 +329,14 @@
             }
             //鍏堜笂浼犳枃浠�,鑾峰彇鏂囦欢id
             GD2022ResponseDto responseDto = GD2022HttpClientUtil.postUploadData(url, authToken, api1109.getWjdz());
+            System.out.println((String) responseDto.getData());
             //璁剧疆涓婁紶鏂囦欢id
             api1109.setFileStorageId((String) responseDto.getData());
             return JSON.toJSONString(api1109);
+        }else if (Constant.API_CODE_1111.equals(inteId)) {
+            Gd2022Api1111 api1111 = new Gd2022Api1111();
+            BeanUtils.copyProperties(data, api1111);
+            return JSON.toJSONString(api1111);
         } else if (Constant.API_CODE_1208.equals(inteId)) {
             Gd2022Api1208 api1208 = new Gd2022Api1208();
             BeanUtils.copyProperties(data, api1208);
@@ -315,6 +368,7 @@
             api1308.setFileStorageId((String) responseDto.getData());
             return JSON.toJSONString(api1308);
         } else {
+//            changeObject(data);
             return JSON.toJSONString(data);
         }
     }

--
Gitblit v1.9.3