zjh
2024-12-13 dba27f21bc05c999ace46fe15be6e4c824ed9104
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
@@ -23,6 +23,7 @@
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.crypto.symmetric.DES;
import cn.hutool.extra.pinyin.PinyinUtil;
@@ -43,10 +44,7 @@
import com.ltkj.common.core.domain.entity.SysUser;
import com.ltkj.common.core.redis.RedisCache;
import com.ltkj.common.enums.DataSourceType;
import com.ltkj.common.utils.AgeResult;
import com.ltkj.common.utils.DateUtils;
import com.ltkj.common.utils.PDFDocumentUtil;
import com.ltkj.common.utils.SecurityUtils;
import com.ltkj.common.utils.*;
import com.ltkj.framework.config.MatchUtils;
import com.ltkj.framework.config.ThreadPoolConfig;
import com.ltkj.framework.config.UserHoder;
@@ -73,9 +71,8 @@
import com.ltkj.mall.mallOrderUtils.TjConstants;
import com.ltkj.mall.service.IMallCheckLogService;
import com.ltkj.mall.service.IMallOrderService;
import com.ltkj.system.service.ISysConfigService;
import com.ltkj.system.service.ISysDeptService;
import com.ltkj.system.service.ISysUserService;
import com.ltkj.system.domain.TjDjdDyjl;
import com.ltkj.system.service.*;
import com.ltkj.web.controller.his.*;
import com.ltkj.web.controller.lis.LisApiMethod;
import com.ltkj.web.controller.pacs.PacsApiMethodService;
@@ -83,6 +80,7 @@
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;
@@ -219,6 +217,16 @@
    private TjSamplingMapper tjSamplingMapper;
    @Autowired
    private ITjGroupingProService groupingProService;
    @Autowired
    private ITjDjdDyjlService djdDyjlService;
    @Autowired
    private IdUtils idUtils;
    @Autowired
    private LtkjJybbzdService jybbzdService;
    @Autowired
    private LisJyflhbService lisJyflhbService;
    @Autowired
    private ISysDictDataService sysDictDataService;
    //将方法返回值解析成json格式
    public JSONObject getJSONObject(String builder) {
@@ -414,7 +422,7 @@
            LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
            wqq.like(TjCustomer::getCusName, name);
            List<TjCustomer> customerList = tjCustomerService.list(wqq);
            if (null != customerList && customerList.size() > 0) {
            if (null != customerList && !customerList.isEmpty()) {
                List<TjOrder> list = new ArrayList<>();
                for (TjCustomer customer : customerList) {
                    LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
@@ -425,7 +433,7 @@
                    list.addAll(tjOrderService.list(wq));
                }
                List<TjOrder> collect = null;
                if (list.size() > 0) {
                if (!list.isEmpty()) {
                    for (TjOrder order : list) {
                        TjCustomer tjCustomer = tjCustomerService.getById(order.getUserId());
                        if (null != tjCustomer) {
@@ -441,18 +449,25 @@
                            order.setIdType(tjCustomer.getIdType());
                            order.setAgeUnit(tjCustomer.getAgeUnit());
                            order.setTjCount(String.valueOf(tjCustomer.getCusNumber()));
                        }
                        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());
                            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 != dwDeptService.getById(order.getPacId())) {
                                order.setPacName(dwDeptService.getById(order.getPacId()).getDwDeptName());
                            if (null != order.getPacId()) {
                                if (null != tjPackageService.getById(order.getPacId())) {
                                    order.setPacName(tjPackageService.getById(order.getPacId()).getPacName());
                                }
                                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()));
                        }
                    }
                    collect = list.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
@@ -500,17 +515,23 @@
                    order.setIdType(tjCustomer.getIdType());
                    order.setAgeUnit(tjCustomer.getAgeUnit());
                    order.setTjCount(String.valueOf(tjCustomer.getCusNumber()));
                }
                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());
                    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()));
                }
            }
        }
