use of com.bc.pmpheep.annotation.LogDetail in project pmph by BCSquad.
the class MaterialController method getTempFile.
/**
* 获取临时文件
*
* @param tempId
* @param response 服务响应
*/
@LogDetail(businessType = Business_Type, logRemark = "获取临时文件")
@RequestMapping(value = "getTempFile", method = RequestMethod.GET)
public void getTempFile(String tempFileId, HttpServletRequest request, HttpServletResponse response) {
byte[] fileByte = (byte[]) request.getSession(false).getAttribute(tempFileId);
response.setContentType("image/png");
try (OutputStream out = response.getOutputStream()) {
out.write(fileByte, 0, fileByte.length);
out.flush();
out.close();
} catch (IOException ex) {
logger.error("文件下载时出现IO异常:{}", ex.getMessage());
} catch (Exception ex) {
logger.warn("图片查看时出现异常:{}", ex.getMessage());
}
}
use of com.bc.pmpheep.annotation.LogDetail in project pmph by BCSquad.
the class MaterialController method update.
/**
* 更新遴选公告
*
* @param sessionId
* @param material
* 教材对象
* @param materialContacts
* 多个教材联系人
* @param materialExtensions
* 多个教材扩展项
* @param MaterialProjectEditors
* 多个教材扩项目编辑
* @param materialExtra
* 教材通知备
* @param materialNoticeAttachments
* 多个教材通知
* @param noticeFiles
* 通知文件
* @param materialNoteAttachments
* 多个教材备注
* @param noteFiles
* 备注文件
* @return
*/
@ResponseBody
@LogDetail(businessType = Business_Type, logRemark = "修改遴选公告")
@RequestMapping(value = "/update", method = RequestMethod.POST)
public ResponseBean update(MaterialVO materialVO, HttpServletRequest request, // MultipartFile[] noteFiles,
String deadline, String actualDeadline, String ageDeadline) {
try {
materialVO.getMaterial().setDeadline(DateUtil.str3Date(deadline));
materialVO.getMaterial().setActualDeadline(DateUtil.str3Date(actualDeadline));
materialVO.getMaterial().setAgeDeadline(DateUtil.str3Date(ageDeadline));
return new ResponseBean(materialService.addOrUpdateMaterial(request, materialVO, // noteFiles,
true));
} catch (IOException e) {
ResponseBean responseBean = new ResponseBean(e);
responseBean.setData("上传文件失败");
return responseBean;
} catch (Exception e) {
ResponseBean responseBean = new ResponseBean(e);
responseBean.setData(e.getMessage());
return responseBean;
}
}
use of com.bc.pmpheep.annotation.LogDetail in project pmph by BCSquad.
the class MaterialExtraController method history.
/**
* <pre>
* 功能描述:查询历史教材通知列表
* 使用示范:
*
* @param pageNumber 当前页数
* @param pageSize 当前页条数
* @param request
* @return
* </pre>
*/
@ResponseBody
@LogDetail(businessType = BUSINESS_TYPE, logRemark = "查询历史教材通知列表")
@RequestMapping(value = "/history", method = RequestMethod.GET)
public ResponseBean history(@RequestParam(name = "pageNumber", defaultValue = "1") Integer pageNumber, @RequestParam(name = "pageSize", defaultValue = "5") Integer pageSize, HttpServletRequest request) {
PageParameter<MateriaHistorylVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
MateriaHistorylVO materiaHistorylVO = new MateriaHistorylVO();
pageParameter.setParameter(materiaHistorylVO);
String sessionId = CookiesUtil.getSessionId(request);
return new ResponseBean(materialExtraService.listMaterialHistory(pageParameter, sessionId));
}
use of com.bc.pmpheep.annotation.LogDetail in project pmph by BCSquad.
the class OrgController method excel.
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "解析批量导入的发布学校数据")
@RequestMapping(value = "/orgExport", method = RequestMethod.POST)
public ResponseBean excel(MultipartFile file, HttpServletRequest req) {
if (null == file || file.isEmpty()) {
return new ResponseBean("没有文件");
}
// 文件名称
String name = file.getOriginalFilename();
// 文件类型
String fileType = name.substring(name.lastIndexOf("."));
InputStream in = null;
try {
in = file.getInputStream();
} catch (FileNotFoundException e) {
if (null != in) {
try {
in.close();
} catch (Exception ee) {
} finally {
in = null;
}
}
return new ResponseBean("未获取到文件");
} catch (Exception e) {
if (null != in) {
try {
in.close();
} catch (Exception ee) {
} finally {
in = null;
}
}
return new ResponseBean("未知异常");
}
Workbook workbook = null;
try {
if ((".xls").equals(fileType)) {
workbook = new HSSFWorkbook(in);
} else if ((".xlsx").equals(fileType)) {
workbook = new XSSFWorkbook(in);
} else {
if (null != in) {
try {
in.close();
} catch (Exception ee) {
} finally {
in = null;
}
}
return new ResponseBean("读取的不是Excel文件");
}
} catch (IOException e) {
if (null != workbook) {
try {
workbook.close();
} catch (Exception ee) {
} finally {
workbook = null;
}
}
if (null != in) {
try {
in.close();
} catch (Exception ee) {
} finally {
in = null;
}
}
return new ResponseBean("读取文件异常");
} catch (Exception e) {
if (null != workbook) {
try {
workbook.close();
} catch (Exception ee) {
} finally {
workbook = null;
}
}
if (null != in) {
try {
in.close();
} catch (Exception ee) {
} finally {
in = null;
}
}
return new ResponseBean("未知异常");
}
// sheet数目
// int sheetTotal = workbook.getNumberOfSheets() ;
Sheet sheet = workbook.getSheetAt(0);
List<Org> orgs = new ArrayList<Org>(sheet.getLastRowNum());
List<String> erros = new ArrayList<String>(sheet.getLastRowNum());
for (int rowNum = 1; rowNum <= sheet.getLastRowNum(); rowNum++) {
Row row = sheet.getRow(rowNum);
if (null == row) {
continue;
}
Cell cell1 = row.getCell(0);
Cell cell2 = row.getCell(1);
Cell cell3 = row.getCell(2);
String value1 = StringUtil.getCellValue(cell1);
String value2 = StringUtil.getCellValue(cell2);
String value3 = StringUtil.getCellValue(cell3);
if (StringUtil.notEmpty(value2) && StringUtil.notEmpty(value3)) {
Org org = orgService.getOrgByNameAndUserName(value2, value3);
if (null != org) {
orgs.add(org);
} else {
erros.add("系统找不到机构名称为\"" + value2 + "\",机构代码为\"" + value3 + "\"的机构");
}
} else {
if (StringUtil.isEmpty(value1) && StringUtil.isEmpty(value2) && StringUtil.isEmpty(value3)) {
} else {
erros.add("第" + rowNum + "条数据填写不完整 ");
}
}
}
if (null != workbook) {
try {
workbook.close();
} catch (Exception e) {
} finally {
workbook = null;
}
}
if (null != in) {
try {
in.close();
} catch (Exception e) {
} finally {
in = null;
}
}
Map<String, Object> res = new HashMap<String, Object>();
res.put("orgs", orgs);
res.put("erros", erros);
return new ResponseBean(res);
}
use of com.bc.pmpheep.annotation.LogDetail in project pmph by BCSquad.
the class OrgUserController method importExcel.
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "机构用户管理界面导入Excel文件")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public ResponseBean importExcel(@RequestParam(name = "file") MultipartFile file, HttpServletRequest request) {
Map<String, Object> map = new HashedMap();
String sessionId = CookiesUtil.getSessionId(request);
HttpSession session = SessionContext.getSession(sessionId);
String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
try {
List<OrgVO> list = orgUserService.importExcel(file);
map.put("uuid", uuid);
map.put("list", list);
session.setAttribute(uuid, list);
} catch (CheckedServiceException e) {
return new ResponseBean(e);
} catch (IOException e) {
return new ResponseBean(e);
}
return new ResponseBean(map);
}
Aggregations