From b734a90de7e2b783aeafeebb93da5efb8bebd023 Mon Sep 17 00:00:00 2001 From: "wei.peng" Date: Thu, 28 Feb 2019 13:49:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=A1=88=E4=BE=8B=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/estsh/i3plus/core/apiservice/mq/TestMQ.java | 50 ++ .../apiservice/serviceimpl/busi/ArraySort.java | 34 ++ .../core/apiservice/serviceimpl/busi/JavaTest.java | 40 ++ .../core/apiservice/serviceimpl/busi/TestBase.java | 80 +++ .../serviceimpl/busi/TestDepartmentService.java | 118 ++++ .../serviceimpl/busi/TestExcelOrderNoRule.java | 96 +++ .../serviceimpl/busi/TestExcelPermission.java | 260 ++++++++ .../serviceimpl/busi/TestExcelSysConfig.java | 207 +++++++ .../core/apiservice/serviceimpl/busi/TestMain.java | 45 ++ .../apiservice/serviceimpl/busi/TestMathOper.java | 59 ++ .../serviceimpl/busi/TestMessageService.java | 110 ++++ .../serviceimpl/busi/TestOrganizeService.java | 118 ++++ .../serviceimpl/busi/TestPositionService.java | 117 ++++ .../serviceimpl/busi/TestSysConfigService.java | 102 ++++ .../serviceimpl/busi/TestSysDictionaryService.java | 99 ++++ .../serviceimpl/busi/TestSysFileService.java | 107 ++++ .../serviceimpl/busi/TestSysMenuService.java | 104 ++++ .../busi/TestTaskTimeExpressionService.java | 104 ++++ .../serviceimpl/busi/TestTaskTimeService.java | 109 ++++ .../serviceimpl/busi/TestToolService.java | 109 ++++ .../serviceimpl/busi/TestToolTypeService.java | 101 ++++ .../core/apiservice/serviceimpl/busi/TestUser.java | 652 +++++++++++++++++++++ .../i3plus/core/apiservice/util/TestExcelUtil.java | 41 ++ .../i3plus/core/apiservice/util/TestMailUtil.java | 29 + .../core/apiservice/util/TestOrderNoMakeUtil.java | 33 ++ 25 files changed, 2924 insertions(+) create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/mq/TestMQ.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/ArraySort.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/JavaTest.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestBase.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestDepartmentService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelOrderNoRule.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelPermission.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelSysConfig.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMain.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMathOper.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMessageService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestOrganizeService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestPositionService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysConfigService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysDictionaryService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysFileService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysMenuService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestTaskTimeExpressionService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestTaskTimeService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestToolService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestToolTypeService.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestUser.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestExcelUtil.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestMailUtil.java create mode 100644 modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestOrderNoMakeUtil.java diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/mq/TestMQ.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/mq/TestMQ.java new file mode 100644 index 0000000..62b9b5c --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/mq/TestMQ.java @@ -0,0 +1,50 @@ +package cn.estsh.i3plus.core.apiservice.mq; + +import cn.estsh.i3plus.core.apiservice.serviceimpl.busi.TestBase; +import cn.estsh.i3plus.core.apiservice.util.MailUtil; +import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil; +import cn.estsh.i3plus.pojo.platform.bean.SysMessage; +import org.junit.Test; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @Description : + * @Reference : + * @Author : yunhao + * @CreateDate : 2018-11-15 13:22 + * @Modify: + **/ +public class TestMQ extends TestBase { + + /** + * rabbitMQ队列 + */ + @Autowired + private RabbitTemplate rabbitTemplate; + + @Autowired + private MailUtil mailUtil; + + @Test + public void sendMail() throws InterruptedException { + + SysMessage sysMessage = new SysMessage(); + sysMessage.setMessageTitle("test-系统通知"); + sysMessage.setMessageSenderNameRdd("system"); + sysMessage.setMessageSenderId(-1L); + sysMessage.setMessageType(ImppEnumUtil.MESSAGE_TYPE.MAIL.getValue()); + sysMessage.setMessageSendTime("2018-11-01 16:58:00"); + + for (int i = 0; i < 50; i++) { + sysMessage = new SysMessage(); + sysMessage.setId(null); + sysMessage.setMessageTitle( i + "mail测试"); + sysMessage.setMessageSenderNameRdd(i+""); + rabbitTemplate.convertAndSend("WYH_MESSAGE_QUEUE", new SysMessage()); + System.out.println("第" + i + "次"); + } + + } + +} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/ArraySort.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/ArraySort.java new file mode 100644 index 0000000..5d501bb --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/ArraySort.java @@ -0,0 +1,34 @@ +package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; + +/** + * @Description : + * @Reference : + * @Author : alwaysfrin + * @CreateDate : 2018-11-09 10:00 + * @Modify: + **/ +public class ArraySort implements Runnable { + + private String num; + + public ArraySort(int num){ + this.num = num + ""; + } + + public static void main(String[] args){ + int[] num = {11,3,9,5,1,4,15}; + for(int i=0;i " + i); + fileWriter("E:\\test\\test.txt", "Hello World !~ -> " + i); + } + } + +// public static void fileWriter(String fileName, String txt) throws Exception { +// PrintStream fileStream = new PrintStream(new File(fileName)); +// fileStream.println(txt); +// } + + + public static void fileWriter(String fileName, String content) { + try { + // 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件    + FileWriter writer = new FileWriter(fileName, true); + writer.write(content+"\r\n"); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestBase.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestBase.java new file mode 100644 index 0000000..d806e8f --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestBase.java @@ -0,0 +1,80 @@ +package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; + +import cn.estsh.i3plus.core.apiservice.auth.realm.UserAuthRealm; +import cn.estsh.i3plus.pojo.base.shirotoken.UserToken; +import cn.estsh.i3plus.pojo.platform.bean.SessionUser; +import cn.estsh.impp.framework.boot.auth.AuthUtil; +import cn.estsh.impp.framework.boot.util.SpringContextsUtil; +import cn.estsh.impp.framework.run.ImppGo; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.mgt.DefaultSecurityManager; +import org.apache.shiro.session.mgt.DefaultSessionContext; +import org.apache.shiro.session.mgt.SessionContext; +import org.junit.After; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * @Description : + * @Reference : + * @Author : Adair Peng + * @CreateDate : 2018-12-13 10:00 + * @Modify: + **/ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ImppGo.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +public class TestBase { + + public static final String JSON_SESSION_USER = "{\"languageCode\":\"zh\",\"user\":{\"ascOrDesc\":1,\"id\":400001,\"isValid\":1,\"menuList\":[],\"orderByParam\":\"\",\"roleList\":[],\"userEmail\":\"wei.peng@estsh.com\",\"userInfoId\":300001,\"userLoginLastDateTime\":\"2018-12-13 14:52:09\",\"userLoginName\":\"admin\",\"userLoginNum\":170,\"userLoginPassword\":\"e10adc3949ba59abbe56e057f20f883e\",\"userName\":\"系统管理员\",\"userPhone\":\"18507256660\",\"userStatus\":1,\"userType\":1},\"userCode\":\"100001\",\"userId\":300001,\"userInfo\":{\"ascOrDesc\":1,\"department\":{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:52:38\",\"createUser\":\"系统管理员\",\"departmentCode\":\"10001\",\"id\":1072036353472073728,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:52:38\",\"modifyUser\":\"系统管理员\",\"name\":\"闵行一部\",\"orderByParam\":\"\",\"organizeId\":1072033924571598848,\"organizeNameRdd\":\"闵行车轮工厂\",\"parentId\":-1,\"parentNameRdd\":\"顶级部门\"},\"departmentId\":1072036353472073728,\"departmentList\":[{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:52:38\",\"createUser\":\"系统管理员\",\"departmentCode\":\"10001\",\"id\":1072036353472073728,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:52:38\",\"modifyUser\":\"系统管理员\",\"name\":\"闵行一部\",\"orderByParam\":\"\",\"organizeId\":1072033924571598848,\"organizeNameRdd\":\"闵行车轮工厂\",\"parentId\":-1,\"parentNameRdd\":\"顶级部门\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:52:52\",\"createUser\":\"系统管理员\",\"departmentCode\":\"10002\",\"id\":1072036412234272768,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:52:52\",\"modifyUser\":\"系统管理员\",\"name\":\"闵行二部\",\"orderByParam\":\"\",\"organizeId\":1072033995035906048,\"organizeNameRdd\":\"闵行车门工厂\",\"parentId\":-1,\"parentNameRdd\":\"顶级部门\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:53:07\",\"createUser\":\"系统管理员\",\"departmentCode\":\"10003\",\"id\":1072036474448384000,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:53:07\",\"modifyUser\":\"系统管理员\",\"name\":\"浦东一部\",\"orderByParam\":\"\",\"organizeId\":1072034176548605952,\"organizeNameRdd\":\"浦东车窗工厂\",\"parentId\":-1,\"parentNameRdd\":\"顶级部门\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:53:26\",\"createUser\":\"系统管理员\",\"departmentCode\":\"10004\",\"id\":1072036552160448512,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:53:26\",\"modifyUser\":\"系统管理员\",\"name\":\"浦东二部\",\"orderByParam\":\"\",\"organizeId\":1072034276020719616,\"organizeNameRdd\":\"浦东发动机工厂\",\"parentId\":-1,\"parentNameRdd\":\"顶级部门\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:54:42\",\"createUser\":\"系统管理员\",\"departmentCode\":\"10005\",\"id\":1072036873070841856,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:54:52\",\"modifyUser\":\"系统管理员\",\"name\":\"浙江AD部\",\"orderByParam\":\"\",\"organizeId\":1072034411442212864,\"organizeNameRdd\":\"浙江AD钙工厂\",\"parentId\":-1,\"parentNameRdd\":\"顶级部门\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:55:05\",\"createUser\":\"系统管理员\",\"departmentCode\":\"10006\",\"id\":1072036970013790208,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:55:05\",\"modifyUser\":\"系统管理员\",\"name\":\"江苏一部\",\"orderByParam\":\"\",\"organizeId\":1072034525309177856,\"organizeNameRdd\":\"江苏爽歪歪工厂\",\"parentId\":-1,\"parentNameRdd\":\"顶级部门\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:55:48\",\"createUser\":\"系统管理员\",\"departmentCode\":\"10007\",\"id\":1072037153732694016,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:55:48\",\"modifyUser\":\"系统管理员\",\"name\":\"闵行一部一组\",\"orderByParam\":\"\",\"organizeId\":1072033924571598848,\"organizeNameRdd\":\"闵行车轮工厂\",\"parentId\":1072036353472073728,\"parentNameRdd\":\"闵行一部\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:56:08\",\"createUser\":\"系统管理员\",\"departmentCode\":\"10008\",\"id\":1072037232132624384,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:56:08\",\"modifyUser\":\"系统管理员\",\"name\":\"闵行二部一组\",\"orderByParam\":\"\",\"organizeId\":1072033995035906048,\"organizeNameRdd\":\"闵行车门工厂\",\"parentId\":1072036412234272768,\"parentNameRdd\":\"闵行二部\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 20:43:11\",\"createUser\":\"系统管理员\",\"departmentCode\":\"10010\",\"id\":1072109473407045632,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 20:43:11\",\"modifyUser\":\"系统管理员\",\"name\":\"东尚总部\",\"orderByParam\":\"\",\"organizeId\":1072028266539388928,\"organizeNameRdd\":\"东尚集团\",\"parentId\":-1,\"parentNameRdd\":\"顶级部门\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 20:43:37\",\"createUser\":\"系统管理员\",\"departmentCode\":\"20010\",\"id\":1072109580340826112,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 20:43:37\",\"modifyUser\":\"系统管理员\",\"name\":\"娃哈哈总部\",\"orderByParam\":\"\",\"organizeId\":1072033577438416896,\"organizeNameRdd\":\"娃哈哈集团\",\"parentId\":-1,\"parentNameRdd\":\"顶级部门\"}],\"departmentNameRdd\":\"闵行一部\",\"departmentNamesRdd\":\"闵行一部,闵行二部,浦东一部,浦东二部,浙江AD部,江苏一部,闵行一部一组,闵行二部一组,东尚总部,娃哈哈总部\",\"id\":300001,\"isValid\":1,\"modifyDatetime\":\"2018-12-12 16:34:45\",\"modifyUser\":\"系统管理员\",\"name\":\"系统管理员\",\"orderByParam\":\"\",\"organize\":{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:42:59\",\"createUser\":\"系统管理员\",\"id\":1072033924571598848,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:42:59\",\"modifyUser\":\"系统管理员\",\"name\":\"闵行车轮工厂\",\"orderByParam\":\"\",\"organizeCode\":\"10004\",\"organizeType\":3,\"parentId\":1072032375745155072,\"parentNameRdd\":\"闵行公司\"},\"organizeId\":1072033924571598848,\"organizeList\":[{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:42:59\",\"createUser\":\"系统管理员\",\"id\":1072033924571598848,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:42:59\",\"modifyUser\":\"系统管理员\",\"name\":\"闵行车轮工厂\",\"orderByParam\":\"\",\"organizeCode\":\"10004\",\"organizeType\":3,\"parentId\":1072032375745155072,\"parentNameRdd\":\"闵行公司\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:43:16\",\"createUser\":\"系统管理员\",\"id\":1072033995035906048,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:43:16\",\"modifyUser\":\"系统管理员\",\"name\":\"闵行车门工厂\",\"orderByParam\":\"\",\"organizeCode\":\"10005\",\"organizeType\":3,\"parentId\":1072032375745155072,\"parentNameRdd\":\"闵行公司\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:43:59\",\"createUser\":\"系统管理员\",\"id\":1072034176548605952,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:43:59\",\"modifyUser\":\"系统管理员\",\"name\":\"浦东车窗工厂\",\"orderByParam\":\"\",\"organizeCode\":\"10006\",\"organizeType\":3,\"parentId\":1072033520731426816,\"parentNameRdd\":\"浦东公司\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:44:23\",\"createUser\":\"系统管理员\",\"id\":1072034276020719616,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 15:44:23\",\"modifyUser\":\"系统管理员\",\"name\":\"浦东发动机工厂\",\"orderByParam\":\"\",\"organizeCode\":\"10007\",\"organizeType\":3,\"parentId\":1072033520731426816,\"parentNameRdd\":\"浦东公司\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:44:55\",\"createUser\":\"系统管理员\",\"id\":1072034411442212864,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-12 15:47:10\",\"modifyUser\":\"系统管理员\",\"name\":\"浙江AD钙工厂\",\"orderByParam\":\"\",\"organizeCode\":\"20004\",\"organizeSort\":999999999,\"organizeType\":3,\"parentId\":1072033722552946688,\"parentNameRdd\":\"浙江娃哈哈有限公司\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 15:45:22\",\"createUser\":\"系统管理员\",\"id\":1072034525309177856,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-12 15:47:57\",\"modifyUser\":\"系统管理员\",\"name\":\"江苏爽歪歪工厂\",\"orderByParam\":\"\",\"organizeCode\":\"20005\",\"organizeSort\":222222222,\"organizeType\":3,\"parentId\":1072033806300614656,\"parentNameRdd\":\"江苏娃哈哈有限公司\"}],\"organizeNameRdd\":\"闵行车轮工厂\",\"position\":{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 16:07:07\",\"createUser\":\"系统管理员\",\"id\":1072039995872776192,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-12 15:22:50\",\"modifyUser\":\"系统管理员\",\"name\":\"Java开发工程师\",\"orderByParam\":\"\",\"parentId\":1072039995872776192,\"parentNameRdd\":\"Java开发工程师\",\"positionCode\":\"10001\"},\"positionId\":1072039995872776192,\"positionList\":[{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 16:20:17\",\"createUser\":\"系统管理员\",\"id\":1072043310375374848,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 16:20:17\",\"modifyUser\":\"系统管理员\",\"name\":\"运维工程师\",\"orderByParam\":\"\",\"parentId\":-1,\"parentNameRdd\":\"顶级岗位\",\"positionCode\":\"10002\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 16:20:31\",\"createUser\":\"系统管理员\",\"id\":1072043370869821440,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-12 15:22:34\",\"modifyUser\":\"系统管理员\",\"name\":\"Android 开发工程师\",\"orderByParam\":\"\",\"parentId\":-1,\"parentNameRdd\":\"顶级岗位\",\"positionCode\":\"10003\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 16:20:50\",\"createUser\":\"系统管理员\",\"id\":1072043447055159296,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 16:20:50\",\"modifyUser\":\"系统管理员\",\"name\":\"数据库运维\",\"orderByParam\":\"\",\"parentId\":1072043310375374848,\"parentNameRdd\":\"运维工程师\",\"positionCode\":\"10004\"},{\"ascOrDesc\":1,\"createDatetime\":\"2018-12-10 16:21:38\",\"createUser\":\"系统管理员\",\"id\":1072043651225489408,\"isDeleted\":2,\"isValid\":1,\"modifyDatetime\":\"2018-12-10 16:21:38\",\"modifyUser\":\"系统管理员\",\"name\":\"部署工程师\",\"orderByParam\":\"\",\"parentId\":1072043310375374848,\"parentNameRdd\":\"运维工程师\",\"positionCode\":\"10006\"}],\"positionNameRdd\":\"Java开发工程师\",\"positionNamesRdd\":\"运维工程师,Android 开发工程师,数据库运维,部署工程师\",\"user\":{\"$ref\":\"$.user\"},\"userAge\":110,\"userEmpNo\":\"100001\",\"userImageId\":1072104117033373696,\"userInfoStatus\":1,\"userLoginLastDateTime\":\"2018-12-13 14:52:09\",\"userLoginNum\":170},\"userName\":\"系统管理员\",\"userType\":\"普通用户\"}\n"; + + @Before + public void before() { + System.out.println("----------------->> 注入登录用户 <<-----------------"); + SessionContext sessionContext = new DefaultSessionContext(); + sessionContext.setHost("localhost"); + + UserAuthRealm userAuthRealm = (UserAuthRealm) SpringContextsUtil.getBean(UserAuthRealm.class); + org.apache.shiro.mgt.SecurityManager securityManager = new DefaultSecurityManager(userAuthRealm); + SecurityUtils.setSecurityManager(securityManager); + securityManager.start(sessionContext); + + UserToken token = new UserToken("login_name", "login_pwd", "zh"); +// SessionUser sessionUser = AuthUtil.login(token); +// AuthUtil.setSessionUser(sessionUser); + System.out.println("----------------->> 开始测试 <<-----------------"); + } + + @After + public void after() { + System.out.println("----------------->> 测试结束 <<-----------------"); + + } + +} +// +//@Component +//class UserAuthRealm extends AuthorizingRealm { +// +// public UserAuthRealm() { +// //添加支持的token +// this.setAuthenticationTokenClass(UserToken.class); +// } +// +// @Override +// protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { +// return new SimpleAuthorizationInfo(); +// } +// +// @Override +// protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { +// SessionUser user = JSON.parseObject(TestBase.JSON_SESSION_USER, SessionUser.class); +// return new SimpleAuthenticationInfo(user, ((UserToken) authenticationToken).getLoginPwd(), this.getName()); +// } +// +//} +// + diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestDepartmentService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestDepartmentService.java new file mode 100644 index 0000000..c330bce --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestDepartmentService.java @@ -0,0 +1,118 @@ +//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; +// +//import cn.estsh.i3plus.core.api.iservice.busi.IDepartmentService; +//import cn.estsh.i3plus.pojo.base.bean.ListPager; +//import cn.estsh.i3plus.pojo.base.common.Pager; +//import cn.estsh.i3plus.pojo.platform.bean.Department; +//import cn.estsh.i3plus.pojo.platform.bean.Organize; +//import com.alibaba.fastjson.JSON; +//import org.junit.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.test.annotation.Rollback; +// +//import javax.transaction.Transactional; +//import java.util.List; +// +///** +// * @Description : 岗位信息测试 +// * @Reference : +// * @Author : wei.peng +// * @Date : 2018-10-29 19:02 +// * @Modify : +// **/ +//public class TestDepartmentService extends TestBase { +// +// @Autowired +// private IDepartmentService departmentService; +// +// /** +// * 新增数据 +// */ +// @Test +// @Transactional +// public void testInsertDepartment(){ +// for(int i = 0 ; i < 50 ; i++ ){ +// Department obj = new Department(); +// obj.setName("Junit Test " + i); +// obj.setDepartmentCode("DEV_JUNIT " + i); +// obj.setParentId(1057165194242953216L); +// obj.setOrganizeId(1057163974900060160L); +// obj = departmentService.insertDepartment(obj); +// System.out.println(JSON.toJSONString(obj)); +// } +// } +// +// /** +// * 根据Key 数据 +// * @return +// */ +// @Test +// @Transactional +// public void testGetDepartmentById(){ +// Department obj = departmentService.getDepartmentById("1057163974900060160"); +// System.out.println(JSON.toJSONString(obj)); +// } +// +// /** +// * 查询所有数据 +// * +// * @return +// */ +// @Test +// @Transactional +// public void testListDepartment(){ +// List list = departmentService.listDepartment(); +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 根据岗位信息进行查找 +// * @return +// */ +// @Test +// @Transactional +// public void testFindDepartmentByPager(){ +// Organize obj = new Organize(); +// +// Pager pager = new Pager(); +// pager.setPageSize(10); +// pager.setCurrentPage(1); +// +// ListPager list = departmentService.queryDepartment(null, pager); +// +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 修改数据 +// */ +// @Test +// @Transactional +// public void testUpdateDepartment(){ +// Department obj = departmentService.getDepartmentById("1057108586410414080"); +// obj.setName("Junit update Name "); +// departmentService.updateDepartment(obj); +// System.out.println(JSON.toJSONString(obj)); +// } +// +// /** +// * 根据Key 删除数据 +// */ +// @Test +// @Transactional +// public void testDeleteDepartmentById(){ +//// departmentService.deleteOrganizeById(""); +// } +// +// /** +// * 根据id批量删除岗位 +// * @return +// */ +// @Test +// @Transactional +// public void deleteDepartmentByIds(){ +//// departmentService.deleteOrganizeByIds(new String[]{"1057108585445724160","1057108585760296960"}); +// } +// +// +//} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelOrderNoRule.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelOrderNoRule.java new file mode 100644 index 0000000..2d527bf --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelOrderNoRule.java @@ -0,0 +1,96 @@ +package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; + +import cn.estsh.i3plus.pojo.platform.bean.*; +import cn.estsh.i3plus.pojo.platform.repository.*; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * @Description : + * @Reference : + * @Author : yunhao + * @CreateDate : 2018-11-22 11:01 + * @Modify: + **/ +public class TestExcelOrderNoRule extends TestBase { + + public static final Logger LOGGER = LoggerFactory.getLogger(TestExcelOrderNoRule.class); + + // 文件路径 + public static final String PATH_NAME = "init/oder-no-rule.xlsx"; + // 权限Sheet 名称 + public static final String SHEET_ORDER_NO_RULE = "order-no-rule"; + + @Autowired + private SysOrderNoRuleRepository sysOrderNoRuleRDao; + + @Test + public void testInit() throws Exception { + XSSFWorkbook workbook = getWorkbook(PATH_NAME); + if(workbook != null){ + XSSFSheet sheetOrderNoRule = workbook.getSheet(SHEET_ORDER_NO_RULE); + + List ysOrderNoRuleList = getSysOrderNoRule(sheetOrderNoRule); + + LOGGER.info("System Init SysOrderNoRule Size:{}",ysOrderNoRuleList.size()); + + sysOrderNoRuleRDao.saveAll(ysOrderNoRuleList); + } + } + + public List getSysOrderNoRule(XSSFSheet sheet){ + List result = new ArrayList<>(); + if(sheet != null){ + if(sheet.getLastRowNum() >= 1){ + SysOrderNoRule obj = null; + for (int i = 1; i <= sheet.getLastRowNum(); i++) { + try { + Row row = sheet.getRow(i);//获取索引为i的行,以0开始 + if(row.getCell(0).toString().trim().length() > 0){ + obj = new SysOrderNoRule(); + obj.setId(Long.parseLong(row.getCell(0).getStringCellValue())); + obj.setName(row.getCell(1).getStringCellValue()); + obj.setOrderNoRuleCode(row.getCell(2).getStringCellValue()); + obj.setOrderNoRule(row.getCell(3).getStringCellValue()); + obj.setSerialNoSeed(Long.parseLong(row.getCell(4).getStringCellValue())); + obj.setSerialNoIncrement(Long.parseLong(row.getCell(5).getStringCellValue())); + obj.setSerialNoLength(Long.parseLong(row.getCell(6).getStringCellValue())); + obj.setIsCycle(Integer.parseInt(row.getCell(7).getStringCellValue())); + obj.setOrderNoRuleDescription(row.getCell(8).getStringCellValue()); + obj.setOrderNoRuleStatus(1); + obj.setSerialNo(-1L); + obj.setIsValid(1); + + result.add(obj); + } + }catch (Exception e){ + LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i); + } + } + } + } + return result; + } + + public XSSFWorkbook getWorkbook(String pathName){ + try { + InputStream in = TestExcelPermission.class.getClassLoader().getResourceAsStream(pathName); + XSSFWorkbook workbook = new XSSFWorkbook(in); + return workbook; + }catch (Exception e){ + LOGGER.error(" System Init Sys Data Excel Error file path {} error message :{}",pathName,e.getMessage()); + e.getMessage(); + return null; + } + } + +} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelPermission.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelPermission.java new file mode 100644 index 0000000..55718e7 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelPermission.java @@ -0,0 +1,260 @@ +package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; + +import cn.estsh.i3plus.platform.common.tool.EncryptTool; +import cn.estsh.i3plus.pojo.platform.bean.*; +import cn.estsh.i3plus.pojo.platform.repository.*; +import com.alibaba.fastjson.JSON; +import io.swagger.models.auth.In; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jdom2.Document; +import org.jdom2.JDOMException; +import org.jdom2.input.SAXBuilder; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * 系统数据初始化 + */ +public class TestExcelPermission extends TestBase { +//public class TestExcelPermission { + + public static final Logger LOGGER = LoggerFactory.getLogger(TestExcelPermission.class); + + // 文件路径 + public static final String PATH_NAME = "init/permission.xlsx"; + // 权限Sheet 名称 + public static final String SHEET_NAME_MENU = "menu"; + public static final String SHEET_NAME_ROLE = "role"; + public static final String SHEET_NAME_USER_INFO = "user-info"; + public static final String SHEET_NAME_USER = "user"; + + @Autowired + private SysUserRepository sysUserRdao; + + @Autowired + private SysUserInfoRepository userInfoRDao; + + @Autowired + private SysMenuRepository menuRdao; + + @Autowired + private SysRoleRepository roleRDao; + + @Autowired + private SysRefRoleMenuRepository refRoleMenuRDao; + + @Test + public void testInit() throws Exception { + XSSFWorkbook workbook = getWorkbook(PATH_NAME); + if(workbook != null){ + XSSFSheet sheetMenu = workbook.getSheet(SHEET_NAME_MENU); + XSSFSheet sheetRole = workbook.getSheet(SHEET_NAME_ROLE); + XSSFSheet sheetUserInfo = workbook.getSheet(SHEET_NAME_USER_INFO); + XSSFSheet sheetUser = workbook.getSheet(SHEET_NAME_USER); + + List menus = getSysMenu(sheetMenu); + List roles = getSysRole(sheetRole); + List userInfos = getSysUserInfo(sheetUserInfo); + List users = getSysUser(sheetUser); + + List refRoleMenu = getRefRoleMenu(menus, roles); + + LOGGER.info("System Init SysMenu Size:{}",menus.size()); + LOGGER.info("System Init SysRole Size:{}",roles.size()); + LOGGER.info("System Init SysUserInfo Size:{}",userInfos.size()); + LOGGER.info("System Init SysUser Size:{}",users.size()); + LOGGER.info("System Init SysRefRoleMenu Size:{}",refRoleMenu.size()); + + sysUserRdao.saveAll(users); + userInfoRDao.saveAll(userInfos); + menuRdao.saveAll(menus); + roleRDao.saveAll(roles); + refRoleMenuRDao.saveAll(refRoleMenu); + } + } + + public List getRefUserRole(List users,List roles){ + List result = new ArrayList<>(); + if(users != null && roles != null){ + SysRefUserRole ref = null; + for (SysUser user : users) { + for (SysRole role : roles) { + ref = new SysRefUserRole(); + ref.setRoleId(role.getId()); + ref.setRoleNameRdd(role.getName()); + ref.setUserId(user.getId()); + ref.setUserNameRdd(user.getUserName()); + result.add(ref); + } + } + } + return result; + } + + public List getRefRoleMenu(List menus,List roles){ + List result = new ArrayList<>(); + if(menus != null && roles != null){ + SysRefRoleMenu ref = null; + for (SysMenu menu : menus) { + for (SysRole role : roles) { + ref = new SysRefRoleMenu(); + ref.setRoleId(role.getId()); + ref.setRoleNameRdd(role.getName()); + ref.setMenuId(menu.getId()); + ref.setMenuNameRdd(menu.getName()); + ref.setMenuTypeRdd(menu.getMenuType()); + result.add(ref); + } + } + } + return result; + } + + public List getSysUser(XSSFSheet sheet){ + List result = new ArrayList<>(); + if(sheet != null){ + if(sheet.getLastRowNum() >= 1){ + SysUser obj = null; + for (int i = 1; i <= sheet.getLastRowNum(); i++) { + try { + Row row = sheet.getRow(i);//获取索引为i的行,以0开始 + if(row.getCell(0).toString().trim().length() > 0){ + obj = new SysUser(); + String md5 = EncryptTool.hexMD5(row.getCell(2).toString()); + obj.setId(Long.parseLong(row.getCell(0).getStringCellValue())); + obj.setUserLoginName(row.getCell(1).getStringCellValue()); + obj.setUserLoginPassword(md5); + obj.setUserEmail(row.getCell(3).getStringCellValue()); + obj.setUserPhone(row.getCell(4).getStringCellValue()); + obj.setUserInfoId(Long.parseLong(row.getCell(5).getStringCellValue())); + obj.setUserName(row.getCell(6).getStringCellValue()); + obj.setIsValid(1); + obj.setUserStatus(1); + obj.setUserType(1); + obj.setUserLoginNum(0); + + result.add(obj); + } + }catch (Exception e){ + LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i); + } + } + } + } + return result; + } + + public List getSysUserInfo(XSSFSheet sheet){ + List result = new ArrayList<>(); + if(sheet != null){ + if(sheet.getLastRowNum() >= 1){ + SysUserInfo obj = null; + for (int i = 1; i <= sheet.getLastRowNum(); i++) { + try { + Row row = sheet.getRow(i);//获取索引为i的行,以0开始 + if(row.getCell(0).toString().trim().length() > 0){ + obj = new SysUserInfo(); + obj.setId(Long.parseLong(row.getCell(0).getStringCellValue())); + obj.setName(row.getCell(1).getStringCellValue()); + obj.setUserEmpNo(row.getCell(2).getStringCellValue()); + obj.setUserLoginNum(0); + obj.setIsValid(1); + obj.setUserInfoStatus(1); + + result.add(obj); + } + }catch (Exception e){ + LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i); + } + } + } + } + return result; + } + + public List getSysRole(XSSFSheet sheet){ + List result = new ArrayList<>(); + if(sheet != null){ + if(sheet.getLastRowNum() >= 1){ + SysRole role = null; + for (int i = 1; i <= sheet.getLastRowNum(); i++) { + try { + Row row = sheet.getRow(i);//获取索引为i的行,以0开始 + if(row.getCell(0).toString().trim().length() > 0){ + role = new SysRole(); + role.setId(Long.parseLong(row.getCell(0).getStringCellValue())); + role.setName(row.getCell(1).getStringCellValue()); + role.setRoleDescription(row.getCell(2).getStringCellValue()); + role.setRoleStatus(1); + role.setIsValid(1); + + result.add(role); + } + }catch (Exception e){ + LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i); + } + } + } + } + return result; + } + + public List getSysMenu(XSSFSheet sheet){ + List result = new ArrayList<>(); + if(sheet != null){ + if(sheet.getLastRowNum() >= 1){ + SysMenu menu = null; + for (int i = 1; i <= sheet.getLastRowNum(); i++) { + try { + Row row = sheet.getRow(i);//获取索引为i的行,以0开始 + if(row.getCell(0).toString().trim().length() > 0){ + menu = new SysMenu(); + menu.setId(Long.parseLong(row.getCell(0).getStringCellValue())); + menu.setMenuType(Integer.parseInt(row.getCell(1).getStringCellValue())); + menu.setMenuCode(row.getCell(2).getStringCellValue()); + menu.setName(row.getCell(3).getStringCellValue()); + menu.setParentId(Long.parseLong(row.getCell(4).getStringCellValue())); + menu.setParentNameRdd(row.getCell(5).getStringCellValue()); + menu.setMenuDescription(row.getCell(6).getStringCellValue()); + menu.setMenuStatus(Integer.parseInt(row.getCell(7).getStringCellValue())); + menu.setCreateUser("System Init"); + menu.setMenuUrl(row.getCell(9).getStringCellValue()); + menu.setMenuCss(row.getCell(10).getStringCellValue()); + menu.setMenuIcon(row.getCell(11).getStringCellValue()); + + result.add(menu); + } + }catch (Exception e){ + LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i); + } + } + } + } + return result; + } + + public XSSFWorkbook getWorkbook(String pathName){ + try { + InputStream in = TestExcelPermission.class.getClassLoader().getResourceAsStream(pathName); + XSSFWorkbook workbook = new XSSFWorkbook(in); + return workbook; + }catch (Exception e){ + LOGGER.error(" System Init Sys Data Excel Error file path {} error message :{}",pathName,e.getMessage()); + e.getMessage(); + return null; + } + } + +} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelSysConfig.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelSysConfig.java new file mode 100644 index 0000000..11ccac1 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestExcelSysConfig.java @@ -0,0 +1,207 @@ +package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; + +import cn.estsh.i3plus.pojo.platform.bean.*; +import cn.estsh.i3plus.pojo.platform.repository.SysConfigRepository; +import cn.estsh.i3plus.pojo.platform.repository.SysDictionaryRepository; +import cn.estsh.i3plus.pojo.platform.repository.SysLocaleLanguageRepository; +import cn.estsh.i3plus.pojo.platform.repository.SysLocaleResourceRepository; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * @Description : + * @Reference : + * @Author : yunhao + * @CreateDate : 2018-11-22 11:01 + * @Modify: + **/ +public class TestExcelSysConfig extends cn.estsh.i3plus.core.apiservice.serviceimpl.busi.TestBase { + + public static final Logger LOGGER = LoggerFactory.getLogger(cn.estsh.i3plus.core.apiservice.serviceimpl.busi.TestExcelPermission.class); + + // 文件路径 + public static final String PATH_NAME = "init/sys-config.xlsx"; + // 权限Sheet 名称 + public static final String SHEET_SYS_CONFIG = "sys-config"; + public static final String SHEET_DICTIONARY = "dictionary"; + public static final String SHEET_LANGUAGE = "language"; + public static final String SHEET_RESOURCE = "resource"; + + @Autowired + private SysConfigRepository sysConfigRDao; + @Autowired + private SysDictionaryRepository sysDictionaryRDao; + @Autowired + private SysLocaleLanguageRepository sysLocaleLanguageRDao; + @Autowired + private SysLocaleResourceRepository sysLocaleResourceRDao; + + @Test + public void testInit() throws Exception { + XSSFWorkbook workbook = getWorkbook(PATH_NAME); + if(workbook != null){ + XSSFSheet sheetSysConfig = workbook.getSheet(SHEET_SYS_CONFIG); + XSSFSheet sheetDictionary = workbook.getSheet(SHEET_DICTIONARY); + XSSFSheet sheetLanguage = workbook.getSheet(SHEET_LANGUAGE); + XSSFSheet sheetResource = workbook.getSheet(SHEET_RESOURCE); + + List sysConfigList = getSysConfig(sheetSysConfig); + List sysDictionaryList = getSysDictionary(sheetDictionary); + List sysLocaleLanguageList = getSysLocaleLanguage(sheetLanguage); + List sysLocaleResourceList= getSysLocaleResource(sheetResource); + + LOGGER.info("System Init SysConfig Size:{}",sysConfigList.size()); + LOGGER.info("System Init SysDictionary Size:{}",sysDictionaryList.size()); + LOGGER.info("System Init SysLocaleLanguage Size:{}",sysLocaleLanguageList.size()); + LOGGER.info("System Init SysLocaleResource Size:{}",sysLocaleResourceList.size()); + + sysConfigRDao.saveAll(sysConfigList); + sysDictionaryRDao.saveAll(sysDictionaryList); + sysLocaleLanguageRDao.saveAll(sysLocaleLanguageList); + sysLocaleResourceRDao.saveAll(sysLocaleResourceList); + } + } + + public List getSysConfig(XSSFSheet sheet){ + List result = new ArrayList<>(); + if(sheet != null){ + if(sheet.getLastRowNum() >= 1){ + SysConfig obj = null; + for (int i = 1; i <= sheet.getLastRowNum(); i++) { + try { + Row row = sheet.getRow(i);//获取索引为i的行,以0开始 + if(row.getCell(0).toString().trim().length() > 0){ + obj = new SysConfig(); + obj.setId(Long.parseLong(row.getCell(0).getStringCellValue())); + obj.setName(row.getCell(1).getStringCellValue()); + obj.setConfigType(Integer.valueOf(row.getCell(2).getStringCellValue())); + obj.setConfigCode(row.getCell(3).getStringCellValue()); + obj.setConfigValue(row.getCell(4).getStringCellValue()); + obj.setConfigDescription(row.getCell(5).getStringCellValue()); + obj.setIsValid(1); + + result.add(obj); + } + }catch (Exception e){ + LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i); + } + } + } + } + return result; + } + + public List getSysDictionary(XSSFSheet sheet){ + List result = new ArrayList<>(); + if(sheet != null){ + if(sheet.getLastRowNum() >= 1){ + SysDictionary obj = null; + for (int i = 1; i <= sheet.getLastRowNum(); i++) { + try { + Row row = sheet.getRow(i);//获取索引为i的行,以0开始 + if(row.getCell(0).toString().trim().length() > 0){ + obj = new SysDictionary(); + obj.setId(Long.parseLong(row.getCell(0).getStringCellValue())); + obj.setName(row.getCell(1).getStringCellValue()); + obj.setDictionaryCode(row.getCell(2).getStringCellValue()); + obj.setParentId(Long.valueOf(row.getCell(3).getStringCellValue())); + obj.setParentNameRdd(row.getCell(4).getStringCellValue()); + obj.setParentCodeRdd(row.getCell(5).getStringCellValue()); + obj.setDictionaryValue(row.getCell(6).getStringCellValue()); + obj.setDictionarySort(Integer.valueOf(row.getCell(7).getStringCellValue())); + obj.setDictionaryDescription(row.getCell(8).getStringCellValue()); + obj.setIsValid(1); + + result.add(obj); + } + }catch (Exception e){ + LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i); + } + } + } + } + return result; + } + + public List getSysLocaleLanguage(XSSFSheet sheet){ + List result = new ArrayList<>(); + if(sheet != null){ + if(sheet.getLastRowNum() >= 1){ + SysLocaleLanguage obj = null; + for (int i = 1; i <= sheet.getLastRowNum(); i++) { + try { + Row row = sheet.getRow(i);//获取索引为i的行,以0开始 + if(row.getCell(0).toString().trim().length() > 0){ + obj = new SysLocaleLanguage(); + obj.setId(Long.parseLong(row.getCell(0).getStringCellValue())); + obj.setLanguageName(row.getCell(1).getStringCellValue()); + obj.setLanguageCode(row.getCell(2).getStringCellValue()); + obj.setLanguageSort(Integer.valueOf(row.getCell(3).getStringCellValue())); + obj.setIsDefault(Integer.valueOf(row.getCell(4).getStringCellValue())); + obj.setLanguageStatus(Integer.valueOf(row.getCell(5).getStringCellValue())); + obj.setIsValid(1); + + result.add(obj); + } + }catch (Exception e){ + LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i); + } + } + } + } + return result; + } + + public List getSysLocaleResource(XSSFSheet sheet){ + List result = new ArrayList<>(); + if(sheet != null){ + if(sheet.getLastRowNum() >= 1){ + SysLocaleResource obj = null; + for (int i = 1; i <= sheet.getLastRowNum(); i++) { + try { + Row row = sheet.getRow(i);//获取索引为i的行,以0开始 + if(row.getCell(0).toString().trim().length() > 0){ + obj = new SysLocaleResource(); + obj.setId(Long.parseLong(row.getCell(0).getStringCellValue())); + obj.setResourceType(Integer.valueOf(row.getCell(1).getStringCellValue())); + obj.setLanguageCode(row.getCell(2).getStringCellValue()); + obj.setLanguageNameRdd(row.getCell(3).getStringCellValue()); + obj.setResourceKey(row.getCell(4).getStringCellValue()); + obj.setResourceValue(row.getCell(5).getStringCellValue()); + obj.setIsSystem(Integer.valueOf(row.getCell(6).getStringCellValue())); + obj.setIsValid(1); + + result.add(obj); + } + }catch (Exception e){ + LOGGER.error("Excel Sheet Name :{} Index:{} DataType Error", sheet.getSheetName(), i); + } + } + } + } + return result; + } + + + public XSSFWorkbook getWorkbook(String pathName){ + try { + InputStream in = cn.estsh.i3plus.core.apiservice.serviceimpl.busi.TestExcelPermission.class.getClassLoader().getResourceAsStream(pathName); + XSSFWorkbook workbook = new XSSFWorkbook(in); + return workbook; + }catch (Exception e){ + LOGGER.error(" System Init Sys Data Excel Error file path {} error message :{}",pathName,e.getMessage()); + e.getMessage(); + return null; + } + } + +} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMain.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMain.java new file mode 100644 index 0000000..bb1db82 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMain.java @@ -0,0 +1,45 @@ +package test.cn.estsh.i3plus.core.apiservice.serviceimpl.busi; + +/** + * @Description : + * @Reference : + * @Author : Adair Peng + * @CreateDate : 2019-02-27 1:24 + * @Modify: + **/ +public class TestMain { + static int a ; + int b; + static int c; + + public int setT(){ + a++; + return a; + } + + public int setT2(){ + b++; + return b; + } + + public int setT3(){ + c++; + return c; + } + + public static void main(String[] args) { + TestMain t1 = new TestMain(); + TestMain t2 = new TestMain(); + TestMain t3 = new TestMain(); + + t1.setT(); + System.out.println(t1.setT()); + + t2.setT2(); + System.out.println(t2.setT2()); + + t3.setT3(); + System.out.println(t3.setT3()); + + } +} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMathOper.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMathOper.java new file mode 100644 index 0000000..3770b78 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMathOper.java @@ -0,0 +1,59 @@ +package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; + +import cn.estsh.i3plus.pojo.platform.bean.SysConfig; +import cn.estsh.i3plus.pojo.platform.repository.SysConfigRepository; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @Description : + * @Reference : + * @Author : yunhao + * @CreateDate : 2018-12-20 17:02 + * @Modify: + **/ +public class TestMathOper extends cn.estsh.i3plus.core.apiservice.serviceimpl.busi.TestBase { + + @Test + public void test(){ + System.out.println("Hello World !~"); + } + + @Autowired + private SysConfigRepository sysConfigRDao; + + String propertyName = "configType"; + String groupByName = "configType"; + String[] param = new String[]{"configType"}; + Object[] paramValue = new Object[]{1}; + + + @Test + public void testMax(){ + SysConfig sysConfig = new SysConfig(); + // max + System.out.println(sysConfigRDao.findMaxByProperties(propertyName,groupByName,param,paramValue)); + System.out.println(sysConfigRDao.findMaxByProperty(propertyName,groupByName,param[0],paramValue[0])); + } + + @Test + public void testMin(){ + // min + System.out.println(sysConfigRDao.findMinByProperties(propertyName,groupByName,param,paramValue)); + System.out.println(sysConfigRDao.findMinByProperty(propertyName,groupByName,param[0],paramValue[0])); + } + + @Test + public void testSum(){ + //sum + System.out.println(sysConfigRDao.findSumByProperties(propertyName,groupByName,param,paramValue)); + System.out.println(sysConfigRDao.findSumByProperty(propertyName,groupByName,param[0],paramValue[0])); + } + @Test + public void testAvg(){ + //avg + System.out.println(sysConfigRDao.findAvgByProperties(propertyName,groupByName,param,paramValue)); + System.out.println(sysConfigRDao.findAvgByProperty(propertyName,groupByName,param[0],paramValue[0])); + } + +} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMessageService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMessageService.java new file mode 100644 index 0000000..259a4e6 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestMessageService.java @@ -0,0 +1,110 @@ +//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; +// +//import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService; +//import cn.estsh.i3plus.pojo.base.bean.ListPager; +//import cn.estsh.i3plus.pojo.base.common.Pager; +//import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil; +//import cn.estsh.i3plus.pojo.platform.bean.SysMessage; +//import com.alibaba.fastjson.JSON; +//import org.junit.Test; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.test.annotation.Rollback; +// +//import javax.transaction.Transactional; +//import java.util.List; +// +///** +// * @Description : 测试 消息服务接口 +// * @Reference : +// * @Author : yunhao +// * @Date : 2018-10-31 15:30 +// * @Modify : +// **/ +//public class TestMessageService extends TestBase { +// +// public static final Logger LOGGER = LoggerFactory.getLogger(TestMessageService.class); +// @Autowired +// private ISysMessageService sysMessageService; +// +// /** +// * 测试 查询所有消息 +// */ +// @Test +// @Transactional +// public void testListSysMessage() { +// List list = sysMessageService.listSysMessage(); +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 测试 根据id查询消息 +// */ +// @Test +// @Transactional +// public void testGetSysMessageById() { +// SysMessage sysMessage = sysMessageService.getSysMessageById(1L); +// System.out.println(JSON.toJSONString(sysMessage)); +// } +// +// /** +// * 测试 添加消息 +// */ +// @Test +// @Transactional +// @Rollback(false) +// public void testInsertSysMessage() { +// SysMessage sysMessage = new SysMessage(); +// sysMessage.setMessageTitle("test-系统通知"); +// sysMessage.setMessageSenderNameRdd("system"); +// sysMessage.setMessageSenderId(-1L); +// sysMessage.setMessageType(ImppEnumUtil.MESSAGE_TYPE.MAIL.getValue()); +// sysMessage.setMessageSendTime("2018-11-01 16:58:00"); +// +// for (int i = 0; i < 50; i++) { +// sysMessage.setId(null); +// sysMessage.setMessageTitle("test-系统通知" + i); +// sysMessageService.insertSysMessage(sysMessage); +// } +// System.out.println(JSON.toJSONString(sysMessage)); +// } +// +// /** +// * 测试 修改消息 +// */ +// @Test +// @Transactional +// public void testUpdateSysMessage(){ +// SysMessage sysMessage = sysMessageService.getSysMessageById(1L); +// sysMessage.setMessageTitle("测试修改"); +// +// sysMessageService.updateSysMessage(sysMessage); +// } +// +// /** +// * 测试 根据id删除消息 +// */ +// @Test +// @Transactional +// public void testDeleteSysMessageById(){ +// sysMessageService.deleteSysMessageById(1L); +// } +// +// /** +// * 测试 复杂查询 +// */ +// @Test +// @Transactional +// public void testQuerySysMessageByPager(){ +// SysMessage sysMessage = new SysMessage(); +// +// Pager pager = new Pager(); +// pager.setPageSize(10); +// pager.setCurrentPage(5); +// +// ListPager list = sysMessageService.querySysMessageByPager(sysMessage,pager); +// System.out.println(list); +// } +// +//} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestOrganizeService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestOrganizeService.java new file mode 100644 index 0000000..af77e5d --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestOrganizeService.java @@ -0,0 +1,118 @@ +//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; +// +//import cn.estsh.i3plus.core.api.iservice.busi.IOrganizeService; +//import cn.estsh.i3plus.pojo.base.bean.ListPager; +//import cn.estsh.i3plus.pojo.base.common.Pager; +//import cn.estsh.i3plus.pojo.platform.bean.Organize; +//import cn.estsh.i3plus.pojo.platform.bean.Organize; +//import com.alibaba.fastjson.JSON; +//import org.junit.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.test.annotation.Rollback; +// +//import javax.transaction.Transactional; +//import java.util.List; +// +///** +// * @Description : 岗位信息测试 +// * @Reference : +// * @Author : wei.peng +// * @Date : 2018-10-29 19:02 +// * @Modify : +// **/ +//public class TestOrganizeService extends TestBase { +// +// @Autowired +// private IOrganizeService organizeService; +// +// /** +// * 新增数据 +// */ +// @Test +// @Transactional +// @Rollback(false) +// public void testInsertOrganize(){ +// for(int i = 0 ; i < 50 ; i++ ){ +// Organize obj = new Organize(); +// obj.setName("Junit Test " + i); +// obj.setOrganizeCode("DEV_JUNIT " + i); +// obj.setParentId(-1L); +// obj = organizeService.insertOrganize(obj); +// System.out.println(JSON.toJSONString(obj)); +// } +// } +// +// /** +// * 根据Key 数据 +// * @return +// */ +// @Test +// @Transactional +// public void testGetOrganizeById(){ +// Organize obj = organizeService.getOrganizeById("1057163974900060160"); +// System.out.println(JSON.toJSONString(obj)); +// } +// +// /** +// * 查询所有数据 +// * +// * @return +// */ +// @Test +// @Transactional +// public void testListOrganize(){ +// List list = organizeService.listOrganize(); +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 根据岗位信息进行查找 +// * @return +// */ +// @Test +// @Transactional +// public void testFindOrganizeByPager(){ +// Organize obj = new Organize(); +// +// Pager pager = new Pager(); +// pager.setPageSize(10); +// pager.setCurrentPage(1); +// +// ListPager list = organizeService.queryOrganize(null, pager); +// +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 修改数据 +// */ +// @Test +// @Transactional +// public void testUpdateOrganize(){ +// Organize obj = organizeService.getOrganizeById("1057108586410414080"); +// obj.setName("Junit update Name "); +// organizeService.updateOrganize(obj); +// System.out.println(JSON.toJSONString(obj)); +// } +// +// /** +// * 根据Key 删除数据 +// */ +// @Test +// @Transactional +// public void testDeleteOrganizeById(){ +//// organizeService.deleteOrganizeById(""); +// } +// +// /** +// * 根据id批量删除岗位 +// * @return +// */ +// @Test +// @Transactional +// public void deleteOrganizeByIds(){ +//// organizeService.deleteOrganizeByIds(new String[]{"1057108585445724160","1057108585760296960"}); +// } +// +// +//} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestPositionService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestPositionService.java new file mode 100644 index 0000000..3e53b3b --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestPositionService.java @@ -0,0 +1,117 @@ +//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; +// +//import cn.estsh.i3plus.core.api.iservice.busi.IPositionService; +//import cn.estsh.i3plus.pojo.base.bean.ListPager; +//import cn.estsh.i3plus.pojo.base.common.Pager; +//import cn.estsh.i3plus.pojo.platform.bean.Position; +//import com.alibaba.fastjson.JSON; +//import org.junit.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.core.annotation.Order; +//import org.springframework.test.annotation.Rollback; +// +//import javax.transaction.Transactional; +//import java.util.List; +// +///** +// * @Description : 岗位信息测试 +// * @Reference : +// * @Author : wei.peng +// * @Date : 2018-10-29 19:02 +// * @Modify : +// **/ +//public class TestPositionService extends TestBase { +// +// @Autowired +// private IPositionService positionService; +// +// /** +// * 新增数据 +// */ +// @Test +// @Transactional +// @Rollback(false) +// public void testInsertPosition(){ +// for(int i = 0 ; i < 50 ; i++ ){ +// Position position = new Position(); +// position.setName("Junit Test " + i); +// position.setPositionCode("DEV_JUNIT " + i); +// position = positionService.insertPosition(position); +// System.out.println(JSON.toJSONString(position)); +// } +// } +// +// /** +// * 根据Key 数据 +// * @return +// */ +// @Test +// @Transactional +// public void testGetPositionById(){ +// Position pos = positionService.getPositionById("1057108589715525632"); +// System.out.println(JSON.toJSONString(pos)); +// } +// +// /** +// * 查询所有数据 +// * +// * @return +// */ +// @Test +// @Transactional +// public void testListPosition(){ +// List list = positionService.listPosition(); +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 根据岗位信息进行查找 +// * @return +// */ +// @Test +// @Transactional +// public void testFindPositionByPager(){ +// Position position = new Position(); +// +// Pager pager = new Pager(); +// pager.setPageSize(10); +// pager.setCurrentPage(1); +// +// ListPager list = positionService.findPositionByPager(null, pager); +// +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 修改数据 +// */ +// @Test +// @Transactional +// public void testUpdatePosition(){ +// Position position = positionService.getPositionById("1057108586410414080"); +// position.setName("Junit update Name "); +// positionService.updatePosition(position); +// System.out.println(JSON.toJSONString(position)); +// } +// +// /** +// * 根据Key 删除数据 +// */ +// @Test +// @Transactional +// public void testDeletePositionById(){ +// positionService.deletePositionById("1057108585240203264"); +// } +// +// /** +// * 根据id批量删除岗位 +// * @return +// */ +// @Test +// @Transactional +// public void deletePositionByIds(){ +// positionService.deletePositionByIds(new String[]{"1057108585445724160","1057108585760296960"}); +// } +// +// +//} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysConfigService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysConfigService.java new file mode 100644 index 0000000..1ca0c30 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysConfigService.java @@ -0,0 +1,102 @@ +package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; + +import cn.estsh.i3plus.core.api.iservice.busi.ISysConfigService; +import cn.estsh.i3plus.pojo.base.bean.ListPager; +import cn.estsh.i3plus.pojo.base.common.Pager; +import cn.estsh.i3plus.pojo.platform.bean.SysConfig; +import com.alibaba.fastjson.JSON; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.Rollback; + +import javax.transaction.Transactional; +import java.util.List; + +/** + * @Description : 系统参数服务测试 + * @Reference : + * @Author : yunhao + * @Date : 2018-10-30 10:49 + * @Modify : + **/ +public class TestSysConfigService extends TestBase { + + @Autowired + private ISysConfigService sysConfigService; + + /** + * 测试 查询所有系统参数 + */ + @Test + @Transactional + public void testListSysConfig() { + List list = sysConfigService.ListSysConfig(); + System.out.println(JSON.toJSONString(list)); + } + + /** + * 测试 根据id查询系统参数 + */ + @Test + @Transactional + public void testGetSysConfigById() { + SysConfig sysConfig = sysConfigService.getSysConfigById(1057110061127700480L); + System.out.println(JSON.toJSONString(sysConfig)); + } + + /** + * 测试 添加系统参数 + */ + @Test + @Transactional + @Rollback(false) + public void testInsertSysConfig() { + SysConfig sysConfig = new SysConfig(); + sysConfig.setName("系统名称"); + sysConfig.setConfigCode("sys_name"); + sysConfig.setConfigType(1); + sysConfig.setConfigValue("IMPP"); + sysConfig.setConfigDescription("系统名称"); + + sysConfigService.insertSysConfig(sysConfig); + System.out.println(JSON.toJSONString(sysConfig)); + + } + + /** + * 测试 修改系统参数 + */ + @Test + @Transactional + public void testUpdateSysConfig(){ + SysConfig sysConfig = sysConfigService.getSysConfigById(1057110613261684736L); + sysConfig.setConfigDescription("测试修改"); + + sysConfigService.updateSysConfig(sysConfig); + } + + /** + * 测试 根据id删除系统参数 + */ + @Test + @Transactional + public void testDeleteSysConfigById(){ + sysConfigService.deleteSysConfigById(1057111616417566720L); + } + + /** + * 测试 复制查询 + */ + @Test + @Transactional + public void testQuerySysConfigByPager(){ + SysConfig sysConfig = new SysConfig(); + + Pager pager = new Pager(); + pager.setPageSize(10); + pager.setCurrentPage(1); + + ListPager list = sysConfigService.querySysConfigByPager(sysConfig,pager); + System.out.println(list); + } +} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysDictionaryService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysDictionaryService.java new file mode 100644 index 0000000..8922e68 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysDictionaryService.java @@ -0,0 +1,99 @@ +//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; +// +//import cn.estsh.i3plus.core.api.iservice.busi.ISysDictionaryService; +//import cn.estsh.i3plus.pojo.base.bean.ListPager; +//import cn.estsh.i3plus.pojo.base.common.Pager; +//import cn.estsh.i3plus.pojo.platform.bean.SysDictionary; +//import com.alibaba.fastjson.JSON; +//import org.junit.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.test.annotation.Rollback; +// +//import javax.transaction.Transactional; +//import java.util.List; +// +///** +// * @Description : 测试字典服务接口 +// * @Reference : +// * @Author : yunhao +// * @Date : 2018-10-30 18:52 +// * @Modify : +// **/ +//public class TestSysDictionaryService extends TestBase { +// @Autowired +// private ISysDictionaryService sysDictionaryService; +// +// /** +// * 测试 查询所有字典 +// */ +// @Test +// @Transactional +// public void testListSysDictionary() { +// List list = sysDictionaryService.listSysDictionary(); +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 测试 根据id查询字典 +// */ +// @Test +// @Transactional +// public void testGetSysDictionaryById() { +// SysDictionary sysDictionary = sysDictionaryService.getSysDictionaryById("1057110061127700480"); +// System.out.println(JSON.toJSONString(sysDictionary)); +// } +// +// /** +// * 测试 添加字典 +// */ +// @Test +// @Transactional +// @Rollback(false) +// public void testInsertSysDictionary() { +// SysDictionary sysDictionary = new SysDictionary(); +// sysDictionary.setName("字典测试"); +// sysDictionary.setDictionaryCode("dic_test"); +// sysDictionary.setDictionaryValue("DEV"); +// sysDictionary.setDictionaryDescription("字典测试"); +// +// sysDictionaryService.insertSysDictionary(sysDictionary); +// System.out.println(JSON.toJSONString(sysDictionary)); +// } +// +// /** +// * 测试 修改字典 +// */ +// @Test +// @Transactional +// public void testUpdateSysDictionary(){ +// SysDictionary sysDictionary = sysDictionaryService.getSysDictionaryById("1057110613261684736"); +// sysDictionary.setName("测试修改"); +// +// sysDictionaryService.updateSysDictionary(sysDictionary); +// } +// +// /** +// * 测试 根据id删除字典 +// */ +// @Test +// @Transactional +// public void testDeleteSysDictionaryById(){ +// sysDictionaryService.deleteSysDictionaryById("1057111616417566720"); +// } +// +// /** +// * 测试 复杂查询 +// */ +// @Test +// @Transactional +// public void testQuerySysDictionaryByPager(){ +// SysDictionary sysDictionary = new SysDictionary(); +// +// Pager pager = new Pager(); +// pager.setPageSize(10); +// pager.setCurrentPage(5); +// +// ListPager list = sysDictionaryService.querySysDictionaryByPager(sysDictionary,pager); +// System.out.println(list); +// } +//} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysFileService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysFileService.java new file mode 100644 index 0000000..955f1a5 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysFileService.java @@ -0,0 +1,107 @@ +//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; +// +//import cn.estsh.i3plus.core.api.iservice.busi.ISysFileService; +//import cn.estsh.i3plus.pojo.base.bean.ListPager; +//import cn.estsh.i3plus.pojo.base.common.Pager; +//import cn.estsh.i3plus.pojo.platform.bean.SysFile; +//import com.alibaba.fastjson.JSON; +//import org.junit.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.test.annotation.Rollback; +// +//import javax.transaction.Transactional; +//import java.util.List; +// +///** +// * @Description : 测试 文件资源服务接口 +// * @Reference : +// * @Author : yunhao +// * @Date : 2018-10-31 15:30 +// * @Modify : +// **/ +//public class TestSysFileService extends TestBase { +// +// @Autowired +// public ISysFileService sysFileService; +// +// /** +// * 测试 查询所有文件资源 +// */ +// @Test +// @Transactional +// public void testListSysFile() { +// List list = sysFileService.listSysFile(); +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 测试 根据id查询文件资源 +// */ +// @Test +// @Transactional +// public void testGetSysFileById() { +// SysFile sysFile = sysFileService.getSysFileById(1057110061127700480L); +// System.out.println(JSON.toJSONString(sysFile)); +// } +// +// /** +// * 测试 添加文件资源 +// */ +// @Test +// @Transactional +// @Rollback(false) +// public void testInsertSysFile() { +// SysFile sysFile = new SysFile(); +// sysFile.setName("文件doc"); +// sysFile.setFileTypeId(1058251784058966016L); +// sysFile.setFileTypeName("doc"); +// sysFile.setDownloads(999); +// sysFile.setFileSize(1024); +// sysFile.setCreateUser("中国移动"); +// sysFile.setCreateDatetime("2018-01-01 00:00:00"); +// for (int i = 0; i < 50; i++) { +// sysFile.setId(null); +// sysFile.setName("文件"+ i +".doc"); +// sysFile.setCreateDatetime("2018-01-01 " + (i % 10) + "0:00:00"); +// sysFileService.insertSysFile(sysFile); +// } +// System.out.println(JSON.toJSONString(sysFile)); +// } +// +// /** +// * 测试 修改文件资源 +// */ +// @Test +// @Transactional +// public void testUpdateSysFile(){ +// SysFile sysFile = sysFileService.getSysFileById(1057110613261684736L); +// sysFile.setName("测试修改"); +// +// sysFileService.updateSysFile(sysFile); +// } +// +// /** +// * 测试 根据id删除文件资源 +// */ +// @Test +// @Transactional +// public void testDeleteSysFileById(){ +// sysFileService.deleteSysFileById("1057111616417566720"); +// } +// +// /** +// * 测试 复杂查询 +// */ +// @Test +// @Transactional +// public void testQuerySysFileByPager(){ +// SysFile sysFile = new SysFile(); +// +// Pager pager = new Pager(); +// pager.setPageSize(10); +// pager.setCurrentPage(5); +// +// ListPager list = sysFileService.querySysFileByPager(sysFile,pager); +// System.out.println(list); +// } +//} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysMenuService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysMenuService.java new file mode 100644 index 0000000..ce918a3 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestSysMenuService.java @@ -0,0 +1,104 @@ +//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; +// +//import cn.estsh.i3plus.core.api.iservice.busi.ISysMenuService; +//import cn.estsh.i3plus.pojo.platform.bean.Organize; +//import cn.estsh.i3plus.pojo.platform.bean.SysMenu; +//import com.alibaba.fastjson.JSON; +//import org.junit.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.test.annotation.Rollback; +// +//import javax.transaction.Transactional; +//import java.util.List; +// +///** +// * @Description : +// * @Reference : +// * @Author : wei.peng +// * @Date : 2018-11-01 11:58 +// * @Modify : +// **/ +//public class TestSysMenuService extends TestBase { +// +// @Autowired +// private ISysMenuService sysMenuService; +// +// +// +// +// /** +// * 修改数据 +// */ +// @Test +// public void testUpdateSysMenu() { +// +// } +// +// /** +// * 修改权限状态 +// */ +// @Test +// public void testUpdateSysMenuStatus() { +// +// } +// +// /** +// * 批量修改状态 +// */ +// @Test +// public void testUpdateSysMenuStatusByIds() { +// +// } +// +// /** +// * 根据Key 删除数据 +// */ +// @Test +// public void testDeleteSysMenuById() { +// +// } +// +// /** +// * 新增数据 +// */ +// @Test +// @Transactional +// @Rollback(false) +// public void testInsertSysMenu() { +// for(int i = 0 ; i < 50 ; i++ ){ +// SysMenu obj = new SysMenu(); +// obj.setName("Junit Test " + i); +// obj.setMenuCode("DEV_JUNIT " + i); +// obj.setParentId(-1L); +// obj = sysMenuService.insertSysMenu(obj); +// System.out.println(JSON.toJSONString(obj)); +// } +// } +// +// /** +// * 查询所有数据 +// */ +// @Test +// public void testFindSysMenuAll() { +// List list = sysMenuService.findSysMenuAll(); +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 根据id 数据 +// */ +// @Test +// public void testGetSysMenuById() { +// SysMenu menu = sysMenuService.getSysMenuById("1057844135052054528"); +// System.out.println(JSON.toJSONString(menu)); +// } +// +// /** +// * 复杂查询 +// */ +// @Test +// public void testQuerySysMenu() { +// +// } +// +//} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestTaskTimeExpressionService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestTaskTimeExpressionService.java new file mode 100644 index 0000000..69f5336 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestTaskTimeExpressionService.java @@ -0,0 +1,104 @@ +//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; +// +//import cn.estsh.i3plus.core.api.iservice.busi.ITaskTimeExpressionService; +//import cn.estsh.i3plus.pojo.base.bean.ListPager; +//import cn.estsh.i3plus.pojo.base.common.Pager; +//import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; +//import cn.estsh.i3plus.pojo.platform.bean.TaskTimeExpression; +//import com.alibaba.fastjson.JSON; +//import org.junit.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.test.annotation.Rollback; +// +//import javax.transaction.Transactional; +//import java.util.List; +// +///** +// * @Description : 测试 时间表达式 +// * @Reference : +// * @Author : yunhao +// * @Date : 2018-10-31 15:30 +// * @Modify : +// **/ +//public class TestTaskTimeExpressionService extends TestBase { +// +// @Autowired +// ITaskTimeExpressionService taskTimeExpressionService; +// +// /** +// * 测试 查询所有时间表达式 +// */ +// @Test +// @Transactional +// public void testListTaskTimeExpression() { +// List list = taskTimeExpressionService.listTaskTimeExpression(); +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 测试 根据id查询时间表达式 +// */ +// @Test +// @Transactional +// public void testGetTaskTimeExpressionById() { +// TaskTimeExpression taskTimeExpression = taskTimeExpressionService.getTaskTimeExpressionById("1057110061127700480"); +// System.out.println(JSON.toJSONString(taskTimeExpression)); +// } +// +// /** +// * 测试 添加时间表达式 +// */ +// @Test +// @Transactional +// @Rollback(false) +// public void testInsertTaskTimeExpression() { +// TaskTimeExpression taskTimeExpression = new TaskTimeExpression(); +// taskTimeExpression.setName("表达式"); +// taskTimeExpression.setExpressionContent("0000000"); +// taskTimeExpression.setExpressionDescription("描述"); +// +// for (int i = 0; i < 50; i++) { +// taskTimeExpression.setId(null); +// taskTimeExpression.setName("表达式"+i); +// taskTimeExpressionService.insertTaskTimeExpression(taskTimeExpression); +// } +// System.out.println(JSON.toJSONString(taskTimeExpression)); +// } +// +// /** +// * 测试 修改时间表达式 +// */ +// @Test +// @Transactional +// public void testUpdateTaskTimeExpression(){ +// TaskTimeExpression taskTimeExpression = taskTimeExpressionService.getTaskTimeExpressionById("1057110613261684736"); +// taskTimeExpression.setName("测试修改"); +// +// taskTimeExpressionService.updateTaskTimeExpression(taskTimeExpression); +// } +// +// /** +// * 测试 根据id删除时间表达式 +// */ +// @Test +// @Transactional +// public void testDeleteTaskTimeExpressionById(){ +// taskTimeExpressionService.deleteTaskTimeExpressionById("1057111616417566720"); +// } +// +// /** +// * 测试 复杂查询 +// */ +// @Test +// @Transactional +// public void testQueryTaskTimeExpressionByPager(){ +// TaskTimeExpression taskTimeExpression = new TaskTimeExpression(); +// +// Pager pager = new Pager(); +// pager.setPageSize(10); +// pager.setCurrentPage(5); +// +// ListPager list = taskTimeExpressionService.queryTaskTimeExpressionByPager(taskTimeExpression,pager); +// System.out.println(list); +// } +//} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestTaskTimeService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestTaskTimeService.java new file mode 100644 index 0000000..d9924f0 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestTaskTimeService.java @@ -0,0 +1,109 @@ +//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; +// +//import cn.estsh.i3plus.core.api.iservice.busi.ITaskTimeService; +//import cn.estsh.i3plus.core.api.iservice.busi.ITaskTimeService; +//import cn.estsh.i3plus.pojo.base.bean.ListPager; +//import cn.estsh.i3plus.pojo.base.common.Pager; +//import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; +//import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil; +//import cn.estsh.i3plus.pojo.platform.bean.TaskTime; +//import com.alibaba.fastjson.JSON; +//import org.junit.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.test.annotation.Rollback; +// +//import javax.transaction.Transactional; +//import java.util.List; +// +///** +// * @Description : +// * @Reference : +// * @Author : yunhao +// * @Date : 2018-11-03 00:09 +// * @Modify : +// **/ +//public class TestTaskTimeService extends TestBase { +// +// @Autowired +// ITaskTimeService taskTimeService; +// +// /** +// * 测试 查询所有硬件 +// */ +// @Test +// @Transactional +// public void testListTaskTime() { +// List list = taskTimeService.listTaskTime(); +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 测试 根据id查询硬件 +// */ +// @Test +// @Transactional +// public void testGetTaskTimeById() { +// TaskTime taskTime = taskTimeService.getTaskTimeById("1057110061127700480"); +// System.out.println(JSON.toJSONString(taskTime)); +// } +// +// /** +// * 测试 添加硬件 +// */ +// @Test +// @Transactional +// @Rollback(false) +// public void testInsertTaskTime() { +// TaskTime taskTime = new TaskTime(); +// taskTime.setName("时间表达式"); +// taskTime.setTimeExpressionId(1L); +// taskTime.setTaskStartDateTimeRdd("2018-01-01 00:00:00"); +// taskTime.setTaskEndDateTimeRdd("2018-12-31 00:00:00"); +// taskTime.setTaskTypeId(ImppEnumUtil.TASK_METHOD_TYPE.TYPE_GROUP.getValue()); +// taskTime.setTaskStatus(CommonEnumUtil.DATA_STATUS.ENABLE.getValue()); +// +// for (int i = 0; i < 50; i++) { +// taskTime.setId(null); +// taskTime.setName("时间表达式"+i); +// taskTimeService.insertTaskTime(taskTime,null); +// } +// System.out.println(JSON.toJSONString(taskTime)); +// } +// +// /** +// * 测试 修改硬件 +// */ +// @Test +// @Transactional +// public void testUpdateTaskTime(){ +// TaskTime taskTime = taskTimeService.getTaskTimeById("1057110613261684736"); +// taskTime.setName("测试修改"); +// +// taskTimeService.updateTaskTime(taskTime,null); +// } +// +// /** +// * 测试 根据id删除硬件 +// */ +// @Test +// @Transactional +// public void testDeleteTaskTimeById(){ +// taskTimeService.deleteTaskTimeById("1058406771644829696"); +// } +// +// /** +// * 测试 复杂查询 +// */ +// @Test +// @Transactional +// public void testQueryTaskTimeByPager(){ +// TaskTime taskTime = new TaskTime(); +// +// Pager pager = new Pager(); +// pager.setPageSize(10); +// pager.setCurrentPage(5); +// +// ListPager list = taskTimeService.queryTaskTimeByPager(taskTime,pager); +// System.out.println(list); +// } +//} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestToolService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestToolService.java new file mode 100644 index 0000000..a1a6bfc --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestToolService.java @@ -0,0 +1,109 @@ +//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; +// +//import cn.estsh.i3plus.core.api.iservice.busi.IToolService; +//import cn.estsh.i3plus.pojo.base.bean.ListPager; +//import cn.estsh.i3plus.pojo.base.common.Pager; +//import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; +//import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil; +//import cn.estsh.i3plus.pojo.platform.bean.Tool; +//import com.alibaba.fastjson.JSON; +//import org.apache.commons.lang3.EnumUtils; +//import org.junit.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.test.annotation.Rollback; +// +//import javax.transaction.Transactional; +//import java.util.List; +// +///** +// * @Description : 测试 硬件服务接口 +// * @Reference : +// * @Author : yunhao +// * @Date : 2018-10-31 15:30 +// * @Modify : +// **/ +//public class TestToolService extends TestBase { +// +// @Autowired +// IToolService toolService; +// +// /** +// * 测试 查询所有硬件 +// */ +// @Test +// @Transactional +// public void testListTool() { +// List list = toolService.listTool(); +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 测试 根据id查询硬件 +// */ +// @Test +// @Transactional +// public void testGetToolById() { +// Tool tool = toolService.getToolById("1057110061127700480"); +// System.out.println(JSON.toJSONString(tool)); +// } +// +// /** +// * 测试 添加硬件 +// */ +// @Test +// @Transactional +// @Rollback(false) +// public void testInsertTool() { +// Tool tool = new Tool(); +// tool.setName("扫描枪"); +// tool.setToolTypeId(1057261374348070912L); +// tool.setRedToolTypeName("扫描枪22"); +// tool.setToolConnTypeId(1); +// tool.setToolDataTypeId(1); +// tool.setToolStatusId(CommonEnumUtil.DATA_STATUS.ENABLE.getValue()); +// +// for (int i = 0; i < 50; i++) { +// tool.setId(null); +// tool.setName("扫描枪"+i); +// toolService.insertTool(tool); +// } +// System.out.println(JSON.toJSONString(tool)); +// } +// +// /** +// * 测试 修改硬件 +// */ +// @Test +// @Transactional +// public void testUpdateTool(){ +// Tool tool = toolService.getToolById("1057110613261684736"); +// tool.setName("测试修改"); +// +// toolService.updateTool(tool); +// } +// +// /** +// * 测试 根据id删除硬件 +// */ +// @Test +// @Transactional +// public void testDeleteToolById(){ +// toolService.deleteToolById("1057111616417566720"); +// } +// +// /** +// * 测试 复杂查询 +// */ +// @Test +// @Transactional +// public void testQueryToolByPager(){ +// Tool tool = new Tool(); +// +// Pager pager = new Pager(); +// pager.setPageSize(10); +// pager.setCurrentPage(5); +// +// ListPager list = toolService.queryToolByPager(tool,pager); +// System.out.println(list); +// } +//} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestToolTypeService.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestToolTypeService.java new file mode 100644 index 0000000..8e09a4b --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestToolTypeService.java @@ -0,0 +1,101 @@ +//package cn.estsh.i3plus.core.apiservice.serviceimpl.busi; +// +//import cn.estsh.i3plus.core.api.iservice.busi.IToolTypeService; +//import cn.estsh.i3plus.core.api.iservice.busi.IToolTypeService; +//import cn.estsh.i3plus.pojo.base.bean.ListPager; +//import cn.estsh.i3plus.pojo.base.common.Pager; +//import cn.estsh.i3plus.pojo.platform.bean.ToolType; +//import com.alibaba.fastjson.JSON; +//import org.junit.Test; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.test.annotation.Rollback; +// +//import javax.transaction.Transactional; +//import java.util.List; +// +///** +// * @Description : 测试 硬件类型服务接口 +// * @Reference : +// * @Author : yunhao +// * @Date : 2018-10-30 20:36 +// * @Modify : +// **/ +//public class TestToolTypeService extends TestBase { +// @Autowired +// private IToolTypeService toolTypeService; +// +// /** +// * 测试 查询所有硬件类型 +// */ +// @Test +// @Transactional +// public void testListToolType() { +// List list = toolTypeService.listToolType(); +// System.out.println(JSON.toJSONString(list)); +// } +// +// /** +// * 测试 根据id查询硬件类型 +// */ +// @Test +// @Transactional +// public void testGetToolTypeById() { +// ToolType toolType = toolTypeService.getToolTypeById("1057110061127700480"); +// System.out.println(JSON.toJSONString(toolType)); +// } +// +// /** +// * 测试 添加硬件类型 +// */ +// @Test +// @Transactional +// @Rollback(false) +// public void testInsertToolType() { +// ToolType toolType = new ToolType(); +// toolType.setName("扫描枪"); +// +// for (int i = 0; i < 50; i++) { +// toolType.setId(null); +// toolType.setName("扫描枪"+i); +// toolTypeService.insertToolType(toolType); +// } +// System.out.println(JSON.toJSONString(toolType)); +// } +// +// /** +// * 测试 修改硬件类型 +// */ +// @Test +// @Transactional +// public void testUpdateToolType(){ +// ToolType toolType = toolTypeService.getToolTypeById("1057110613261684736"); +// toolType.setName("测试修改"); +// +// toolTypeService.updateToolType(toolType); +// } +// +// /** +// * 测试 根据id删除硬件类型 +// */ +// @Test +// @Transactional +// public void testDeleteToolTypeById(){ +// toolTypeService.deleteToolTypeById("1057111616417566720"); +// } +// +// /** +// * 测试 复杂查询 +// */ +// @Test +// @Transactional +// public void testQueryToolTypeByPager(){ +// ToolType toolType = new ToolType(); +// +// Pager pager = new Pager(); +// pager.setPageSize(10); +// pager.setCurrentPage(5); +// +// ListPager list = toolTypeService.queryToolTypeByPager(toolType,pager); +// System.out.println(list); +// } +//} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestUser.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestUser.java new file mode 100644 index 0000000..3ddc7af --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/serviceimpl/busi/TestUser.java @@ -0,0 +1,652 @@ +package test.cn.estsh.i3plus.core.apiservice.serviceimpl.busi; + +import cn.estsh.i3plus.core.api.iservice.busi.*; +import cn.estsh.i3plus.core.apiservice.serviceimpl.busi.TestBase; +import cn.estsh.i3plus.core.apiservice.util.FileUtil; +import cn.estsh.i3plus.platform.common.convert.ConvertBean; +import cn.estsh.i3plus.pojo.base.bean.BaseBean; +import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker; +import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; +import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil; +import cn.estsh.i3plus.pojo.model.platform.UserDetailModel; +import cn.estsh.i3plus.pojo.platform.bean.*; +import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack; +import cn.estsh.impp.framework.boot.auth.AuthUtil; +import cn.estsh.impp.framework.boot.util.ValidatorBean; +import com.alibaba.fastjson.JSON; +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.commons.lang3.RandomUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.UUID; + +/** + * @Description : + * @Reference : + * @Author : Adair Peng + * @CreateDate : 2019-02-25 14:39 + * @Modify: + **/ +public class TestUser extends TestBase{ + + SnowflakeIdMaker snowflakeIdMaker = new SnowflakeIdMaker(); + + @Autowired + private ISysPositionService positionService; + + @Autowired + private ISysOrganizeService organizeService; + + @Autowired + private ISysDepartmentService departmentService; + + @Autowired + private ISysMenuService menuService; + + @Autowired + private ISysRoleService roleService; + + String TEXT = "飓风黑兹尔是1954年大西洋飓风季期间造成死亡人数最多、经济损失最惨重的飓风。这场风暴夺走了海地多达1000人的生命,然后又以四级飓风强度从南、北卡罗莱纳州边境附近袭击美国,造成95人丧生。之后黑兹尔转变成温带风暴,但仍然致使81人遇难,其中大部分来自多伦多。由于风暴造成了重大人员伤亡和财产损失,其名称“黑兹尔”因此从大西洋风暴命名名单上退役。黑兹尔摧毁了海地40%的咖啡树和50%的可可作物,对当地经济的影响持续了数年之久。飓风在南、北卡罗莱纳州登陆,冲击点附近的大部分海滨住宅被毁。气旋从北卡罗莱纳州沿大西洋海岸北上,先后影响了弗吉尼亚州、西弗吉尼亚州、马里兰州、特拉华州、新泽西州、宾夕法尼亚州和纽约州,产生的阵风时速有近160公里,造成的经济损失高达3.08亿美元。多伦多市内及周边有许多溪流溢出,导致严重的洪涝灾害。加拿大遭受的损失达到1.35亿加拿大元。由于缺少应对热带气旋的经验,加上风暴强度的保持时间异常之长,多伦多所受影响的严重程度是前所未有的"; + + @Test + public void testSysPosition() throws Exception{ + List dataBase = new ArrayList<>(); + + for (int i = 0; i < 15; i++) { + SysPosition position = new SysPosition(); + position.setName(RandomStringUtils.random(10, TEXT)); + position.setPositionCode(RandomStringUtils.random(10, true, false)); + position.setParentId(CommonEnumUtil.PARENT.DEFAULT.getValue()); + init(position); + dataBase.add(position); + + for (int j = 0; j < 10; j++) { + + SysPosition position2 = new SysPosition(); + position2.setName(RandomStringUtils.random(10, TEXT)); + position2.setPositionCode(RandomStringUtils.random(10, true, false)); + position2.setParentId(position.getId()); + position2.setParentNameRdd(position.getName()); + init(position2); + dataBase.add(position2); + + for (int k = 0; k < 5; k++) { + SysPosition position3 = new SysPosition(); + position3.setName(RandomStringUtils.random(10, TEXT)); + position3.setPositionCode(RandomStringUtils.random(10, true, false)); + position3.setParentId(position2.getId()); + position3.setParentNameRdd(position2.getName()); + init(position3); + dataBase.add(position3); + } + } + } + + System.out.println("打印SQL Start "); + String txt = null; + + for (SysPosition position : dataBase) { + txt = new String("INSERT INTO sys_position (id, create_date, create_user, is_deleted, is_valid, modify_date, modify_user, organize_code, name, parent_id, parent_name_rdd, position_code, position_description) VALUES" + + " ("+position.getId()+", '"+position.getCreateDatetime()+"', '"+position.getCreateUser()+"', "+position.getIsDeleted()+", "+position.getIsValid()+"," + + " '"+position.getModifyDatetime()+"', '"+position.getModifyUser()+"', null, '"+position.getName()+"', "+position.getParentId()+", '"+position.getParentNameRdd()+"', '"+position.getPositionCode()+"', null);"); + fileWriter("E:\\test\\SysPosition.sql",txt); + } + + System.out.println("打印SQL Start End "); + + } + + @Test + public void testOrganize()throws Exception{ + System.out.println(positionService); + List organizeList = new ArrayList<>(); + List departmentList = new ArrayList<>(); + + for (int i = 0; i < 10; i++) { + SysOrganize organize = new SysOrganize(); + organize.setName(RandomStringUtils.random(10, TEXT)); + organize.setOrganizeCode(RandomStringUtils.random(10, true, false)); + organize.setParentId(CommonEnumUtil.PARENT.DEFAULT.getValue()); + organize.setParentNameRdd("顶级组织"); + organize.setOrganizeType(ImppEnumUtil.ORGANIZE_YTPE.TYPE_GROUP.getValue()); + + init(organize); + organizeList.add(organize); + + for (int j = 0; j < 5 ; j++) { + SysDepartment department = new SysDepartment(); + department.setName(RandomStringUtils.random(10, TEXT)); + department.setDepartmentCode(RandomStringUtils.random(10, true, false)); + department.setParentId(CommonEnumUtil.PARENT.DEFAULT.getValue()); + department.setParentNameRdd("顶级部门"); + department.setOrganizeId(organize.getId()); + department.setOrganizeNameRdd(organize.getName()); + department.setOrganizeCode(organize.getOrganizeCode()); + + init(department); + departmentList.add(department); + + for (int k = 0; k < 5; k++) { + SysDepartment department1 = new SysDepartment(); + department1.setName(RandomStringUtils.random(10, TEXT)); + department1.setDepartmentCode(RandomStringUtils.random(10, true, false)); + department1.setParentId(department.getId()); + department1.setParentNameRdd(department.getParentNameRdd()); + department1.setOrganizeId(organize.getId()); + department1.setOrganizeNameRdd(organize.getName()); + department1.setOrganizeCode(organize.getOrganizeCode()); + + init(department1); + departmentList.add(department1); + + for (int l = 0; l < 5; l++) { + SysDepartment department2 = new SysDepartment(); + department2.setName(RandomStringUtils.random(10, TEXT)); + department2.setDepartmentCode(RandomStringUtils.random(10, true, false)); + department2.setParentId(department1.getId()); + department2.setParentNameRdd(department1.getParentNameRdd()); + department2.setOrganizeId(organize.getId()); + department2.setOrganizeNameRdd(organize.getName()); + department2.setOrganizeCode(organize.getOrganizeCode()); + + init(department2); + departmentList.add(department2); + } + } + } + + for (int j = 0; j < 5; j++) { + + SysOrganize organize1 = new SysOrganize(); + organize1.setName(RandomStringUtils.random(10, TEXT)); + organize1.setOrganizeCode(RandomStringUtils.random(10, true, false)); + organize1.setParentId(organize.getParentId()); + organize1.setParentNameRdd(organize.getName()); + organize1.setOrganizeType(ImppEnumUtil.ORGANIZE_YTPE.TYPE_FACTORY.getValue()); + + init(organize1); + organizeList.add(organize1); + + for (int k = 0; k < 5; k++) { + SysDepartment department = new SysDepartment(); + department.setName(RandomStringUtils.random(10, TEXT)); + department.setDepartmentCode(RandomStringUtils.random(10, true, false)); + department.setParentId(CommonEnumUtil.PARENT.DEFAULT.getValue()); + department.setParentNameRdd("顶级部门"); + department.setOrganizeId(organize1.getId()); + department.setOrganizeNameRdd(organize1.getName()); + department.setOrganizeCode(organize1.getOrganizeCode()); + + init(department); + departmentList.add(department); + for (int l = 0; l < 5; l++) { + SysDepartment department1 = new SysDepartment(); + department1.setName(RandomStringUtils.random(10, TEXT)); + department1.setDepartmentCode(RandomStringUtils.random(10, true, false)); + department1.setParentId(department.getId()); + department1.setParentNameRdd(department.getParentNameRdd()); + department1.setOrganizeId(organize1.getId()); + department1.setOrganizeNameRdd(organize1.getName()); + department1.setOrganizeCode(organize1.getOrganizeCode()); + + init(department1); + departmentList.add(department1); + for (int m = 0; m < 5; m++) { + SysDepartment department2 = new SysDepartment(); + department2.setName(RandomStringUtils.random(10, TEXT)); + department2.setDepartmentCode(RandomStringUtils.random(10, true, false)); + department2.setParentId(department1.getId()); + department2.setParentNameRdd(department1.getParentNameRdd()); + department2.setOrganizeId(organize1.getId()); + department2.setOrganizeNameRdd(organize1.getName()); + department2.setOrganizeCode(organize1.getOrganizeCode()); + + init(department2); + departmentList.add(department2); + } + } + } + + for (int k = 0; k < 5; k++) { + + SysOrganize organize2 = new SysOrganize(); + organize2.setName(RandomStringUtils.random(10, TEXT)); + organize2.setOrganizeCode(RandomStringUtils.random(10, true, false)); + organize2.setParentId(organize1.getParentId()); + organize2.setParentNameRdd(organize1.getName()); + organize2.setOrganizeType(ImppEnumUtil.ORGANIZE_YTPE.TYPE_FACTORY.getValue()); + + init(organize2); + organizeList.add(organize2); + + for (int l = 0; l < 5; l++) { + SysDepartment department = new SysDepartment(); + department.setName(RandomStringUtils.random(10, TEXT)); + department.setDepartmentCode(RandomStringUtils.random(10, true, false)); + department.setParentId(CommonEnumUtil.PARENT.DEFAULT.getValue()); + department.setParentNameRdd("顶级部门"); + department.setOrganizeId(organize2.getId()); + department.setOrganizeNameRdd(organize2.getName()); + department.setOrganizeCode(organize2.getOrganizeCode()); + + init(department); + departmentList.add(department); + for (int m = 0; m < 5; m++) { + SysDepartment department1 = new SysDepartment(); + department1.setName(RandomStringUtils.random(10, TEXT)); + department1.setDepartmentCode(RandomStringUtils.random(10, true, false)); + department1.setParentId(department.getId()); + department1.setParentNameRdd(department.getParentNameRdd()); + department1.setOrganizeId(organize2.getId()); + department1.setOrganizeNameRdd(organize2.getName()); + department1.setOrganizeCode(organize2.getOrganizeCode()); + + init(department1); + departmentList.add(department1); + for (int n = 0; n < 5; n++) { + SysDepartment department2 = new SysDepartment(); + department2.setName(RandomStringUtils.random(10, TEXT)); + department2.setDepartmentCode(RandomStringUtils.random(10, true, false)); + department2.setParentId(department1.getId()); + department2.setParentNameRdd(department1.getParentNameRdd()); + department2.setOrganizeId(organize2.getId()); + department2.setOrganizeNameRdd(organize2.getName()); + department2.setOrganizeCode(organize2.getOrganizeCode()); + + init(department2); + departmentList.add(department2); + } + } + } + } + } + } + + for (SysOrganize organize : organizeList) { + String txt = new String(" INSERT INTO sys_organize (" + + "id, create_date, create_user, is_deleted, is_valid, modify_date, " + + "modify_user, organize_code, name, organize_type, parent_id, parent_name_rdd) VALUES " + + "("+organize.getId()+", '"+organize.getCreateDatetime()+"', '"+organize.getCreateUser()+"', " + + " "+organize.getIsDeleted()+", "+organize.getIsValid()+", '"+organize.getModifyDatetime()+"'," + + " '"+organize.getModifyUser()+"', '"+organize.getOrganizeCode()+"', '"+organize.getParentNameRdd()+"'," + + " "+organize.getOrganizeType()+", "+organize.getParentId()+", '"+organize.getParentNameRdd()+"');"); + fileWriter("E:\\test\\SysOrganize.sql",txt); + } + + for (SysDepartment department : departmentList) { + String txt = new String("INSERT INTO sys_department (id, create_date, create_user, is_deleted," + + " is_valid, modify_date, modify_user, department_code, name, organize_id, organize_name_rdd," + + " parent_id, parent_name_rdd) VALUES (" + + " "+department.getId()+", '"+department.getCreateDatetime()+"'," + + " '"+department.getCreateUser()+"', "+department.getIsDeleted()+", "+department.getIsValid()+"," + + " '"+department.getModifyDatetime()+"', '"+department.getModifyUser()+"', '"+department.getDepartmentCode()+"'," + + " '"+department.getName()+"', "+department.getOrganizeId()+", '"+department.getOrganizeNameRdd()+"', " + + " "+department.getParentId()+", ':"+department.getParentNameRdd()+"');"); + fileWriter("E:\\test\\SysDepartment.sql",txt); + } + + } + + @Test + public void testSysMenu() throws Exception { + List list = menuService.findSysMenuAll(); + + for (SysMenu menu : list) { + String txt = new String("INSERT INTO sys_menu (id, create_date, create_user, is_deleted, is_valid," + + " modify_date, modify_user, menu_class_path, menu_code, menu_css, menu_description, menu_grade, menu_icon, " + + "menu_sort, menu_status, menu_type, menu_url, name, parent_id, parent_name_rdd, name_zh_shortening) VALUES (" + + " "+menu.getId()+", null, 'System Init', null, null, '2018-12-20 12:39:56', '系统管理员', '', '101010000', '', null, null, '', '0', 1, 2, '/impp-base', '基础信息管理', 100002, '设置', 'jcxxgl');"); + fileWriter("E:\\test\\SysRefRoleMenu.sql",txt); + } + } + + @Test + public void testSysRole() throws Exception{ + List list = menuService.findSysMenuAll(); + + List roleList = new ArrayList<>(); + List refRoleMenuList = new ArrayList<>(); + + for (int i = 0; i < 100 ; i++) { + List moduleListRdd = new ArrayList<>(); + List featuresListRdd = new ArrayList<>(); // 冗余 + + SysRole role = new SysRole(); + role.setRoleStatus(CommonEnumUtil.DATA_STATUS.ENABLE.getValue()); + role.setMenuNumber(0); + role.setModuleNumber(0); + role.setName(RandomStringUtils.random(10, TEXT)); + role.setRoleDescription(RandomStringUtils.random(50, TEXT)); + + for (SysMenu menu : list) { + SysRefRoleMenu ref = new SysRefRoleMenu(); + ref.setRoleId(role.getId()); + ref.setRoleNameRdd(role.getName()); + ref.setMenuNameRdd(menu.getName()); + ref.setMenuId(menu.getId()); + ref.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue()); + ref.setMenuTypeRdd(menu.getMenuType()); + + // 冗余信息封装 + if(CommonEnumUtil.METHOD_LEVEL.MODULE.getValue() == menu.getMenuType().intValue()){ + moduleListRdd.add(menu.getName()); + } + if(CommonEnumUtil.METHOD_LEVEL.METHOD.getValue() == menu.getMenuType().intValue()){ + featuresListRdd.add(menu.getName()); + } + + init(ref); + refRoleMenuList.add(ref); + } + + role.setModuleNumber(moduleListRdd.size()); + role.setModuleNamesRdd(String.join(",",moduleListRdd)); + role.setMenuNumber(featuresListRdd.size()); + role.setMenuNamesRdd(String.join(",",featuresListRdd)); + + init(role); + roleList.add(role); + } + + for (SysRole role : roleList) { + String txt = new String(" INSERT INTO sys_role (id, create_date, create_user, is_deleted, is_valid," + + " modify_date, modify_user, menu_names_rdd, menu_number_rdd, module_names_rdd, module_number, name," + + " role_description, role_status) VALUES " + + "( "+role.getId()+", '"+role.getCreateDatetime()+"', '"+role.getCreateUser()+"', "+role.getIsDeleted()+"," + + " "+role.getIsValid()+", '"+role.getModifyDatetime()+"', '"+role.getModifyUser()+"', '"+role.getMenuNamesRdd()+"', "+role.getMenuNumber()+"," + + " '"+role.getModuleNamesRdd()+"', "+role.getModuleNumber()+", '"+role.getName()+"', null, 1);"); + fileWriter("E:\\test\\SysRole.sql",txt); + } + + for (SysRefRoleMenu ref : refRoleMenuList) { + String txt = new String("INSERT INTO sys_ref_role_menu (id, create_date, create_user, is_deleted," + + " is_valid, modify_date, modify_user, menu_id, menu_name_rdd, menu_type_rdd, role_id, role_name_rdd) VALUES (" + + " "+ref.getId()+", '"+ref.getCreateDatetime()+"', '"+ref.getCreateUser()+"', "+ref.getIsDeleted()+", "+ref.getIsValid()+"," + + " '"+ref.getModifyDatetime()+"', '"+ref.getModifyUser()+"', "+ref.getMenuId()+", '"+ref.getMenuNameRdd()+"'," + + " '"+ref.getMenuTypeRdd()+"', "+ref.getRoleId()+", '"+ref.getRoleNameRdd()+"');"); + fileWriter("E:\\test\\SysRefRoleMenu.sql",txt); + } + + + + } + + @Test + public void testUserInfo() throws Exception { + List roleList = roleService.findSysRoleAll(); + List positionList = positionService.listSysPosition(); + List departmentList = departmentService.listSysDepartment(); + + for (int y = 0; y < 10; y++) { + String PATH = new String("E:\\test\\user\\" + y); + List userList = new ArrayList<>(); + List userInfoList = new ArrayList<>(); + List refUserRoleList = new ArrayList<>(); + List refUserDepartmentList = new ArrayList<>(); + List refUserInfoDepartmentList = new ArrayList<>(); + List refUserPositionList = new ArrayList<>(); + + List refUserRoleNameList ; + List refUserPositionNameList ; + List refUserDepartmentNameList ; + + SysUser user; + SysUserInfo userInfo; + SysRefUserRole refUserRole; + SysRefUserDepartment refUserDepartment; + SysRefUserInfoDepartment refUserInfoDepartment; + SysRefUserPosition refUserPosition; + SysDepartment department = null; + SysPosition position = null; + + for (int i = 0; i < 10000; i++) { + user = new SysUser(); + userInfo = new SysUserInfo(); + refUserRoleNameList = new ArrayList<>(); + refUserPositionNameList = new ArrayList<>(); + refUserDepartmentNameList = new ArrayList<>(); + + init(user); + init(userInfo); + + for (int j = 0; j < 2; j++) { + SysRole role = roleList.get(new Random().nextInt(roleList.size() - 1)); + if(role != null){ + refUserRole = new SysRefUserRole(); + init(refUserRole); + + refUserRole.setRoleId(role.getId()); + refUserRole.setRoleNameRdd(role.getName()); + refUserRole.setUserId(user.getId()); + refUserRole.setUserNameRdd(user.getUserName()); + + refUserRoleNameList.add(role.getName()); + refUserRoleList.add(refUserRole); + } + } + + for (int j = 0; j < 3; j++) { + position = positionList.get(new Random().nextInt(positionList.size() - 1)); + if(position != null){ + refUserPosition = new SysRefUserPosition(); + init(refUserPosition); + + refUserPosition.setUserId(userInfo.getId()); + refUserPosition.setUserNameRdd(userInfo.getName()); + refUserPosition.setPositionId(position.getId()); + refUserPosition.setPositionNameRdd(position.getName()); + + refUserPositionNameList.add(position.getName()); + + refUserPositionList.add(refUserPosition); + } + } + + for (int j = 0; j < 3; j++) { + department = departmentList.get(new Random().nextInt(departmentList.size() - 1)); + + if(department != null){ + refUserDepartment= new SysRefUserDepartment(); + refUserInfoDepartment = new SysRefUserInfoDepartment(); + + init(refUserDepartment); + init(refUserInfoDepartment); + + refUserDepartment.setDepartmentId(department.getId()); + refUserDepartment.setDepartmentNameRdd(department.getName()); + refUserDepartment.setOrganizeNameRdd(department.getOrganizeNameRdd()); + refUserDepartment.setOrganizeId(department.getOrganizeId()); + refUserDepartment.setOrganizeCode(department.getOrganizeCode()); + refUserDepartment.setUserId(user.getId()); + refUserDepartment.setUserNameRdd(user.getUserName()); + + refUserInfoDepartment.setDepartmentId(department.getId()); + refUserInfoDepartment.setDepartmentNameRdd(department.getName()); + refUserInfoDepartment.setOrganizeNameRdd(department.getOrganizeNameRdd()); + refUserInfoDepartment.setOrganizeId(department.getOrganizeId()); + refUserInfoDepartment.setOrganizeCode(department.getOrganizeCode()); + refUserInfoDepartment.setUserId(user.getId()); + refUserInfoDepartment.setUserNameRdd(user.getUserName()); + + refUserDepartmentNameList.add(department.getName()); + + refUserDepartmentList.add(refUserDepartment); + refUserInfoDepartmentList.add(refUserInfoDepartment); + } + } + + userInfo.setDepartmentNamesRdd(StringUtils.join(refUserDepartmentNameList)); + userInfo.setDepartmentId(department.getId()); + userInfo.setDepartmentNameRdd(department.getName()); + userInfo.setOrganizeId(department.getOrganizeId()); + userInfo.setOrganizeNameRdd(department.getOrganizeNameRdd()); + userInfo.setOrganizeCode(department.getOrganizeCode()); + userInfo.setPositionId(position.getId()); + userInfo.setPositionNameRdd(position.getName()); + userInfo.setPositionNamesRdd(StringUtils.join(refUserPositionNameList,",")); + userInfo.setName(RandomStringUtils.random(5, TEXT)); + userInfo.setUserEmpNo(RandomStringUtils.random(10, true, true)); + userInfo.setUserInfoStatus(CommonEnumUtil.USER_INFO_STATUS.INCUMBENT.getValue()); + userInfo.setUserLoginNum(0); + userInfo.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue()); + userInfo.setUserId(user.getId()); + + user.setUserType(CommonEnumUtil.USER_TYPE.USER.getValue()); + user.setUserStatus(CommonEnumUtil.USER_STATUS.ENABLE.getValue()); + user.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue()); + user.setUserLoginNum(0); + user.setDepartmentNamesRdd(StringUtils.join(refUserDepartmentNameList,",")); + user.setDepartmentId(department.getId()); + user.setDepartmentNameRdd(department.getName()); + user.setUserPhone(RandomStringUtils.random(11, false, true)); + user.setUserEmail(RandomStringUtils.random(15, true, true)); + user.setUserLoginName(RandomStringUtils.random(20, true, true)); + user.setUserLoginPassword("123456"); + user.setUserEmpNo(userInfo.getUserEmpNo()); + + userList.add(user); + userInfoList.add(userInfo); + } + + for (SysRefUserPosition ref : refUserPositionList) { + String txt = new String("INSERT INTO sys_ref_user_position (id, create_date, create_user, is_deleted," + + " is_valid, modify_date, modify_user, position_id, position_name_rdd, user_id, user_name_rdd) VALUES (" + + " "+ref.getId()+", '"+ref.getCreateDatetime()+"', '"+ref.getCreateUser()+"', "+ref.getIsDeleted()+"," + + " "+ref.getIsValid()+", '"+ref.getModifyUser()+"', '"+ref.getModifyDatetime()+"', "+ref.getPositionId()+"," + + " '"+ref.getPositionNameRdd()+"', "+ref.getUserId()+", '"+ref.getUserNameRdd()+"');"); + fileWriter(PATH+"\\SysRefUserPosition.sql",txt); + } + + for (SysRefUserRole ref : refUserRoleList) { + String txt = new String("INSERT INTO sys_ref_user_role (id, create_date, create_user, is_deleted," + + " is_valid, modify_date, modify_user, role_id, role_name_rdd, user_id, user_name_rdd) VALUES (" + + " "+ref.getId()+", '"+ref.getCreateDatetime()+"', '"+ref.getCreateUser()+"', "+ref.getIsDeleted()+"," + + " "+ref.getIsValid()+", '"+ref.getModifyDatetime()+"', '"+ref.getModifyUser()+"', "+ref.getRoleId()+"," + + " '"+ref.getRoleNameRdd()+"', "+ref.getUserId()+", '"+ref.getUserNameRdd()+"');"); + fileWriter(PATH+"\\SysRefUserRole.sql",txt); + } + + for (SysRefUserDepartment ref : refUserDepartmentList) { + String txt = new String("INSERT INTO sys_ref_user_department (id, create_date, create_user, is_deleted," + + " is_valid, modify_date, modify_user, department_id, department_name_rdd, organize_id, organize_name_rdd, user_id, user_name) VALUES (" + + " "+ref.getId()+", '"+ref.getCreateDatetime()+"', '"+ref.getCreateUser()+"', "+ref.getIsDeleted()+"," + + " "+ref.getIsValid()+", '"+ref.getModifyDatetime()+"', '"+ref.getModifyUser()+"', "+ref.getDepartmentId()+"," + + " '"+ref.getDepartmentNameRdd()+"', "+ref.getOrganizeId()+", '"+ref.getOrganizeNameRdd()+"'," + + " "+ref.getUserId()+", '"+ref.getUserNameRdd()+"');"); + fileWriter(PATH+"\\SysRefUserDepartment.sql",txt); + } + + for (SysRefUserInfoDepartment ref : refUserInfoDepartmentList) { + String txt = new String("INSERT INTO sys_ref_user_info_department (id, create_date, create_user, is_deleted," + + " is_valid, modify_date, modify_user, department_id, department_name_rdd, organize_id, organize_name_rdd, user_id, user_name) VALUES (" + + " "+ref.getId()+", '"+ref.getCreateDatetime()+"', '"+ref.getCreateUser()+"', "+ref.getIsDeleted()+"," + + " "+ref.getIsValid()+", '"+ref.getModifyDatetime()+"', '"+ref.getModifyUser()+"', "+ref.getDepartmentId()+"," + + " '"+ref.getDepartmentNameRdd()+"', "+ref.getOrganizeId()+", '"+ref.getOrganizeNameRdd()+"'," + + " "+ref.getUserId()+", '"+ref.getUserNameRdd()+"');"); + fileWriter(PATH+"\\SysRefUserInfoDepartment.sql",txt); + } + + for (SysUser su : userList) { + String txt = new String("INSERT INTO sys_user (id, create_date, create_user, is_deleted, is_valid," + + " modify_date, modify_user, organize_code, department_id, department_name_rdd, department_names_rdd, language_code," + + " organize_id, organize_name_rdd, organize_names_rdd, role_names_rdd, user_email, user_emp_no, user_info_id," + + " user_login_last_date_time, user_login_name, user_login_num, user_login_password, user_name_rdd," + + " user_phone, user_status, user_type) VALUES (" + + " "+su.getId()+", '"+su.getCreateDatetime()+"', '"+su.getCreateUser()+"', "+su.getIsDeleted()+", "+su.getIsValid()+"," + + " '"+su.getModifyDatetime()+"', '"+su.getModifyUser()+"', '"+su.getOrganizeCode()+"', " + + " "+su.getDepartmentId()+", '"+su.getDepartmentNameRdd()+"', '"+su.getDepartmentNamesRdd()+"', ''," + + " "+su.getOrganizeId()+", '"+su.getOrganizeNameRdd()+"', null, '"+su.getRoleNamesRdd()+"', '"+su.getUserEmail()+"'," + + " '"+su.getUserEmpNo()+"', "+su.getUserInfoId()+", null, '"+su.getUserLoginName()+"', 0, '2637a5c30af69a7bad877fdb65fbd78b'," + + " '"+su.getUserName()+"', '"+su.getUserPhone()+"', 1, 1);"); + fileWriter(PATH+"\\SysUser.sql",txt); + } + + for (SysUserInfo ui : userInfoList) { + String txt = new String("INSERT INTO sys_user_info (id, create_date, create_user, is_deleted, is_valid," + + " modify_date, modify_user, organize_code, department_id, department_name_rdd, department_names_rdd, name," + + " organize_id, organize_name_rdd, position_id, position_name_rdd, position_names_rdd, user_emp_no, user_id," + + " user_info_status, user_join_date, user_login_last_date_time, user_login_num) VALUES (" + + " "+ui.getId()+", '"+ui.getCreateDatetime()+"', '"+ui.getCreateUser()+"', "+ui.getIsDeleted()+", "+ui.getIsValid()+"," + + " '"+ui.getModifyDatetime()+"', '"+ui.getModifyUser()+"', '"+ui.getOrganizeCode()+"'," + + " "+ui.getDepartmentId()+", '"+ui.getDepartmentNameRdd()+"', '"+ui.getDepartmentNamesRdd()+"'," + + " '"+ui.getName()+"', "+ui.getOrganizeId()+", '"+ui.getOrganizeNameRdd()+"'," + + " "+ui.getPositionId()+", '"+ui.getPositionNameRdd()+"', '"+ui.getPositionNamesRdd()+"'," + + " '"+ui.getUserEmpNo()+"', "+ui.getUserId()+", 1, '2019-02-26', null , 0);"); + fileWriter(PATH+"\\SysUserInfo.sql",txt); + } + + System.gc(); + } + } + + public void testUserDetailModel(){ + List roleList = roleService.findSysRoleAll(); + List positionList = positionService.listSysPosition(); + List departmentList = departmentService.listSysDepartment(); + + UserDetailModel model = new UserDetailModel(); + List roleIds = new ArrayList<>(); + List positionIds = new ArrayList<>(); + List departmentIds = new ArrayList<>(); + + for (int i = 0; i < new Random().nextInt(10) ; i++) { + SysRole role = roleList.get(new Random().nextInt(roleList.size() - 1)); + roleIds.add(role.getId().toString()); + } + + for (int i = 0; i < new Random().nextInt(10) ; i++) { + SysPosition position = positionList.get(new Random().nextInt(positionList.size() - 1)); + positionIds.add(position.getId().toString()); + } + + for (int i = 0; i < new Random().nextInt(10) ; i++) { + SysDepartment department = departmentList.get(new Random().nextInt(departmentList.size() - 1)); + departmentIds.add(department.getId().toString()); + } + + + + model.setUserInfoId(System.currentTimeMillis() + snowflakeIdMaker.nextId() + ""); + model.setUserId(System.currentTimeMillis() + snowflakeIdMaker.nextId() + ""); + model.setUserPhone(RandomStringUtils.random(11, false, true)); + model.setUserEmail(RandomStringUtils.random(15, true, true)); + model.setUserLoginPassword(RandomStringUtils.random(20, true, true)); + model.setUserRoleIdList(roleIds); + model.setUserDepartmentIdList(departmentIds); + model.setInfoEmpNo(RandomStringUtils.random(10, true, true)); + model.setInfoPositionIdList(positionIds); + model.setInfoDepartmentIdList(departmentIds); + + } + + + public void init(BaseBean bean)throws Exception{ + bean.setId(System.currentTimeMillis() + snowflakeIdMaker.nextId() + UUID.randomUUID().hashCode() + new Random().nextInt(10000000)); + bean.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue()); + bean.setIsDeleted(CommonEnumUtil.IS_DEAL.NO.getValue()); + bean.setCreateUser("系统管理员-测试"); + bean.setModifyUser("系统管理员-测试"); + bean.setCreateDatetime(DateFormatUtils.format(System.currentTimeMillis(),"yyyy-MM-dd HH:mm:ss")); + bean.setModifyDatetime(DateFormatUtils.format(System.currentTimeMillis(),"yyyy-MM-dd HH:mm:ss")); + } + + public static void fileWriter(String fileName, String content) { + try { + // 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件    + FileWriter writer = new FileWriter(fileName, true); + writer.write(content+"\r\n"); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestExcelUtil.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestExcelUtil.java new file mode 100644 index 0000000..1283122 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestExcelUtil.java @@ -0,0 +1,41 @@ +package cn.estsh.i3plus.core.apiservice.util; + +import cn.estsh.i3plus.core.apiservice.serviceimpl.busi.TestBase; +import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil; +import cn.estsh.i3plus.pojo.platform.bean.SysTool; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * @Description : excel导入导出测试 + * @Reference : + * @Author : yunhao + * @CreateDate : 2018-11-21 19:44 + * @Modify: + **/ +public class TestExcelUtil extends TestBase { + + + @Test + public void TestExportData(){ + + } + + @Test + public void importData() throws Exception{ + try { + List sy = ExcelUtil.importData("testOut.xls", new FileInputStream("E://testOut.xls"), SysTool.class); + System.out.println(sy); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } +} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestMailUtil.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestMailUtil.java new file mode 100644 index 0000000..a201dda --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestMailUtil.java @@ -0,0 +1,29 @@ +package cn.estsh.i3plus.core.apiservice.util; + +import cn.estsh.i3plus.core.apiservice.serviceimpl.busi.TestBase; +import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @Description : + * @Reference : + * @Author : yunhao + * @CreateDate : 2018-11-21 19:44 + * @Modify: + **/ +public class TestMailUtil extends TestBase { + + @Autowired + MailUtil mailUtil; + + @Test + public void TestSendMail(){ + mailUtil.setTo("yunhao.wang@estsh.com"); + mailUtil.setSubject("中文"); + mailUtil.setContentType(ImppEnumUtil.MESSAGE_TYPE_CONTENT.HTML.getDescription()); + mailUtil.setBody("内容"); + mailUtil.send(); + + } +} diff --git a/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestOrderNoMakeUtil.java b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestOrderNoMakeUtil.java new file mode 100644 index 0000000..e592865 --- /dev/null +++ b/modules/i3plus-core-apiservice/src/test/java/test/cn/estsh/i3plus/core/apiservice/util/TestOrderNoMakeUtil.java @@ -0,0 +1,33 @@ +package cn.estsh.i3plus.core.apiservice.util; + +import cn.estsh.i3plus.core.apiservice.serviceimpl.busi.TestBase; +import cn.estsh.i3plus.pojo.platform.bean.SysOrderNoRule; +import org.junit.Test; + +/** + * @Description : + * @Reference : + * @Author : yunhao + * @CreateDate : 2018-11-21 19:45 + * @Modify: + **/ +public class TestOrderNoMakeUtil extends TestBase { + + @Test + public void TestMakeOrderNo() { + SysOrderNoRule sysOrderNoRule = new SysOrderNoRule(); + sysOrderNoRule.setName("一号单据"); + sysOrderNoRule.setOrderNoRule("GG-{yyyy}{MM}{dd}{serialNo}"); + sysOrderNoRule.setSerialNoSeed(1L); + sysOrderNoRule.setSerialNoIncrement(1L); + sysOrderNoRule.setSerialNoLength(4L); + sysOrderNoRule.setSerialNo(9999L); + sysOrderNoRule.setIsCycle(1); + + System.out.println(OrderNoMakeUtil.next(sysOrderNoRule)); + +// String d= MessageFormat.format("%0{0}d", 3); +// System.out.println(d); + } + +}