zhaowenxuan
2024-10-14 7d702f59202496e28a80582b4aeeab2a9b9da76d
ltkj-admin/src/main/java/com/ltkj/web/controller/service/TjSysAsyncServiceImpl.java
@@ -15,6 +15,7 @@
import com.ltkj.framework.config.MatchUtils;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.hisDto.*;
import com.ltkj.hosp.pacsDto.SavePacsApply;
import com.ltkj.hosp.service.*;
import com.ltkj.hosp.vodomain.AddNewReservationConfirm;
import com.ltkj.hosp.vodomain.LineChartsVo;
@@ -26,6 +27,10 @@
import com.ltkj.system.service.ISysUserService;
import com.ltkj.web.controller.his.HisApiGetMethodService;
import com.ltkj.web.controller.his.HisApiMethodService;
import com.ltkj.web.controller.lis.LisApiMethod;
import com.ltkj.web.controller.pacs.PacsApiMethodService;
import com.ltkj.web.controller.system.TjOrderController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@@ -48,6 +53,7 @@
 * @Date: 2023/9/15 15:57
 */
@Slf4j
@Service
@Transactional
public class TjSysAsyncServiceImpl implements TjAsyncService {
@@ -129,6 +135,12 @@
    private ISysDeptService deptService;
    @Autowired
    private TjCfService cfService;
    @Resource
    private LtkjHysqdService hysqdService;
    @Autowired
    private PacsApiMethodService pacsApiMethodService;
    @Autowired
    private LisApiMethod lisApiMethod;
    @Override
    public void newSaveextracted(TjOrder tjOrder, TjCustomer tjCustomer, BigDecimal discount, SysUser sysUser, TjReservation tjReservation, TjFlowingWater tjFlowingWater) {
@@ -156,7 +168,7 @@
            redisCache.deleteObject(tjCustomer.getCusIdcard() + "cusId");
        if (null != tbTransitionList && tbTransitionList.size() > 0) {
            tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
            tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()),tjOrder.getCardId());
            //修改每项的原价现价
            for (TbTransition transition : tbTransitionList) {
@@ -208,7 +220,8 @@
    public void ttextracted(TjOrder tjOrder, TjCustomer tjCustomer, SysUser sysUser, TjReservation tjReservation, TjFlowingWater tjFlowingWater) {
        tjAskMedicalHistoryService.updateTjAskMedicalHistoryByCusId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjCustomer.getCusId()));
        boolean b = tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
        boolean b = tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(),
                String.valueOf(sysUser.getUserId()),tjOrder.getCardId());
        if (!b) {
            List<TjGroupingPro> proList = groupingProService.list(new LambdaQueryWrapper<TjGroupingPro>().eq(TjGroupingPro::getGroupingId, tjOrder.getGroupId()));
            if (null != proList && proList.size() > 0) {
@@ -276,7 +289,7 @@
            transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), BigDecimal.valueOf(Long.parseLong(tjFlowingWater.getDiscount())), tjOrder.getTjNumber());
        }
        tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
        tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()),tjOrder.getCardId());
//        List<TjOrderDetail> list = tjOrderDetailService.getTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()));
//        if (list != null) {
//            for (TjOrderDetail tjOrderDetail : list) {
@@ -395,7 +408,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);
    }
    public 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();
@@ -500,7 +517,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");
@@ -519,7 +536,6 @@
        proBl.setBlje(String.valueOf(tjFlowingWater.getPaidIn()));
        blService.save(proBl);
        List<TjConsumables> list2 = new ArrayList<>();
        String[] tjProIds = tjFlowingWater.getTjProIds();
        String config = configService.selectConfigByKey("sfkqdyhis");
@@ -539,8 +555,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();
@@ -588,7 +605,7 @@
                    detail1.setJxbz(jxbz);
                    tjOrderDetailService.save(detail1);
                }
                wqq.in(TbTransition::getProId, proIds);
