zhaowenxuan
2024-10-12 9f8d59cbb041deed380fa62ec76429258831ec4e
ltkj-admin/src/main/java/com/ltkj/web/controller/service/TjSysAsyncServiceImpl.java
@@ -398,7 +398,11 @@
        wq.isNotNull(TjOrderDetail::getFlowingWaterId);
        wq.eq(TjOrderDetail::getIsSampling, 0);
        List<TjOrderDetail> detailList = tjOrderDetailService.list(wq);
        if (null != detailList && detailList.size() > 0) {
        addCaiYangDengJi(detailList, !detailList.isEmpty(), order, sysUser);
    }
    private void addCaiYangDengJi(List<TjOrderDetail> detailList, boolean detailList1, TjOrder order, SysUser sysUser) {
        if (null != detailList && detailList1) {
            String format = DateUtil.format(new Date(), "yyMMddHHmmssSSS");
            for (TjOrderDetail detail : detailList) {
                TjSampling sampling = new TjSampling();
@@ -503,7 +507,7 @@
    @Override
    @Async("async")
    @Transactional
//    @Transactional
    public void iundividualCharges(TjFlowingWater tjFlowingWater, TjOrder order, TjCustomer customer, SysUser sysUser) {
        Date dates = new Date();
        final String date = DateUtil.format(dates, "yyyy-MM-dd HH:mm:ss");
@@ -522,7 +526,6 @@
        proBl.setBlje(String.valueOf(tjFlowingWater.getPaidIn()));
        blService.save(proBl);
        List<TjConsumables> list2 = new ArrayList<>();
        String[] tjProIds = tjFlowingWater.getTjProIds();
        String config = configService.selectConfigByKey("sfkqdyhis");
@@ -542,8 +545,9 @@
        List<TjProject>  projectList=new ArrayList<>();
        for (String tjProId : tjProIds) {
            LambdaQueryWrapper<TbTransition> wqq = new LambdaQueryWrapper<>();
            wqq.eq(TbTransition::getCusId, customer.getCusIdcard());
//            LambdaQueryWrapper<TbTransition> wqq = new LambdaQueryWrapper<>();
//            wqq.eq(TbTransition::getCusId, customer.getCusIdcard());
//            wqq.isNull(TbTransition::getTjNum);
            TjProject project = projectService.getById(Long.valueOf(tjProId));
            if (null != project && project.getProParentId() == 0) {
                TjOrderRemark tjOrderRemark = new TjOrderRemark();
@@ -591,7 +595,7 @@
                    detail1.setJxbz(jxbz);
                    tjOrderDetailService.save(detail1);
                }
                wqq.in(TbTransition::getProId, proIds);
//                wqq.in(TbTransition::getProId, proIds);
                if(null !=config && config.equals("Y")){
                //检验
@@ -729,7 +733,7 @@
            } else {
                wqq.in(TbTransition::getProId, Arrays.asList(tjProIds));
//                wqq.in(TbTransition::getProId, Arrays.asList(tjProIds));
                TjProject projects = projectService.selectTjProjectByProId(Long.valueOf(tjProId));
                if (null != projects) {
                    TjProject projectss = projectService.getById(projects.getProParentId());
@@ -737,11 +741,9 @@
                        projectList.add(projectss);
                    }
                }
//                List<Long> proIds = projectService.getTjProjectListBySoneId(tjProId).stream().map(TjProject::getProId).collect(Collectors.toList());
                TjOrderDetail detail = new TjOrderDetail();
                detail.setTjStatus(0L);
                detail.setOrderId(tjFlowingWater.getOrderId());
//                detail.setFlowingWaterId(String.valueOf(tjFlowingWater.getTjSerialNumber()));
                detail.setProId(Long.valueOf(tjProId));
                detail.setIsAddition("Y");
                detail.setCreateBy(sysUser.getNickName());
@@ -755,64 +757,23 @@
            }
            List<TbTransition> tbTransitionList = transitionService.list(wqq);
            if (null != tbTransitionList && tbTransitionList.size() > 0) {
//            List<TbTransition> tbTransitionList = transitionService.list(wqq);
            List<TbTransition> tbTransitionList = transitionService.getTbTransitionListByCusIdAndPacIdAndProId(customer.getCusIdcard(),tjProId);
            if (null != tbTransitionList && !tbTransitionList.isEmpty()) {
                for (TbTransition transition : tbTransitionList) {
                    transition.setJxbz(jxbz);
                    transition.setTjNum(order.getTjNumber());
                    transition.setCardId(order.getCardId());
                    transition.setNowPrice(transition.getOrdPrice().multiply(BigDecimal.valueOf(Double.parseDouble(tjFlowingWater.getDiscount())).divide(BigDecimal.valueOf(10))));
                    transitionService.updateById(transition);
//                    TjProject tjProject = projectService.selectTjProjectByProId(transition.getProId());
                    //子项
//                    if (null != tjProject) {
//                        TjChargingStandard tjChargingStandard = new TjChargingStandard();
//                        tjChargingStandard.setTjNum(order.getTjNumber());
//                        tjChargingStandard.setProId(transition.getProId());
//                        tjChargingStandard.setPrice(transition.getNowPrice());
//                        tjChargingStandard.setProName(tjProject.getProName());
//                        tjChargingStandard.setCreateBy(sysUser.getNickName());
//                        tjChargingStandard.setCreateTime(dates);
//                        tjChargingStandard.setUpdateBy(sysUser.getNickName());
//                        tjChargingStandard.setUpdateTime(dates);
//                        tjChargingStandard.setCreateId(String.valueOf(sysUser.getUserId()));
//                        tjChargingStandard.setUpdateId(String.valueOf(sysUser.getUserId()));
//                        chargingStandardService.save(tjChargingStandard);
//                    }
//                    transition.setJxbz(jxbz);
//                    transition.setTjNum(order.getTjNumber());
//                    transition.setCardId(order.getCardId());
//                    transition.setNowPrice(transition.getOrdPrice().multiply(BigDecimal.valueOf(Double.parseDouble(tjFlowingWater.getDiscount())).divide(BigDecimal.valueOf(10))));
//                    transitionService.updateById(transition);
                    transitionService.updateTbTransitionById(transition.getId().toString(),jxbz,order.getTjNumber(),order.getCardId(),
                            transition.getOrdPrice().multiply(BigDecimal.valueOf(Double.parseDouble(tjFlowingWater.getDiscount())).divide(BigDecimal.valueOf(10))));
                }
                //父项
//
//                TjProject parentProject = projectService.selectTjProjectByProId(Long.valueOf(tjProId));
//                if (null != parentProject && parentProject.getProParentId() == 0) {
//                    LambdaQueryWrapper<TjProConsumables> wqqq = new LambdaQueryWrapper<>();
//                    wqqq.eq(TjProConsumables::getProId, parentProject.getProId());
//                    List<TjProConsumables> proConsumables = proConsumablesService.list(wqqq);
//                    if (null != proConsumables && proConsumables.size() > 0) {
//                        for (TjProConsumables tjProConsumables : proConsumables) {
//                            TjConsumables tjConsumables = consumablesService.selectTjConsumablesById(tjProConsumables.getConsumablesId());
//                            list2.add(tjConsumables);
//                        }
//                    }
//
//                } else {
//                    TjProject parentProjects = projectService.getById(tjProId);
//                    if (null != parentProjects) {
//                        LambdaQueryWrapper<TjProConsumables> wqqq = new LambdaQueryWrapper<>();
//                        wqqq.eq(TjProConsumables::getProId, parentProjects.getProId());
//                        List<TjProConsumables> proConsumables = proConsumablesService.list(wqqq);
//                        if (null != proConsumables && proConsumables.size() > 0) {
//                            for (TjProConsumables tjProConsumables : proConsumables) {
//                                TjConsumables tjConsumables = consumablesService.selectTjConsumablesById(tjProConsumables.getConsumablesId());
//                                list2.add(tjConsumables);
//                            }
//                        }
//                    }
//                }
            }
        }
        if(projectList.size()>0){
        if(!projectList.isEmpty()){
            List<TjProject> list = projectList.stream().distinct().collect(Collectors.toList());
            for (TjProject project : list) {
                TjOrderRemark tjOrderRemark = new TjOrderRemark();
@@ -832,7 +793,6 @@
                TjOrderDetail detail1 = new TjOrderDetail();
                detail1.setTjStatus(0L);
                detail1.setOrderId(tjFlowingWater.getOrderId());
//                        detail1.setFlowingWaterId(String.valueOf(tjFlowingWater.getTjSerialNumber()));
                detail1.setProId(project.getProId());
                detail1.setIsAddition("Y");
                detail1.setCreateBy(sysUser.getNickName());
@@ -982,10 +942,8 @@
        if(null !=config && config.equals("Y")){
            //检验申请
            if(detailsDtos.size()>0){
            if(!detailsDtos.isEmpty()){
                OutpintestapplyDto dto = new OutpintestapplyDto();
                dto.setHisRegistrationId(order.getCardId());
                dto.setSfzh(customer.getCusIdcard());
@@ -1048,7 +1006,7 @@
            }
            //门诊检查申请
            if(detailsDtoss.size()>0){
            if(!detailsDtoss.isEmpty()){
                OutpinexamapplyDto outpinexamapplyDto = new OutpinexamapplyDto();
                outpinexamapplyDto.setHisRegistrationId(order.getCardId());
                outpinexamapplyDto.setSfzh(customer.getCusIdcard());
@@ -1109,7 +1067,7 @@
            }
            //药品申请
            if(outpinmedicapplyDetilsDtos.size()>0){
            if(!outpinmedicapplyDetilsDtos.isEmpty()){
                OutpinmedicapplyDto dto1=new OutpinmedicapplyDto();
                dto1.setHisRegistrationId(order.getCardId());
                dto1.setSfzh(customer.getCusIdcard());
@@ -1157,7 +1115,7 @@
            }
            //门诊治疗处置申请
            if(detailDtos.size()>0){
            if(!detailDtos.isEmpty()){
                OutpintreatapplyDto dao = new OutpintreatapplyDto();
                dao.setHisRegistrationId(order.getCardId());
                dao.setSfzh(customer.getCusIdcard());
@@ -1218,7 +1176,6 @@
                }
            }
        }
        //父项耗材
//        ArrayList<TjConsumables> collect = list2.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TjConsumables::getId))), ArrayList::new));
@@ -1740,36 +1697,7 @@
        wq.isNotNull(TjOrderDetail::getFlowingWaterId);
        wq.eq(TjOrderDetail::getIsSampling, 0);
        List<TjOrderDetail> detailList = tjOrderDetailService.list(wq);
        if (null != detailList && detailList.size() > 0) {
            String format = DateUtil.format(new Date(), "yyMMddHHmmssSSS");
            for (TjOrderDetail detail : detailList) {
                TjSampling sampling = new TjSampling();
                if (null == projectService.getById(detail.getProId())) continue;
                Long proParentId = projectService.getById(detail.getProId()).getProParentId();
                if (null != proParentId && proParentId == 0) {
                    sampling.setSpecimenType(projectService.getById(detail.getProId()).getSpecimenType());
                } else {
                    sampling.setSpecimenType(projectService.getById(projectService.getById(detail.getProId()).getProParentId()).getSpecimenType());
                }
                sampling.setSamplingNumber(format);
                sampling.setTjNum(order.getTjNumber());
                sampling.setCusId(String.valueOf(order.getUserId()));
                if (tjCustomerService.getById(String.valueOf(order.getUserId())) != null) {
                    sampling.setCusName(tjCustomerService.getById(String.valueOf(order.getUserId())).getCusName());
                }
                sampling.setApplicationTime(new Date());
                sampling.setTjTime(order.getCreateTime());
                sampling.setProId(String.valueOf(detail.getProId()));
                sampling.setProName(projectService.getById(detail.getProId()).getProName());
                sampling.setCreateBy(sysUser.getNickName());
                sampling.setCreateTime(new Date());
                sampling.setUpdateBy(sysUser.getNickName());
                sampling.setUpdateTime(new Date());
                sampling.setCreateId(String.valueOf(sysUser.getUserId()));
                sampling.setUpdateId(String.valueOf(sysUser.getUserId()));
                samplingService.save(sampling);
            }
        }
        addCaiYangDengJi(detailList, detailList.size() > 0, order, sysUser);
    }
    //首页饼状图登记人数接口