use of com.bc.pmpheep.back.vo.OrgAndOrgUserVO in project pmph by BCSquad.
the class OrgUserSeviceTest method testUpdateOrgUserOfBack.
@Test
public void testUpdateOrgUserOfBack() {
OrgAndOrgUserVO orgAndOrgUserVO = new OrgAndOrgUserVO();
Org org = new Org();
OrgUser orgUser = new OrgUser();
// 所属区域
org.setAreaId(12345L);
// 机构id
org.setOrgTypeId(4L);
orgUser.setRealname("s");
orgUser.setOrgId(org.getId());
// 管理员姓名
org.setOrgName("asdasdasdasda");
// 机构代码
orgUser.setUsername("m1001021");
orgUserService.addOrgUserAndOrgOfBack(orgUser, org);
orgAndOrgUserVO.setId(orgUser.getId());
orgAndOrgUserVO.setRealname("机构");
orgAndOrgUserVO.setUsername(orgUser.getUsername());
orgAndOrgUserVO.setOrgId(org.getId());
orgAndOrgUserVO.setOrgName("name");
Object result = orgUserService.updateOrgUserOfBack(orgAndOrgUserVO);
Assert.assertTrue("更新失败", result.equals("SUCCESS"));
}
use of com.bc.pmpheep.back.vo.OrgAndOrgUserVO 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.OrgAndOrgUserVO in project pmph by BCSquad.
the class OrgUserController method allOrgUser.
/**
* Description:分页查询机构用户
*
* @author:lyc
* @date:2017年9月26日下午5:43:59
* @Param: OrgUserManagerVO
* @Return:分页数据集
*/
@RequestMapping(value = "/list/allOrgUser", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "分页查询机构用户")
@ResponseBody
public ResponseBean allOrgUser(@RequestParam("pageSize") Integer pageSize, @RequestParam("pageNumber") Integer pageNumber, @RequestParam("name") String name, @RequestParam("orgName") String orgName) {
PageParameter pageParameter = new PageParameter<>();
OrgAndOrgUserVO orgAndOrgUserVO = new OrgAndOrgUserVO();
if (StringUtil.notEmpty(orgName)) {
orgAndOrgUserVO.setOrgName(StringUtil.toAllCheck(orgName));
}
if (StringUtil.notEmpty(name)) {
// 去除空格
orgAndOrgUserVO.setName(StringUtil.toAllCheck(name));
}
pageParameter.setPageNumber(pageNumber);
pageParameter.setPageSize(pageSize);
pageParameter.setParameter(orgAndOrgUserVO);
return new ResponseBean(orgUserService.getListAllOrgUser(pageParameter));
}
use of com.bc.pmpheep.back.vo.OrgAndOrgUserVO in project pmph by BCSquad.
the class FileDownLoadController method orgUserExportEcel.
/**
* 机构用户export
*/
@RequestMapping(value = "/orgUserExportEcel", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "导出excel")
@ResponseBody
public void orgUserExportEcel(HttpServletRequest request, HttpServletResponse response, String name, String orgName, String orgTypeName, Integer isHospital) {
PageParameter pageParameter = new PageParameter<>();
OrgAndOrgUserVO orgAndOrgUserVO = new OrgAndOrgUserVO();
if (StringUtil.notEmpty(orgName)) {
orgAndOrgUserVO.setOrgName(orgName.replaceAll(" ", ""));
}
if (StringUtil.notEmpty(name)) {
// 去除空格
orgAndOrgUserVO.setName(name.replaceAll(" ", ""));
}
if (StringUtil.notEmpty(orgTypeName)) {
// 去除空格
orgAndOrgUserVO.setOrgTypeName(orgTypeName.replaceAll(" ", ""));
}
orgAndOrgUserVO.setIsHospital(isHospital);
pageParameter.setParameter(orgAndOrgUserVO);
pageParameter.setStart(null);
// export
Workbook workbook = null;
List<OrgAndOrgUserVO> orgList = null;
try {
orgList = orgUserService.getListOrgUser(pageParameter).getRows();
workbook = excelHelper.fromBusinessObjectList(orgList, "机构账户信息");
} catch (CheckedServiceException | IllegalArgumentException | IllegalAccessException 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 (Exception e) {
logger.warn("文件下载时出现IO异常:{}", e.getMessage());
throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_DOWNLOAD_FAILED, "文件在传输时中断");
}
}
use of com.bc.pmpheep.back.vo.OrgAndOrgUserVO in project pmph by BCSquad.
the class OrgUserController method orgUser.
/**
* Description:分页查询机构用户
*
* @author:lyc
* @date:2017年9月26日下午5:43:59
* @Param: OrgUserManagerVO
* @Return:分页数据集
*/
@RequestMapping(value = "/list/orgUser", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "分页查询机构用户")
@ResponseBody
public ResponseBean orgUser(@RequestParam("pageSize") Integer pageSize, @RequestParam("pageNumber") Integer pageNumber, @RequestParam("name") String name, @RequestParam("orgName") String orgName, @RequestParam("orgTypeName") String orgTypeName, @RequestParam("isHospital") Integer isHospital) {
PageParameter pageParameter = new PageParameter<>();
OrgAndOrgUserVO orgAndOrgUserVO = new OrgAndOrgUserVO();
if (StringUtil.notEmpty(orgName)) {
orgAndOrgUserVO.setOrgName(orgName.replaceAll(" ", ""));
}
if (StringUtil.notEmpty(name)) {
// 去除空格
orgAndOrgUserVO.setName(name.replaceAll(" ", ""));
}
if (StringUtil.notEmpty(orgTypeName)) {
// 去除空格
orgAndOrgUserVO.setOrgTypeName(orgTypeName.replaceAll(" ", ""));
}
orgAndOrgUserVO.setIsHospital(isHospital);
pageParameter.setPageNumber(pageNumber);
pageParameter.setPageSize(pageSize);
pageParameter.setParameter(orgAndOrgUserVO);
return new ResponseBean(orgUserService.getListOrgUser(pageParameter));
}
Aggregations