陈昶聿
5 天以前 25c9ca5313fbed298f1faf3893b7b0c780b6e1b2
smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -1520,6 +1520,81 @@
        return true;
    }
    @Override
    public Boolean cancelOperationInfo(Map dataMap) {
        log.info("ServiceExternalServiceImpl---cancelOperationInfo的撤销的值为:{}", dataMap);
        Map yeWuXX = (Map) dataMap.get("YeWuXX");
        Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null;
        ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true);
        PatArchive patArchive = addPatArchive(externalInHospPatientInfo, null, null);
        //手术撤销
        Map<String, Object> sscx = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("ShouShuCX") : null;
        ExternalOperationInfo externalOperationInfo = null;
        if (ObjectUtils.isNotEmpty(sscx))
            externalOperationInfo = BeanUtil.mapToBean(sscx, ExternalOperationInfo.class, true);
        PatMedOperation patMedOperation = new PatMedOperation();
        patMedOperation.setPatid(patArchive.getId());
        patMedOperation.setOrgid(patArchive.getOrgid());
        patMedOperation.setOpreqcode(externalOperationInfo.getShenQingDID());
        //查询一下,该患者是否已经有这些数据
        List<PatMedOperation> patMedOperations = patMedOperationMapper.selectPatMedOperationList(patMedOperation);
        if (CollectionUtils.isNotEmpty(patMedOperations)) {
            for(PatMedOperation operation : patMedOperations){
                Long id = operation.getId();
                //如果手术撤销,直接删除该条手术信息
                if (ObjectUtils.isNotEmpty(sscx)) {
                    operation.setId(id);
                    operation.setCheckFlag("1");
                    operation.setDelFlag("1");
                    //同时去查询,是否在subtask中生成任务,如果生成出得立马删除
                    //            手术随访
                    PatMedOperationItem pmoi = new PatMedOperationItem();
                    //获取需要出院手术随访,未处理的数据
                    pmoi.setOpid(operation.getId().toString());
                    List<PatMedOperationItem> patMedOperationItems
                            = patMedOperationItemMapper.selectOperationItemList(pmoi);
                    List<Long> operationItemIds = patMedOperationItems.stream()
                            .map(PatMedOperationItem::getId)
                            .filter(Objects::nonNull)
                            .distinct()
                            .collect(Collectors.toList());
                    //不需要服务了,需要通过patid和sendstate=1,2,3,5,7去查询一下,service_subtask里是否有正在执行的任务,
                    //有的话,立即停了
                    List<Long> sendstates = Arrays.asList(1L, 2L, 3L, 5L, 7L);
                    List<ServiceSubtask> serviceSubtaskList = new ArrayList<>();
                    ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity();
                    serviceSubtaskVO.setOrgid(patArchive.getOrgid());
                    serviceSubtaskVO.setPatid(patArchive.getId());
                    serviceSubtaskVO.setSendstates(sendstates);
                    serviceSubtaskVO.setOperationItemIds(operationItemIds);
                    serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO);
                    //去redis中,查询是否有subid,有的话移除cache-exist
                    if (CollectionUtils.isNotEmpty(serviceSubtaskList)) {
                        for (ServiceSubtask serviceSubtask : serviceSubtaskList) {
                            log.info("需要移除的subId为:{}", serviceSubtask.getId().toString());
                            serviceSubtask.setSendstate(4L);
                            serviceSubtask.setRemark("手术撤销");
                            serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
                            redisCache.removeElementFromList("cache-exist", serviceSubtask.getId().toString());
                            redisCache.removeElementFromList("cache-0", serviceSubtask.getId().toString());
                            redisCache.removeElementFromList("cache-1", serviceSubtask.getId().toString());
                            redisCache.removeElementFromList("cache-2", serviceSubtask.getId().toString());
                            redisCache.removeElementFromList("cache-3", serviceSubtask.getId().toString());
                            redisCache.removeElementFromList("cache-4", serviceSubtask.getId().toString());
                        }
                    }
                    operation.setUpdateTime(new Date());
                    patMedOperationMapper.updatePatMedOperation(operation);
                    patMedOperationItemMapper.deleteSoftPatMedOperationItemByOpId(operation.getOpid());
                }
            }
        }
        return true;
    }
    //新增患者基本信息
    private PatArchive addPatArchive(ExternalInHospPatientInfo externalInHospPatientInfo, ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo, ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo) {
        Date parse = null;
@@ -2013,6 +2088,7 @@
                return true;
            case "SM_SQ_CheXiao":
                log.info("手术撤销入参类型为:{}", type);
                cancelOperationInfo(dataMap);
                return true;
            case "TJ_YW_BaoGaoXX":
                log.info("体检报告入参类型为:{}", type);