zhaowenxuan
昨天 dedacd79c93f8ef95e0cb986f5e7fbd27ddbd907
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
@@ -2,31 +2,25 @@
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.symmetric.DES;
import cn.hutool.extra.pinyin.PinyinUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
@@ -34,10 +28,7 @@
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.BeanProperty;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.ltkj.common.annotation.RepeatSubmit;
@@ -54,12 +45,10 @@
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.TbTransitionMapper;
import com.ltkj.hosp.mapper.TestMapper;
import com.ltkj.hosp.mapper.TjSamplingMapper;
import com.ltkj.hosp.pacsDto.SavePacsApply;
import com.ltkj.hosp.service.*;
import com.ltkj.hosp.sqlDomain.LtkjMiddleDetail;
import com.ltkj.hosp.sqlDomain.LtkjMiddleHead;
@@ -76,24 +65,19 @@
import com.ltkj.mall.service.IMallOrderService;
import com.ltkj.system.domain.TjDjdDyjl;
import com.ltkj.system.service.*;
import com.ltkj.hosp.idutil.IdUtils;
import com.ltkj.web.controller.his.*;
import com.ltkj.web.controller.lis.LisApiMethod;
import com.ltkj.web.controller.pacs.PacsApiMethodService;
import com.ltkj.web.controller.service.TjSysAsyncServiceImpl;
import com.ltkj.web.wxUtils.HttpClientUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.aspectj.weaver.ast.Var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpRequest;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -142,8 +126,8 @@
    private ITbTransitionService transitionService;
    @Resource
    private ISysConfigService configService;
    @Value("${path.filePath}")
    private String value;
//    @Value("${path.filePath}")
//    private String value;
    @Resource
    private ITjOrderRemarkService remarkService;
    @Resource
@@ -573,13 +557,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())) {
@@ -659,82 +639,6 @@
                                     @ApiParam(value = "单位") @RequestParam(required = false) String dw,
                                     @ApiParam(value = "报告开始时间") @RequestParam(required = false) String djbeginTime,
                                     @ApiParam(value = "报告结束时间") @RequestParam(required = false) String djendTime) {
                                    /*        Map<String, Object> map = new HashMap<>();
        List<Long> cusIds = null;
        if (StringUtil.isNotBlank(name)) {
            LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
            wqq.like(TjCustomer::getCusName, name);
            cusIds = tjCustomerService.list(wqq).stream().map(TjCustomer::getCusId).collect(Collectors.toList());
        }
        Page<TjOrder> page1 = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
        if (dyzt == 0) {
            wq.isNull(TjOrder::getPrintLastTime);
            wq.eq(TjOrder::getHeshouStatus, 1);  //核收状态为1才能打印
        } else {
            wq.isNotNull(TjOrder::getPrintLastTime);
        }
        if (null != djbeginTime && null != djendTime) {
            wq.between(TjOrder::getCreateTime, DateUtil.beginOfDay(DateUtil.parseDate(djbeginTime)), DateUtil.endOfDay(DateUtil.parseDate(djendTime)));
        }
        if (null != tjNum) {
            wq.like(TjOrder::getTjNumber, tjNum);
        }
        if (StringUtil.isNotBlank(dw)) {
            wq.like(TjOrder::getFirmName, dw);
        }
        if (null != cusIds && !cusIds.isEmpty()) {
            wq.in(TjOrder::getUserId, cusIds);
        }
        wq.orderByDesc(TjOrder::getCreateTime);
        Page<TjOrder> page2 = tjOrderService.page(page1, wq);
        List<TjOrder> list = page2.getRecords();
        if (list != null) {
            for (int i = 0; i < list.size(); i++) {
                TjCustomer tjCustomer = tjCustomerService.getById(list.get(i).getUserId());
                if (null == tjCustomer) {
                    list.remove(list.get(i));
                    continue;
                }
                list.get(i).setTjCustomerSex(tjCustomer.getCusSex());
                list.get(i).setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                list.get(i).setTjCustomerName(tjCustomer.getCusName());
                list.get(i).setTjCustomerPhone(tjCustomer.getCusPhone());
                if (tjCustomer.getCusIdcard() != null) {
                    list.get(i).setTjCusIdCard(tjCustomer.getCusIdcard());
                }
                if (null != tjCustomer.getCompName()) {
                    list.get(i).setDictCompName(tjCustomer.getCompName());
                } else {
                    String firmId = list.get(i).getFirmId();
                    if (firmId != null && null != iDictCompService.getById(String.valueOf(list.get(i).getFirmId()))) {
                        list.get(i).setDictCompName(iDictCompService.getById(String.valueOf(list.get(i).getFirmId())).getCnName());
                    }
                }
                if (null != list.get(i).getPacId()) {
                    if (null != tjPackageService.getById(list.get(i).getPacId())) {
                        list.get(i).setPacName(tjPackageService.getById(list.get(i).getPacId()).getPacName());
                    }
                    if (null != dwDeptService.getById(list.get(i).getPacId())) {
                        list.get(i).setPacName(dwDeptService.getById(list.get(i).getPacId()).getDwDeptName());
                    }
                }
                //从打印记录查出最新打印时间
//                LambdaQueryWrapper<TjReportPrint> wqqq = new LambdaQueryWrapper<>();
//                wqqq.eq(TjReportPrint::getTjNumber, list.get(i).getTjNumber());
//                wqqq.orderByDesc(TjReportPrint::getPrintTime);
//                wqqq.last("limit 1");
//                TjReportPrint one = tjReportPrintService.getOne(wqqq);
//                if (one != null) {
//                    list.get(i).setPrintLastTime(one.getPrintTime());
//                }
            }
        }
        map.put("list", list);
        map.put("total", page2.getTotal());*/
        if (djbeginTime == null) djbeginTime = "";
        if (djendTime == null) djendTime = "";
        Map<String, Object> map = tjOrderService.getTjBgdyList(pageNum, pageSize, dyzt, tjNum, name, dw, djbeginTime, djendTime);
@@ -937,16 +841,236 @@
    }
    /**
     * 导出体检记录列表
     */
