3
13693261870
2022-09-16 63ba114e70e380442fcbed4a5157ee52c9491216
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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
package com.landtool.lanbase.modules.api.controller;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.landtool.lanbase.common.utils.ComplexPropertyPreFilter;
import com.landtool.lanbase.common.utils.PageUtils;
import com.landtool.lanbase.common.utils.Query;
import com.landtool.lanbase.common.utils.Result;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.sys.entity.SysDiyApp;
import com.landtool.lanbase.modules.sys.entity.SysSysteminfo;
import com.landtool.lanbase.modules.sys.entity.SysSysteminfoApply;
import com.landtool.lanbase.modules.sys.service.SysDiyAppService;
import com.landtool.lanbase.modules.sys.service.SysSysteminfoApplyService;
import com.landtool.lanbase.modules.sys.service.SysSysteminfoService;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
 
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import java.io.IOException;
import java.net.URLDecoder;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;
 
/**
 * @Description: 应用程序模块提供的api
 * @Author: zimao.guo
 * @Date: 9:53 2018/1/31
 */
@Controller
@RequestMapping(path = "/api/sys/systeminfo/")
@Api(value = "", tags = {"应用程序相关接口"})
public class SysSysteminfoApiController {
 
    @Autowired
    private SysSysteminfoService systeminfoService;
    @Autowired
    private SysSysteminfoApplyService sysSysteminfoApplyService;
    @Autowired
    private SysDiyAppService sysDiyAppService;
 
    @Autowired
    private SysTemPropertyConfig sysProps;
 
    /**
     * @Description: 获取应用程序列表
     */
    @GetMapping(path = "/queryTopList")
    @ApiOperation(value = "获取应用程序列表", notes = "获取应用程序列表")
    @ResponseBody
    public void queryTopList(@ApiParam(name = "userid", value = "用户ID" ,required = true) @RequestParam(name = "userid") Integer userid,
                             @ApiParam(name = "num", value = "数量" ,required = true) @RequestParam(name = "num") Integer num,
                             @ApiParam(name = "type", value = "系统分类") @RequestParam(name = "type" , required = false) String type,
                             HttpServletResponse response, HttpServletRequest request) throws IOException {
        ComplexPropertyPreFilter filter = new ComplexPropertyPreFilter();
        Map<String, Object> map = new HashMap<>();
        map.put("userid", userid);
        map.put("num", num);
        Map<String, Object> usermap = new HashMap<>();
        usermap.put("userid", userid);
        usermap.put("num", num);
        if(type != null && type.length() != 0){
            type =java.net.URLDecoder.decode(type);
        }
        usermap.put("type", type);
        String typeStr = "";
        List<String> typeList = new ArrayList<String>();;
        if(type != null && type.length() !=0){
            type = URLDecoder.decode(type,"UTF-8");
            String[] typelist = type.split("\\,");
            for (String t:typelist) {
                if(typeStr.length()==0){
                    typeStr+="'"+t+"'";
                }else{
                    typeStr+=",'"+t+"'";
                }
                typeList.add(t);
            }
            typeStr = type;
        }
        map.put("type", typeList);
        List<SysSysteminfo> list;
        list = systeminfoService.queryTopUserList(usermap);//获取用户设置应用程序
        if(list.size() == 0) {
            list = systeminfoService.queryTopList(map);
        }
        response.setHeader("Content-Type", "application/json;charset=UTF-8");
        response.getWriter().write(JSONObject.toJSONString(list, filter));
    }
 
    /**
     * @Description: 获取用户所属应用程序列表
     * @Author: xiaoxuan.xie
     * @Date: 09:30 2018/4/20
     * @return: String
     * @see SysSysteminfo
     */
    @GetMapping(path = "/getSysListByUserId/{userid}")
    @ApiOperation(value = "获取用户所属应用程序列表", notes = "")
    public void GetMapUrlObject(@ApiParam(name = "userid", value = "用户Id", required = true) @PathVariable(name = "userid") Long userid, HttpServletResponse response, HttpServletRequest request) throws IOException {
        ComplexPropertyPreFilter filter = new ComplexPropertyPreFilter();
        List<SysSysteminfo> list = systeminfoService.getSysListByUserId(userid);
        response.setHeader("Content-Type", "application/json;charset=UTF-8");
        response.getWriter().write(JSONObject.toJSONString(list, filter));
    }
 
