双重预防项目-国泰新华二开定制版
dev
heheng
2 天以前 f3afb09adeaf7acad0b4fc44afc8062ebbe649dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
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排查任务记录数据上报已关闭");
        }
 
    }
 
 
 
}