cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
package cn.ksource.web.controller.business.pages.xtgl;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
 
import cn.ksource.beans.GG_USER;
import cn.ksource.core.dao.BaseDao;
import cn.ksource.core.dao.SqlParameter;
import cn.ksource.core.page.PageInfo;
import cn.ksource.core.util.AjaxUtil;
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.JsonUtil;
import cn.ksource.core.util.ParamsMapUtil;
import cn.ksource.core.util.StringUtil;
import cn.ksource.core.web.SysInfo;
import cn.ksource.core.web.WebUtil;
import cn.ksource.web.Constants;
import cn.ksource.web.facade.BmglFacade;
import cn.ksource.web.facade.YhglFacade;
/**
 * 角色权限--用户管理控制器
 * @note:
 * @version
 * @author sxj
 * @date June 28, 2016 10:35:44 AM
 */
@Controller
@RequestMapping("/business/pages/xtgl/yhgl")
public class YhglController {
    
    @Autowired
    private YhglFacade yhglFacade;
    
    @Autowired 
    private BmglFacade bmglFacade;
    
    @Resource(name="baseDao")
    private BaseDao baseDao;
    
    
    @RequestMapping("yhtreeList.html")
    public ModelAndView yhtreeList(HttpServletRequest request,HttpServletResponse response){
        ModelAndView modelAndView =  new ModelAndView("/business/pages/xtgl/yhgl/yhtreeList");
        
        //查询树形结构
        List<Map> trees = bmglFacade.queryBmYjList(request);
        System.out.println(JsonUtil.list2Json(trees));
        modelAndView.addObject("bms", trees);
        
        return modelAndView;
    }
    
