/
zj
2025-05-02 9102aa7e0b42ce5b9667fa3b67fede889df60fc0
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package project.web.admin.monitor;
 
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.providers.encoding.PasswordEncoder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
 
import kernel.exception.BusinessException;
import kernel.web.Page;
import kernel.web.PageActionSupport;
import project.Constants;
import project.monitor.AdminAutoMonitorTipService;
import project.monitor.model.AutoMonitorTip;
import project.tip.TipService;
import project.user.googleauth.GoogleAuthService;
import security.internal.SecUserService;
 
/**
 * 异常提醒
 */
@RestController
public class AdminAutoMonitorTipController extends PageActionSupport {
 
    private Logger logger = LoggerFactory.getLogger(AdminAutoMonitorTipController.class);
    
    @Autowired
    private AdminAutoMonitorTipService adminAutoMonitorTipService;
    @Autowired
    protected PasswordEncoder passwordEncoder;
    @Autowired
    protected GoogleAuthService googleAuthService;
    @Autowired
    protected SecUserService secUserService;
    @Autowired
    private TipService tipService;
    
    private final String action = "normal/adminAutoMonitorTipAction!";
 
    @RequestMapping(value = action + "list.action")
    public ModelAndView list(HttpServletRequest request) {
        
        int pageNo = this.checkAndSetPageNo(request.getParameter("pageNo"));
        int pageSize = 20;
        String loginPartyId = getLoginPartyId();
        
        String message = request.getParameter("message");
        String name_para = request.getParameter("name_para");
        // 0 阀值 提醒 1 ETH充值 
        Integer tiptype_para = null;
        if (null != request.getParameter("tiptype_para") && !"".equals(request.getParameter("tiptype_para"))) {
            
            tiptype_para = Integer.valueOf(request.getParameter("tiptype_para"));
        }
        // 是否已查看确认知道这条消息, 0 初始状态,未知 1  已确认
        Integer is_confirmed_para = null;
        if (null != request.getParameter("is_confirmed_para") && !"".equals(request.getParameter("is_confirmed_para"))) {
            
            is_confirmed_para = Integer.valueOf(request.getParameter("is_confirmed_para"));
        }
 
        Page page = this.adminAutoMonitorTipService.pagedQuery(pageNo, pageSize, name_para,
                tiptype_para, is_confirmed_para, loginPartyId);
 
        List<Map> list = page.getElements();
        for (int i = 0; i < list.size(); i++) {
            Map map = list.get(i);            
            if (null == map.get("rolename")) {
                map.put("roleNameDesc", "");
            } else {
                String roleName = map.get("rolename").toString();
                map.put("roleNameDesc", Constants.ROLE_MAP.containsKey(roleName) ? Constants.ROLE_MAP.get(roleName) : roleName);
            }
        }
        
        ModelAndView model = new ModelAndView();
        model.addObject("pageNo", pageNo);
        model.addObject("pageSize", pageSize);
        model.addObject("page", page);
        model.addObject("name_para", name_para);
        model.addObject("tiptype_para", tiptype_para);
        model.addObject("is_confirmed_para", is_confirmed_para);
        
        model.addObject("message", message);
        model.setViewName("auto_monitor_remind");
        return model;
    }
    
    @RequestMapping(value = action + "confirmed.action")
    public ModelAndView confirmed(HttpServletRequest request) {
        String message = "";
        String error = "";
        try {
            String id = request.getParameter("id");
            AutoMonitorTip entity= adminAutoMonitorTipService.findById(id);
            if (entity!=null) {
                entity.setIs_confirmed(1);
                adminAutoMonitorTipService.update(entity);
                tipService.deleteTip(entity.getId().toString());
            }
            message = "操作成功";
        } catch (BusinessException e) {
            error = e.getMessage();
        } catch (Throwable t) {
            logger.error(" error ", t);
            error = ("[ERROR] 服务器错误");
        } 
        
        ModelAndView model = new ModelAndView();
        model.addObject("message", message);
        model.addObject("error", error);
        model.setViewName("redirect:/" + action + "list.action");
        return model;
    }
 
}