@@ -524,12 +545,14 @@
    @ApiOperation(value = "体检报告页面——体检记录列表")
    public AjaxResult getOrderListOO(@ApiParam(value = "页码数(默认1)") @RequestParam(defaultValue = "1") Integer pageNum,
                                     @ApiParam(value = "显示条数(默认10)") @RequestParam(defaultValue = "10") Integer pageSize,
                                     @ApiParam(value = "打印未打印状态 0未打印 1已打印") @RequestParam(defaultValue = "0") Integer dyzt,
                                     @ApiParam(value = "体检号)") @RequestParam(required = false) String tjNum,
                                     @ApiParam(value = "姓名)") @RequestParam(required = false) String name,
                                     @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<>();
        if (null != name) {
        if (StringUtil.isNotBlank(name)) {
            LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
            wqq.like(TjCustomer::getCusName, name);
            List<TjCustomer> customerList = tjCustomerService.list(wqq);
@@ -537,9 +560,13 @@
                List<TjOrder> list = new ArrayList<>();
                for (TjCustomer customer : customerList) {
                    LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
                    wq.isNotNull(TjOrder::getReportTime);
                    wq.eq(TjOrder::getUserId, customer.getCusId());
                    wq.eq(TjOrder::getHeshouStatus, 1); //核收状态为1才能打印
                    if (dyzt == 0) {
                        wq.isNull(TjOrder::getPrintLastTime);
                        wq.eq(TjOrder::getHeshouStatus, 1);
                    } else {
                        wq.isNotNull(TjOrder::getPrintLastTime);
                    }
                    list.addAll(tjOrderService.list(wq));
                }
                List<TjOrder> collect = null;
@@ -554,13 +581,18 @@
                        list.get(i).setTjCustomerSex(tjCustomer.getCusSex());
                        list.get(i).setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                        list.get(i).setTjCustomerName(tjCustomer.getCusName());
                        list.get(i).setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
                        list.get(i).setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
                        list.get(i).setTjCustomerPhone(tjCustomer.getCusPhone());
                        list.get(i).setTjCusIdCard(tjCustomer.getCusIdcard());
                        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 != 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());
@@ -569,16 +601,6 @@
                                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());
                        }
                    }
                    collect = list.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
                }
@@ -592,15 +614,88 @@
            }
        }
        if (StringUtil.isNotBlank(dw)) {
            LambdaQueryWrapper<TjCustomer> wqq = new LambdaQueryWrapper<>();
            wqq.like(TjCustomer::getCompName,dw);
            List<TjCustomer> customerList = tjCustomerService.list(wqq);
            List<TjOrder> list = new ArrayList<>();
            if (null != customerList && !customerList.isEmpty()) {
                for (TjCustomer customer : customerList) {
                    LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
                    wq.eq(TjOrder::getUserId, customer.getCusId());
                    if (dyzt == 0) {
                        wq.isNull(TjOrder::getPrintLastTime);
                        wq.eq(TjOrder::getHeshouStatus, 1);
                    } else {
                        wq.isNotNull(TjOrder::getPrintLastTime);
                    }
                    list.addAll(tjOrderService.list(wq));
                }
            }
             List<String> dwIds=  iDictCompService.getdwIdByDwName(dw);
            LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
            wq.in(TjOrder::getFirmId,dwIds);
            list.addAll(tjOrderService.list(wq));
            List<TjOrder> collect = null;
                if (!list.isEmpty()) {
                    List<TjOrder> orders = list.stream().distinct().collect(Collectors.toList());
                    for (int i = 0; i < orders.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());
                        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());
                            }
                        }
                    }
                    collect = list.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
                }
                if (null != collect) {
                    map.put("total", collect.size());
                } else {
                    map.put("total", 0);
                }
                map.put("list", collect);
                return AjaxResult.success(map);
        }
        Page<TjOrder> page1 = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<TjOrder> wq = new LambdaQueryWrapper<>();
        wq.isNotNull(TjOrder::getReportTime);
        wq.eq(TjOrder::getHeshouStatus, 1);  //核收状态为1才能打印
        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.eq(TjOrder::getTjNumber, tjNum);
            wq.like(TjOrder::getTjNumber, tjNum);
        }
        wq.orderByDesc(TjOrder::getCreateTime);
        Page<TjOrder> page2 = tjOrderService.page(page1, wq);
@@ -615,14 +710,18 @@
                list.get(i).setTjCustomerSex(tjCustomer.getCusSex());
                list.get(i).setTjCustomerAge(DateUtil.ageOfNow(tjCustomer.getCusBrithday()));
                list.get(i).setTjCustomerName(tjCustomer.getCusName());
                list.get(i).setTjCustomerPhone(MatchUtils.hidePhoneNum(tjCustomer.getCusPhone()));
                list.get(i).setTjCustomerPhone(tjCustomer.getCusPhone());
                if (tjCustomer.getCusIdcard() != null) {
                    list.get(i).setTjCusIdCard(MatchUtils.hideIdCardNum(tjCustomer.getCusIdcard()));
                    list.get(i).setTjCusIdCard(tjCustomer.getCusIdcard());
                }
                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 != 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())) {
@@ -633,14 +732,14 @@
                    }
                }
                //从打印记录查出最新打印时间
                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());
                }
