From 2c19fa65dc87ea8f3d81f84154f4eeabff7f8d00 Mon Sep 17 00:00:00 2001 From: zjh <1084500556@qq.com> Date: 星期四, 05 六月 2025 12:36:47 +0800 Subject: [PATCH] zjh20250605 --- ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java | 319 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 268 insertions(+), 51 deletions(-) diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java index 24ad6b7..51d0401 100644 --- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java +++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java @@ -1,36 +1,33 @@ package com.ltkj.web.controller.system; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; import java.util.stream.Collectors; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import javax.swing.plaf.basic.BasicScrollPaneUI; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ltkj.common.core.redis.RedisCache; import com.ltkj.framework.config.MatchUtils; -import com.ltkj.hosp.domain.TbTransition; -import com.ltkj.hosp.domain.TjCustomer; -import com.ltkj.hosp.domain.TjProject; -import com.ltkj.hosp.service.ITjCustomerService; -import com.ltkj.hosp.service.ITjProjectService; -import com.ltkj.hosp.service.TjAsyncService; +import com.ltkj.hosp.domain.*; +import com.ltkj.hosp.service.*; +import com.ltkj.system.service.ISysConfigService; +import com.ltkj.web.controller.his.HisApiMethod; +import com.ltkj.web.controller.lis.LisApiMethod; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.aspectj.weaver.AjAttribute; -import org.springframework.security.access.prepost.PreAuthorize; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import com.ltkj.common.annotation.Log; import com.ltkj.common.core.controller.BaseController; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.enums.BusinessType; -import com.ltkj.hosp.domain.TjSampling; -import com.ltkj.hosp.service.ITjSamplingService; import com.ltkj.common.utils.poi.ExcelUtil; import com.ltkj.common.core.page.TableDataInfo; @@ -40,9 +37,10 @@ * @author ltkj_璧典匠璞�&鏉庢牸 * @date 2023-04-11 */ +@Slf4j @RestController @RequestMapping("/sampling/sampling") -@Api(tags = "浣撴閲囨牱绠$悊") +@Api(tags = "PC绔� 浣撴閲囨牱绠$悊") public class TjSamplingController extends BaseController { @Resource private ITjSamplingService tjSamplingService; @@ -54,11 +52,29 @@ private TjAsyncService asyncService; @Resource private RedisCache redisCache; + @Autowired + private ITjOrderService orderService; + @Autowired + private ITbTransitionService tbTransitionService; + @Autowired + private LisApiMethod lisApiMethod; + @Autowired + private ISysConfigService configService; + @Autowired + private SamplingServiceApi samplingService; + @Autowired + private HisApiMethod hisApiMethod; + @Autowired + private LtkjJianchajianyanTreeService treeService; + @Autowired + private TbLisSqService tbLisSqService; + @Autowired + private LtkjJfxmgljyxmzdService jfxmgljyxmzdService; /** * 鏌ヨ浣撴閲囨牱绠$悊鍒楄〃 */ - @PreAuthorize("@ss.hasPermi('sampling:sampling:list')") + //@PreAuthorize("@ss.hasPermi('sampling:sampling:list')") @GetMapping("/list") @ApiOperation(value = "鏌ヨ浣撴閲囨牱绠$悊鍒楄〃(鑷甫榛樿)") public TableDataInfo list(TjSampling tjSampling) { @@ -178,9 +194,235 @@ } /** + * 鑾峰彇閲囨牱瀹㈡埛鍒楄〃 + * + * @param isSignFor + * @param tjNumber + * @param name + * @param pageNum + * @param pageSize + * @param beginTime + * @param endTime + * @return + */ + @GetMapping("/getCusList") + @ApiOperation(value = "鑾峰彇閲囨牱瀹㈡埛鍒楄〃") + public AjaxResult getCusList(@RequestParam(defaultValue = "1") @ApiParam(value = "0鏄�1鍚�") Integer isSignFor, + @RequestParam(required = false) @ApiParam(value = "浣撴鍙�") String tjNumber, + @RequestParam(required = false) @ApiParam(value = "瀹㈡埛濮撳悕") String name, + @RequestParam(required = false) @ApiParam(value = "鍗曚綅") String dw, + @ApiParam(value = "椤电爜鏁�(榛樿1)") @RequestParam(defaultValue = "1") Integer pageNum, + @ApiParam(value = "鏄剧ず鏉℃暟(榛樿10)") @RequestParam(defaultValue = "10") Integer pageSize, + @ApiParam(value = "寮�濮嬫椂闂�") @RequestParam(required = false) String beginTime, + @ApiParam(value = "缁撴潫鏃堕棿") @RequestParam(required = false) String endTime) { + Page<TjSampling> samplingPage = new Page<>(pageNum, pageSize); + LambdaQueryWrapper<TjSampling> wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(TjSampling::getIsSignFor, isSignFor); + if (null != tjNumber && StrUtil.isNotBlank(tjNumber)) + wrapper.like(TjSampling::getTjNum, tjNumber); + if (null != name && StrUtil.isNotBlank(name)) + wrapper.like(TjSampling::getCusName, name); + if (null != beginTime && null != endTime && StrUtil.isNotBlank(beginTime) && StrUtil.isNotBlank(endTime)) + wrapper.between(TjSampling::getApplicationTime, beginTime, endTime); + if (StrUtil.isNotBlank(dw)){ + LambdaQueryWrapper<TjOrder> wqq=new LambdaQueryWrapper<>(); + wqq.like(TjOrder::getFirmId,dw); + wqq.select(TjOrder::getTjNumber); + List<TjOrder> orderList = orderService.list(wqq); + if(null !=orderList && !orderList.isEmpty()){ + List<String> list = orderList.stream().map(TjOrder::getTjNumber).collect(Collectors.toList()); + wrapper.in(TjSampling::getTjNum, list); + } + } + + wrapper.groupBy(TjSampling::getTjNum); + wrapper.orderByDesc(TjSampling::getCreateTime); +// wrapper.last("LIMIT " + (pageNum - 1) * pageSize + "," + pageSize); + Page<TjSampling> page = tjSamplingService.page(samplingPage, wrapper); + List<TjSampling> list = page.getRecords(); + ArrayList<TjCustomer> tjCustomers = new ArrayList<>(); + for (TjSampling tjSampling : list) { + TjCustomer customer = customerService.getById(tjSampling.getCusId()); + if(null !=customer){ + TjOrder order = orderService.getOrderByTjNum(tjSampling.getTjNum()); + customer.setCompName(order.getFirmName()); + customer.setCusName(customer.getCusName()); + customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone())); + customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard())); + customer.setTjNumber(tjSampling.getTjNum()); + customer.setApplicationTime(tjSampling.getApplicationTime()); + tjCustomers.add(customer); + } + } + HashMap<String, Object> hashMap = new HashMap<>(); + hashMap.put("list", tjCustomers); + hashMap.put("total", page.getTotal()); + return AjaxResult.success(hashMap); + } + + /** + * 鏍规嵁瀹㈡埛鑾峰彇閲囨牱鍒楄〃 + * + * @param tjNumber + * @return + */ + @GetMapping("/getCusCyList") + @ApiOperation(value = "鏍规嵁瀹㈡埛鑾峰彇閲囨牱鍒楄〃") + public AjaxResult getCusCyList(@RequestParam @ApiParam(value = "瀹㈡埛id") String tjNumber, + @RequestParam(defaultValue = "1") @ApiParam(value = "0鏄�1鍚�") Integer isSignFor) { + if (tjNumber == null || StrUtil.isBlank(tjNumber)) + return AjaxResult.error("鍙傛暟閿欒,鏈紶鍙傛暟"); + LambdaQueryWrapper<TjSampling> wrapper = new LambdaQueryWrapper<>(); + String config = configService.selectConfigByKey("sfkqdyhis"); + if (config.equals("Y")){ +// LambdaQueryWrapper<TjSampling> wrapper6 = new LambdaQueryWrapper<>(); +// wrapper6.eq(TjSampling::getTjNum, tjNumber); +// wrapper6.eq(TjSampling::getIsSignFor,isSignFor); +// wrapper6.and(i -> i.isNull(TjSampling::getParentId).or().eq(TjSampling::getIsMerge,1)); +// wrapper6.isNull(TjSampling::getJyxh); +// List<TjSampling> list1 = tjSamplingService.list(wrapper6); +// if (!list1.isEmpty()){ + if (true){ + LambdaQueryWrapper<TjOrder> wrapper1 = new LambdaQueryWrapper<>(); + wrapper1.eq(TjOrder::getTjNumber,tjNumber); + TjOrder tjOrder = orderService.getOne(wrapper1); + hisApiMethod.Getlabreginfoinfo(tjOrder.getCardId(),new SimpleDateFormat("yyyy-MM-dd").format(tjOrder.getCreateTime())); + LambdaQueryWrapper<TbLisSq> wrapper2 = new LambdaQueryWrapper<>(); + wrapper2.eq(TbLisSq::getCardId,tjOrder.getCardId()); + List<TbLisSq> list = tbLisSqService.list(wrapper2); + for (TbLisSq lisSq : list) { + if (!lisSq.getSqdbh().contains("jk")) + continue; + String jyxmdm = lisSq.getJyxmdm(); + LambdaQueryWrapper<TjProject> wrapper4 = new LambdaQueryWrapper<>(); + wrapper4.eq(TjProject::getLisXmbm,jyxmdm); + TjProject project = projectService.getOne(wrapper4); + if (project != null){ + LambdaUpdateWrapper<TjSampling> wrapper5 = new LambdaUpdateWrapper<>(); + String jyxh = ""; + if (StrUtil.isNotBlank(lisSq.getJyxhHb())) + jyxh = lisSq.getJyxhHb(); + else jyxh = lisSq.getJyxh(); + wrapper5.set(TjSampling::getJyxh,jyxh); + wrapper5.set(TjSampling::getJyxmdm,lisSq.getJyxmdm()); + wrapper5.eq(TjSampling::getProId,project.getProParentId()); + wrapper5.eq(TjSampling::getTjNum,tjNumber); + tjSamplingService.update(wrapper5); + } + } + +// JSONArray array = hisApiMethod.Getlabreginfoinfo(tjOrder.getCardId()); +// if (array != null && !array.isEmpty()){ +// for (Object o : array) { +// JSONObject jsonObject = (JSONObject) o; +// String sqdh = jsonObject.getStr("sqdh"); +// String jyxh = jsonObject.getStr("jyxh"); +// LambdaQueryWrapper<LtkjJianchajianyanTree> wrapper2 = new LambdaQueryWrapper<>(); +// wrapper2.eq(LtkjJianchajianyanTree::getCardId,tjOrder.getCardId()); +// wrapper2.eq(LtkjJianchajianyanTree::getType,"妫�楠�"); +// wrapper2.eq(LtkjJianchajianyanTree::getSqdh,sqdh); +// List<LtkjJianchajianyanTree> list = treeService.list(wrapper2); +// List<String> hisXms = list.stream().map(LtkjJianchajianyanTree::getHisXmdm).collect(Collectors.toList()); +// LambdaQueryWrapper<TjProject> wrapper3 = new LambdaQueryWrapper<>(); +// wrapper3.in(TjProject::getHisXmbm,hisXms); +// wrapper3.ne(TjProject::getProParentId,0); +// wrapper3.groupBy(TjProject::getProParentId); +// List<Long> proParentIds = projectService.list(wrapper3).stream().map(TjProject::getProParentId).collect(Collectors.toList()); +// LambdaQueryWrapper<TjProject> wrapper4 = new LambdaQueryWrapper<>(); +// wrapper4.in(TjProject::getProId,proParentIds); +// List<Long> proIds = projectService.list(wrapper4).stream().map(TjProject::getProId).collect(Collectors.toList()); +// LambdaUpdateWrapper<TjSampling> wrapper5 = new LambdaUpdateWrapper<>(); +// wrapper5.set(TjSampling::getJyxh,jyxh); +// wrapper5.in(TjSampling::getProId,proIds); +// wrapper5.eq(TjSampling::getTjNum,tjNumber); +// tjSamplingService.update(wrapper5); +// } +// } + } + } + +// if (config.equals("Y")) +// wrapper.eq(TjSampling::getJyxh,""); + 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) { +// TjCustomer customer = customerService.getById(sampling.getCusId()); +// TjOrder order = orderService.getOrderByTjNum(sampling.getTjNum()); +// if(null !=order)sampling.setCardId(order.getCardId()); +// sampling.setCustomer(customer); +// } + + if (list.size() >= 2) { + // 杩涜鍚堝苟 + List<String> stringList = list.stream().map(TjSampling::getId).collect(Collectors.toList()); +// log.info("鎻愬彇id ->{}",stringList); + for (String s : stringList) { + if (tjSamplingService.isMergeItem(s) != 0) { + list.removeIf(item -> Objects.equals(item.getId(), s)); + } + } + String lis_tmh_prefix = configService.selectConfigByKey("make_lis_tmh_prefix"); + Map<String, List<TjSampling>> map = list.stream().filter(i->StrUtil.isNotBlank(i.getSpecimenTypeCode())).collect(Collectors.groupingBy(item -> item.getSpecimenTypeCode())); + for (Map.Entry<String, List<TjSampling>> entry : map.entrySet()) { + List<TjSampling> entryValue = entry.getValue(); + tjSamplingService.mergeCaiYangTran(entryValue.stream().map(TjSampling::getId).collect(Collectors.toList()),lis_tmh_prefix); + } + } + wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(TjSampling::getTjNum, tjNumber); + wrapper.eq(TjSampling::getIsSignFor,isSignFor); + wrapper.and(i -> i.isNull(TjSampling::getParentId).or().eq(TjSampling::getIsMerge,1)); +// wrapper.orderByDesc(TjSampling::getIsMerge); + wrapper.orderByAsc(TjSampling::getSpecimenTypeCode,TjSampling::getIsMerge); + list = tjSamplingService.list(wrapper); + for (TjSampling sampling : list) { + TjCustomer customer = customerService.getById(sampling.getCusId()); + TjOrder order = orderService.getOrderByTjNum(sampling.getTjNum()); + if(null !=order)sampling.setCardId(order.getCardId()); + sampling.setCustomer(customer); + } + return AjaxResult.success(list); + } + + @PostMapping("/mergeCaiYang") + @ApiOperation(value = "閲囨牱鐧昏鍚堝苟椤圭洰鎺ュ彛") + public AjaxResult mergeCaiYang(@RequestBody List<String> ids) { + String lis_tmh_prefix = configService.selectConfigByKey("make_lis_tmh_prefix"); + return tjSamplingService.mergeCaiYangTran(ids,lis_tmh_prefix); + } + + + @PostMapping("/chexiaoCaiYang") + @ApiOperation(value = "鎾ら攢閲囨牱鐧昏鍚堝苟椤圭洰鎺ュ彛") + @Transactional + public AjaxResult chexiaoCaiYang(@RequestBody List<String> ids) { + if (null != ids && !ids.isEmpty()) { + int pdsfczhbxm = tjSamplingService.pdsfczhbxm(ids); + if (pdsfczhbxm != ids.size()) return AjaxResult.error("瀛樺湪鏈悎骞剁殑椤圭洰涓嶅彲鎾ら攢!!!"); + tjSamplingService.deletedTjSamplingListByHb(ids); + tjSamplingService.updateHeBingXm(ids); + return AjaxResult.success("鎾ら攢鎴愬姛!!!"); + } + return AjaxResult.error("璇烽�夋嫨浣犺鎾ら攢鐨勯」鐩�!!!"); + } + + + /** * 瀵煎嚭浣撴閲囨牱绠$悊鍒楄〃 */ - @PreAuthorize("@ss.hasPermi('sampling:sampling:export')") + //@PreAuthorize("@ss.hasPermi('sampling:sampling:export')") @Log(title = "浣撴閲囨牱绠$悊", businessType = BusinessType.EXPORT) @PostMapping("/export") @ApiOperation(value = "瀵煎嚭浣撴閲囨牱绠$悊鍒楄〃") @@ -193,7 +435,7 @@ /** * 鑾峰彇浣撴閲囨牱绠$悊璇︾粏淇℃伅 */ - @PreAuthorize("@ss.hasPermi('sampling:sampling:query')") + //@PreAuthorize("@ss.hasPermi('sampling:sampling:query')") @GetMapping(value = "/{id}") @ApiOperation(value = "鑾峰彇浣撴閲囨牱绠$悊璇︾粏淇℃伅") public AjaxResult getInfo(@PathVariable("id") String id) { @@ -203,7 +445,7 @@ /** * 鏂板浣撴閲囨牱绠$悊 */ - @PreAuthorize("@ss.hasPermi('sampling:sampling:add')") + //@PreAuthorize("@ss.hasPermi('sampling:sampling:add')") @Log(title = "浣撴閲囨牱绠$悊", businessType = BusinessType.INSERT) @PostMapping @ApiOperation(value = "鏂板浣撴閲囨牱绠$悊") @@ -214,7 +456,7 @@ /** * 淇敼浣撴閲囨牱绠$悊 */ - @PreAuthorize("@ss.hasPermi('sampling:sampling:edit')") + //@PreAuthorize("@ss.hasPermi('sampling:sampling:edit')") @Log(title = "浣撴閲囨牱绠$悊", businessType = BusinessType.UPDATE) @PutMapping @ApiOperation(value = "淇敼浣撴閲囨牱绠$悊") @@ -225,7 +467,7 @@ /** * 鍒犻櫎浣撴閲囨牱绠$悊 */ - @PreAuthorize("@ss.hasPermi('sampling:sampling:remove')") + //@PreAuthorize("@ss.hasPermi('sampling:sampling:remove')") @Log(title = "浣撴閲囨牱绠$悊", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") @ApiOperation(value = "鍒犻櫎浣撴閲囨牱绠$悊") @@ -239,35 +481,10 @@ */ @PostMapping("/confirmSampling") @ApiOperation(value = "纭閲囨牱鎺ュ彛") + @Transactional public AjaxResult confirmSampling(@RequestBody List<String> ids) { - if (null == ids || ids.size() == 0) { - return AjaxResult.error("璇烽�夋嫨瑕佺‘璁ら」"); - } - for (String id : ids) { - TjSampling sampling = tjSamplingService.getById(id); - if (null != sampling) { - sampling.setIsSignFor("0"); - LambdaQueryWrapper<TjProject> wq = new LambdaQueryWrapper<>(); - wq.eq(TjProject::getProParentId, sampling.getProId()); - List<TjProject> projectList = projectService.list(wq); - List<String> collect = new ArrayList<>(); - for (TjProject project : projectList) { - Long proId = project.getProId(); - collect.add(String.valueOf(proId)); - } - LambdaQueryWrapper<TjSampling> wq1 = new LambdaQueryWrapper<>(); - wq1.eq(TjSampling::getTjNum, sampling.getTjNum()); - wq1.in(TjSampling::getProId, collect); - List<TjSampling> samplingList = tjSamplingService.list(wq1); - if (null != samplingList && samplingList.size() > 0) { - for (TjSampling tjSampling : samplingList) { - tjSampling.setIsSignFor("0"); - tjSamplingService.updateById(tjSampling); - } - } - } - tjSamplingService.updateById(sampling); - } - return AjaxResult.success("鎿嶄綔鎴愬姛"); + String config = configService.selectConfigByKey("sfkqdyhis"); + String mergeRequest = configService.selectConfigByKey("use_lis_pacs_is_auto_merge_request"); + return samplingService.confirmApi(ids,config,mergeRequest); } } -- Gitblit v1.8.0