OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2022-02-22 6a916b069c73ad7def95ad72ae848125544bc309
src/main/java/kr/wisestone/owl/service/impl/UserServiceImpl.java
@@ -18,7 +18,6 @@
import kr.wisestone.owl.util.*;
import kr.wisestone.owl.vo.*;
import kr.wisestone.owl.web.condition.UserCondition;
import kr.wisestone.owl.web.form.DepartmentForm;
import kr.wisestone.owl.web.form.UserForm;
import kr.wisestone.owl.web.view.ExcelView;
import org.apache.commons.validator.routines.EmailValidator;
@@ -93,6 +92,9 @@
    private ProjectService projectService;
    @Autowired
    private IssueTypeService issueTypeService;
    @Autowired
    private UserSecurityService userSecurityService;
    @Autowired
@@ -103,6 +105,9 @@
    @Autowired
    private AttachedFileService attachedFileService;
    @Autowired
    private UserDepartmentService userDepartmentService;
    @Autowired
    private IssueService issueService;
@@ -166,6 +171,9 @@
    @Value("${total.statistics.email}")
    private String totalStatisticsEmail; //  프로젝트, 이슈, 사용자수 알림
    @Value("${email.joinEmail}")
    private boolean bJoinEmail;
    @Autowired
    private ExcelView excelView;
@@ -236,6 +244,13 @@
            /*user.setPermission(MngPermission.USER_PERMISSION_MNG_NONE);*/
        } else if(validAdmin == 1) {    // 라이센스 입력 관리자
            /*DepartmentForm departmentForm = new DepartmentForm();
            departmentForm.setDepartmentName("부서 없음");
            Department department = this.departmentService.add(departmentForm);
            this.departmentRepository.saveAndFlush(department);*/
            Workspace primaryWorkspace = this.workspaceService.getPrimaryWorkspace();
            UserLevel userLevel = this.userLevelService.addSuperUserLevel();
@@ -251,7 +266,10 @@
                this.userWorkspaceService.addUserWorkspace(user, workspace, true, true);
                //  기본으로 제공되는 프로젝트를 생성한다.
//                this.projectService.addDefaultProject(user, workspace);
                this.projectService.addDefaultProject(user, workspace);
                // 기본으로 제공되는 프로젝트를 이슈 유형의 사용 프로젝트로 설정
                this.issueTypeService.addDefaultUsedProject(workspace);
                user.setLastWorkspaceId(workspace.getId());
@@ -263,13 +281,6 @@
                /*user.setPermission(MngPermission.makeSubAllPermission());*/
            }
        }
        DepartmentForm departmentForm = new DepartmentForm();
        departmentForm.setDepartmentName("부서 없음");
        Department department = this.departmentService.add(departmentForm);
        // wyu
        this.departmentRepository.saveAndFlush(department);
        this.userRepository.saveAndFlush(user);
        //  이메일 알림 예정 시간이 공백이면 디폴트 이메일 알림 예정 시간으로 설정한다.
@@ -284,8 +295,9 @@
        userMap.put("registerDate", DateUtil.convertDateToYYYYMMDD(user.getRegisterDate()));
        //  회원 가입 알림 메일 전송
        this.systemEmailService.directEmail(new String[]{user.getAccount()}, EmailType.WORKSPACE_JOIN, userMap, null);
        if(bJoinEmail) {
            this.systemEmailService.directEmail(new String[]{user.getAccount()}, EmailType.WORKSPACE_JOIN, userMap, null);
        }
        return user;
    }
@@ -541,8 +553,12 @@
            User user = this.getUser(userCondition.getId());
            userVo = ConvertUtil.copyProperties(user, UserVo.class, "password");
            userVo.setAccount(CommonUtil.decryptAES128(userVo.getAccount()));
        }
            Map<String, Object> projectManagerYN = this.projectRoleUserService.findProjectManager((userCondition.getId()));
            if(projectManagerYN != null){
                userVo.setProjectManagerYN(true);
            }
        }
        resJsonData.put(Constants.RES_KEY_CONTENTS, userVo);
    }
@@ -949,6 +965,15 @@
        return this.convertUserVoToMap(results, totalUsersCount, pageable, resJsonData);
    }
    //  사용자 정보를 가져온다.
    @Override
    @Transactional(readOnly = true)
    public void findMyLevelAndDepartment(Map<String, Object> resJsonData) {
        Long loginId = this.webAppUtil.getLoginId();
        Map<String, Object> result = this.userMapper.findByMyLevelAndDepartment(loginId);
        resJsonData.put(Constants.RES_KEY_CONTENTS, result);
    }
    //  사용자 아이디로 사용자를 조회한다.
    @Override
    @Transactional(readOnly = true)
@@ -1064,6 +1089,30 @@
        resJsonData.put(Constants.RES_KEY_CONTENTS, userVo);
    }
    //  마지막으로 선택한 이슈 타입 정보를 저장한다.
    @Override
    @Transactional
    public void updateLastIssueType(Map<String, Object> resJsonData, UserForm userForm) {
        User user = this.getUser(this.webAppUtil.getLoginId());
        if (userForm.getLastIssueTypeId() != null) {
            user.setLastIssueTypeId(userForm.getLastIssueTypeId());
        }
        this.userRepository.saveAndFlush(user);
        //  세션 업데이트
        SecurityUtils.setUserToSession(user);
        //  클라이언트의 사용자 정보 업데이트
        UserVo userVo = ConvertUtil.copyProperties(user, UserVo.class, "password");
        if (user.getSocialType() != null) {
            userVo.setSocialType(user.getSocialType().toString());
        }
        userVo.setAccount(CommonUtil.decryptAES128(userVo.getAccount()));
        resJsonData.put(Constants.RES_KEY_CONTENTS, userVo);
    }
    //  특정 아이디에 해당하는 사용자 목록을 가져온다.
    @Override
    @Transactional(readOnly = true)
