|
@@ -3,13 +3,10 @@ package com.huimv.receive.timer;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
-import com.huimv.receive.entity.BillIsolate;
|
|
|
|
-import com.huimv.receive.entity.SysUser;
|
|
|
|
-import com.huimv.receive.entity.BillPcr;
|
|
|
|
-import com.huimv.receive.service.IBillIsolateService;
|
|
|
|
-import com.huimv.receive.service.IBillPcrService;
|
|
|
|
-import com.huimv.receive.service.ISysUserService;
|
|
|
|
-import com.huimv.receive.service.IConfigurationService;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
+import com.huimv.receive.common.token.TokenSign;
|
|
|
|
+import com.huimv.receive.entity.*;
|
|
|
|
+import com.huimv.receive.service.*;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
@@ -19,6 +16,7 @@ import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
|
+import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -36,6 +34,12 @@ public class SafeTimer {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ISysUserService sysUserService;
|
|
private ISysUserService sysUserService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBaseProcessService processService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBaseLocationService locationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBillCleanService cleanService;
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 0/1 * * * ? ")
|
|
@Scheduled(cron = "0 0/1 * * * ? ")
|
|
@@ -44,14 +48,86 @@ public class SafeTimer {
|
|
queryWrapper.eq("bill_status", 1);
|
|
queryWrapper.eq("bill_status", 1);
|
|
List<BillIsolate> isolates = isolateService.list(queryWrapper);
|
|
List<BillIsolate> isolates = isolateService.list(queryWrapper);
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
- for (BillIsolate isolate : isolates) {
|
|
|
|
- if (isolate.getIsolateEndDate().getTime() <= date.getTime()) {
|
|
|
|
- isolate.setIsolateRealEndDate(date);
|
|
|
|
- isolate.setIsolateRealDayNum(isolate.getIsolateDayNum());
|
|
|
|
- isolate.setBillStatus(2);
|
|
|
|
- isolate.setPassUserName("自然解除隔离");
|
|
|
|
- isolate.setPassDate(date);
|
|
|
|
- isolateService.updateById(isolate);
|
|
|
|
|
|
+ for (BillIsolate billIsolate : isolates) {
|
|
|
|
+ if (billIsolate.getIsolateEndDate().getTime() <= date.getTime()) {
|
|
|
|
+ billIsolate.setIsolateRealEndDate(date);
|
|
|
|
+ billIsolate.setIsolateRealDayNum(billIsolate.getIsolateDayNum());
|
|
|
|
+ billIsolate.setBillStatus(2);
|
|
|
|
+ billIsolate.setPassUserName("自然解除隔离");
|
|
|
|
+ billIsolate.setPassDate(date);
|
|
|
|
+ BaseProcess baseProcess = processService.getById(billIsolate.getProcessId());
|
|
|
|
+ QueryWrapper<BaseLocation> locationQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ locationQueryWrapper.eq("id", billIsolate.getIsolateLocationId());
|
|
|
|
+ BaseLocation baseLocation = locationService.getOne(locationQueryWrapper);//当前隔离所在的位置
|
|
|
|
+
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ String end = sdf.format(billIsolate.getIsolateEndDate());
|
|
|
|
+ String start = sdf.format(billIsolate.getIsolateStartDate());
|
|
|
|
+ String now = sdf.format(new Date());
|
|
|
|
+ if (baseProcess.getDestId().equals(billIsolate.getIsolateLocationId()) || baseProcess.getDestId() >= 13) {
|
|
|
|
+ //目的地就是当前隔离地点
|
|
|
|
+ baseProcess.setProcessType(1);
|
|
|
|
+ baseProcess.setCurrentLocation(baseProcess.getCurrentLocation());
|
|
|
|
+ baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId());
|
|
|
|
+ } else {
|
|
|
|
+ baseProcess.setProcessType(0);
|
|
|
|
+ baseProcess.setCurrentLocation(baseProcess.getCurrentLocation() + "," + baseLocation.getNextLocation());
|
|
|
|
+ baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId() + "," + baseLocation.getNextId());
|
|
|
|
+ }
|
|
|
|
+ if (billIsolate.getIsolateLocationId() == 3 && baseProcess.getDestId() >= 4) {
|
|
|
|
+ //通过生成洗消记录
|
|
|
|
+ BillClean billClean = new BillClean();
|
|
|
|
+ billClean.setVistitType(billIsolate.getVistitType());
|
|
|
|
+ billClean.setDestName(billIsolate.getDestName());
|
|
|
|
+ billClean.setDestId(billIsolate.getDestId());
|
|
|
|
+ billClean.setAdmissionUserName(billIsolate.getAdmissionUserName());
|
|
|
|
+ billClean.setAdmissionUserId(billIsolate.getAdmissionUserId());
|
|
|
|
+ billClean.setVistitDate(billIsolate.getVistitDate());
|
|
|
|
+ billClean.setSubDate(LocalDateTime.now());
|
|
|
|
+ billClean.setFarmId(billIsolate.getFarmId());
|
|
|
|
+ billClean.setPassUserName(billIsolate.getPassUserName());
|
|
|
|
+ billClean.setPassDate(billIsolate.getPassDate());
|
|
|
|
+ billClean.setPassUserId(billIsolate.getPassUserId());
|
|
|
|
+ billClean.setProcessId(billIsolate.getProcessId());
|
|
|
|
+ billClean.setTestLocation("场内");
|
|
|
|
+ billClean.setTestLocationId(4);
|
|
|
|
+ billClean.setPhone(billIsolate.getPhone());
|
|
|
|
+ cleanService.save(billClean);
|
|
|
|
+
|
|
|
|
+ String status = baseProcess.getAllLocationStatus();
|
|
|
|
+ String[] split = status.split(",");
|
|
|
|
+ split[0] = "2";
|
|
|
|
+ split[1] = "2";
|
|
|
|
+ split[2] = "2";
|
|
|
|
+ split[3] = "2";
|
|
|
|
+ split[4] = "1";
|
|
|
|
+ baseProcess.setAllLocationStatus(split[0] + "," + split[1] + "," + split[2] + "," + split[3]+"," +split[4]+ status.substring(9));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ billIsolate.setIsolateRealEndDate(new Date());
|
|
|
|
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ Calendar cal1 = Calendar.getInstance();
|
|
|
|
+ Calendar cal2 = Calendar.getInstance();
|
|
|
|
+ Date startDate = sdf1.parse(start);
|
|
|
|
+ Date endDate = sdf1.parse(now);
|
|
|
|
+ cal1.setTime(startDate);
|
|
|
|
+ cal2.setTime(endDate);
|
|
|
|
+ long days = (cal2.getTimeInMillis() - cal1.getTimeInMillis()) / (1000 * 3600 * 24);
|
|
|
|
+ billIsolate.setIsolateRealDayNum(Long.toString(days));
|
|
|
|
+ billIsolate.setBillStatus(2);
|
|
|
|
+
|
|
|
|
+ baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + now);
|
|
|
|
+
|
|
|
|
+ String status = baseProcess.getCurrentStatus();
|
|
|
|
+ String substring = status.substring(0, status.length() - 1);
|
|
|
|
+ baseProcess.setCurrentStatus(substring + "1," + 0);
|
|
|
|
+
|
|
|
|
+ if (billIsolate.getIsolateLocationId() == 5) {
|
|
|
|
+ baseProcess.setAllLocationStatus("2,2,2,2,2,2");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ isolateService.updateById(billIsolate);
|
|
|
|
+ processService.updateById(baseProcess);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|