import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.RandomUtil; 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.LtkjApplication; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.core.domain.entity.DictUserInfo; import com.ltkj.hosp.domain.*; import com.ltkj.hosp.hisDto.OutpintestapplyDetailsDto; import com.ltkj.hosp.lisDto.LisSaveSqdxxDto; import com.ltkj.hosp.lisDto.LisSaveSqdxxJyxmlistDto; import com.ltkj.hosp.service.*; import com.ltkj.hosp.sqlDomain.LtkjExamJcbgd; import com.ltkj.hosp.sqlDomain.LtkjHybgd; import com.ltkj.hosp.sqlDomain.LtkjHysqd; import com.ltkj.system.service.ISysDeptService; import com.ltkj.web.config.pdfutils.PDFBinaryUtil; import com.ltkj.web.controller.lis.LisApiMethod; import com.ltkj.web.controller.pacs.PacsApiMethodService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.time.DateFormatUtils; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; import java.io.*; import java.math.BigDecimal; import java.nio.file.Files; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; /** * @Company: 西安路泰科技有限公司 * @Author: zhaowenxuan * @Date: 2024/7/1 15:00 */ @RunWith(SpringRunner.class) @SpringBootTest(classes = LtkjApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @Slf4j @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class}) public class zwxTest { @Autowired private ITjReportTemplateService tjReportTemplateService; @Autowired private IDictUserInfoService dictUserInfoService; @Resource private LtkjExamJcbgdService jcbgdService; @Resource private LtkjExamJcsqdService jcsqdService; @Resource private LtkjHybgdService ltkjHybgdService; @Resource private LtkjHysqdService ltkjHysqdService; @Autowired private ITbTransitionService tbTransitionService; @Autowired private ISysDeptService deptService; @Autowired private ITjProjectService projectService; @Autowired private LtkjJfzhgljyxmzdService ltkjJfzhgljyxmzdService; @Autowired private LtkjJfxmgljyxmzdService ltkjJfxmgljyxmzdService; @Autowired private LtkjJyxmzdService jyxmzdService; @Autowired private LisApiMethod lisApiMethod; @Autowired private ITjOrderService orderService; @Autowired private ITjCustomerService customerService; @Autowired private PacsApiMethodService pacsApiMethodService; @Test public void test01(){ // 修改体检模板 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(TjReportTemplate::getReportTemId,1763094589125423105L); TjReportTemplate template = tjReportTemplateService.getOne(queryWrapper); String s = PDFBinaryUtil.getPDFBinary("D:\\Tjreport\\体检模板5 - 去除首.pdf"); template.setTemplate(s); System.out.println(tjReportTemplateService.updateById(template)); //(BLOB) 537.41 KB } @Test public void test02(){ // 修改医师签名 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(DictUserInfo::getId,1762046878778523680L); DictUserInfo dictUserInfo = dictUserInfoService.getOne(queryWrapper); String s = PDFBinaryUtil.getPDFBinary("d:\\Users\\w\\Desktop\\医师签名测试\\蔡丽娴.gif"); dictUserInfo.setQmImg(s); dictUserInfoService.updateById(dictUserInfo); // queryWrapper = new LambdaQueryWrapper<>(); // queryWrapper.eq(DictUserInfo::getId,1814237486088957952L); // dictUserInfo = dictUserInfoService.getOne(queryWrapper); // s = PDFBinaryUtil.getPDFBinary("d:\\Users\\w\\Desktop\\医师签名测试\\曹凌艳.gif"); // dictUserInfo.setQmImg(s); // dictUserInfoService.updateById(dictUserInfo); // queryWrapper = new LambdaQueryWrapper<>(); // queryWrapper.eq(DictUserInfo::getId,1814238293836402688L); // dictUserInfo = dictUserInfoService.getOne(queryWrapper); // s = PDFBinaryUtil.getPDFBinary("d:\\Users\\w\\Desktop\\医师签名测试\\曾志云.gif"); // dictUserInfo.setQmImg(s); // dictUserInfoService.updateById(dictUserInfo); // queryWrapper = new LambdaQueryWrapper<>(); // queryWrapper.eq(DictUserInfo::getId,1814238354339196928L); // dictUserInfo = dictUserInfoService.getOne(queryWrapper); // s = PDFBinaryUtil.getPDFBinary("d:\\Users\\w\\Desktop\\医师签名测试\\陈海红.gif"); // dictUserInfo.setQmImg(s); // dictUserInfoService.updateById(dictUserInfo); } @Test public void test03(){ List detailList = tbTransitionService.getTbTransitionListByCusId("610125200008122217","10001241009165139"); LambdaQueryWrapper wq = new LambdaQueryWrapper<>(); wq.in(TjProject::getProId, detailList.stream().map(TbTransition::getParentProId).collect(Collectors.toList())); wq.in(TjProject::getDeptId,deptService.getJyDeptIds()); List projects = projectService.list(wq); List detailsDtos = new ArrayList<>(); if (projects != null && !projects.isEmpty()){ LisSaveSqdxxDto lisSaveSqdxxDto = new LisSaveSqdxxDto(); ArrayList dtos = new ArrayList<>(); BigDecimal allPrice = new BigDecimal("0"); int xh = 0; for (TjProject project : projects) { if (0 == project.getProParentId() && project.getProPrice().compareTo(BigDecimal.ZERO) != 0) { if (null != project.getHisXmbm()) { allPrice.add(project.getProPrice()); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(LtkjJfzhgljyxmzd::getZhxmdm, project.getHisXmbm()); LtkjJfzhgljyxmzd jfzhgljyxmzd = ltkjJfzhgljyxmzdService.getOne(wrapper); if (jfzhgljyxmzd != null) { LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); wrapper1.eq(LtkjJyxmzd::getJyxmdm,jfzhgljyxmzd.getJyxmdm()); LtkjJyxmzd jyxmzd = jyxmzdService.getOne(wrapper1); System.out.println("jyxmzd.getJybbdm() = " + jyxmzd.getJybbdm()); LisSaveSqdxxJyxmlistDto dto = new LisSaveSqdxxJyxmlistDto(); dto.setXh(String.valueOf(xh++)); dto.setJyxm(jfzhgljyxmzd.getJyxmdm()); dto.setXmmc(jfzhgljyxmzd.getZhxmmc()); 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); }else { LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); wrapper1.eq(LtkjJfxmgljyxmzd::getXmdm, project.getHisXmbm()); LtkjJfxmgljyxmzd jfxmgljyxmzd = ltkjJfxmgljyxmzdService.getOne(wrapper1); if (jfxmgljyxmzd != null) { LambdaQueryWrapper wrapper2 = new LambdaQueryWrapper<>(); wrapper2.eq(LtkjJyxmzd::getJyxmdm,jfxmgljyxmzd.getJyxmdm()); LtkjJyxmzd jyxmzd = jyxmzdService.getOne(wrapper2); System.out.println("jyxmzd.getJybbdm() = " + jyxmzd.getJybbdm()); LisSaveSqdxxJyxmlistDto dto = new LisSaveSqdxxJyxmlistDto(); dto.setXh(String.valueOf(xh++)); dto.setJyxm(jfxmgljyxmzd.getJyxmdm()); dto.setXmmc(jfxmgljyxmzd.getXmmc()); 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); } } } } } } } @Test public void test04(){ String cusId = "610622199805230627"; String cardId = "10001241010163121"; // 检验保存 List detailList = tbTransitionService.getTbTransitionListByCusId(cusId,cardId); TjOrder tjOrder = orderService.getOrderByTjNum(detailList.get(0).getTjNum()); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(TjCustomer::getCusIdcard,cusId); TjCustomer customer = customerService.getOne(wrapper); // lisApiMethod.save(tjOrder,customer,detailList); // 检验作废 // lisApiMethod.cancel("",tjOrder.getCardId(),customer.getCusName()); // 检查保存 pacsApiMethodService.save(tjOrder,customer,detailList); // 检查作废 pacsApiMethodService.updatePacsApply("","",customer.getCusName()); } public static String generateId() { String id; do { // 获取当前时间戳的后几位 long timestamp = System.currentTimeMillis() % 10000000000L; // 随机生成4位数 int randomNum = new Random().nextInt(9000) + 1000; // 生成1000~9999之间的随机数 // 拼接时间戳后6位和随机数4位,得到10位数 id = String.valueOf(timestamp) + randomNum; } while (id.startsWith("2")); return id; } public static void main01(String[] args) { // LtkjExamJcbgd jcbgd = new LtkjExamJcbgd(); // jcbgd.setJcbw("1"); // jcbgd.setBgImg("1"); // jcbgd.setBgNr("1"); // jcbgd.setBgUrl("1"); // jcbgd.setShysdm("1"); // jcbgd.setShysxm("1"); // jcbgd.setSqsj("1"); // jcbgd.setTjh("1"); // Map map = BeanUtil.beanToMap(jcbgd, true, true); // System.out.println("map = " + map); // System.out.println(IdUtil.getSnowflake().nextIdStr()); // String format = DateFormatUtils.format(new Date(), "yyyyMMddHHmmss"); // System.out.println("format = " + format); // String s = String.valueOf(RandomUtil.randomInt(1000, 9999)); // System.out.println("s = " + s); // format+=s; // System.out.println("format = " + format); // System.out.println(format.length()); // String str = "3"; // // List list = Arrays.asList(str.split(",")); // if (list.contains("3")){ // System.out.println("1"); // }else { // System.out.println("0"); // } // String millis = String.valueOf(System.currentTimeMillis()); // System.out.println("millis = " + millis); // System.out.println(RandomUtil.randomString(millis, 3)); // String yyyyMMdd = new SimpleDateFormat("yyyyMMdd").format(new Date()); // String sqdh = "3"+yyyyMMdd.substring(2)+ RandomUtil.randomString(String.valueOf(System.currentTimeMillis()), 3); // System.out.println("sqdh = " + sqdh); String yyyyMMdd = new SimpleDateFormat("yyMMdd").format(new Date()); Random random = new Random(); int firstDigit = random.nextInt(9) + 1; while (firstDigit == 2) { firstDigit = random.nextInt(9) + 1; } int randomLastTwo = random.nextInt(100); String sqdh = String.format("%d%s%02d", firstDigit, yyyyMMdd, randomLastTwo); System.out.println("sqdh = " + sqdh); } public static void main(String[] args) { } }