双重预防项目-国泰新华二开定制版
heheng
2025-11-20 037e91db7dee12aa1adc666601d890a58ca2e2ab
新增数据上传准东单独业务处理
已修改7个文件
253 ■■■■■ 文件已修改
src/main/java/com/ruoyi/common/utils/ImageToBase64.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/doublePrevention/controller/RiskOldInfoController.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/doublePrevention/repository/PreventCJReportDangerInfoRepository.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/doublePrevention/scheduls/ZhunDongSchedule.java 162 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/doublePrevention/service/baseService/PreventCJReportDangerInfoService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/PreventCJReportDangerInfoServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mybatis/doublePrevention/PreventCJReportDangerInfoMapper.xml 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/common/utils/ImageToBase64.java
@@ -33,7 +33,10 @@
            }else if (split.length == 1){
                URL1 = imageUrl.trim();
            }
            if (URL1.isEmpty()){
                log.info("【F】任务记录-处理数据URL1为空");
                return  "";
            }
            // 创建URL对象
            URL url = new URL(URL1);
@@ -41,8 +44,8 @@
            // 设置请求方法和超时时间
            connection.setRequestMethod("GET");
            connection.setConnectTimeout(5000);
            connection.setReadTimeout(5000);
            connection.setConnectTimeout(10000);
            connection.setReadTimeout(10000);
            connection.setDoInput(true);
            // 获取输入流
src/main/java/com/ruoyi/doublePrevention/controller/RiskOldInfoController.java
@@ -6,6 +6,7 @@
import com.ruoyi.doublePrevention.enums.ResultCodes;
import com.ruoyi.doublePrevention.repository.RiskOldInfoRepository;
//import com.ruoyi.doublePrevention.scheduls.ZhunDongSchedule;
import com.ruoyi.doublePrevention.scheduls.ZhunDongSchedule;
import com.ruoyi.doublePrevention.service.baseService.RiskOldInfoService;
import com.ruoyi.doublePrevention.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,15 +38,15 @@
//        return riskOldInfoService.selectOldRiskInfoPage(queryReqDTO);
    }
//
//    @Autowired
//    private ZhunDongSchedule zhunDongSchedule;
//    @GetMapping("/dataTest")
//    public ResultVO dataTest() {
//        zhunDongSchedule.updateHuaidongReportStatus();
//        ResultVO resultVO = new ResultVO<>();
//        resultVO.setCode(ResultCodes.OK.getCode());
//        return resultVO;
//    }
    @Autowired
    private ZhunDongSchedule zhunDongSchedule;
    @GetMapping("/dataTest")
    public ResultVO dataTest(Integer indexId) {
        zhunDongSchedule.ZDDangerInfosSP(indexId);
        ResultVO resultVO = new ResultVO<>();
        resultVO.setCode(ResultCodes.OK.getCode());
        return resultVO;
    }
}
src/main/java/com/ruoyi/doublePrevention/repository/PreventCJReportDangerInfoRepository.java
@@ -44,6 +44,10 @@
     * 上报数据-待上报数据查询
     */
    List<ZDPreventCJReportDangerInfo> listReportDangerDateZhunDong();
    List<ZDPreventCJReportDangerInfo> listReportDangerDateZhunDongSp(Integer indexId);
    int updateErrorZDdata();
    /**
     * 上报数据-待上报状态变更-通过id
     */
