zhaowenxuan
2025-06-05 b7adb9e5316030aabfb90a8ff1b43c848aa550ec
ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisApiController.java
@@ -9,10 +9,7 @@
import com.ltkj.common.core.controller.BaseController;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.framework.config.UserHoder;
import com.ltkj.hosp.domain.LtkjJianchajianyanTree;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.domain.TjOrder;
import com.ltkj.hosp.domain.TjProject;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.hisDto.*;
import com.ltkj.hosp.mapper.TestMapper;
import com.ltkj.hosp.service.*;
@@ -23,8 +20,10 @@
import com.ltkj.hosp.vodomain.CsProVo;
import com.ltkj.web.controller.system.TjCheckController;
import io.swagger.annotations.Api;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.NoTransactionException;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.*;
@@ -62,6 +61,8 @@
    private LtkjHybgdService hybgdService;
    @Autowired
    private ITjCustomerService tjCustomerService;
    @Autowired
    private TjJcycxmService jcycxmService;
    /**
     * 获取pacs检查数据
@@ -110,6 +111,7 @@
    /**
     * 获取pacs检查数据
     *
     * @param json
     * @return
     */
@@ -122,14 +124,14 @@
        String start = StrUtil.isBlank(parseObj.getStr("start")) ? null : parseObj.getStr("start");
        String end = StrUtil.isBlank(parseObj.getStr("end")) ? null : parseObj.getStr("end");
        String mzh = null;
        if (tjNum == null && name == null){
        if (tjNum == null && name == null) {
            return AjaxResult.error("体检号和名字不能都为空");
        }
        if (tjNum != null) {
            TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
            mzh = order.getCardId();
            LambdaQueryWrapper<TjCustomer> wrapper1 = new LambdaQueryWrapper<>();
            wrapper1.eq(TjCustomer::getCusId,order.getUserId());
            wrapper1.eq(TjCustomer::getCusId, order.getUserId());
            TjCustomer tjCustomer = tjCustomerService.getOne(wrapper1);
            name = tjCustomer.getCusName();
        }
@@ -141,6 +143,7 @@
    /**
     * 获取Lis检验数据
     *
     * @param json
     * @return
     */
@@ -153,52 +156,52 @@
        String start = StrUtil.isBlank(parseObj.getStr("start")) ? null : parseObj.getStr("start");
        String end = StrUtil.isBlank(parseObj.getStr("end")) ? null : parseObj.getStr("end");
        String mzh = null;
        if (tjNum == null && name == null){
        if (tjNum == null && name == null) {
            return AjaxResult.error("体检号和名字不能都为空");
        }
        if (tjNum != null) {
            LambdaQueryWrapper<TjOrder> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(TjOrder::getTjNumber,tjNum);
            wrapper.eq(TjOrder::getTjNumber, tjNum);
            TjOrder order = tjOrderService.getOne(wrapper);
            mzh = order.getCardId();
            LambdaQueryWrapper<TjCustomer> wrapper1 = new LambdaQueryWrapper<>();
            wrapper1.eq(TjCustomer::getCusId,order.getUserId());
            wrapper1.eq(TjCustomer::getCusId, order.getUserId());
            TjCustomer tjCustomer = tjCustomerService.getOne(wrapper1);
            name = tjCustomer.getCusName();
        }
        List<Map<String, Object>> jcList = testMapper.getLisJyList(name, mzh, start, end);
        return AjaxResult.success(jcList);
//        String json1 = "[{\"deptName\":\"科室\",\"gender\":\"男\",\"brid\":\"sqd445314589914\",\"checkParts\":\"血液\",\"project\":\"1.0-2.0\",\"examinationDate\":\"2025-02-11 05:12:23\",\"proResult\":\"1.0\",\"name\":\"赵四1\",\"patientAge\":\"20\",\"mzh\":\"810001246120745\",\"reportDoctorName\":\"医师\",\"proName\":\"血液分析\",\"conclusion\":\"异常\",\"tjStandardGtValue\":\"1 - 5\",\"company\":\"毫克\",\"checkDoctorName\":\"检测医师\",\"jcxmid\":\"123\",\"shys\":\"审核医师\"},{\"deptName\":\"科室\",\"gender\":\"男\",\"brid\":\"sqd445314589914\",\"checkParts\":\"血液\",\"project\":\"1.0-2.0\",\"examinationDate\":\"2025-02-11 05:12:23\",\"proResult\":\"1.0\",\"name\":\"赵四2\",\"patientAge\":\"20\",\"mzh\":\"201474534\",\"reportDoctorName\":\"医师\",\"proName\":\"血液分析\"},{\"deptName\":\"科室\",\"gender\":\"男\",\"brid\":\"sqd445314589914\",\"checkParts\":\"血液\",\"project\":\"1.0-2.0\",\"examinationDate\":\"2025-02-11 05:12:23\",\"proResult\":\"1.0\",\"name\":\"赵四3\",\"patientAge\":\"20\",\"mzh\":\"201474534\",\"reportDoctorName\":\"医师\",\"proName\":\"血液分析\"}]";
//        String json1 = "[{\"deptName\":\"科室\",\"gender\":\"男\",\"brid\":\"sqd445314589914\",\"checkParts\":\"血液\",\"project\":\"1.0-2.0\",\"examinationDate\":\"2025-02-11 05:12:23\",\"proResult\":\"1.0\",\"name\":\"赵四1\",\"patientAge\":\"20\",\"mzh\":\"810001246120745\",\"reportDoctorName\":\"医师\",\"proName\":\"血液分析\",\"conclusion\":\"异常\",\"tjStandardGtValue\":\"1 - 5\",\"company\":\"毫克\",\"checkDoctorName\":\"检测医师\",\"jcxmid\":\"123\",\"shys\":\"审核医师\"},{\"deptName\":\"科室\",\"gender\":\"男\",\"brid\":\"sqd445314589914\",\"checkParts\":\"血液\",\"project\":\"1.0-2.0\",\"examinationDate\":\"2025-02-11 05:12:23\",\"proResult\":\"1.0\",\"name\":\"赵四2\",\"patientAge\":\"20\",\"mzh\":\"201474534\",\"reportDoctorName\":\"医师\",\"proName\":\"血液分析\"},{\"deptName\":\"科室\",\"gender\":\"男\",\"brid\":\"sqd445314589914\",\"checkParts\":\"血液\",\"project\":\"1.0-2.0\",\"examinationDate\":\"2025-02-11 05:12:23\",\"proResult\":\"1.0\",\"name\":\"赵四3\",\"patientAge\":\"20\",\"mzh\":\"201474534\",\"reportDoctorName\":\"医师\",\"proName\":\"血液分析\"},{\"deptName\":\"科室\",\"gender\":\"男\",\"brid\":\"sqd445314589914\",\"checkParts\":\"血液\",\"project\":\"1.0-2.0\",\"examinationDate\":\"2025-02-11 05:12:23\",\"proResult\":\"1.0\",\"name\":\"赵四3\",\"patientAge\":\"20\",\"mzh\":\"201474534\",\"reportDoctorName\":\"医师\",\"proName\":\"血液分析\"},{\"deptName\":\"科室\",\"gender\":\"男\",\"brid\":\"sqd445314589914\",\"checkParts\":\"血液\",\"project\":\"1.0-2.0\",\"examinationDate\":\"2025-02-11 05:12:23\",\"proResult\":\"1.0\",\"name\":\"赵四3\",\"patientAge\":\"20\",\"mzh\":\"201474534\",\"reportDoctorName\":\"医师\",\"proName\":\"血液分析\"},{\"deptName\":\"科室\",\"gender\":\"男\",\"brid\":\"sqd445314589914\",\"checkParts\":\"血液\",\"project\":\"1.0-2.0\",\"examinationDate\":\"2025-02-11 05:12:23\",\"proResult\":\"1.0\",\"name\":\"赵四3\",\"patientAge\":\"20\",\"mzh\":\"201474534\",\"reportDoctorName\":\"医师\",\"proName\":\"血液分析\"},{\"deptName\":\"科室\",\"gender\":\"男\",\"brid\":\"sqd445314589914\",\"checkParts\":\"血液\",\"project\":\"1.0-2.0\",\"examinationDate\":\"2025-02-11 05:12:23\",\"proResult\":\"1.0\",\"name\":\"赵四3\",\"patientAge\":\"20\",\"mzh\":\"201474534\",\"reportDoctorName\":\"医师\",\"proName\":\"血液分析\"},{\"deptName\":\"科室\",\"gender\":\"男\",\"brid\":\"sqd445314589914\",\"checkParts\":\"血液\",\"project\":\"1.0-2.0\",\"examinationDate\":\"2025-02-11 05:12:23\",\"proResult\":\"1.0\",\"name\":\"赵四3\",\"patientAge\":\"20\",\"mzh\":\"201474534\",\"reportDoctorName\":\"医师\",\"proName\":\"血液分析\"}]";
//        return AjaxResult.success(JSONUtil.parseArray(json1));
    }
    @GetMapping("/getTjList")
    public AjaxResult getTjList(@RequestParam("code")String code){
    public AjaxResult getTjList(@RequestParam("code") String code) {
//        log.info("tjList接口参数->{}",code);
        LambdaQueryWrapper<TjOrder> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TjOrder::getCardId, code)
                .or()
                .eq(TjOrder::getTjNumber, code);
        TjOrder order = tjOrderService.getOne(queryWrapper);
        if (order == null){
            return AjaxResult.error("门诊号:"+code+"在体检系统中不存在");
        if (order == null) {
            return AjaxResult.error("门诊号:" + code + "在体检系统中不存在");
        }
        List<CsProVo> proVos = tjCheckController.getCsProVos(order.getTjNumber(),true);
        return AjaxResult.success(proVos);
//        String json = "[{\"deptName\":\"CT室\",\"proName\":\"(tj)胸部CT平扫\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"},{\"deptName\":\"彩超室\",\"proName\":\"(tj)泌尿系前列腺\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2024-11-06 10:47:15\",\"bcupdateTime\":\"2024-11-06 10:47:15\",\"bcdoctorName\":null,\"zhupdateTime\":\"2024-11-06 10:47:15\"}]";
//        String json = "[{\"proId\":\"1870371396991955206\",\"deptName\":\"DR室\",\"proName\":\"胸部DR正位\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2025-06-05 10:55:43\",\"bcupdateTime\":\"2025-06-05 10:55:43\",\"bcdoctorName\":null,\"imageUrl\":null,\"zhupdateTime\":\"2025-06-05 10:55:43\",\"deptId\":599},{\"proId\":\"1878964342340526298\",\"deptName\":\"彩超室\",\"proName\":\"肝胆脾胰肾彩超\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2025-06-05 10:55:43\",\"bcupdateTime\":\"2025-06-05 10:55:43\",\"bcdoctorName\":null,\"imageUrl\":null,\"zhupdateTime\":\"2025-06-05 10:55:43\",\"deptId\":609},{\"proId\":\"1878964342340526330\",\"deptName\":\"彩超室\",\"proName\":\"膀胱前列腺彩超\",\"type\":0,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2025-06-05 10:55:43\",\"bcupdateTime\":\"2025-06-05 10:55:43\",\"bcdoctorName\":null,\"imageUrl\":null,\"zhupdateTime\":\"2025-06-05 10:55:43\",\"deptId\":609},{\"proId\":\"1870371396991955336\",\"deptName\":\"心电图\",\"proName\":\"心电图检查\",\"type\":1,\"doctorName\":null,\"sffs\":\"统收\",\"isPay\":\"已收费\",\"qdcreateTime\":\"2025-06-05 10:55:43\",\"bcupdateTime\":\"2025-06-05 11:12:50\",\"bcdoctorName\":null,\"imageUrl\":null,\"zhupdateTime\":\"2025-06-05 11:12:50\",\"deptId\":601}]";
//        return AjaxResult.success(JSONUtil.parseArray(json));
    }
    @GetMapping("/getJyTjList")
    public AjaxResult getJyTjList(@RequestParam("code")String code){
    public AjaxResult getJyTjList(@RequestParam("code") String code) {
//        log.info("tjList接口参数->{}",code);
        LambdaQueryWrapper<TjOrder> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TjOrder::getCardId,code)
        queryWrapper.eq(TjOrder::getCardId, code)
                .or()
                .eq(TjOrder::getTjNumber, code);
        TjOrder order = tjOrderService.getOne(queryWrapper);
        if (order == null){
            return AjaxResult.error("门诊号:"+code+"在体检系统中不存在");
        if (order == null) {
            return AjaxResult.error("门诊号:" + code + "在体检系统中不存在");
        }
        List<CsProVo> proVos = orderRemarkService.cSWebGetProByTjNumAndOrderIdJy(order.getTjNumber());
        if (null != proVos && !proVos.isEmpty()) {
@@ -212,7 +215,8 @@
    @Transactional
    @PostMapping("/asyncPacs")
    public AjaxResult asyncPacs(@RequestBody String json) {
        log.info("合并检测同步参数 ->{}",json);
        try {
            log.info("合并检测同步参数 ->{}", json);
//        try {
//            Thread.sleep(2000);
//        } catch (InterruptedException ignored) {
@@ -220,185 +224,492 @@
//        }
//        if (true)
//            return AjaxResult.error("同步失败请重试");
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        cn.hutool.json.JSONObject parseObj = JSONUtil.parseObj( json);
        cn.hutool.json.JSONObject pacs = parseObj.getJSONObject("pacs");
        cn.hutool.json.JSONArray lis = parseObj.getJSONArray("lis");
        cn.hutool.json.JSONObject tj = parseObj.getJSONObject("tj");
        if (pacs != null && !pacs.isEmpty()){
            String tjNum = pacs.getStr("tjnum");
            LambdaQueryWrapper<TjOrder> wrapper1 = new LambdaQueryWrapper<>();
            wrapper1.eq(TjOrder::getTjNumber,tjNum);
            TjOrder order = tjOrderService.getOne(wrapper1);
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            cn.hutool.json.JSONObject parseObj = JSONUtil.parseObj(json);
            cn.hutool.json.JSONObject pacs = parseObj.getJSONObject("pacs");
            cn.hutool.json.JSONArray lis = parseObj.getJSONArray("lis");
            cn.hutool.json.JSONObject tj = parseObj.getJSONObject("tj");
            if (pacs != null && !pacs.isEmpty()) {
                String tjNum = pacs.getStr("tjnum");
                LambdaQueryWrapper<TjOrder> wrapper1 = new LambdaQueryWrapper<>();
                wrapper1.eq(TjOrder::getTjNumber, tjNum);
                TjOrder order = tjOrderService.getOne(wrapper1);
            LtkjExamJcsqd ltkjExamJcsqd = new LtkjExamJcsqd();
            ltkjExamJcsqd.setTjh(order.getCardId());
                LtkjExamJcsqd ltkjExamJcsqd = new LtkjExamJcsqd();
                ltkjExamJcsqd.setTjh(order.getCardId());
            LambdaQueryWrapper<LtkjJianchajianyanTree> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(LtkjJianchajianyanTree::getCardId, order.getCardId());
            TjProject project = projectService.getById(tj.getStr("proId"));
            String xmdm = project.getHisXmbm();
            if (project.getSfzhfy().equals("N")){
                LambdaQueryWrapper<TjProject> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(TjProject::getProParentId,project.getProId());
                List<TjProject> list = projectService.list(wrapper);
                for (TjProject tjProject : list) {
                    if (StrUtil.isNotBlank(tjProject.getHisXmbm())){
                        xmdm = tjProject.getHisXmbm();
                        break;
                    }
                }
            }
            queryWrapper.eq(LtkjJianchajianyanTree::getType,"检查");
            queryWrapper.eq(LtkjJianchajianyanTree::getHisXmdm,xmdm);
            LtkjJianchajianyanTree tree = ltkjJianchajianyanTreeService.getOne(queryWrapper);
            ltkjExamJcsqd.setTmh("M_"+tree.getSqdh()+"_"+tree.getHisXmdm());
            ltkjExamJcsqd.setBgys(pacs.getStr("checkDoctorName"));
            ltkjExamJcsqd.setBgysid(pacs.getStr("checkDoctorCode"));
            ltkjExamJcsqd.setSqsj(format.format(tree.getCreateTime()));
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
            Date reportDate = null;
            try {
                reportDate = dateFormat.parse(pacs.getStr("reportDate"));
                ltkjExamJcsqd.setJgsj(format.format(reportDate));
            } catch (ParseException ignored) {
                ltkjExamJcsqd.setJgsj(format.format(new Date()));
            }
            String checkParts = pacs.getStr("checkParts");
            ltkjExamJcsqd.setJcxmmc(checkParts);
            ltkjExamJcsqd.setJcxmid(xmdm);
            ltkjExamJcsqd.setBw(checkParts);
            ltkjExamJcsqd.setJgzt(pacs.getStr("diagnosis"));
            ltkjExamJcsqd.setJgbx(pacs.getStr("examination"));
            boolean save1 = ltkjExamJcsqdService.save(ltkjExamJcsqd);
            LtkjExamJcbgd ltkjExamJcbgd = new LtkjExamJcbgd();
            ltkjExamJcbgd.setTjh(ltkjExamJcsqd.getTjh());
            ltkjExamJcbgd.setTmh(ltkjExamJcsqd.getTmh());
            ltkjExamJcbgd.setXmdm(ltkjExamJcsqd.getJcxmid());
            ltkjExamJcbgd.setXmmc(ltkjExamJcsqd.getJcxmmc());
            ltkjExamJcbgd.setBgUrl("");
            ltkjExamJcbgd.setShysxm(pacs.getStr("reportDoctorName"));
            ltkjExamJcbgd.setShysdm(pacs.getStr("reportDoctorCode"));
//            ltkjExamJcbgd.setYxzd(ltkjExamJcsqd.getJgzt());
//            ltkjExamJcbgd.setYxbx(ltkjExamJcsqd.getJgbx());
            ltkjExamJcbgd.setZdsj(ltkjExamJcsqd.getJgsj());
            ltkjExamJcbgd.setSqsj(ltkjExamJcsqd.getSqsj());
            ltkjExamJcbgd.setJcbw(ltkjExamJcsqd.getJcxmmc());
            ltkjExamJcbgd.setBgNr(ltkjExamJcsqd.getJgbx());
            ltkjExamJcbgd.setYxbx(ltkjExamJcsqd.getJgzt());
            ltkjExamJcbgd.setYxzd(ltkjExamJcsqd.getJgzt());
            boolean save2 = ltkjExamJcbgdService.save(ltkjExamJcbgd);
            if (save1 && save2) {
                try {
                    testMapper.updateDetailByTjJcCall(order.getCardId(), String.valueOf(order.getOrderId()), order.getTjNumber(), UserHoder.getLoginUser().getUserId());
                }catch (Exception e){
                    log.error(String.valueOf(e));
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error("同步失败请重试");
                }
            } else {
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return AjaxResult.error("同步失败请重试");
            }
            return AjaxResult.success();
        }else {
            cn.hutool.json.JSONObject entries = (cn.hutool.json.JSONObject) lis.get(0);
            String tjNum = entries.getStr("tjNum");
            LtkjHysqd hysqd = new LtkjHysqd();
            LambdaQueryWrapper<TjOrder> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(TjOrder::getTjNumber,tjNum);
            TjOrder order = tjOrderService.getOne(wrapper);
            hysqd.setTjh(order.getCardId());
            String mzh = order.getCardId();
            LambdaQueryWrapper<LtkjJianchajianyanTree> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(LtkjJianchajianyanTree::getCardId, mzh);
            TjProject project = projectService.getById(tj.getStr("proId"));
            String xmdm = project.getHisXmbm();
            queryWrapper.eq(LtkjJianchajianyanTree::getType,"检验");
            queryWrapper.eq(LtkjJianchajianyanTree::getHisXmdm,xmdm);
            LtkjJianchajianyanTree tree = ltkjJianchajianyanTreeService.getOne(queryWrapper);
            if (tree == null) {
                tree = new LtkjJianchajianyanTree();
                tree.setHisXmdm(xmdm);
                tree.setCreateTime(new Date());
                String sqdh = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + String.valueOf(RandomUtil.randomInt(0, 99999));
                queryWrapper = new LambdaQueryWrapper<>();
                queryWrapper.eq(LtkjJianchajianyanTree::getSqdh,sqdh);
                if (ltkjJianchajianyanTreeService.getOne(queryWrapper) == null) {
                    tree.setSqdh(sqdh);
                }else {
                    while (true){
                        sqdh = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + String.valueOf(RandomUtil.randomInt(0, 99999));
                        queryWrapper = new LambdaQueryWrapper<>();
                        queryWrapper.eq(LtkjJianchajianyanTree::getSqdh,sqdh);
                        if (ltkjJianchajianyanTreeService.getOne(queryWrapper) == null) {
                            tree.setSqdh(sqdh);
                LambdaQueryWrapper<LtkjJianchajianyanTree> queryWrapper = new LambdaQueryWrapper<>();
                queryWrapper.eq(LtkjJianchajianyanTree::getCardId, order.getCardId());
                TjProject project = projectService.getById(tj.getStr("proId"));
                String xmdm = project.getHisXmbm();
                if (project.getSfzhfy().equals("N")) {
                    LambdaQueryWrapper<TjProject> wrapper = new LambdaQueryWrapper<>();
                    wrapper.eq(TjProject::getProParentId, project.getProId());
                    List<TjProject> list = projectService.list(wrapper);
                    for (TjProject tjProject : list) {
                        if (StrUtil.isNotBlank(tjProject.getHisXmbm())) {
                            xmdm = tjProject.getHisXmbm();
                            break;
                        }
                    }
                }
            }
            String tmh = tree.getSqdh()+"_"+tree.getHisXmdm();
            String shys = "";
            for (Object o : lis) {
                cn.hutool.json.JSONObject jsonObject = (cn.hutool.json.JSONObject) o;
                if (StrUtil.isNotBlank(jsonObject.getStr("jyxh"))) tmh = jsonObject.getStr("jyxh");
                if (StrUtil.isNotBlank(jsonObject.getStr("shys"))) shys = jsonObject.getStr("shys");
                if (StrUtil.isNotBlank(tmh) && StrUtil.isNotBlank(shys) && StrUtil.isNotBlank(jsonObject.getStr("jyxh"))) break;
            }
            hysqd.setTmh(tmh);
            if (StrUtil.isNotBlank(xmdm)) {
                hysqd.setXmid(xmdm);
                hysqd.setXmmc(project.getHisXmmc());
            }else {
                hysqd.setXmid(String.valueOf(project.getProId()));
                hysqd.setXmmc(project.getProName());
            }
            hysqd.setSqsj(format.format(tree.getCreateTime()));
            hysqd.setJgsj(format.format(new Date()));
            hysqd.setShrxm(shys);
//            hysqd.setBbmc();
            hysqdService.deletedByTjhAndXmId(hysqd.getTjh(),hysqd.getXmid());
            hybgdService.deletedLtkjHybgdByTjhAndTmh(tree.getSqdh()+"_"+tree.getHisXmdm());
            hysqdService.save(hysqd);
            for (Object object : lis) {
                cn.hutool.json.JSONObject jsonObject = (cn.hutool.json.JSONObject) object;
                LtkjHybgd hybgd = new LtkjHybgd();
                hybgd.setTmh(tree.getSqdh()+"_"+tree.getHisXmdm());
                hybgd.setJcxmid(jsonObject.getStr("jcxmid"));
                hybgd.setJcxm(jsonObject.getStr("proName"));
                hybgd.setJyjg(jsonObject.getStr("proResult"));
                hybgd.setJgdw(jsonObject.getStr("company"));
                String tjStandardGtValue = jsonObject.getStr("tjStandardGtValue");
                String zdz = "";
                String zxz = "";
                if (tjStandardGtValue.contains("-")){
                    String[] split = tjStandardGtValue.split("-");
                    zxz = split[0].trim();
                    zdz = split[1].trim();
                queryWrapper.eq(LtkjJianchajianyanTree::getType, "检查");
                queryWrapper.eq(LtkjJianchajianyanTree::getHisXmdm, xmdm);
                LtkjJianchajianyanTree tree = ltkjJianchajianyanTreeService.getOne(queryWrapper);
                ltkjExamJcsqd.setTmh("M_" + tree.getSqdh() + "_" + tree.getHisXmdm());
                ltkjExamJcsqd.setBgys(pacs.getStr("checkDoctorName"));
                ltkjExamJcsqd.setBgysid(pacs.getStr("checkDoctorCode"));
                ltkjExamJcsqd.setSqsj(format.format(tree.getCreateTime()));
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
                Date reportDate = null;
                try {
                    reportDate = dateFormat.parse(pacs.getStr("reportDate"));
                    ltkjExamJcsqd.setJgsj(format.format(reportDate));
                } catch (ParseException ignored) {
                    ltkjExamJcsqd.setJgsj(format.format(new Date()));
                }
                hybgd.setFwzdz(zdz);
                hybgd.setFwzgz(zxz);
                hybgd.setFwz(tjStandardGtValue);
                hybgd.setJysj(jsonObject.getStr("examinationDate"));
                hybgd.setShsj(jsonObject.getStr("examinationDate"));
                hybgd.setJyys(jsonObject.getStr("checkDoctorName"));
                hybgd.setShysmc(shys);
                hybgd.setYcbz(jsonObject.getStr("ycbz"));
                hybgdService.save(hybgd);
                String checkParts = pacs.getStr("checkParts");
                //            ltkjExamJcsqd.setJcxmmc(checkParts);
                //            ltkjExamJcsqd.setJcxmid(xmdm);
                ltkjExamJcsqd.setJcxmmc(project.getProName());
                ltkjExamJcsqd.setJcxmid(project.getProId().toString());
                ltkjExamJcsqd.setBw(checkParts);
                ltkjExamJcsqd.setJgzt(pacs.getStr("diagnosis"));
                ltkjExamJcsqd.setJgbx(pacs.getStr("examination"));
                ltkjExamJcsqd.setSgorzd("1");
                ltkjExamJcsqd.setCreateTime(new Date());
                ltkjExamJcsqdService.deletedLtkjJcsqdByTjhAndXmId(ltkjExamJcsqd.getTjh(), ltkjExamJcsqd.getJcxmid());
                boolean save1 = ltkjExamJcsqdService.save(ltkjExamJcsqd);
                log.info("手动同步检查结果状态 ->{}", ltkjExamJcsqd.getJgzt());
                if (StringUtil.isNotBlank(ltkjExamJcsqd.getJgzt())) {
                    jcycxmService.deletedByTjh(order.getTjNumber());
                    String[] split = ltkjExamJcsqd.getJgzt().replaceAll("\n", "").split("。|;|;|,|,");
                    log.info("进入检查结果异常提取分割方法体 ->{}->{}", order.getTjNumber(), split);
                    for (String jg : split) {
                        if (StringUtil.isNotBlank(jg) && !jg.contains("未见异常")
                                && !jg.contains("未见明显异常") && !jg.contains("未见占位") && !jg.contains("未见")
                                && !jg.contains("未见明显") && !jg.contains("正常") && !jg.contains("双侧椎间孔无狭窄")) {
                            TjJcycxm jcycxm = new TjJcycxm();
                            jcycxm.setTjh(order.getTjNumber());
                            jcycxm.setYqid("jczyy");
                            String[] split1 = ltkjExamJcsqd.getJcxmid().split(";");
                            jcycxm.setProId(split1[0]);
                            jcycxm.setProName(ltkjExamJcsqd.getJcxmmc());
                            jcycxm.setCreateTime(new Date());
                            jcycxm.setJcjg(jg);
                            jcycxmService.save(jcycxm);
                        }
                    }
                }
                LtkjExamJcbgd ltkjExamJcbgd = new LtkjExamJcbgd();
                ltkjExamJcbgd.setTjh(ltkjExamJcsqd.getTjh());
                ltkjExamJcbgd.setTmh(ltkjExamJcsqd.getTmh());
                //            ltkjExamJcbgd.setXmdm(ltkjExamJcsqd.getJcxmid());
                //            ltkjExamJcbgd.setXmmc(ltkjExamJcsqd.getJcxmmc());
                ltkjExamJcbgd.setXmdm(project.getProId().toString());
                ltkjExamJcbgd.setXmmc(project.getProName());
                ltkjExamJcbgd.setBgUrl("");
                ltkjExamJcbgd.setShysxm(pacs.getStr("reportDoctorName"));
                ltkjExamJcbgd.setShysdm(pacs.getStr("reportDoctorCode"));
                //            ltkjExamJcbgd.setYxzd(ltkjExamJcsqd.getJgzt());
                //            ltkjExamJcbgd.setYxbx(ltkjExamJcsqd.getJgbx());
                ltkjExamJcbgd.setZdsj(ltkjExamJcsqd.getJgsj());
                ltkjExamJcbgd.setSqsj(ltkjExamJcsqd.getSqsj());
                ltkjExamJcbgd.setJcbw(ltkjExamJcsqd.getJcxmmc());
                ltkjExamJcbgd.setBgNr(ltkjExamJcsqd.getJgbx());
                ltkjExamJcbgd.setYxbx(ltkjExamJcsqd.getJgzt());
                ltkjExamJcbgd.setYxzd(ltkjExamJcsqd.getJgzt());
                ltkjExamJcbgd.setSgorzd("1");
                ltkjExamJcsqd.setCreateTime(new Date());
                ltkjExamJcbgdService.deletedLtkjJcbgdByTjhAndTmhA(ltkjExamJcsqd.getTjh(), ltkjExamJcsqd.getTmh());
                boolean save2 = ltkjExamJcbgdService.save(ltkjExamJcbgd);
                if (save1 && save2) {
                    try {
                        testMapper.updateDetailByTjJcCall(order.getCardId(), String.valueOf(order.getOrderId()), order.getTjNumber(), UserHoder.getLoginUser().getUserId());
                    } catch (Exception e) {
                        log.error(String.valueOf(e));
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        return AjaxResult.error("同步失败请重试");
                    }
                } else {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error("同步失败请重试");
                }
                return AjaxResult.success();
            } else {
                cn.hutool.json.JSONObject entries = (cn.hutool.json.JSONObject) lis.get(0);
                String tjNum = entries.getStr("tjNum");
                LtkjHysqd hysqd = new LtkjHysqd();
                TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
                hysqd.setTjh(order.getCardId());
                String mzh = order.getCardId();
                LambdaQueryWrapper<LtkjJianchajianyanTree> queryWrapper = new LambdaQueryWrapper<>();
                queryWrapper.eq(LtkjJianchajianyanTree::getCardId, mzh);
                TjProject project = projectService.getById(tj.getStr("proId"));
                String xmdm = project.getHisXmbm();
                queryWrapper.eq(LtkjJianchajianyanTree::getType, "检验");
                queryWrapper.eq(LtkjJianchajianyanTree::getHisXmdm, xmdm);
                LtkjJianchajianyanTree tree = ltkjJianchajianyanTreeService.getOne(queryWrapper);
                String tmh;
                if (tree == null) {
                    tree = new LtkjJianchajianyanTree();
                    tree.setHisXmdm(xmdm);
                    tree.setCreateTime(new Date());
                    String sqdh = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + String.valueOf(RandomUtil.randomInt(0, 99999));
                    queryWrapper = new LambdaQueryWrapper<>();
                    queryWrapper.eq(LtkjJianchajianyanTree::getSqdh, sqdh);
                    if (ltkjJianchajianyanTreeService.getOne(queryWrapper) == null) {
                        tree.setSqdh(sqdh);
                    } else {
                        while (true) {
                            sqdh = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + String.valueOf(RandomUtil.randomInt(0, 99999));
                            queryWrapper = new LambdaQueryWrapper<>();
                            queryWrapper.eq(LtkjJianchajianyanTree::getSqdh, sqdh);
                            if (ltkjJianchajianyanTreeService.getOne(queryWrapper) == null) {
                                tree.setSqdh(sqdh);
                                break;
                            }
                        }
                    }
                    tmh = tree.getSqdh() + "_" + tree.getHisXmdm();
                } else {
                    tmh = tree.getSqdh();
                }
                String shys = "";
                for (Object o : lis) {
                    cn.hutool.json.JSONObject jsonObject = (cn.hutool.json.JSONObject) o;
                    if (StrUtil.isNotBlank(jsonObject.getStr("jyxh"))) tmh = jsonObject.getStr("jyxh");
                    if (StrUtil.isNotBlank(jsonObject.getStr("shys"))) shys = jsonObject.getStr("shys");
                    if (StrUtil.isNotBlank(tmh) && StrUtil.isNotBlank(shys) && StrUtil.isNotBlank(jsonObject.getStr("jyxh")))
                        break;
                }
                hysqd.setTmh(tmh);
                //            if (StrUtil.isNotBlank(xmdm)) {
                //                hysqd.setXmid(xmdm);
                //                hysqd.setXmmc(project.getHisXmmc());
                //            }else {
                //                hysqd.setXmid(String.valueOf(project.getProId()));
                //                hysqd.setXmmc(project.getProName());
                //            }
                hysqd.setXmid(project.getProId().toString());
                hysqd.setXmmc(project.getProName());
                hysqd.setSqsj(format.format(tree.getCreateTime()));
                hysqd.setJgsj(format.format(new Date()));
                hysqd.setShrxm(shys);
                hysqd.setCreateTime(new Date());
                //            hysqd.setBbmc();
                hysqdService.deletedByTjhAndXmId(hysqd.getTjh(), hysqd.getXmid());
                hybgdService.deletedLtkjHybgdByTjhAndTmh(tmh);
                hysqdService.save(hysqd);
                for (Object object : lis) {
                    cn.hutool.json.JSONObject jsonObject = (cn.hutool.json.JSONObject) object;
                    LtkjHybgd hybgd = new LtkjHybgd();
                    hybgd.setTmh(tmh);
                    hybgd.setJcxmid(jsonObject.getStr("jcxmid"));
                    hybgd.setJcxm(jsonObject.getStr("proName"));
                    hybgd.setJyjg(jsonObject.getStr("proResult"));
                    hybgd.setJgdw(jsonObject.getStr("company"));
                    String tjStandardGtValue = jsonObject.getStr("tjStandardGtValue");
                    String zdz = "";
                    String zxz = "";
                    if (tjStandardGtValue.contains("-")) {
                        String[] split = tjStandardGtValue.split("-");
                        zxz = split[0].trim();
                        zdz = split[1].trim();
                    }
                    hybgd.setFwzdz(zdz);
                    hybgd.setFwzgz(zxz);
                    hybgd.setFwz(tjStandardGtValue);
                    hybgd.setJysj(jsonObject.getStr("examinationDate"));
                    hybgd.setShsj(jsonObject.getStr("examinationDate"));
                    hybgd.setJyys(jsonObject.getStr("checkDoctorName"));
                    hybgd.setShysmc(shys);
                    hybgd.setYcbz(jsonObject.getStr("ycbz"));
                    hybgd.setCreateTime(new Date());
                    hybgdService.save(hybgd);
                }
                try {
                    testMapper.updateDetailByCall(order.getCardId(), String.valueOf(order.getOrderId()), order.getTjNumber(), UserHoder.getLoginUser().getUserId());
                } catch (Exception e) {
                    log.error(String.valueOf(e));
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error("同步失败请重试");
                }
                return AjaxResult.success();
            }
            try {
                testMapper.updateDetailByCall(order.getCardId(), String.valueOf(order.getOrderId()), order.getTjNumber(), UserHoder.getLoginUser().getUserId());
            }catch (Exception e){
                log.error(String.valueOf(e));
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return AjaxResult.error("同步失败请重试");
        } catch (NoTransactionException e) {
            log.error(String.valueOf(e));
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return AjaxResult.error("同步失败请重试");
        }
    }
    @Transactional
    @PostMapping("/newasyncPacs")
    public AjaxResult newasyncPacs(@RequestBody String json) {
        try {
            log.info("合并检测同步参数 ->{}", json);
//        try {
//            Thread.sleep(2000);
//        } catch (InterruptedException ignored) {
//
//        }
//        if (true)
//            return AjaxResult.error("同步失败请重试");
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            cn.hutool.json.JSONObject parseObj = JSONUtil.parseObj(json);
            cn.hutool.json.JSONArray pacss = parseObj.getJSONArray("pacs");
            cn.hutool.json.JSONArray lis = parseObj.getJSONArray("lis");
            cn.hutool.json.JSONObject tj = parseObj.getJSONObject("tj");
            if (pacss != null && !pacss.isEmpty()) {
                cn.hutool.json.JSONObject entries = (cn.hutool.json.JSONObject) pacss.get(0);
                String tjNum = entries.getStr("tjNum");
                LambdaQueryWrapper<TjOrder> wrapper1 = new LambdaQueryWrapper<>();
                wrapper1.eq(TjOrder::getTjNumber, tjNum);
                TjOrder order = tjOrderService.getOne(wrapper1);
                for (Object o : pacss) {
                    cn.hutool.json.JSONObject pacs = (cn.hutool.json.JSONObject) o;
                    if (pacs != null && !pacs.isEmpty()) {
                        LtkjExamJcsqd ltkjExamJcsqd = new LtkjExamJcsqd();
                        ltkjExamJcsqd.setTjh(order.getCardId());
                        LambdaQueryWrapper<LtkjJianchajianyanTree> queryWrapper = new LambdaQueryWrapper<>();
                        queryWrapper.eq(LtkjJianchajianyanTree::getCardId, order.getCardId());
                        TjProject project = projectService.getById(tj.getStr("proId"));
                        String xmdm = project.getHisXmbm();
                        if (project.getSfzhfy().equals("N")) {
                            LambdaQueryWrapper<TjProject> wrapper = new LambdaQueryWrapper<>();
                            wrapper.eq(TjProject::getProParentId, project.getProId());
                            List<TjProject> list = projectService.list(wrapper);
                            for (TjProject tjProject : list) {
                                if (StrUtil.isNotBlank(tjProject.getHisXmbm())) {
                                    xmdm = tjProject.getHisXmbm();
                                    break;
                                }
                            }
                        }
                        queryWrapper.eq(LtkjJianchajianyanTree::getType, "检查");
                        queryWrapper.eq(LtkjJianchajianyanTree::getHisXmdm, xmdm);
                        LtkjJianchajianyanTree tree = ltkjJianchajianyanTreeService.getOne(queryWrapper);
                        String brid = pacs.getStr("brid");
                        ltkjExamJcsqd.setTmh(brid + tree.getHisXmdm());
                        ltkjExamJcsqd.setBgys(pacs.getStr("checkDoctorName"));
                        ltkjExamJcsqd.setBgysid(pacs.getStr("checkDoctorCode"));
                        ltkjExamJcsqd.setSqsj(format.format(tree.getCreateTime()));
                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
                        Date reportDate = null;
                        try {
                            reportDate = dateFormat.parse(pacs.getStr("reportDate"));
                            ltkjExamJcsqd.setJgsj(format.format(reportDate));
                        } catch (ParseException ignored) {
                            ltkjExamJcsqd.setJgsj(format.format(new Date()));
                        }
                        String checkParts = pacs.getStr("checkParts");
                        //            ltkjExamJcsqd.setJcxmmc(checkParts);
                        //            ltkjExamJcsqd.setJcxmid(xmdm);
                        ltkjExamJcsqd.setJcxmmc(project.getProName());
                        ltkjExamJcsqd.setJcxmid(project.getProId().toString());
                        ltkjExamJcsqd.setBw(checkParts);
                        ltkjExamJcsqd.setJgzt(pacs.getStr("diagnosis"));
                        ltkjExamJcsqd.setJgbx(pacs.getStr("examination"));
                        ltkjExamJcsqd.setSgorzd("1");
                        ltkjExamJcsqd.setCreateTime(new Date());
//                        ltkjExamJcsqdService.deletedLtkjJcsqdByTjhAndXmId(ltkjExamJcsqd.getTjh(), ltkjExamJcsqd.getJcxmid());
                        ltkjExamJcsqdService.sdtbdeletedLtkjJcsqdByTjhandtmh(ltkjExamJcsqd.getTjh(), ltkjExamJcsqd.getTmh());
                        boolean save1 = ltkjExamJcsqdService.save(ltkjExamJcsqd);
                        log.info("手动同步检查结果状态 ->{}", ltkjExamJcsqd.getJgzt());
                        if (StringUtil.isNotBlank(ltkjExamJcsqd.getJgzt())) {
                            jcycxmService.deletedByTjh(order.getTjNumber());
                            String[] split = ltkjExamJcsqd.getJgzt().replaceAll("\n", "").split("。|;|;|,|,");
                            log.info("进入检查结果异常提取分割方法体 ->{}->{}", order.getTjNumber(), split);
                            for (String jg : split) {
                                if (StringUtil.isNotBlank(jg) && !jg.contains("未见异常")
                                        && !jg.contains("未见明显异常") && !jg.contains("未见占位") && !jg.contains("未见")
                                        && !jg.contains("未见明显") && !jg.contains("正常") && !jg.contains("双侧椎间孔无狭窄")) {
                                    TjJcycxm jcycxm = new TjJcycxm();
                                    jcycxm.setTjh(order.getTjNumber());
                                    jcycxm.setYqid("jczyy");
                                    String[] split1 = ltkjExamJcsqd.getJcxmid().split(";");
                                    jcycxm.setProId(split1[0]);
                                    jcycxm.setProName(ltkjExamJcsqd.getJcxmmc());
                                    jcycxm.setCreateTime(new Date());
                                    jcycxm.setJcjg(jg);
                                    jcycxmService.save(jcycxm);
                                }
                            }
                        }
                        LtkjExamJcbgd ltkjExamJcbgd = new LtkjExamJcbgd();
                        ltkjExamJcbgd.setTjh(ltkjExamJcsqd.getTjh());
                        ltkjExamJcbgd.setTmh(ltkjExamJcsqd.getTmh());
                        //            ltkjExamJcbgd.setXmdm(ltkjExamJcsqd.getJcxmid());
                        //            ltkjExamJcbgd.setXmmc(ltkjExamJcsqd.getJcxmmc());
                        ltkjExamJcbgd.setXmdm(project.getProId().toString());
                        ltkjExamJcbgd.setXmmc(project.getProName());
                        ltkjExamJcbgd.setBgUrl("");
                        ltkjExamJcbgd.setShysxm(pacs.getStr("reportDoctorName"));
                        ltkjExamJcbgd.setShysdm(pacs.getStr("reportDoctorCode"));
                        //            ltkjExamJcbgd.setYxzd(ltkjExamJcsqd.getJgzt());
                        //            ltkjExamJcbgd.setYxbx(ltkjExamJcsqd.getJgbx());
                        ltkjExamJcbgd.setZdsj(ltkjExamJcsqd.getJgsj());
                        ltkjExamJcbgd.setSqsj(ltkjExamJcsqd.getSqsj());
                        ltkjExamJcbgd.setJcbw(ltkjExamJcsqd.getJcxmmc());
                        ltkjExamJcbgd.setBgNr(ltkjExamJcsqd.getJgbx());
                        ltkjExamJcbgd.setYxbx(ltkjExamJcsqd.getJgzt());
                        ltkjExamJcbgd.setYxzd(ltkjExamJcsqd.getJgzt());
                        ltkjExamJcbgd.setSgorzd("1");
                        ltkjExamJcsqd.setCreateTime(new Date());
                        ltkjExamJcbgdService.deletedLtkjJcbgdByTjhAndTmhA(ltkjExamJcsqd.getTjh(), ltkjExamJcsqd.getTmh());
                        boolean save2 = ltkjExamJcbgdService.save(ltkjExamJcbgd);
                        if (save1 && save2) {
                            try {
                                testMapper.updateDetailByTjJcCall(order.getCardId(), String.valueOf(order.getOrderId()), order.getTjNumber(), UserHoder.getLoginUser().getUserId());
                            } catch (Exception e) {
                                log.error(String.valueOf(e));
                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                                return AjaxResult.error("同步失败请重试");
                            }
                        } else {
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                            return AjaxResult.error("同步失败请重试");
                        }
                    }
                }
                return AjaxResult.success();
            } else {
                cn.hutool.json.JSONObject entries = (cn.hutool.json.JSONObject) lis.get(0);
                String tjNum = entries.getStr("tjNum");
                LtkjHysqd hysqd = new LtkjHysqd();
                TjOrder order = tjOrderService.getOrderByTjNum(tjNum);
                hysqd.setTjh(order.getCardId());
                String mzh = order.getCardId();
                LambdaQueryWrapper<LtkjJianchajianyanTree> queryWrapper = new LambdaQueryWrapper<>();
                queryWrapper.eq(LtkjJianchajianyanTree::getCardId, mzh);
                TjProject project = projectService.getById(tj.getStr("proId"));
                String xmdm = project.getHisXmbm();
                queryWrapper.eq(LtkjJianchajianyanTree::getType, "检验");
                queryWrapper.eq(LtkjJianchajianyanTree::getHisXmdm, xmdm);
                LtkjJianchajianyanTree tree = ltkjJianchajianyanTreeService.getOne(queryWrapper);
                String tmh;
                if (tree == null) {
                    tree = new LtkjJianchajianyanTree();
                    tree.setHisXmdm(xmdm);
                    tree.setCreateTime(new Date());
                    String sqdh = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + String.valueOf(RandomUtil.randomInt(0, 99999));
                    queryWrapper = new LambdaQueryWrapper<>();
                    queryWrapper.eq(LtkjJianchajianyanTree::getSqdh, sqdh);
                    if (ltkjJianchajianyanTreeService.getOne(queryWrapper) == null) {
                        tree.setSqdh(sqdh);
                    } else {
                        while (true) {
                            sqdh = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + String.valueOf(RandomUtil.randomInt(0, 99999));
                            queryWrapper = new LambdaQueryWrapper<>();
                            queryWrapper.eq(LtkjJianchajianyanTree::getSqdh, sqdh);
                            if (ltkjJianchajianyanTreeService.getOne(queryWrapper) == null) {
                                tree.setSqdh(sqdh);
                                break;
                            }
                        }
                    }
                    tmh = tree.getSqdh() + "_" + tree.getHisXmdm();
                } else {
                    tmh = tree.getSqdh();
                }
                String shys = "";
                for (Object o : lis) {
                    cn.hutool.json.JSONObject jsonObject = (cn.hutool.json.JSONObject) o;
                    if (StrUtil.isNotBlank(jsonObject.getStr("jyxh"))) tmh = jsonObject.getStr("jyxh");
                    if (StrUtil.isNotBlank(jsonObject.getStr("shys"))) shys = jsonObject.getStr("shys");
                    if (StrUtil.isNotBlank(tmh) && StrUtil.isNotBlank(shys) && StrUtil.isNotBlank(jsonObject.getStr("jyxh")))
                        break;
                }
                hysqd.setTmh(tmh);
                //            if (StrUtil.isNotBlank(xmdm)) {
                //                hysqd.setXmid(xmdm);
                //                hysqd.setXmmc(project.getHisXmmc());
                //            }else {
                //                hysqd.setXmid(String.valueOf(project.getProId()));
                //                hysqd.setXmmc(project.getProName());
                //            }
                hysqd.setXmid(project.getProId().toString());
                hysqd.setXmmc(project.getProName());
                hysqd.setSqsj(format.format(tree.getCreateTime()));
                hysqd.setJgsj(format.format(new Date()));
                hysqd.setShrxm(shys);
                hysqd.setCreateTime(new Date());
                //            hysqd.setBbmc();
                hysqdService.deletedByTjhAndXmId(hysqd.getTjh(), hysqd.getXmid());
                hybgdService.deletedLtkjHybgdByTjhAndTmh(tmh);
                hysqdService.save(hysqd);
                for (Object object : lis) {
                    cn.hutool.json.JSONObject jsonObject = (cn.hutool.json.JSONObject) object;
                    LtkjHybgd hybgd = new LtkjHybgd();
                    hybgd.setTmh(tmh);
                    hybgd.setJcxmid(jsonObject.getStr("jcxmid"));
                    hybgd.setJcxm(jsonObject.getStr("proName"));
                    hybgd.setJyjg(jsonObject.getStr("proResult"));
                    hybgd.setJgdw(jsonObject.getStr("company"));
                    String tjStandardGtValue = jsonObject.getStr("tjStandardGtValue");
                    String zdz = "";
                    String zxz = "";
                    if (tjStandardGtValue.contains("-")) {
                        String[] split = tjStandardGtValue.split("-");
                        zxz = split[0].trim();
                        zdz = split[1].trim();
                    }
                    hybgd.setFwzdz(zdz);
                    hybgd.setFwzgz(zxz);
                    hybgd.setFwz(tjStandardGtValue);
                    hybgd.setJysj(jsonObject.getStr("examinationDate"));
                    hybgd.setShsj(jsonObject.getStr("examinationDate"));
                    hybgd.setJyys(jsonObject.getStr("checkDoctorName"));
                    hybgd.setShysmc(shys);
                    hybgd.setYcbz(jsonObject.getStr("ycbz"));
                    hybgd.setCreateTime(new Date());
                    hybgdService.save(hybgd);
                }
                try {
                    testMapper.updateDetailByCall(order.getCardId(), String.valueOf(order.getOrderId()), order.getTjNumber(), UserHoder.getLoginUser().getUserId());
                } catch (Exception e) {
                    log.error(String.valueOf(e));
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    return AjaxResult.error("同步失败请重试");
                }
                return AjaxResult.success();
            }
            return AjaxResult.success();
        } catch (NoTransactionException e) {
            log.error(String.valueOf(e));
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return AjaxResult.error("同步失败请重试");
        }
    }
@@ -409,7 +720,7 @@
        System.out.println(json.toJSONString());
        String tjNumber = json.get("tjNumber").toString();
        String reportName = json.get("reportName").toString();
        System.out.println("用户: "+tjNumber+reportName+" 已打印");
        System.out.println("用户: " + tjNumber + reportName + " 已打印");
    }
}