//    @PreAuthorize("@ss.hasPermi('hosp:order:export')")
    @Log(title = "体检记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @PostMapping("/exportOrderList")
    @ApiOperation(value = "导出体检记录列表")
    public void export(HttpServletResponse response, TjOrder tjOrder) {
        //List<TjOrder> list = tjOrderService.selectTjOrderList(tjOrder);
        List<TjOrder> list = tjOrderService.selectExportOrderList(tjOrder);
    public void exportOrderList(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer pageNum,
                                   @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize,
                                   @ApiParam(value = "状态") @RequestParam(required = false) Integer zt,
                                   @ApiParam(value = "体检号)") @RequestParam(required = false) String tjNum,
                                   @ApiParam(value = "姓名)") @RequestParam(required = false) String name,
                                   @ApiParam(value = "项目名)") @RequestParam(required = false) String xmmc,
                                   @ApiParam(value = "登记开始时间") @RequestParam(required = false) Date djbeginTime,
                                   @ApiParam(value = "登记结束时间") @RequestParam(required = false) Date djendTime,
                                   @ApiParam(value = "报告开始时间") @RequestParam(required = false) Date bgbeginTime,
                                   @ApiParam(value = "报告结束时间") @RequestParam(required = false) Date bgendTime,
                                   @ApiParam(value = "单位") @RequestParam(required = false) String dw,
                                   @ApiParam(value = "当前页或全部数据") @RequestParam(required = false) String dqyorqbsj,
                                   HttpServletResponse response) {
        List<Long> cusIds = null;
        if (null != name) {
            LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
            wqq.like(TjCustomer::getCusName, name);
            cusIds = tjCustomerService.list(wqq).stream().map(TjCustomer::getCusId).collect(Collectors.toList());
        }
        Page<TjOrder> page1 = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
        if (null != djbeginTime && null != djendTime) {
            wq.between(TjOrder::getCreateTime, DateUtil.beginOfDay(djbeginTime), DateUtil.endOfDay(djendTime));
        }
        if (null != bgbeginTime && null != bgendTime) {
            wq.between(TjOrder::getCreateTime, DateUtil.beginOfDay(bgbeginTime), DateUtil.endOfDay(bgendTime));
        }
        if (null != tjNum) {
            wq.eq(TjOrder::getTjNumber, tjNum);
        }
        if (null != xmmc) {
            wq.in(TjOrder::getTjNumber, projectService.getTjNumLIstByXmmx(xmmc));
        }
        if (StrUtil.isNotBlank(dw)) {
            wq.like(TjOrder::getFirmName, dw);
        }
        if (null != cusIds && !cusIds.isEmpty()) {
            wq.in(TjOrder::getUserId, cusIds);
        }
        if (null != zt && (zt == 0 || zt == 1 || zt == 2)) {
            List<TjOrder> orders = new ArrayList<>();
            List<TjOrder> tjOrders = null;
            List<TjOrder> orderList = tjOrderService.list(wq);
            if (null != orderList && !orderList.isEmpty()) {
                for (TjOrder order : orderList) {
                    int czwj = remarkService.panduaniscunzaiweijian(order.getTjNumber());
                    int sfwc = remarkService.panduaniswancheng(order.getTjNumber());
                    if (zt == 0 && czwj == 0) {
                        //未检0
                        order.setZt("未检");
                        orders.add(order);
                    }
                    if (zt == 1 && czwj > 0) {
                        //在检1
                        order.setZt("在检");
                        orders.add(order);
                    }
                    if (zt == 2 && sfwc == 0 && order.getCheckStatus() == 0 && order.getCheckTime() == null && order.getHeshouStatus() == 0 && order.getPrintLastTime() == null) {
                        //已完成2
                        order.setZt("已完成");
                        orders.add(order);
                    }
                }
                if (!orders.isEmpty()) {
                    tjOrders = orders.stream().sorted(Comparator.comparing(TjOrder::getCreateTime).reversed())
                            .skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
                    for (TjOrder order : tjOrders) {
                        TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                        if (null != tjCustomer) {
                            order.setTjCustomerSex(tjCustomer.getCusSex());
                            order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                            order.setTjCustomerName(tjCustomer.getCusName());
                            order.setTjCustomerPhone(tjCustomer.getCusPhone());
                            order.setTjCusIdCard(tjCustomer.getCusIdcard());
                            order.setCareer(tjCustomer.getCareer());
                            order.setIdType(tjCustomer.getIdType());
                            order.setAgeUnit(tjCustomer.getAgeUnit());
                            order.setTjCount(String.valueOf(tjCustomer.getCusNumber()));
                            String firmName = order.getFirmName();
                            if (StringUtil.isNotBlank(firmName)) {
                                order.setDictCompName(firmName);
                            }
                            if (null != order.getPacId()) {
                                if (null != tjPackageService.getById(order.getPacId())) {
                                    order.setPacName(tjPackageService.getById(order.getPacId()).getPacName());
                                } else if (null != dwDeptService.getById(order.getPacId())) {
                                    order.setPacName(dwDeptService.getById(order.getPacId()).getDwDeptName());
                                }
                            }
                            TjDjdDyjl dycs = djdDyjlService.getDjdDyCsByTjNum(order.getTjNumber());
                            if (null != dycs) order.setDycs(Math.toIntExact(dycs.getDycs()));
                        }
                    }
                }
            }
            ExcelUtil<TjOrder> util = new ExcelUtil<TjOrder>(TjOrder.class);
            util.exportExcel(response, tjOrders, "体检记录数据");
        }
        if (null != zt) {
            if (zt == 3) {
                //已审核
                wq.isNotNull(TjOrder::getCheckTime);
                wq.eq(TjOrder::getCheckStatus, 1);
                wq.isNull(TjOrder::getHeshouTime);
                wq.isNull(TjOrder::getPrintLastTime);
                wq.eq(TjOrder::getHeshouStatus, 0);
            }
            if (zt == 4) {
                //生成报告
                wq.isNotNull(TjOrder::getReportTime);
                wq.isNull(TjOrder::getHeshouTime);
                wq.isNull(TjOrder::getPrintLastTime);
                wq.eq(TjOrder::getHeshouStatus, 0);
            }
            if (zt == 5) {
                //报告核收
                wq.eq(TjOrder::getHeshouStatus, 1);
                wq.isNull(TjOrder::getPrintLastTime);
            }
            if (zt == 6) {
                //已打印
                wq.isNotNull(TjOrder::getPrintLastTime);
                wq.eq(TjOrder::getHeshouStatus, 1);
                wq.isNotNull(TjOrder::getPrintLastTime);
            }
        }
        wq.orderByDesc(TjOrder::getCreateTime);
        List<TjOrder> list =null;
        if(StringUtil.isNotBlank(dqyorqbsj) && dqyorqbsj.equals("1")){
            list = tjOrderService.list(wq);
        }else {
            Page<TjOrder> page2 = tjOrderService.page(page1, wq);
            list = page2.getRecords();
        }
        if (!list.isEmpty()) {
            for (TjOrder order : list) {
                TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                if (null != tjCustomer) {
                    order.setTjCustomerSex(tjCustomer.getCusSex());
                    order.setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                    order.setTjCustomerName(tjCustomer.getCusName());
                    order.setTjCustomerPhone(tjCustomer.getCusPhone());
                    order.setTjCusIdCard(tjCustomer.getCusIdcard());
                    order.setCareer(tjCustomer.getCareer());
                    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());
                        }
                    }
                    if (null != order.getPacId()) {
                        if (null != tjPackageService.getById(order.getPacId())) {
                            order.setPacName(tjPackageService.getById(order.getPacId()).getPacName());
                        } else if (null != dwDeptService.getById(order.getPacId())) {
                            order.setPacName(dwDeptService.getById(order.getPacId()).getDwDeptName());
                        }
                    }
                    TjDjdDyjl dycs = djdDyjlService.getDjdDyCsByTjNum(order.getTjNumber());
                    if (null != dycs) order.setDycs(Math.toIntExact(dycs.getDycs()));
                }
                int czwj = remarkService.panduaniscunzaiweijian(order.getTjNumber());
                int sfwc = remarkService.panduaniswancheng(order.getTjNumber());
                Date checkTime = order.getCheckTime();
                Date reportTime = order.getReportTime();
                Integer heshouStatus = order.getHeshouStatus();
                Date lastTime = order.getPrintLastTime();
                if (null != zt) {
                    if (zt == 3) {
                        order.setZt("已审核");
                    }
                    if (zt == 4) {
                        order.setZt("生成报告");
                    }
                    if (zt == 5) {
                        order.setZt("报告核收");
                    }
                    if (zt == 6) {
                        order.setZt("已打印");
                    }
                } else {
                    if (czwj == 0) {
                        //未检0
                        order.setZt("未检");
                    }
                    if (czwj > 0) {
                        //在检1
                        order.setZt("在检");
                    }
                    if (sfwc == 0) {
                        //已完成2
                        order.setZt("已完成");
                    }
                    if (null != checkTime) {
                        //已审核3
                        order.setZt("已审核");
                    }
                    if (null != reportTime) {
                        //生成报告4
                        order.setZt("生成报告");
                    }
                    if (1 == heshouStatus) {
                        //报告核收5
                        order.setZt("报告核收");
                    }
                    if (null != lastTime) {
                        //已打印6
                        order.setZt("已打印");
                    }
                }
            }
        }
        ExcelUtil<TjOrder> util = new ExcelUtil<TjOrder>(TjOrder.class);
        util.exportExcel(response, list, "体检记录数据");
    }
