zhaowenxuan
2025-05-13 6ae6fc96fd53b083091d704b43be30aa61063395
2025-05-13
7个文件已修改
2个文件已添加
830 ■■■■■ 已修改文件
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjCheckController.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-admin/src/main/java/com/ltkj/web/controller/system/ZhiYeController.java 653 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjOrder.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjOrderDetailMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjOrderDetailService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjOrderDetailServiceImpl.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-hosp/src/main/java/com/ltkj/hosp/vo/ProFcListVo.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-hosp/src/main/resources/mapper/hosp/TjOrderMapper.xml 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-system/src/main/java/com/ltkj/system/service/impl/SysDictTypeServiceImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjCheckController.java
@@ -25,6 +25,7 @@
import com.ltkj.hosp.mapper.TestMapper;
import com.ltkj.hosp.service.*;
import com.ltkj.hosp.sqlDomain.*;
import com.ltkj.hosp.vo.ProFcListVo;
import com.ltkj.hosp.vodomain.CsProVo;
import com.ltkj.hosp.vodomain.UpdateOrderRemarkVo;
import com.ltkj.mall.mallOrderUtils.TjConstants;
@@ -1889,5 +1890,30 @@
        return AjaxResult.success();
    }
    /**
     * 查询复查项目列表
     * @param tjNum 体检号
     * @param type 复查状态 0未复查状态 1复查状态
     * @return
     */
    @GetMapping("/getFcList")
    public AjaxResult getFcList(@RequestParam("tjNum") String tjNum,@RequestParam("type") Integer type){
        TjOrder order = orderService.getOrderByTjNum(tjNum);
        if (order == null)
            return AjaxResult.error();
        List<ProFcListVo> list = detailService.getFcList(order.getOrderId(),type);
        return AjaxResult.success(list);
    }
    /**
     * 复查项目提交
     * @param json
     * @return
     */
    @PostMapping("/UpdFcPro")
    public AjaxResult updFcPro(@RequestBody String json) {
        return detailService.updFcPro(json);
    }
}
ltkj-admin/src/main/java/com/ltkj/web/controller/system/ZhiYeController.java
New file
@@ -0,0 +1,653 @@
package com.ltkj.web.controller.system;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.core.domain.entity.SysDept;
import com.ltkj.common.core.domain.entity.SysUser;
import com.ltkj.common.utils.SecurityUtils;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.idutil.IdUtils;
import com.ltkj.hosp.mapper.TjSamplingMapper;
import com.ltkj.hosp.service.*;
import com.ltkj.hosp.sqlDomain.LtkjMiddleHead;
import com.ltkj.mall.domain.MallCheckLog;
import com.ltkj.mall.domain.MallOrder;
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.ISysDictDataService;
import com.ltkj.system.service.ISysUserService;
import com.ltkj.web.controller.his.HisApiMethod;
import com.ltkj.web.controller.his.HisApiMethodService;
import com.ltkj.web.controller.lis.LisApiMethod;
import com.ltkj.web.wxUtils.HttpClientUtils;
import io.swagger.annotations.ApiOperation;
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.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.bind.annotation.*;
import java.io.File;
import java.io.FileInputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
/**
 * @Company: 西安路泰科技有限公司
 * @Author: zhaowenxuan
 * @Date: 2025/5/12 14:37
 */
