44 lines
1.5 KiB
Java
44 lines
1.5 KiB
Java
package com.rzyc.service;
|
|
|
|
import com.rzyc.mapper.EntDeviceInsCycleMapper;
|
|
import com.rzyc.mapper.EntDeviceMapper;
|
|
import com.rzyc.model.EntDeviceInsCycle;
|
|
|
|
import java.text.DateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Calendar;
|
|
import java.util.List;
|
|
/**
|
|
* @author Xuwanxin
|
|
* @date 2022/11/16
|
|
* */
|
|
public class DeviceInspectionCycle implements Runnable{
|
|
|
|
private EntDeviceInsCycleMapper entDeviceInsCycleMapper;
|
|
|
|
private EntDeviceMapper entDeviceMapper;
|
|
|
|
public DeviceInspectionCycle(EntDeviceInsCycleMapper entDeviceInsCycleMapper, EntDeviceMapper entDeviceMapper) {
|
|
this.entDeviceInsCycleMapper = entDeviceInsCycleMapper;
|
|
this.entDeviceMapper = entDeviceMapper;
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
|
|
Calendar calendar=Calendar.getInstance();
|
|
calendar.set(Calendar.HOUR_OF_DAY,-24);
|
|
String yesterdayDate=dateFormat.format(calendar.getTime());
|
|
List<EntDeviceInsCycle> list = entDeviceInsCycleMapper.checkDeviceInspectionRecord(yesterdayDate);
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
for (EntDeviceInsCycle e:list) {
|
|
String date1 = simpleDateFormat.format(e.getNextTimeInspection());
|
|
String date2 = simpleDateFormat.format(e.getInsRecordDate());
|
|
if (!date1.equals(date2)){
|
|
//2为超期
|
|
entDeviceMapper.updateOverdueInspection(e.getDeviceId(),2);
|
|
}
|
|
}
|
|
}
|
|
}
|