zhaowenxuan
2024-10-21 936e2c79cd741472a6acfe28d730eb644b082cf7
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
@@ -57,6 +57,7 @@
import com.ltkj.hosp.hisDto.OutpinimpapplyDto;
import com.ltkj.hosp.hisDto.OutpinmedicapplyDto;
import com.ltkj.hosp.mapper.TestMapper;
import com.ltkj.hosp.mapper.TjSamplingMapper;
import com.ltkj.hosp.pacsDto.SavePacsApply;
import com.ltkj.hosp.service.*;
import com.ltkj.hosp.sqlDomain.LtkjMiddleDetail;
@@ -78,6 +79,7 @@
import com.ltkj.web.controller.his.*;
import com.ltkj.web.controller.lis.LisApiMethod;
import com.ltkj.web.controller.pacs.PacsApiMethodService;
import com.ltkj.web.controller.service.TjSysAsyncServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -211,6 +213,10 @@
    private HisPDFUtil hisPDFUtil;
    @Value("${path.reportServer}")
    private String urlValue;
    @Autowired
    private ITjSamplingService samplingService;
    @Autowired
    private TjSamplingMapper tjSamplingMapper;
    //将方法返回值解析成json格式
    public JSONObject getJSONObject(String builder) {
@@ -874,13 +880,12 @@
    }
    /**
     * 体检签到登记接口
     */
    ReentrantLock lock=new ReentrantLock();
    ReentrantLock lock = new ReentrantLock();
    @PostMapping
    @ApiOperation(value = "体检签到登记接口")
@@ -976,7 +981,7 @@
        try {
            boolean b = lock.tryLock(3, TimeUnit.MINUTES);
            if(b){
            if (b) {
                //生成体检号
                String tjNumber = (SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
                tjOrder.setTjNumber(tjNumber);
@@ -1046,7 +1051,7 @@
                            tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
                            tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
                            tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount());
    //                    tjFlowingWater.setPayStasus(0L);
                            //                    tjFlowingWater.setPayStasus(0L);
                        }
                    }
                    if (tjFlowingWaterService.save(tjFlowingWater)) {
@@ -1082,24 +1087,15 @@
                            newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                        }
                        // 查询 对接Lis、Pacs申请如果类型包含在配置内则使用对接lis、pacs
//                        String useLisAndPacsRegisterDictTeam = configService.selectConfigByKey("use_lis_and_pacs_register_dict_team");
//                        String[] split = useLisAndPacsRegisterDictTeam.split(",");
//                        List<String> list = Arrays.asList(split);
//                        if (list.contains(tjOrder.getTjType())) {
//                            List<TbTransition> detailList = tbTransitionService.getTbTransitionListByCusId(tjCustomer.getCusIdcard(),tjOrder.getCardId());
//                            try {
//                                lisApiMethod.save(tjOrder,tjCustomer,detailList);
//                                pacsApiMethodService.save(tjOrder,tjCustomer,detailList);
//                            }catch (Exception e){
//                                String jyxh = "";
//                                String cardId = "";
//                                String cusName = "";
//                                lisApiMethod.cancel(jyxh,cardId,cusName);
//                            }
//                        }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());
                        if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) {
                            // 这是上面个人方法引入数据
                            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;
                        }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());
                        return AjaxResult.success(tjNumber);
                    } else {
                        tjCustomer.setCardId(tjOrder.getTjNumber());
@@ -2562,6 +2558,7 @@
            customer.setCardId("0");
            tjCustomerService.updateById(customer);
            String configByKey = configService.selectConfigByKey("sfkqdyhis");
            tjSamplingMapper.deleteByTjNumAndCusId(tjNum,order.getUserId());
            if (configByKey.equals("Y")) {
                HashMap<String, Object> hisRequestParams = new HashMap<>();
@@ -2580,7 +2577,7 @@
                        return AjaxResult.error("撤销失败,该人员已缴费,请先退费!");
                    }
                }
                boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order);
                boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order, lisApiMethod.isUseLisAndPacsRegister(order));
                if (zfHisApiMethods) {
                    return AjaxResult.success("撤销成功");
                } else {
@@ -2589,7 +2586,6 @@
                }
            }
            return AjaxResult.success("撤销成功!!!");
        }
        return AjaxResult.success("签到记录不存在!");
    }
