zhaowenxuan
2025-01-20 011bf0464e98d8f866795b49883d1005ecf55ebb
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
@@ -53,6 +53,7 @@
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.dto.QianDaoDto;
import com.ltkj.hosp.dto.TjProBlDto;
import com.ltkj.hosp.dto.UpdateTransitionnewPriceDto;
import com.ltkj.hosp.hisDto.OutpinimpapplyDto;
import com.ltkj.hosp.hisDto.OutpinmedicapplyDto;
import com.ltkj.hosp.mapper.TestMapper;
@@ -231,6 +232,8 @@
    private ISysDictDataService sysDictDataService;
    @Autowired
    private TjFlowingWaterHisService tjFlowingWaterHisService;
    @Resource
    private ITjXdPictureService xdPictureService;
    //将方法返回值解析成json格式
    public JSONObject getJSONObject(String builder) {
@@ -495,13 +498,9 @@
                            order.setIdType(tjCustomer.getIdType());
                            order.setAgeUnit(tjCustomer.getAgeUnit());
                            order.setTjCount(String.valueOf(tjCustomer.getCusNumber()));
                            if (null != tjCustomer.getCompName()) {
                                order.setDictCompName(tjCustomer.getCompName());
                            } else {
                                String firmId = order.getFirmId();
                                if (firmId != null && null != iDictCompService.getById(String.valueOf(order.getFirmId()))) {
                                    order.setDictCompName(iDictCompService.getById(String.valueOf(order.getFirmId())).getCnName());
                                }
                            String firmName = order.getFirmName();
                            if (StringUtil.isNotBlank(firmName)) {
                                order.setDictCompName(firmName);
                            }
                            if (null != order.getPacId()) {
                                if (null != tjPackageService.getById(order.getPacId())) {
@@ -988,18 +987,18 @@
        TjCustomer tjCustomer = tjCustomerService.getOne(wq);
        if (tjCustomer == null) return AjaxResult.error("该客户未登记");
        LambdaQueryWrapper<TjOrder> wqq = new LambdaQueryWrapper<>();
        wqq.eq(TjOrder::getUserId, tjOrder.getUserId());
        wqq.eq(TjOrder::getCheckStatus, 0);
        wqq.isNull(TjOrder::getFinishTime);
//        if (!tjCustomer.getCardId().equals("0")) {
        wqq.eq(TjOrder::getCardId, tjCustomer.getCardId());
//        LambdaQueryWrapper<TjOrder> wqq = new LambdaQueryWrapper<>();
//        wqq.eq(TjOrder::getUserId, tjOrder.getUserId());
//        wqq.eq(TjOrder::getCheckStatus, 0);
//        wqq.isNull(TjOrder::getFinishTime);
////        if (!tjCustomer.getCardId().equals("0")) {
//        wqq.eq(TjOrder::getCardId, tjCustomer.getCardId());
////        }
//        TjOrder order = tjOrderService.getOne(wqq);
//        if (null != order) {
//            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId());
//            return AjaxResult.error("不可重复登记");
//        }
        TjOrder order = tjOrderService.getOne(wqq);
        if (null != order) {
            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId());
            return AjaxResult.error("不可重复登记");
        }
        TjFlowingWater tjFlowingWater = new TjFlowingWater();
        LambdaQueryWrapper<TjReservation> wq1 = new LambdaQueryWrapper<>();
        wq1.eq(TjReservation::getIdCard, tjCustomer.getCusIdcard());
@@ -1018,8 +1017,8 @@
                return AjaxResult.error("对不起您的预约已超时请重新预约");
            }
            if (null != tjReservation.getTeamNo()) tjOrder.setTeamNo(tjReservation.getTeamNo());
//            if (null != tjReservation.getCompanyId()) tjOrder.setFirmId(tjReservation.getCompanyId());
//            if (null != tjReservation.getCompany()) tjOrder.setFirmName(tjReservation.getCompany());
            if (null != tjReservation.getCompanyId()) tjOrder.setFirmId(tjReservation.getCompanyId());
            if (null != tjReservation.getCompany()) tjOrder.setFirmName(tjReservation.getCompany());
            if (null != tjReservation.getDepartment()) tjOrder.setFirmDeptName(tjReservation.getDepartment());
            if (null != tjReservation.getJobNo()) tjOrder.setFirmWorkId(tjReservation.getJobNo());
            if (null != tjReservation.getPacId()) tjOrder.setPacId(tjReservation.getPacId());
@@ -1036,16 +1035,9 @@
                tjOrder.setTjType("2");
            }
        }
        if (null != tjCustomer.getCompName()) {
            tjOrder.setFirmName(tjCustomer.getCompName());
        }
        if (null != tjCustomer.getDictCompId()) {
            tjOrder.setFirmId(String.valueOf(tjCustomer.getDictCompId()));
        } else {
        if(StringUtil.isBlank(tjOrder.getFirmId())){
            tjOrder.setFirmId("0");
        }
        if (null != tjOrder.getPhoto()) {
            File file = new File(tjOrder.getPhoto());
@@ -1093,11 +1085,21 @@
    @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
    public AjaxResult processOrderWithTransaction(TjOrder tjOrder, TjCustomer tjCustomer, TjReservation tjReservation, TjFlowingWater tjFlowingWater, MallOrder mallOrder, SysUser sysUser) {
        //生成体检号
        String tjNumber = (SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
        tjOrder.setTjNumber(tjNumber);
        BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount()));
        //获取拼接前缀
        String makeLisTmhPrefix = configService.selectConfigByKey("make_lis_tmh_prefix");
        //生成体检号
//        String tjNumber = (SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
//        if(StringUtil.isNotBlank(makeLisTmhPrefix)) tjNumber=makeLisTmhPrefix+tjNumber;
        String tjNumber = (SecurityUtils.getUsername()+IdUtils.getTjNumber());
        if(StringUtil.isNotBlank(makeLisTmhPrefix)) tjNumber=makeLisTmhPrefix+tjNumber;
        tjOrder.setTjNumber(tjNumber);
        BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount()));
        tjOrder.setDiscount(discount.toString());
        if (tjOrderService.save(tjOrder)) {
            //保存收货地址
@@ -1132,11 +1134,18 @@
            Date date1 = new Date(System.currentTimeMillis());
            String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date1);
            tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "").toUpperCase() + s1);
            BigDecimal copeWith = tjOrder.getTjFlowingWater().getCopeWith();
            BigDecimal paidIn = tjOrder.getTjFlowingWater().getPaidIn();
            tjFlowingWater.setCopeWith(copeWith);
            tjFlowingWater.setPaidIn(paidIn);
            tjFlowingWater.setDiscount(discount.toString());
            tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
            tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
            tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount());
            BigDecimal subtract = paidIn.subtract(copeWith.multiply(discount.divide(BigDecimal.valueOf(10))));
            log.info("签到登记体检人: "+tjOrder.getTjNumber()+" 应付: "+copeWith);
            log.info("签到登记体检人: "+tjOrder.getTjNumber()+" 折扣: "+discount);
            log.info("签到登记体检人: "+tjOrder.getTjNumber()+" 实付: "+paidIn);
            log.info("签到登记体检人: "+tjOrder.getTjNumber()+" 相差: "+subtract);
            if (isPay.equals("true")) {
                if (null != mallOrder) {
@@ -1166,13 +1175,27 @@
                    //                    tjFlowingWater.setPayStasus(0L);
                }
            }
            //修改每项的原价现价