    /**
     * @Description: 获取应用程序列表(排除用户设置系统导航显示)
     * @Author: xiaoxuan.xie
     * @Date: 18:00 2018/5/10
     * @return: String
     * @see SysSysteminfo
     */
    @GetMapping(path = "/getSysListIgnoredUserId")
    @ApiOperation(value = "获取应用程序列表(排除用户设置系统导航显示)", notes = "")
    @ResponseBody
    public String getSysListIgnoredUserId(@ApiParam(name = "userid", value = "用户Id", required = true) @RequestParam(name = "userid") Integer userid,
                                        @ApiParam(name = "limit", value = "每页记录数", required = true) @RequestParam(name = "limit") Integer limit,
                                        @ApiParam(name = "page", value = "当前页数", required = true) @RequestParam(name = "page") Integer page,
                                        @ApiParam(name = "appfullname", value = "系统名称") String appfullname,
                                        @ApiParam(name = "systype", value = "系统类型") String systype,
                                          @ApiParam(name = "otherids", value = "应用系统ids") String otherids,
                                        HttpServletResponse response, HttpServletRequest request) throws IOException {
        Map<String, Object> params = new HashMap<>();
        params.put("userid", userid);
        params.put("limit", limit);
        params.put("page", page);
        if(appfullname != null && !appfullname.isEmpty()) {
            params.put("appfullname", appfullname);
        }
        if(systype != null && !systype.isEmpty()) {
            params.put("systype", systype);
        }
        if(otherids != null && !otherids.isEmpty()){
            params.put("otherids",otherids);
        }
        Query query = new Query(params);
        List<SysSysteminfo> systeminfoList = systeminfoService.getSysListIgnoredUserId(query);
        int total = systeminfoService.querySysListIgnoredUserIdTotal(query);
 
        PageUtils pageUtil = new PageUtils(systeminfoList, total, query.getLimit(), query.getPage());
 
        StringBuilder rsb = new StringBuilder();
        rsb.append("{'totalCount':'" + total);
        rsb.append("','topics':[");
        for (Integer i = 0; i < systeminfoList.size(); i++) {
            if (i != 0) {
                rsb.append(",");
            }
            rsb.append("{'appid':'" + systeminfoList.get(i).getAppid() + "'");//应用程序ID
            rsb.append(",'appfullname':'" + systeminfoList.get(i).getAppfullname() + "'");//系统名称
            rsb.append(",'apptype':'" + systeminfoList.get(i).getSystype() + "'");//系统类型
            rsb.append("}");
        }
        rsb.append("]}");
 
        return rsb.toString();
    }
 
    /**
     * @Description: 设置用户显示应用程序
     * @Author: xiaoxuan.xie
     * @Date: 16:00 2018/5/11
     * @return: String
     * @see SysSysteminfo
     */
    @GetMapping(path = "/addUserShowSystemInfo")
    @ApiOperation(value = "设置用户显示应用程序", notes = "")
    @ResponseBody
    public String addUserShowSystemInfo(@ApiParam(name = "userid", value = "用户Id", required = true) @RequestParam(name = "userid") Integer userid,
                                          @ApiParam(name = "appids", value = "应用程序IDs", required = true) @RequestParam(name = "appids") String appids,
                                        @ApiParam(name = "type", value = "参数type") @RequestParam(name = "type" , required = false) String type,
                                          HttpServletResponse response, HttpServletRequest request) throws IOException {
        if(appids != null && appids.length() != 0){
            String[] ids = appids.split("\\,");
            for (String id:ids) {
                SysDiyApp sysDiyApp = new SysDiyApp();
                sysDiyApp.setAppid(Integer.parseInt(id));
                sysDiyApp.setUserid(userid);
                sysDiyApp.setOrderid(0);
                if(type != null && type.length()!=0){
                    type =java.net.URLDecoder.decode(type);
                }
                sysDiyApp.setType(type);
                sysDiyAppService.save(sysDiyApp);
            }
        }
        return "新增成功";
    }
 
