ltkj-admin/src/main/java/com/ltkj/web/controller/lis/LisApiMethod.java
@@ -2,8 +2,6 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.pinyin.PinyinUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; @@ -11,7 +9,7 @@ import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.utils.AgeResult; import com.ltkj.common.utils.DateUtils; import com.ltkj.common.utils.IdUtils; import com.ltkj.hosp.idutil.IdUtils; import com.ltkj.hosp.domain.*; import com.ltkj.hosp.hisDto.OutpintestapplyDetailsDto; import com.ltkj.hosp.lisDto.LisSaveSqdxxDto; @@ -68,132 +66,6 @@ @Autowired private ITjSamplingService tjSamplingService; /** * 保存检验单申请信息 * @param tjOrder * @param tjCustomer * @param detailList * @return * @deprecated 修改 不使用List<TbTransition>传参数 */ @Deprecated public Boolean save(TjOrder tjOrder, TjCustomer tjCustomer, List<TbTransition> detailList){ if (detailList != null && !detailList.isEmpty()) { String dept = configService.selectConfigByKey("request_default_dept"); String ysbm = configService.selectConfigByKey("request_default_ysbm"); String lis_tmh_prefix = configService.selectConfigByKey("make_lis_tmh_prefix"); LambdaQueryWrapper<TjProject> wq = new LambdaQueryWrapper<>(); wq.in(TjProject::getProId, detailList.stream().map(TbTransition::getParentProId).collect(Collectors.toList())); wq.in(TjProject::getDeptId,deptService.getJyDeptIds()); List<TjProject> projects = projectService.list(wq); if (projects != null && !projects.isEmpty()){ // 根据project表的his_xmbm查组合关联表 ltkj_jfzhgljyxmzd 根据字段`zhxmdm` // - 查到 使用字段`jyxmdm`查检验项目字典表 ltkj_jyxmzd 根据字段`jyxmdm` // - 未查到 查项目关联表ltkj_jfxmgljyxmzd 根据字段`xmdm` AtomicInteger xh = new AtomicInteger(); for (TjProject project : projects) { if (0 == project.getProParentId() && project.getProPrice().compareTo(BigDecimal.ZERO) != 0) { if (null != project.getHisXmbm()) { LtkjJyxmzd jyxmzd = getJyxmzd(project); if (jyxmzd != null) { LisSaveSqdxxDto lisSaveSqdxxDto = new LisSaveSqdxxDto(); String jyxh = idUtils.generateLisID(lis_tmh_prefix); lisSaveSqdxxDto.setJyxh(jyxh); lisSaveSqdxxDto.setBah(tjOrder.getCardId()); lisSaveSqdxxDto.setBrxm(tjCustomer.getCusName()); lisSaveSqdxxDto.setBrdm(PinyinUtil.getFirstLetter(tjCustomer.getCusName(),"")); lisSaveSqdxxDto.setXb(tjCustomer.getCusSex()==1?"2":"1"); lisSaveSqdxxDto.setCsrq(DateFormatUtils.format(tjCustomer.getCusBrithday(), "yyyy-MM-dd")); AgeResult ageResult = DateUtils.calculateAge(tjCustomer.getCusBrithday()); lisSaveSqdxxDto.setNl(String.valueOf(ageResult.getAge())); lisSaveSqdxxDto.setNldw(String.valueOf(ageResult.getUnit())); lisSaveSqdxxDto.setSfzh(tjCustomer.getCusIdcard()); lisSaveSqdxxDto.setLxdh(tjCustomer.getCusPhone()); lisSaveSqdxxDto.setJtzz(""); Date date = new Date(); lisSaveSqdxxDto.setSqrq(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); lisSaveSqdxxDto.setCyrq(""); lisSaveSqdxxDto.setLczd(""); lisSaveSqdxxDto.setBz(""); lisSaveSqdxxDto.setKsbm(dept); lisSaveSqdxxDto.setSqys(ysbm); lisSaveSqdxxDto.setKfbz("1"); List<OutpintestapplyDetailsDto> detailsDtos = new ArrayList<>(); ArrayList<LisSaveSqdxxJyxmlistDto> dtos = new ArrayList<>(); BigDecimal allPrice = new BigDecimal("0"); for (TbTransition transition : detailList.stream().filter(item -> Objects.equals(item.getParentProId(), project.getProId())) .collect(Collectors.toList())) { allPrice = allPrice.add(transition.getNowPrice()); } lisSaveSqdxxDto.setFyje(allPrice.toString()); lisSaveSqdxxDto.setYbbm(jyxmzd.getJybbdm()); LisSaveSqdxxJyxmlistDto dto = new LisSaveSqdxxJyxmlistDto(); dto.setXh(String.valueOf(xh.getAndIncrement() + 1)); dto.setJyxm(jyxmzd.getJyxmdm()); dto.setXmmc(jyxmzd.getJyxmmc()); dtos.add(dto); OutpintestapplyDetailsDto detailsDto = new OutpintestapplyDetailsDto(); detailsDto.setMxfyxmbm(project.getHisXmbm()); if (project.getSfzhfy().equals("Y")) { detailsDto.setSfzhfy("1"); } else { detailsDto.setSfzhfy("0"); } detailsDto.setSl(project.getSl()); detailsDto.setProjg(project.getProPrice()); detailsDtos.add(detailsDto); lisSaveSqdxxDto.setJyxmlist(dtos); log.info("检验申请参数 ->{}",JSONUtil.toJsonStr(lisSaveSqdxxDto)); AjaxResult ajaxResult = lisApiMethodService.saveSqdxx(lisSaveSqdxxDto); // Lis请求返回 ->{"msg":"操作失败","code":500,"result":{"Response":{"ResultContent":"成功","ResultData":null,"ResultCode":"1"}}} // {"msg":"操作成功","code":200,"data":{"ResultContent":"成功","ResultData":null,"ResultCode":"1"}} log.info("Lis请求返回 ->{}",JSONUtil.toJsonStr(ajaxResult)); String result = ajaxResult.get("data").toString(); JSONObject object = JSONUtil.parseObj(result); String code = object.getStr("ResultCode"); if(code.equals("1")){ for (OutpintestapplyDetailsDto detail : detailsDtos) { LtkjJianchajianyanTree tree = new LtkjJianchajianyanTree(); tree.setCardId(tjOrder.getCardId()); tree.setPationid(tjCustomer.getPationId()); tree.setSqdh(jyxh); tree.setFyhj(allPrice.toString()); String mxfyxmbm = detail.getMxfyxmbm(); tree.setHisXmdm(mxfyxmbm); tree.setType("检验"); tree.setService("lis"); tree.setTjPrice(String.valueOf(detail.getProjg())); LambdaQueryWrapper<LtkjJfzhglmxjfxmzd> wrapper1 = new LambdaQueryWrapper<>(); if (detail.getSfzhfy().equals("1")) wrapper1.eq(LtkjJfzhglmxjfxmzd::getZhxmdm, mxfyxmbm); else wrapper1.eq(LtkjJfzhglmxjfxmzd::getXmdm, mxfyxmbm); List<LtkjJfzhglmxjfxmzd> ltkjJfzhglmxjfxmzds = ltkjJfzhglmxjfxmzdService.list(wrapper1); if (ltkjJfzhglmxjfxmzds != null && !ltkjJfzhglmxjfxmzds.isEmpty()) { String xmdm = ltkjJfzhglmxjfxmzds.get(0).getXmdm(); LambdaQueryWrapper<LtkjMxjfxmzd> wrapper3 = new LambdaQueryWrapper<>(); wrapper3.eq(LtkjMxjfxmzd::getXmdm, xmdm); LtkjMxjfxmzd mxjfxmzd = ltkjMxjfxmzdService.getOne(wrapper3); LambdaQueryWrapper<LtkjEjjfxmzd> wrapper4 = new LambdaQueryWrapper<>(); wrapper4.eq(LtkjEjjfxmzd::getEjkmdm, mxjfxmzd.getEjkmdm()); LtkjEjjfxmzd ejjfxmzd = ltkjEjjfxmzdService.getOne(wrapper4); tree.setXmfl(ejjfxmzd.getYjkmdm()); } tree.setCreateTime(DateUtil.date()); ltkjJianchajianyanTreeService.save(tree); } }else { log.error("请求失败 ->{}",lisSaveSqdxxDto); } } } } } } } return true; } public Boolean save(TjSampling sampling,TjOrder tjOrder,TjCustomer tjCustomer){ String dept = configService.selectConfigByKey("request_default_dept"); @@ -322,123 +194,6 @@ log.error("请求失败 ->{}", lisSaveSqdxxDto); return false; } } public Boolean save(TjOrder tjOrder, TjCustomer tjCustomer, List<TjProject> projects,List<TbTransition> detailList) { // LambdaQueryWrapper<TjProject> wq = new LambdaQueryWrapper<>(); // wq.in(TjProject::getProId, detailList.stream().map(TbTransition::getParentProId).collect(Collectors.toList())); // wq.in(TjProject::getDeptId,deptService.getJyDeptIds()); // List<TjProject> projects = projectService.list(wq); if (projects != null && !projects.isEmpty()) { String dept = configService.selectConfigByKey("request_default_dept"); String ysbm = configService.selectConfigByKey("request_default_ysbm"); String lis_tmh_prefix = configService.selectConfigByKey("make_lis_tmh_prefix"); // 根据project表的his_xmbm查组合关联表 ltkj_jfzhgljyxmzd 根据字段`zhxmdm` // - 查到 使用字段`jyxmdm`查检验项目字典表 ltkj_jyxmzd 根据字段`jyxmdm` // - 未查到 查项目关联表ltkj_jfxmgljyxmzd 根据字段`xmdm` AtomicInteger xh = new AtomicInteger(); for (TjProject project : projects) { if (0 == project.getProParentId() && project.getProPrice().compareTo(BigDecimal.ZERO) != 0) { if (null != project.getHisXmbm()) { LtkjJyxmzd jyxmzd = getJyxmzd(project); if (jyxmzd != null) { LisSaveSqdxxDto lisSaveSqdxxDto = new LisSaveSqdxxDto(); String jyxh = idUtils.generateLisID(lis_tmh_prefix); lisSaveSqdxxDto.setJyxh(jyxh); lisSaveSqdxxDto.setBah(tjOrder.getCardId()); lisSaveSqdxxDto.setBrxm(tjCustomer.getCusName()); lisSaveSqdxxDto.setBrdm(PinyinUtil.getFirstLetter(tjCustomer.getCusName(), "")); lisSaveSqdxxDto.setXb(tjCustomer.getCusSex() == 1 ? "2" : "1"); lisSaveSqdxxDto.setCsrq(DateFormatUtils.format(tjCustomer.getCusBrithday(), "yyyy-MM-dd")); AgeResult ageResult = DateUtils.calculateAge(tjCustomer.getCusBrithday()); lisSaveSqdxxDto.setNl(String.valueOf(ageResult.getAge())); lisSaveSqdxxDto.setNldw(String.valueOf(ageResult.getUnit())); lisSaveSqdxxDto.setSfzh(tjCustomer.getCusIdcard()); lisSaveSqdxxDto.setLxdh(tjCustomer.getCusPhone()); lisSaveSqdxxDto.setJtzz(""); Date date = new Date(); lisSaveSqdxxDto.setSqrq(DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss")); lisSaveSqdxxDto.setCyrq(""); lisSaveSqdxxDto.setLczd(""); lisSaveSqdxxDto.setBz(""); lisSaveSqdxxDto.setKsbm(dept); lisSaveSqdxxDto.setSqys(ysbm); lisSaveSqdxxDto.setKfbz("1"); List<OutpintestapplyDetailsDto> detailsDtos = new ArrayList<>(); ArrayList<LisSaveSqdxxJyxmlistDto> dtos = new ArrayList<>(); BigDecimal allPrice = new BigDecimal("0"); for (TbTransition transition : detailList.stream().filter(item -> Objects.equals(item.getParentProId(), project.getProId())) .collect(Collectors.toList())) { allPrice = allPrice.add(transition.getNowPrice()); } lisSaveSqdxxDto.setFyje(allPrice.toString()); lisSaveSqdxxDto.setYbbm(jyxmzd.getJybbdm()); LisSaveSqdxxJyxmlistDto dto = new LisSaveSqdxxJyxmlistDto(); dto.setXh(String.valueOf(xh.getAndIncrement() + 1)); dto.setJyxm(jyxmzd.getJyxmdm()); dto.setXmmc(jyxmzd.getJyxmmc()); dtos.add(dto); OutpintestapplyDetailsDto detailsDto = new OutpintestapplyDetailsDto(); detailsDto.setMxfyxmbm(project.getHisXmbm()); if (project.getSfzhfy().equals("Y")) { detailsDto.setSfzhfy("1"); } else { detailsDto.setSfzhfy("0"); } detailsDto.setSl(project.getSl()); detailsDto.setProjg(project.getProPrice()); detailsDtos.add(detailsDto); lisSaveSqdxxDto.setJyxmlist(dtos); log.info("检验申请参数 ->{}", JSONUtil.toJsonStr(lisSaveSqdxxDto)); AjaxResult ajaxResult = lisApiMethodService.saveSqdxx(lisSaveSqdxxDto); // Lis请求返回 ->{"msg":"操作失败","code":500,"result":{"Response":{"ResultContent":"成功","ResultData":null,"ResultCode":"1"}}} // {"msg":"操作成功","code":200,"data":{"ResultContent":"成功","ResultData":null,"ResultCode":"1"}} log.info("Lis请求返回 ->{}", JSONUtil.toJsonStr(ajaxResult)); String result = ajaxResult.get("data").toString(); JSONObject object = JSONUtil.parseObj(result); String code = object.getStr("ResultCode"); if (code.equals("1")) { for (OutpintestapplyDetailsDto detail : detailsDtos) { LtkjJianchajianyanTree tree = new LtkjJianchajianyanTree(); tree.setCardId(tjOrder.getCardId()); tree.setPationid(tjCustomer.getPationId()); tree.setSqdh(jyxh); tree.setFyhj(allPrice.toString()); String mxfyxmbm = detail.getMxfyxmbm(); tree.setHisXmdm(mxfyxmbm); tree.setType("检验"); tree.setService("lis"); tree.setTjPrice(String.valueOf(detail.getProjg())); LambdaQueryWrapper<LtkjJfzhglmxjfxmzd> wrapper1 = new LambdaQueryWrapper<>(); if (detail.getSfzhfy().equals("1")) wrapper1.eq(LtkjJfzhglmxjfxmzd::getZhxmdm, mxfyxmbm); else wrapper1.eq(LtkjJfzhglmxjfxmzd::getXmdm, mxfyxmbm); List<LtkjJfzhglmxjfxmzd> ltkjJfzhglmxjfxmzds = ltkjJfzhglmxjfxmzdService.list(wrapper1); if (ltkjJfzhglmxjfxmzds != null && !ltkjJfzhglmxjfxmzds.isEmpty()) { String xmdm = ltkjJfzhglmxjfxmzds.get(0).getXmdm(); LambdaQueryWrapper<LtkjMxjfxmzd> wrapper3 = new LambdaQueryWrapper<>(); wrapper3.eq(LtkjMxjfxmzd::getXmdm, xmdm); LtkjMxjfxmzd mxjfxmzd = ltkjMxjfxmzdService.getOne(wrapper3); LambdaQueryWrapper<LtkjEjjfxmzd> wrapper4 = new LambdaQueryWrapper<>(); wrapper4.eq(LtkjEjjfxmzd::getEjkmdm, mxjfxmzd.getEjkmdm()); LtkjEjjfxmzd ejjfxmzd = ltkjEjjfxmzdService.getOne(wrapper4); tree.setXmfl(ejjfxmzd.getYjkmdm()); } tree.setCreateTime(DateUtil.date()); ltkjJianchajianyanTreeService.save(tree); } } else { log.error("请求失败 ->{}", lisSaveSqdxxDto); } } } } } } return true; } /** ltkj-admin/src/main/java/com/ltkj/web/controller/lis/LisController.java
@@ -49,11 +49,11 @@ LambdaQueryWrapper<TjCustomer> wrapper = new LambdaQueryWrapper<>(); wrapper.eq(TjCustomer::getCusIdcard,cusId); TjCustomer customer = customerService.getOne(wrapper); lisApiMethod.save(tjOrder,customer,detailList); // lisApiMethod.save(tjOrder,customer,detailList); // 检验作废 lisApiMethod.cancel("",tjOrder.getCardId(),customer.getCusName()); // 检查保存 pacsApiMethodService.save(tjOrder,customer,detailList); // pacsApiMethodService.save(tjOrder,customer,detailList); // 检查作废 pacsApiMethodService.updatePacsApply("","",customer.getCusName()); return AjaxResult.success(); ltkj-admin/src/main/java/com/ltkj/web/controller/service/TjSysAsyncServiceImpl.java
@@ -1,6 +1,5 @@ package com.ltkj.web.controller.service; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; @@ -14,7 +13,7 @@ import com.ltkj.common.core.domain.entity.SysDept; import com.ltkj.common.core.domain.entity.SysUser; import com.ltkj.common.core.redis.RedisCache; import com.ltkj.common.utils.IdUtils; import com.ltkj.hosp.idutil.IdUtils; import com.ltkj.common.utils.StringUtils; import com.ltkj.framework.config.MatchUtils; import com.ltkj.hosp.domain.*; @@ -452,6 +451,7 @@ } public void addCaiYangDengJi(List<TjOrderDetail> detailList, boolean detailList1, TjOrder order, SysUser sysUser,String jxbz) { try { String lis_tmh_prefix = sysConfigService.selectConfigByKey("make_lis_tmh_prefix"); String config = configService.selectConfigByKey("sfkqdyhis"); Boolean lisAndPacsRegister = lisApiMethod.isUseLisAndPacsRegister(order); @@ -549,6 +549,9 @@ tjSamplingMapper.updateUserIdByTjNumAndJxbz(order.getTjNumber(),sysUser.getNickName(), String.valueOf(sysUser.getUserId()),jxbz); }else { tjSamplingMapper.updateUserIdByTjNum(order.getTjNumber(),sysUser.getNickName(), String.valueOf(sysUser.getUserId())); } } catch (Exception e) { log.error(e.getMessage()); } } @@ -870,6 +873,7 @@ } public void addCaiYangDengJiByDiaoYongShiTu(List<TjOrderDetail> detailList, boolean detailList1, TjOrder order, SysUser sysUser,String jxbz) { try { String lis_tmh_prefix = sysConfigService.selectConfigByKey("make_lis_tmh_prefix"); if (null != detailList && detailList1) { Date date = new Date(); @@ -950,6 +954,9 @@ }else { tjSamplingMapper.updateUserIdByTjNum(order.getTjNumber(),sysUser.getNickName(), String.valueOf(sysUser.getUserId())); } } catch (Exception e) { log.error(e.getMessage()); } } private static List<String> mapJinchuan=null; ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysConfigController.java
@@ -1,7 +1,8 @@ package com.ltkj.web.controller.system; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; @@ -9,13 +10,10 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.extra.pinyin.PinyinUtil; import cn.hutool.json.JSONUtil; import com.ltkj.common.core.domain.entity.SysMenu; import com.ltkj.hosp.idutil.IdUtils; import com.ltkj.common.utils.SecurityUtils; import com.ltkj.framework.datasource.DynamicDataSourceContextHolder; import com.ltkj.hosp.domain.DictHosp; import com.ltkj.hosp.domain.TjJcycxm; import com.ltkj.hosp.domain.TjOrder; import com.ltkj.hosp.domain.TjProject; import com.ltkj.hosp.domain.*; import com.ltkj.hosp.mapper.TestMapper; import com.ltkj.hosp.service.*; import com.ltkj.hosp.sqlDomain.*; @@ -25,8 +23,6 @@ import io.swagger.annotations.ApiParam; import jodd.util.StringUtil; import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.annotations.Case; import org.apache.ibatis.jdbc.Null; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; @@ -78,6 +74,8 @@ private TestMapper testMapper; @Autowired private AwsService awsService; @Autowired private IdUtils idUtils; /** * 获取参数配置列表 @@ -414,4 +412,30 @@ } } @GetMapping ("/ceshitijianhao")//同步his项目单价信息 // @PreAuthorize("@ss.hasPermi('system:config:tbhisproprice')") @ApiOperation (value = "测试体检号") public AjaxResult ceshitijianhao() { //创建线程池 ExecutorService threadPool = Executors.newFixedThreadPool(2000); List<String> numbers = new ArrayList<>(); for (int i = 0; i < 2000; i++) { //获取线程 threadPool.execute(new Runnable() { @Override public void run() { try { String number = idUtils.getNewTjNumberRedisLock(); // 调用获取编号的方法 numbers.add(number); // 添加到 Set } catch (Exception e) { e.printStackTrace(); } } }); } threadPool.shutdown(); return AjaxResult.success(numbers); } } ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjOrderController.java
@@ -2,31 +2,24 @@ import java.io.*; import java.math.BigDecimal; import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.OffsetTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.List; import java.util.concurrent.*; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import cn.hutool.core.codec.Base64; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.symmetric.DES; import cn.hutool.extra.pinyin.PinyinUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; @@ -34,10 +27,7 @@ import com.alibaba.fastjson2.JSON; 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.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.databind.BeanProperty; import com.itextpdf.text.Document; import com.itextpdf.text.DocumentException; import com.ltkj.common.annotation.RepeatSubmit; @@ -54,12 +44,10 @@ import com.ltkj.hosp.dto.QianDaoDto; import com.ltkj.hosp.dto.TjProBlDto; import com.ltkj.hosp.dto.UpdateTransitionnewPriceDto; import com.ltkj.hosp.hisDto.OutpinimpapplyDto; import com.ltkj.hosp.hisDto.OutpinmedicapplyDto; import com.ltkj.hosp.mapper.TbTransitionMapper; 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; import com.ltkj.hosp.sqlDomain.LtkjMiddleHead; @@ -76,24 +64,19 @@ import com.ltkj.mall.service.IMallOrderService; import com.ltkj.system.domain.TjDjdDyjl; import com.ltkj.system.service.*; import com.ltkj.hosp.idutil.IdUtils; 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 com.ltkj.web.wxUtils.HttpClientUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import jodd.util.StringUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.time.DateFormatUtils; import org.aspectj.weaver.ast.Var; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.http.HttpRequest; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -1107,11 +1090,37 @@ //生成体检号 // String tjNumber = (SecurityUtils.getUsername() + new SimpleDateFormat("yyMMddHHmmss").format(new Date())); // if(StringUtil.isNotBlank(makeLisTmhPrefix)) tjNumber=makeLisTmhPrefix+tjNumber; // String tjNumber = (SecurityUtils.getUsername() + idUtils.getTjNumber()); String tjNumber = idUtils.getTjNumber(); if (StringUtil.isNotBlank(makeLisTmhPrefix)) tjNumber = makeLisTmhPrefix + tjNumber; // String tjNumber = idUtils.getTjNumber(); 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()); }finally { a++; } } tjOrder.setTjNumber(tjNumber); @@ -1461,6 +1470,7 @@ } public void addCaiYangDengJi(List<TjOrderDetail> detailList, boolean detailList1, TjOrder order, SysUser sysUser, String jxbz) { try { String lis_tmh_prefix = configService.selectConfigByKey("make_lis_tmh_prefix"); String config = configService.selectConfigByKey("sfkqdyhis"); Boolean lisAndPacsRegister = lisApiMethod.isUseLisAndPacsRegister(order); @@ -1544,6 +1554,9 @@ tjSamplingMapper.updateUserIdByTjNumAndJxbz(order.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId()), jxbz); } else { tjSamplingMapper.updateUserIdByTjNum(order.getTjNumber(), sysUser.getNickName(), String.valueOf(sysUser.getUserId())); } } catch (Exception e) { log.error(e.getMessage()); } } @@ -1913,7 +1926,8 @@ //获取拼接前缀 String makeLisTmhPrefix = configService.selectConfigByKey("make_lis_tmh_prefix"); // String tjNumber = (sysUser.getUserName() + idUtils.getTjNumber()); String tjNumber = idUtils.getTjNumber(); // String tjNumber = idUtils.getTjNumber(); String tjNumber = idUtils.getNewTjNumberRedisLockAndMysql(); if (StringUtil.isNotBlank(makeLisTmhPrefix)) tjNumber = makeLisTmhPrefix + tjNumber; ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjSamplingController.java
@@ -4,20 +4,13 @@ import java.util.*; import java.util.stream.Collectors; import javax.annotation.Resource; import javax.servlet.ServletSecurityElement; import javax.servlet.http.HttpServletResponse; import javax.swing.plaf.basic.BasicScrollPaneUI; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.pinyin.PinyinUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; 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.common.utils.IdUtils; import com.ltkj.framework.config.MatchUtils; import com.ltkj.hosp.domain.*; import com.ltkj.hosp.service.*; @@ -28,12 +21,8 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.aspectj.weaver.AjAttribute; import org.springframework.beans.BeanUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.*; import com.ltkj.common.annotation.Log; import com.ltkj.common.core.controller.BaseController; ltkj-common/src/main/java/com/ltkj/common/utils/IdUtils.java
File was deleted ltkj-framework/src/main/java/com/ltkj/framework/config/SecurityConfig.java
@@ -110,7 +110,8 @@ // 对于登录login 注册register 验证码captchaImage 允许匿名访问 .antMatchers("/login", "/register", "/captchaImage","/cus/**","/getCaptchaConfigKey","/report/jmreport/**", "/sqlserver/getdata/**","/api/His/**","/system/config/zx","/system/config/gxxmpym","/system/report/savePdf", "/system/dyjl/saveGjddyjl","/system/dyjl/saveBlGjddyjl","/check/ceshi","/check/pacs","/check/ceshicc","/system/report/xiugaidayinzhuangtai").permitAll() "/system/dyjl/saveGjddyjl","/system/dyjl/saveBlGjddyjl","/check/ceshi","/check/pacs","/check/ceshicc" ,"/system/report/xiugaidayinzhuangtai","/system/config/ceshitijianhao").permitAll() .antMatchers("/common/uploadImgExe","/common/listExeVal","/pacs/InvokeRisService/**").permitAll() .antMatchers("/check/dataSynchronizationApi","/reservation/reservation/linkage").permitAll() // 静态资源,可匿名访问 ltkj-hosp/src/main/java/com/ltkj/hosp/idutil/IdUtils.java
New file @@ -0,0 +1,240 @@ package com.ltkj.hosp.idutil; import cn.hutool.core.util.StrUtil; import com.ltkj.hosp.mapper.OrderNumberMapper; import lombok.extern.slf4j.Slf4j; import org.redisson.api.RLock; import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.core.StringRedisTemplate; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Random; import java.util.UUID; import java.util.concurrent.TimeUnit; /** * @Company: 西安路泰科技有限公司 * @Author: zhaowenxuan * @Date: 2024/10/10 14:55 */ @Configuration @Slf4j public class IdUtils { private static final String LIS_LAST_ID_KEY = "id:generate:lis:id"; private static final String TJH_LAST_ID_KEY = "id:generate:tjhs:tjh"; private static final String LIS_LAST_ID_INCR_KEY = "id:generate:lis:id:incr"; private static final String LIS_CURRENT_DATE_KEY = "id:generate:lis:currentDate"; @Autowired private StringRedisTemplate stringRedisTemplate; @Autowired private OrderNumberMapper orderNumberMapper; @Autowired private RedissonClient redissonClient; public synchronized String yuangenerateLisID(String prefix) { String currentDate = new SimpleDateFormat("yyyyMMdd").format(new Date()); String storedDate = stringRedisTemplate.opsForValue().get(LIS_CURRENT_DATE_KEY); String lastIdStr = stringRedisTemplate.opsForValue().get(LIS_LAST_ID_KEY); int lastId; if (storedDate == null || !storedDate.equals(currentDate)) { lastId = 1; stringRedisTemplate.opsForValue().set(LIS_LAST_ID_KEY, String.valueOf(lastId)); stringRedisTemplate.opsForValue().set(LIS_CURRENT_DATE_KEY, currentDate); } else { lastId = Integer.parseInt(lastIdStr) + 1; stringRedisTemplate.opsForValue().set(LIS_LAST_ID_KEY, String.valueOf(lastId)); } String yyMMdd = currentDate.substring(2); return String.format(prefix+"%s%05d", yyMMdd, lastId); } //redis分布式锁和MySQL公用 public String generateLisID(String prefix) { String lockKey = "lock:tmh:tj_tmh_lock"; RLock lock = redissonClient.getLock(lockKey); try { if (lock.tryLock(3, 5, TimeUnit.SECONDS)) { String currentDate = new SimpleDateFormat("yyyyMMdd").format(new Date()); String storedDate = stringRedisTemplate.opsForValue().get(LIS_CURRENT_DATE_KEY); String lastIdStr = stringRedisTemplate.opsForValue().get(LIS_LAST_ID_KEY); // 2. 如果 Redis 中没有或者编号丢失,查询数据库并同步到 Redis if (storedDate == null || !storedDate.equals(currentDate) || lastIdStr == null) { Integer lastIdFromDb = orderNumberMapper.getLastId(currentDate,lockKey); lastIdFromDb = (lastIdFromDb == null) ? 0 : lastIdFromDb; // 同步到 Redis stringRedisTemplate.opsForValue().set(LIS_LAST_ID_KEY, String.valueOf(lastIdFromDb), 1, TimeUnit.DAYS); stringRedisTemplate.opsForValue().set(LIS_CURRENT_DATE_KEY, currentDate, 1, TimeUnit.DAYS); } // 3. 使用 Redis 的 INCR 保证流水号唯一 long lastId = stringRedisTemplate.opsForValue().increment(LIS_LAST_ID_KEY); // 4. 同时更新数据库,确保一致性 orderNumberMapper.updateLastId(currentDate, (int) lastId,lockKey); return String.format(prefix+"%s%05d", currentDate.substring(2), lastId); } else { throw new RuntimeException("获取条码号失败,请重试"); } } catch (InterruptedException e) { throw new RuntimeException(e); } finally { if (lock.isHeldByCurrentThread()) { lock.unlock(); } } } /** * 生成无限递增条码号 * @param prefix * @return */ public synchronized String generateLisNextId(String prefix){ String lastIdStr = stringRedisTemplate.opsForValue().get(LIS_LAST_ID_INCR_KEY); int current; if (StrUtil.isBlank(lastIdStr)) { current = 1; }else { current = Integer.parseInt(lastIdStr); } int numberLength = String.valueOf(99999).length(); String result = prefix + String.format("%0" + numberLength + "d", current); current++; stringRedisTemplate.opsForValue().set(LIS_LAST_ID_INCR_KEY,String.valueOf(current)); return result; } //生成体检号用 private static long lastTimestamp = -1; private static final Random random = new Random(); // public static synchronized String getTjNumber() { // long timestamp = System.currentTimeMillis(); // 获取当前时间戳(毫秒) // // // 如果时间戳和上次生成的时间戳相同,生成一个新的随机数 // if (timestamp == lastTimestamp) { // return String.format("%09d", (timestamp % 1000000000) + random.nextInt(900) + 100); // } else { // lastTimestamp = timestamp; // 更新最后生成时间戳 // return String.format("%09d", (timestamp % 1000000000) + random.nextInt(900) + 100); // } // } public synchronized String getTjNumber() { String currentDate = new SimpleDateFormat("yyyyMMdd").format(new Date()); String storedDate = stringRedisTemplate.opsForValue().get(LIS_CURRENT_DATE_KEY); String lastIdStr = stringRedisTemplate.opsForValue().get(TJH_LAST_ID_KEY); if (StrUtil.isBlank(lastIdStr))lastIdStr = "0"; int lastId; if (storedDate == null || !storedDate.equals(currentDate)) { lastId = 1; stringRedisTemplate.opsForValue().set(TJH_LAST_ID_KEY, String.valueOf(lastId)); stringRedisTemplate.opsForValue().set(LIS_CURRENT_DATE_KEY, currentDate); } else { lastId = Integer.parseInt(lastIdStr) + 1; stringRedisTemplate.opsForValue().set(TJH_LAST_ID_KEY, String.valueOf(lastId)); } String yyMMdd = currentDate.substring(2); return String.format("%s%05d", yyMMdd, lastId); } // 使用分布式ID生成器(如Snowflake) public static String generateExamNumber() { // long id = uidGenerator.getUID(); // 获取生成的唯一ID // return String.format("%09d", Math.abs(id) % 1000000000); // 格式化为9位 return null; } // redis分布式锁 public String getNewTjNumberRedisLock() { String lockKey = "lock:tjh:tj_number_lock"; String lockValue = UUID.randomUUID().toString(); Boolean locked = stringRedisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 5, TimeUnit.SECONDS); if (Boolean.TRUE.equals(locked)) { try { String currentDate = new SimpleDateFormat("yyyyMMdd").format(new Date()); String storedDate = stringRedisTemplate.opsForValue().get(LIS_CURRENT_DATE_KEY); if (storedDate == null || !storedDate.equals(currentDate)) { // 日期变更,重置 Redis 计数器 stringRedisTemplate.opsForValue().set(TJH_LAST_ID_KEY, "1", 1, TimeUnit.DAYS); stringRedisTemplate.opsForValue().set(LIS_CURRENT_DATE_KEY, currentDate, 1, TimeUnit.DAYS); return String.format("%s%05d", currentDate.substring(2), 1); } // 使用 Redis INCR 确保唯一性 long lastId = stringRedisTemplate.opsForValue().increment(TJH_LAST_ID_KEY); return String.format("%s%05d", currentDate.substring(2), lastId); } finally { // 释放锁(确保是当前线程持有的锁才删除) String currentLockValue = stringRedisTemplate.opsForValue().get(lockKey); if (lockValue.equals(currentLockValue)) { stringRedisTemplate.delete(lockKey); } } } else { throw new RuntimeException("获取流水号失败,请重试"); } } //redis分布式锁和MySQL公用 public String getNewTjNumberRedisLockAndMysql() { String lockKey = "lock:tjh:tj_number_lock"; RLock lock = redissonClient.getLock(lockKey); try { if (lock.tryLock(5, 10, TimeUnit.SECONDS)) { String currentDate = new SimpleDateFormat("yyyyMMdd").format(new Date()); // 1. 先从 Redis 获取编号 String storedDate = stringRedisTemplate.opsForValue().get(LIS_CURRENT_DATE_KEY); String lastIdStr = stringRedisTemplate.opsForValue().get(TJH_LAST_ID_KEY); // 2. 如果 Redis 中没有或者编号丢失,查询数据库并同步到 Redis if (storedDate == null || !storedDate.equals(currentDate) || lastIdStr == null) { Integer lastIdFromDb = orderNumberMapper.getLastId(currentDate,lockKey); lastIdFromDb = (lastIdFromDb == null) ? 0 : lastIdFromDb; // 同步到 Redis stringRedisTemplate.opsForValue().set(TJH_LAST_ID_KEY, String.valueOf(lastIdFromDb), 1, TimeUnit.DAYS); stringRedisTemplate.opsForValue().set(LIS_CURRENT_DATE_KEY, currentDate, 1, TimeUnit.DAYS); } // 3. 使用 Redis 的 INCR 保证流水号唯一 long lastId = stringRedisTemplate.opsForValue().increment(TJH_LAST_ID_KEY); // 4. 同时更新数据库,确保一致性 orderNumberMapper.updateLastId(currentDate, (int) lastId,lockKey); return String.format("%s%05d", currentDate.substring(2), lastId); } else { throw new RuntimeException("获取体检号失败,请重试"); } } catch (InterruptedException e) { throw new RuntimeException(e); } finally { if (lock.isHeldByCurrentThread()) { lock.unlock(); } } } } ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/OrderNumberMapper.java
New file @@ -0,0 +1,17 @@ package com.ltkj.hosp.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.poi.ss.formula.functions.T; @Mapper public interface OrderNumberMapper extends BaseMapper<T> { @Select("SELECT max(last_id) FROM order_number WHERE date_key = #{dateKey} and fl=#{fl}") Integer getLastId(@Param("dateKey") String dateKey,@Param("fl") String fl); @Insert("INSERT INTO order_number(date_key, last_id,fl) VALUES(#{dateKey}, #{lastId},#{fl}) ON DUPLICATE KEY UPDATE last_id = #{lastId}") void updateLastId(@Param("dateKey") String dateKey, @Param("lastId") int lastId,@Param("fl") String fl); } ltkj-hosp/src/main/java/com/ltkj/hosp/mapper/TjOrderMapper.java
@@ -145,7 +145,7 @@ @Select("SELECT * FROM tj_order WHERE user_id = #{cusId} AND deleted='0' ORDER BY create_time DESC") public List<TjOrder> getOrderListByCusId(@Param("cusId") String cusId); @Select("SELECT * FROM tj_order WHERE tj_number = #{tjNum} AND deleted='0' ") @Select("SELECT * FROM tj_order WHERE tj_number = #{tjNum} AND deleted=0 ") public TjOrder getOrderByTjNum(String tjNum); @Select("SELECT * FROM tj_order WHERE card_id = #{cardId} AND deleted='0' ") @@ -389,4 +389,8 @@ List<List<?>> getYxJcList(Map<String,Object> map); @Select("SELECT count(*) FROM tj_order WHERE tj_number = #{tjNum}") int getOrderCountByTjNum(String tjNum); } ltkj-hosp/src/main/java/com/ltkj/hosp/service/ITjOrderService.java
@@ -163,6 +163,8 @@ List<String> getHuoQuBlZlsqdh(String cardId, String bldh); Boolean delHuoQuZlsqdh(String cardId, String bldh); int getOrderCountByTjNum(String tjNum); Map<String,Object> getgetBghsList(String tjNumber, Integer page, Integer pageSize, String value, String beginTime, String endTime, String name); ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjOrderServiceImpl.java
@@ -358,6 +358,11 @@ } @Override public int getOrderCountByTjNum(String tjNum) { return tjOrderMapper.getOrderCountByTjNum(tjNum); } @Override public Map<String, Object> getgetBghsList(String tjNumber, Integer page, Integer pageSize, String compId, String beginTime, String endTime, String tjname) { Map<String, Object> map = new HashMap<>(); ltkj-hosp/src/main/java/com/ltkj/hosp/service/impl/TjSamplingServiceImpl.java
@@ -1,19 +1,14 @@ package com.ltkj.hosp.service.impl; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.utils.DateUtils; import com.ltkj.common.utils.IdUtils; import com.ltkj.hosp.domain.TjCustomer; import com.ltkj.hosp.domain.TjOrder; import com.ltkj.hosp.idutil.IdUtils; import com.ltkj.hosp.service.ITjCustomerService; import com.ltkj.hosp.service.ITjOrderService; import lombok.extern.slf4j.Slf4j; @@ -169,6 +164,7 @@ } private AjaxResult mergeCaiYang(List<String> ids,String prefix) { try { if (null != ids && !ids.isEmpty()) { if(ids.size()==1) return AjaxResult.error("请选择至少两条项目进行合并!"); int i = panduanshifoukeyihebing(ids); @@ -219,6 +215,9 @@ return AjaxResult.error("操作失败!"); } } } catch (Exception e) { log.error(e.getMessage()); } return AjaxResult.error("请选择你要合并的项目!!!"); }