zhuguifei
2026-03-10 2c1fd10c6fbabb8e9f0e9f07fe66fb36c008e883
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
package com.shlanbao.tzsc.pms.msg.info.controller;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import com.shlanbao.tzsc.base.mapping.MdEquipment;
import com.shlanbao.tzsc.pms.sys.user.beans.UserBean;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.shlanbao.tzsc.base.controller.BaseController;
import com.shlanbao.tzsc.base.mapping.MsgInfo;
import com.shlanbao.tzsc.base.model.DataGrid;
import com.shlanbao.tzsc.base.model.Json;
import com.shlanbao.tzsc.base.model.PageParams;
import com.shlanbao.tzsc.pms.msg.info.beans.MsgInfoBean;
import com.shlanbao.tzsc.pms.msg.info.service.MsgInfoServiceI;
import com.shlanbao.tzsc.utils.tools.StringUtil;
 
/**
 * 机台通知信息管理控制类 增删改查操作
 * @author yangbo
 *
 */
@Controller
@RequestMapping("/pms/msg")
public class MsgInfoController extends BaseController{
    protected Logger log = Logger.getLogger(this.getClass());
    @Autowired
    protected MsgInfoServiceI msgInfoService;
    
    @RequestMapping("/gotoMsgInfo")
    public String gotoMsgInfo(HttpServletRequest request){
        //设置当前用户的操作 控制审批或者签发按钮的显示
        try {
            request.setAttribute("msgOperator", msgInfoService.getCurrUserOperator());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/pms/msg/info/msgInfo";
    }
    
    @RequestMapping("/gotoMsgInfoForm")
    public String gotoMsgInfoForm(String id,HttpServletRequest request){
        try {
            if(id!=null){
                MsgInfoBean msgInfoById = msgInfoService.getMsgInfoById(id);
//                List<MdEquipment> mdEquipments = msgInfoService.queryMdequipment();
                //组装告警信息中设备选择状态
//                msgInfoService.getMsgEqu(msgInfoById,mdEquipments);
                if(StringUtil.notNull(id)){
                    request.setAttribute("msgInfo", msgInfoById);
                }
                //查询设备表
//                request.setAttribute("mdEquipments", mdEquipments);
            }
 
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/pms/msg/info/msgInfoForm";
    }
    @RequestMapping("/gotoMsgInfoApprove")
    public String gotoMsgInfoApprove(String id,HttpServletRequest request){
        try {
            if(StringUtil.notNull(id))
                request.setAttribute("msgInfo", msgInfoService.getMsgInfoBeanById(id));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/pms/msg/info/msgInfoApprove";
    }
    @RequestMapping("/gotoMsgInfoIssuer")
    public String gotoMsgInfoIssuer(String id,HttpServletRequest request){
        try {
            if(StringUtil.notNull(id))
                request.setAttribute("msgInfo", msgInfoService.getMsgInfoBeanById(id));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/pms/msg/info/msgInfoIssuer";
    }
    
    @RequestMapping("/openMsgInfoView")
    public String openMsgInfoView(String id,HttpServletRequest request){
        try {
            if(StringUtil.notNull(id)){
                request.setAttribute("msgInfo", msgInfoService.getMsgInfoBeanById(id));
                request.setAttribute("msgInfos", msgInfoService.getMsgInfoApprove(id));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/pms/msg/info/msginfoView";
    }
 
    /**
     *
     * @param msgInfo
     * @return
     */
    @ResponseBody
    @RequestMapping("/saveOrUpdateMsgInfo")
    public Json saveOrUpdateMsgInfo(MsgInfo msgInfo){
        Json json = new Json();
        try {
            Json st= msgInfoService.addMsgInfo(msgInfo);
            if(st.isSuccess()==false){
                json.setMsg(st.getMsg());
                json.setSuccess(false);        
            }else{        
                json.setMsg("操作成功");
                json.setSuccess(true);
            }
        } catch (Exception e) {
            json.setMsg("操作失败");
            json.setSuccess(false);
            e.printStackTrace();
        }
        return json;
    }
    
    
    /**
     * 保存审批信息,更改机台通知信息发布状态
     * @param msgInfo
     * @return
     */
    @ResponseBody
    @RequestMapping("/saveMsgInfo")
    public Json saveMsgInfo(MsgInfo msgInfo){
        Json json = new Json();
        try {
            msgInfoService.saveMsgInfo(msgInfo);
            json.setMsg("操作成功");
            json.setSuccess(true);
        } catch (Exception e) {
            json.setMsg("操作失败");
            json.setSuccess(false);
            e.printStackTrace();
        }
        return json;
    }
 
    /**
     * @param msgInfo id
     * @return
     * @desc 保存消息的推送状态
     */
    @ResponseBody
    @RequestMapping("/saveMsgSend")
    public Json saveMsgSend(MsgInfo msgInfo){
        Json json = new Json();
        try {
            Map<String,Object> param = new HashMap<>();
            param.put("msg",msgInfo);
            //需要推送到wct的设备code
            param.put("eid",msgInfo.getEid());
            param.put("type",msgInfo.getSendType());
            boolean b = msgInfoService.pushToWctOrPms(param);
            if(b){
                msgInfoService.addMsgInfo(msgInfo);
                json.setMsg("操作成功");
                json.setSuccess(true);
            }else {
                json.setMsg("操作失败");
                json.setSuccess(false);
            }
 
        } catch (Exception e) {
            json.setMsg("操作失败");
            json.setSuccess(false);
            e.printStackTrace();
 
        }
        return json;
    }
    
    @ResponseBody
    @RequestMapping("/queryMsgInfo")
    public DataGrid queryMsgInfo(MsgInfoBean msgInfo,PageParams pageParams){
        try {
            DataGrid gd = msgInfoService.queryMsgInfo(msgInfo, pageParams);
            return gd;
        } catch (Exception e) {
            log.error("查询机台通知信息失败!", e);
        }
        return null;
    }
    
    @ResponseBody
    @RequestMapping("/deleteMsgInfo")
    public Json deleteMsgInfo(String id){
        Json json = new Json();
        try {
            msgInfoService.deleteMsgInfoById(id);
            json.setSuccess(true);
            json.setMsg("操作成功!");
        } catch (Exception e) {
            json.setSuccess(false);
            json.setMsg("操作失败");
            e.printStackTrace();
        }
        return json;
    }
 
 
    /**
     * 批量删除
     * @param ids
     * @return
     */
    @ResponseBody
    @RequestMapping("/batchDeleteMsgInfo")
    public Json batchDeleteMsgInfo(String ids){
        Json json = new Json();
        try {
            msgInfoService.batchDeleteMsgInfo(ids);
            json.setSuccess(true);
            json.setMsg("操作成功!");
        } catch (Exception e) {
            json.setSuccess(false);
            json.setMsg("操作失败");
            e.printStackTrace();
        }
        return json;
    }
    
    @ResponseBody
    @RequestMapping("/getMsgInfo")
    public List<MsgInfoBean> getMsgInfo(){
        try {
            return msgInfoService.getMsgInfo();
        } catch (Exception e) {
            log.error("获取通知信息失败!", e);
        }
        return null;
    }
 
    @ResponseBody
    @RequestMapping("/getEquInfo")
    public List<MdEquipment> getEquInfo(UserBean userBean){
        try {
            List<MdEquipment> equInfo = msgInfoService.getEquInfo(userBean);
            //userBean  id为eid(告警下设备id集合)
            MsgInfoBean msg  = new MsgInfoBean();
            //组装告警信息中设备选择状态
            if(userBean!=null&&!StringUtils.isEmpty(userBean.getId())){
                msg.setEid(userBean.getId());
                msgInfoService.getMsgEqu(msg,equInfo);
            }
 
            return equInfo;
        } catch (Exception e) {
            log.error("获取设备信息失败!", e);
        }
        return null;
    }
 
 
    /**
     * 跳转到wct在线设备弹出层
     * @return
     */
    @RequestMapping("/goToWctOnlineEquJsp")
    public String goToWctOnlineEquJsp(){
 
        return "/pms/msg/info/wctOnlineEqu";
    }
 
    /**
     * @return  wct websocket在线的设备
     */
    @ResponseBody
    @RequestMapping("/getWctOnlineEqu")
    public List<MdEquipment> getWctOnlineEqu(){
        List<MdEquipment>  list= new ArrayList<>();
        List<MdEquipment> wctOnlineEqu = msgInfoService.getWctOnlineEqu();
        if(wctOnlineEqu!=null) list.addAll(wctOnlineEqu);
        return list;
    }
}