@@ -1199,10 +1248,19 @@
    @Transactional(readOnly = true)
    public User getUserSession(Map<String, Object> resJsonData, HttpServletRequest httpServletRequest) {
        User user = this.getUser(this.webAppUtil.getLoginId());
        UserVo userVo = ConvertUtil.copyProperties(user, UserVo.class, "password","permission");
        UserVo userVo = ConvertUtil.copyProperties(user, UserVo.class, "password");
        // user에서 Permission 값을 가져와서 userVo 에 setPermission 함
        userVo.setPermission(user.getPermission());
        userVo.setAccount(CommonUtil.decryptAES128(userVo.getAccount()));
        UserLevel userLevel = user.getUserLevel();
        if (userLevel != null) {
            userVo.setLevelName(userLevel.getLevelName());
        }
        List<Department> departments = this.userDepartmentService.findDepartment(user.getId());
        if (departments != null) {
            userVo.setDepartmentVos(ConvertUtil.convertObjectsToClasses(departments, DepartmentVo.class));
        }
        resJsonData.put(Constants.RES_KEY_CONTENTS, userVo);
        //  사용자 세션 정보를 분석해서 로그에 남긴다.
        log.info(ElasticSearchUtil.makeUserSessionHistoryMessage(httpServletRequest, userVo));
@@ -1228,6 +1286,22 @@
        conditions.put("endTime", DateUtil.convertDateToStr(endCal.getTime(), "HH:mm"));
        List<Map<String, Object>> users = this.userMapper.findByReservationNotifyTime(conditions);
        List<String> results = Lists.newArrayList();
        for (Map<String, Object> user : users) {
            results.add(MapUtil.getString(user, "account"));
        }
        return results;
    }
    //  이메일 알림 예정 시간을 실시간으로 설정한 사용자를 조회한다.
    @Override
    @Transactional(readOnly = true)
    public List<String> findByRealTimeNotifyTime() {
        Map<String, Object> conditions = new HashMap<>();
        List<Map<String, Object>> users = this.userMapper.findByRealTimeNotifyTime(conditions);
        List<String> results = Lists.newArrayList();
        for (Map<String, Object> user : users) {
@@ -1303,15 +1377,17 @@
        userMap.put("newUserCount", joinUsers.size());
        userMap.put("joinUsers", userVos);
        String[] sendEmails = this.userJoinStatisticsEmail.replaceAll("\\p{Z}", "").split(",");
        List<String> encryptSendEmail = Lists.newArrayList();
        if (this.userJoinStatisticsEmail != null && !this.userJoinStatisticsEmail.equals("")) {
            String[] sendEmails = this.userJoinStatisticsEmail.replaceAll("\\p{Z}", "").split(",");
            List<String> encryptSendEmail = Lists.newArrayList();
        for (String sendEmail : sendEmails) {
            encryptSendEmail.add(CommonUtil.encryptAES128(sendEmail));
            for (String sendEmail : sendEmails) {
                encryptSendEmail.add(CommonUtil.encryptAES128(sendEmail));
            }
            //  결제 성공 메일 발송
            this.systemEmailService.directEmail(encryptSendEmail.toArray(new String[encryptSendEmail.size()]), EmailType.USER_JOIN_STATISTICS, userMap, null);
        }
        //  결제 성공 메일 발송
        this.systemEmailService.directEmail(encryptSendEmail.toArray(new String[encryptSendEmail.size()]), EmailType.USER_JOIN_STATISTICS, userMap, null);
    }
    //  전체 사용자, 프로젝트 수, 이슈 수를 이메일로 보낸다.
@@ -1329,15 +1405,17 @@
        userMap.put("projectCount", CommonUtil.getDecimalFormat(projectCount));
        userMap.put("userCount", CommonUtil.getDecimalFormat(activeUsers.size()));
        String[] sendEmails = this.totalStatisticsEmail.replaceAll("\\p{Z}", "").split(",");
        List<String> encryptSendEmail = Lists.newArrayList();
        if (this.totalStatisticsEmail != null && !this.totalStatisticsEmail.equals("")) {
            String[] sendEmails = this.totalStatisticsEmail.replaceAll("\\p{Z}", "").split(",");
            List<String> encryptSendEmail = Lists.newArrayList();
        for (String sendEmail : sendEmails) {
            encryptSendEmail.add(CommonUtil.encryptAES128(sendEmail));
            for (String sendEmail : sendEmails) {
                encryptSendEmail.add(CommonUtil.encryptAES128(sendEmail));
            }
            //  결제 성공 메일 발송
            this.systemEmailService.directEmail(encryptSendEmail.toArray(new String[encryptSendEmail.size()]), EmailType.TOTAL_STATISTICS, userMap, null);
        }
        //  결제 성공 메일 발송
        this.systemEmailService.directEmail(encryptSendEmail.toArray(new String[encryptSendEmail.size()]), EmailType.TOTAL_STATISTICS, userMap, null);
    }