From 111f952ebe91c261fa418be96226e1fa01865e3b Mon Sep 17 00:00:00 2001
From: CZT <czt18638530771@163.com>
Date: 星期六, 11 十一月 2023 20:37:52 +0800
Subject: [PATCH] 优化上海接口信息

---
 src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java |  200 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 124 insertions(+), 76 deletions(-)

diff --git a/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java b/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java
index 36925f8..251e9dd 100644
--- a/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java
+++ b/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java
@@ -9,6 +9,9 @@
 import com.fzzy.api.service.ApiCommonService;
 import com.fzzy.api.service.ApiRemoteService;
 import com.fzzy.api.utils.*;
+import com.fzzy.api.view.repository.Api1101Rep;
+import com.fzzy.api.view.repository.Api1102Rep;
+import com.fzzy.api.view.repository.Api1404Rep;
 import com.fzzy.api.view.repository.ApiLogRep;
 import com.fzzy.push.gd2022.dto.*;
 import com.fzzy.push.gd2022.dto.Gd2022Api1101;
@@ -16,6 +19,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 +28,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.lang.reflect.Field;
 import java.util.*;
 
 /**
@@ -44,13 +49,23 @@
 
     @Autowired
     private ApiCommonService apiCommonService;
-
+    @Autowired
+    private Api1404Rep api1404Rep;
+    @Autowired
+    private Api1101Rep api1101Rep;
+    @Autowired
+    private Api1102Rep api1102Rep;
     @Autowired
     private ApiLogRep apiLogRep;
 
     @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,7 +130,6 @@
             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);
@@ -123,71 +137,9 @@
         }
     }
 
-    @Override
-    public ResponseDto pushData(ApiParam param, Object data) {
-        return pushData(param, null, data);
-    }
-
-//    @Override
-//    public ResponseDto pushFile(ApiParam param, ApiConfs conf, Object data) {
-//
-//        String inteId = param.getInteId();
-//        String kqdm = param.getKqdm();
-//
-//        try {
-//
-//            if (null == conf) {
-//                conf = apiCommonService.getConf(kqdm);
-//            }
-//            //鑾峰彇TOKEN
-//            GD2022AuthToken token = getGD2022AuthToken(conf);
-//
-//            ApiLog apiLog = new ApiLog();
-//            apiLog.setId(ContextUtil.getUUID());
-//            apiLog.setInteId(inteId);
-//            apiLog.setData(JSON.toJSONString(data));
-//            apiLog.setKqdm(kqdm);
-//            apiLog.setUploadTime(new Date());
-//
-//            String wjdz = "";
-//            if (Constant.API_CODE_1109.equals(inteId)) {
-//                //灏佽鏁版嵁,鑾峰彇鏂囦欢鍦板潃
-//                Gd2022Api1109 api1109 = new Gd2022Api1109();
-//                BeanUtils.copyProperties(data, api1109);
-//                wjdz = api1109.getWjdz();
-//            } else if (Constant.API_CODE_1307.equals(inteId)) {
-//                //灏佽鏁版嵁,鑾峰彇鏂囦欢鍦板潃
-//                Gd2022Api1307 api1307 = new Gd2022Api1307();
-//                BeanUtils.copyProperties(data, api1307);
-//                wjdz = api1307.getWjdz();
-//            } else if (Constant.API_CODE_1308.equals(inteId)) {
-//                //灏佽鏁版嵁,鑾峰彇鏂囦欢鍦板潃
-//                Gd2022Api1308 api1308 = new Gd2022Api1308();
-//                BeanUtils.copyProperties(data, api1308);
-//                wjdz = api1308.getWjdz();
-//            }
-//            if (StringUtils.isEmpty(wjdz)) {
-//                ResponseDto responseDto = new ResponseDto(99, "娌℃湁鑾峰彇鍒版枃浠跺湴鍧�", wjdz);
-//                apiLog.setStatus(99);
-//                apiLog.setResult("娌℃湁鑾峰彇鍒版枃浠跺湴鍧�");
-//                apiLogRep.save(apiLog);
-//                return responseDto;
-//            }
-//            //鍏堜笂浼犳枃浠�,鑾峰彇鏂囦欢id
-//            GD2022ResponseDto responseDto = GD2022HttpClientUtil.postUploadData(conf.getApiUrl(), token, wjdz);
-//            ResponseDto resd = new ResponseDto();
-//            resd.setSuccess(responseDto.getCode() == 200 ? 0 : responseDto.getCode());
-//            resd.setBizId((String) responseDto.getData());
-//            resd.setMsg(responseDto.getMsg());
-//            return resd;
-//        } catch (Exception e) {
-//            log.error(e.getMessage(), e);
-//            return new ResponseDto(99, e.getMessage());
-//        }
-//    }
-
     /**
      * 鎺ㄩ�佽储鍔℃暟鎹帴鍙�
+     *
      * @param param
      * @param conf
      * @param data
@@ -324,12 +276,64 @@
         }
     }
 
+    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)) {
+        }
+        if (Constant.API_CODE_1102.equals(inteId)) {
+            Gd2022Api1102 api1102 = new Gd2022Api1102();
+            BeanUtils.copyProperties(data, api1102);
+            return JSON.toJSONString(api1102);
+        }
+        if (Constant.API_CODE_1103.equals(inteId)) {
+            Gd2022Api1103 api1103 = new Gd2022Api1103();
+            BeanUtils.copyProperties(data, api1103);
+            changeObject(api1103);
+            return JSON.toJSONString(api1103);
+        }
+        if (Constant.API_CODE_1104.equals(inteId)) {
+            Gd2022Api1104 api1104 = new Gd2022Api1104();
+            BeanUtils.copyProperties(data, api1104);
+            changeObject(api1104);
+            return JSON.toJSONString(api1104);
+        }
+        if (Constant.API_CODE_1105.equals(inteId)) {
+            Gd2022Api1105 api1105 = new Gd2022Api1105();
+            BeanUtils.copyProperties(data, api1105);
+            return JSON.toJSONString(api1105);
+        }
+        if (Constant.API_CODE_1109.equals(inteId)) {
             //灏佽鏁版嵁
             Gd2022Api1109 api1109 = new Gd2022Api1109();
             BeanUtils.copyProperties(data, api1109);
@@ -339,18 +343,30 @@
             }
             //鍏堜笂浼犳枃浠�,鑾峰彇鏂囦欢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)) {
+        }
+        if (Constant.API_CODE_1111.equals(inteId)) {
             Gd2022Api1111 api1111 = new Gd2022Api1111();
             BeanUtils.copyProperties(data, api1111);
+            List<Api1102> api1102List = api1102Rep.findPushData(api1111.getKqdm());
+            if(null != api1102List && api1102List.size() > 0){
+                api1111.setKqmc(api1102List.get(0).getKqmc());
+            }
+            List<Api1101> api1101List = api1101Rep.findDataByDwdm(api1111.getDwdm());
+            if(null != api1101List && api1101List.size() > 0){
+                api1111.setDwmc(api1101List.get(0).getDwmc());
+            }
             return JSON.toJSONString(api1111);
-        } else if (Constant.API_CODE_1208.equals(inteId)) {
+        }
+        if (Constant.API_CODE_1208.equals(inteId)) {
             Gd2022Api1208 api1208 = new Gd2022Api1208();
             BeanUtils.copyProperties(data, api1208);
             return JSON.toJSONString(api1208);
-        } else if (Constant.API_CODE_1307.equals(inteId)) {
+        }
+        if (Constant.API_CODE_1307.equals(inteId)) {
             //灏佽鏁版嵁
             Gd2022Api1307 api1307 = new Gd2022Api1307();
             BeanUtils.copyProperties(data, api1307);
@@ -363,7 +379,8 @@
             //璁剧疆涓婁紶鏂囦欢id
             api1307.setFileStorageId((String) responseDto.getData());
             return JSON.toJSONString(api1307);
-        } else if (Constant.API_CODE_1308.equals(inteId)) {
+        }
+        if (Constant.API_CODE_1308.equals(inteId)) {
             //灏佽鏁版嵁
             Gd2022Api1308 api1308 = new Gd2022Api1308();
             BeanUtils.copyProperties(data, api1308);
@@ -376,9 +393,40 @@
             //璁剧疆涓婁紶鏂囦欢id
             api1308.setFileStorageId((String) responseDto.getData());
             return JSON.toJSONString(api1308);
-        } else {
-            return JSON.toJSONString(data);
         }
+        if (Constant.API_CODE_1403.equals(inteId)) {
+            //杞崲璁″垝锛屽崟鐙煡璇㈣疆鎹㈣鍒掓槑缁嗕俊鎭紝缁熶竴灏佽鍚庝笂浼�
+            Gd2022Api1403 api1403 = new Gd2022Api1403();
+            BeanUtils.copyProperties(data, api1403);
+            List<Api1404> list = api1404Rep.getDataByLhjhdh(api1403.getLhjhdh());
+            Gd2022Api1404 gd2022Api1404;
+            List<Gd2022Api1404> dtls = new ArrayList<>();
+            Double lrsl = 0.0, lcsl = 0.0; //鐢ㄤ簬缁熻杞叆鏁伴噺鍜岃疆鍑烘暟閲�
+            if(null != list && list.size() > 0){
+                for (Api1404 api1404 : list) {
+                    gd2022Api1404 = new Gd2022Api1404();
+                    BeanUtils.copyProperties(api1404, gd2022Api1404);
+                    if(null!= gd2022Api1404.getLhlx() && "2".equals(gd2022Api1404.getLhlx())){
+                        lrsl += gd2022Api1404.getLhsl();
+                    }
+                    if(null!= gd2022Api1404.getLhlx() && "1".equals(gd2022Api1404.getLhlx())){
+                        lcsl += gd2022Api1404.getLhsl();
+                    }
+                    dtls.add(gd2022Api1404);
+                }
+            }
+            api1403.setRotationInQty(lrsl);
+            api1403.setRotationOutQty(lcsl);
+            api1403.setDtls(dtls);
+            return JSON.toJSONString(api1403);
+        }
+        if (Constant.API_CODE_1404.equals(inteId)) {
+            //杞崲璁″垝鏄庣粏锛屼笉鍗曠嫭涓婁紶锛屽湪杞崲璁″垝涓粺涓�涓婁紶
+            return null;
+        }
+
+//        changeObject(data);
+        return JSON.toJSONString(data);
     }
 
 
@@ -620,7 +668,7 @@
             case "1112":
                 return ApiCodeConstant.API_CODE_RYXX;
             case "1113":
-                return "";
+                return ApiCodeConstant.API_CODE_QYXYXX;
             case "1201":
                 return ApiCodeConstant.API_CODE_HTXX;
             case "1202":
@@ -668,11 +716,11 @@
             case "1401":
                 return ApiCodeConstant.API_CODE_CBGM;
             case "1402":
-                return ApiCodeConstant.API_CODE_CBJHXX;
+                return ApiCodeConstant.API_CODE_CBJH;
             case "1403":
-                return ApiCodeConstant.API_CODE_LHJHXX;
+                return ApiCodeConstant.API_CODE_LHJH;
             case "1404":
-                return ApiCodeConstant.API_CODE_LHJHMXXX;
+                return null;
             case "1405":
                 return "";
             case "1501":

--
Gitblit v1.9.3