@@ -1032,8 +1156,9 @@
            if (null != tjReservation.getPacId()) tjOrder.setPacId(tjReservation.getPacId());
            if (null != tjReservation.getTjCategory()) tjOrder.setTjCategory(tjReservation.getTjCategory());
            if (null != tjReservation.getGroupingId()) {
                TjDwGrouping dwGrouping = dwGroupingService.getById(tjReservation.getGroupingId());
                tjOrder.setGroupId(tjReservation.getGroupingId());
                tjOrder.setFirmDeptId(tjReservation.getPacId());
                tjOrder.setFirmDeptId(dwGrouping.getDwDeptId());
            }
            tjReservation.setIsExpire(1);
            tjReservationService.updateById(tjReservation);
@@ -1047,7 +1172,7 @@
            tjOrder.setFirmId("0");
        }
        if (null != tjOrder.getPhoto()) {
        if (StringUtil.isNotBlank(tjOrder.getPhoto())) {
            File file = new File(tjOrder.getPhoto());
            if (file.isFile()) {
                FileInputStream fileInputStream = new FileInputStream(file);
@@ -1059,10 +1184,10 @@
                tjOrder.setPhoto(encode);
            }
        }
        String pacId = transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjCustomer.getCusIdcard()));
        if (null == tjOrder.getPacId() && null != transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId()))) {
            tjOrder.setPacId(transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId())));
        if (StringUtil.isNotBlank(tjOrder.getPacId()) && StringUtil.isNotBlank(pacId) ) {
            tjOrder.setPacId(pacId);
        }
        //判断小程序上预约是否付钱
        if (null != mallOrder) tjOrder.setMallOrderId(String.valueOf(mallOrder.getId()));
@@ -1072,7 +1197,6 @@
            tjOrder.setFinishTime(new Date());
            tjOrder.setCheckStatus(1);
            tjOrder.setStatus(TjConstants.TJ_WAIT);
            //            tjFlowingWater.setPayStasus(1L);
        }
        tjFlowingWater.setPayStasus(0L);
@@ -1086,6 +1210,7 @@
                return result;
            }
        }catch (Exception e){
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            log.error(String.valueOf(e));
        }
        finally {
@@ -1094,7 +1219,8 @@
        return AjaxResult.error();
    }
    @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
//    @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
    @Transactional(propagation = Propagation.REQUIRED) // 共享事务
    public AjaxResult processOrderWithTransaction(TjOrder tjOrder, TjCustomer tjCustomer, TjReservation tjReservation, TjFlowingWater tjFlowingWater, MallOrder mallOrder, SysUser sysUser) {
        //获取拼接前缀
@@ -1107,10 +1233,38 @@
        //生成体检号
//        String tjNumber = (SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
//        if(StringUtil.isNotBlank(makeLisTmhPrefix)) tjNumber=makeLisTmhPrefix+tjNumber;
//        String tjNumber = (SecurityUtils.getUsername() + idUtils.getTjNumber());
//        String tjNumber = idUtils.getTjNumber();
        String tjNumber = null;
        int a =0;
        while (tjNumber ==null){
            if(a>3){
                throw new RuntimeException("前方拥挤,请稍等!!!");
            }
            try {
                String newTjNumberRedisLockAndMysql = idUtils.getNewTjNumberRedisLockAndMysql();
                if (StringUtil.isNotBlank(makeLisTmhPrefix)){
                 String tjh=  makeLisTmhPrefix + newTjNumberRedisLockAndMysql;
                 int countByTjNum = tjOrderService.getOrderCountByTjNum(tjh);
                 if(countByTjNum==0){
                     tjNumber=tjh;
                 }
                }else {
                    int countByTjNum = tjOrderService.getOrderCountByTjNum(newTjNumberRedisLockAndMysql);
                    if(countByTjNum==0){
                        tjNumber=newTjNumberRedisLockAndMysql;
                    }
                }
            } catch (Exception e) {
                log.error(e.getMessage());
            }finally {
                a++;
            }
        }
        String tjNumber = (SecurityUtils.getUsername() + idUtils.getTjNumber());
        if (StringUtil.isNotBlank(makeLisTmhPrefix)) tjNumber = makeLisTmhPrefix + tjNumber;
        if(StringUtil.isBlank(tjNumber)) return AjaxResult.error("登记失败 重新操作");
        tjOrder.setTjNumber(tjNumber);
@@ -1215,6 +1369,23 @@
            /*调用his接口*/
            String config = configService.selectConfigByKey("sfkqdyhis");
            if (null != config && config.equals("Y")) {
                if(tjCustomer.getPationId().equals("0")){
                    AjaxResult result = controller.Outpincreateapply(tjCustomer);
                    String result1 = getAjaxResult(result);
                    JSONObject object = getJSONObject(result1);
                    String code = object.getStr("ResultCode");
                    if (code.equals("0")) {
                        JSONArray resultDatass = object.getJSONArray("ResultData");
                        Map<String, Object> resultData = (Map<String, Object>) resultDatass.get(0);
                        if (null != resultData && !resultData.isEmpty()) {
                            String pationid = resultData.get("PationId").toString();
                            if (null != pationid) {
                                tjCustomer.setPationId(pationid);
                                tjCustomerService.updateById(tjCustomer);
                            }
                        }
                    }
                }
                AjaxResult result = hisApiMethod.HisApiMethods(tjCustomer, tjOrder);
                if (!result.get("code").toString().equals("200")) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -1223,45 +1394,39 @@
                        hisApiMethod.ZfHisApiMethod(jzh.toString());
                    }
                    log.info("该登记人挂号失败, 就诊号为: " + tjOrder.getCardId());
                    return AjaxResult.error("挂号失败!" + result.get("msg").toString());
                    throw new IllegalStateException("挂号失败!" + result.get("msg").toString());
                }
                log.info("该登记人的his就诊号是: " + tjOrder.getCardId());
                //团体