//                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);
@@ -946,7 +1045,7 @@
            tjReservationService.updateById(tjReservation);
            if (null != tjReservation.getTeamNo() && tjOrder.getTjType().equals("1")) {
                tjOrder.setTjType("1");
            } else if (tjOrder.getTjType().equals("2")){
            } else if (tjOrder.getTjType().equals("2")) {
                tjOrder.setTjType("2");
            }
        }
@@ -987,6 +1086,7 @@
                AjaxResult result = processOrderWithTransaction(tjOrder, tjCustomer, tjReservation, tjFlowingWater, mallOrder, sysUser);
                if (!result.get("code").toString().equals("200"))
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                tjOrderService.tjQiandaodengji(tjOrder.getTjNumber());
                return result;
            }
        } finally {
@@ -1000,7 +1100,9 @@
        //生成体检号
        String tjNumber = (SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
        tjOrder.setTjNumber(tjNumber);
        BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount()));
        tjOrder.setDiscount(discount.toString());
        if (tjOrderService.save(tjOrder)) {
            //保存收货地址
            if ("2".equals(tjOrder.getGetType())) {
@@ -1013,7 +1115,6 @@
            Long cusNumber = tjCustomer.getCusNumber();
            cusNumber += 1;
            tjCustomer.setCusNumber(cusNumber);
            BigDecimal discount = BigDecimal.valueOf(Double.parseDouble(tjOrder.getTjFlowingWater().getDiscount()));
            if ("1".equals(tjOrder.getTjType())) {
                if (null != tjReservation && tjReservation.getPayType() == 1) {
@@ -1111,7 +1212,7 @@
                    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()));
                }else {
                } else {
                    hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId());
                }
//                        hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId());
@@ -1133,11 +1234,102 @@
            if ("2".equals(tjOrder.getTjType())) {
                //asyncService.newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
            }
            // 查询 对接Lis、Pacs申请如果类型包含在配置内则使用对接lis、pacs
            if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) {
                // 这是上面个人方法引入数据
                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()));
                List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
                addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
            }
//            pacsApiMethodService.OrderAdd(tjCustomer,tjOrder);
            return AjaxResult.success(tjNumber);
        }
        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        return AjaxResult.error();
    }
    public void addCaiYangDengJi(List<TjOrderDetail> detailList, boolean detailList1, TjOrder order, SysUser sysUser, String jxbz) {
        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());
                    sampling.setSpecimenTypeCode(project.getSpecimenType());
                    sampling.setSpecimenType(dictLabel);
                    sampling.setJyxmdm(project.getProId().toString());
                } else {
                    TjProject project1 = projectService.getById(proParentId);
                    sampling.setJyxh(idUtils.generateLisID());
                    sampling.setSpecimenTypeCode(project1.getSpecimenType());
                    sampling.setSpecimenType(dictLabel);
                    sampling.setJyxmdm(project.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);
            }
        }
        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")) {
                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);
                    }
                }
            }
        }
    }
@@ -1614,6 +1806,11 @@
                transitionService.deletedTbTransitionListByCusIdAndPac(cusId, cardId);
                List<TjPackageProject> ppList = tjPackageProjectService.getTjPackageProjectListByPacId(String.valueOf(pacId));
                if (null != ppList && !ppList.isEmpty()) {
                    String string = transitionService.panduantaocanshifouchongfu(cusId, pacId);
                    if (!StringUtils.isBlank(string)) {
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        return AjaxResult.error("操作失败! 以下项目已存在: " + string);
                    }
                    transitionService.saveRedisTransitionByPacId(cusId, cardId, pacId);
                }
            }
@@ -1830,6 +2027,7 @@
                    }
                }
            }
            remarkService.updateRemark(tjNumber);
            asyncService.tjGoutAsync(domainVos, sysUser, list);
            TjCustomer customer = tjCustomerService.selectTjCustomerByCusId(tjOrder.getUserId());