//                wqq.in(TbTransition::getProId, proIds);
                if(null !=config && config.equals("Y")){
                //检验
@@ -726,7 +743,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());
@@ -734,11 +751,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());
@@ -752,64 +767,26 @@
            }
            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){
        ArrayList<TjProject> jianChaProjects = new ArrayList<>();
        ArrayList<TjProject> jianYanProjects = new ArrayList<>();
        if(!projectList.isEmpty()){
            List<TjProject> list = projectList.stream().distinct().collect(Collectors.toList());
            for (TjProject project : list) {
                TjOrderRemark tjOrderRemark = new TjOrderRemark();
@@ -829,7 +806,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());
@@ -845,6 +821,7 @@
//                    if (project.getProPrice().compareTo(BigDecimal.ZERO) != 0 && (project.getDeptId() == 241L || project.getDeptId() == 317L)) {
                    if (project.getProPrice().compareTo(BigDecimal.ZERO) != 0 && deptService.getJyDeptIds().contains(project.getDeptId().toString())) {
                        if (null != project.getHisXmbm()) {
                            jianYanProjects.add(project);
                            OutpintestapplyDetailsDto detailsDto = new OutpintestapplyDetailsDto();
                            detailsDto.setMxfyxmbm(project.getHisXmbm());
@@ -892,6 +869,7 @@
//                                    project.getDeptId() == 275L || project.getDeptId() == 298L)) {
                        if (project.getProPrice().compareTo(BigDecimal.ZERO) != 0 && deptService.getJcDeptIds().contains(project.getDeptId().toString())) {
                        if (null != project.getHisXmbm()) {
                            jianChaProjects.add(project);
                            OutpintestapplyDetailsDto detailsDto = new OutpintestapplyDetailsDto();
                            detailsDto.setMxfyxmbm(project.getHisXmbm());
                            if (project.getSfzhfy().equals("Y")) {
@@ -978,133 +956,144 @@
        }
        if(null !=config && config.equals("Y")){
            if (lisApiMethod.isUseLisAndPacsRegister(order)) {
                List<TjProject> projectList2 = jianYanProjects.stream().distinct().collect(Collectors.toList());
                LambdaQueryWrapper<TjOrderDetail> wq = new LambdaQueryWrapper<>();
                wq.eq(TjOrderDetail::getOrderId, order.getOrderId());
                wq.isNotNull(TjOrderDetail::getFlowingWaterId);
                wq.eq(TjOrderDetail::getIsSampling, 0);
                List<TjOrderDetail> detailList = tjOrderDetailService.list(wq);
                addCaiYangDengJi(detailList, !detailList.isEmpty(), order, sysUser);
            //检验申请
            if(detailsDtos.size()>0){
                OutpintestapplyDto dto = new OutpintestapplyDto();
                dto.setHisRegistrationId(order.getCardId());
                dto.setSfzh(customer.getCusIdcard());
                dto.setSqysbm("00029");
                dto.setMzksbm("0101");
                dto.setSjrq(date);
                dto.setCzybm("00029");
                dto.setCzyksbm("0101");
                dto.setSfjz("0");
                dto.setDetails(detailsDtos.stream().distinct().collect(Collectors.toList()));
                AjaxResult ajaxResult1 = controller.Outpintestapply(dto);
                String result5 = getAjaxResult(ajaxResult1);
                JSONObject object3 = getJSONObject(result5);
                String code3 = object3.getStr("ResultCode");
                if (code3.equals("0")) {
                    List<OutpintestapplyDetailsDto> details = dto.getDetails();
                    for (OutpintestapplyDetailsDto detail : details) {
                        LtkjJianchajianyanTree tree = new LtkjJianchajianyanTree();
                        tree.setSfjx("Y");
                        tree.setJxbz(jxbz);
                        tree.setCardId(dto.getHisRegistrationId());
                        LambdaQueryWrapper<TjCustomer> wrapper4 = new LambdaQueryWrapper<>();
                        wrapper4.eq(TjCustomer::getCardId, tree.getCardId());
                        TjCustomer tjCustomer = tjCustomerService.getOne(wrapper4);
                        tree.setPationid(tjCustomer.getPationId());
                        JSONObject resultData = object3.getJSONObject("ResultData");
                        tree.setSqdh(resultData.getStr("jysqdh"));
                        tree.setFyhj(resultData.getStr("fyhj"));
                        String mxfyxmbm = detail.getMxfyxmbm();
                        tree.setHisXmdm(mxfyxmbm);
                        tree.setType("检验");
                        LambdaQueryWrapper<TjProject> wrapper = new LambdaQueryWrapper<>();
                        wrapper.eq(TjProject::getHisXmbm, mxfyxmbm);
                        List<TjProject> list = projectService.list(wrapper);
                        String tj_price = "";
                        for (TjProject project : list) {
                            tj_price += project.getProPrice() + "、";
                // 检查申请
                pacsReg(order, customer, jianChaProjects);
            }else {
                //检验申请
                if(!detailsDtos.isEmpty()){
                    OutpintestapplyDto dto = new OutpintestapplyDto();
                    dto.setHisRegistrationId(order.getCardId());
                    dto.setSfzh(customer.getCusIdcard());
                    dto.setSqysbm("00029");
                    dto.setMzksbm("0101");
                    dto.setSjrq(date);
                    dto.setCzybm("00029");
                    dto.setCzyksbm("0101");
                    dto.setSfjz("0");
                    dto.setDetails(detailsDtos.stream().distinct().collect(Collectors.toList()));
                    AjaxResult ajaxResult1 = controller.Outpintestapply(dto);
                    String result5 = getAjaxResult(ajaxResult1);
                    JSONObject object3 = getJSONObject(result5);
                    String code3 = object3.getStr("ResultCode");
                    if (code3.equals("0")) {
                        List<OutpintestapplyDetailsDto> details = dto.getDetails();
                        for (OutpintestapplyDetailsDto detail : details) {
                            LtkjJianchajianyanTree tree = new LtkjJianchajianyanTree();
                            tree.setSfjx("Y");
                            tree.setJxbz(jxbz);
                            tree.setCardId(dto.getHisRegistrationId());
                            LambdaQueryWrapper<TjCustomer> wrapper4 = new LambdaQueryWrapper<>();
                            wrapper4.eq(TjCustomer::getCardId, tree.getCardId());
                            TjCustomer tjCustomer = tjCustomerService.getOne(wrapper4);
                            tree.setPationid(tjCustomer.getPationId());
                            JSONObject resultData = object3.getJSONObject("ResultData");
                            tree.setSqdh(resultData.getStr("jysqdh"));
                            tree.setFyhj(resultData.getStr("fyhj"));
                            String mxfyxmbm = detail.getMxfyxmbm();
                            tree.setHisXmdm(mxfyxmbm);
                            tree.setType("检验");
                            LambdaQueryWrapper<TjProject> wrapper = new LambdaQueryWrapper<>();
                            wrapper.eq(TjProject::getHisXmbm, mxfyxmbm);
                            List<TjProject> list = projectService.list(wrapper);
                            String tj_price = "";
                            for (TjProject project : list) {
                                tj_price += project.getProPrice() + "、";
                            }
                            tree.setTjPrice(tj_price.substring(0, tj_price.length() - 1));
                            LambdaQueryWrapper<LtkjJfzhglmxjfxmzd> wrapper1 = new LambdaQueryWrapper<>();
                            if (detail.getSfzhfy().equals("1"))
                                wrapper1.eq(LtkjJfzhglmxjfxmzd::getZhxmdm, mxfyxmbm);
                            else wrapper1.eq(LtkjJfzhglmxjfxmzd::getXmdm, mxfyxmbm);
                            List<LtkjJfzhglmxjfxmzd> ltkjJfzhglmxjfxmzds = ltkjJfzhglmxjfxmzdService.list(wrapper1);
                            if (ltkjJfzhglmxjfxmzds != null && !ltkjJfzhglmxjfxmzds.isEmpty()) {
                                String xmdm = ltkjJfzhglmxjfxmzds.get(0).getXmdm();
                                LambdaQueryWrapper<LtkjMxjfxmzd> wrapper2 = new LambdaQueryWrapper<>();
                                wrapper2.eq(LtkjMxjfxmzd::getXmdm, xmdm);
                                LtkjMxjfxmzd mxjfxmzd = ltkjMxjfxmzdService.getOne(wrapper2);
                                LambdaQueryWrapper<LtkjEjjfxmzd> wrapper3 = new LambdaQueryWrapper<>();
                                wrapper3.eq(LtkjEjjfxmzd::getEjkmdm, mxjfxmzd.getEjkmdm());
                                LtkjEjjfxmzd ejjfxmzd = ltkjEjjfxmzdService.getOne(wrapper3);
                                tree.setXmfl(ejjfxmzd.getYjkmdm());
                            }
                            tree.setCreateTime(dates);
                            ltkjJianchajianyanTreeService.save(tree);
                        }
                        tree.setTjPrice(tj_price.substring(0, tj_price.length() - 1));
                        LambdaQueryWrapper<LtkjJfzhglmxjfxmzd> wrapper1 = new LambdaQueryWrapper<>();
                        if (detail.getSfzhfy().equals("1"))
                            wrapper1.eq(LtkjJfzhglmxjfxmzd::getZhxmdm, mxfyxmbm);
                        else wrapper1.eq(LtkjJfzhglmxjfxmzd::getXmdm, mxfyxmbm);
                        List<LtkjJfzhglmxjfxmzd> ltkjJfzhglmxjfxmzds = ltkjJfzhglmxjfxmzdService.list(wrapper1);
                        if (ltkjJfzhglmxjfxmzds != null && !ltkjJfzhglmxjfxmzds.isEmpty()) {
                            String xmdm = ltkjJfzhglmxjfxmzds.get(0).getXmdm();
                            LambdaQueryWrapper<LtkjMxjfxmzd> wrapper2 = new LambdaQueryWrapper<>();
                            wrapper2.eq(LtkjMxjfxmzd::getXmdm, xmdm);
                            LtkjMxjfxmzd mxjfxmzd = ltkjMxjfxmzdService.getOne(wrapper2);
                            LambdaQueryWrapper<LtkjEjjfxmzd> wrapper3 = new LambdaQueryWrapper<>();
                            wrapper3.eq(LtkjEjjfxmzd::getEjkmdm, mxjfxmzd.getEjkmdm());
                            LtkjEjjfxmzd ejjfxmzd = ltkjEjjfxmzdService.getOne(wrapper3);
                            tree.setXmfl(ejjfxmzd.getYjkmdm());
                        }
                        ltkjJianchajianyanTreeService.save(tree);
                    }
                }
            }
            //门诊检查申请
            if(detailsDtoss.size()>0){
                OutpinexamapplyDto outpinexamapplyDto = new OutpinexamapplyDto();
                outpinexamapplyDto.setHisRegistrationId(order.getCardId());
                outpinexamapplyDto.setSfzh(customer.getCusIdcard());
                outpinexamapplyDto.setSqysbm("00029");
                outpinexamapplyDto.setMzksbm("0101");
                outpinexamapplyDto.setCzybm("00029");
                outpinexamapplyDto.setCzyksbm("0101");
                outpinexamapplyDto.setSfjz("0");
                outpinexamapplyDto.setDetails(detailsDtoss.stream().distinct().collect(Collectors.toList()));
                AjaxResult ajaxResult2 = controller.Outpinexamapply(outpinexamapplyDto);
                String result6 = getAjaxResult(ajaxResult2);
                JSONObject object5 = getJSONObject(result6);
                String code4 = object5.getStr("ResultCode");
                if (code4.equals("0")) {
                    List<OutpintestapplyDetailsDto> details = outpinexamapplyDto.getDetails();
                    for (OutpintestapplyDetailsDto detail : details) {
                        LtkjJianchajianyanTree tree = new LtkjJianchajianyanTree();
                        tree.setSfjx("Y");
                        tree.setJxbz(jxbz);
                        tree.setCardId(outpinexamapplyDto.getHisRegistrationId());
                        LambdaQueryWrapper<TjCustomer> wrapper4 = new LambdaQueryWrapper<>();
                        wrapper4.eq(TjCustomer::getCardId, tree.getCardId());
                        TjCustomer tjCustomer = tjCustomerService.getOne(wrapper4);
                        tree.setPationid(tjCustomer.getPationId());
                        JSONObject resultData = object5.getJSONObject("ResultData");
                        tree.setSqdh(resultData.getStr("jcsqdh"));
                        tree.setFyhj(resultData.getStr("fyhj"));
                        String mxfyxmbm = detail.getMxfyxmbm();
                        tree.setHisXmdm(mxfyxmbm);
                        tree.setType("检查");
                        LambdaQueryWrapper<TjProject> wrapper = new LambdaQueryWrapper<>();
                        wrapper.eq(TjProject::getHisXmbm, mxfyxmbm);
                        List<TjProject> list = projectService.list(wrapper);
                        String tj_price = "";
                        for (TjProject project : list) {
                            tj_price += project.getProPrice() + "、";
                //门诊检查申请
                if(!detailsDtoss.isEmpty()){
                    OutpinexamapplyDto outpinexamapplyDto = new OutpinexamapplyDto();
                    outpinexamapplyDto.setHisRegistrationId(order.getCardId());
                    outpinexamapplyDto.setSfzh(customer.getCusIdcard());
                    outpinexamapplyDto.setSqysbm("00029");
                    outpinexamapplyDto.setMzksbm("0101");
                    outpinexamapplyDto.setCzybm("00029");
                    outpinexamapplyDto.setCzyksbm("0101");
                    outpinexamapplyDto.setSfjz("0");
                    outpinexamapplyDto.setDetails(detailsDtoss.stream().distinct().collect(Collectors.toList()));
                    AjaxResult ajaxResult2 = controller.Outpinexamapply(outpinexamapplyDto);
                    String result6 = getAjaxResult(ajaxResult2);
                    JSONObject object5 = getJSONObject(result6);
                    String code4 = object5.getStr("ResultCode");
                    if (code4.equals("0")) {
                        List<OutpintestapplyDetailsDto> details = outpinexamapplyDto.getDetails();
                        for (OutpintestapplyDetailsDto detail : details) {
                            LtkjJianchajianyanTree tree = new LtkjJianchajianyanTree();
                            tree.setSfjx("Y");
                            tree.setJxbz(jxbz);
                            tree.setCardId(outpinexamapplyDto.getHisRegistrationId());
                            LambdaQueryWrapper<TjCustomer> wrapper4 = new LambdaQueryWrapper<>();
                            wrapper4.eq(TjCustomer::getCardId, tree.getCardId());
                            TjCustomer tjCustomer = tjCustomerService.getOne(wrapper4);
                            tree.setPationid(tjCustomer.getPationId());
                            JSONObject resultData = object5.getJSONObject("ResultData");
                            tree.setSqdh(resultData.getStr("jcsqdh"));
                            tree.setFyhj(resultData.getStr("fyhj"));
                            String mxfyxmbm = detail.getMxfyxmbm();
                            tree.setHisXmdm(mxfyxmbm);
                            tree.setType("检查");
                            LambdaQueryWrapper<TjProject> wrapper = new LambdaQueryWrapper<>();
                            wrapper.eq(TjProject::getHisXmbm, mxfyxmbm);
                            List<TjProject> list = projectService.list(wrapper);
                            String tj_price = "";
                            for (TjProject project : list) {
                                tj_price += project.getProPrice() + "、";
                            }
                            tree.setTjPrice(tj_price.substring(0, tj_price.length() - 1));
                            LambdaQueryWrapper<LtkjJfzhglmxjfxmzd> wrapper1 = new LambdaQueryWrapper<>();
                            if (detail.getSfzhfy().equals("1"))
                                wrapper1.eq(LtkjJfzhglmxjfxmzd::getZhxmdm, mxfyxmbm);
                            else wrapper1.eq(LtkjJfzhglmxjfxmzd::getXmdm, mxfyxmbm);
                            List<LtkjJfzhglmxjfxmzd> ltkjJfzhglmxjfxmzds = ltkjJfzhglmxjfxmzdService.list(wrapper1);
                            if (ltkjJfzhglmxjfxmzds != null && !ltkjJfzhglmxjfxmzds.isEmpty()) {
                                String xmdm = ltkjJfzhglmxjfxmzds.get(0).getXmdm();
                                LambdaQueryWrapper<LtkjMxjfxmzd> wrapper2 = new LambdaQueryWrapper<>();
                                wrapper2.eq(LtkjMxjfxmzd::getXmdm, xmdm);
                                LtkjMxjfxmzd mxjfxmzd = ltkjMxjfxmzdService.getOne(wrapper2);
                                LambdaQueryWrapper<LtkjEjjfxmzd> wrapper3 = new LambdaQueryWrapper<>();
                                wrapper3.eq(LtkjEjjfxmzd::getEjkmdm, mxjfxmzd.getEjkmdm());
                                LtkjEjjfxmzd ejjfxmzd = ltkjEjjfxmzdService.getOne(wrapper3);
                                tree.setXmfl(ejjfxmzd.getYjkmdm());
                            }
                            tree.setCreateTime(dates);
                            ltkjJianchajianyanTreeService.save(tree);
                        }
                        tree.setTjPrice(tj_price.substring(0, tj_price.length() - 1));
                        LambdaQueryWrapper<LtkjJfzhglmxjfxmzd> wrapper1 = new LambdaQueryWrapper<>();
                        if (detail.getSfzhfy().equals("1"))
                            wrapper1.eq(LtkjJfzhglmxjfxmzd::getZhxmdm, mxfyxmbm);
                        else wrapper1.eq(LtkjJfzhglmxjfxmzd::getXmdm, mxfyxmbm);
                        List<LtkjJfzhglmxjfxmzd> ltkjJfzhglmxjfxmzds = ltkjJfzhglmxjfxmzdService.list(wrapper1);
                        if (ltkjJfzhglmxjfxmzds != null && !ltkjJfzhglmxjfxmzds.isEmpty()) {
                            String xmdm = ltkjJfzhglmxjfxmzds.get(0).getXmdm();
                            LambdaQueryWrapper<LtkjMxjfxmzd> wrapper2 = new LambdaQueryWrapper<>();
                            wrapper2.eq(LtkjMxjfxmzd::getXmdm, xmdm);
                            LtkjMxjfxmzd mxjfxmzd = ltkjMxjfxmzdService.getOne(wrapper2);
                            LambdaQueryWrapper<LtkjEjjfxmzd> wrapper3 = new LambdaQueryWrapper<>();
                            wrapper3.eq(LtkjEjjfxmzd::getEjkmdm, mxjfxmzd.getEjkmdm());
                            LtkjEjjfxmzd ejjfxmzd = ltkjEjjfxmzdService.getOne(wrapper3);
                            tree.setXmfl(ejjfxmzd.getYjkmdm());
                        }
                        ltkjJianchajianyanTreeService.save(tree);
                    }
                }
            }
            //药品申请
            if(outpinmedicapplyDetilsDtos.size()>0){
            if(!outpinmedicapplyDetilsDtos.isEmpty()){
                OutpinmedicapplyDto dto1=new OutpinmedicapplyDto();
                dto1.setHisRegistrationId(order.getCardId());
                dto1.setSfzh(customer.getCusIdcard());
@@ -1122,10 +1111,10 @@
                String result1 = getAjaxResult(result);
                JSONObject object = getJSONObject(result1);
                String code = object.getStr("ResultCode");
                if(null !=code && code.equals("200")){
                    JSONArray resultData = object.getJSONArray("ResultData");
                    Map<String, Object> resultDatasss = (Map<String, Object>) resultData.get(0);
                    String cfh = resultDatasss.get("cfh").toString();
                if(null !=code && code.equals("0")){
                    JSONObject resultData = object.getJSONObject("ResultData");
//                    Map<String, Object> resultDatasss = (Map<String, Object>) resultData.get(0);
                    String cfh = resultData.getStr("cfh");
                    for (OutpinmedicapplyDetilsDto detilsDto : outpinmedicapplyDetilsDtos) {
                        TjCf cf=new TjCf();
@@ -1145,13 +1134,14 @@
                        cf.setPj(String.valueOf(detilsDto.getPj()));
                        cf.setJj(String.valueOf(detilsDto.getJj()));
                        cf.setCreateTime(new Date());
                        cf.setJxbz(jxbz);
                        cfService.save(cf);
                    }
                }
            }
            //门诊治疗处置申请
            if(detailDtos.size()>0){
            if(!detailDtos.isEmpty()){
                OutpintreatapplyDto dao = new OutpintreatapplyDto();
                dao.setHisRegistrationId(order.getCardId());
                dao.setSfzh(customer.getCusIdcard());
@@ -1206,12 +1196,12 @@
                            LtkjEjjfxmzd ejjfxmzd = ltkjEjjfxmzdService.getOne(wrapper3);
                            tree.setXmfl(ejjfxmzd.getYjkmdm());
                        }
                        tree.setCreateTime(dates);
                        ltkjJianchajianyanTreeService.save(tree);
                    }
                }
            }
        }
        //父项耗材
//        ArrayList<TjConsumables> collect = list2.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TjConsumables::getId))), ArrayList::new));
@@ -1231,6 +1221,28 @@
//            tjChargingStandard.setUpdateId(String.valueOf(sysUser.getUserId()));
//            chargingStandardService.save(tjChargingStandard);
//        }
    }
    private void pacsReg(TjOrder order, TjCustomer customer, ArrayList<TjProject> jianChaProjects) {
        List<TjProject> projectList1 = jianChaProjects.stream().distinct().collect(Collectors.toList());
        JSONArray array = JSONUtil.createArray();
        ArrayList<SavePacsApply> successPacsList = new ArrayList<>();
        ArrayList<SavePacsApply> errorPacsList = new ArrayList<>();
        int allTotal = 0;
        try {
            allTotal = pacsApiMethodService.saveProjects(order, customer, projectList1, array, successPacsList, errorPacsList);
        } catch (Exception e) {
            log.error(e.getMessage());
            for (Object object : array) {
                JSONObject jsonObject = (JSONObject) object;
                pacsApiMethodService.updatePacsApply(jsonObject.getStr("regNo"), jsonObject.getStr("cardId"), jsonObject.getStr("name"));
            }
        }
        log.info("检查总计 ->{}个", allTotal);
        if (!errorPacsList.isEmpty()) {
            log.info("成功 ->{}", successPacsList);
            log.error("失败 ->{}", errorPacsList);
        }
    }
    @Override
@@ -1733,47 +1745,20 @@
        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);
    }
    //首页饼状图登记人数接口
    private AjaxResult getPieCharts() {
        Map<String, Object> map = new HashMap<>();
        Date date=new Date();
        //获取体检登记数
        LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
        wq0.between(TjOrder::getCreateTime, DateUtil.lastMonth(), DateUtil.now());
        wq0.between(TjOrder::getCreateTime,DateUtil.offsetMonth(date,-1),date);
        List<TjOrder> orderCountList = orderService.list(wq0);
        if (null != orderCountList && orderCountList.size() > 0) {
        if (null != orderCountList && !orderCountList.isEmpty()) {
            List<PieChartVo> pieChartVoList = getTjorderCountMap(orderCountList);
            map.put("tjdj", pieChartVoList);
        } else {
@@ -1781,11 +1766,13 @@
        }
        //获取体检异常数
        LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>();
        wq1.between(TjOrder::getFinishTime, DateUtil.lastMonth(), DateUtil.now());
        wq1.eq(TjOrder::getCheckStatus, 1);
        List<TjOrder> orderAbnormalCountList = orderService.list(wq1);
        if (null != orderAbnormalCountList && orderAbnormalCountList.size() > 0) {
            List<PieChartVo> pieChartVoList = getTjorderAbnormalCountMap(orderAbnormalCountList);
        wq1.between(TjOrder::getCreateTime,DateUtil.offsetMonth(date,-1),date);
//        wq1.isNotNull(TjOrder::getFinishTime);
//        wq1.eq(TjOrder::getCheckStatus, 1);
        List<TjOrder> orderList = orderService.list(wq1);
        if (null !=orderList && !orderList.isEmpty()) {
//            List<TjOrder> orderList = orderAbnormalCountList.stream().distinct().collect(Collectors.toList());
            List<PieChartVo> pieChartVoList = getTjorderAbnormalCountMap(orderList);
            map.put("tjyc", pieChartVoList);
        } else {
            map.put("tjyc", 0);
@@ -1852,14 +1839,14 @@
        int c = 0;
        int d = 0;
        int e = 0;
        Map<String, Object> map = null;
        Map<String, Object> map = new HashMap<>();
        for (TjOrder tjOrder : orderList) {
            map = new HashMap<>();
            LambdaQueryWrapper<TjOrderDetail> wq = new LambdaQueryWrapper<>();
            wq.eq(TjOrderDetail::getOrderId, tjOrder.getOrderId());
            wq.eq(TjOrderDetail::getExceptionDesc, 1);
            List<TjOrderDetail> list = tjOrderDetailService.list(wq);
            if (null != list && list.size() > 0) {
            int count = hysqdService.getHyYcXmCount(tjOrder.getCardId());
            if ((null != list && !list.isEmpty()) || (count>0)) {
                TjCustomer customer = tjCustomerService.getById(tjOrder.getUserId());
                if (null != customer) {
                    int age = DateUtil.ageOfNow(customer.getCusBrithday());
@@ -1875,15 +1862,14 @@
                        e += 1;
                    }
                }
                map.put("0-3岁", a);
                map.put("3-16岁", b);
                map.put("16-40岁", c);
                map.put("40-60岁", d);
                map.put("60岁以上", e);
            }
        }
        map.put("0-3岁", a);
        map.put("3-16岁", b);
        map.put("16-40岁", c);
        map.put("40-60岁", d);
        map.put("60岁以上", e);
        List<PieChartVo> pieChartVoList = new ArrayList<>();
        assert map != null;
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            PieChartVo pieChartVo = new PieChartVo();
            pieChartVo.setName(entry.getKey());