/*                if ("1".equals(tjOrder.getTjType())) {
//                            asyncService.ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
                    ttextracted(tjOrder, tjCustomer, sysUser, tjReservation, tjFlowingWater);
                }*/
                //个人
         /*       if ("2".equals(tjOrder.getTjType())) {
                    //asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                    newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                }*/
                // 查询 对接Lis、Pacs申请如果类型包含在配置内则使用对接lis、pacs
                if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) {
                    log.info("调用his开启 进入不收费方法 该体检人员不收费:"+tjOrder.getTjNumber());
                    // 这是上面个人方法引入数据
                    tjFlowingWater.setPayStasus(1L);
                    newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                    AjaxResult ajaxResult = hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder, sysUser, result);
                    if (!ajaxResult.get("code").toString().equals("200")) return ajaxResult;
                    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);
                    log.info("调用his开启 进入不收费方法 该方法执行完毕");
                } else {
                    log.info("调用his开启 进入收费方法 该体检人员不收费:"+tjOrder.getTjNumber());
                    newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                    List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
                    addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
                    String isUseMx = configService.selectConfigByKey("jcxhis_is_use_mx");
                    if (isUseMx.equalsIgnoreCase("Y"))
                        hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId());
                    else hisApiMethod.tijianshenqingJinchuanNew(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId());
                try {
                    if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) {
                        log.info("调用his开启 进入不收费方法 该体检人员不收费:"+tjOrder.getTjNumber());
                        // 这是上面个人方法引入数据
                        tjFlowingWater.setPayStasus(1L);
                        newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                        AjaxResult ajaxResult = hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder, sysUser, result);
                        if (!ajaxResult.get("code").toString().equals("200")) return ajaxResult;
                        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);
                        log.info("调用his开启 进入不收费方法 该方法执行完毕");
                    } else {
                        log.info("调用his开启 进入收费方法 该体检人员收费:"+tjOrder.getTjNumber());
                        newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                        List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
                        addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
                        String isUseMx = configService.selectConfigByKey("jcxhis_is_use_mx");
                        if (isUseMx.equalsIgnoreCase("Y"))
                            hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId());
                        else hisApiMethod.tijianshenqingJinchuanNew(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId());
                    }
                } catch (Exception e) {
                    log.error("发生错误 ->{}"+String.valueOf(e),e.getMessage());
                    throw new IllegalStateException();
                }
                return AjaxResult.success(tjNumber);
            } else {
@@ -1360,24 +1525,35 @@
            log.info("签到登记接口该人员: "+tjOrder.getTjNumber()+" 的体检类型是:"+tjOrder.getTjType());
            if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) {
                log.info(tjOrder.getTjNumber()+"签到登记进入未收费方法");
                // 这是上面个人方法引入数据
                tjFlowingWater.setPayStasus(1L);
                newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                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());
                log.info(tjOrder.getTjNumber()+"签到登记:采样数据查询个数"+detailList.size());
                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
                return AjaxResult.success(tjNumber);
                try {
                    log.info(tjOrder.getTjNumber()+"签到登记进入未收费方法");
                    // 这是上面个人方法引入数据
                    tjFlowingWater.setPayStasus(1L);
                    newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                    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());
                    log.info(tjOrder.getTjNumber()+"签到登记:采样数据查询个数"+detailList.size());
                    addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
                    return AjaxResult.success(tjNumber);
                } catch (Exception e) {
                    log.error(e.getMessage());
                    throw new IllegalStateException(e);
                }
            } else {
                log.info(tjOrder.getTjNumber()+"else签到登记进入收费方法");
                newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                AjaxResult error = isRequestCommonHisApi(tjOrder, tjCustomer, tjFlowingWater);
                if (error != null) return error;
                try {
                    log.info(tjOrder.getTjNumber()+"else签到登记进入收费方法");
                    newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                    isRequestCommonHisApi(tjOrder, tjCustomer, tjFlowingWater);
                } catch (Exception e) {
                    log.error("processOrderWithTransaction 方法异常"+e.getMessage());
                    throw new RuntimeException("调用公共方法失败 强制触发回滚");
//                    return AjaxResult.error();
                }
//                if (error != null) return error;
//                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
//                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
            }
@@ -1386,11 +1562,12 @@
//            pacsApiMethodService.OrderAdd(tjCustomer,tjOrder);
//            return AjaxResult.success(tjNumber);
        }
        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        return AjaxResult.error();
//        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        throw new RuntimeException("体检记录保存失败 强制触发回滚");
    }
    private AjaxResult isRequestCommonHisApi(TjOrder tjOrder, TjCustomer tjCustomer, TjFlowingWater tjFlowingWater) {
    @Transactional(propagation = Propagation.REQUIRED) // 共享事务
    public void 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");
@@ -1452,95 +1629,104 @@
                }
                tjFlowingWaterService.updateById(tjFlowingWater);
            } else {
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return AjaxResult.error();
//                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                log.error("isRequestCommonHisApi 方法异常");
                throw new RuntimeException("is_request_common_his_api 强制触发回滚");
//                return AjaxResult.error();
            }
        }
        return null;
