|
|
@@ -0,0 +1,107 @@
|
|
|
+package com.xintong.visualinspection.visuallnspection_qzd;
|
|
|
+
|
|
|
+import com.alibaba.dubbo.config.annotation.Reference;
|
|
|
+import com.xintong.visualinspection.bean.Constant;
|
|
|
+import com.xintong.visualinspection.bean.FwqCheckTask;
|
|
|
+import com.xintong.visualinspection.bean.QzdCheckTask;
|
|
|
+import com.xintong.visualinspection.bean.TaskStatus;
|
|
|
+import com.xintong.visualinspection.service.CommonService;
|
|
|
+import com.xintong.visualinspection.service.TaskService_Q;
|
|
|
+import com.xintong.visualinspection.util.CacheUtil;
|
|
|
+import com.xintong.visualinspection.util.Constants;
|
|
|
+import org.junit.Test;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.thymeleaf.util.DateUtils;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+//@RunWith(SpringJUnit4ClassRunner.class)
|
|
|
+//@SpringBootTest(classes = TaskAutoGenApplication.class)
|
|
|
+@Component
|
|
|
+//@Configurable
|
|
|
+//@WebAppConfiguration
|
|
|
+public class ConfirmTask {
|
|
|
+ @Reference(version = "1.0.0",
|
|
|
+ application = "${dubbo.application.id}",
|
|
|
+ registry = "${dubbo.registry.address}")
|
|
|
+ private TaskService_Q taskService;
|
|
|
+
|
|
|
+ @Reference(version = "1.0.0",
|
|
|
+ application = "${dubbo.application.id}",
|
|
|
+ registry = "${dubbo.registry.address}")
|
|
|
+ private CommonService commonService;
|
|
|
+
|
|
|
+
|
|
|
+ private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ConfirmTask.class);
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0 0/1 * * ?")
|
|
|
+ @Test
|
|
|
+ public void confirmTasks() {
|
|
|
+ logger.info("任务确认检测开始---------");
|
|
|
+ checkConfirmTask();
|
|
|
+ checkConfirmAppealTask();
|
|
|
+ logger.info("任务确认检测结束---------");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void checkConfirmTask() {
|
|
|
+ logger.info("开始检查未被确认任务----------");
|
|
|
+ QzdCheckTask task = new QzdCheckTask();
|
|
|
+ task.setCheck_status(Constants.STATUS_CHECK_DISPATCH);
|
|
|
+ Object unConfirmedTaskList = taskService.getAllTask(0, 0, task);
|
|
|
+ int taskConfirmDays = 4;
|
|
|
+ List<QzdCheckTask> list = (ArrayList<QzdCheckTask>) unConfirmedTaskList;
|
|
|
+ Map<String, Constant> codeMap = commonService.getCodeMap();
|
|
|
+ Date now = new Date();
|
|
|
+ int count = 0;
|
|
|
+ for (QzdCheckTask t : list) {
|
|
|
+ List<TaskStatus> taskStatusList = taskService.getTaskStatusList((long) t.getId());
|
|
|
+ if (taskStatusList != null && taskStatusList.size() > 0) {
|
|
|
+ TaskStatus taskStatus = taskStatusList.get(0);
|
|
|
+ long days = (now.getTime() - taskStatus.getUpdate_time().getTime()) / (1000 * 60 * 60 * 24);
|
|
|
+ if (days >= taskConfirmDays) {
|
|
|
+ t.setCheck_status(Constants.STATUS_CHECK_END);
|
|
|
+ taskService.updateStatus(t);
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("结束检查未被确认任务----------,默认确认任务条数:" + count);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void checkConfirmAppealTask() {
|
|
|
+ logger.info("开始检查未被确认申诉任务----------");
|
|
|
+ QzdCheckTask task = new QzdCheckTask();
|
|
|
+ task.setCheck_status(Constants.STATUS_APPEAL_CHECK_DISPATCH);
|
|
|
+ List<QzdCheckTask> unConfirmedTaskList = (ArrayList<QzdCheckTask>)taskService.getAllTask(0,0,task);
|
|
|
+ int taskConfirmDays = 3;
|
|
|
+ Constant constant = CacheUtil.codeMap.get("appeal_task_confirmed_days_1");
|
|
|
+ if(constant!=null)
|
|
|
+ taskConfirmDays = Integer.parseInt(constant.getCode_name());
|
|
|
+
|
|
|
+ Date now = new Date();
|
|
|
+ int count=0;
|
|
|
+ for(QzdCheckTask t:unConfirmedTaskList) {
|
|
|
+ List<TaskStatus> taskStatusList = taskService.getTaskStatusList((long) t.getId());
|
|
|
+ if(taskStatusList!=null && taskStatusList.size()>0) {
|
|
|
+ TaskStatus taskStatus = taskStatusList.get(0);
|
|
|
+ long days = (now.getTime()-taskStatus.getUpdate_time().getTime())/(1000*60*60*24);
|
|
|
+ if(days>=taskConfirmDays){
|
|
|
+ t.setCheck_status(Constants.STATUS_APPEAL_CHECK_CONFIRMED);
|
|
|
+ taskService.updateStatus(t);
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("结束检查未被确认申诉任务----------,默认确认任务条数:"+count);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
+ cal.set(Calendar.MINUTE, 120);
|
|
|
+ System.out.println(DateUtils.format(cal, Locale.CHINA));
|
|
|
+ }
|
|
|
+}
|