@Slf4j
@RestController
@RequestMapping("/zhiye/order")
public class ZhiYeController {
    @Autowired
    private ISysUserService userService;
    @Autowired
    private ITjCustomerService tjCustomerService;
    @Autowired
    private ITjReservationService tjReservationService;
    @Autowired
    private IMallOrderService mallOrderService;
    @Autowired
    private ITjDwGroupingService dwGroupingService;
    @Autowired
    private ITbTransitionService transitionService;
    @Autowired
    private ITjOrderService tjOrderService;
    @Autowired
    private ISysConfigService configService;
    @Autowired
    private IdUtils idUtils;
    @Autowired
    private ITjReportGetAddressService tjReportGetAddressService;
    @Autowired
    private LtkjMiddleHeadService headService;
    @Autowired
    private IMallCheckLogService mallCheckLogService;
    @Autowired
    private ITjFlowingWaterService tjFlowingWaterService;
    @Autowired
    private HisApiMethodService controller;
    @Autowired
    private HisApiMethod hisApiMethod;
    @Autowired
    private LisApiMethod lisApiMethod;
    @Autowired
    private ITjAskMedicalHistoryService tjAskMedicalHistoryService;
    @Autowired
    private ITjOrderDetailService tjOrderDetailService;
    @Autowired
    private ITjOrderRemarkService remarkService;
    @Autowired
    private ITjXdPictureService xdPictureService;
    @Autowired
    private ITjSamplingService samplingService;
    @Autowired
    private ITjProjectService projectService;
    @Autowired
    private ISysDictDataService sysDictDataService;
    @Autowired
    private LisJyflhbService lisJyflhbService;
    @Autowired
    private TjSamplingMapper tjSamplingMapper;
    @Autowired
    private ITbTransitionService tbTransitionService;
    @Autowired
    private ISysDeptService sysDeptService;
    @Autowired
    private TjFlowingWaterHisService tjFlowingWaterHisService;
    ReentrantLock lock = new ReentrantLock();
    @PostMapping
    @ApiOperation(value = "体检签到登记接口")
    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
    public AjaxResult addOrderAndDetail(@RequestBody TjOrder tjOrder) throws Exception {
        Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId());
        SysUser sysUser = userService.getById(userId);
        LambdaQueryWrapper<TjCustomer> wq = new LambdaQueryWrapper<>();
        wq.eq(TjCustomer::getCusId, tjOrder.getUserId());
        TjCustomer tjCustomer = tjCustomerService.getOne(wq);
        if (tjCustomer == null) return AjaxResult.error("该客户未登记");
        TjFlowingWater tjFlowingWater = new TjFlowingWater();
        LambdaQueryWrapper<TjReservation> wq1 = new LambdaQueryWrapper<>();
        wq1.eq(TjReservation::getIdCard, tjCustomer.getCusIdcard());
        wq1.eq(TjReservation::getIsExpire, 2);
        TjReservation tjReservation = tjReservationService.getOne(wq1);
        MallOrder mallOrder = null;
        if (null != tjReservation) {
            tjOrder.setReservationId(tjReservation.getId());
            mallOrder = mallOrderService.getOne(new LambdaQueryWrapper<MallOrder>().eq(MallOrder::getReservationId, tjReservation.getId()));
            if (DateUtil.endOfDay(DateUtil.offsetDay(tjReservation.getReservationTime(), tjReservation.getYxts())).before(new Date())) {
                tjReservation.setIsExpire(1);
                tjReservationService.updateById(tjReservation);
                return AjaxResult.error("对不起您的预约已超时请重新预约");
            }
            if (null != tjReservation.getTeamNo()) tjOrder.setTeamNo(tjReservation.getTeamNo());
            if (null != tjReservation.getCompanyId()) tjOrder.setFirmId(tjReservation.getCompanyId());
            if (null != tjReservation.getCompany()) tjOrder.setFirmName(tjReservation.getCompany());
            if (null != tjReservation.getDepartment()) tjOrder.setFirmDeptName(tjReservation.getDepartment());
            if (null != tjReservation.getJobNo()) tjOrder.setFirmWorkId(tjReservation.getJobNo());
            if (null != tjReservation.getPacId()) tjOrder.setPacId(tjReservation.getPacId());
            if (null != tjReservation.getTjCategory()) tjOrder.setTjCategory(tjReservation.getTjCategory());
            if (null != tjReservation.getGroupingId()) {
                TjDwGrouping dwGrouping = dwGroupingService.getById(tjReservation.getGroupingId());
                tjOrder.setGroupId(tjReservation.getGroupingId());
                tjOrder.setFirmDeptId(dwGrouping.getDwDeptId());
            }
            tjReservation.setIsExpire(1);
            tjReservationService.updateById(tjReservation);
            if (null != tjReservation.getTeamNo() && tjOrder.getTjType().equals("1")) {
                tjOrder.setTjType("1");
            } else if (tjOrder.getTjType().equals("2")) {
                tjOrder.setTjType("2");
            }
        }
        if (StringUtil.isBlank(tjOrder.getFirmId())) {
            tjOrder.setFirmId("0");
        }
        if (null != tjOrder.getPhoto()) {
            File file = new File(tjOrder.getPhoto());
            if (file.isFile()) {
                FileInputStream fileInputStream = new FileInputStream(file);
                byte[] bytes = new byte[fileInputStream.available()];
                fileInputStream.read(bytes); // 读取到 byte 里面
                fileInputStream.close();
                // 得到文件 之后转成beye 然后使用base64转码
                String encode = Base64.encode(bytes);
                tjOrder.setPhoto(encode);
            }
        }
        if (null == tjOrder.getPacId() && null != transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId()))) {
            tjOrder.setPacId(transitionService.getTbTransitionPacIdByCusIdAndPac(String.valueOf(tjOrder.getUserId())));
        }
        //判断小程序上预约是否付钱
        if (null != mallOrder) tjOrder.setMallOrderId(String.valueOf(mallOrder.getId()));
        tjOrder.setStatus(TjConstants.TJ_BEGIN);
        tjOrder.setCardId(tjCustomer.getCardId());
        if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
            tjOrder.setFinishTime(new Date());
            tjOrder.setCheckStatus(1);
            tjOrder.setStatus(TjConstants.TJ_WAIT);
            //            tjFlowingWater.setPayStasus(1L);
        }
        tjFlowingWater.setPayStasus(0L);
        try {
            boolean b = lock.tryLock(3, TimeUnit.MINUTES);
            if (b) {
                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;
            }
        }catch (Exception e){
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            log.error(String.valueOf(e),e.getMessage());
            e.printStackTrace();
        }
        finally {
            lock.unlock();
        }
        return AjaxResult.error();
    }
    @Transactional(propagation = Propagation.REQUIRED)
    public AjaxResult processOrderWithTransaction(TjOrder tjOrder, TjCustomer tjCustomer, TjReservation tjReservation, TjFlowingWater tjFlowingWater, MallOrder mallOrder, SysUser sysUser) {
        //获取拼接前缀
        String makeLisTmhPrefix = configService.selectConfigByKey("make_lis_tmh_prefix");
        String tjNumber = null;
        int a =0;
        while (tjNumber ==null){
            if(a>3){
                throw new RuntimeException("前方拥挤,请稍等!!!");
            }
            try {
                String newTjNumberRedisLockAndMysql = idUtils.getNewTjNumberRedisLockAndMysql();
                if (StringUtil.isNotBlank(makeLisTmhPrefix)){
                    String tjh=  makeLisTmhPrefix + newTjNumberRedisLockAndMysql;
                    int countByTjNum = tjOrderService.getOrderCountByTjNum(tjh);
                    if(countByTjNum==0){
                        tjNumber=tjh;
                    }
                }else {
                    int countByTjNum = tjOrderService.getOrderCountByTjNum(newTjNumberRedisLockAndMysql);
                    if(countByTjNum==0){
                        tjNumber=newTjNumberRedisLockAndMysql;
                    }
                }
            } catch (Exception e) {
                log.error(e.getMessage());
                throw new IllegalStateException();
            }finally {
                a++;
            }
        }
        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())) {
                final TjReportGetAddress address = tjOrder.getAddAddress();
                if (address != null) {
                    address.setTjNumber(tjNumber);
                    tjReportGetAddressService.save(address);
                }
            }
            Long cusNumber = tjCustomer.getCusNumber();
            cusNumber += 1;
            tjCustomer.setCusNumber(cusNumber);
            if ("1".equals(tjOrder.getTjType())) {
                if (null != tjReservation && tjReservation.getPayType() == 1) {
                    tjFlowingWater.setPayStasus(3L);
                }
            }
            //调用SQL server拿取收费情况
            //根据配置调取存储过程 将临时表数据存入预约表2023.12.12
            final String getInfoFromSqlData = configService.selectConfigByKey("getInfoFromSqlData");
            final String isPay = configService.selectConfigByKey("isPay");
            if ("Y".equals(getInfoFromSqlData)) {
                LtkjMiddleHead middleHead = headService.getMiddleHeadByPartId(tjCustomer.getCardId());
                if (null != middleHead) {
                    tjFlowingWater.setPayStasus(1L);
                }
            }
            tjFlowingWater.setOrderId(tjOrder.getOrderId());
            Date date1 = new Date(System.currentTimeMillis());
            String s1 = SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmssSSS").format(date1);
            tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "").toUpperCase() + s1);
            BigDecimal copeWith = tjOrder.getTjFlowingWater().getCopeWith();
            BigDecimal paidIn = tjOrder.getTjFlowingWater().getPaidIn();
            tjFlowingWater.setCopeWith(copeWith);
            tjFlowingWater.setPaidIn(paidIn);
            tjFlowingWater.setDiscount(discount.toString());
            BigDecimal subtract = paidIn.subtract(copeWith.multiply(discount.divide(BigDecimal.valueOf(10))));
            log.info("签到登记体检人: " + tjOrder.getTjNumber() + " 应付: " + copeWith);
            log.info("签到登记体检人: " + tjOrder.getTjNumber() + " 折扣: " + discount);
            log.info("签到登记体检人: " + tjOrder.getTjNumber() + " 实付: " + paidIn);
            log.info("签到登记体检人: " + tjOrder.getTjNumber() + " 相差: " + subtract);
            if (isPay.equals("true")) {
                if (null != mallOrder) {
                    if (mallOrder.getOrderStatus().equals(201L)) {
                        tjFlowingWater.setCopeWith(mallOrder.getActualPrice());
                        tjFlowingWater.setPaidIn(mallOrder.getActualPrice());
                        tjFlowingWater.setDiscount(String.valueOf(1));
                        tjFlowingWater.setPayStasus(1L);
                        tjFlowingWater.setPayType(3L);
                        MallCheckLog checkLog = new MallCheckLog();
                        checkLog.setCheckBy(sysUser.getNickName());
                        checkLog.setUserId(mallOrder.getUserId());
                        checkLog.setConsignee(mallOrder.getConsignee());
                        checkLog.setIdCard(mallOrder.getIdCard());
                        checkLog.setOrderId(String.valueOf(mallOrder.getId()));
                        checkLog.setOrderSn(mallOrder.getOrderSn());
                        checkLog.setCheckTime(new Date());
                        checkLog.setShipSn("HX" + s1);
                        mallCheckLogService.save(checkLog);
                        mallOrder.setOrderStatus(301L);
                        mallOrderService.updateById(mallOrder);
                    }
                } else {
                    tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
                    tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
                    tjFlowingWater.setDiscount(tjOrder.getTjFlowingWater().getDiscount());
                    //                    tjFlowingWater.setPayStasus(0L);
                }
            }
            //修改临时表体检号
            transitionService.updateTbTransitionTjNumByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber());
            if (tjFlowingWaterService.save(tjFlowingWater)) {
                tjOrder.setTjSerialNumber(String.valueOf(tjFlowingWater.getTjSerialNumber()));
                tjOrderService.updateById(tjOrder);
            }
            /*调用his接口*/
            String config = configService.selectConfigByKey("sfkqdyhis");
            if (null != config && config.equals("Y")) {
                AjaxResult result = null;
                try {
                    result = hisApiMethod.HisApiMethods(tjCustomer, tjOrder);
                    if (!result.get("code").toString().equals("200")) {
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        Object jzh = result.get("jzh");
                        if (null != jzh && null != jzh.toString()) {
                            hisApiMethod.ZfHisApiMethod(jzh.toString());
                        }
                        log.info("该登记人挂号失败, 就诊号为: " + tjOrder.getCardId());
                        return AjaxResult.error("挂号失败!" + result.get("msg").toString());
                    }
                } catch (NoTransactionException e) {
                    log.error(e.getMessage());
                    throw new RuntimeException(e);
                }
                log.info("该登记人的his就诊号是: " + tjOrder.getCardId());
                // 查询 对接Lis、Pacs申请如果类型包含在配置内则使用对接lis、pacs
                try {
                    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()));
                        remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
                        List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
                        xdPictureService.saveBatch(xdPictureList);
                    } else {
                        newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                        List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
                        addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
                        hisApiMethod.tijianshenqing(tjCustomer, DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss"), tjOrder.getCardId());
                    }
                    return AjaxResult.success(tjNumber);
                } catch (Exception e) {
                    log.error(e.getMessage());
                    throw new RuntimeException(e);
                }
            } else {
                tjCustomer.setCardId(tjOrder.getTjNumber());
                tjCustomerService.updateById(tjCustomer);
                transitionService.updateCardIdByTjNumAndIdCard(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), tjOrder.getTjNumber());
                tjOrder.setCardId(tjOrder.getTjNumber());
                tjOrderService.updateById(tjOrder);
            }
            String drrysfsf = configService.selectConfigByKey("drrysfsf");
            try {
                if (lisApiMethod.isUseLisAndPacsRegister(tjOrder)) {
                    if(StringUtil.isNotBlank(drrysfsf) && drrysfsf.equalsIgnoreCase("Y")){
                        if(null != tjReservation){
                            return isUseLisAndPacsRegister(tjOrder, tjCustomer, tjReservation, tjFlowingWater, sysUser, discount, tjNumber);
                        }else {
                            newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                            AjaxResult error = isRequestCommonHisApi(tjOrder, tjCustomer, tjFlowingWater);
                            if (error != null) return error;
                            return AjaxResult.success(tjNumber);
                        }
                    }
                    return isUseLisAndPacsRegister(tjOrder, tjCustomer, tjReservation, tjFlowingWater, sysUser, discount, tjNumber);
                } else {
                    newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
                    AjaxResult error = isRequestCommonHisApi(tjOrder, tjCustomer, tjFlowingWater);
                    if (error != null) return error;
                }
            } catch (Exception e) {
                log.error(e.getMessage());
                throw new RuntimeException(e);
            }
            return AjaxResult.success(tjNumber);
        }
        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        return AjaxResult.error();
    }
    public void newSaveextracted(TjOrder tjOrder, TjCustomer tjCustomer, BigDecimal discount, SysUser sysUser, TjReservation tjReservation, TjFlowingWater tjFlowingWater) {
        try {
            tjAskMedicalHistoryService.updateTjAskMedicalHistoryByCusId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjCustomer.getCusId()));
            if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
                tjOrderDetailService.saveJSYTjOrderDetailsByCusId(tjCustomer.getCusIdcard(),
                        String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId(), String.valueOf(tjFlowingWater.getTjSerialNumber()));
            } else {
                tjOrderDetailService.saveTjOrderDetailsByCusId(tjCustomer.getCusIdcard(), String.valueOf(tjOrder.getOrderId()), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId());
            }
            tjOrderDetailService.saveTjPureToneTesByCusId(tjCustomer.getCusIdcard(), tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), tjOrder.getCardId());
            //添加remark表数据
            if (null != tjOrder.getTjCategory() && tjOrder.getTjCategory().equals("13")) {
                remarkService.saveJSYTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
            } else {
                remarkService.saveTjOrderRemarkByOrderId(tjOrder.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjOrder.getOrderId()));
            }
            //判断是否交钱
            if ("1".equals(tjOrder.getTjType())) {
                if (null != tjReservation && tjReservation.getPayType() == 1) {
                    tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                            sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
                    remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
                    List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
                    xdPictureService.saveBatch(xdPictureList);
                }
            }
            if (tjFlowingWater.getPayStasus() == 1L) {
                tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                        sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
                tjFlowingWater.setPaidIn(tjOrder.getTjFlowingWater().getPaidIn());
                tjFlowingWater.setCopeWith(tjOrder.getTjFlowingWater().getCopeWith());
                tjFlowingWater.setPayType(4L);
                tjFlowingWaterService.updateById(tjFlowingWater);
                remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
                //            asyncService.addTjChargingStandard(tjOrder, transitionService.getTbTransitionListByCusId(tjCustomer.getCusIdcard(), tjOrder.getCardId()), sysUser);
                List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
                xdPictureService.saveBatch(xdPictureList);
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            throw new RuntimeException(e);
        }
    }
    public void addCaiYangDengJi(List<TjOrderDetail> detailList, boolean detailList1, TjOrder order, SysUser sysUser, String jxbz) {
        String lis_tmh_prefix = configService.selectConfigByKey("make_lis_tmh_prefix");
        String config = configService.selectConfigByKey("sfkqdyhis");
        Boolean lisAndPacsRegister = lisApiMethod.isUseLisAndPacsRegister(order);
        if (null != detailList && detailList1) {
            Date date = new Date();
            String format = DateUtil.format(date, "yyMMddHHmmssSSS");
            for (TjOrderDetail detail : detailList) {
                int i = samplingService.isExistProId(order.getTjNumber(), String.valueOf(detail.getProId()));
                if(i>0) continue;
                TjSampling sampling = new TjSampling();
                if (null == projectService.getById(detail.getProId())) continue;
                TjProject project = projectService.getById(detail.getProId());
                Long proParentId = project.getProParentId();
                String dictLabel = sysDictDataService.selectDictLabel("sys_dict_specimen", project.getSpecimenType());
                if (null != proParentId && proParentId == 0) {
                    sampling.setJyxh(idUtils.generateLisID(lis_tmh_prefix));
                    sampling.setSpecimenTypeCode(project.getSpecimenType());
                    sampling.setSpecimenType(dictLabel);
                    if (config.equals("Y") && lisAndPacsRegister)
                        sampling.setJyxmdm(project.getLisXmbm());
                    else sampling.setJyxmdm(project.getProId().toString());
                } else {
                    TjProject project1 = projectService.getById(proParentId);
                    sampling.setJyxh(idUtils.generateLisID(lis_tmh_prefix));
                    sampling.setSpecimenTypeCode(project1.getSpecimenType());
                    sampling.setSpecimenType(dictLabel);
                    if (config.equals("Y") && lisAndPacsRegister)
                        sampling.setJyxmdm(project1.getLisXmbm());
                    else sampling.setJyxmdm(project1.getProId().toString());
                }
                sampling.setSamplingNumber(format);
                sampling.setTjNum(order.getTjNumber());
                sampling.setCusId(String.valueOf(order.getUserId()));
                if (tjCustomerService.getById(String.valueOf(order.getUserId())) != null) {
                    sampling.setCusName(tjCustomerService.getById(String.valueOf(order.getUserId())).getCusName());
                }
                sampling.setApplicationTime(date);
                sampling.setTjTime(order.getCreateTime());
                sampling.setProId(String.valueOf(detail.getProId()));
                sampling.setProName(projectService.getById(detail.getProId()).getProName());
                sampling.setCreateBy(sysUser.getNickName());
                sampling.setCreateTime(date);
                sampling.setUpdateBy(sysUser.getNickName());
                sampling.setUpdateTime(date);
                sampling.setCreateId(String.valueOf(sysUser.getUserId()));
                sampling.setUpdateId(String.valueOf(sysUser.getUserId()));
                sampling.setJxbz(jxbz);
                samplingService.save(sampling);
            }
        }
        if (lisApiMethod.isUseLisAndPacsRegister(order) && (null != config && config.equals("Y"))) {
            AjaxResult ajaxResult = lisApiMethod.getJyFlHb();
            if (ajaxResult.get("code").toString().equals("200")) {
                String str = ajaxResult.get("data").toString();
                str = str.replace("=", ":");
                JSONArray array = JSONUtil.parseArray(str);
                for (Object o : array) {
                    JSONObject object = (JSONObject) o;
                    LisJyflhb lisJyflhb = new LisJyflhb();
                    lisJyflhb.setHbhxm(object.getStr("hbhxm"));
                    lisJyflhb.setFlmc(object.getStr("flmc"));
                    lisJyflhb.setMc(object.getStr("mc"));
                    lisJyflhb.setFlbm(object.getStr("flbm"));
                    LambdaQueryWrapper<LisJyflhb> wrapper = new LambdaQueryWrapper<>();
                    wrapper.eq(LisJyflhb::getFlbm, lisJyflhb.getFlbm());
                    LisJyflhb jyflhb = lisJyflhbService.getOne(wrapper);
                    if (jyflhb == null) {
                        lisJyflhb.setId(IdUtil.getSnowflake().nextId());
                        lisJyflhbService.save(lisJyflhb);
                    } else {
                        lisJyflhb.setId(jyflhb.getId());
                        lisJyflhbService.updateById(lisJyflhb);
                    }
                }
            }
        }
        if (StrUtil.isNotBlank(jxbz)) {
            tjSamplingMapper.updateUserIdByTjNumAndJxbz(order.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), jxbz);
        } else {
            tjSamplingMapper.updateUserIdByTjNum(order.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()));
        }
    }
    private AjaxResult isUseLisAndPacsRegister(TjOrder tjOrder, TjCustomer tjCustomer, TjReservation tjReservation, TjFlowingWater tjFlowingWater, SysUser sysUser, BigDecimal discount, String tjNumber) {
        try {
            log.info("签到登记进入未收费方法");
            // 这是上面个人方法引入数据
            tjFlowingWater.setPayStasus(1L);
            newSaveextracted(tjOrder, tjCustomer, discount, sysUser, tjReservation, tjFlowingWater);
            tjOrderDetailService.updateTjOrderDetailsByOrderId(String.valueOf(tjOrder.getOrderId()),
                    sysUser.getNickName(), String.valueOf(sysUser.getUserId()), String.valueOf(tjFlowingWater.getTjSerialNumber()));
            remarkService.updateTjOrderRemarkSfbzByJxbzisnull(tjOrder.getOrderId().toString(), tjFlowingWater.getTjSerialNumber().toString());
            List<TjXdPicture> xdPictureList = xdPictureService.saveTjXdPicture(tjOrder.getTjNumber());
            xdPictureService.saveBatch(xdPictureList);
            List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(tjOrder.getOrderId());
            log.info("签到登记:采样数据查询个数"+detailList.size());
            addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, sysUser, null);
            return AjaxResult.success(tjNumber);
        } catch (Exception e) {
            log.error(e.getMessage());
            throw new RuntimeException(e);
        }
    }
    private AjaxResult isRequestCommonHisApi(TjOrder tjOrder, TjCustomer tjCustomer, TjFlowingWater tjFlowingWater) {
        String s = configService.selectConfigByKey("is_request_common_his_api");
        if (null != s && s.equals("Y")) {
            String apiUrl = configService.selectConfigByKey("common_api_url");
            String hospbm = configService.selectConfigByKey("common_api_service_hospbm");
            HashMap<String, Object> map = new HashMap<>();
            map.put("pationId", tjCustomer.getPationId());
            map.put("cardId", tjCustomer.getHisJzkh());
            map.put("tjNum", tjFlowingWater.getTjSerialNumber());
            map.put("kaiDanKs", "7805");
            // 收费标志 1待售费 2待退费
            map.put("shouTuiStatus", "1");
            JSONArray array = JSONUtil.createArray();
            LambdaQueryWrapper<TbTransition> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(TbTransition::getTjNum, tjOrder.getTjNumber());
            wrapper.eq(TbTransition::getCusId, tjCustomer.getCusIdcard());
            wrapper.eq(TbTransition::getCardId, tjCustomer.getCardId());
            wrapper.isNotNull(TbTransition::getNowPrice);
            wrapper.gt(TbTransition::getNowPrice, 0);
            List<TbTransition> list = tbTransitionService.list(wrapper);
            BigDecimal zongjia = new BigDecimal("0.0");
            for (TbTransition transition : list) {
                LambdaQueryWrapper<TjProject> wrapper1 = new LambdaQueryWrapper<>();
                wrapper1.eq(TjProject::getProId, transition.getProId());
                TjProject project = projectService.getOne(wrapper1);
                LambdaQueryWrapper<SysDept> wrapper2 = new LambdaQueryWrapper<>();
                wrapper2.eq(SysDept::getDeptId, project.getDeptId());
                SysDept dept = sysDeptService.getOne(wrapper2);
                JSONObject obj = JSONUtil.createObj();
//                Integer sl = project.getSl();
                int sl = 1;
                BigDecimal danjia = transition.getNowPrice();
                BigDecimal allPrice = danjia.multiply(new BigDecimal(sl));
                obj.putOpt("danJia", danjia);
                obj.putOpt("jieSuanJe", allPrice);
                obj.putOpt("shuliang", sl);
                obj.putOpt("zhiXingKs", dept.getDeptId());
                obj.putOpt("zhiXingKsMc", dept.getDeptName());
                obj.putOpt("shouFeiXmId", project.getHisXmbm());
                obj.putOpt("shouFeiXmMc", project.getHisXmmc());
                array.add(obj);
                zongjia = zongjia.add(allPrice);
            }
            map.put("feiYongInfoList", array);
            log.info("调用His接口前 收费总价:{}", zongjia.toString());
            String post = HttpClientUtils.sendPost(apiUrl + "/api/his/" + hospbm + "/creatCostInfo", map);
            JSONObject object = JSONUtil.parseObj(post);
            if (object.getInt("code") == 200) {
                JSONObject data = object.getJSONObject("data");
                tjFlowingWater.setHisWaterId(data.getStr("feiYongId"));
                JSONArray mxList = data.getJSONArray("mxList");
                if (mxList != null && !mxList.isEmpty()) {
                    List<TjFlowingWaterHis> his = mxList.toList(TjFlowingWaterHis.class);
                    tjFlowingWaterHisService.saveBatch(his);
                }
                tjFlowingWaterService.updateById(tjFlowingWater);
            } else {
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                return AjaxResult.error();
            }
        }
        return null;
    }
}
ltkj-hosp/src/main/java/com/ltkj/hosp/domain/TjOrder.java
@@ -458,6 +458,31 @@
    @TableField(exist = false)
    private String zt;
    /**
     * 接害工龄年
     */
    private String zhiyeJhgln;
    /**
     * 接害工龄月
     */
    private String zhiyeJhgly;
    /**
     * 开始接害日期
     */
    private Date zhiyeKsjhrq;
    /**
     * 工号
     */
    private String zhiyeGh;
    /**
     * 车间
     */
    private String zhiyeCj;
    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjOrderDetailMapper.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ltkj.hosp.domain.TjOrderDetail;
