| | |
| | | import kr.wisestone.owl.web.condition.UserCondition; |
| | | import kr.wisestone.owl.web.form.DepartmentForm; |
| | | import kr.wisestone.owl.web.form.UserDepartmentForm; |
| | | import org.jsoup.Jsoup; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.ui.Model; |
| | | import com.google.common.collect.Lists; |
| | | import kr.wisestone.owl.common.ExcelConditionCheck; |
| | |
| | | |
| | | @Service |
| | | public class DepartmentServiceImpl extends AbstractServiceImpl<Department, Long, JpaRepository<Department, Long>> implements DepartmentService { |
| | | |
| | | private static final Logger log = LoggerFactory.getLogger(IssueServiceImpl.class); |
| | | |
| | | @Autowired |
| | | private DepartmentRepository departmentRepository; |
| | |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("departmentDescription", this.messageAccessor.message("department.departmentDescription"), 20, ExportExcelAttrVo.ALIGN_CENTER)); |
| | | excelInfo.addAttrInfos(new ExportExcelAttrVo("departmentCount", this.messageAccessor.message("department.departmentCount"), 3, ExportExcelAttrVo.ALIGN_CENTER)); |
| | | |
| | | excelInfo.setDatas(departmentVos); |
| | | // DepartmentVos 데이터를 엑셀에서 표시할 수 있는 데이터로 변경한다. |
| | | List<Map<String, Object>> convertExcelViewToDepartmentMaps = this.convertExcelViewToDepartmentVos(departmentVos); |
| | | |
| | | excelInfo.setDatas(convertExcelViewToDepartmentMaps); |
| | | |
| | | model.addAttribute(Constants.EXCEL, excelInfo); |
| | | return new ModelAndView(this.excelView); |
| | |
| | | return this.departmentMapper.countInDepartment(id) > 0; |
| | | } |
| | | |
| | | // DepartmentVos 데이터를 엑셀에서 표시할 수 있는 데이터로 변경한다. |
| | | private List<Map<String, Object>> convertExcelViewToDepartmentVos(List<DepartmentVo> departmentVos) { |
| | | List<Map<String, Object>> results = Lists.newArrayList(); |
| | | |
| | | for (DepartmentVo departmentVo : departmentVos){ |
| | | try { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("departmentName", departmentVo.getDepartmentName()); |
| | | result.put("departmentCount", departmentVo.getDepartmentCount()); |
| | | |
| | | String description= ""; |
| | | |
| | | if(departmentVo.getDepartmentDescription() != null){ |
| | | description = Jsoup.parse(departmentVo.getDepartmentDescription()).text(); //HTML 태그 제거 |
| | | description = description.replaceAll("\\<.*?>", ""); //공백 제거 |
| | | } |
| | | result.put("departmentDescription", description); |
| | | results.add(result); |
| | | } catch (Exception e) { |
| | | log.error("엑셀 다운로드 오류 발생"); |
| | | } |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | // 사용자 부서 ID로 조회한다. |
| | | @Override |
| | |
| | | departmentVo.setByName(departmentVo.getDepartmentName()); |
| | | departmentVos.add(departmentVo); |
| | | } |
| | | |
| | | |
| | | int totalPage = (int) Math.ceil((totalDepartmentsCount - 1) / pageable.getPageSize()) + 1; |
| | | |
| | | resJsonData.put(Constants.RES_KEY_CONTENTS, departmentVos); |