//        return null;
    }
    @Transactional(propagation = Propagation.REQUIRED) // 共享事务
    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");
            for (TjOrderDetail detail : detailList) {
                TjSampling sampling = new TjSampling();
                if (null == projectService.getById(detail.getProId())) continue;
                TjProject project = projectService.getById(detail.getProId());
                Long proParentId = project.getProParentId();
                String dictLabel = sysDictDataService.selectDictLabel("sys_dict_specimen", project.getSpecimenType());
                if (null != proParentId && proParentId == 0) {
                    sampling.setJyxh(idUtils.generateLisID(lis_tmh_prefix));
                    sampling.setSpecimenTypeCode(project.getSpecimenType());
                    sampling.setSpecimenType(dictLabel);
                    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(lis_tmh_prefix));
                    sampling.setSpecimenTypeCode(project1.getSpecimenType());
                    sampling.setSpecimenType(dictLabel);
                    if (config.equals("Y") && lisAndPacsRegister)
                        sampling.setJyxmdm(project1.getLisXmbm());
                    else sampling.setJyxmdm(project1.getProId().toString());
                }
                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(date);
                sampling.setTjTime(order.getCreateTime());
                sampling.setProId(String.valueOf(detail.getProId()));
                sampling.setProName(projectService.getById(detail.getProId()).getProName());
                sampling.setCreateBy(sysUser.getNickName());
                sampling.setCreateTime(date);
                sampling.setUpdateBy(sysUser.getNickName());
                sampling.setUpdateTime(date);
                sampling.setCreateId(String.valueOf(sysUser.getUserId()));
                sampling.setUpdateId(String.valueOf(sysUser.getUserId()));
                sampling.setJxbz(jxbz);
                samplingService.save(sampling);
            }
        }
        if (lisApiMethod.isUseLisAndPacsRegister(order) && (null != config && config.equals("Y"))) {
            AjaxResult ajaxResult = lisApiMethod.getJyFlHb();
            if (ajaxResult.get("code").toString().equals("200")) {
                String str = ajaxResult.get("data").toString();
                str = str.replace("=", ":");
                JSONArray array = JSONUtil.parseArray(str);
                for (Object o : array) {
                    JSONObject object = (JSONObject) o;
                    LisJyflhb lisJyflhb = new LisJyflhb();
                    lisJyflhb.setHbhxm(object.getStr("hbhxm"));
                    lisJyflhb.setFlmc(object.getStr("flmc"));
                    lisJyflhb.setMc(object.getStr("mc"));
                    lisJyflhb.setFlbm(object.getStr("flbm"));
                    LambdaQueryWrapper<LisJyflhb> wrapper = new LambdaQueryWrapper<>();
                    wrapper.eq(LisJyflhb::getFlbm, lisJyflhb.getFlbm());
                    LisJyflhb jyflhb = lisJyflhbService.getOne(wrapper);
                    if (jyflhb == null) {
                        lisJyflhb.setId(IdUtil.getSnowflake().nextId());
                        lisJyflhbService.save(lisJyflhb);
        try {
            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");
                for (TjOrderDetail detail : detailList) {
                    int i = samplingService.isExistProId(order.getTjNumber(), String.valueOf(detail.getProId()));
                    if(i>0) continue;
                    TjSampling sampling = new TjSampling();
                    if (null == projectService.getById(detail.getProId())) continue;
                    TjProject project = projectService.getById(detail.getProId());
                    Long proParentId = project.getProParentId();
                    String dictLabel = sysDictDataService.selectDictLabel("sys_dict_specimen", project.getSpecimenType());
                    if (null != proParentId && proParentId == 0) {
                        sampling.setJyxh(idUtils.generateLisID(lis_tmh_prefix));
                        sampling.setSpecimenTypeCode(project.getSpecimenType());
                        sampling.setSpecimenType(dictLabel);
                        if (config.equals("Y") && lisAndPacsRegister)
                            sampling.setJyxmdm(project.getLisXmbm());
                        else sampling.setJyxmdm(project.getProId().toString());
                    } else {
                        lisJyflhb.setId(jyflhb.getId());
                        lisJyflhbService.updateById(lisJyflhb);
                        TjProject project1 = projectService.getById(proParentId);
                        sampling.setJyxh(idUtils.generateLisID(lis_tmh_prefix));
                        sampling.setSpecimenTypeCode(project1.getSpecimenType());
                        sampling.setSpecimenType(dictLabel);
                        if (config.equals("Y") && lisAndPacsRegister)
                            sampling.setJyxmdm(project1.getLisXmbm());
                        else sampling.setJyxmdm(project1.getProId().toString());
                    }
                    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(date);
                    sampling.setTjTime(order.getCreateTime());
                    sampling.setProId(String.valueOf(detail.getProId()));
                    sampling.setProName(projectService.getById(detail.getProId()).getProName());
                    sampling.setCreateBy(sysUser.getNickName());
                    sampling.setCreateTime(date);
                    sampling.setUpdateBy(sysUser.getNickName());
                    sampling.setUpdateTime(date);
                    sampling.setCreateId(String.valueOf(sysUser.getUserId()));
                    sampling.setUpdateId(String.valueOf(sysUser.getUserId()));
                    sampling.setJxbz(jxbz);
                    samplingService.save(sampling);
                }
            }
            if (lisApiMethod.isUseLisAndPacsRegister(order) && (null != config && config.equals("Y"))) {
                AjaxResult ajaxResult = lisApiMethod.getJyFlHb();
                if (ajaxResult.get("code").toString().equals("200")) {
                    String str = ajaxResult.get("data").toString();
                    str = str.replace("=", ":");
                    JSONArray array = JSONUtil.parseArray(str);
                    for (Object o : array) {
                        JSONObject object = (JSONObject) o;
                        LisJyflhb lisJyflhb = new LisJyflhb();
                        lisJyflhb.setHbhxm(object.getStr("hbhxm"));
                        lisJyflhb.setFlmc(object.getStr("flmc"));
                        lisJyflhb.setMc(object.getStr("mc"));
                        lisJyflhb.setFlbm(object.getStr("flbm"));
                        LambdaQueryWrapper<LisJyflhb> wrapper = new LambdaQueryWrapper<>();
                        wrapper.eq(LisJyflhb::getFlbm, lisJyflhb.getFlbm());
                        LisJyflhb jyflhb = lisJyflhbService.getOne(wrapper);
                        if (jyflhb == null) {
                            lisJyflhb.setId(IdUtil.getSnowflake().nextId());
                            lisJyflhbService.save(lisJyflhb);
                        } else {
                            lisJyflhb.setId(jyflhb.getId());
                            lisJyflhbService.updateById(lisJyflhb);
                        }
                    }
                }
            }
        }
        if (StrUtil.isNotBlank(jxbz)) {
            tjSamplingMapper.updateUserIdByTjNumAndJxbz(order.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), jxbz);
        } else {
            tjSamplingMapper.updateUserIdByTjNum(order.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
            }
            if (StrUtil.isNotBlank(jxbz)) {
                tjSamplingMapper.updateUserIdByTjNumAndJxbz(order.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), jxbz);
            } else {
                tjSamplingMapper.updateUserIdByTjNum(order.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
            }
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }
@@ -1578,12 +1764,17 @@
        if (null != cusIds && !cusIds.isEmpty()) {
            ExecutorService threadPools = Executors.newFixedThreadPool(cusIds.size());
            for (String cusId : cusIds) {
                threadPools.execute(new Runnable() {
                    @Override
                    public void run() {
                        getAjaxResults(cusId);
                    }
                });
//                threadPools.execute(new Runnable() {
//                    @Override
//                    public void run() {
                        try {
                            getAjaxResults(cusId);
                        } catch (Exception e) {
                        }
//                    }
//                });
            }
            LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
            wq.in(TjCustomer::getCusIdcard, cusIds);
@@ -1628,73 +1819,12 @@
                threadPools.shutdown();
            }
            // TODO 因为有体检号会查出空数据 先使用死数据  打印导诊单
            Map<String,Object> map=new HashMap<>();
            if (!tjNumbers.isEmpty()) {
            /*    Map<String, Object> map = null;
                try {
                    map = PDFDocumentUtil.getDocument();
                    Document document = (Document) map.get("document");
//                    for (int i = 0; i < tjNumbers.size(); i++) {
                    int i = 0;
                    for (String tjNumber : tjNumbers) {
                        try {
                            List<Map<String, Object>> djdInfos = tjOrderService.selectDjdInfo(tjNumber);
                            Map<String, Object> userInfo = tjOrderService.selectDjdUserInfo(tjNumber);
                            if(null !=userInfo && null !=djdInfos && !djdInfos.isEmpty()){
                                LocalDateTime tjsj = (LocalDateTime) userInfo.get("tjsj");
                                DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
                                String time = null;
                                if (tjsj != null) {
                                    time = dateFormat.format(tjsj);
                                }
                                PDFDocumentUtil.makeUserInfoTable(document, (String) userInfo.get("tjname"), (String) userInfo.get("sex")
                                        , (String) userInfo.get("tjh"), (String) userInfo.get("lxdh"), (String) userInfo.get("tjname"), time);
                                PDFDocumentUtil.makeTjInfo(document, djdInfos);
                                // 多条则换页
                                if (i + 1 < tjNumbers.size()) {
                                    document.newPage();
                                }
                            }
                        } catch (DocumentException | IOException e) {
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                            //这里删除的是这个人所有项目包括补录项目
                            TjOrder order = tjOrderService.getOrderByTjNum(tjNumber);
                            tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
                            tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
                            remarkService.deletedOrderRemarkByTjNum(tjNumber);
                            tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
//                transitionService.deletedTbTransitionByTjNum(tjNum);
                            tjSamplingMapper.deleteByTjNumAndCusId(order.getTjNumber(), order.getUserId());
                            TjReservation reservation = tjReservationService.getById(order.getReservationId());
                            if(null !=reservation){
                                reservation.setIsExpire(2);
                                tjReservationService.updateById(reservation);
                                transitionService.updateTbTransitionByTjNum(tjNumber);
                            }
                            e.printStackTrace();
                        }
                    }
//                    }
                    document.close();
                    ByteArrayOutputStream outputStream = (ByteArrayOutputStream) map.get("stream");
                    String encodeToString = java.util.Base64.getEncoder().encodeToString(outputStream.toByteArray());
                    return AjaxResult.success().put("file", encodeToString);
                } catch (IOException | DocumentException e) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    e.printStackTrace();
                }*/
                Map<String,Object> map=new HashMap<>();
                map.put("tjh",tjNumbers);
                return AjaxResult.success("操作成功",map);
            }
            if (!errTjh.isEmpty()){
                Map<String,Object> map=new HashMap<>();
                map.put("errtjh",errTjh);
                return AjaxResult.success("以上人员签到失败",map);
            }
            return AjaxResult.success();
            map.put("errtjh",errTjh);
            return AjaxResult.success("操作成功",map);
        }
//        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        return AjaxResult.error();
@@ -1773,51 +1903,59 @@
                    tjReservationService.updateById(tjReservation);
//                    return AjaxResult.error("对不起您的预约已超时请重新预约");
                }*/
                LambdaQueryWrapper<TjCustomer> qw = new LambdaQueryWrapper<>();
                qw.eq(TjCustomer::getCusIdcard, cusIdcard);
                TjCustomer tjCustomer1 = tjCustomerService.getOne(qw);
                if (tjCustomer1 != null) {
                    tjCustomer1.setTjType(tjReservation.getTjType());
                    tjCustomer1.setCusName(tjReservation.getName());
                    tjCustomer1.setCusSex(Long.valueOf(tjReservation.getSex()));
                    tjCustomer1.setCusBrithday(tjReservation.getBirthday());
                    tjCustomer1.setCusPhone(tjReservation.getPhoe());
                    tjCustomer1.setCusEmail(tjReservation.getEmail());
                    tjCustomer1.setCusAddr(tjReservation.getAddress());
                    tjCustomer1.setCusMarryStatus(String.valueOf(tjReservation.getMarriage()));
                    tjCustomer1.setCusNational(String.valueOf(tjReservation.getNation()));
                    tjCustomer1.setIdType(tjReservation.getIdType());
                    tjCustomer1.setAge(tjReservation.getAge());
                    tjCustomer1.setAgeUnit(tjReservation.getAgeUnit());
                    tjCustomer1.setCareer(tjReservation.getCareer());
                    tjCustomerService.updateById(tjCustomer1);
                } else {
                    TjCustomer tjCustomer = new TjCustomer();
                    tjCustomer.setCusIdcard(tjReservation.getIdCard());
                    tjCustomer.setCusName(tjReservation.getName());
                    tjCustomer.setCusSex(Long.valueOf(tjReservation.getSex()));
                    tjCustomer.setCusBrithday(tjReservation.getBirthday());
                    tjCustomer.setCusPhone(tjReservation.getPhoe());
                    tjCustomer.setCusEmail(tjReservation.getEmail());
                    tjCustomer.setCusAddr(tjReservation.getAddress());
                    tjCustomer.setCusMarryStatus(String.valueOf(tjReservation.getMarriage()));
                    tjCustomer.setCusNational(String.valueOf(tjReservation.getNation()));
                    tjCustomer.setIdType(tjReservation.getIdType());
                    tjCustomer.setAge(tjReservation.getAge());
                    tjCustomer.setAgeUnit(tjReservation.getAgeUnit());
                    tjCustomer.setCareer(tjReservation.getCareer());
                    tjCustomer.setDwPhone(tjReservation.getDwPhone());
                    tjCustomer.setCardId(tjReservation.getCardId());
                    tjCustomer.setIndexCard(tjReservation.getIndexCard());
                    //截取密码自动生成set进去
                    String substring = cusIdcard.substring(cusIdcard.length() - 6);
                    substring = DigestUtils.md5DigestAsHex(substring.getBytes());
                    tjCustomer.setCusPassword(substring);
                    tjCustomer.setTjType(tjReservation.getTjType());
                    tjCustomerService.save(tjCustomer);
                try {
                    LambdaQueryWrapper<TjCustomer> qw = new LambdaQueryWrapper<>();
                    qw.eq(TjCustomer::getCusIdcard, cusIdcard);
                    TjCustomer tjCustomer1 = tjCustomerService.getOne(qw);
                    if (tjCustomer1 != null) {
                        tjCustomer1.setTjType(tjReservation.getTjType());
                        tjCustomer1.setCusName(tjReservation.getName());
                        tjCustomer1.setCusSex(Long.valueOf(tjReservation.getSex()));
                        tjCustomer1.setCusBrithday(tjReservation.getBirthday());
                        tjCustomer1.setCusPhone(tjReservation.getPhoe());
                        tjCustomer1.setCusEmail(tjReservation.getEmail());
                        tjCustomer1.setCusAddr(tjReservation.getAddress());
                        tjCustomer1.setCusMarryStatus(String.valueOf(tjReservation.getMarriage()));
                        tjCustomer1.setCusNational(String.valueOf(tjReservation.getNation()));
                        tjCustomer1.setIdType(tjReservation.getIdType());
                        tjCustomer1.setAge(tjReservation.getAge());
                        tjCustomer1.setAgeUnit(tjReservation.getAgeUnit());
                        tjCustomer1.setCareer(tjReservation.getCareer());
                        tjCustomerService.updateById(tjCustomer1);
                    } else {
                        TjCustomer tjCustomer = new TjCustomer();
                        tjCustomer.setCusIdcard(tjReservation.getIdCard());
                        tjCustomer.setCusName(tjReservation.getName());
                        tjCustomer.setCusSex(Long.valueOf(tjReservation.getSex()));
                        tjCustomer.setCusBrithday(tjReservation.getBirthday());
                        tjCustomer.setCusPhone(tjReservation.getPhoe());
                        tjCustomer.setCusEmail(tjReservation.getEmail());
                        tjCustomer.setCusAddr(tjReservation.getAddress());
                        tjCustomer.setCusMarryStatus(String.valueOf(tjReservation.getMarriage()));
                        tjCustomer.setCusNational(String.valueOf(tjReservation.getNation()));
                        tjCustomer.setIdType(tjReservation.getIdType());
                        tjCustomer.setAge(tjReservation.getAge());
                        tjCustomer.setAgeUnit(tjReservation.getAgeUnit());
                        tjCustomer.setCareer(tjReservation.getCareer());
                        tjCustomer.setDwPhone(tjReservation.getDwPhone());
                        tjCustomer.setCardId(tjReservation.getCardId());
                        tjCustomer.setIndexCard(tjReservation.getIndexCard());
                        //截取密码自动生成set进去
                        String substring = cusIdcard.substring(cusIdcard.length() - 6);
                        substring = DigestUtils.md5DigestAsHex(substring.getBytes());
                        tjCustomer.setCusPassword(substring);
                        tjCustomer.setTjType(tjReservation.getTjType());
                        tjCustomerService.save(tjCustomer);
                    }
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }else {
                throw new RuntimeException();
            }
        }else {
            throw new RuntimeException();
        }
    }
