对比新文件 |
| | |
| | | package com.ruoyi.doublePrevention.scheduls; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.ruoyi.common.utils.BeanCopyUtils; |
| | | import com.ruoyi.doublePrevention.config.redis.RedisUtils; |
| | | import com.ruoyi.doublePrevention.entity.*; |
| | | import com.ruoyi.doublePrevention.entity.CJReport.CJdto.CJReportResultData; |
| | | import com.ruoyi.doublePrevention.entity.CJReport.CJdto.Data; |
| | | import com.ruoyi.doublePrevention.entity.CJReport.CJdto.ErrorMsgDetails; |
| | | import com.ruoyi.doublePrevention.entity.CJReport.CJdto.HandlerDO.CJReportCheckRecordFromTaskDTO; |
| | | import com.ruoyi.doublePrevention.entity.CJReport.PreventCJReportCheckRecordFromTask; |
| | | import com.ruoyi.doublePrevention.entity.CJReport.PreventCJReportCheckTaskFromWork; |
| | | import com.ruoyi.doublePrevention.enums.CJReportEnum; |
| | | import com.ruoyi.doublePrevention.enums.E; |
| | | import com.ruoyi.doublePrevention.enums.SyncEnum; |
| | | import com.ruoyi.doublePrevention.exception.AusinessException; |
| | | import com.ruoyi.doublePrevention.repository.param.HandlerCJReportParam; |
| | | import com.ruoyi.doublePrevention.service.baseService.*; |
| | | import com.ruoyi.project.system.user.domain.User; |
| | | import com.ruoyi.project.system.user.service.IUserService; |
| | | import com.ruoyi.project.tr.hiddenDangerCheck.domain.HiddenDangerCheck; |
| | | import com.ruoyi.project.tr.hiddenDangerCheck.service.IHiddenDangerCheckService; |
| | | import com.ruoyi.project.tr.hiddenDangerCheckPoint.domain.HiddenDangerCheckPoint; |
| | | import com.ruoyi.project.tr.hiddenDangerCheckPoint.service.IHiddenDangerCheckPointService; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.bouncycastle.crypto.engines.AESFastEngine; |
| | | import org.bouncycastle.crypto.modes.GCMBlockCipher; |
| | | import org.bouncycastle.crypto.params.AEADParameters; |
| | | import org.bouncycastle.crypto.params.KeyParameter; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.*; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | @Component |
| | | public class FormTaskSchedule { |
| | | |
| | | |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | @Autowired |
| | | private PreventReportConfigService preventReportConfigService; |
| | | |
| | | @Autowired |
| | | private PreventCJReportCheckRecordFromTaskService CJTaskRecordService; |
| | | |
| | | @Autowired |
| | | private PreventRiskDangerCheckLogService preventRiskDangerCheckLogService;//排查任务记录附属表 |
| | | |
| | | @Autowired |
| | | private PreventRiskControlMeasureService preventRiskControlMeasureService; |
| | | |
| | | @Autowired |
| | | private IUserService trUserService; //用户服务 |
| | | |
| | | @Autowired |
| | | private PreventTaskTypeService taskTypeService; |
| | | |
| | | @Autowired |
| | | private IHiddenDangerCheckService trHiddenDangerCheckService;//排查任务记录 |
| | | |
| | | @Autowired |
| | | private IHiddenDangerCheckPointService trHiddenDangerCheckPointService;//隐患信息上报、整改、验收 |
| | | |
| | | @Autowired |
| | | private PreventRiskDangerCheckAndMeasureService riskDangerCheckAndMeasureService;//管控措施,任务清单对应关系。基础排查点附属表 |
| | | |
| | | @Autowired |
| | | private PreventCJReportCheckTaskFromWorkService CJTaskFromWorkService; |
| | | |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | |
| | | private static String TASK_SPE_REDIS_KEY = "TASK_SPE_REDIS_KEY"; |
| | | |
| | | public static String companyCode = "652310082"; |
| | | |
| | | |
| | | String token = "GT6gGJV7JV"; |
| | | String key = "Bv+NeBolwqg2Pbc1yVwrZA=="; |
| | | String iv = "4QC9V8eAiB7tdlgBkMsTAw=="; |
| | | |
| | | public static final int MAC_BIT_SIZE = 128; |
| | | |
| | | public static String encrypt(String plainText, byte[] key, byte[] iv) { |
| | | String sr; |
| | | try { |
| | | byte[] plainBytes = plainText.getBytes(StandardCharsets.UTF_8); |
| | | GCMBlockCipher cipher = new GCMBlockCipher(new |
| | | AESFastEngine()); |
| | | AEADParameters parameters = |
| | | new AEADParameters(new KeyParameter(key), |
| | | MAC_BIT_SIZE, iv, null); |
| | | cipher.init(true, parameters); |
| | | byte[] encryptedBytes = new |
| | | byte[cipher.getOutputSize(plainBytes.length)]; |
| | | int retLen = cipher.processBytes(plainBytes, 0, plainBytes.length, |
| | | encryptedBytes, 0); |
| | | cipher.doFinal(encryptedBytes, retLen); |
| | | sr = Base64.getEncoder().encodeToString(encryptedBytes); |
| | | } catch (Exception ex) { |
| | | throw new RuntimeException(ex.getMessage()); |
| | | } |
| | | return sr; |
| | | } |
| | | |
| | | //@Scheduled(cron = "0 0/30 * * * ? ") |
| | | @Scheduled(cron = "0 0/1 * * * ? ") |
| | | @Transactional |
| | | public void taskFormRedis() { |
| | | redisUtils.set(TASK_SPE_REDIS_KEY, preventReportConfigService.getSpecPushData() == null ? 1 : preventReportConfigService.getSpecPushData()); |
| | | } |
| | | |
| | | |
| | | |
| | | @Scheduled(cron = "45 3/3 * * * ? ") |
| | | @Transactional |
| | | public void taskFormSchedule() { |
| | | Object o = redisUtils.get(TASK_SPE_REDIS_KEY); |
| | | if (ObjectUtils.isEmpty(o)){ |
| | | redisUtils.set(TASK_SPE_REDIS_KEY, preventReportConfigService.getSpecPushData() == null ? 1 : preventReportConfigService.getSpecPushData()); |
| | | }else { |
| | | Integer i = Integer.valueOf(o.toString()); |
| | | if (i == 1){ |
| | | logger.info("【特殊】上报数据开始TASKFORM未开启..."); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | logger.info("【####】上报数据开始TASKFORM..."); |
| | | |
| | | HttpURLConnection con = null; |
| | | BufferedReader buffer = null; |
| | | int responseCode = 200; |
| | | |
| | | SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd HH:MM:ss"); |
| | | |
| | | Date date = new Date(); |
| | | //格式化时间,作为token的时间戳 |
| | | SimpleDateFormat tokenDate= new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String formatDate = tokenDate.format(date); |
| | | |
| | | logger.info("【token时间】" + formatDate); |
| | | |
| | | //使用风险分析单元数据上报主配置,作为自动上报开关 |
| | | PreventReportConfig reportConfig = preventReportConfigService.getReportConfigById(SyncEnum.REPORT_CONFIG_RISK_ANA_UNIT.getCode()); |
| | | if (reportConfig.getReportType() == 0){ |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * 5、处理 任务-记录 数据 |
| | | * */ |
| | | logger.info("【5】TASKFORM任务记录-处理数据..."); |
| | | List<PreventCJReportCheckRecordFromTask> CJRecordFromTasks = CJTaskRecordService.listReportTaskRecordDate(); |
| | | if (ObjectUtils.isNotEmpty(CJRecordFromTasks)){ |
| | | //封装上报数据 |
| | | List<CJReportCheckRecordFromTaskDTO> reportRecordFromTaskList = new ArrayList<>(); |
| | | for (PreventCJReportCheckRecordFromTask cjRecordFromTask : CJRecordFromTasks) { |
| | | CJReportCheckRecordFromTaskDTO cjReportCheckRecordFromTaskDTO = BeanCopyUtils.copyBean(cjRecordFromTask, CJReportCheckRecordFromTaskDTO.class); |
| | | // cjReportCheckRecordFromTaskDTO.setCreateDate(dateFormat.format(cjRecordFromTask.getCreateDate())); |
| | | // cjReportCheckRecordFromTaskDTO.setUpdateDate(dateFormat.format(cjRecordFromTask.getUpdateDate())); |
| | | cjReportCheckRecordFromTaskDTO.setCheckTime(dateFormat.format(cjRecordFromTask.getCheckTime())); |
| | | cjReportCheckRecordFromTaskDTO.setMobileMe(cjRecordFromTask.getMobileCode()); |
| | | cjReportCheckRecordFromTaskDTO.setIsDefend(cjRecordFromTask.getDefend()); |
| | | reportRecordFromTaskList.add(cjReportCheckRecordFromTaskDTO); |
| | | } |
| | | // System.out.println(Arrays.toString(reportRecordFromTaskList.toArray())); |
| | | //数据加密 |
| | | String AESReportRecordFromTask = encrypt(JSONObject.toJSONString(reportRecordFromTaskList), key.getBytes(), iv.getBytes()); |
| | | logger.info("TASKFORM数据加密完成,开始上报数据"); |
| | | |
| | | StringBuffer recordFromTaskResultBuffer = null; |
| | | //上报数据 |
| | | try { |
| | | URL url = new URL("http://120.71.182.198:9999/v1/data/receive/measuresTaskRecordMsg"); |
| | | //URL url = new URL("https://cjzjg.gtaq.com.cn:7004/v1/data/receive/measuresTaskRecordMsg"); //备用地址 |
| | | //得到连接对象 |
| | | con = (HttpURLConnection) url.openConnection(); |
| | | //设置请求类型 |
| | | con.setRequestMethod("POST"); |
| | | //设置Content-Type,此处根据实际情况确定 |
| | | con.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); |
| | | // con.setRequestProperty(HTTP.CONN_DIRECTIVE,HTTP.CONN_CLOSE); |
| | | con.setConnectTimeout(600000); |
| | | con.setReadTimeout(600000); |
| | | |
| | | //允许写出 |
| | | con.setDoOutput(true); |
| | | //允许读入 |
| | | con.setDoInput(true); |
| | | //不使用缓存 |
| | | con.setUseCaches(false); |
| | | //设置请求头 |
| | | con.setRequestProperty("X-Access-Token",token+tokenDate.format(new Date()).toString()); |
| | | OutputStream os = con.getOutputStream(); |
| | | Map paraMap = new HashMap(); |
| | | paraMap.put("data", AESReportRecordFromTask);/**封装数据*/ |
| | | //组装入参,设置请求体 |
| | | os.write(JSON.toJSONString(paraMap).getBytes()); |
| | | //得到响应码 |
| | | responseCode = con.getResponseCode(); |
| | | //本段日志,测试成功后,可注释掉 |
| | | if (responseCode == HttpURLConnection.HTTP_OK) { |
| | | //得到响应流 |
| | | InputStream inputStream = con.getInputStream(); |
| | | //将响应流转换成字符串 |
| | | recordFromTaskResultBuffer = new StringBuffer(); |
| | | String line; |
| | | buffer = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); |
| | | while ((line = buffer.readLine()) != null) { |
| | | recordFromTaskResultBuffer.append(line); |
| | | } |
| | | logger.info("TASKFORMresult:" + recordFromTaskResultBuffer.toString()); |
| | | }else { |
| | | logger.info("TASKFORMHttp结果:" + responseCode); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | logger.info("【TASKFORM】接收返回值"); |
| | | CJReportResultData CJRecordFromTaskResult = new CJReportResultData(); |
| | | try { |
| | | CJRecordFromTaskResult = JSONObject.parseObject(recordFromTaskResultBuffer.toString(), CJReportResultData.class); |
| | | if (ObjectUtils.isEmpty(CJRecordFromTaskResult)){ |
| | | throw new RuntimeException("返回值为空"); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | logger.info("【TASKFORM】接收返回值异常"); |
| | | } |
| | | |
| | | //接收返回值,保存返回值 |
| | | // CJReportResultData CJRecordFromTaskResult = JSONObject.parseObject(recordFromTaskResultBuffer.toString(), CJReportResultData.class); |
| | | //接收返回值,保存返回值 |
| | | logger.info("【TASKFORM】保存上报结果"); |
| | | List<String> errorIdList= new ArrayList<>(); |
| | | Data data = JSONObject.parseObject(CJRecordFromTaskResult.getData(), Data.class); |
| | | //保存失败结果 |
| | | if (ObjectUtils.isNotEmpty(data)){ |
| | | for (ErrorMsgDetails errorMsgDetail : data.getErrorMsgDetails()) { |
| | | errorIdList.add(errorMsgDetail.getId()); |
| | | } |
| | | } |
| | | logger.info("【TASKFORM】CJRecordFromTask数据上报结果:" + CJRecordFromTaskResult.getCode()); |
| | | //设置所有数据上报成功 |
| | | if (CJRecordFromTaskResult.getCode().equals(CJReportEnum.SUCCESS.getCode()) || CJRecordFromTaskResult.getCode().equals(CJReportEnum.SUCESS_AND_FAIL.getCode())){ |
| | | for (PreventCJReportCheckRecordFromTask CJRecordFromTask : CJRecordFromTasks) { |
| | | HandlerCJReportParam handlerCJReportParam = new HandlerCJReportParam(); |
| | | //封装数据 |
| | | handlerCJReportParam.setId(CJRecordFromTask.getId()); |
| | | handlerCJReportParam.setReportStatus(SyncEnum.SYNC_EXEC_SUCCESS.getCode()); |
| | | handlerCJReportParam.setReportTime(date); |
| | | CJTaskRecordService.updateCJReportStatusById(handlerCJReportParam); |
| | | } |
| | | } |
| | | //设置上报失败的数据,上报失败 |
| | | if (CJRecordFromTaskResult.getCode().equals(CJReportEnum.FAIL.getCode()) || CJRecordFromTaskResult.getCode().equals(CJReportEnum.SUCESS_AND_FAIL.getCode())){ |
| | | for (String failId : errorIdList) { |
| | | //上报失败 |
| | | HandlerCJReportParam handlerCJReportParam = new HandlerCJReportParam(); |
| | | //封装数据 |
| | | handlerCJReportParam.setId(failId); |
| | | handlerCJReportParam.setReportStatus(SyncEnum.SYNC_EXEC_FAIL.getCode()); |
| | | handlerCJReportParam.setReportTime(date); |
| | | CJTaskRecordService.updateCJReportStatusById(handlerCJReportParam); |
| | | } |
| | | } |
| | | logger.info("【TASKFORM】任务记录-数据处理完成"); |
| | | }else { |
| | | logger.info("【TASKFORM】任务记录-无数据上报昌吉州"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | @Scheduled(cron = "10 1/2 * * * ? ") |
| | | @Transactional |
| | | public void CJReportDateSchedule(){ |
| | | |
| | | Object o = redisUtils.get(TASK_SPE_REDIS_KEY); |
| | | if (ObjectUtils.isEmpty(o)){ |
| | | redisUtils.set(TASK_SPE_REDIS_KEY, preventReportConfigService.getSpecPushData() == null ? 1 : preventReportConfigService.getSpecPushData()); |
| | | }else { |
| | | Integer i = Integer.valueOf(o.toString()); |
| | | if (i == 1){ |
| | | logger.info("【特殊】数据生成TASKFORM未开启..."); |
| | | return; |
| | | } |
| | | } |
| | | /** |
| | | * 5、排查任务记录数据 PreventReportCheckRecordFromTask |
| | | * */ |
| | | //读取安全风险管控措施数据上报主配置信息 |
| | | PreventReportConfig recordReportConfig = preventReportConfigService.getReportConfigById(SyncEnum.REPORT_CONFIG__CHECK_RECORD.getCode()); |
| | | //如果安全风险管控措施主配置开启上报 |
| | | if (recordReportConfig.getReportState().equals(SyncEnum.REPORT_ON.getCode())) { |
| | | |
| | | //logger.info("【##】5.检索排查任务记录数据..."); |
| | | logger.info("【Cratetaskform】5.检索排查任务记录数据..."); |
| | | |
| | | //查询所有 选择上报的数据 && (reportTime == null 或者 reportTime < updateReportDataTime) |
| | | List<PreventRiskDangerCheckLog> tasks = preventRiskDangerCheckLogService.listReportTask(); |
| | | List<Long> taskIds = new ArrayList<>(); |
| | | //获取上报数据对象 |
| | | List<PreventCJReportCheckRecordFromTask> CJRecordFromTaskLists = new ArrayList<>(); |
| | | int tag = 0; |
| | | // HandlerReportParam handlerReportParam = new HandlerReportParam(); |
| | | // List<HandlerReportParam> handlerReportParamList = new ArrayList<>(); |
| | | if (ObjectUtils.isNotEmpty(tasks)) { |
| | | //获取信息 |
| | | List<User> allUserList = trUserService.getAllUser(); |
| | | List<PreventRiskControlMeasure> allMeasureList = preventRiskControlMeasureService.getAllMeasureList(); |
| | | List<PreventTaskType> allTaskTypeList = taskTypeService.getAllTaskTypeList(); |
| | | //遍历,封装数据 |
| | | for (PreventRiskDangerCheckLog task : tasks) { |
| | | //获取任务记录主表信息 |
| | | HiddenDangerCheck hiddenDangerCheckById = trHiddenDangerCheckService.getHiddenDangerCheckById(task.getCheckId()); |
| | | //转换检查结果 |
| | | //如果已经执行过,进入方法 |
| | | if (Integer.valueOf(hiddenDangerCheckById.getScheduleCheckStatus()) == 1) { |
| | | |
| | | List<HiddenDangerCheckPoint> hiddenDangerCheckPointList = trHiddenDangerCheckPointService.getHiddenDangerCheckPointByCheckId(task.getCheckId()); |
| | | |
| | | //避免个别任务无检查点的情况 |
| | | if (ObjectUtils.isEmpty(hiddenDangerCheckPointList)) { |
| | | logger.info("【Cratetaskform】排查任务记录CJ:异常,无检查点..."); |
| | | } else { |
| | | for (HiddenDangerCheckPoint hiddenDangerCheckPoint : hiddenDangerCheckPointList) { |
| | | //获取上报数据对象 |
| | | PreventCJReportCheckRecordFromTask CJRecordFromTask = new PreventCJReportCheckRecordFromTask(); |
| | | CJRecordFromTask.setCheckStatus("0");// 0-正常;1-存在隐患;2-未处理;3-其他 |
| | | if (Integer.valueOf(hiddenDangerCheckPoint.getWhetherDanger()) == 1) { |
| | | CJRecordFromTask.setCheckStatus("1");// 0-正常;1-存在隐患;2-未处理;3-其他 |
| | | } |
| | | |
| | | User createUser = new User(); |
| | | User updateUser = new User(); |
| | | // createUser = trUserService.getUserByLoginName(hiddenDangerCheckById.getCreateBy()); |
| | | // if(ObjectUtils.isEmpty(createUser)){ |
| | | // createUser = trUserService.getUserByName(hiddenDangerCheckById.getCreateBy()); |
| | | // } |
| | | // updateUser = trUserService.getUserByLoginName(hiddenDangerCheckById.getUpdateBy()); |
| | | |
| | | |
| | | // todo 取出所有用户信息,再循环在匹配 |
| | | for (User user : allUserList) { |
| | | if (hiddenDangerCheckById.getCreateBy().equals(user.getLoginName())) { |
| | | createUser = user; |
| | | } |
| | | if (hiddenDangerCheckById.getUpdateBy().equals(user.getLoginName())) { |
| | | updateUser = user; |
| | | } |
| | | } |
| | | if (ObjectUtils.isEmpty(createUser)) { |
| | | for (User user : allUserList) { |
| | | if (hiddenDangerCheckById.getCreateBy().equals(user.getUserName())) { |
| | | createUser = user; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //封装上报昌吉州的任务数据 |
| | | // String taskUuid = UUID.randomUUID().toString(); |
| | | CJRecordFromTask.setId(UUID.randomUUID().toString()); |
| | | CJRecordFromTask.setCompanyCode(companyCode); |
| | | CJRecordFromTask.setCreateBy(createUser.getUserName()); |
| | | CJRecordFromTask.setCreateDate(hiddenDangerCheckById.getCreateTime()); |
| | | CJRecordFromTask.setCreateByMobile(createUser.getPhonenumber()); |
| | | if (ObjectUtils.isEmpty(updateUser)) { |
| | | CJRecordFromTask.setUpdateBy(createUser.getUserName()); |
| | | CJRecordFromTask.setUpdateDate(hiddenDangerCheckById.getCreateTime()); |
| | | CJRecordFromTask.setUpdateByMobile(createUser.getPhonenumber()); |
| | | } else { |
| | | CJRecordFromTask.setUpdateBy(updateUser.getUserName()); |
| | | CJRecordFromTask.setUpdateDate(hiddenDangerCheckById.getUpdateTime()); |
| | | CJRecordFromTask.setUpdateByMobile(updateUser.getPhonenumber()); |
| | | } |
| | | |
| | | if (task.getReportStatus().equals(SyncEnum.SYNC_EXEC_SUCCESS.getCode())) { |
| | | CJRecordFromTask.setDeleted("2");//数据更新状态标识,目前仅昌吉州需要 2022-08-10 |
| | | } else { |
| | | CJRecordFromTask.setDeleted("0"); |
| | | } |
| | | CJRecordFromTask.setReportStatus(SyncEnum.SYNC_WAIT_EXEC.getCode()); |
| | | CJRecordFromTask.setReportTime(null); |
| | | CJRecordFromTask.setZhunReportStatus(SyncEnum.SYNC_WAIT_EXEC.getCode()); |
| | | CJRecordFromTask.setZhunReportTime(null); |
| | | CJRecordFromTask.setDataSource((byte) 1); |
| | | List<PreventRiskDangerCheckAndMeasure> baseCheckPointAndMeasure = riskDangerCheckAndMeasureService.getByBaseCheckPointId(hiddenDangerCheckPoint.getCheckPointId()); |
| | | //获取该条记录对应的管控措施id, |
| | | Long controlMeasureId = 1L; |
| | | for (PreventRiskDangerCheckAndMeasure checkAndMeasure : baseCheckPointAndMeasure) { |
| | | controlMeasureId = checkAndMeasure.getControlMeasureId(); |
| | | } |
| | | // //获取该条记录对应的管控措施uuid |
| | | // PreventRiskControlMeasure preventRiskControlMeasureById = preventRiskControlMeasureService.getPreventRiskControlMeasureById(controlMeasureId); |
| | | // //通过管控措施uuid ,jobId(workId),在任务上报表中,找到任务对应的uuid |
| | | // PreventCJReportCheckTaskFromWork preventCJReportCheckTaskFromWork = CJTaskFromWorkService.geByMeasureUUidAndJobId(preventRiskControlMeasureById.getUuid(), task.getJobId()); |
| | | // CJRecordFromTask.setCheckTaskId(preventCJReportCheckTaskFromWork.getId()); |
| | | // todo 取出所有措施,再循环在匹配 |
| | | boolean checkTaskIdExist = true; |
| | | for (PreventRiskControlMeasure measure : allMeasureList) { |
| | | if (controlMeasureId.equals(measure.getId())) { |
| | | //通过管控措施uuid ,jobId(workId),在任务上报表中,找到任务对应的uuid |
| | | |
| | | PreventCJReportCheckTaskFromWork preventCJReportCheckTaskFromWork = CJTaskFromWorkService.geByMeasureUUidAndJobId(measure.getUuid(), task.getJobId()); |
| | | try { |
| | | // if(preventCJReportCheckTaskFromWork!=null) { |
| | | CJRecordFromTask.setCheckTaskId(preventCJReportCheckTaskFromWork.getId()); |
| | | //} |
| | | } catch (Exception e) { |
| | | checkTaskIdExist = false; |
| | | logger.info("chekcPointId={},PreventRiskDangerCheckLogId={},controlMeasureId={},measure uuid={},jobId={}", hiddenDangerCheckPoint.getId(), task.getId(), controlMeasureId, measure.getUuid(), task.getJobId()); |
| | | logger.error(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!checkTaskIdExist) { |
| | | continue; |
| | | } |
| | | CJRecordFromTask.setCheckTime(hiddenDangerCheckById.getCheckTime()); |
| | | CJRecordFromTask.setTaskId(task.getCheckId()); |
| | | //第二版标准新增 |
| | | CJRecordFromTask.setMobileCode(task.getMobileCode().toString()); |
| | | |
| | | int typeTag = 0; |
| | | // List<PreventTaskType> typeByJobIds = taskTypeService.getInfoByJobId(task.getJobId()); |
| | | // for (PreventTaskType typeByJobId : typeByJobIds) { |
| | | // if (typeByJobId.getType()!= 0) { |
| | | // typeTag = 1; |
| | | // } |
| | | // } |
| | | |
| | | // todo 取出所有任务信息表,再循环在匹配 |
| | | for (PreventTaskType taskType : allTaskTypeList) { |
| | | if (taskType.getJobId().equals(task.getJobId())) { |
| | | if (taskType.getType() != 0) { |
| | | typeTag = 1; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | CJRecordFromTask.setDefend(String.valueOf(typeTag)); |
| | | //封装数据 |
| | | CJRecordFromTaskLists.add(CJRecordFromTask); |
| | | } |
| | | } |
| | | |
| | | //设置原始数据上报状态 |
| | | // handlerReportParam.setId(task.getId()); |
| | | // handlerReportParam.setReportTime(new Date()); |
| | | // handlerReportParam.setReportStatus(SyncEnum.SYNC_WAIT_EXEC.getCode()); |
| | | // handlerReportParamList.add(handlerReportParam); |
| | | // preventRiskDangerCheckLogService.updateTaskReportStatus(handlerReportParam); |
| | | int i = 1; |
| | | taskIds.add(task.getId()); |
| | | tag++; |
| | | } |
| | | logger.info("【Cratetaskform】5.数据封装完成..."); |
| | | |
| | | } |
| | | } else { |
| | | logger.info("【Cratetaskform双重预防】当前无排查任务记录需要处理"); |
| | | } |
| | | |
| | | if (CJRecordFromTaskLists.size() > 0) { |
| | | logger.info("【Cratetaskform双重预防】排查任务记录CJ:数据处理..."); |
| | | |
| | | |
| | | //设置原始数据状态 |
| | | int taskUpdateResult = preventRiskDangerCheckLogService.updateTaskReportStatusByList(taskIds); |
| | | if (taskUpdateResult < taskIds.size()) { |
| | | logger.error("【Cratetaskform】排查任务记录CJ:数据处理开始taskIds...排查任务记录原始数据更新失败, 取消操作"); |
| | | throw new AusinessException(E.ADD_FAIL.getCode(), "排查任务记录原始数据更新失败, 取消操作"); |
| | | } |
| | | int result = CJTaskRecordService.insertRecordList(CJRecordFromTaskLists); |
| | | if (result < CJRecordFromTaskLists.size()) { |
| | | logger.error("【Cratetaskform】排查任务记录CJ:数据处理开始taskIds...排查任务记录插入失败, 取消操作"); |
| | | throw new AusinessException(E.ADD_FAIL.getCode(), "排查任务记录插入失败, 取消操作"); |
| | | } |
| | | |
| | | |
| | | } |
| | | } else { |
| | | logger.info("Cratetaskform排查任务记录数据上报已关闭"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |