|
@@ -1,14 +1,21 @@
|
|
|
package com.bz.smart_city.quartz.job;
|
|
|
|
|
|
+import com.bz.smart_city.dao.pay.PayControlRecordMapper;
|
|
|
import com.bz.smart_city.dao.pay.PayFeeMapper;
|
|
|
import com.bz.smart_city.dto.pay.payfee.PayValveStateInfo;
|
|
|
+import com.bz.smart_city.quartz.entity.QuartzEntity;
|
|
|
+import com.bz.smart_city.quartz.service.JobAndTriggerService;
|
|
|
import com.bz.smart_city.service.pay.PayFeeService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.quartz.Job;
|
|
|
+import org.quartz.JobExecutionContext;
|
|
|
+import org.quartz.JobExecutionException;
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.Serializable;
|
|
|
import java.math.BigInteger;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -20,15 +27,39 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
-public class DeviceValveCommondSync implements InitializingBean {
|
|
|
+public class DeviceValveCommondSync implements InitializingBean, Job, Serializable {
|
|
|
+
|
|
|
+ private static final long serialVersionUID = -5732782747738726245L;
|
|
|
|
|
|
@Resource
|
|
|
private PayFeeMapper payFeeMapper;
|
|
|
+ @Resource
|
|
|
+ private JobAndTriggerService jobAndTriggerService;
|
|
|
|
|
|
@Autowired
|
|
|
private PayFeeService payFeeService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PayControlRecordMapper payControlRecordMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public void afterPropertiesSet() {
|
|
|
+
|
|
|
+ QuartzEntity entity = new QuartzEntity();
|
|
|
+ entity.setJobGroup("巡检阀门操作有效期");
|
|
|
+ entity.setJobName("DeviceValveSyncByJob" );
|
|
|
+ entity.setDescription("DeviceValveSyncByJob" );
|
|
|
+ // modify by pengdi ,判断定时任务是否存在,不存在才进行新增
|
|
|
+
|
|
|
+ boolean exists = jobAndTriggerService.isExists(entity);
|
|
|
+ if(!exists) {
|
|
|
+ String cron = "0 */1 * * * ?";
|
|
|
+ log.info("巡检阀门操作有效期:" + cron);
|
|
|
+ entity.setCronExpression(cron);
|
|
|
+ entity.setJobClassName(DeviceValveCommondSync.class.getName());
|
|
|
+ jobAndTriggerService.save(entity);
|
|
|
+ }
|
|
|
+
|
|
|
new Thread(() -> {
|
|
|
while (true) {
|
|
|
try {
|
|
@@ -52,4 +83,11 @@ public class DeviceValveCommondSync implements InitializingBean {
|
|
|
}
|
|
|
}).start();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void execute(JobExecutionContext context) throws JobExecutionException {
|
|
|
+ log.info("巡检阀门操作有效期开始");
|
|
|
+ payControlRecordMapper.updateControlRecordResultTimeOut();
|
|
|
+ log.info("巡检阀门操作有效期结束");
|
|
|
+ }
|
|
|
}
|