import com.ltkj.hosp.domain.TjProject;
import com.ltkj.hosp.vo.ProFcListVo;
import com.ltkj.hosp.vodomain.ShenGaoTiZhongVo;
import org.apache.ibatis.annotations.*;
@@ -289,4 +290,11 @@
            "a.update_time=SYSDATE()\n" +
            "WHERE a.order_id=#{orderId} and isnull(a.jxbz)")
    void updateTjOrderDetailsFlowingWaterIdByJxbzisnull(@Param("orderId") String orderId,@Param("ls")String ls);
    @Select("SELECT p.pro_id,p.pro_name,p.pro_parent_id,o.order_id,p.sl * p.pro_price as price,d.dept_id,d.dept_name\n" +
            " FROM tj_order_detail o \n" +
            " LEFT JOIN tj_project p ON o.pro_id = p.pro_id\n" +
            " LEFT JOIN sys_dept d ON p.dept_id = d.dept_id\n" +
            "  WHERE order_id = #{orderId} AND p.pro_parent_id <>0 AND o.is_return = #{type}")
    List<ProFcListVo> getFcList(@Param("orderId") Long orderId, @Param("type") Integer type);
}
ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjOrderDetailService.java
@@ -4,9 +4,11 @@
import java.util.Map;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.core.domain.entity.SysUser;
import com.ltkj.hosp.domain.TjOrderDetail;
import com.ltkj.hosp.domain.TjProject;
import com.ltkj.hosp.vo.ProFcListVo;
import com.ltkj.hosp.vodomain.ShenGaoTiZhongVo;
import org.apache.ibatis.annotations.Select;
@@ -146,4 +148,8 @@
    void updateTjOrderDetailsFlowingWaterIdByJxbz(String orderId, String jxbz,String ls);
    void updateTjOrderDetailsFlowingWaterIdByJxbzisnull(String orderId,String ls);
    List<ProFcListVo> getFcList(Long orderId, Integer type);
    AjaxResult updFcPro(String json);
}
ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjOrderDetailServiceImpl.java
@@ -1,20 +1,29 @@
package com.ltkj.hosp.service.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.core.domain.entity.SysUser;
import com.ltkj.common.utils.DateUtils;
import com.ltkj.hosp.domain.TjProject;
import com.ltkj.hosp.vo.ProFcListVo;
import com.ltkj.hosp.vodomain.ShenGaoTiZhongVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ltkj.hosp.mapper.TjOrderDetailMapper;
import com.ltkj.hosp.domain.TjOrderDetail;
import com.ltkj.hosp.service.ITjOrderDetailService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
/**
 * 体检项目明细Service业务层处理
@@ -22,6 +31,7 @@
 * @author ltkj
 * @date 2022-11-22
 */