//            transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), discount, tjOrder.getTjNumber());
            //修改临时表体检号
            transitionService.updateTbTransitionTjNumByCusId(tjCustomer.getCusIdcard(),tjOrder.getTjNumber());
            //补差价
    /*        if(subtract.compareTo(BigDecimal.ZERO)>0){
                tjFlowingWater.setPaidIn(paidIn.add(subtract));
                TbTransition onwTbTransition = transitionService.getOnwTbTransition(tjCustomer.getCusIdcard(),tjOrder.getTjNumber());
                if(null !=onwTbTransition){
                    log.info("签到登记体检人: "+tjOrder.getTjNumber()+"给: "+onwTbTransition.getParentProName()+" "+onwTbTransition.getNowPrice()
                            +" 补差价 "+subtract+" 最终得 "+onwTbTransition.getNowPrice().add(subtract));
                    onwTbTransition.setNowPrice(onwTbTransition.getNowPrice().add(subtract));
                    transitionService.updateById(onwTbTransition);
                }
            }*/
            if (tjFlowingWaterService.save(tjFlowingWater)) {
                tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber()));
                tjOrderService.updateById(tjOrder);
            }
            //修改每项的原价现价 //修改临时表体检号
            transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), discount, tjOrder.getTjNumber());
            /*调用his接口*/
            String config = configService.selectConfigByKey("sfkqdyhis");