@@ -1909,7 +2047,9 @@
            //获取拼接前缀
            String makeLisTmhPrefix = configService.selectConfigByKey("make_lis_tmh_prefix");
            String tjNumber = (sysUser.getUserName() + idUtils.getTjNumber());
//            String tjNumber = (sysUser.getUserName() + idUtils.getTjNumber());
//            String tjNumber = idUtils.getTjNumber();
            String tjNumber = idUtils.getNewTjNumberRedisLockAndMysql();
            if (StringUtil.isNotBlank(makeLisTmhPrefix)) tjNumber = makeLisTmhPrefix + tjNumber;
@@ -2054,7 +2194,6 @@
                    xdPictureService.saveBatch(xdPictureList);
                    List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
                    addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
//                    return AjaxResult.success(tjNumber);
                }
                tjCustomer.setCardId("0");
@@ -2153,9 +2292,11 @@
                    transitionService.saveRedisTransitionByPacId(cusId, cardId, pacId);
                    //补差价
                    List<Map<String, Object>> cjMaps = groupingProService.huoquxiangmuchajia(pacId.toString(), cusId);
                    List<Map<String, Object>> cjMaps = transitionService.addTbhuoquxiangmuchajia(pacId.toString(), cusId);
                    if (null != cjMaps && !cjMaps.isEmpty()) {
                        log.info("该套餐"+pacId+"中有差价:"+cjMaps.size()+"个");
                        for (Map<String, Object> cjMap : cjMaps) {
                            log.info("添加临时表套餐数据时所选的差价为:"+ cjMap.get("cj").toString());
                            transitionService.buxiangmuchajia(cusId, pacId.toString(), cjMap.get("xmid").toString(), new BigDecimal(cjMap.get("cj").toString()));
                        }
                    }
