use of com.bc.pmpheep.back.vo.OrgVO in project pmph by BCSquad.
the class OrgSeviceTest method testListOrgByOrgName.
@Test
public void testListOrgByOrgName() {
PageParameter pageParameter = new PageParameter<>();
PageResult<OrgVO> pageResult = new PageResult<OrgVO>();
OrgVO orgVO = new OrgVO();
orgVO.setOrgName(null);
orgVO.setAreaId(null);
orgVO.setRealname(null);
pageParameter.setPageNumber(1);
pageParameter.setPageSize(20);
pageParameter.setParameter(orgVO);
pageResult = orgService.getSchoolAdminCheckList(pageParameter);
Assert.assertNotNull("在新增用户与修改用户时查询机构失败", orgService.listOrgByOrgName("机构名称"));
}
use of com.bc.pmpheep.back.vo.OrgVO in project pmph by BCSquad.
the class OrgSeviceTest method testListSendToSchoolAdminOrAllUser.
@Test
public void testListSendToSchoolAdminOrAllUser() {
PageParameter pageParameter = new PageParameter<>();
PageResult<OrgVO> pageResult = new PageResult<OrgVO>();
OrgVO orgVO = new OrgVO();
orgVO.setOrgName(null);
orgVO.setAreaId(null);
orgVO.setRealname(null);
pageParameter.setPageNumber(1);
pageParameter.setPageSize(20);
pageParameter.setParameter(orgVO);
pageResult = orgService.getSchoolAdminCheckList(pageParameter);
Assert.assertNotNull("系统消息——发送新消息——发送对象失败", orgService.listSendToSchoolAdminOrAllUser("机构名称", 1L));
}
use of com.bc.pmpheep.back.vo.OrgVO in project pmph by BCSquad.
the class OrgUserServiceImpl method importExcel.
@SuppressWarnings("resource")
@Override
public List<OrgVO> importExcel(MultipartFile file) throws CheckedServiceException {
String fileType = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
Workbook workbook = null;
InputStream in = null;
try {
in = file.getInputStream();
} catch (FileNotFoundException e) {
throw new CheckedServiceException(CheckedExceptionBusiness.EXCEL, CheckedExceptionResult.NULL_PARAM, "获取上传的文件失败");
} catch (IOException e) {
throw new CheckedServiceException(CheckedExceptionBusiness.EXCEL, CheckedExceptionResult.ILLEGAL_PARAM, "读取文件失败");
}
try {
if (".xls".equals(fileType)) {
workbook = new HSSFWorkbook(in);
} else if (".xlsx".equals(fileType)) {
workbook = new XSSFWorkbook(in);
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.EXCEL, CheckedExceptionResult.ILLEGAL_PARAM, "读取的不是Excel文件");
}
} catch (IOException e) {
throw new CheckedServiceException(CheckedExceptionBusiness.EXCEL, CheckedExceptionResult.ILLEGAL_PARAM, "文件读取失败");
} catch (OfficeXmlFileException e) {
throw new CheckedServiceException(CheckedExceptionBusiness.EXCEL, CheckedExceptionResult.ILLEGAL_PARAM, "此文档不是对应的.xls或.xlsx的Excel文档,请修改为正确的后缀名再进行上传");
}
PageParameter<OrgAndOrgUserVO> pageParameter = new PageParameter<>();
pageParameter.setParameter(new OrgAndOrgUserVO());
pageParameter.setStart(null);
List<OrgAndOrgUserVO> orgUsers = orgUserDao.getListAllOrgUser(pageParameter);
List<OrgVO> list = new ArrayList<>();
for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
Sheet sheet = workbook.getSheetAt(numSheet);
if (null == sheet) {
continue;
}
for (int rowNum = 1; rowNum <= sheet.getLastRowNum(); rowNum++) {
OrgVO orgVO = new OrgVO();
Row row = sheet.getRow(rowNum);
if (null == row) {
break;
}
Cell second = row.getCell(1);
String orgName = StringUtil.getCellValue(second);
if (StringUtil.isEmpty(orgName)) {
throw new CheckedServiceException(CheckedExceptionBusiness.EXCEL, CheckedExceptionResult.NULL_PARAM, "Excel文件里序号为" + rowNum + "的机构名称为空");
}
orgVO.setOrgName(orgName);
if (null == orgUsers || orgUsers.isEmpty()) {
list.add(orgVO);
continue;
}
for (OrgAndOrgUserVO orgAndOrgUserVO : orgUsers) {
if (orgName.equals(orgAndOrgUserVO.getOrgName())) {
orgVO.setUsername(orgAndOrgUserVO.getUsername());
orgVO.setOrgTypeName(orgAndOrgUserVO.getOrgTypeName());
orgVO.setRealname(orgAndOrgUserVO.getRealname());
break;
}
}
list.add(orgVO);
}
}
return list;
}
use of com.bc.pmpheep.back.vo.OrgVO in project pmph by BCSquad.
the class ExcelHelper method fromOrgVO.
public Workbook fromOrgVO(List<OrgVO> dataSource, String sheetName) throws CheckedServiceException, IllegalAccessException, IllegalArgumentException {
if (null == dataSource || dataSource.isEmpty()) {
throw new CheckedServiceException(CheckedExceptionBusiness.EXCEL, CheckedExceptionResult.NULL_PARAM, "用于导出的数据源为空");
}
Workbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet(sheetName);
Row header = sheet.createRow(0);
header.createCell(0).setCellValue("序号");
header.createCell(1).setCellValue("机构名称");
header.createCell(2).setCellValue("机构账号");
header.createCell(3).setCellValue("管理员名称");
header.createCell(4).setCellValue("机构类型");
headerStyleSetup(workbook, 1);
int rowCount = 1;
for (OrgVO orgVO : dataSource) {
Row row = sheet.createRow(rowCount);
row.createCell(0).setCellValue(rowCount);
row.createCell(1).setCellValue(orgVO.getOrgName());
row.createCell(2).setCellValue(orgVO.getUsername());
row.createCell(3).setCellValue(orgVO.getRealname());
row.createCell(4).setCellValue(orgVO.getOrgTypeName());
rowCount++;
}
int[] maxLength = { 2, 15, 15, 10, 15 };
return dataStyleSetup(workbook, 1, rowCount, new ColumnProperties(5, maxLength));
}
use of com.bc.pmpheep.back.vo.OrgVO in project pmph by BCSquad.
the class FileDownLoadController method exportOrgInfo.
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "导出机构用户对比后的信息")
@RequestMapping(value = "/org/exportOrgInfo", method = RequestMethod.GET)
public void exportOrgInfo(HttpServletRequest request, HttpServletResponse response, String uuid) {
if (StringUtil.isEmpty(uuid)) {
throw new CheckedServiceException(CheckedExceptionBusiness.EXCEL, CheckedExceptionResult.NULL_PARAM, "参数不能为空");
}
String sessionId = CookiesUtil.getSessionId(request);
HttpSession session = SessionContext.getSession(sessionId);
List<OrgVO> list = (List<OrgVO>) session.getAttribute(uuid);
if (null == list || list.isEmpty()) {
throw new CheckedServiceException(CheckedExceptionBusiness.ORG, CheckedExceptionResult.NULL_PARAM, "导出的机构信息不能为空");
}
Workbook workbook = null;
try {
workbook = excelHelper.fromOrgVO(list, "机构用户信息");
} catch (CheckedServiceException | IllegalAccessException | IllegalArgumentException e) {
logger.warn("数据表格化的时候失败");
}
response.setCharacterEncoding("utf-8");
response.setContentType("application/force-download");
String fileName = returnFileName(request, "机构用户信息" + ".xls");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
try (OutputStream out = response.getOutputStream()) {
workbook.write(out);
out.flush();
out.close();
} catch (IOException e) {
logger.warn("文件下载时出现IO异常: {}", e.getMessage());
throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_DOWNLOAD_FAILED, "文件在传输时中断");
}
}
Aggregations