1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
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
package com.landtool.lanbase.modules.sys.controller;
 
import com.alibaba.fastjson.JSONObject;
import com.landtool.lanbase.modules.sys.entity.SysSysteminfoApply;
import com.landtool.lanbase.modules.sys.service.SysSysteminfoApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
 
import java.io.IOException;
import java.util.*;
 
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import com.landtool.lanbase.modules.org.entity.OrgUser;
import com.landtool.lanbase.modules.org.service.OrgUserService;
import com.landtool.lanbase.modules.sys.entity.SysResource;
import com.landtool.lanbase.modules.sys.entity.SysSysteminfo; 
import com.landtool.lanbase.modules.sys.service.SysSysteminfoService;
import com.landtool.lanbase.common.annotation.LogAction;
import com.landtool.lanbase.common.annotation.SysLog;
import com.landtool.lanbase.common.utils.PageUtils;
import com.landtool.lanbase.common.utils.Query;
import com.landtool.lanbase.common.utils.Result;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
/**
 * @author lanbase
 * @Description: TODO(系统管理信息表)
 * @date 2018-01-16 09:04:50
 */
@RestController
@RequestMapping("/sys/systeminfo")
@Api(value = "", tags = {"系统应用程序信息"})
public class SysSysteminfoController extends AbstractController{
 
    @Autowired
    private SysSysteminfoService systeminfoService;
    
    @Autowired
    private OrgUserService userService;
 
    @Autowired
    private SysSysteminfoApplyService sysSysteminfoApplyService;
 
    /**
     * 列表
     */
    @LogAction("平台管理,应用程序管理,应用程序查询,查询")
    @RequestMapping(value ="/list", method ={RequestMethod.POST, RequestMethod.GET})
//    @RequiresPermissions("sys:systeminfo:list")
    @RequiresPermissions(value = {"sys:systeminfo:list","sys:systeminfo:edit"}, logical = Logical.OR)
    @ApiOperation(
            value = "所有系统应用程序信息列表",
            notes = ""
            )
    public Result list(@ApiParam(name="params",value="",required=true)@RequestParam Map<String, Object> params){
        //查询列表数据
        Set<String> permissions = userService.getUserPermissions(getUserId());
        if(permissions.contains("org_user_admin")){//管理员可以查看所有应用程序
            params.put("isadmin", 1);
        }
        else{//主管单位下的用户 or主管单位的单位管理员 为自己 or 自己录的应用程序 or 系统负责人为自己的应用程序
            params.put("isadmin", 0);
        }
        OrgUser orgUser = (OrgUser) SecurityUtils.getSubject().getPrincipal();
        params.put("userid", orgUser.getUserid());
        Query query = new Query(params);
         List<SysSysteminfo> systeminfoList = systeminfoService.queryList(query);
         List<SysSysteminfo> list = new ArrayList<SysSysteminfo>();
         for(int i = 0; i < systeminfoList.size(); i++) {
            systeminfoList.get(i).setSystype(getSystemName(systeminfoList.get(i).getSystype()));
            systeminfoList.get(i).setApplycount(sysSysteminfoApplyService.selectCount(systeminfoList.get(i).getAppid().intValue(),0));
            systeminfoList.get(i).setAudityescount(sysSysteminfoApplyService.selectCount(systeminfoList.get(i).getAppid().intValue(),1));
            systeminfoList.get(i).setAuditnocount(sysSysteminfoApplyService.selectCount(systeminfoList.get(i).getAppid().intValue(),2));
            list.add(systeminfoList.get(i));
        }
        int total = systeminfoService.queryTotal(query);
        
        PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
        
        return Result.ok().put("page", pageUtil);
    }
 
    //获取系统中文名称
    private String getSystemName(String name) {
        String SystemName = name;
        if(name.equals("haiyu")) {
            SystemName = "海域";
        }
        if(name.equals("zonghe")) {
            SystemName = "综合";
        }
        if(name.equals("haidao")) {
            SystemName = "海岛";
        }
        if(name.equals("jingji")) {
            SystemName = "经济";
        }
        if(name.equals("huangjing")) {
            SystemName = "环境";
        }
        if(name.equals("zhifa")) {
            SystemName = "执法";
        }
        if(name.equals("yubaojianzai")) {
            SystemName = "预报减灾";
        }
 
        if(name.equals("huanjinganquan")) {
            SystemName = "环境安全";
        }
 
        return SystemName;
    }
 
    /**
     * 信息
     */
    @GetMapping("/info/{appid}")
//    @RequiresPermissions("sys:systeminfo:list")
    @RequiresPermissions(value = {"sys:systeminfo:list","sys:systeminfo:edit"}, logical = Logical.OR)
    @ApiOperation(
            value = "所有应用程序信息",
            notes = ""
            )
    public Result info(@ApiParam(name="appid",value="appId",required=true)@PathVariable("appid") Long appid){
        SysSysteminfo systeminfo = systeminfoService.queryObject(appid);
        
        return Result.ok().put("systeminfo", systeminfo);
    }
    