@@ -2845,46 +2986,51 @@
    }
    @Transactional(propagation = Propagation.REQUIRED) // 共享事务
    public void newSaveextracted(TjOrder tjOrder, TjCustomer tjCustomer, BigDecimal discount, SysUser sysUser, TjReservation tjReservation, TjFlowingWater tjFlowingWater) {
        tjAskMedicalHistoryService.updateTjAskMedicalHistoryByCusId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjCustomer.getCusId()));
        if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
            tjOrderDetailService.saveJSYTjOrderDetailsByCusId(tjCustomer.getCusIdcard(),
                    String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId(), String.valueOf(tjFlowingWater.getTjSerialNumber()));
        } else {
            tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId());
        }
        try {
            tjAskMedicalHistoryService.updateTjAskMedicalHistoryByCusId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjCustomer.getCusId()));
            if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
                tjOrderDetailService.saveJSYTjOrderDetailsByCusId(tjCustomer.getCusIdcard(),
                        String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId(), String.valueOf(tjFlowingWater.getTjSerialNumber()));
            } else {
                tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId());
            }
        tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId());
            tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId());
        //添加remark表数据
        if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
            remarkService.saveJSYTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
            //添加remark表数据
            if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
                remarkService.saveJSYTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
        } else {
            remarkService.saveTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
            } else {
                remarkService.saveTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
        }
        //判断是否交钱
        if ("1".equals(tjOrder.getTjType())) {
            if (null != tjReservation && tjReservation.getPayType() == 1) {
            }
            //判断是否交钱
            if ("1".equals(tjOrder.getTjType())) {
                if (null != tjReservation && tjReservation.getPayType() == 1) {
                    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) {
                tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                        sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
                tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
                tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
                tjFlowingWater.setPayType(4L);
                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);
            }
        }
        if (tjFlowingWater.getPayStasus() == 1L) {
            tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                    sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
            tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
            tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
            tjFlowingWater.setPayType(4L);
            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);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
@@ -3069,9 +3215,9 @@
            TjReport tjReport = new TjReport();
            tjReport.setTjNumber(String.valueOf(tjNumber));
            tjReport.setPath(urlValue + outputFileName1);
            String outputPath1 = value + File.separator;
            String pdfBinary = getPDFBinary(outputPath1 + outputFileName1);
            tjReport.setReport(pdfBinary);
//            String outputPath1 = value + File.separator;
//            String pdfBinary = getPDFBinary(outputPath1 + outputFileName1);
//            tjReport.setReport(pdfBinary);
            tjReport.setType("体检报告");
            tjReport.setPrint("pdf");
            tjReportService.save(tjReport);
@@ -3202,13 +3348,15 @@
        TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
        if (null != order) {
//            String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
//            if (null != payByTjNum) {
//                return AjaxResult.error("该用户已收费不可撤销签到!");
//            }
            if (null != order.getFinishTime()) return AjaxResult.error("该人员已签离,不可撤销!!!");
            if (null != order.getPrintLastTime()) return AjaxResult.error("该人员报告已打印,不可撤销!!!");
            LambdaQueryWrapper<TjCustomer> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(TjCustomer::getCusId, order.getUserId());
            TjCustomer tjCustomer = tjCustomerService.getOne(wrapper);
            Boolean useLisAndPacsRegister = lisApiMethod.isUseLisAndPacsRegister(order);
            String s = configService.selectConfigByKey("is_request_common_his_api");
//            if (null != s && s.equals("Y") && "2".equals(order.getTjType())) {
@@ -3222,14 +3370,11 @@
                wrapper1.eq(TjFlowingWater::getOrderId, order.getOrderId());
                wrapper1.orderByDesc(TjFlowingWater::getJxbz);
                List<TjFlowingWater> list = tjFlowingWaterService.list(wrapper1);
                LambdaQueryWrapper<TjCustomer> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(TjCustomer::getCusId, order.getUserId());
                TjCustomer tjCustomer = tjCustomerService.getOne(wrapper);
                for (TjFlowingWater water : list) {
                    if (water.getPayStasus() == 0L) {
                        weizhifu.add(water);
                    } else {
                    } else if (water.getPayStasus() == 1L) {
                        yizhifu.add(water);
                    }
                }
@@ -3239,21 +3384,16 @@
                AjaxResult error1 = zuofeiYiZhifu(yizhifu, tjCustomer, order, apiUrl, hospbm, false, tjNum);
                if (error1 != null && !error.get("code").toString().equals("200")) return error1;
            } else {
                tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
            }
            /*     tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
                tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
                remarkService.deletedOrderRemarkByTjNum(tjNum);
                tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
                transitionService.deletedTbTransitionByTjNum(tjNum);
                ycxmService.delOrderYcXmJyByTjh(tjNum);
                TjCustomer customer = tjCustomerService.getById(order.getUserId());
                customer.setCardId("0");
                tjCustomerService.updateById(customer);
                xdPictureService.deleteTjXdPictureBytjNum(tjNum);
                tjSamplingMapper.deleteByTjNumAndCusId(tjNum, order.getUserId());
            }
                tjSamplingMapper.deleteByTjNumAndCusId(tjNum, order.getUserId());*/
            String configByKey = configService.selectConfigByKey("sfkqdyhis");
            if (configByKey.equals("Y")) {
@@ -3274,16 +3414,18 @@
                    }
                }
                boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order, lisApiMethod.isUseLisAndPacsRegister(order));
                if (zfHisApiMethods) {
                    return AjaxResult.success("撤销成功");
                } else {
                if (!zfHisApiMethods) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error("撤销失败,调用作废出现失败");
                }
            }
            tjCustomer.setCardId("0");
            tjCustomerService.updateById(tjCustomer);
            tjOrderService.removeById(order.getOrderId());
            return  AjaxResult.success("撤销成功");
        }
        return AjaxResult.success("签到记录不存在!");
        return AjaxResult.error("体检记录不存在!");
    }
@@ -3460,10 +3602,6 @@
        TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
        if (null != order) {
//            String payByTjNum = tjOrderService.isPayByTjNum(String.valueOf(order.getOrderId()));
//            if (null != payByTjNum) {
//                return AjaxResult.error("该用户已收费不可撤销签到!");
//            }
            //这里删除的是这个人所有项目包括补录项目
            tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
            tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
@@ -3522,6 +3660,9 @@
        TjOrder order = tjOrderService.getOrderByTjNum(dto.getTjh());
        if (null != order) {
            if (null != order.getPrintLastTime()) return AjaxResult.error("该人员报告已打印,不可撤销!!!");
            String configByKey = configService.selectConfigByKey("sfkqdyhis");
            if (null != configByKey && configByKey.equals("Y")) {
                log.info("dto的数据是" + JSONUtil.toJsonStr(dto));
@@ -3573,7 +3714,7 @@
                    TjFlowingWater water = tjFlowingWaterService.getOne(wrapper);
                    if (water.getPayStasus() == 0L) {
                        weizhifu.add(water);
                    } else {
                    } else if (water.getPayStasus() == 1L) {
                        yizhifu.add(water);
                    }
                }
@@ -3587,18 +3728,18 @@
                AjaxResult error1 = zuofeiYiZhifu(yizhifu, tjCustomer, order, apiUrl, hospbm, false, dto.getTjh());
                if (error1 != null && !error.get("code").toString().equals("200")) return error1;
                return AjaxResult.success();
            } else {
//                return AjaxResult.success();
            }
                try {
                    extracted(dto, order);
                } catch (Exception e) {
                    log.info("撤销失败,删除表失败");
                    return AjaxResult.error("撤销失败,删除表失败!");
                }
                return AjaxResult.success();
            }
                return AjaxResult.success("撤销成功");
        }
        return AjaxResult.error();
        return AjaxResult.error("未找到体检记录");
    }
    private AjaxResult zuofeiYiZhifu(ArrayList<TjFlowingWater> yizhifu, TjCustomer tjCustomer, TjOrder order, String apiUrl, String hospbm, Boolean isDelete, String tjNum) {
@@ -3671,7 +3812,7 @@
                        String tfid = jsonObject.getJSONObject("data").getStr("feiYongId");
                        water.setHisTfWaterId(tfid);
                        tjFlowingWaterService.updateById(water);
                        if (isDelete) {
             /*           if (isDelete) {
                            for (TjFlowingWater water1 : yizhifu) {
                                String bldh1 = water1.getJxbz();
                                remarkService.deleteTjOrderDetailByjxbz(bldh1);
@@ -3681,7 +3822,7 @@
                                blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, tjNum).eq(TjProBl::getBldh, bldh1));
                                tjSamplingMapper.deleteByTjNumAndCusIdAndJxbzo(tjNum, order.getUserId(), bldh1);
                            }
                        }
                        }*/
                    } else return AjaxResult.error();
                }
            }
