From 4761f2bc70814bde9929f1081a213a9ab38a7393 Mon Sep 17 00:00:00 2001 From: zhaowenxuan <chacca165@163.com> Date: 星期四, 02 一月 2025 18:15:38 +0800 Subject: [PATCH] 采样管理确认采样增加调用lis请求 --- ltkj-admin/src/main/java/com/ltkj/web/controller/system/SamplingServiceApi.java | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 166 insertions(+), 3 deletions(-) diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/SamplingServiceApi.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/SamplingServiceApi.java index 640dbc8..8d421ee 100644 --- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/SamplingServiceApi.java +++ b/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()); + // 鍙杢b琛� + 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()); + + // 鍙杢b琛� + 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; + } } -- Gitblit v1.8.0