From 94a26e9330cacfef3a3b3c0e40dfdac850675d40 Mon Sep 17 00:00:00 2001 From: zhaowenxuan <chacca165@163.com> Date: 星期六, 12 十月 2024 15:22:02 +0800 Subject: [PATCH] 测试类 --- ltkj-admin/src/test/java/zwxTest.java | 281 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 281 insertions(+), 0 deletions(-) diff --git a/ltkj-admin/src/test/java/zwxTest.java b/ltkj-admin/src/test/java/zwxTest.java new file mode 100644 index 0000000..fb70f7e --- /dev/null +++ b/ltkj-admin/src/test/java/zwxTest.java @@ -0,0 +1,281 @@ +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<TjReportTemplate> 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<DictUserInfo> 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<TbTransition> detailList = tbTransitionService.getTbTransitionListByCusId("610125200008122217","10001241009165139"); + 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); + List<OutpintestapplyDetailsDto> detailsDtos = new ArrayList<>(); + if (projects != null && !projects.isEmpty()){ + LisSaveSqdxxDto lisSaveSqdxxDto = new LisSaveSqdxxDto(); + ArrayList<LisSaveSqdxxJyxmlistDto> 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<LtkjJfzhgljyxmzd> wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(LtkjJfzhgljyxmzd::getZhxmdm, project.getHisXmbm()); + LtkjJfzhgljyxmzd jfzhgljyxmzd = ltkjJfzhgljyxmzdService.getOne(wrapper); + if (jfzhgljyxmzd != null) { + LambdaQueryWrapper<LtkjJyxmzd> 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<LtkjJfxmgljyxmzd> wrapper1 = new LambdaQueryWrapper<>(); + wrapper1.eq(LtkjJfxmgljyxmzd::getXmdm, project.getHisXmbm()); + LtkjJfxmgljyxmzd jfxmgljyxmzd = ltkjJfxmgljyxmzdService.getOne(wrapper1); + if (jfxmgljyxmzd != null) { + LambdaQueryWrapper<LtkjJyxmzd> 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<TbTransition> detailList = tbTransitionService.getTbTransitionListByCusId(cusId,cardId); + TjOrder tjOrder = orderService.getOrderByTjNum(detailList.get(0).getTjNum()); + LambdaQueryWrapper<TjCustomer> 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<String, Object> 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<String> 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) { + + } +} -- Gitblit v1.8.0