@@ -1866,6 +2064,7 @@
            }*/
            return AjaxResult.success("签离成功!");
        } else {
            remarkService.updateRemark(tjNumber);
            return getAjaxResult(tjNumber);
        }
    }
@@ -2341,7 +2540,7 @@
        tjAskMedicalHistoryService.updateTjAskMedicalHistoryByCusId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjCustomer.getCusId()));
        boolean b = tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(),
                String.valueOf(sysUser.getUserId()),tjOrder.getCardId());
                String.valueOf(sysUser.getUserId()), tjOrder.getCardId());
        if (!b) {
            List<TjGroupingPro> proList = groupingProService.list(new LambdaQueryWrapper<TjGroupingPro>().eq(TjGroupingPro::getGroupingId, tjOrder.getGroupId()));
            if (null != proList && !proList.isEmpty()) {
@@ -2406,7 +2605,7 @@
            transitionService.updateTbTransitionPriceByCusId(tjCustomer.getCusIdcard(), BigDecimal.valueOf(Long.parseLong(tjFlowingWater.getDiscount())), tjOrder.getTjNumber());
        }
        tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()),tjOrder.getCardId());
        tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId());
//        List<TjOrderDetail> list = tjOrderDetailService.getTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()));
//        if (list != null) {
//            for (TjOrderDetail tjOrderDetail : list) {
@@ -2488,8 +2687,12 @@
                    LambdaQueryWrapper<TjCustomer> wq1 = new LambdaQueryWrapper<>();
                    wq1.eq(TjCustomer::getCusId, byId.getUserId());
                    TjCustomer tjCustomer = tjCustomerService.getOne(wq1);
                    LambdaQueryWrapper<TjReportTemplate> wrapper = new LambdaQueryWrapper<>();
                    wrapper.eq(TjReportTemplate::getFlag, "4");
                    wrapper.eq(TjReportTemplate::getOpen, "1");
                    TjReportTemplate zongJianYiShiQianMing = reportTemplateService.getOne(wrapper);
                    try {
                        shengchengbgmoban(byId.getTjNumber(), byId, tjCustomer, reportTemplate);
                        shengchengbgmoban(byId.getTjNumber(), byId, tjCustomer, reportTemplate, zongJianYiShiQianMing);
                        byId.setStatus(TjConstants.TJ_END);
                        byId.setReportTime(date);
                        byId.setPrintLastTime(date);
@@ -2516,8 +2719,10 @@
    }
    public AjaxResult shengchengbgmoban(String tjNumber, TjOrder tjOrder, TjCustomer tjCustomer, TjReportTemplate reportTemplate) throws Exception {
        AjaxResult ajaxResult = hisPDFUtil.hisPDF(tjOrder, tjCustomer, reportTemplate);
    public AjaxResult shengchengbgmoban(String tjNumber, TjOrder tjOrder, TjCustomer tjCustomer, TjReportTemplate reportTemplate, TjReportTemplate zongJianYiShiQianMing) throws Exception {
//        AjaxResult ajaxResult = hisPDFUtil.hisPDF(tjOrder, tjCustomer, reportTemplate);
//        AjaxResult ajaxResult = hisPDFUtil.hisPDFNew(tjOrder, tjCustomer, reportTemplate);
        AjaxResult ajaxResult = hisPDFUtil.hisPDFNew2(tjOrder, tjCustomer, reportTemplate, zongJianYiShiQianMing);
        if (!ajaxResult.get("code").toString().equals("200")) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        } else {
@@ -2526,7 +2731,7 @@
            TjReport tjReport = new TjReport();
            tjReport.setTjNumber(String.valueOf(tjNumber));
            tjReport.setPath(urlValue + outputFileName1);
            String outputPath1 = value + "\\";
            String outputPath1 = value + File.separator;
            String pdfBinary = getPDFBinary(outputPath1 + outputFileName1);
            tjReport.setReport(pdfBinary);
            tjReport.setType("体检报告");
@@ -2669,6 +2874,7 @@
//            if (null != payByTjNum) {
//                return AjaxResult.error("该用户已收费不可撤销签到!");
//            }
            if (null != order.getFinishTime()) return AjaxResult.error("该人员已签离,不可撤销!!!");
            tjOrderService.deleteTjOrderByOrderId(order.getOrderId());
            tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId()));
            remarkService.deletedOrderRemarkByTjNum(tjNum);