@Slf4j
@Service
public class TjOrderDetailServiceImpl extends ServiceImpl<TjOrderDetailMapper, TjOrderDetail> implements ITjOrderDetailService {
    @Autowired
@@ -244,4 +254,55 @@
    public void updateTjOrderDetailsFlowingWaterIdByJxbzisnull(String orderId,String ls) {
        tjOrderDetailMapper.updateTjOrderDetailsFlowingWaterIdByJxbzisnull(orderId,ls);
    }
    @Override
    public List<ProFcListVo> getFcList(Long orderId, Integer type) {
        return tjOrderDetailMapper.getFcList(orderId,type);
    }
    @Transactional
    @Override
    public AjaxResult updFcPro(String json) {
        try {
            JSONObject entries = JSONUtil.parseObj(json);
            System.out.println(JSONUtil.toJsonStr(entries));
            String orderId = entries.getStr("orderId");
            JSONArray array = entries.getJSONArray("data");
            ArrayList<String> fcList = new ArrayList<>();
            ArrayList<String> notFcList = new ArrayList<>();
            for (Object o : array) {
                JSONObject object = (JSONObject) o;
                String proId = object.getStr("proId");
                Integer type = object.getInt("type");
                if (type == 1) {
                    fcList.add(proId);
                } else {
                    notFcList.add(proId);
                }
            }
//            System.out.println("fcList = " + fcList);
//            System.out.println("notFcList = " + notFcList);
//            if (true)
//                return AjaxResult.error();
            if (!fcList.isEmpty()){
                LambdaUpdateWrapper<TjOrderDetail> wrapper = new LambdaUpdateWrapper<>();
                wrapper.set(TjOrderDetail::getIsReturn,1);
                wrapper.eq(TjOrderDetail::getOrderId,orderId);
                wrapper.in(TjOrderDetail::getProId,fcList);
                update(wrapper);
            }
            if (!notFcList.isEmpty()){
                LambdaUpdateWrapper<TjOrderDetail> wrapper = new LambdaUpdateWrapper<>();
                wrapper.set(TjOrderDetail::getIsReturn,0);
                wrapper.eq(TjOrderDetail::getOrderId,orderId);
                wrapper.in(TjOrderDetail::getProId,notFcList);
                update(wrapper);
            }
        }catch (Exception e){
            log.error(String.valueOf(e),e.getMessage());
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return AjaxResult.error();
        }
        return AjaxResult.success();
    }
}
ltkj-hosp/src/main/java/com/ltkj/hosp/vo/ProFcListVo.java
New file
@@ -0,0 +1,19 @@
package com.ltkj.hosp.vo;
import lombok.Data;
/**
 * @Company: 西安路泰科技有限公司
 * @Author: zhaowenxuan
 * @Date: 2025/5/9 14:35
 */
