Search in sources :

Example 56 with ResponseBean

use of com.bc.pmpheep.controller.bean.ResponseBean 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));
}
Also used : MateriaHistorylVO(com.bc.pmpheep.back.vo.MateriaHistorylVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 57 with ResponseBean

use of com.bc.pmpheep.controller.bean.ResponseBean 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);
}
Also used : Org(com.bc.pmpheep.back.po.Org) HashMap(java.util.HashMap) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) Row(org.apache.poi.ss.usermodel.Row) Sheet(org.apache.poi.ss.usermodel.Sheet) Cell(org.apache.poi.ss.usermodel.Cell) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 58 with ResponseBean

use of com.bc.pmpheep.controller.bean.ResponseBean 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);
}
Also used : OrgVO(com.bc.pmpheep.back.vo.OrgVO) HttpSession(javax.servlet.http.HttpSession) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) IOException(java.io.IOException) HashedMap(org.apache.commons.collections.map.HashedMap) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 59 with ResponseBean

use of com.bc.pmpheep.controller.bean.ResponseBean 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));
}
Also used : OrgAndOrgUserVO(com.bc.pmpheep.back.vo.OrgAndOrgUserVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 60 with ResponseBean

use of com.bc.pmpheep.controller.bean.ResponseBean in project pmph by BCSquad.

the class PmphDepartmentController method listOpts.

/**
 * 功能描述:选题申报运维人员获取部门和部门负责人
 *
 * @param dpName
 *            部门名称
 * @param pageSize
 *            当页条数
 * @param pageNumber
 *            当前页数
 * @return
 */
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "获取部门与部门负责人")
@RequestMapping(value = "/listOpts", method = RequestMethod.GET)
public ResponseBean listOpts(String dpName, Integer pageSize, Integer pageNumber) {
    PageParameter<DepartmentOptsVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
    DepartmentOptsVO departmentOptsVO = new DepartmentOptsVO();
    departmentOptsVO.setDpName(dpName);
    pageParameter.setParameter(departmentOptsVO);
    return new ResponseBean(pmphDepartmentService.listOpts(pageParameter));
}
Also used : DepartmentOptsVO(com.bc.pmpheep.back.vo.DepartmentOptsVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)67 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)67 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)65 LogDetail (com.bc.pmpheep.annotation.LogDetail)61 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)37 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)11 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 TopicLog (com.bc.pmpheep.back.po.TopicLog)5 DesRun (com.bc.pmpheep.back.util.DesRun)4 Properties (java.util.Properties)4 BookVideo (com.bc.pmpheep.back.po.BookVideo)3 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)3 PmphUser (com.bc.pmpheep.back.po.PmphUser)3 Topic (com.bc.pmpheep.back.po.Topic)3 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)2 PmphRole (com.bc.pmpheep.back.po.PmphRole)2 WriterUser (com.bc.pmpheep.back.po.WriterUser)2 DeclarationResultSchoolVO (com.bc.pmpheep.back.vo.DeclarationResultSchoolVO)2