Search in sources :

Example 6 with StaffInfoVO

use of sqltoy.showcase.system.vo.StaffInfoVO in project sagacity-sqltoy by chenrenfei.

the class SeniorQueryServiceTest method testFindPage.

/**
 * 分页查询演示
 *
 * @throws Exception
 */
@Test
public void testFindPage() throws Exception {
    sqlToyCRUDService.truncate(StaffInfoVO.class);
    List<StaffInfoVO> staffVOs = new ArrayList<StaffInfoVO>();
    String[] postType = { "1", "2", "3", "4" };
    String[] sexType = { "F", "M", "X" };
    String staffNames = "赵钱孙李周吴郑王冯陈楮卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄";
    String names = "俞倩倪倰偀偲妆佳亿仪寒宜女奴妶好妃姗姝姹姿婵姑姜姣嫂嫦嫱姬娇娟嫣婕婧娴婉姐姞姯姲姳娘娜妹妍妙妹娆娉娥媚媱嫔婷玟环珆珊珠玲珴瑛琼瑶瑾瑞珍琦玫琪琳环琬瑗琰薇珂芬芳芯花茜荭荷莲莉莹菊芝萍燕苹荣草蕊芮蓝莎菀菁苑芸芊茗荔菲蓉英蓓蕾";
    int end = 100;
    for (int i = 0; i < end; i++) {
        StaffInfoVO staffVO = new StaffInfoVO();
        staffVO.setStaffId(Integer.toString(i + 1));
        staffVO.setStaffCode("S" + StringUtil.addLeftZero2Len(Integer.toString(i + 1), 4));
        int index = CommonUtils.getRandomNum(1, staffNames.length() - 1);
        int nameIndex = CommonUtils.getRandomNum(1, names.length() - 1);
        staffVO.setStaffName(staffNames.substring(index - 1, index) + names.substring(nameIndex - 1, nameIndex) + i);
        staffVO.setBirthday(DateUtil.getNowTime());
        staffVO.setOperator("admin");
        staffVO.setOperateDate(DateUtil.getNowTime());
        staffVO.setOrganId(Integer.toString(CommonUtils.getRandomNum(2, 10)));
        staffVO.setPost(postType[CommonUtils.getRandomNum(postType.length)]);
        // 按照千人比例取性别(千分之五为不确定性别)
        staffVO.setSexType(sexType[CommonUtils.getProbabilityIndex(new int[] { 493, 498, 5 })]);
        staffVO.setStatus("1");
        staffVOs.add(staffVO);
        if (((i + 1) % 100) == 0 || i == end - 1) {
            sqlToyCRUDService.saveOrUpdateAll(staffVOs);
            staffVOs.clear();
        }
    }
    PaginationModel result = seniorQueryService.findStaffInfo(new PaginationModel(), new String[] { "staffName" }, new Object[] { "张" }, StaffInfoVO.class);
    System.err.println(result.getRecordCount());
}
Also used : PaginationModel(org.sagacity.sqltoy.model.PaginationModel) ArrayList(java.util.ArrayList) StaffInfoVO(sqltoy.showcase.system.vo.StaffInfoVO) Test(org.junit.Test)

Example 7 with StaffInfoVO

use of sqltoy.showcase.system.vo.StaffInfoVO in project sagacity-sqltoy by chenrenfei.

the class LinkDaoTest method saveStaff.

@Test
public void saveStaff() throws Exception {
    List<StaffInfoVO> staffVOs = new ArrayList<StaffInfoVO>();
    String[] postType = { "1", "2", "3", "4" };
    String[] sexType = { "F", "M", "X" };
    String staffNames = "赵钱孙李周吴郑王冯陈楮卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄";
    String names = "俞倩倪倰偀偲妆佳亿仪寒宜女奴妶好妃姗姝姹姿婵姑姜姣嫂嫦嫱姬娇娟嫣婕婧娴婉姐姞姯姲姳娘娜妹妍妙妹娆娉娥媚媱嫔婷玟环珆珊珠玲珴瑛琼瑶瑾瑞珍琦玫琪琳环琬瑗琰薇珂芬芳芯花茜荭荷莲莉莹菊芝萍燕苹荣草蕊芮蓝莎菀菁苑芸芊茗荔菲蓉英蓓蕾";
    int end = 100;
    for (int i = 0; i < end; i++) {
        StaffInfoVO staffVO = new StaffInfoVO();
        staffVO.setStaffId(Integer.toString(i + 1));
        staffVO.setStaffCode("S" + StringUtil.addLeftZero2Len(Integer.toString(i + 1), 4));
        int index = CommonUtils.getRandomNum(1, staffNames.length() - 1);
        int nameIndex = CommonUtils.getRandomNum(1, names.length() - 1);
        staffVO.setStaffName(staffNames.substring(index - 1, index) + names.substring(nameIndex - 1, nameIndex) + i);
        staffVO.setBirthday(DateUtil.getNowTime());
        staffVO.setOperator("admin");
        staffVO.setOperateDate(DateUtil.getNowTime());
        staffVO.setOrganId(Integer.toString(CommonUtils.getRandomNum(2, 10)));
        staffVO.setPost(postType[CommonUtils.getRandomNum(postType.length)]);
        // 按照千人比例取性别(千分之五为不确定性别)
        staffVO.setSexType(sexType[CommonUtils.getProbabilityIndex(new int[] { 493, 498, 5 })]);
        staffVO.setStatus("1");
        staffVOs.add(staffVO);
        if (((i + 1) % 100) == 0 || i == end - 1) {
            staffInfoDao.saveOrUpdateStaff(staffVOs);
            staffVOs.clear();
        }
    }
}
Also used : ArrayList(java.util.ArrayList) StaffInfoVO(sqltoy.showcase.system.vo.StaffInfoVO) Test(org.junit.Test)

Example 8 with StaffInfoVO

use of sqltoy.showcase.system.vo.StaffInfoVO in project sagacity-sqltoy by chenrenfei.

the class LinkDaoTest method findPage.

@Test
public void findPage() throws Exception {
    StaffInfoVO staffInfoVO = new StaffInfoVO();
    staffInfoVO.setStaffName("李");
    PaginationModel pageModel = staffInfoDao.findPage(new PaginationModel(), staffInfoVO);
    System.err.println(pageModel.getRecordCount());
}
Also used : PaginationModel(org.sagacity.sqltoy.model.PaginationModel) StaffInfoVO(sqltoy.showcase.system.vo.StaffInfoVO) Test(org.junit.Test)

Example 9 with StaffInfoVO

use of sqltoy.showcase.system.vo.StaffInfoVO in project sagacity-sqltoy by chenrenfei.

the class SeniorQueryServiceTest method testGetRandom.

/**
 * 取random随机记录数
 *
 * @throws Exception
 */
@Test
public void testGetRandom() throws Exception {
    StaffInfoVO staffInfoVO = new StaffInfoVO();
    staffInfoVO.setStaffName("陈");
    List<StaffInfoVO> staffInfoVOs = seniorQueryService.findRandomStaff(0.2, staffInfoVO);
    for (StaffInfoVO staff : staffInfoVOs) {
        System.out.println("staffId=" + staff.getStaffId() + ",staffName=" + staff.getStaffName() + ";organName=" + staff.getOrganName());
    }
}
Also used : StaffInfoVO(sqltoy.showcase.system.vo.StaffInfoVO) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 StaffInfoVO (sqltoy.showcase.system.vo.StaffInfoVO)9 ArrayList (java.util.ArrayList)6 PaginationModel (org.sagacity.sqltoy.model.PaginationModel)2