OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2022-01-13 4545664bbece1b1b185945376b344b1660669a53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package kr.wisestone.owl.common;
 
import kr.wisestone.owl.constant.Constants;
import kr.wisestone.owl.constant.MsgConstants;
import kr.wisestone.owl.util.CommonUtil;
import kr.wisestone.owl.util.WebAppUtil;
import kr.wisestone.owl.vo.ExportExcelAttrVo;
import kr.wisestone.owl.vo.ExportExcelVo;
import kr.wisestone.owl.web.view.ExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.servlet.ModelAndView;
 
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
 
/**
 * Created by wisestone on 2018-12-18.
 */
@Component
public class ExcelConditionCheck {
 
    @Autowired
    private SimpMessagingTemplate simpMessagingTemplate;
 
    @Autowired
    private WebAppUtil webAppUtil;
 
    @Autowired
    private MessageAccessor messageAccessor;
 
    @Autowired
    private ExcelView excelView;
 
    public ModelAndView checkCondition(Map<String, Object> conditions, HttpServletRequest request, Model model) {
        Map<String, Object> results;
 
        try {
            results = CommonUtil.getSearchConditions(request);
            Iterator iterator = results.keySet().iterator();
 
            while(iterator.hasNext()) {
                String key = (String)iterator.next();
                Object value = results.get(key);
                conditions.put(key, value);
            }
        }
        catch(IOException e) {
            ExportExcelVo excelInfo = this.makeEmptyDownloadExcel();
            excelInfo.setFileName("검색 조건 오류 - 와이즈스톤 담당자에게 문의하세요.");
            this.simpMessagingTemplate.convertAndSendToUser(this.webAppUtil.getLoginUser().getAccount(), "/notification/system-alert", this.messageAccessor.getMessage(MsgConstants.EXCEL_CONDITIONS_NOT_EXIST));
            model.addAttribute(Constants.EXCEL, excelInfo);
            return new ModelAndView(this.excelView);
        }
 
        return null;
    }
 
    public ExportExcelVo makeEmptyDownloadExcel() {
        ExportExcelVo excelInfo = new ExportExcelVo();
        excelInfo.addAttrInfos(new ExportExcelAttrVo("name", "", 120, ExportExcelAttrVo.ALIGN_LEFT));
        return excelInfo;
    }
 
}