@Data
public class ProFcListVo {
    private String proParentId;
    private String proId;
    private String price;
    private String deptName;
    private String deptId;
    private String orderId;
    private String proName;
}
ltkj-hosp/src/main/resources/mapper/hosp/TjOrderMapper.xml
@@ -36,6 +36,11 @@
        <result property="confirmDoctor" column="confirm_doctor"/>
        <result property="confirmTime" column="confirm_time"/>
        <result property="confirmStatus" column="confirm_status"/>
        <result property="zhiyeJhgln" column="zhiye_jhgln"/>
        <result property="zhiyeJhgly" column="zhiye_jhgly"/>
        <result property="zhiyeKsjhrq" column="zhiye_ksjhrq"/>
        <result property="zhiyeGh" column="zhiye_gh"/>
        <result property="zhiyeCj" column="zhiye_cj"/>
    </resultMap>
    <sql id="selectTjOrderVo">
@@ -77,7 +82,7 @@
               heshou_time,
               is_hz,
               get_type,
               tj_category
               tj_category,zhiye_jhgln,zhiye_jhgly,zhiye_ksjhrq,zhiye_gh,zhiye_cj
        from tj_order
    </sql>
@@ -209,6 +214,11 @@
            <if test="isHz != null">is_hz,</if>
            <if test="getType != null">get_type,</if>
            <if test="tjCategory != null">tj_category,</if>
            <if test="zhiyeJhgln != null">zhiye_jhgln,</if>
            <if test="zhiyeJhgly != null">zhiye_jhgly,</if>
            <if test="zhiyeKsjhrq != null">zhiye_ksjhrq,</if>
            <if test="zhiyeGh != null">zhiye_gh,</if>
            <if test="zhiyeCj != null">zhiye_cj,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