src/main/java/com/ruoyi/doublePrevention/scheduls/ZhunDongSchedule.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ImageToBase64;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.doublePrevention.entity.CJReport.*;
import com.ruoyi.doublePrevention.entity.CJReport.CJdto.HandlerDO.CJReportDangerInfoDTO;
import com.ruoyi.doublePrevention.entity.ZDReport.*;
@@ -69,10 +70,17 @@
        //排查记录表
       // sleep(5000);
        ZDRecordFromTasks();
        sleep(5000);
    }
    @Scheduled(cron = "0 0/5 * * * ? ")
    public void updateHuaidongReportStatusDangerInfo() {
        log.info("开始推送准东数据隐患治理..." + DateUtils.dateTimeNow());
        sleep(1000);
        //治理信息表
        ZDDangerInfos();
    }
    /**
@@ -554,6 +562,8 @@
                /**
         * 6、处理隐患信息数据
         * */
        int i = CJDangerInfoService.updateErrorZDdata();
        log.info("【F】隐患信息-处理数据【原始数据错误更新数量】" + i);
        log.info("【F】隐患信息-处理数据...");
        List<ZDPreventCJReportDangerInfo> CJDangerInfos = CJDangerInfoService.listReportDangerDateZhunDong();
        if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(CJDangerInfos)){
@@ -588,16 +598,23 @@
                //非必传
//                cjReportDangerInfoDTO.setMANAGEMENT_CLASSIFICATION(cjDangerInfo.getManagementClassification());
//                cjReportDangerInfoDTO.setOCCURRENCE_LINK(cjDangerInfo.getOccurrenceLink());
                if(ObjectUtils.isNotEmpty(cjDangerInfo.getPreRectifyPhoto())){
                    cjReportDangerInfoDTO.setATTACHMENTS1(ImageToBase64.convertImageToBase64More(cjDangerInfo.getPreRectifyPhoto()));
                if(StringUtils.isNotEmpty(cjDangerInfo.getPreRectifyPhoto())){
                    String s = ImageToBase64.convertImageToBase64(cjDangerInfo.getPreRectifyPhoto());
                    if (StringUtils.isNotEmpty( s)){
                        cjReportDangerInfoDTO.setATTACHMENTS1(s);
                    }
                }
                if (ObjectUtils.isNotEmpty(cjDangerInfo.getPostRectifyPhoto())) {
                    cjReportDangerInfoDTO.setATTACHMENTS2(ImageToBase64.convertImageToBase64More(cjDangerInfo.getPostRectifyPhoto()));
                    String s = ImageToBase64.convertImageToBase64(cjDangerInfo.getPostRectifyPhoto());
                    if (StringUtils.isNotEmpty(s)){
                        cjReportDangerInfoDTO.setATTACHMENTS2(s);
                    }
                }
               // cjReportDangerInfoDTO.setFJ(cjDangerInfo.getRectifyAttachment());
                cjReportDangerInfoDTO.setCREATE_TIME(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, cjDangerInfo.getCreateDate()));
                cjReportDangerInfoDTO.setUPDATE_TIME(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, cjDangerInfo.getUpdateDate()));
                cjReportDangerInfoDTO.setUPDATE_TIME(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date()));
                cjReportDangerInfoDTO.setDELETE_MARK(cjDangerInfo.getDeleted());
                cjReportDangerInfoDTO.setCREATE_BY(cjDangerInfo.getCreateBy());
                cjReportDangerInfoDTO.setUPDATE_BY(cjDangerInfo.getUpdateBy());
@@ -619,6 +636,8 @@
                con.setUseCaches(false);
                con.setRequestProperty("token", TOKEN);
                con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
                con.setConnectTimeout(10000);
                con.setReadTimeout(10000);
                // 发送请求体
                try (OutputStream os = con.getOutputStream()) {
                    os.write(JSON.toJSONString(reportDangerInfoLists).getBytes(StandardCharsets.UTF_8));
@@ -666,4 +685,135 @@
    }
    @Transactional
    public void ZDDangerInfosSP(Integer indexId) {
        HttpURLConnection con = null;
        BufferedReader buffer = null;
        int responseCode = 200;
        /**
         * 6、处理隐患信息数据
         * */
        log.info("【FFFF】隐患信息-处理数据...");
        List<ZDPreventCJReportDangerInfo> CJDangerInfos = CJDangerInfoService.listReportDangerDateZhunDongSP(indexId);
        if (org.apache.commons.lang3.ObjectUtils.isNotEmpty(CJDangerInfos)){
            //封装上报数据
            List<ZDReportDangerInfoDTO> reportDangerInfoLists = new ArrayList<>();
            for (ZDPreventCJReportDangerInfo cjDangerInfo : CJDangerInfos) {
                ZDReportDangerInfoDTO cjReportDangerInfoDTO = new ZDReportDangerInfoDTO();
                cjReportDangerInfoDTO.setDANGER_ID(cjDangerInfo.getId());
                cjReportDangerInfoDTO.setREGIST_TIME(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, cjDangerInfo.getRegistTime()));
                cjReportDangerInfoDTO.setREGISTRANT(cjDangerInfo.getRegistrant());
                cjReportDangerInfoDTO.setDANGER_NAME(cjDangerInfo.getDangerName());
                cjReportDangerInfoDTO.setHAZARD_CODE(cjDangerInfo.getHazardCode());
                cjReportDangerInfoDTO.setRISK_MEASURE_ID(cjDangerInfo.getRiskMeasureId());
                cjReportDangerInfoDTO.setCHECK_RECORD_ID(cjDangerInfo.getCheckRecordId());
                cjReportDangerInfoDTO.setDANGER_LEVEL(cjDangerInfo.getDangerLevel());
                cjReportDangerInfoDTO.setDANGER_SRC(cjDangerInfo.getDangerSrc());
                cjReportDangerInfoDTO.setDANGER_MANAGE_TYPE(cjDangerInfo.getDangerManageType());
                cjReportDangerInfoDTO.setHAZARD_DANGER_TYPE(cjDangerInfo.getHazardDangerType() == null ? "0" : cjDangerInfo.getHazardDangerType());
                cjReportDangerInfoDTO.setHAZARD_CATEGORY(cjDangerInfo.getHazardCategory());
                cjReportDangerInfoDTO.setDANGER_DESC(cjDangerInfo.getDangerDesc());
                //非必传
//                cjReportDangerInfoDTO.setDANGER_REASON(cjDangerInfo.getDangerReason());
//                cjReportDangerInfoDTO.setCONTROL_MEASURES(cjDangerInfo.getControlMeasures());
                //  cjReportDangerInfoDTO.setCOST(cjDangerInfo.getCost());
                cjReportDangerInfoDTO.setLIABLE_PERSON(cjDangerInfo.getLiablePerson());
                cjReportDangerInfoDTO.setDANGER_MANAGE_DEADLINE(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, cjDangerInfo.getDangerManageDeadline()));
                cjReportDangerInfoDTO.setCHECK_ACCEPT_PERSON(cjDangerInfo.getCheckAcceptPerson());
                cjReportDangerInfoDTO.setCHECK_ACCEPT_TIME(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, cjDangerInfo.getCheckAcceptTime()));
                //非必传
                // cjReportDangerInfoDTO.setCHECK_ACCEPT_COMMENT(cjDangerInfo.getCheckAcceptComment());
                cjReportDangerInfoDTO.setDANGER_STATE(cjDangerInfo.getDangerState());
                //非必传