    /**
     * 保存
     */
    @LogAction("平台管理,应用程序管理,应用程序新增,新增")
    @PostMapping("/save")
    @RequiresPermissions("sys:systeminfo:edit")
    @ApiOperation(
            value = "保存系统应用程序信息",
            notes = ""
            )
    public Result save(@ApiParam(name="应用程序信息对象",value="传入json格式",required=true)@RequestBody SysSysteminfo systeminfo){
        if(systeminfo.getAppfullname() == null || systeminfo.getAppfullname().length() == 0 || systeminfo.getAppname() == null ||
                systeminfo.getAppname().length() == 0 || systeminfo.getSysaddress() == null || systeminfo.getSysaddress().length() == 0){
            return Result.error("保存失败,存在特殊字符,请重新输入!");
        }
        OrgUser orgUser = (OrgUser) SecurityUtils.getSubject().getPrincipal();
        systeminfo.setRcreateuser(orgUser.getUserid());
        if(systeminfo.getAppname()==null || systeminfo.getAppname()==""){
            systeminfo.setAppname(systeminfo.getAppfullname());
        }
        int orderid = systeminfoService.queryMaxOrderid()+1;
        systeminfo.setOrderid(orderid);
        systeminfoService.save(systeminfo);
        
        //保存完后获取对应appid
        int appid = systeminfoService.querySysteminfoWithSEQ();
        return Result.ok().put("appid",appid);
    }
    
    /**
     * 修改
     */
    @LogAction("平台管理,应用程序管理,应用程序修改,修改")
    @PostMapping("/update")
    @RequiresPermissions("sys:systeminfo:edit")
    @ApiOperation(
            value = "修改系统应用程序信息",
            notes = ""
            )
    public Result update(@ApiParam(name="应用程序信息对象",value="传入json格式",required=true)@RequestBody SysSysteminfo systeminfo){
        if(systeminfo.getAppfullname() == null || systeminfo.getAppfullname().length() == 0 || systeminfo.getAppname() == null ||
                systeminfo.getAppname().length() == 0 || systeminfo.getSysaddress() == null || systeminfo.getSysaddress().length() == 0){
            return Result.error("保存失败,存在特殊字符,请重新输入!");
        }
        if(systeminfo.getAppname()==null || systeminfo.getAppname()==""){
            systeminfo.setAppname(systeminfo.getAppfullname());
        }
        systeminfoService.update(systeminfo);
        
        return Result.ok();
    }
    
    /**
     * 删除
     */
    @LogAction("平台管理,应用程序管理,应用程序删除,删除")
    @PostMapping("/delete")
    @RequiresPermissions("sys:systeminfo:edit")
    @ApiOperation(
            value = "删除系统应用程序信息",
            notes = ""
            )
    public Result delete(@ApiParam(name="appids",value="appId",required=true)@RequestBody Long[] appids){
        systeminfoService.deleteBatch(appids);
        
        return Result.ok();
    }
    
    /**
     * 显示系统信息
     */
    @SysLog("显示系统信息")
    @GetMapping("/queryListAll")
    @ApiOperation(
            value = "显示系统信息",
            notes = ""
            )
    public Map<String, Object> queryListAll(){
        Map<String, Object> map = new HashMap<String,Object>();
        List<SysSysteminfo> systemList = systeminfoService.queryListAll();
        map.put("systemList", systemList);
        return map;
    }
 
    /**
     * 所有系统应用程序信息列表
     */
    @RequestMapping(value ="/queryAllList", method ={RequestMethod.GET})
//    @RequiresPermissions("sys:systeminfo:list")
    @RequiresPermissions(value = {"sys:systeminfo:list","sys:systeminfo:edit"}, logical = Logical.OR)
    public Result queryAllList(){
        Map<String, Object> params = new HashMap<String,Object>();
        //查询列表数据
        Set<String> permissions = userService.getUserPermissions(getUserId());
        if(permissions.contains("org_user_admin")){//管理员可以查看所有应用程序
            params.put("isadmin", 1);
        }
        else{//主管单位下的用户 or主管单位的单位管理员 为自己 or 自己录的应用程序 or 系统负责人为自己的应用程序
            params.put("isadmin", 0);
        }
        List<SysSysteminfo> systeminfoList = systeminfoService.queryAllList(params);
        return Result.ok().put("systeminfoList", systeminfoList);
    }
 
    /**
     * 修改排序
     */
    @LogAction("平台管理,应用程序管理,应用程序排序修改,修改")
    @PostMapping("/updateRorder")
    @RequiresPermissions("sys:systeminfo:edit")
    @ApiOperation(
            value = "修改排序",
            notes = ""
    )
    public Result updateRorder(@ApiParam(name="复合对象",value="传入json格式",required=true)@RequestBody JSONObject json){
        String appids = json.getString("appids");
//        String sorts = json.getString("sorts");
        String[] appidList = appids.split(",");
//        String[] sortList=sorts.split(",");
        for(int i =0;i<appidList.length;i++){
            SysSysteminfo info = new SysSysteminfo();
            info.setAppid(Long.parseLong(appidList[i]));
//            info.setOrderid(Integer.parseInt(sortList[i]));
            info.setOrderid(i);
            systeminfoService.updateRorder(info);
        }
        return Result.ok();
    }
 
    @GetMapping("/getNavigAtionShowCount")
    public Integer getNavigAtionShowCount(Integer appid){
        Integer result = 0;
        try {
            result = systeminfoService.queryNavigAtionShowCount(appid);
        }catch (Exception ex){
 
        }
        return result;
    }
}