@@ -249,6 +259,11 @@
            <if test="isHz != null">#{isHz},</if>
            <if test="getType != null">#{getType},</if>
            <if test="tjCategory != null">#{tjCategory},</if>
            <if test="zhiyeJhgln != null">#{zhiyeJhgln},</if>
            <if test="zhiyeJhgly != null">#{zhiyeJhgly},</if>
            <if test="zhiyeKsjhrq != null">#{zhiyeKsjhrq},</if>
            <if test="zhiyeGh != null">#{zhiyeGh},</if>
            <if test="zhiyeCj != null">#{zhiyeCj},</if>
        </trim>
    </insert>
@@ -294,6 +309,11 @@
            <if test="isHz != null">is_hz = #{isHz},</if>
            <if test="getType != null">get_type = #{getType},</if>
            <if test="tjCategory != null">tj_category = #{tjCategory},</if>
            <if test="zhiyeJhgln != null">zhiye_jhgln = #{zhiyeJhgln},</if>
            <if test="zhiyeJhgly != null">zhiye_jhgly = #{zhiyeJhgly},</if>
            <if test="zhiyeKsjhrq != null">zhiye_ksjhrq = #{zhiyeKsjhrq},</if>
            <if test="zhiyeGh != null">zhiye_gh = #{zhiyeGh},</if>
            <if test="zhiyeCj != null">zhiye_cj = #{zhiyeCj},</if>
        </trim>
        where order_id = #{orderId}
    </update>
ltkj-system/src/main/java/com/ltkj/system/service/impl/SysDictTypeServiceImpl.java
@@ -70,11 +70,11 @@
     */
    @Override
    public List<SysDictData> selectDictDataByType(String dictType) {
        List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
        if (StringUtils.isNotEmpty(dictDatas)) {
            return dictDatas;
        }
        dictDatas = dictDataMapper.selectDictDataByType(dictType);
//        List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
//        if (StringUtils.isNotEmpty(dictDatas)) {
//            return dictDatas;
//        }
        List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType);
        if (StringUtils.isNotEmpty(dictDatas)) {
            DictUtils.setDictCache(dictType, dictDatas);
            return dictDatas;