zhaowenxuan
2025-01-02 4761f2bc70814bde9929f1081a213a9ab38a7393
采样管理确认采样增加调用lis请求
3个文件已修改
225 ■■■■■ 已修改文件
ltkj-admin/src/main/java/com/ltkj/web/controller/callback/CallBackController.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-admin/src/main/java/com/ltkj/web/controller/system/SamplingServiceApi.java 169 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ltkj-admin/src/main/java/com/ltkj/web/controller/callback/CallBackController.java
@@ -1,11 +1,18 @@
package com.ltkj.web.controller.callback;
import cn.hutool.core.util.StrUtil;
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.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.mapper.TjProjectMapper;
import com.ltkj.hosp.mapper.TjSamplingMapper;
import com.ltkj.hosp.service.*;
import com.ltkj.system.service.ISysConfigService;
import com.ltkj.web.wxUtils.HttpClientUtils;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -14,8 +21,10 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * 对接其他平台提供的回调服务
@@ -44,7 +53,8 @@
    private ITjCustomerService tjCustomerService;
    @Autowired
    private ITjOrderService orderService;
    @Autowired
    private TjProjectMapper tjProjectMapper;
    /**
     * 收退费回调接口
     * @param params
@@ -72,11 +82,18 @@
                        if(StringUtil.isNotBlank(jxbz)){
                            tjOrderDetailService.updateTjOrderDetailsFlowingWaterIdByJxbz(water.getOrderId().toString(),jxbz,water.getTjSerialNumber().toString());
                            remarkService.updateTjOrderRemarkSfbzByJxbz(water.getOrderId().toString(),jxbz,water.getTjSerialNumber().toString());
//                            LambdaUpdateWrapper<TjSampling> wrapper1 = new LambdaUpdateWrapper<>();
//                            wrapper1.eq(TjSampling::getJxbz,jxbz);
//                            wrapper1.set(TjSampling::getIsPay,1);
//                            tjSamplingService.update(wrapper1);
                        }else {
                            tjOrderDetailService.updateTjOrderDetailsFlowingWaterIdByJxbzisnull(water.getOrderId().toString(),water.getTjSerialNumber().toString());
                            remarkService.updateTjOrderRemarkSfbzByJxbzisnull(water.getOrderId().toString(),water.getTjSerialNumber().toString());
//                            LambdaUpdateWrapper<TjSampling> wrapper1 = new LambdaUpdateWrapper<>();
//                            wrapper1.isNull(TjSampling::getJxbz);
//                            wrapper1.set(TjSampling::getIsPay,1);
//                            tjSamplingService.update(wrapper1);
                        }
                    }
                }else {
                    return AjaxResult.error("查不到流水号: "+feiYongId);
@@ -89,6 +106,7 @@
                if (order != null){
                    // 退费
                    String bldh = water.getJxbz();
                    //TODO 是否发送作废申请
                    if (bldh != null){
                        remarkService.deleteTjOrderDetailByjxbz(bldh);
                        tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh);
@@ -114,6 +132,11 @@
        return AjaxResult.success();
    }
    /**
     * 获取所有的His字典集合
     * @param params
     * @return
     */
    @PostMapping("getZdList")
    public AjaxResult getZdList(@RequestBody Map<String ,Object> params){
        String hosp = params.get("hosp").toString();
@@ -123,4 +146,29 @@
        return AjaxResult.success(list);
    }
    /**
     * 获取所有的检验项目
     * @param params
     * @return
     */
    @PostMapping("getLisXmList")
    public AjaxResult getLisXmList(@RequestBody Map<String ,Object> params){
        List<Map<String, Object>> list = tjProjectMapper.getLisViewList();
        return AjaxResult.success(list);
    }
    /**
     * Lis确认撤销回调
     * @param params
     * @return
     */
    @PostMapping("lisRevoke")
    public AjaxResult lisRevoke(@RequestBody Map<String ,Object> params){
        List<String> keys = (List<String>) params.get("keys");
        String czy = params.get("czy").toString();
        String hospid = params.get("hospid").toString();
        return AjaxResult.success();
    }
}
ltkj-admin/src/main/java/com/ltkj/web/controller/system/SamplingServiceApi.java
@@ -1,22 +1,31 @@
package com.ltkj.web.controller.system;
import cn.hutool.core.util.StrUtil;
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.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.domain.TjOrder;
import com.ltkj.hosp.domain.TjSampling;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.mapper.TjProjectMapper;
import com.ltkj.hosp.service.ITbTransitionService;
import com.ltkj.hosp.service.ITjCustomerService;
import com.ltkj.hosp.service.ITjOrderService;
import com.ltkj.hosp.service.ITjSamplingService;
import com.ltkj.system.mapper.SysConfigMapper;
import com.ltkj.system.service.ISysConfigService;
import com.ltkj.web.controller.lis.LisApiMethod;
import com.ltkj.web.wxUtils.HttpClientUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service
@@ -33,6 +42,12 @@
    private SysConfigMapper sysConfigMapper;
    @Autowired
    private ISysConfigService sysConfigService;
    @Autowired
    private TjProjectMapper tjProjectMapper;
    @Autowired
    private ITjCustomerService tjCustomerService;
    @Autowired
    private ITbTransitionService tbTransitionService;
    /**
     * 确认采样接口
@@ -44,6 +59,7 @@
    }
    public AjaxResult confirm(List<String> ids,String config,String mergeRequest) {
        // sfkqdshitulianjie
@@ -87,8 +103,14 @@
            TjCustomer tjCustomer = customerService.getById(tjOrder.getUserId());
            boolean updChild;
            Boolean save;
            String is_request_common_his_api = sysConfigService.selectConfigByKey("is_request_common_his_api");
            if (null != config && config.equals("Y") && !mergeRequest.equals("Y")) {
                save = lisApiMethod.save(sampling, tjOrder, tjCustomer);
            } else if (is_request_common_his_api.equals("Y")){
//                String apiUrl = sysConfigService.selectConfigByKey("common_api_url");
//                String hospbm = sysConfigService.selectConfigByKey("common_api_service_hospbm");
//                save = sendLis(sampling,tjOrder,apiUrl,hospbm);
                save = true;
            }else {
                save = true;
            }
@@ -116,4 +138,145 @@
        if (StrUtil.isNotBlank(errorMsg)) return AjaxResult.error(errorMsg);
        return AjaxResult.success("操作成功");
    }
    private void sendLisSqd(Long orderId, String jxbz) {
        String apiUrl = sysConfigService.selectConfigByKey("common_api_url");
        String hospbm = sysConfigService.selectConfigByKey("common_api_service_hospbm");
        TjOrder order = orderService.getById(orderId);
        if (StrUtil.isNotBlank(jxbz)){
            LambdaQueryWrapper<TjSampling> wrapper1 = new LambdaQueryWrapper<>();
            wrapper1.eq(TjSampling::getTjNum,order.getTjNumber());
            wrapper1.eq(TjSampling::getJxbz,jxbz);
            getLisMxList(wrapper1, order,apiUrl,hospbm);
        }else {
            LambdaQueryWrapper<TjSampling> wrapper1 = new LambdaQueryWrapper<>();
            wrapper1.eq(TjSampling::getTjNum,order.getTjNumber());
            wrapper1.isNull(TjSampling::getJxbz);
            getLisMxList(wrapper1, order,apiUrl,hospbm);
        }
    }
    private void getLisMxList(LambdaQueryWrapper<TjSampling> wrapper1, TjOrder order,String apiUrl,String hospbm) {
        List<TjSampling> samplings = tjSamplingService.list(wrapper1);
        if (!samplings.isEmpty()){
            List<TjSampling> mergeList = samplings.stream().filter(i -> i.getIsMerge() == 1).collect(Collectors.toList());
            List<TjSampling> notMergeList = samplings.stream().filter(i -> i.getIsMerge() == 0).collect(Collectors.toList());
            if (!mergeList.isEmpty()){
                notMergeList = sendLis(order, apiUrl, hospbm, mergeList, notMergeList);
            }
            if (!notMergeList.isEmpty()){
                sendLis(order,apiUrl,hospbm,notMergeList,notMergeList);
            }
        }
    }
    private List<TjSampling> sendLis(TjOrder order, String apiUrl, String hospbm, List<TjSampling> mergeList, List<TjSampling> notMergeList) {
        for (TjSampling sampling : mergeList) {
            JSONArray xmList = JSONUtil.createArray();
            String code = sampling.getSpecimenTypeCode();
            String type = sampling.getSpecimenType();
            String[] prodIds = sampling.getProId().split(",");
            for (String prodId : prodIds) {
                JSONObject entries = JSONUtil.createObj();
                String id = notMergeList.stream().filter(i -> i.getProId().equals(prodId)).collect(Collectors.toList()).get(0).getId();
                TjProject project = tjProjectMapper.selectById(prodId);
                entries.putOpt("sfxmid",project.getProId());
                entries.putOpt("sfxmname",project.getProName());
                // 取tb表
                entries.putOpt("sfxmprice",project.getProPrice());
                entries.putOpt("quality",project.getSl());
                entries.putOpt("specimencode",code);
                entries.putOpt("specimendesc",type);
                entries.putOpt("primaryKey",id);
                xmList.add(entries);
                notMergeList = notMergeList.stream().filter(i -> !i.getProId().equals(prodId)).collect(Collectors.toList());
            }
            JSONObject entries = JSONUtil.createObj();
            TjCustomer customer = tjCustomerService.getById(order.getUserId());
            entries.putOpt("patientno",customer.getHisJzkh());
            entries.putOpt("gh_patientno", order.getTjNumber());
            entries.putOpt("txm",sampling.getJyxh());
            entries.putOpt("printno",customer.getHisJzkh());
            entries.putOpt("cusName",customer.getCusName());
            entries.putOpt("cusBrithday",customer.getCusBrithday());
            entries.putOpt("cusIdCard",customer.getCusIdcard());
            entries.putOpt("cusSex",customer.getCusSex());
            entries.putOpt("cusAddr",customer.getCusAddr());
            entries.putOpt("cusPhone",customer.getCusPhone());
            entries.putOpt("compName","");
            entries.putOpt("mxList",xmList);
            String post = HttpClientUtils.sendPost(apiUrl + "/api/lis/"+ hospbm +"/create", JSONUtil.toBean(entries, Map.class));
            JSONObject result = JSONUtil.parseObj(post);
            if (result.getStr("code").equals("200")){
                List<String> list = Arrays.asList(prodIds);
                list.add(sampling.getId());
                LambdaUpdateWrapper<TjSampling> wrapper = new LambdaUpdateWrapper<>();
                wrapper.in(TjSampling::getId,list);
                wrapper.set(TjSampling::getIsApply,1);
                tjSamplingService.update(wrapper);
            }
        }
        return notMergeList;
    }
    private Boolean sendLis(TjSampling sampling,TjOrder order,String apiUrl,String hospbm){
        JSONArray xmList = JSONUtil.createArray();
        String code = sampling.getSpecimenTypeCode();
        String type = sampling.getSpecimenType();
        String[] prodIds = sampling.getProId().split(",");
        for (String prodId : prodIds) {
            JSONObject entries = JSONUtil.createObj();
            TjProject project = tjProjectMapper.selectById(prodId);
            entries.putOpt("sfxmid",project.getProId());
            entries.putOpt("sfxmname",project.getProName());
            // 取tb表
            QueryWrapper<TbTransition> wrapper = new QueryWrapper<>();
            wrapper
                    .select("sum(now_price) as now_price")
                    .eq("tj_num",order.getTjNumber())
                    .eq("parent_pro_id",prodId);
            TbTransition transition = tbTransitionService.getOne(wrapper);
            entries.putOpt("sfxmprice",transition.getNowPrice());
            entries.putOpt("quality",project.getSl());
            entries.putOpt("specimencode",code);
            entries.putOpt("specimendesc",type);
            entries.putOpt("primaryKey",prodId);
            xmList.add(entries);
        }
        JSONObject entries = JSONUtil.createObj();
        TjCustomer customer = tjCustomerService.getById(order.getUserId());
        entries.putOpt("patientno",customer.getHisJzkh());
        entries.putOpt("gh_patientno", order.getTjNumber());
        entries.putOpt("txm",sampling.getJyxh());
        entries.putOpt("printno",customer.getHisJzkh());
        entries.putOpt("cusName",customer.getCusName());
        entries.putOpt("cusBrithday",customer.getCusBrithday());
        entries.putOpt("cusIdCard",customer.getCusIdcard());
        entries.putOpt("cusSex",customer.getCusSex());
        entries.putOpt("cusAddr",customer.getCusAddr());
        entries.putOpt("cusPhone",customer.getCusPhone());
        entries.putOpt("compName","");
        entries.putOpt("mxList",xmList);
        String post = HttpClientUtils.sendPost(apiUrl + "/api/lis/"+ hospbm +"/create", JSONUtil.toBean(entries, Map.class));
//        JSONObject result = JSONUtil.parseObj(post);
//        if (result.getStr("code").equals("200")){
//            List<String> list = Arrays.asList(prodIds);
//            list.add(sampling.getId());
//            LambdaUpdateWrapper<TjSampling> wrapper = new LambdaUpdateWrapper<>();
//            wrapper.in(TjSampling::getId,list);
//            wrapper.set(TjSampling::getIsApply,1);
//            tjSamplingService.update(wrapper);
//            return true;
//        }
//        return false;
        return true;
    }
}
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java
@@ -260,10 +260,14 @@
        wrapper.eq(TjSampling::getTjNum, tjNumber);
        wrapper.eq(TjSampling::getIsSignFor,isSignFor);
        wrapper.and(i -> i.isNull(TjSampling::getParentId).or().eq(TjSampling::getIsMerge,1));
//        wrapper.eq(TjSampling::getIsPay,1);
//        if (isSignFor == 1)
//            wrapper.eq(TjSampling::getIsApply,0);
        wrapper.orderByDesc(TjSampling::getIsMerge);
        List<TjSampling> list = tjSamplingService.list(wrapper);
        if (list.isEmpty()){
            logger.info("jtNum ->{}",tjNumber);
//            return AjaxResult.error("未查询到数据,人员未缴费或没有未采样项目");
            return AjaxResult.error("参数错误,未查询到数据");
        }
//        for (TjSampling sampling : list) {