@@ -1209,8 +1232,10 @@
                    tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                            sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
                    remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
                    List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
                    addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
                    List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
                    xdPictureService.saveBatch(xdPictureList);
//                    List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
//                    addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
                } else {
                    newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                    List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
@@ -1320,80 +1345,17 @@
                tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                        sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
                remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
                List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
                xdPictureService.saveBatch(xdPictureList);
                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
                return AjaxResult.success(tjNumber);
            }else {
                newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
            }
            String s = configService.selectConfigByKey("is_request_common_his_api");
            if (null != s && s.equals("Y")) {
                String apiUrl = configService.selectConfigByKey("common_api_url");
                String hospbm = configService.selectConfigByKey("common_api_service_hospbm");
                HashMap<String, Object> map = new HashMap<>();
                map.put("pationId", tjCustomer.getPationId());
                map.put("cardId", tjCustomer.getHisJzkh());
                map.put("tjNum", tjFlowingWater.getTjSerialNumber());
                map.put("kaiDanKs", "7805");
                // 收费标志 1待售费 2待退费
                map.put("shouTuiStatus", "1");
                JSONArray array = JSONUtil.createArray();
                LambdaQueryWrapper<TbTransition> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(TbTransition::getTjNum, tjOrder.getTjNumber());
                wrapper.eq(TbTransition::getCusId, tjCustomer.getCusIdcard());
                wrapper.eq(TbTransition::getCardId, tjCustomer.getCardId());
                wrapper.isNotNull(TbTransition::getOrdPrice);
                wrapper.gt(TbTransition::getOrdPrice, 0);
                List<TbTransition> list = tbTransitionService.list(wrapper);
                for (TbTransition transition : list) {
                    LambdaQueryWrapper<TjProject> wrapper1 = new LambdaQueryWrapper<>();
                    wrapper1.eq(TjProject::getProId, transition.getProId());
                    TjProject project = projectService.getOne(wrapper1);
                    LambdaQueryWrapper<SysDept> wrapper2 = new LambdaQueryWrapper<>();
                    wrapper2.eq(SysDept::getDeptId, project.getDeptId());
                    SysDept dept = sysDeptService.getOne(wrapper2);
                    JSONObject obj = JSONUtil.createObj();
                    Integer sl = project.getSl();
                    BigDecimal danjia = transition.getOrdPrice();
                    BigDecimal allPrice = danjia.multiply(new BigDecimal(sl));
                    obj.putOpt("danJia", danjia);
                    obj.putOpt("jieSuanJe", allPrice);
                    obj.putOpt("shuliang", sl);
                    obj.putOpt("zhiXingKs", dept.getDeptId());
                    obj.putOpt("zhiXingKsMc", dept.getDeptName());
                    obj.putOpt("shouFeiXmId", project.getHisXmbm());
                    obj.putOpt("shouFeiXmMc", project.getHisXmmc());
//                        obj.putOpt("zhiXingKs","7805");
//                        obj.putOpt("zhiXingKsMc","体检科");
//                        obj.putOpt("shouFeiXmId","4735346");
//                        obj.putOpt("shouFeiXmMc","体检费");
                    array.add(obj);
                }
                map.put("feiYongInfoList", array);
                String post = HttpClientUtils.sendPost(apiUrl + "/api/his/" + hospbm + "/creatCostInfo", map);
                JSONObject object = JSONUtil.parseObj(post);
                if (object.getInt("code") == 200) {
                    JSONObject data = object.getJSONObject("data");
                    tjFlowingWater.setHisWaterId(data.getStr("feiYongId"));
                    JSONArray mxList = data.getJSONArray("mxList");
                    if (mxList != null && !mxList.isEmpty()) {
                        List<TjFlowingWaterHis> his = mxList.toList(TjFlowingWaterHis.class);
                        tjFlowingWaterHisService.saveBatch(his);
                    }
                    tjFlowingWaterService.updateById(tjFlowingWater);
                } else {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error();
                }
                AjaxResult error = isRequestCommonHisApi(tjOrder, tjCustomer, tjFlowingWater);
                if (error != null) return error;
//                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
//                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
            }
            return AjaxResult.success(tjNumber);
