双重预防项目-国泰新华二开定制版
heheng
2025-11-19 247a4a1f10f233c89a4bd054dee3cb9b7d4a76f1
新增数据上传准东
已修改3个文件
180 ■■■■ 文件已修改
src/main/java/com/ruoyi/common/utils/ImageToBase64.java 162 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/doublePrevention/scheduls/ZhunDongSchedule.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mybatis/doublePrevention/PreventCJReportDangerInfoMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/common/utils/ImageToBase64.java
@@ -22,10 +22,21 @@
@Slf4j
public class ImageToBase64 {
    public static String convertImageToBase64(String imageUrl) {
        try {
            log.info("【F】任务记录-处理数据imageUrl:" + imageUrl);
            String[] split = imageUrl.split(",");
            String URL1 = "";
            if (split.length > 1){
                URL1 = split[0].trim();
            }else if (split.length == 1){
                URL1 = imageUrl.trim();
            }
            // 创建URL对象
            URL url = new URL(imageUrl);
            URL url = new URL(URL1);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            // 设置请求方法和超时时间
@@ -51,7 +62,68 @@
            byteArrayOutputStream.close();
            // 将图片字节数组编码为 Base64 字符串
            // 将图片字节数组编码为 Base64 字符串
            return Base64.getEncoder().encodeToString(imageBytes);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    public static String convertImageToBase64More(String imageUrl) {
        try {
            log.info("【F】任务记录-处理数据imageUrl:" + imageUrl);
            String[] split = imageUrl.split(",");
            String URL1 = split[0].trim();
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < split.length; i++) {
                String url1 = split[i].trim();
                // 跳过空字符串
                if (url1.isEmpty()) {
                    continue;
                }
                // 创建URL对象
                URL url = new URL(url1);
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                // 设置请求方法和超时时间
                connection.setRequestMethod("GET");
                connection.setConnectTimeout(5000);
                connection.setReadTimeout(5000);
                connection.setDoInput(true);
                // 获取输入流
                InputStream inputStream = connection.getInputStream();
                // 读取图片字节数据
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                byte[] buffer = new byte[1024];
                int bytesRead;
                while ((bytesRead = inputStream.read(buffer)) != -1) {
                    byteArrayOutputStream.write(buffer, 0, bytesRead);
                }
                byte[] imageBytes = byteArrayOutputStream.toByteArray();
                // 关闭流
                inputStream.close();
                byteArrayOutputStream.close();
                // 将图片字节数组编码为 Base64 字符串
                // 将图片字节数组编码为 Base64 字符串
                String base64 = Base64.getEncoder().encodeToString(imageBytes);
                if (result.length() > 0) {
                    result.append(",");
                }
                result.append(base64);
            }
            return result.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
@@ -97,55 +169,55 @@
        BufferedReader buffer = null;
        int responseCode = 200;
            StringBuffer unitResultBuffer = null;
            //上报数据
            try {
        StringBuffer unitResultBuffer = null;
        //上报数据
        try {
                URL url = new URL( "http://218.31.50.112:8087/api/wwyt/t_qyfxfbxx_List");
                con = (HttpURLConnection) url.openConnection();
            URL url = new URL("http://218.31.50.112:8087/api/wwyt/t_qyfxfbxx_List");
            con = (HttpURLConnection) url.openConnection();
                // 设置请求方式和参数
                con.setRequestMethod("POST");
                con.setDoOutput(true);
                con.setDoInput(true);
                con.setUseCaches(false);
                con.setRequestProperty("token", "030B6744-EECB-4732-B679-280373E7E575");
                con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
            // 设置请求方式和参数
            con.setRequestMethod("POST");
            con.setDoOutput(true);
            con.setDoInput(true);
            con.setUseCaches(false);
            con.setRequestProperty("token", "030B6744-EECB-4732-B679-280373E7E575");
            con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("ID", "mn25kwer-8956-34hj-3sdl-dl980lcfdc8a");
                jsonObject.put("IMG", convertImageToBase64local("D:\\1751424343390.png"));
                jsonObject.put("CREATE_TIME", "20220501000000");
                jsonObject.put("UPDATE_TIME", "20250701000000");
                jsonObject.put("DELETE_MARK", "0");
                jsonObject.put("CREATE_BY", "李康");
                jsonObject.put("UPDATE_BY","李康");
                JSONArray jsonArray = new JSONArray();
                jsonArray.add(jsonObject);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("ID", "mn25kwer-8956-34hj-3sdl-dl980lcfdc8a");
            jsonObject.put("IMG", convertImageToBase64local("D:\\1751424343390.png"));
            jsonObject.put("CREATE_TIME", "20220501000000");
            jsonObject.put("UPDATE_TIME", "20250701000000");
            jsonObject.put("DELETE_MARK", "0");
            jsonObject.put("CREATE_BY", "李康");
            jsonObject.put("UPDATE_BY", "李康");
            JSONArray jsonArray = new JSONArray();
            jsonArray.add(jsonObject);
                // 发送请求体
                try (OutputStream os = con.getOutputStream()) {
                    os.write(JSON.toJSONString(jsonArray).getBytes(StandardCharsets.UTF_8));
                }
                responseCode = con.getResponseCode();
                //本段日志,测试成功后,可注释掉
                if (responseCode == HttpURLConnection.HTTP_OK) {
                    //得到响应流
                    InputStream inputStream = con.getInputStream();
                    //将响应流转换成字符串
                    unitResultBuffer = new StringBuffer();
                    String line;
                    buffer = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                    while ((line = buffer.readLine()) != null) {
                        unitResultBuffer.append(line);
                    }
                    System.out.println("上传四色图:" + unitResultBuffer);
                }
            } catch (Exception e) {
                e.printStackTrace();
            // 发送请求体
            try (OutputStream os = con.getOutputStream()) {
                os.write(JSON.toJSONString(jsonArray).getBytes(StandardCharsets.UTF_8));
            }
            responseCode = con.getResponseCode();
            //本段日志,测试成功后,可注释掉
            if (responseCode == HttpURLConnection.HTTP_OK) {
                //得到响应流
                InputStream inputStream = con.getInputStream();
                //将响应流转换成字符串
                unitResultBuffer = new StringBuffer();
                String line;
                buffer = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                while ((line = buffer.readLine()) != null) {
                    unitResultBuffer.append(line);
                }
                System.out.println("上传四色图:" + unitResultBuffer);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
src/main/java/com/ruoyi/doublePrevention/scheduls/ZhunDongSchedule.java
@@ -588,8 +588,12 @@
                //非必传
//                cjReportDangerInfoDTO.setMANAGEMENT_CLASSIFICATION(cjDangerInfo.getManagementClassification());
//                cjReportDangerInfoDTO.setOCCURRENCE_LINK(cjDangerInfo.getOccurrenceLink());
//                cjReportDangerInfoDTO.setATTACHMENTS1(ImageToBase64.convertImageToBase64(cjDangerInfo.getPreRectifyPhoto()));
//                cjReportDangerInfoDTO.setATTACHMENTS2(ImageToBase64.convertImageToBase64(cjDangerInfo.getPostRectifyPhoto()));
                if(ObjectUtils.isNotEmpty(cjDangerInfo.getPreRectifyPhoto())){
                    cjReportDangerInfoDTO.setATTACHMENTS1(ImageToBase64.convertImageToBase64More(cjDangerInfo.getPreRectifyPhoto()));
                }
                if (ObjectUtils.isNotEmpty(cjDangerInfo.getPostRectifyPhoto())) {
                    cjReportDangerInfoDTO.setATTACHMENTS2(ImageToBase64.convertImageToBase64More(cjDangerInfo.getPostRectifyPhoto()));
                }
               // cjReportDangerInfoDTO.setFJ(cjDangerInfo.getRectifyAttachment());
                cjReportDangerInfoDTO.setCREATE_TIME(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, cjDangerInfo.getCreateDate()));
@@ -601,7 +605,7 @@
            }
            //数据上报
            log.info("【F】隐患信息-处理数据【原始数据】" + JSONObject.toJSONString(reportDangerInfoLists));
           // log.info("【F】隐患信息-处理数据【原始数据】" + JSONObject.toJSONString(reportDangerInfoLists));
            StringBuffer dangerInfoResultBuffer = null;
            //上报数据
            try {
src/main/resources/mybatis/doublePrevention/PreventCJReportDangerInfoMapper.xml
@@ -61,10 +61,10 @@
<!--        where zhun_report_status = 1-->
<!--            limit 50-->
<!--,c.pre_rectify_photo,c.post_rectify_photo,c.rectify_attachment-->
        select a.* from prevent_cj_report_danger_info a
<!--        INNER JOIN prevent_risk_danger_info b on  a.id = b.uuid-->
<!--        INNER JOIN tr_hidden_danger_check_point c on c.id = b.danger_check_point_id-->
        where a.zhun_report_status = 1 and a.deleted = 0
        select a.* ,c.pre_rectify_photo,c.post_rectify_photo,c.rectify_attachment from prevent_cj_report_danger_info a
        INNER JOIN prevent_risk_danger_info b on  a.id = b.uuid
        INNER JOIN tr_hidden_danger_check_point c on c.id = b.danger_check_point_id
        where a.zhun_report_status = 1 and a.deleted = 0 and a.danger_manage_deadline &gt;= a.regist_time
<!--        and a.create_date &gt;= '2025-06-15 00:00:00' and a.create_date &lt;= '2025-06-18 23:59:59'-->
        limit 50
    </select>