@@ -2726,7 +2722,9 @@
    @Transactional
    public AjaxResult revokeTjOrderByTjCardId(@RequestParam @ApiParam(value = "就诊号") String cardId) {
        TjOrder order = new TjOrder();
        LambdaQueryWrapper<TjOrder> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TjOrder::getCardId, cardId);
        TjOrder order = tjOrderService.getOne(queryWrapper);
        order.setCardId(cardId);
        String configByKey = configService.selectConfigByKey("sfkqdyhis");
        if (configByKey.equals("Y")) {
@@ -2746,7 +2744,7 @@
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return AjaxResult.error("撤销失败,门诊患者费用清单信息不为空");
            } else {
                boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order);
                boolean zfHisApiMethods = hisApiMethod.ZfHisApiMethods(null, order, lisApiMethod.isUseLisAndPacsRegister(order));
                if (zfHisApiMethods) {
                    return AjaxResult.success("撤销成功", map);
                } else {
@@ -2816,10 +2814,11 @@
    @PostMapping("/revokeBlProByBldhAndTjh")
    @ApiOperation(value = "根据补录单号和体检号删除记录")
    @Transactional
//    @Transactional
    public AjaxResult revokeBlProByBldhAndTjh(@RequestBody TjProBlDto dto) {
        if (null == dto.getBldhs() || dto.getBldhs().size() == 0) {
            log.info("请选择要撤销的补录项目");
            return AjaxResult.error("请选择要撤销的补录项目");
        }
@@ -2827,42 +2826,66 @@
        if (null != order) {
            String configByKey = configService.selectConfigByKey("sfkqdyhis");
            if (null != configByKey && configByKey.equals("Y")) {
                log.info("dto的数据是" + JSONUtil.toJsonStr(dto));
                HashMap<String, Object> hisRequestParams = new HashMap<>();
                hisRequestParams.put("patientId", order.getCardId());
                AjaxResult queryPay = hisApiGetMethodService.getHISDataNew("QueryPay", hisRequestParams);
                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");
                    BigDecimal cateFeeAll = BigDecimal.ZERO;
                    List<String> advIds = new ArrayList<>();
                    for (Map<String, String> datum : data) {
                        String advId = datum.get("Adv_Id").split("_")[1];
                        BigDecimal cateFee = new BigDecimal(datum.get("CateFee"));
                        cateFeeAll = cateFeeAll.add(cateFee);
                        advIds.add(advId);
                    log.info("data的数据是" + JSONUtil.toJsonStr(data));
//                    BigDecimal cateFeeAll = BigDecimal.ZERO;
//                    List<String> advIds = new ArrayList<>();
                    List<LtkjJianchajianyanTree> buLuXmXinXi = tjOrderService.getBuLuXmXinXi(dto.getBldhs(), order.getCardId());
                    log.info("buLuXmXinXi的值为:==========" + buLuXmXinXi);
                    if (null != buLuXmXinXi && !buLuXmXinXi.isEmpty()) {
                        for (Map<String, String> datum : data) {
                            for (LtkjJianchajianyanTree tree : buLuXmXinXi) {
                                String advId = datum.get("Adv_Id").split("_")[1];
                                log.info("advid的值为:==========" + advId);
                                log.info("tree的值为:==========" + advId);
                                BigDecimal cateFee = new BigDecimal(datum.get("CateFee"));
                                log.info("cateFee的值为:==========" + cateFee);
                                log.info("tree.getFyhj()的值为:==========" + tree.getFyhj());
                                if (tree.getSqdh().equals(advId) && cateFee.compareTo(new BigDecimal(tree.getFyhj())) == 0) {
                                    log.info("该项目已缴费不可撤销");
                                    return AjaxResult.error("该项目已缴费不可撤销!!!");
                                }
                            }
                        }
                    }
                    if (advIds.containsAll(dto.getBldhs()) && cateFeeAll.compareTo(BigDecimal.ZERO) != 0) {
                        return AjaxResult.error("改项目已缴费不可撤销!!!");
                    }
                }
                boolean b = hisApiMethod.ZfBlXm(dto.getBldhs(), order);
                if (!b) {
                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                    log.info("撤销失败,调用作废出现失败");
                    return AjaxResult.error("撤销失败,调用作废出现失败");
                }
            }
            for (String bldh : dto.getBldhs()) {
                remarkService.deleteTjOrderDetailByjxbz(bldh);
                tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh);
                tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh);
                transitionService.deleteTjOrderDetailByjxbz(bldh);
                blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, dto.getTjh()).eq(TjProBl::getBldh, bldh));
            try {
                extracted(dto,order);
            } catch (Exception e) {
                log.info("撤销失败,删除表失败");
                return AjaxResult.error("撤销失败,删除表失败!");
            }
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }
//    @Transactional(propagation =Propagation.REQUIRES_NEW)
    public void extracted(TjProBlDto dto,TjOrder order) {
        for (String bldh : dto.getBldhs()) {
            remarkService.deleteTjOrderDetailByjxbz(bldh);
            tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh);
            tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh);
            transitionService.deleteTjOrderDetailByjxbz(bldh);
            blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, dto.getTjh()).eq(TjProBl::getBldh, bldh));
        }
        tjSamplingMapper.deleteByTjNumAndCusIdAndJxbz(dto.getTjh(),order.getUserId(),dto.getBldhs());
    }
    @PostMapping("/addYaoPinShenQing")
    @ApiOperation(value = "药品信息申请")