    /**
     * @Description: 根据id获取应用程序信息
     * @Author: dsh
     * @Date: 2018-05-28
     * @return: String
     * @see SysSysteminfo
     */
    @GetMapping(path = "/getSysteminfoById/{appid}")
    @ApiOperation(value = "根据id获取应用程序信息", notes = "")
    @ResponseBody
    public String getSysteminfoById(@ApiParam(name = "appid", value = "appid", required = true) @PathVariable(name = "appid") Long appid){
        StringBuilder rsb = new StringBuilder();
        SysSysteminfo info = systeminfoService.getInfoById(appid);
        Map<String,Object> map = new HashMap<>();
        if(info != null){
            map.put("appid", info.getAppid());
            map.put("appfullname", info.getAppfullname());
            map.put("apptype", info.getSystype());
            map.put("sysaddress", info.getSysaddress());
            map.put("maguser",info.getMaguser());
        }
        return JSON.toJSONString(map);
    }
 
    /**
     * @Description: 获取全部应用程序列表
     */
    @GetMapping(path = "/queryAllList")
    @ApiOperation(value = "获取全部应用程序列表", notes = "获取全部应用程序列表")
    @ResponseBody
    public String queryAllList(@ApiParam(name = "sysstatus", value = "系统状态")  Integer sysstatus,
                               @ApiParam(name = "iscaslogin", value = "集成单点登录")  Integer iscaslogin,
                             @ApiParam(name = "appfullname", value = "系统名称") String appfullname,
                             @ApiParam(name = "systype", value = "系统类型") String systype,
                             HttpServletResponse response, HttpServletRequest request) throws IOException {
        ComplexPropertyPreFilter filter = new ComplexPropertyPreFilter();
        Map<String, Object> params = new HashMap<String,Object>();
        if(appfullname != null && !appfullname.isEmpty()) {
            params.put("appfullname", URLDecoder.decode(appfullname));
        }
        if(systype != null && !systype.isEmpty()) {
            params.put("systype", systype);
        }
        if(sysstatus != null && sysstatus!=0) {
            params.put("sysstatus", sysstatus);
        }
        if(iscaslogin != null) {
            params.put("iscaslogin", iscaslogin);
        }
        params.put("isadmin", 1);//暂时先查全部
        params.put("currentsystemid",sysProps.getCurrentSystemId());//过滤本系统
        List<SysSysteminfo> list = systeminfoService.queryAllList(params);
        StringBuilder rsb = new StringBuilder();
 
        List<Map<String,Object>> maps = new LinkedList<>();
        for (Integer i = 0; i < list.size(); i++) {
 
            Map<String,Object> map = new HashMap<>();
            map.put("appid",list.get(i).getAppid());
            map.put("appfullname",list.get(i).getAppfullname());
            map.put("appname",list.get(i).getAppname());
            map.put("systype",list.get(i).getSystype());
            map.put("chinesename",(list.get(i).getChinesename() != null ? list.get(i).getChinesename(): ""));
            map.put("unitname",(list.get(i).getUnitname() != null ? list.get(i).getUnitname(): ""));
            map.put("sysaddress",list.get(i).getSysaddress());
            map.put("sysimgurl",list.get(i).getSysimgurl());
            map.put("sysstatus",list.get(i).getSysstatus());
            map.put("browser",list.get(i).getBrowser());
            map.put("iscaslogin",list.get(i).getIscaslogin());
 
            maps.add(map);
        }
        return JSON.toJSONString(maps);
    }
 
