liusheng
23 小时以前 459aa78c84cf552ebea6ef056d978c2531d71ac8
smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
@@ -13,6 +13,7 @@
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.smartor.domain.*;
import com.smartor.domain.entity.ServiceSubtaskEntity;
import com.smartor.mapper.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
@@ -71,31 +72,34 @@
     * @return 患者门诊记录
     */
    @Override
    @Cacheable(value = "selectPatMedOuthospList", key = "T(org.springframework.util.DigestUtils).md5DigestAsHex(#patMedOuthosp.toString().getBytes())", unless = "#result == null or #result.isEmpty()")
    public List<PatMedOuthosp> selectPatMedOuthospList(PatMedOuthosp patMedOuthosp) {
        List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.selectPatMedOuthospList(patMedOuthosp);
        for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
            PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid());
            if (patArchive.getBirthdate() != null) {
                Map<String, String> map = calculateAge(patArchive.getBirthdate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now());
                patArchive.setAge(ObjectUtils.isNotEmpty(map.get("age")) ? Long.valueOf(map.get("age")) : null);
                patArchive.setAgeUnit(map.get("ageUnit"));
                patArchive.setAge2(ObjectUtils.isNotEmpty(map.get("age2")) ? Long.valueOf(map.get("age2")) : null);
                patArchive.setAgeUnit2(map.get("ageUnit2"));
                patMedOuthosp1.setAge(patArchive.getAge() + patArchive.getAgeUnit() + patArchive.getAge2() + patArchive.getAgeUnit2());
                patMedOuthosp1.setTelcode(patArchive.getTelcode());
                patMedOuthosp1.setIdcardno(patArchive.getIdcardno());
        if (patMedOuthosp.getPageNum() != null) {
            for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
                PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid());
                if (patArchive.getBirthdate() != null) {
                    Map<String, String> map = calculateAge(patArchive.getBirthdate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now());
                    patArchive.setAge(ObjectUtils.isNotEmpty(map.get("age")) ? Long.valueOf(map.get("age")) : null);
                    patArchive.setAgeUnit(map.get("ageUnit"));
                    patArchive.setAge2(ObjectUtils.isNotEmpty(map.get("age2")) ? Long.valueOf(map.get("age2")) : null);
                    patArchive.setAgeUnit2(map.get("ageUnit2"));
                    patMedOuthosp1.setAge(patArchive.getAge() + patArchive.getAgeUnit() + patArchive.getAge2() + patArchive.getAgeUnit2());
                    patMedOuthosp1.setSex(patArchive.getSex());
                    patMedOuthosp1.setTelcode(patArchive.getTelcode());
                    patMedOuthosp1.setIdcardno(patArchive.getIdcardno());
                }
                ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity();
                serviceSubtaskVO.setPatid(patMedOuthosp1.getPatid());
                List<Long> sendstates = new ArrayList<>();
                sendstates.add(1L);
                sendstates.add(2L);
                sendstates.add(3L);
                serviceSubtaskVO.setSendstates(sendstates);
                serviceSubtaskVO.setServiceType("3");
                List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskBySendstate(serviceSubtaskVO);
                if (!CollectionUtils.isEmpty(serviceSubtaskList)) patMedOuthosp1.setServerState("1");
            }
            ServiceSubtaskVO serviceSubtaskVO = new ServiceSubtaskVO();
            serviceSubtaskVO.setPatid(patMedOuthosp1.getPatid());
            List<Long> sendstates = new ArrayList<>();
            sendstates.add(1L);
            sendstates.add(2L);
            sendstates.add(3L);
            serviceSubtaskVO.setSendstates(sendstates);
            serviceSubtaskVO.setServiceType("3");
            List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskBySendstate(serviceSubtaskVO);
            if (!CollectionUtils.isEmpty(serviceSubtaskList)) patMedOuthosp1.setServerState("1");
        }
        return patMedOuthosps;
    }
@@ -300,7 +304,7 @@
        //先判断一下,是否需要校验
        if (check) {
            //在新增之前,先通过患者ID,sendstate=2查询一下,在所有长期任务中,是不是还有该患者待执行的任务,有的话,比较之前的endtime是否小于当前的endtaime,如果之前的小于现在的,则直接将之前的停掉(原因再入院)
            ServiceSubtaskVO subtask = new ServiceSubtaskVO();
            ServiceSubtaskEntity subtask = new ServiceSubtaskEntity();
            subtask.setPatid(patArchive.getId());
            subtask.setSendstate(2L);
            subtask.setTaskid(taskid);