From 8e3f58c38fd3d552125ada6afdf88e7fc2b380a0 Mon Sep 17 00:00:00 2001 From: Jinquan_Ou <Jinquan@gdut.com> Date: 星期一, 17 四月 2023 12:47:32 +0800 Subject: [PATCH] 888 --- ruoyi-admin/src/test/java/com/ruoyi/insertData.java | 152 +++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 123 insertions(+), 29 deletions(-) diff --git a/ruoyi-admin/src/test/java/com/ruoyi/insertData.java b/ruoyi-admin/src/test/java/com/ruoyi/insertData.java index 4f7d505..2c4e2a3 100644 --- a/ruoyi-admin/src/test/java/com/ruoyi/insertData.java +++ b/ruoyi-admin/src/test/java/com/ruoyi/insertData.java @@ -1,15 +1,13 @@ package com.ruoyi; -import com.ruoyi.domain.ZfDoctor; -import com.ruoyi.domain.ZfEquipment; -import com.ruoyi.domain.ZfEvent; -import com.ruoyi.service.ZfDoctorService; -import com.ruoyi.service.ZfEquipmentService; -import com.ruoyi.service.ZfEventService; +import com.ruoyi.domain.*; +import com.ruoyi.service.*; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -32,23 +30,29 @@ @Autowired private ZfEquipmentService zfEquipmentService; + @Autowired + ZfCollectionService zfCollectionService; + + @Autowired + ZfEconomyService zfEconomyService; + @Test - public void insert(){ + public void insert() { List<String> people = Arrays.asList("寮犱笁锛屽紶寮猴紝寮犲姏", "寮犺悓锛屽紶钂�", "寮犳椇锛屽紶鐐癸紝寮犲彲", "寮犵珷锛屽紶甯�", "寮犵拠锛屽紶涓猴紝寮犲己锛屽紶鍔�"); List<String> address = Arrays.asList("鑺卞洯", "娴锋哗", "鍏洯", "娓镐箰鍦�", "鐢板洯", "鍐滃簞"); ZfEvent zfEvent = null; for (int i = 0; i < 200; i++) { - zfEvent=new ZfEvent(); + zfEvent = new ZfEvent(); int peopleRandom = new Random().nextInt(5);//0-4鐨勯殢鏈烘暟 int addressRandom = new Random().nextInt(6);//0-5鐨勯殢鏈烘暟 - String base="abcdefghijklmnopqrstuvwxyz"; + String base = "abcdefghijklmnopqrstuvwxyz"; int strRandom1 = new Random().nextInt(16);//0-15鐨勯殢鏈烘暟 int strRandom2 = new Random().nextInt(16);//0-15鐨勯殢鏈烘暟 - String title=base.substring(strRandom1,strRandom1+8); - String remark=base.substring(strRandom2,strRandom2+8); + String title = base.substring(strRandom1, strRandom1 + 8); + String remark = base.substring(strRandom2, strRandom2 + 8); zfEvent.setPeople(people.get(peopleRandom)); zfEvent.setAddress(address.get(addressRandom)); @@ -59,9 +63,10 @@ } } + @Test - void insertDoctor(){ - List<String> l1 = Arrays.asList("鐗欑", "绁炵粡绉�","澶栫"); + void insertDoctor() { + List<String> l1 = Arrays.asList("鐗欑", "绁炵粡绉�", "澶栫"); List<String> l2 = Arrays.asList("鐗欑棝", "澶寸棝", "鐨偆鐐�"); List<String> l3 = Arrays.asList("涓�涓湀", "鍗婁釜鏈�", "涓�澶�"); List<String> l4 = Arrays.asList("鐧借姺10g", "涓尰鑽�1", "涓尰鑽�2"); @@ -70,11 +75,11 @@ List<String> l7 = Arrays.asList("寮犱笁", "鏉庡洓", "鐜嬩簲"); List<String> l8 = Arrays.asList("涓撴不鐗欑棝", "涓撴不澶寸棝", "涓撴不鐨偆鐐�"); - ZfDoctor zfDoctor=null; - int count=0; + ZfDoctor zfDoctor = null; + int count = 0; for (int i = 0; i < 200; i++) { - count=count%3; - zfDoctor=new ZfDoctor(); + count = count % 3; + zfDoctor = new ZfDoctor(); zfDoctor.setType(l1.get(count)); zfDoctor.setSymptom(l2.get(count)); zfDoctor.setDuration(l3.get(count)); @@ -90,8 +95,8 @@ } @Test - void insertEquipment(){ - List<String> l1 = Arrays.asList("鐢佃", "鐢靛啺绠�","鐢佃剳"); + void insertEquipment() { + List<String> l1 = Arrays.asList("鐢佃", "鐢靛啺绠�", "鐢佃剳"); List<String> l2 = Arrays.asList("2020-11-11", "2021-11-12", "2022-12-08"); List<String> l3 = Arrays.asList("寮犱笁", "鏉庡洓", "鐜嬩簲"); List<String> l4 = Arrays.asList("澶忔櫘娑叉櫠鐢佃", "瑗块棬瀛愮數鍐扮", "鑻规灉鐢佃剳"); @@ -99,22 +104,111 @@ List<String> l6 = Arrays.asList("4k瓒呴珮娓�", "鍙屽紑闂�", "M2鑺墖"); - ZfEquipment zfEquipment=null; - int count=0; + ZfEquipment zfEquipment = null; + int count = 0; for (int i = 0; i < 200; i++) { - count=count%3; - zfEquipment=new ZfEquipment(); - zfEquipment.setName(l1.get(count)); - zfEquipment.setBuyer(l3.get(count)); - zfEquipment.setContent(l4.get(count)); - zfEquipment.setLocation(l5.get(count)); - zfEquipment.setRemark(l6.get(count)); - zfEquipment.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg"); + count = count % 3; + zfEquipment = new ZfEquipment(); + zfEquipment.setName(l1.get(count)); + zfEquipment.setBuyer(l3.get(count)); + zfEquipment.setContent(l4.get(count)); + zfEquipment.setLocation(l5.get(count)); + zfEquipment.setRemark(l6.get(count)); + zfEquipment.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg"); count++; zfEquipmentService.save(zfEquipment); } } + @Test + void insertCollection() throws ParseException { + List<String> l1 = Arrays.asList("2020-11-11", "2021-11-12", "2022-12-08"); + List<String> l2 = Arrays.asList("閭エ", "鏃ユ湰鍐涘垁", "鐡峰櫒"); + List<String> l3 = Arrays.asList("鍗佷簩鐢熻倴绾康閭エ", "澶╃洰褰辨墦鍒�", "闈掕姳鐡�"); + List<String> l4 = Arrays.asList("璐拱", "鑾疯禒", "鎷嶅崠"); + List<String> l5 = Arrays.asList("寮犱笁", "鏉庡洓", "鐜嬩簲"); + List<String> l6 = Arrays.asList("10000", "16000", "28000"); + List<String> l7 = Arrays.asList("搴婂ご鏌�", "閰掓煖", "瀹㈠巺鐢佃鏌�"); + List<String> l8 = Arrays.asList("鍗佷簩鐢熻倴", "瀹濆垁鏈��", "鍙よ懀鐡峰櫒"); + List<String> l9 = Arrays.asList("1", "2", "3", "4"); + + Random type = new Random(); + Random source = new Random(); + Random own = new Random(); + Random family = new Random(); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + ZfCollection zfCollection = null; + + for (int i = 0; i < 50; i++) { + int typeNum = type.nextInt(3); + int sourceNum = source.nextInt(3); + int ownNum = own.nextInt(3); +// int familyNum = family.nextInt(4); + + zfCollection = new ZfCollection(); + zfCollection.setGetTime(simpleDateFormat.parse(l1.get(typeNum))); + zfCollection.setType(l2.get(typeNum)); + zfCollection.setName(l3.get(typeNum)); + zfCollection.setSource(l4.get(sourceNum)); + zfCollection.setOwner(l5.get(ownNum)); + zfCollection.setPrice(l6.get(typeNum)); + zfCollection.setLocation(l7.get(typeNum)); + zfCollection.setRemark(l8.get(typeNum)); + zfCollection.setFamilyId("4"); + zfCollection.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg"); + + zfCollectionService.save(zfCollection); + } + } + + + @Test + void insertEconomy() throws ParseException { + List<String> l1 = Arrays.asList("2020-11-11", "2021-11-12", "2022-12-08"); + List<String> l2 = Arrays.asList("-8000", "+10000"); + List<String> l3 = Arrays.asList("渚涙ゼ", "瀛樻"); + List<String> l4 = Arrays.asList("寮犱笁", "鏉庡洓"); + List<String> l5 = Arrays.asList("20000", "30000"); + List<Integer> l6 = Arrays.asList(0,1); + List<String> l9 = Arrays.asList("1", "2", "3", "4"); + + Random type = new Random(); + Random source = new Random(); + Random own = new Random(); + Random family = new Random(); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + + + ZfEconomy zfEconomy = null; + + for (int i = 0; i < 400; i++) { + int timeNum = type.nextInt(3); + int typeNum = source.nextInt(2); + int ownNum = own.nextInt(3); + int familyNum = family.nextInt(4); + + zfEconomy = new ZfEconomy(); + zfEconomy.setCreateTime(simpleDateFormat.parse(l1.get(timeNum))); + zfEconomy.setType(l6.get(typeNum)); + zfEconomy.setPrice(l2.get(typeNum)); + zfEconomy.setUseFor(l3.get(typeNum)); + zfEconomy.setUsePeople(l4.get(typeNum)); + zfEconomy.setKind(l6.get(typeNum)); + zfEconomy.setBalance(l5.get(typeNum)); + zfEconomy.setRemark(l3.get(typeNum)); + zfEconomy.setFamilyId(l9.get(familyNum)); + zfEconomy.setUrl("profile/upload/2023/03/19/test7_20230319222030A007.jpg"); + + zfEconomyService.save(zfEconomy); + } + + + } } + + + -- Gitblit v1.9.1