    /**
     * 跳转到用户管理列表页
     * @param request
     * @param response
     */
    @RequestMapping("yhList.html")
    public ModelAndView yhList(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/xtgl/yhgl/yhList");
        String bmId = request.getParameter("id");
        modelAndView.addObject("bmId", bmId);
        modelAndView.addObject("bmName", bmglFacade.getBmNameById(bmId));
        List<Map> list = baseDao.queryForList("select A.ID,A.DESKTOP_NAME from GG_DESKTOP A");
        
        Map deskMap = new HashMap();
        for(Map map : list) {
            deskMap.put(map.get("ID"), map.get("DESKTOP_NAME"));
        }
        modelAndView.addObject("deskdata",deskMap);
        return modelAndView;
    } 
    
    
    /**
     * 查询用户管理列表数据
     */
    @RequestMapping("yhData.html")
    public ModelAndView partnerYhData(HttpServletRequest request,PageInfo pageInfo) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/xtgl/yhgl/yhData");
        //定义参数Map
        Map<String,String> params = ParamsMapUtil.getParameterMap(request);
        PageInfo info = yhglFacade.yhData(pageInfo,params);
        modelAndView.addObject("info", info);
        return modelAndView;
    }
 
    /**
     * 查询用户管理列表数量
     */
    @RequestMapping("yhCount.html")
    public void yhCount(HttpServletRequest request,HttpServletResponse response) {
        //定义参数Map
        Map<String,String> params = ParamsMapUtil.getParameterMap(request);
        int count = yhglFacade.yhCount(params);
        WebUtil.write(response, String.valueOf(count));
    }
    
    @RequestMapping("addYh.html")
    public ModelAndView onAddYhLoad(HttpServletRequest request,HttpServletResponse response){
        String id = request.getParameter("id");
        String ssbm = request.getParameter("ssbm");
        String bmName = AjaxUtil.decode(request.getParameter("bmName"));
        ModelAndView view = new ModelAndView("/business/pages/xtgl/yhgl/addYh");
        if(!StringUtil.notEmpty(id)) {
            Map resultMap = yhglFacade.queryPartnerUserNum();
            String result = ConvertUtil.obj2StrBlank(resultMap.get("result"));
            if(result.equals("2")) {
                view.addObject("resultMap", resultMap);
                return view;
            }
        }
        
        String show = request.getParameter("show");
        Map info = new HashMap();
        if (StringUtils.isNotBlank(id)) {
            info = baseDao.queryForMap("SELECT A.* FROM GG_USER A WHERE A.ID=:id ",new SqlParameter("id",id));
            ssbm = ConvertUtil.obj2StrBlank(info.get("SSBMBH"));
        }
        List<Map> list = baseDao.queryForList("select A.ID,A.DESKTOP_NAME from GG_DESKTOP A");
        view.addObject("info",info);
        
        Map deskMap = new HashMap();
        for(Map map : list) {
            deskMap.put(map.get("ID"), map.get("DESKTOP_NAME"));
        }
        view.addObject("deskdata",deskMap);
        view.addObject("show",show);
        view.addObject("ssbm", ssbm);
        view.addObject("bmName", bmName);
        return view;
    }
    
    @RequestMapping("subBm.html")
    public ModelAndView subBm(HttpServletRequest request){
        ModelAndView view = new ModelAndView("/business/pages/xtgl/yhgl/subBm");
        List<Map> result = bmglFacade.getBmtree();
        String bmName = AjaxUtil.decode(request.getParameter("bmName"));
        
        view.addObject("trees", result);
        view.addObject("checkSl", new SqlParameter("bmId",request.getParameter("bmId")).addValue("bmName", bmName));
        return view;
    }
    
    
    
    @RequestMapping("addYhSubmit.html")
    public ModelAndView onAddYhSubmit(GG_USER user,HttpServletRequest request,HttpServletResponse response){
        
        String ssbm = request.getParameter("ssbm");
        String id=user.getId();
        if(!StringUtil.notEmpty(id)) {
            Map resultMap = yhglFacade.queryPartnerUserNum();
            String result = ConvertUtil.obj2StrBlank(resultMap.get("result"));
            if(result.equals("2")) {
                
                return WebUtil.sysInfoPage(request, "操作失败!您最多只能添加"+resultMap.get("maxNum")+"个启用的员工账户!",
                        "window.top.hideDialog('0');",
                        SysInfo.Error,"");
            }
        }
        
        
        if(StringUtil.isBlank(user.getId())){
            user.setAccounttype(1);
            user.setSsbmbh(ssbm);
        }else{
            user.setSsbmbh(ssbm);
        }
        
        GG_USER myUser = yhglFacade.addOrUpdateGG_USER(user);
        
        String show = request.getParameter("show");
        if (StringUtils.isBlank(show)) {
            return WebUtil.sysInfoPage(request, "操作成功!",
                    "window.top.document.getElementById('myiframe').contentWindow.query('"+ssbm+"');window.top.hideDialog('0');",
                    SysInfo.Success,"");
            
        //从主界面【我的资料】处点击而来
        } else {
            return WebUtil.goSysInfoPage(request,"操作成功!信息将会在重新登录后生效!",
                    "window.top.closeDialog(0);" ,
                    SysInfo.Success);
        }
        
    }
    
    @RequestMapping("checkUser.html")
    public void checkUser(HttpServletRequest request,HttpServletResponse response){
        String loginname = request.getParameter("loginname");
        if(StringUtil.isNotBlank(loginname)){
            boolean loginNameExists = yhglFacade.isLoginNameExists(loginname);
            if(!loginNameExists){
                WebUtil.write(response,"0");
            }else{
                WebUtil.write(response,"1");
            }
        }else{
            WebUtil.write(response,"1");
        }
    }
    
    /**
     * 跳转到用户详情页面
     */
    @RequestMapping("userDetail.html")
    public ModelAndView userDetail(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/xtgl/yhgl/userDetail");
        String id = request.getParameter("id");
        
        Map user = yhglFacade.queryUserDetail(id);
        
        
        modelAndView.addObject("info", user);
        return modelAndView;
    }
    
    @RequestMapping("initPwd.html")
    public void onInitPwd(HttpServletRequest request,HttpServletResponse response){
        String id = request.getParameter("id");
        String loginname = request.getParameter("loginname");
        
        if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(loginname)) {
            yhglFacade.execInitUserPwd(id, loginname);
        }
        WebUtil.write(response, "1");
    }
    
    @RequestMapping("disable.html")
    public void disable(HttpServletRequest request,HttpServletResponse response){
        String id = request.getParameter("id");
        String status=request.getParameter("status");
        
        
        if (StringUtils.isNotBlank(id)) {
            
            yhglFacade.execDisableUser(id,status);
        
        }
        
        WebUtil.write(response, "1");
    }
    
    /**
     * 用户选择器
     * @author chenlong 
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("userSelector.html")
    public String userSelector(Model model,HttpServletRequest request,HttpServletResponse response){
        //查询树形结构
        List<Map> trees = bmglFacade.queryBmYjList(request);
        System.out.println(JsonUtil.list2Json(trees));
        model.addAttribute("bms", trees);
        return "/business/pages/xtgl/yhgl/userSelector";
    }
    
    /**
     * 用户列表选择页
     * @param request
     * @param response
     */
    @RequestMapping("userList.html")
    public String userList(Model model,HttpServletRequest request) {
        String bmId = request.getParameter("id");
        model.addAttribute("bmId", bmId);
        return "/business/pages/xtgl/yhgl/userList";
    } 
    
    
    /**
     * 查询用户管理列表数据
     */
    @RequestMapping("userListData.html")
    public ModelAndView userListData(HttpServletRequest request,PageInfo pageInfo) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/xtgl/yhgl/userListData");
        String bmId = request.getParameter("bmId");
        PageInfo info = yhglFacade.userListData(pageInfo,bmId);
        modelAndView.addObject("info", info);
        return modelAndView;
    }
 
    /**
     * 查询用户管理列表数量
     */
    @RequestMapping("userListCount.html")
    public void userListCount(HttpServletRequest request,HttpServletResponse response) {
        String bmId = request.getParameter("bmId");
        int count = yhglFacade.userListCount(bmId);
        WebUtil.write(response, String.valueOf(count));
    }
    
    
    
    @RequestMapping("userSelectorMore.html")
    public String userSelectorMore(Model model,HttpServletRequest request,HttpServletResponse response){
        //查询树形结构
        List<Map> trees = bmglFacade.queryBmYjList(request);
        System.out.println(JsonUtil.list2Json(trees));
        model.addAttribute("bms", trees);
        return "/business/pages/xtgl/yhgl/userSelectorMore";
    }
    
    @RequestMapping("userListMore.html")
    public String userListMore(Model model,HttpServletRequest request) {
        String bmId = request.getParameter("id");
        model.addAttribute("bmId", bmId);
        return "/business/pages/xtgl/yhgl/userListMore";
    } 
    
    /**
     * 查询用户管理列表数据
     */
    @RequestMapping("userListDataMore.html")
    public ModelAndView userListDataMore(HttpServletRequest request,PageInfo pageInfo) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/xtgl/yhgl/userListDataMore");
        String bmId = request.getParameter("bmId");
        PageInfo info = yhglFacade.userListData(pageInfo,bmId);
        modelAndView.addObject("info", info);
        return modelAndView;
    }
 
    /**
     * 查询用户管理列表数量
     */
    @RequestMapping("userListCountMore.html")
    public void userListCountMore(HttpServletRequest request,HttpServletResponse response) {
        String bmId = request.getParameter("bmId");
        int count = yhglFacade.userListCount(bmId);
        WebUtil.write(response, String.valueOf(count));
    }
}