@@ -1404,7 +1366,80 @@
        return AjaxResult.error();
    }
    private AjaxResult isRequestCommonHisApi(TjOrder tjOrder, TjCustomer tjCustomer, TjFlowingWater tjFlowingWater) {
        String s = configService.selectConfigByKey("is_request_common_his_api");
        if (null != s && s.equals("Y")) {
            String apiUrl = configService.selectConfigByKey("common_api_url");
            String hospbm = configService.selectConfigByKey("common_api_service_hospbm");
            HashMap<String, Object> map = new HashMap<>();
            map.put("pationId", tjCustomer.getPationId());
            map.put("cardId", tjCustomer.getHisJzkh());
            map.put("tjNum", tjFlowingWater.getTjSerialNumber());
            map.put("kaiDanKs", "7805");
            // 收费标志 1待售费 2待退费
            map.put("shouTuiStatus", "1");
            JSONArray array = JSONUtil.createArray();
            LambdaQueryWrapper<TbTransition> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(TbTransition::getTjNum, tjOrder.getTjNumber());
            wrapper.eq(TbTransition::getCusId, tjCustomer.getCusIdcard());
            wrapper.eq(TbTransition::getCardId, tjCustomer.getCardId());
            wrapper.isNotNull(TbTransition::getOrdPrice);
            wrapper.gt(TbTransition::getOrdPrice, 0);
            List<TbTransition> list = tbTransitionService.list(wrapper);
            for (TbTransition transition : list) {
                LambdaQueryWrapper<TjProject> wrapper1 = new LambdaQueryWrapper<>();
                wrapper1.eq(TjProject::getProId, transition.getProId());
                TjProject project = projectService.getOne(wrapper1);
                LambdaQueryWrapper<SysDept> wrapper2 = new LambdaQueryWrapper<>();
                wrapper2.eq(SysDept::getDeptId, project.getDeptId());
                SysDept dept = sysDeptService.getOne(wrapper2);
                JSONObject obj = JSONUtil.createObj();
                Integer sl = project.getSl();
                BigDecimal danjia = transition.getOrdPrice();
                BigDecimal allPrice = danjia.multiply(new BigDecimal(sl));
                obj.putOpt("danJia", danjia);
                obj.putOpt("jieSuanJe", allPrice);
                obj.putOpt("shuliang", sl);
                obj.putOpt("zhiXingKs", dept.getDeptId());
                obj.putOpt("zhiXingKsMc", dept.getDeptName());
                obj.putOpt("shouFeiXmId", project.getHisXmbm());
                obj.putOpt("shouFeiXmMc", project.getHisXmmc());
//                        obj.putOpt("zhiXingKs","7805");
//                        obj.putOpt("zhiXingKsMc","体检科");
//                        obj.putOpt("shouFeiXmId","4735346");
//                        obj.putOpt("shouFeiXmMc","体检费");
                array.add(obj);
            }
            map.put("feiYongInfoList", array);
            String post = HttpClientUtils.sendPost(apiUrl + "/api/his/" + hospbm + "/creatCostInfo", map);
            JSONObject object = JSONUtil.parseObj(post);
            if (object.getInt("code") == 200) {
                JSONObject data = object.getJSONObject("data");
                tjFlowingWater.setHisWaterId(data.getStr("feiYongId"));
                JSONArray mxList = data.getJSONArray("mxList");
                if (mxList != null && !mxList.isEmpty()) {
                    List<TjFlowingWaterHis> his = mxList.toList(TjFlowingWaterHis.class);
                    tjFlowingWaterHisService.saveBatch(his);
                }
                tjFlowingWaterService.updateById(tjFlowingWater);
            } else {
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return AjaxResult.error();
            }
        }
        return null;
    }
    public void addCaiYangDengJi(List<TjOrderDetail> detailList, boolean detailList1, TjOrder order, SysUser sysUser, String jxbz) {
        String lis_tmh_prefix = configService.selectConfigByKey("make_lis_tmh_prefix");
        String config = configService.selectConfigByKey("sfkqdyhis");
        Boolean lisAndPacsRegister = lisApiMethod.isUseLisAndPacsRegister(order);
        if (null != detailList && detailList1) {
            Date date = new Date();
            String format = DateUtil.format(date, "yyMMddHHmmssSSS");
@@ -1415,17 +1450,21 @@
                Long proParentId = project.getProParentId();
                String dictLabel = sysDictDataService.selectDictLabel("sys_dict_specimen", project.getSpecimenType());
                if (null != proParentId && proParentId == 0) {
                    sampling.setJyxh(idUtils.generateLisID());
                    sampling.setJyxh(idUtils.generateLisID(lis_tmh_prefix));
                    sampling.setSpecimenTypeCode(project.getSpecimenType());
                    sampling.setSpecimenType(dictLabel);
                    sampling.setJyxmdm(project.getProId().toString());
                    if (config.equals("Y") && lisAndPacsRegister)
                        sampling.setJyxmdm(project.getLisXmbm());
                    else sampling.setJyxmdm(project.getProId().toString());
                } else {
                    TjProject project1 = projectService.getById(proParentId);
                    sampling.setJyxh(idUtils.generateLisID());
                    sampling.setJyxh(idUtils.generateLisID(lis_tmh_prefix));
                    sampling.setSpecimenTypeCode(project1.getSpecimenType());
                    sampling.setSpecimenType(dictLabel);
                    sampling.setJyxmdm(project.getProId().toString());
                    if (config.equals("Y") && lisAndPacsRegister)
                        sampling.setJyxmdm(project1.getLisXmbm());
                    else sampling.setJyxmdm(project1.getProId().toString());
                }
                sampling.setSamplingNumber(format);
@@ -1448,7 +1487,6 @@
                samplingService.save(sampling);
            }
        }
        String config = configService.selectConfigByKey("sfkqdyhis");
        if (lisApiMethod.isUseLisAndPacsRegister(order) && (null != config && config.equals("Y"))) {
            AjaxResult ajaxResult = lisApiMethod.getJyFlHb();
            if (ajaxResult.get("code").toString().equals("200")) {
@@ -1722,18 +1760,18 @@
        TjCustomer tjCustomer = tjCustomerService.getOne(wq);
        if (tjCustomer == null) return AjaxResult.error("该客户未登记或不存在");
        LambdaQueryWrapper<TjOrder> wqq = new LambdaQueryWrapper<>();
        wqq.eq(TjOrder::getUserId, userId);
        wqq.eq(TjOrder::getCheckStatus, 0);
        wqq.isNull(TjOrder::getFinishTime);
        if (!tjCustomer.getCardId().equals("0")) {
            wqq.eq(TjOrder::getCardId, tjCustomer.getCardId());
        }
        TjOrder order = tjOrderService.getOne(wqq);
        if (null != order) {
            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId());
            return AjaxResult.error("不可重复登记");
        }
//        LambdaQueryWrapper<TjOrder> wqq = new LambdaQueryWrapper<>();
//        wqq.eq(TjOrder::getUserId, userId);
//        wqq.eq(TjOrder::getCheckStatus, 0);
//        wqq.isNull(TjOrder::getFinishTime);
//        if (!tjCustomer.getCardId().equals("0")) {
//            wqq.eq(TjOrder::getCardId, tjCustomer.getCardId());
//        }
//        TjOrder order = tjOrderService.getOne(wqq);
//        if (null != order) {
//            transitionService.deletedTbTransitionListByCusIdAndTjNum(tjCustomer.getCusIdcard(), tjCustomer.getCardId());
//            return AjaxResult.error("不可重复登记");
//        }
        TjOrder tjOrder = new TjOrder();
        Date date = new Date();
        tjOrder.setCreateTime(date);
@@ -2592,9 +2630,9 @@
    @ApiOperation(value = "根据体检号获取汇总和明细的数据")
    public AjaxResult getTransitionInfo(@RequestParam("tjNumber") String tjNumber) {
        QueryWrapper<TbTransition> wrapper = new QueryWrapper<>();
        wrapper.select("parent_pro_id", "parent_pro_name", "sum(ord_price) as ord_price")
        wrapper.select("parent_pro_id", "parent_pro_name", "sum(now_price) as ord_price")
                .eq("tj_num", tjNumber)
                .groupBy("parent_pro_name");
                .groupBy("parent_pro_id");
        List<TbTransition> list = transitionService.list(wrapper);
        List<Long> parentProIds = list.stream().map(item -> item.getParentProId()).collect(Collectors.toList());
        LambdaQueryWrapper<TjProject> projectQueryWrapper = new LambdaQueryWrapper<>();
@@ -2673,6 +2711,8 @@
                tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                        sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
                remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
                List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
                xdPictureService.saveBatch(xdPictureList);
            }
        }
        if (tjFlowingWater.getPayStasus() == 1L) {
@@ -2684,6 +2724,8 @@
            tjFlowingWaterService.updateById(tjFlowingWater);
            remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
//            asyncService.addTjChargingStandard(tjOrder, transitionService.getTbTransitionListByCusId(tjCustomer.getCusIdcard(), tjOrder.getCardId()), sysUser);
            List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
            xdPictureService.saveBatch(xdPictureList);
        }
    }
