소스 검색

无修改2

wwh 1 년 전
부모
커밋
f81c46bcbc
1개의 변경된 파일369개의 추가작업 그리고 0개의 파일을 삭제
  1. 369 0
      huimv-receive/src/main/java/com/huimv/receive/timer/SafeTimer.java

+ 369 - 0
huimv-receive/src/main/java/com/huimv/receive/timer/SafeTimer.java

@@ -0,0 +1,369 @@
+package com.huimv.receive.timer;
+
+
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.huimv.receive.common.utils.FlowUtil;
+import com.huimv.receive.entity.*;
+import com.huimv.receive.service.*;
+import com.huimv.receive.service.impl.BillPcrServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+
+@Configuration
+@EnableScheduling
+public  class SafeTimer {
+
+
+    @Autowired
+    private IBillPcrService pcrService;
+    @Autowired
+    private IBillIsolateService isolateService;
+    @Autowired
+    private IConfigurationService configurationService;
+
+    @Autowired
+    private ISysUserService sysUserService;
+    @Autowired
+    private IBaseProcessService processService;
+    @Autowired
+    private IBaseLocationService locationService;
+    @Autowired
+    private IBillCleanService cleanService;
+    @Autowired
+    private IBillDryService dryService;
+    @Autowired
+    private IBillCleanBeforeService beforeService;
+    @Autowired
+    private IBillSamplingService samplingService;
+    @Autowired
+    private IBillGoodsInventoryService inventoryService;
+
+
+    @Scheduled(cron = "0 0/1 * * * ? ")
+    private void getShenChan() throws Exception {
+        QueryWrapper<BillIsolate> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("bill_status", 1);
+        List<BillIsolate> isolates = isolateService.list(queryWrapper);
+        Date date = new Date();
+        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());
+
+                String allLocationId = baseProcess.getAllLocationId();//所有的位置id
+                String allFlowId = baseProcess.getAllFlowId();//所有的流程id
+                String currentFlowId = baseProcess.getCurrentFlowId();//当前已经完成的流程id
+                String substring1 = allFlowId.substring(currentFlowId.length() + 1, allFlowId.length());
+                String[] splits = substring1.split(",");
+                Integer nextId = Integer.parseInt(splits[0]);
+                Object newObject = BillPcrServiceImpl.getNewObject(nextId, billIsolate.getDestName(), billIsolate.getDestId(), billIsolate.getAdmissionUserName(),
+                        billIsolate.getAdmissionUserId(), billIsolate.getVistitDate(), billIsolate.getSubDate(),
+                        billIsolate.getProcessId(), billIsolate.getFarmId(), billIsolate.getIsolateLocation(), billIsolate.getIsolateLocationId(),
+                        billIsolate.getVistitType(), billIsolate.getPhone(), billIsolate.getDepartureName(), billIsolate.getDepartureId());
+                if (nextId == 0) {
+                    if (StringUtils.isBlank(splits[1])) {
+                        baseProcess.setProcessType(1);
+                        String[] strings = allLocationId.split(",");
+                        String ss2 = "";
+                        for (int i = 0; i < strings.length; i++) {
+                            strings[i].replaceAll(strings[i], "2");
+                            if (i == strings.length - 1) {
+                                ss2 = ss2 + strings[i].replaceAll(strings[i], "2");
+                            } else {
+                                ss2 = strings[i].replaceAll(strings[i], "2") + "," + ss2;
+                            }
+                        }
+                        baseProcess.setAllLocationStatus(ss2);
+                    } else {
+                        String[] strings = allLocationId.split(",");
+                        Integer index = 0;
+                        for (int i = 0; i < strings.length; i++) {
+                            if ((baseLocation.getId().toString()).equals(strings[i])) {
+                                index = i;
+                            }
+                        }
+                        QueryWrapper<BaseLocation> queryWrapper1 = new QueryWrapper();
+                        queryWrapper1.eq("id", strings[index + 2]);
+                        BaseLocation location = locationService.getOne(queryWrapper1);
+                        FlowUtil flowUtil = new FlowUtil();
+                        Object entity = flowUtil.getEntity(Integer.parseInt(splits[1]), billIsolate.getVistitType(), billIsolate.getDestName()
+                                , billIsolate.getDestId(), billIsolate.getAdmissionUserId(), billIsolate.getAdmissionUserName(), billIsolate.getPhone(),
+                                billIsolate.getVistitDate(), location.getId(), location.getLocationName(), billIsolate.getFarmId()
+                                , baseProcess.getId(), billIsolate.getDepartureName(), billIsolate.getDepartureId());
+                        if (Integer.parseInt(splits[1]) == 1) {
+                            //新增采样
+                            BillSampling billSampling = (BillSampling) entity;
+                            if (billIsolate.getVistitType() != 0) {
+                                billSampling.setCarNum(billIsolate.getCarNum());
+                            }
+                            if (billIsolate.getVistitType() == 5) {
+                                billSampling.setResource(billIsolate.getResource());
+                                billSampling.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                                billSampling.setRemark(billIsolate.getRemark());
+                            }
+                            samplingService.save(billSampling);
+                        } else if (Integer.parseInt(splits[1]) == 2) {
+                            //新增pcr
+                            BillPcr billClean = (BillPcr) entity;
+                            if (billIsolate.getVistitType() != 0) {
+                                billClean.setCarNum(billIsolate.getCarNum());
+                            }
+                            if (billIsolate.getVistitType() == 5) {
+                                billClean.setResource(billIsolate.getResource());
+                                billClean.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                                billClean.setRemark(billIsolate.getRemark());
+                            }
+                            pcrService.save(billClean);
+                        } else if (Integer.parseInt(splits[1]) == 3) {
+                            //新增洗澡
+                            BillClean billClean = (BillClean) entity;
+                            if (billIsolate.getVistitType() != 0) {
+                                billClean.setCarNum(billIsolate.getCarNum());
+                            }
+                            if (billIsolate.getVistitType() == 5) {
+                                billClean.setResource(billIsolate.getResource());
+                                billClean.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                                billClean.setRemark(billIsolate.getRemark());
+                            }
+                            cleanService.save(billClean);
+                        } else if (Integer.parseInt(splits[1]) == 4) {
+                            //新增隔离
+                            BillIsolate pcr = (BillIsolate) entity;
+                            if (billIsolate.getVistitType() != 0) {
+                                pcr.setCarNum(billIsolate.getCarNum());
+                            }
+                            if (billIsolate.getVistitType() == 5) {
+                                pcr.setResource(billIsolate.getResource());
+                                pcr.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                                pcr.setRemark(billIsolate.getRemark());
+                            }
+                            isolateService.save(pcr);
+                        } else if (Integer.parseInt(splits[1]) == 5) {
+                            BillDry billClean = (BillDry) entity;
+                            if (billIsolate.getVistitType() != 0) {
+                                billClean.setCarNum(billIsolate.getCarNum());
+                            }
+                            if (billIsolate.getVistitType() == 5) {
+                                billClean.setResource(billIsolate.getResource());
+                                billClean.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                                billClean.setRemark(billIsolate.getRemark());
+                            }
+                            dryService.save(billClean);
+                            //新增烘干
+                        } else if (Integer.parseInt(splits[1]) == 6) {
+                            //新增洗澡前拍照
+                            BillCleanBefore before = (BillCleanBefore) entity;
+                            if (billIsolate.getVistitType() != 0) {
+                                before.setCarNum(billIsolate.getCarNum());
+                            }
+                            if (billIsolate.getVistitType() == 5) {
+                                before.setResource(billIsolate.getResource());
+                                before.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                                before.setRemark(billIsolate.getRemark());
+                            }
+                            beforeService.save(before);
+                        } else if (Integer.parseInt(splits[1]) == 7) {
+                            //新增洗澡前拍照
+                            BillGoodsInventory before = (BillGoodsInventory) entity;
+                            if (billIsolate.getVistitType() != 0) {
+                                before.setCarNum(billIsolate.getCarNum());
+                            }
+                            if (billIsolate.getVistitType() == 5) {
+                                before.setResource(billIsolate.getResource());
+                                before.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                                before.setRemark(billIsolate.getRemark());
+                            }
+                            inventoryService.save(before);
+                        }
+                        baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId + "," + splits[1]);
+                        Integer locationId = billIsolate.getIsolateLocationId();
+                        int indexOf = allLocationId.indexOf(locationId.toString());//当前位置在所有流程位置中的下标
+                        String substring = baseProcess.getAllLocationStatus().substring(0, indexOf + 3);//截取已经过的位置状态
+                        String[] split1 = substring.split(",");
+                        String sb2 = "";
+                        for (int i = 0; i < split1.length; i++) {
+                            if (i == split1.length - 1) {
+                                sb2 = sb2 + split1[i].replaceAll(split1[i], "2");
+                            } else {
+                                sb2 = split1[i].replaceAll(split1[i], "2") + "," + sb2;
+                            }
+                        }
+                        sb2 = sb2 + baseProcess.getAllLocationStatus().substring(indexOf + 3);
+                        baseProcess.setAllLocationStatus(sb2);
+                    }
+                } else if (nextId == 1) {
+                    //新增采样
+                    BillSampling billSampling = (BillSampling) newObject;
+                    if (billIsolate.getVistitType() != 0) {
+                        billSampling.setCarNum(billIsolate.getCarNum());
+                    }
+                    if (billIsolate.getVistitType() == 5) {
+                        billSampling.setResource(billIsolate.getResource());
+                        billSampling.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                        billSampling.setRemark(billIsolate.getRemark());
+                    }
+
+                    samplingService.save(billSampling);
+                    baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
+                } else if (nextId == 2) {
+                    //新增pcr
+                    BillPcr pcr = (BillPcr) newObject;
+                    if (billIsolate.getVistitType() != 0) {
+                        pcr.setCarNum(billIsolate.getCarNum());
+                    }
+                    if (billIsolate.getVistitType() == 5) {
+                        pcr.setResource(billIsolate.getResource());
+                        pcr.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                        pcr.setRemark(billIsolate.getRemark());
+                    }
+                    pcrService.save(pcr);
+                    baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
+                } else if (nextId == 3) {
+                    //新增洗澡
+                    BillClean pcr = (BillClean) newObject;
+                    if (billIsolate.getVistitType() != 0) {
+                        pcr.setCarNum(billIsolate.getCarNum());
+                    }
+                    if (billIsolate.getVistitType() == 5) {
+                        pcr.setResource(billIsolate.getResource());
+                        pcr.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                        pcr.setRemark(billIsolate.getRemark());
+                    }
+                    cleanService.save(pcr);
+                    baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
+                } else if (nextId == 4) {
+                    //新增隔离
+                    BillIsolate pcr = (BillIsolate) newObject;
+                    if (billIsolate.getVistitType() != 0) {
+                        pcr.setCarNum(billIsolate.getCarNum());
+                    }
+                    if (billIsolate.getVistitType() == 5) {
+                        pcr.setResource(billIsolate.getResource());
+                        pcr.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                        pcr.setRemark(billIsolate.getRemark());
+                    }
+
+                    isolateService.save(pcr);
+                    baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
+                } else if (nextId == 5) {
+                    BillDry pcr = (BillDry) newObject;
+                    if (billIsolate.getVistitType() != 0) {
+                        pcr.setCarNum(billIsolate.getCarNum());
+                    }
+                    if (billIsolate.getVistitType() == 5) {
+                        pcr.setResource(billIsolate.getResource());
+                        pcr.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                        pcr.setRemark(billIsolate.getRemark());
+                    }
+                    dryService.save(pcr);
+                    baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
+                    //新增烘干
+                } else if (nextId == 6) {
+                    //新增洗澡前拍照
+                    BillCleanBefore before = (BillCleanBefore) newObject;
+                    if (billIsolate.getVistitType() != 0) {
+                        before.setCarNum(billIsolate.getCarNum());
+                    }
+                    if (billIsolate.getVistitType() == 5) {
+                        before.setResource(billIsolate.getResource());
+                        before.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                        before.setRemark(billIsolate.getRemark());
+                    }
+                    beforeService.save(before);
+                    baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
+                } else if (nextId == 7) {
+                    //新增洗澡前拍照
+                    BillGoodsInventory before = (BillGoodsInventory) newObject;
+                    if (billIsolate.getVistitType() != 0) {
+                        before.setCarNum(billIsolate.getCarNum());
+                    }
+                    if (billIsolate.getVistitType() == 5) {
+                        before.setResource(billIsolate.getResource());
+                        before.setFeedImgUrl(billIsolate.getFeedImgUrl());
+                        before.setRemark(billIsolate.getRemark());
+                    }
+                    inventoryService.save(before);
+                    baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
+                }
+
+
+                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);
+
+
+                isolateService.updateById(billIsolate);
+                processService.updateById(baseProcess);
+            }
+        }
+    }
+
+    @Scheduled(cron = "0 0/1 * * * ? ")
+    private void pcr() throws Exception {
+        QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("bill_status", 1);
+        List<BillPcr> pcrs = pcrService.list(queryWrapper);
+        Date date = new Date();
+        for (BillPcr pcr : pcrs) {
+            Date subDate = pcr.getCheckDate();
+            // 将LocalDateTime转换为Date
+
+            if ((subDate.getTime() + pcr.getQualifiedDate() * 60 * 1000) <= date.getTime()) {
+                pcr.setBillStatus(3);
+                pcrService.updateById(pcr);
+            }
+        }
+    }
+
+    //计算年龄
+    @Scheduled(cron = "0 0 0 * * ? ")
+    private void getAge() {
+        System.out.println("开始");
+        List<SysUser> sysUsers = sysUserService.list();
+        for (SysUser sysUser : sysUsers) {
+            int i = DateUtil.ageOfNow(sysUser.getBirthday());
+            if (i != sysUser.getAge()) {
+                sysUser.setAge(i);
+                sysUserService.updateById(sysUser);
+            }
+        }
+    }
+
+}
+