@@ -3699,7 +3840,7 @@
            String post = HttpClientUtils.sendPost(apiUrl + "/api/his/" + hospbm + "/revokeCost", chexiaoMap);
            if (JSONUtil.parseObj(post).getStr("code").equals("200")) {
                if (isDelete) {
                /*if (isDelete) {
                    for (TjFlowingWater water : weizhifu) {
                        String bldh = water.getJxbz();
                        if (StrUtil.isNotBlank(bldh)) {
@@ -3711,16 +3852,17 @@
                            tjSamplingMapper.deleteByTjNumAndCusIdAndJxbzo(tjNum, order.getUserId(), bldh);
                        } else {
                            //这里删除的是这个人所有项目包括补录项目
                            tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
                 *//*           tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
                            tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
                            remarkService.deletedOrderRemarkByTjNum(tjNum);
                            tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId()));
                            transitionService.deletedTbTransitionByTjNum(tjNum);
                            tjSamplingMapper.deleteByTjNumAndCusId(order.getTjNumber(), order.getUserId());
                            tjSamplingMapper.deleteByTjNumAndCusId(order.getTjNumber(), order.getUserId());*//*
//                            tjOrderService.removeById(order.getOrderId());
                        }
                    }
                }
                }*/
            } else return AjaxResult.error();
        }
        return null;
@@ -3728,14 +3870,18 @@
    //    @Transactional(propagation =Propagation.REQUIRES_NEW)
    public void extracted(TjProBlDto dto, TjOrder order) {
        for (String bldh : dto.getBldhs()) {
            remarkService.deleteTjOrderDetailByjxbz(bldh);
            tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh);
            tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh);
            transitionService.deleteTjOrderDetailByjxbz(bldh);
            blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, dto.getTjh()).eq(TjProBl::getBldh, bldh));
        try {
            for (String bldh : dto.getBldhs()) {
                remarkService.deleteTjOrderDetailByjxbz(bldh);
                tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh);
                tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh);
                transitionService.deleteTjOrderDetailByjxbz(bldh);
                blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, dto.getTjh()).eq(TjProBl::getBldh, bldh));
            }
            tjSamplingMapper.deleteByTjNumAndCusIdAndJxbz(dto.getTjh(), order.getUserId(), dto.getBldhs());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        tjSamplingMapper.deleteByTjNumAndCusIdAndJxbz(dto.getTjh(), order.getUserId(), dto.getBldhs());
    }
@@ -3956,16 +4102,6 @@
    @GetMapping(value = "newgetTransitionList")
    @ApiOperation(value = "最新查询过渡表数据")
    public AjaxResult newgetTransitionList(@RequestParam @ApiParam(value = "客户id") String cusId) {
//        String pacId = transitionService.getTbTransitionPacId(cusId);
//        if(StringUtil.isNotBlank(pacId)){
//            //补差价
//            List<Map<String,Object>> cjMaps = groupingProService.huoquxiangmuchajia(pacId, cusId);
//            if(null !=cjMaps && !cjMaps.isEmpty()){
//                for (Map<String, Object> cjMap : cjMaps) {
//                    transitionService.buxiangmuchajia(cusId,pacId,cjMap.get("xmid").toString(),new BigDecimal(cjMap.get("cj").toString()));
//                }
//            }
//        }
        List<TbTransition> list = transitionService.newgetTransitionList(cusId);
        return AjaxResult.success(list);
    }
@@ -4005,10 +4141,7 @@
                    log.info("前端传递的价格:{}",yhj.toString());
                    BigDecimal cj = yhj.subtract(dxzj);
                    log.info("计算的差价:{}",cj.toString());
//                        int index1 = 0;
                    for (TbTransition transition : list) {
//                        BigDecimal ordPrice = transition.getOrdPrice();
//                        BigDecimal multiply = ordPrice.multiply((new BigDecimal(dto.getDiscount()).divide(BigDecimal.valueOf(10))));
                        BigDecimal result = transition.getNowPrice().add(cj);
                        log.info("补上差价前的价格为:{}",transition.getNowPrice().toString());
                        if (result.compareTo(BigDecimal.ZERO)>0 && !flag && cj.compareTo(BigDecimal.ZERO) != 0){
@@ -4018,61 +4151,7 @@
                            flag = true;
                            break;
                        }
//                            if (index1 == 0 ){
//                                log.info("修改小项 {}{} 原本价格:{}",transition.getProId(),transition.getProName(),multiply.toString());
//                                multiply = multiply.add(cj);
//                                log.info("增加差价后:{}",multiply.toString());
//                            }
//                            index1++;
//                            log.info("后端计算的金额: " + multiply.toString());
////                        log.info("前端传递的金额: " + dto.getYhj());
//                            transition.setNowPrice(multiply);
//                            transition.setDiscount(new BigDecimal(dto.getDiscount()));
//                            transitionService.updateById(transition);
                    }
//                    log.info("dxzj:{}",dxzj.toString());
//                    if (index == dtos.size()){
//                        BigDecimal yhj = dto.getYhj();
//                        log.info("前端传递的价格:{}",yhj.toString());
//                        BigDecimal cj = yhj.subtract(dxzj);
//                        log.info("计算的差价:{}",cj.toString());
//                        int index1 = 0;
//                        for (TbTransition transition : list) {
//                            BigDecimal ordPrice = transition.getOrdPrice();
//                            BigDecimal multiply = ordPrice.multiply((new BigDecimal(dto.getDiscount()).divide(BigDecimal.valueOf(10))));
//                            if (index1 == 0 ){
//                                log.info("修改小项 {}{} 原本价格:{}",transition.getProId(),transition.getProName(),multiply.toString());
//                                multiply = multiply.add(cj);
//                                log.info("增加差价后:{}",multiply.toString());
//                            }
//                            index1++;
//                            log.info("后端计算的金额: " + multiply.toString());
////                        log.info("前端传递的金额: " + dto.getYhj());
//                            transition.setNowPrice(multiply);
//                            transition.setDiscount(new BigDecimal(dto.getDiscount()));
//                            transitionService.updateById(transition);
//                        }
//                    }else {
//                        for (TbTransition transition : list) {
//                            BigDecimal ordPrice = transition.getOrdPrice();
//                            BigDecimal multiply = ordPrice.multiply((new BigDecimal(dto.getDiscount()).divide(BigDecimal.valueOf(10))));
//                            log.info("后端计算的金额: " + multiply.toString());
////                        log.info("前端传递的金额: " + dto.getYhj());
//                            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);
////                            }
////                        }
//                    }
                }
            }
        }