    /**
    * @Description:
    * @author ykm
     * @param
    * @return 应用程序ID数组
    * @date 2019/03/12 14:13
    */
    @GetMapping(path = "/getSysteminfoIdList")
    @ApiOperation(value = "获取应用程序所有ID", notes = "")
    @ResponseBody
    public String getSysteminfoIdList(){
        List<String> list = new LinkedList<>();
        List<SysSysteminfo> systeminfoList = systeminfoService.queryListAll();
        for(SysSysteminfo sysSysteminfo : systeminfoList) {
            list.add(sysSysteminfo.getAppid().toString());
        }
        return list.toString();
    }
 
    
    @GetMapping(path = "/isAdmitSysByUserid")
    @ApiOperation(value = "判断该services是否是用户能访问的系统", notes = "")
    @ResponseBody
    public boolean  isAdmitSysByUserid(String service, String userid){
        Map<String,Object> map=new HashMap<String, Object>();
        map.put("userid", userid);
        map.put("service", service);
       int count = systeminfoService.isAdmitSysByUserid(map);
       return  count>0?true:false;
 
    }
 
//    /**
//     * 接受访问申请
//     * add by zhangshouxin 2021 2 25
//     * @param userid 用户id
//     * @param appid  appid
//     * @return
//     */
//    @GetMapping(path = "/applyAppAdmission")
//    @ApiOperation(value = "申请开放用户访问应用系统", notes = "")
//    @ResponseBody
//    public String  applyAppAdmission(Integer appid, Integer userid){
//        Map<String,Object> map=new HashMap<String, Object>();
//        map.put("userid", userid);
//        map.put("appid", appid);
//        //TODO 查询申请条目是否存在,若存在返回该申请已存在,否则进入申请流程
//        SysSysteminfoApply existdata= sysSysteminfoApplyService.byId(map);
//        if(existdata!=null||existdata.getId()>0){
//           return "不可重复申请";
//        }
//        SysSysteminfoApply sysSysteminfoApply=new SysSysteminfoApply();
//        sysSysteminfoApply.setAppid(appid);
//        sysSysteminfoApply.setApplytime(Timestamp.valueOf(LocalDateTime.now()));
//        sysSysteminfoApply.setUserid(userid);
//        sysSysteminfoApply.setAuditresult(0);
//        Integer result=sysSysteminfoApplyService.add(sysSysteminfoApply);
//        return  result>0?"申请成功":"申请失败";
//
//    }
 
 
//    /**
//     * 应用程序查看申请
//     */
//    @RequestMapping(value = "/applySystemPermission", method = {RequestMethod.GET})
//    public Result applySystemPermission(Integer appid) {
//        Map<String, Object> map = new HashMap<String, Object>();
//        Long userid = getUserId();
//        map.put("appid", appid);
//        map.put("userid", userid);
//        SysSysteminfoApply sysSysteminfoApply = sysSysteminfoApplyService.byId(map);
//        String result = "";
//        if (sysSysteminfoApply != null) {
//            //用户已申请
//            if(sysSysteminfoApply.getAuditresult() == 0) {
//                result = "已申请,管理员未批复!";
//            } else if(sysSysteminfoApply.getAuditresult() == 1) {
//                result = "管理员已通过申请,请重新尝试!";
//            } else if(sysSysteminfoApply.getAuditresult() == 2) {
//                result = "管理员已驳回申请,请联系管理员!驳回意见:" + sysSysteminfoApply.getAuditopinion();
//            }
//        } else {
//            //用户未申请
//            SysSysteminfoApply systeminfoApply = new SysSysteminfoApply();
//            systeminfoApply.setAppid(appid);
//            systeminfoApply.setUserid(userid.intValue());
//            Timestamp audittime = new Timestamp(new Date().getTime());
//            systeminfoApply.setApplytime(audittime);
//            systeminfoApply.setAuditresult(0);//待批复
//            int id = sysSysteminfoApplyService.add(systeminfoApply);
//            result = "已通知管理员!";
//        }
//        return Result.ok().put("result", result);
//    }
 
 
}