CZT
2023-12-27 2fe99f0d876377f7d20cb922c83d31cfbf766020
上海嘉定纪委接口-提交2
已修改4个文件
45 ■■■■ 文件已修改
src/main/java/com/fzzy/api/utils/AESUtils.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/push/shjdjw2023/Shjdjw2023HttpClientUtil.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/push/shjdjw2023/ShjdjwApiRemoteService2023.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/push/shjdjw2023/dto/ShjdjwReqDto.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/api/utils/AESUtils.java
@@ -102,7 +102,7 @@
//            System.out.print("Key长度不是16位");
//            return null;
//        }
        SecretKey secretKey = new SecretKeySpec(key.getBytes(ENCODING), ALGORITHM_ECB);
        SecretKey secretKey = new SecretKeySpec(key.getBytes(ENCODING), ALGORITHM);
        // AES加密采用pkcs5padding填充
        Cipher cipher = Cipher.getInstance(PATTERN);
        //用密匙初始化Cipher对象
src/main/java/com/fzzy/push/shjdjw2023/Shjdjw2023HttpClientUtil.java
@@ -32,10 +32,8 @@
        HttpURLConnection connection = null;
        OutputStream outputStream = null;
        String rs = "";
        ShjdjwRespDto responseDto = null;
        ShjdjwRespDto responseDto;
        try {
            String md = AESUtils.encrypt(data, apiConfs.getPublicKey());
            log.info("---------接口请求地址:" +url+ "----------密文参数:" + md +"---------");
            connection = (HttpURLConnection) urls.openConnection();
            connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
            connection.setDoOutput(true);
@@ -47,10 +45,10 @@
            connection.setConnectTimeout(20000);
            connection.setReadTimeout(30000);
            connection.setRequestMethod("POST");
            StringBuffer buffer = new StringBuffer();
            buffer.append(md);
            outputStream = connection.getOutputStream();
            outputStream.write(buffer.toString().getBytes("UTF-8"));
            outputStream.write(data.getBytes("UTF-8"));
            try {
                connection.connect();
                if (connection.getResponseCode() == 200) {
@@ -71,9 +69,11 @@
                return new ShjdjwRespDto(99,e.getMessage());
            }
            log.info("---------接口返回:" + rs +"---------");
            responseDto = JSON.parseObject(rs,ShjdjwRespDto.class);
            if(responseDto == null )   return new ShjdjwRespDto(99,"接口请求发生未知错误");
            return responseDto;
            if(StringUtils.isEmpty(rs)){
                return new ShjdjwRespDto(99,"接口请求发生未知错误");
            }
//            responseDto = JSON.parseObject(rs, ShjdjwRespDto.class);
            return new ShjdjwRespDto(1,"接口请求发生未知错误");
        } finally {
            try {
                outputStream.close();
src/main/java/com/fzzy/push/shjdjw2023/ShjdjwApiRemoteService2023.java
@@ -106,9 +106,14 @@
            //查询库区信息行政区划码
            List<Api1102> api1102List = api1102Rep.findPushData(kqdm);
            //获取json数据
            String jsonData = getJsonData(inteId, data, api1102List.get(0).getXzqhdm());
            List<Object> list = getJsonData(inteId, data, api1102List.get(0).getXzqhdm());
            ShjdjwReqDto reqData = new ShjdjwReqDto();
            //接口ID
            reqData.setId(getInteId(inteId));
            //上传数据,加密
            reqData.setData(list);
            apiLog.setData(jsonData);
            apiLog.setData(JSON.toJSONString(reqData));
            apiLog.setKqdm(kqdm);
            apiLog.setUploadTime(new Date());
            if (conf == null) {
@@ -119,13 +124,11 @@
                return responseDto;
            }
            ShjdjwReqDto reqData = new ShjdjwReqDto();
            //接口ID
            reqData.setId(getInteId(inteId));
            //上传数据,加密
            reqData.setData(AESUtils.encryptByEcb(jsonData, conf.getPublicKey()));
            String jsonStr = JSON.toJSONString(reqData);
            log.info("上报数据信息=" + jsonStr);
            jsonStr = AESUtils.encryptByEcb(jsonStr, conf.getPublicKey());
            ShjdjwRespDto responseDto = Shjdjw2023HttpClientUtil.postPushData(conf.getApiUrl(), JSON.toJSONString(reqData), conf);
            ShjdjwRespDto responseDto = Shjdjw2023HttpClientUtil.postPushData(conf.getApiUrl(), jsonStr, conf);
            responseDto.setBizId(bizId);
            apiLog.setStatus(responseDto.getCode() == 1 ? 0 : responseDto.getCode());
@@ -186,12 +189,12 @@
     * @param code
     * @return
     */
    private String getJsonData(String inteId, Object data, String code) {
    private List<Object> getJsonData(String inteId, Object data, String code) {
        List<Object> list = new ArrayList<>();
        Object object = getJsonApiData(inteId, data, code);
        list.add(object);
        return JSON.toJSONString(list);
        return list;
    }
    /**
src/main/java/com/fzzy/push/shjdjw2023/dto/ShjdjwReqDto.java
@@ -19,5 +19,5 @@
    /**
     * 上传数据(集合形式)
     */
    private String data;
    private Object data;
}