提交 | 用户 | age
|
ec748c
|
1 |
package com.yc.action.upload; |
X |
2 |
|
|
3 |
import com.yc.entity.attachment.AttachmentOAParam; |
|
4 |
import com.yc.entity.attachment.AttachmentOaEntity; |
|
5 |
import com.yc.multiData.SpObserver; |
|
6 |
import com.yc.phoneQRLogin.utils.BackMsg; |
|
7 |
import com.yc.service.impl.DBHelper; |
|
8 |
import com.yc.service.upload.AttachmentOaIfc; |
|
9 |
import com.yc.utils.SessionKey; |
0046a7
|
10 |
import jodd.util.StringUtil; |
ec748c
|
11 |
import org.apache.commons.lang3.StringUtils; |
X |
12 |
import org.codehaus.jackson.annotate.JsonIgnoreProperties; |
|
13 |
import org.springframework.beans.factory.annotation.Autowired; |
|
14 |
import org.springframework.web.bind.annotation.*; |
|
15 |
|
|
16 |
import javax.servlet.http.HttpServletRequest; |
|
17 |
import javax.servlet.http.HttpServletResponse; |
|
18 |
import java.lang.reflect.Array; |
|
19 |
import java.text.ParseException; |
|
20 |
import java.text.SimpleDateFormat; |
|
21 |
import java.util.ArrayList; |
|
22 |
import java.util.HashMap; |
|
23 |
import java.util.List; |
|
24 |
import java.util.Map; |
|
25 |
import java.util.stream.Collectors; |
|
26 |
|
|
27 |
/** |
|
28 |
* @Author xinyb |
|
29 |
* @Date 14:43 2022/11/1 |
|
30 |
**/ |
|
31 |
@RestController |
|
32 |
@RequestMapping("/attachmentOa") |
|
33 |
public class AttachmentOA { |
|
34 |
|
|
35 |
@Autowired |
|
36 |
AttachmentOaIfc attachmentOaIfc; |
|
37 |
|
418160
|
38 |
/** |
X |
39 |
* 加载用户权限结构数据 |
|
40 |
* |
|
41 |
* @param unid |
|
42 |
* @param seq |
|
43 |
* @param keyword |
|
44 |
* @param request |
|
45 |
* @param response |
|
46 |
* @return |
|
47 |
*/ |
ec748c
|
48 |
@RequestMapping(value = "/userInfo.do", method = RequestMethod.GET) |
X |
49 |
public BackMsg getAttachmentOAUserInfo(String unid, Integer seq, String keyword, HttpServletRequest request, HttpServletResponse response) { |
|
50 |
BackMsg msg = new BackMsg(); |
|
51 |
try { |
|
52 |
if (StringUtils.isBlank(unid)) { |
|
53 |
msg.setFail("附件控件唯一unid不能为空"); |
|
54 |
return msg; |
|
55 |
} |
|
56 |
if (seq == null || seq == 0) { |
|
57 |
msg.setFail("附件标识seq不能为空"); |
|
58 |
return msg; |
|
59 |
} |
|
60 |
String dbId = (String) request.getSession().getAttribute(SessionKey.DATA_BASE_ID); |
|
61 |
SpObserver.setDBtoInstance("_" + dbId); |
|
62 |
List<Map<String, Object>> list = attachmentOaIfc.getAttachmentOAUserInfo(unid, seq, keyword); |
|
63 |
if (list != null && list.size() > 0) { |
|
64 |
msg.setOk(Configure(list)); |
|
65 |
} else { |
|
66 |
if (StringUtils.isNotBlank(keyword)) { |
|
67 |
msg.setOk(list); |
|
68 |
return msg; |
|
69 |
} |
|
70 |
msg.setFail("获取不到用户信息"); |
|
71 |
} |
|
72 |
} catch (Exception e) { |
|
73 |
msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
|
74 |
} finally { |
|
75 |
SpObserver.setDBtoInstance(); |
|
76 |
} |
|
77 |
return msg; |
|
78 |
} |
|
79 |
|
418160
|
80 |
/** |
X |
81 |
* 加载设置了权限的用户 |
|
82 |
* |
|
83 |
* @param param |
|
84 |
* @param request |
|
85 |
* @return |
|
86 |
*/ |
|
87 |
@RequestMapping("/oaUser.do") |
|
88 |
public BackMsg getAttachmentOAUser(@RequestBody AttachmentOAParam param, HttpServletRequest request) { |
|
89 |
BackMsg msg = new BackMsg(); |
|
90 |
try { |
|
91 |
if (StringUtils.isBlank(param.getUnid())) { |
|
92 |
msg.setFail("附件控件唯一unid不能为空"); |
|
93 |
return msg; |
|
94 |
} |
|
95 |
if (param.getSeq() == null || param.getSeq() == 0) { |
|
96 |
msg.setFail("附件标识seq不能为空"); |
|
97 |
return msg; |
|
98 |
} |
|
99 |
String dbId = (String) request.getSession().getAttribute(SessionKey.DATA_BASE_ID); |
|
100 |
SpObserver.setDBtoInstance("_" + dbId); |
|
101 |
List<AttachmentOaEntity> oaUser = attachmentOaIfc.getAttachmentOAUser(param); |
|
102 |
msg.setOk(oaUser); |
|
103 |
} catch (Exception e) { |
|
104 |
msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
|
105 |
} finally { |
|
106 |
SpObserver.setDBtoInstance(); |
|
107 |
} |
|
108 |
return msg; |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* 批量保存权限设置 |
|
113 |
* |
|
114 |
* @param param |
|
115 |
* @param request |
|
116 |
* @param response |
|
117 |
* @return |
|
118 |
*/ |
ec748c
|
119 |
@RequestMapping("/setUserOA.do") |
X |
120 |
public BackMsg setAttachmentOAUser(@RequestBody AttachmentOAParam param, HttpServletRequest request, HttpServletResponse response) { |
|
121 |
BackMsg msg = new BackMsg(); |
|
122 |
try { |
|
123 |
if (param == null || StringUtils.isBlank(param.getUnid())) { |
|
124 |
msg.setFail("参数错误"); |
|
125 |
return msg; |
|
126 |
} |
|
127 |
String dbId = (String) request.getSession().getAttribute(SessionKey.DATA_BASE_ID); |
|
128 |
SpObserver.setDBtoInstance("_" + dbId); |
|
129 |
Integer cont = attachmentOaIfc.setAttachmentOAUser(param); |
|
130 |
msg.setOk("设置成功"); |
|
131 |
} catch (Exception e) { |
|
132 |
msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
|
133 |
} finally { |
|
134 |
SpObserver.setDBtoInstance(); |
|
135 |
} |
|
136 |
return msg; |
|
137 |
} |
|
138 |
|
418160
|
139 |
/** |
X |
140 |
* 保存单个权限设置人员 |
|
141 |
* |
|
142 |
* @param param |
|
143 |
* @param request |
|
144 |
* @return |
|
145 |
*/ |
|
146 |
@RequestMapping("/setUser.do") |
|
147 |
public BackMsg setAttachmentUser(@RequestBody AttachmentOaEntity param, HttpServletRequest request) { |
|
148 |
BackMsg msg = new BackMsg(); |
|
149 |
try { |
|
150 |
if (param == null || StringUtils.isBlank(param.getUnid())) { |
|
151 |
msg.setFail("参数错误"); |
|
152 |
return msg; |
|
153 |
} |
|
154 |
String dbId = (String) request.getSession().getAttribute(SessionKey.DATA_BASE_ID); |
|
155 |
SpObserver.setDBtoInstance("_" + dbId); |
|
156 |
String demo = attachmentOaIfc.setAttachmentUser(param); |
|
157 |
msg.setOk(demo); |
|
158 |
} catch (Exception e) { |
|
159 |
msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
|
160 |
} finally { |
|
161 |
SpObserver.setDBtoInstance(); |
|
162 |
} |
|
163 |
return msg; |
|
164 |
} |
|
165 |
|
|
166 |
|
|
167 |
/** |
0046a7
|
168 |
* 是否有权限显示 ,下载,更新(弃用,前端不需要请求这个接口) |
418160
|
169 |
* |
X |
170 |
* @param param |
|
171 |
* @param request |
|
172 |
* @return |
|
173 |
*/ |
ec748c
|
174 |
@RequestMapping("/getOAInfo.do") |
X |
175 |
public BackMsg getAttachmentOAInfo(@RequestBody AttachmentOAParam param, HttpServletRequest request) { |
|
176 |
BackMsg msg = new BackMsg(); |
|
177 |
try { |
|
178 |
if (StringUtils.isBlank(param.getUnid()) || param.getSeq() == null || param.getSeq() == 0) { |
|
179 |
msg.setFail("附件的参数信息不能为空"); |
|
180 |
return msg; |
|
181 |
} |
|
182 |
if (StringUtils.isBlank(param.getUserCode())) { |
|
183 |
param.setUserCode((String) request.getSession().getAttribute(SessionKey.HRCODE)); |
|
184 |
} |
|
185 |
String dbId = (String) request.getSession().getAttribute(SessionKey.DATA_BASE_ID); |
|
186 |
SpObserver.setDBtoInstance("_" + dbId); |
|
187 |
Map<String, Object> info = attachmentOaIfc.getAttachmentOAInfo(param); |
|
188 |
if (info == null) { |
|
189 |
msg.setFail("无法找到附件内容,检查附件参数是否正确"); |
|
190 |
return msg; |
|
191 |
} |
|
192 |
msg.setOk(info); |
|
193 |
} catch (Exception e) { |
|
194 |
msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
|
195 |
} finally { |
|
196 |
SpObserver.setDBtoInstance(); |
|
197 |
} |
|
198 |
return msg; |
|
199 |
} |
|
200 |
|
418160
|
201 |
/** |
0046a7
|
202 |
* 执行更新次数操作 |
418160
|
203 |
* |
X |
204 |
* @param param |
|
205 |
* @param request |
|
206 |
* @return |
|
207 |
*/ |
ec748c
|
208 |
@RequestMapping("/getAllowOa.do") |
X |
209 |
public BackMsg getAttachmentAllow(@RequestBody AttachmentOAParam param, HttpServletRequest request) { |
|
210 |
BackMsg msg = new BackMsg(); |
|
211 |
try { |
83ba69
|
212 |
if (StringUtils.isBlank(param.getUnid()) || param.getSeqArray().size() < 1) { |
ec748c
|
213 |
msg.setFail("附件的参数信息不能为空"); |
X |
214 |
return msg; |
|
215 |
} |
|
216 |
if (StringUtils.isBlank(param.getUserCode())) { |
|
217 |
param.setUserCode((String) request.getSession().getAttribute(SessionKey.HRCODE)); |
|
218 |
} |
|
219 |
String dbId = (String) request.getSession().getAttribute(SessionKey.DATA_BASE_ID); |
|
220 |
SpObserver.setDBtoInstance("_" + dbId); |
83ba69
|
221 |
List<Map<String, Object>> list = new ArrayList<>(); |
X |
222 |
for (Integer seq : param.getSeqArray()) { |
|
223 |
param.setSeq(seq); |
|
224 |
String memo = attachmentOaIfc.getAttachmentAllow(param); |
|
225 |
if (StringUtils.isBlank(memo)) { |
|
226 |
continue; |
|
227 |
} |
|
228 |
String[] info = memo.split(";"); |
|
229 |
if (info.length == 10) { |
|
230 |
Map<String, Object> map = new HashMap<>(); |
|
231 |
map.put("describe", info[0]); |
|
232 |
map.put("state", info[1]); |
|
233 |
map.put("viewNums", info[2]); |
|
234 |
map.put("downNums", info[3]); |
|
235 |
map.put("updateNums", info[4]); |
|
236 |
map.put("totaViewNums", info[5]); |
|
237 |
map.put("totaDownNums", info[6]); |
|
238 |
map.put("totaUpdateNums", info[7]); |
|
239 |
map.put("fileName", info[8]); |
|
240 |
map.put("seq",info[9]); |
|
241 |
list.add(map); |
|
242 |
} |
ec748c
|
243 |
} |
83ba69
|
244 |
msg.setOk(list); |
418160
|
245 |
} catch (Exception e) { |
X |
246 |
msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
|
247 |
} finally { |
|
248 |
SpObserver.setDBtoInstance(); |
|
249 |
} |
|
250 |
return msg; |
|
251 |
} |
|
252 |
|
|
253 |
/** |
|
254 |
* 删除附件权限人员 |
|
255 |
* |
|
256 |
* @param param |
|
257 |
* @param request |
|
258 |
* @return |
|
259 |
*/ |
|
260 |
@RequestMapping("/deleteAttachmentOa.do") |
|
261 |
public BackMsg getAttachmentDelete(@RequestBody AttachmentOAParam param, HttpServletRequest request) { |
|
262 |
BackMsg msg = new BackMsg(); |
|
263 |
try { |
|
264 |
if (StringUtils.isBlank(param.getUnid()) || param.getSeq() == null || param.getSeq() == 0) { |
|
265 |
msg.setFail("附件的参数信息不能为空"); |
|
266 |
return msg; |
|
267 |
} |
|
268 |
if (StringUtils.isBlank(param.getUserCode())) { |
|
269 |
msg.setFail("删除的用户Code不能为空"); |
|
270 |
return msg; |
|
271 |
} |
|
272 |
String dbId = (String) request.getSession().getAttribute(SessionKey.DATA_BASE_ID); |
|
273 |
SpObserver.setDBtoInstance("_" + dbId); |
|
274 |
String demo = attachmentOaIfc.getAttachmentDelete(param); |
|
275 |
msg.setOk(demo); |
ec748c
|
276 |
} catch (Exception e) { |
X |
277 |
msg.setFail(e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); |
|
278 |
} finally { |
|
279 |
SpObserver.setDBtoInstance(); |
|
280 |
} |
|
281 |
return msg; |
|
282 |
} |
|
283 |
|
|
284 |
/** |
|
285 |
* 配置用户结构 |
|
286 |
* |
|
287 |
* @param list |
|
288 |
* @return |
|
289 |
*/ |
|
290 |
private List<Map<String, Object>> Configure(List<Map<String, Object>> list) { |
|
291 |
List<Map<String, Object>> out = new ArrayList<>(); |
|
292 |
try { |
|
293 |
String filedId = "ccCode"; |
|
294 |
for (Map<String, Object> m : list) { |
|
295 |
String value = DBHelper.getValue(m, filedId).toLowerCase(); |
|
296 |
if (out.stream().filter(o -> value.equals(o.get(filedId) != null ? o.get(filedId).toString().toLowerCase() : "")).count() == 0) {//等于0表示还没有组装到value值 |
|
297 |
//获取相同value的集合 |
|
298 |
List<Map<String, Object>> similar = list.stream().filter(l -> value.equals(DBHelper.getValue(l, filedId).toLowerCase())).collect(Collectors.toList()); |
|
299 |
//创建一个新map存放相同value |
|
300 |
Map<String, Object> map = new HashMap<>(); |
|
301 |
map.put(filedId, DBHelper.getValue(m, filedId)); |
|
302 |
map.put("ccName", DBHelper.getValue(m, "ccName")); |
|
303 |
List<AttachmentOaEntity> oaEntities = new ArrayList<>(); |
|
304 |
boolean check = true;//假设全部选中 |
0046a7
|
305 |
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
ec748c
|
306 |
for (Map<String, Object> map1 : similar) { |
X |
307 |
AttachmentOaEntity oaEntity = new AttachmentOaEntity(); |
|
308 |
oaEntity.setCcCode(DBHelper.getValue(map1, filedId)); |
|
309 |
oaEntity.setCcName(DBHelper.getValue(map1, "ccName")); |
|
310 |
oaEntity.setUserCode(DBHelper.getValue(map1, "userCode")); |
|
311 |
oaEntity.setUserName(DBHelper.getValue(map1, "userName")); |
|
312 |
oaEntity.setHasView(DBHelper.getValueInt(map1, "hasView") == 1 ? true : false); |
|
313 |
oaEntity.setHasDownload(DBHelper.getValueInt(map1, "hasDownLoad") == 1 ? true : false); |
|
314 |
oaEntity.setHasDelete(DBHelper.getValueInt(map1, "hasDelete") == 1 ? true : false); |
e81b7d
|
315 |
oaEntity.setHasUpdate(DBHelper.getValueInt(map1, "hasUpdate") == 1 ? true : false); |
X |
316 |
oaEntity.setHasAuthor(DBHelper.getValueInt(map1, "hasAuthor") == 1 ? true : false); |
ec748c
|
317 |
String star = DBHelper.getValue(map1, "startDate"); |
83ba69
|
318 |
oaEntity.setStartDate(StringUtils.isBlank(star) ? null : star.substring(0, 19)); |
ec748c
|
319 |
String end = DBHelper.getValue(map1, "endDate"); |
83ba69
|
320 |
oaEntity.setEndDate(StringUtils.isBlank(end) ? null : end.substring(0, 19)); |
X |
321 |
String dateFlag = DBHelper.getValue(map1, "dateFlag"); |
|
322 |
if (StringUtils.isBlank(dateFlag)) { |
|
323 |
dateFlag = "2"; |
0046a7
|
324 |
} |
X |
325 |
oaEntity.setDateFlag(Integer.parseInt(dateFlag)); |
ec748c
|
326 |
oaEntity.setAllowViewNums(DBHelper.getValueInt(map1, "allowViewNums")); |
X |
327 |
oaEntity.setAllowDownNums(DBHelper.getValueInt(map1, "allowDownNums")); |
e81b7d
|
328 |
oaEntity.setAllowUpdateNums(DBHelper.getValueInt(map1, "allowUpdateNums")); |
X |
329 |
oaEntity.setViewNums(DBHelper.getValueInt(map1, "viewNums")); |
|
330 |
oaEntity.setDownNums(DBHelper.getValueInt(map1, "downNums")); |
|
331 |
oaEntity.setUpdateNums(DBHelper.getValueInt(map1, "updateNums")); |
ec748c
|
332 |
Integer checked = DBHelper.getValueInt(map1, "checked"); |
e81b7d
|
333 |
if (oaEntity.isHasAuthor()) { |
X |
334 |
oaEntity.setHasView(true); |
|
335 |
oaEntity.setHasUpdate(true); |
|
336 |
oaEntity.setHasDelete(true); |
|
337 |
oaEntity.setHasDownload(true); |
|
338 |
checked = 1; |
|
339 |
} |
ec748c
|
340 |
oaEntity.setChecked(checked == 1 ? true : false); |
X |
341 |
if (checked == 0) { |
|
342 |
check = false; |
|
343 |
} |
|
344 |
oaEntities.add(oaEntity); |
|
345 |
} |
|
346 |
map.put("checked", check); |
|
347 |
map.put("info", oaEntities); |
|
348 |
//把相同的value的map组装到out里 |
|
349 |
out.add(map); |
|
350 |
} |
|
351 |
} |
|
352 |
} catch (Exception e) { |
|
353 |
throw e; |
|
354 |
} |
|
355 |
return out; |
|
356 |
} |
|
357 |
|
|
358 |
|
|
359 |
} |