@@ -2679,7 +2885,7 @@
            customer.setCardId("0");
            tjCustomerService.updateById(customer);
            String configByKey = configService.selectConfigByKey("sfkqdyhis");
            tjSamplingMapper.deleteByTjNumAndCusId(tjNum,order.getUserId());
            tjSamplingMapper.deleteByTjNumAndCusId(tjNum, order.getUserId());
            if (configByKey.equals("Y")) {
                HashMap<String, Object> hisRequestParams = new HashMap<>();
@@ -2951,7 +3157,7 @@
                HashMap<String, Object> hisRequestParams = new HashMap<>();
                hisRequestParams.put("patientId", order.getCardId());
                AjaxResult queryPay = hisApiGetMethodService.getHISDataNew("QueryPay", hisRequestParams);
                log.info("queryPay ->{}",JSONUtil.toJsonStr(queryPay));
                log.info("queryPay ->{}", JSONUtil.toJsonStr(queryPay));
                if (Integer.parseInt(queryPay.get("code").toString()) == 200) {
                    List<Map<String, String>> data = (List<Map<String, String>>) queryPay.get("data");
                    log.info("data的数据是" + JSONUtil.toJsonStr(data));
@@ -2979,13 +3185,13 @@
                boolean b = hisApiMethod.ZfBlXm(dto.getBldhs(), order);
                if (!b) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    log.info("撤销失败,调用作废出现失败");
                    return AjaxResult.error("撤销失败,调用作废出现失败");
                }
            }
            try {
                extracted(dto,order);
                extracted(dto, order);
            } catch (Exception e) {
                log.info("撤销失败,删除表失败");
                return AjaxResult.error("撤销失败,删除表失败!");
@@ -2995,8 +3201,8 @@
        return AjaxResult.error();
    }
//    @Transactional(propagation =Propagation.REQUIRES_NEW)
    public void extracted(TjProBlDto dto,TjOrder order) {
    //    @Transactional(propagation =Propagation.REQUIRES_NEW)
    public void extracted(TjProBlDto dto, TjOrder order) {
        for (String bldh : dto.getBldhs()) {
            remarkService.deleteTjOrderDetailByjxbz(bldh);
            tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh);
@@ -3004,7 +3210,7 @@
            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());
        tjSamplingMapper.deleteByTjNumAndCusIdAndJxbz(dto.getTjh(), order.getUserId(), dto.getBldhs());
    }
@@ -3023,5 +3229,62 @@
    }
    @GetMapping("/chushenyemianqijianjiekou")
    @ApiOperation(value = "初审页面弃检接口")
    @Transactional
    public AjaxResult chushenyemianqijianjiekou(@RequestParam String tjNUm, @RequestParam String proId) {
        LambdaQueryWrapper<TjOrderRemark> wq = new LambdaQueryWrapper<>();
        wq.eq(TjOrderRemark::getTjNumber, tjNUm);
        wq.eq(TjOrderRemark::getProId, proId);
        TjOrderRemark remark = remarkService.getOne(wq);
        remark.setType(1);
        remarkService.updateById(remark);
        return AjaxResult.success("操作成功!");
    }
    @GetMapping("/zongjanyemianshjianzhou")
    @ApiOperation(value = "总检获取时间轴接口")
    @Transactional
    public AjaxResult zongjanyemianshjianzhou(@RequestParam String tjNUm) {
        TjOrder order = tjOrderService.getOrderByTjNum(tjNUm);
        if(null !=order){
            int czwj = remarkService.panduaniscunzaiweijian(tjNUm);
            int sfwc = remarkService.panduaniswancheng(tjNUm);
            Date checkTime = order.getCheckTime();
            Date reportTime = order.getReportTime();
            Integer heshouStatus = order.getHeshouStatus();
            Date lastTime = order.getPrintLastTime();
            if(czwj==0){
                //未检
                return AjaxResult.success(0);
            } else if(czwj>0) {
                //在检
                return AjaxResult.success(1);
            }else if(sfwc==0){
                //已完成
                return AjaxResult.success(2);
            }else if(null !=checkTime){
                //已审核
                return AjaxResult.success(3);
            }else if(null !=reportTime){
                //生成报告
                return AjaxResult.success(4);
            }else if(null !=heshouStatus){
                //报告核收
                return AjaxResult.success(5);
            }else if(null !=lastTime){
                //已出报告
                return AjaxResult.success(6);
            }else {
                return AjaxResult.error();
            }
        }
        return AjaxResult.error();
    }
}