//                cjReportDangerInfoDTO.setMANAGEMENT_CLASSIFICATION(cjDangerInfo.getManagementClassification());
//                cjReportDangerInfoDTO.setOCCURRENCE_LINK(cjDangerInfo.getOccurrenceLink());
                if(StringUtils.isNotEmpty(cjDangerInfo.getPreRectifyPhoto())){
                    String s = ImageToBase64.convertImageToBase64(cjDangerInfo.getPreRectifyPhoto());
                    if (StringUtils.isNotEmpty( s)){
                        cjReportDangerInfoDTO.setATTACHMENTS1(s);
                    }
                }
                if (ObjectUtils.isNotEmpty(cjDangerInfo.getPostRectifyPhoto())) {
                    String s = ImageToBase64.convertImageToBase64(cjDangerInfo.getPostRectifyPhoto());
                    if (StringUtils.isNotEmpty(s)){
                        cjReportDangerInfoDTO.setATTACHMENTS2(s);
                    }
                }
                // cjReportDangerInfoDTO.setFJ(cjDangerInfo.getRectifyAttachment());
                cjReportDangerInfoDTO.setCREATE_TIME(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, cjDangerInfo.getCreateDate()));
                cjReportDangerInfoDTO.setUPDATE_TIME(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSS, new Date()));
                cjReportDangerInfoDTO.setDELETE_MARK(cjDangerInfo.getDeleted());
                cjReportDangerInfoDTO.setCREATE_BY(cjDangerInfo.getCreateBy());
                cjReportDangerInfoDTO.setUPDATE_BY(cjDangerInfo.getUpdateBy());
                reportDangerInfoLists.add(cjReportDangerInfoDTO);
            }
            //数据上报
             log.info("【FFFF】隐患信息-处理数据【原始数据】" + JSONObject.toJSONString(reportDangerInfoLists));
            StringBuffer dangerInfoResultBuffer = null;
            //上报数据
            try {
                URL url = new URL(URL+"/api/wwyt/t_yhzlxx_List");
                //得到连接对象
                con = (HttpURLConnection) url.openConnection();
                // 设置请求方式和参数
                con.setRequestMethod("POST");
                con.setDoOutput(true);
                con.setDoInput(true);
                con.setUseCaches(false);
                con.setRequestProperty("token", TOKEN);
                con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
                con.setConnectTimeout(10000);
                con.setReadTimeout(10000);
                // 发送请求体
                try (OutputStream os = con.getOutputStream()) {
                    os.write(JSON.toJSONString(reportDangerInfoLists).getBytes(StandardCharsets.UTF_8));
                }
                //得到响应码
                responseCode = con.getResponseCode();
                //本段日志,测试成功后,可注释掉
                if (responseCode == HttpURLConnection.HTTP_OK) {
                    //得到响应流
                    InputStream inputStream = con.getInputStream();
                    //将响应流转换成字符串
                    dangerInfoResultBuffer = new StringBuffer();
                    String line;
                    buffer = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                    while ((line = buffer.readLine()) != null) {
                        dangerInfoResultBuffer.append(line);
                    }
                    log.info("【FFFF】隐患信息-处理数据result:" + dangerInfoResultBuffer.toString());
                    JSONObject jsonObject = JSONObject.parseObject(dangerInfoResultBuffer.toString());
                    if (jsonObject.getInteger("status") == 200) {
                        String message = jsonObject.getString("message");
                        if (message.contains("失效0条")) {
                            for (PreventCJReportDangerInfo dangerInfo : CJDangerInfos) {
                                HandlerZDReportParam handlerCJReportParam = new HandlerZDReportParam();
                                handlerCJReportParam.setId(dangerInfo.getId());
                                handlerCJReportParam.setZhunReportStatus(SyncEnum.SYNC_EXEC_SUCCESS.getCode());
                                handlerCJReportParam.setZhunReportTime(new Date());
                                CJDangerInfoService.updateZDReportStatusById(handlerCJReportParam);
                            }
                        }
                    }else {
                        log.info("【FFFF】隐患信息推送数据失败..."+ dangerInfoResultBuffer);
                    }
                    log.info("【FFFF】隐患信息推送数据结束...");
                }
            } catch (Exception e) {
                e.printStackTrace();
                log.info("【FFFF】隐患信息推送数据失败AAAA..."+ e.getMessage());
            }
        }else {
            log.info("【FFFF】检查任务无可推数据");
        }
    }
}
src/main/java/com/ruoyi/doublePrevention/service/baseService/PreventCJReportDangerInfoService.java
@@ -38,6 +38,12 @@
     * 上报数据-待上报数据查询
     */
    List<ZDPreventCJReportDangerInfo> listReportDangerDateZhunDong();
    int updateErrorZDdata();
    /**
     * 上报数据-待上报数据查询
     */
    List<ZDPreventCJReportDangerInfo> listReportDangerDateZhunDongSP(Integer indexId);
    /**
     * 上报数据-待上报状态变更-通过id
     */