@@ -3007,8 +3049,11 @@
//            }
            if (null != order.getFinishTime()) return AjaxResult.error("该人员已签离,不可撤销!!!");
            Boolean useLisAndPacsRegister = lisApiMethod.isUseLisAndPacsRegister(order);
            String s = configService.selectConfigByKey("is_request_common_his_api");
            if (null != s && s.equals("Y") && "2".equals(order.getTjType())) {
//            if (null != s && s.equals("Y") && "2".equals(order.getTjType())) {
            if (null != s && s.equals("Y") && !useLisAndPacsRegister) {
                String apiUrl = configService.selectConfigByKey("common_api_url");
                String hospbm = configService.selectConfigByKey("common_api_service_hospbm");
@@ -3045,7 +3090,7 @@
                TjCustomer customer = tjCustomerService.getById(order.getUserId());
                customer.setCardId("0");
                tjCustomerService.updateById(customer);
                xdPictureService.deleteTjXdPictureBytjNum(tjNum);
                tjSamplingMapper.deleteByTjNumAndCusId(tjNum, order.getUserId());
            }
@@ -3098,11 +3143,11 @@
        if (null != reservationTime)
            wq.between(TjReservation::getReservationTime, DateUtil.beginOfDay(reservationTime), DateUtil.endOfDay(reservationTime));
        List<TjReservation> reservationList = tjReservationService.list(wq);
        if (null != reservationList && reservationList.size() > 0) {
        if (null != reservationList && !reservationList.isEmpty()) {
            LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>();
            wq1.in(TjOrder::getReservationId, reservationList.stream().map(TjReservation::getId).collect(Collectors.toList()));
            List<TjOrder> orderList = tjOrderService.list(wq1);
            if (null != orderList && orderList.size() > 0) {
            if (null != orderList && !orderList.isEmpty()) {
                LambdaQueryWrapper<TjReservation> wq3 = new LambdaQueryWrapper<>();
                wq3.in(TjReservation::getId, orderList.stream().map(TjOrder::getReservationId).collect(Collectors.toList()));
//                    wq3.eq(TjReservation::getTeamNo,reservationList.get(0).getTeamNo());
@@ -3119,11 +3164,11 @@
    @ApiOperation(value = "根据客户体检号批量撤销体检记录")
    @Transactional
    public AjaxResult plRevokeTjOrderByTjNum(@RequestBody @ApiParam(value = "预约主键id集合") List<String> reservationIds) {
        if (null != reservationIds && reservationIds.size() > 0) {
        if (null != reservationIds && !reservationIds.isEmpty()) {
            LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>();
            wq1.in(TjOrder::getReservationId, reservationIds);
            List<TjOrder> orderList = tjOrderService.list(wq1);
            if (null != orderList && orderList.size() > 0) {
            if (null != orderList && !orderList.isEmpty()) {
                for (TjOrder order : orderList) {
//                TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
                    if (null != order) {
@@ -3281,12 +3326,12 @@
            LambdaQueryWrapper<TjProBl> wq = new LambdaQueryWrapper<>();
            wq.eq(TjProBl::getTjh, tjNum);
            List<TjProBl> blList = blService.list(wq);
            if (null != blList && blList.size() > 0) {
            if (null != blList && !blList.isEmpty()) {
                for (TjProBl bl : blList) {
                    LambdaQueryWrapper<TjOrderRemark> wqr = new LambdaQueryWrapper<>();
                    wqr.eq(TjOrderRemark::getJxbz, bl.getBldh());
                    List<TjOrderRemark> remarkList = remarkService.list(wqr);
                    if (null != remarkList && remarkList.size() > 0) {
                    if (null != remarkList && !remarkList.isEmpty()) {
                        List<Long> collect = remarkList.stream().map(TjOrderRemark::getProId).collect(Collectors.toList());
                        LambdaQueryWrapper<TjProject> wqp = new LambdaQueryWrapper<>();
                        wqp.in(TjProject::getProId, collect);
@@ -3357,7 +3402,9 @@
                }
            }
            String s = configService.selectConfigByKey("is_request_common_his_api");
            if (null != s && s.equals("Y") && "2".equals(order.getTjType())) {
            Boolean useLisAndPacsRegister = lisApiMethod.isUseLisAndPacsRegister(order);
//            if (null != s && s.equals("Y") && "2".equals(order.getTjType())) {
            if (null != s && s.equals("Y") && !useLisAndPacsRegister) {
                ArrayList<TjFlowingWater> weizhifu = new ArrayList<>();
                ArrayList<TjFlowingWater> yizhifu = new ArrayList<>();
                for (String bldh : dto.getBldhs()) {
@@ -3457,24 +3504,26 @@
                log.info("退费申请 入参 -> {}", JSONUtil.toJsonStr(map));
                String post = HttpClientUtils.sendPost(apiUrl + "/api/his/" + hospbm + "/creatCostInfo", map);
                log.info("退费申请 返回 -> {}", JSONUtil.toJsonStr(post));
                JSONObject jsonObject = JSONUtil.parseObj(post);
                if (jsonObject.getStr("code").equals("200")) {
                    // hisTfWaterId
                    String tfid = jsonObject.getJSONObject("data").getStr("feiYongId");
                    water.setHisTfWaterId(tfid);
                    tjFlowingWaterService.updateById(water);
                    if (isDelete) {
                        for (TjFlowingWater water1 : yizhifu) {
                            String bldh1 = water1.getJxbz();
                            remarkService.deleteTjOrderDetailByjxbz(bldh1);
                            tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh1);
                            tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh1);
                            transitionService.deleteTjOrderDetailByjxbz(bldh1);
                            blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, tjNum).eq(TjProBl::getBldh, bldh1));
                            tjSamplingMapper.deleteByTjNumAndCusIdAndJxbzo(tjNum, order.getUserId(), bldh1);
                if(null !=post){
                    JSONObject jsonObject = JSONUtil.parseObj(post);
                    if (jsonObject.getStr("code").equals("200")) {
                        // hisTfWaterId
                        String tfid = jsonObject.getJSONObject("data").getStr("feiYongId");
                        water.setHisTfWaterId(tfid);
                        tjFlowingWaterService.updateById(water);
                        if (isDelete) {
                            for (TjFlowingWater water1 : yizhifu) {
                                String bldh1 = water1.getJxbz();
                                remarkService.deleteTjOrderDetailByjxbz(bldh1);
                                tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh1);
                                tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh1);
                                transitionService.deleteTjOrderDetailByjxbz(bldh1);
                                blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, tjNum).eq(TjProBl::getBldh, bldh1));
                                tjSamplingMapper.deleteByTjNumAndCusIdAndJxbzo(tjNum, order.getUserId(), bldh1);
                            }
                        }
                    }
                } else return AjaxResult.error();
                    } else return AjaxResult.error();
                }
            }
        }
        return null;
@@ -3701,6 +3750,14 @@
                }
                transitionService.ttsaveTemoTransitionByGroupingId(cusId, cardId, pacId.toString());
                //补差价
                List<Map<String,Object>> cjMaps = groupingProService.huoquxiangmuchajia(pacId.toString(), cusId);
                if(null !=cjMaps && !cjMaps.isEmpty()){
                    for (Map<String, Object> cjMap : cjMaps) {
                        transitionService.buxiangmuchajia(cusId,pacId.toString(),cjMap.get("xmid").toString(),new BigDecimal(cjMap.get("cj").toString()));
                    }
                }
            }
        }
@@ -3721,5 +3778,53 @@
    }
    @GetMapping(value = "newgetTransitionList")
    @ApiOperation(value = "最新查询过渡表数据")
    public AjaxResult newgetTransitionList(@RequestParam @ApiParam(value = "客户id") String cusId) {
        List<TbTransition> list= transitionService.newgetTransitionList(cusId);
        return AjaxResult.success(list);
    }
    @PostMapping(value = "updateTransitionnewPrice")
    @ApiOperation(value = "签到登记页面根据折扣修改项目现价")
    @Transactional
    public AjaxResult updateTransitionnewPrice(@RequestBody List<UpdateTransitionnewPriceDto> dtos) {
        if(null !=dtos && !dtos.isEmpty()){
            for (UpdateTransitionnewPriceDto dto : dtos) {
                LambdaQueryWrapper<TbTransition> wq=new LambdaQueryWrapper<>();
                wq.eq(TbTransition::getCusId,dto.getCusIdCard());
                wq.eq(TbTransition::getParentProId,dto.getParentProId());
                wq.isNull(TbTransition::getTjNum);
                List<TbTransition> list = transitionService.list(wq);
                log.info("修改的客户身份证号为: "+dto.getCusIdCard());
                log.info("父项目id为: "+dto.getParentProId());
                log.info("折扣为: "+new BigDecimal(dto.getDiscount()));
                if(null !=list && !list.isEmpty()){
                    BigDecimal dxzj = transitionService.getTbTransitionPriceAndOrdPrice(dto.getCusIdCard(),dto.getParentProId());
                    for (TbTransition transition : list) {
                        BigDecimal ordPrice = transition.getOrdPrice();
                        BigDecimal multiply = ordPrice.multiply((new BigDecimal(dto.getDiscount()).divide(BigDecimal.valueOf(10))));
                        log.info("后端计算的金额: "+multiply);
                        transition.setNowPrice(multiply);
                        transition.setDiscount(new BigDecimal(dto.getDiscount()));
                        transitionService.updateById(transition);
                    }
                    if(null !=dto.getYhj() && dto.getYhj().compareTo(BigDecimal.ZERO)>=0){
                        List<TbTransition> transitionList = list.stream().filter(a ->
                                transitionService.getTbTransitionPriceAndOrdPrice(dto.getCusIdCard(),dto.getParentProId()).subtract(dto.getYhj()).compareTo(BigDecimal.ZERO) >= 0).collect(Collectors.toList());
                        if(!transitionList.isEmpty()){
                            TbTransition tbTransition = transitionList.get(0);
                            tbTransition.setNowPrice(dxzj);
                            transitionService.updateById(tbTransition);
                        }
                    }
                }
            }
        }
        return AjaxResult.success();
    }
}