src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/PreventCJReportDangerInfoServiceImpl.java
@@ -13,6 +13,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
@Service("PreventCJReportDangerInfoService")
@@ -76,6 +77,16 @@
    }
    @Override
    public int updateErrorZDdata() {
        return preventCJReportDangerInfoRepository.updateErrorZDdata();
    }
    @Override
    public List<ZDPreventCJReportDangerInfo> listReportDangerDateZhunDongSP(Integer indexId) {
        return preventCJReportDangerInfoRepository.listReportDangerDateZhunDongSp(indexId);
    }
    @Override
    public int updateZDReportStatusById(HandlerZDReportParam handlerZDReportParam) {
        int result = preventCJReportDangerInfoRepository.updateZDReportStatusById(handlerZDReportParam);
        if (result < 0){
src/main/resources/mybatis/doublePrevention/PreventCJReportDangerInfoMapper.xml
@@ -62,13 +62,47 @@
<!--            limit 50-->
<!--,c.pre_rectify_photo,c.post_rectify_photo,c.rectify_attachment-->
        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
        left JOIN prevent_risk_danger_info b on  a.id = b.uuid
        left 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
        limit 10
        <!--        and a.create_date &gt;= '2025-06-15 00:00:00' and a.create_date &lt;= '2025-06-18 23:59:59'-->
    </select>
    <select id="listReportDangerDateZhunDongSp" resultMap="BaseMapVO" parameterType="int">
        <!--        select * from prevent_cj_report_danger_info-->
        <!--        where zhun_report_status = 1-->
        <!--            limit 50-->
        <!--,c.pre_rectify_photo,c.post_rectify_photo,c.rectify_attachment-->
        select a.* ,c.pre_rectify_photo,c.post_rectify_photo,c.rectify_attachment from prevent_cj_report_danger_info a
        left JOIN prevent_risk_danger_info b on  a.id = b.uuid
        left 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
        <if test="indexId != null">
            and a.index_id = #{indexId}
        </if>
        <if test="indexId == null">
            limit 10
        </if>
    </select>
    <update id="updateErrorZDdata">
        update prevent_cj_report_danger_info set
        zhun_report_status =  5
        where zhun_report_status = 1 and deleted = 0 and danger_manage_deadline &lt;= regist_time
    </update>
    <!--todo ???-->
<!--    <select id="listZDOtherState" resultMap="">-->
<!--        select b.uuid as id from prevent_risk_danger_info b-->
<!--        INNER JOIN tr_hidden_danger_check_point c on c.id = b.danger_check_point_id-->
<!--        where b.report_switch = 0 and (b.update_report_data_time > b.report_time or b.report_time is null) and (b.hazard_code !='' or b.hazard_code != null) and b.danger_state in (0,1)-->
<!--    </select>-->
    <update id="updateZDReportStatusById">
        update prevent_cj_report_danger_info set
                                                 zhun_report_status =  #{zhunReportStatus},