FrontDeptController.java
29.9 KB
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
package com.lhcredit.project.business.frontDept.controller;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.common.utils.http.HttpUtils;
import com.lhcredit.common.utils.security.ShiroUtils;
import com.lhcredit.framework.web.domain.Ztree;
import com.lhcredit.project.business.contractReportBusinessType.service.ContractReportBusinessTypeServiceImpl;
import com.lhcredit.project.business.frontUser.domain.FrontUser;
import com.lhcredit.project.business.frontUser.domain.FrontUserMon;
import com.lhcredit.project.business.frontUser.service.IFrontUserService;
import com.lhcredit.project.business.monitorCompany.domain.MonitorCompany;
import com.lhcredit.project.business.monitorCompanyNew.domain.MonitorCompanyNew;
import com.lhcredit.project.business.monitorCompanyNew.service.IMonitorCompanyNewService;
import com.lhcredit.project.business.monitorCompanyNew.vo.MonitorCompanyNewVo;
import com.lhcredit.project.system.dept.domain.Dept;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.omg.Messaging.SYNC_WITH_TRANSPORT;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.lhcredit.framework.aspectj.lang.annotation.Log;
import com.lhcredit.framework.aspectj.lang.enums.BusinessType;
import com.lhcredit.project.business.frontDept.domain.FrontDept;
import com.lhcredit.project.business.frontDept.service.IFrontDeptService;
import com.lhcredit.framework.web.controller.BaseController;
import com.lhcredit.framework.web.page.TableDataInfo;
import com.lhcredit.framework.web.domain.AjaxResult;
import com.lhcredit.common.utils.poi.ExcelUtil;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
/**
* 公司部门信息操作处理
*
* @author lhcredit
* @date 2024-05-08
*/
@Controller
@RequestMapping("/business/frontDept")
public class FrontDeptController extends BaseController {
private String prefix = "business/frontDept";
@Autowired
private IFrontDeptService frontDeptService;
@Autowired
private ContractReportBusinessTypeServiceImpl contractReportBusinessTypeService;
@Autowired
IFrontUserService frontUserService;
@Value("${crm.url}")
private String url;
@Value("${crm.token}")
private String token;
@Value("${dnaapi.monitorApi}")
private String monitorApi;
@Value("${dnaapi.monitorToken}")
private String minitorToken;
@Resource
private IMonitorCompanyNewService monitorCompanyNewService;
/**
* 上传报告价格by机构
* @param id
* @param file
* @return
*/
@RequestMapping("/saveComReportPrice/{id}")
@ResponseBody
public AjaxResult saveComReportPrice(@PathVariable("id") Long id, MultipartFile file){
FrontDept parentDept = frontDeptService.getParentDept(id);
ExcelUtil<FrontDept> util = new ExcelUtil<FrontDept>(FrontDept. class);
try {
List<FrontDept> frontDepts = util.importExcel(file.getInputStream());
if (CollectionUtils.isNotEmpty(frontDepts)){
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return AjaxResult.success();
}
@RequiresPermissions("business:frontDept:view")
@GetMapping()
public String frontDept() {
return prefix + "/frontDept";
}
/**
* 查询公司部门列表
*/
@RequiresPermissions("business:frontDept:list")
@GetMapping("/list")
@ResponseBody
public List<FrontDept> list(FrontDept frontDept) {
List<FrontDept> list = frontDeptService.selectFrontDeptList(frontDept);
return list;
}
/**
* 导出公司部门列表
*/
@RequiresPermissions("business:frontDept:export")
@Log(title = "公司部门", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(FrontDept frontDept) {
List<FrontDept> list = frontDeptService.selectFrontDeptList(frontDept);
ExcelUtil<FrontDept> util = new ExcelUtil<FrontDept>(FrontDept. class);
return util.exportExcel(list, "frontDept");
}
/**
* 新增公司部门
*/
@GetMapping("/add/{parentId}")
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) {
mmap.put("frontDept", frontDeptService.selectFrontDeptById(parentId));
return prefix + "/add";
}
/**
* 新增公司部门
*/
@GetMapping("/addHead")
public String addHead() {
return prefix + "/addHead";
}
/**
* 新增保存公司部门
*/
@RequiresPermissions("business:frontDept:add")
@Log(title = "公司部门", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(FrontDept frontDept) {
frontDept.setCreateBy(ShiroUtils.getLoginName());
frontDept.setCreateTime(new Date());
frontDept.setUpdateBy(ShiroUtils.getLoginName());
frontDept.setUpdateTime(new Date());
//根据父ID查询的总公司还是分公司
FrontDept fd=frontDeptService.selectFrontDeptById(frontDept.getParentId());
String type=fd.getDeptType();
if(type.equals("2")){
return AjaxResult.error("部门不能添加子类");
}
if(type.equals("0")){
//添加分公司
frontDeptService.addCompay(fd,frontDept.getParentId(),frontDept.getDeptName(),frontDept.getSort());
}else {
//添加部门
frontDeptService.addDept(frontDept.getParentId(),frontDept.getDeptName(),frontDept.getSort());
}
return AjaxResult.success();
}
/**
* 修改公司部门
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap) {
FrontDept frontDept =frontDeptService.selectFrontDeptById(id);
if (StringUtils.isNotEmpty(frontDept.getReportParams())){
frontDept.setReportParamsList(frontDept.getReportParams().split(","));
}
mmap.put("frontDept", frontDept);
return prefix + "/edit";
}
/**
* 修改保存公司部门
*/
@RequiresPermissions("business:frontDept:edit")
@Log(title = "公司部门", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(FrontDept frontDept) {
frontDept.setUpdateBy(ShiroUtils.getLoginName());
frontDept.setUpdateTime(new Date());
return toAjax(frontDeptService.updateFrontDept(frontDept));
}
/**
* 删除公司部门
*/
@RequiresPermissions("business:frontDept:remove")
@Log(title = "公司部门", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids) {
return toAjax(frontDeptService.deleteFrontDeptByIds(ids));
}
@RequiresPermissions("business:frontDept:remove")
@Log(title = "公司部门", businessType = BusinessType.DELETE)
@GetMapping("/removeById/{id}")
@ResponseBody
public AjaxResult removeById(@PathVariable("id") Long id) {
/*if (frontDeptService.selectDeptCount(deptId) > 0) {
return AjaxResult.warn("存在下级部门,不允许删除");
}
if (frontDeptService.checkDeptExistUser(deptId)) {
return AjaxResult.warn("部门存在用户,不允许删除");
}*/
return toAjax(frontDeptService.deleteFrontDeptById(id));
}
@GetMapping("/query")
@ResponseBody
public AjaxResult query(String name){
List list=new ArrayList();
String sendUrl=url+"contract/contract/web/listForCM?contractName="+name;
Map map=new HashMap();
map.put("Token",token);
String result= HttpRequest.get(sendUrl).addHeaders(map).execute().body();
if(!"".equals(result)||null!=result){
JSONObject obj= (JSONObject) JSONObject.parse(result);
if(obj.getIntValue("code")==200){
JSONArray array=obj.getJSONArray("rows");
if(array.size()>0){
for(int i=0;i<array.size();i++){
Map resMap=new HashMap();
JSONObject obj1=array.getJSONObject(i);
resMap.put("headOffice",obj1.getString("contractName"));
resMap.put("contractPartyAName",obj1.getString("contractPartyAName"));
resMap.put("contractId",obj1.getString("contractId"));
resMap.put("contractTypeReal",obj1.getString("contractTypeReal"));
String contractId=obj1.getString("contractId");
String sendUrl1=url+"contract/client/web/selectByContractId?id="+contractId;
String result1= HttpRequest.get(sendUrl1).addHeaders(map).execute().body();
if(!"".equals(result1)||null!=result1){
JSONObject obj2= (JSONObject) JSONObject.parse(result1);
if(obj2.getIntValue("code")==200){
JSONArray array2=obj2.getJSONArray("data");
List blist=new ArrayList();
for(int j=0;j<array2.size();j++){
JSONObject obj3= array2.getJSONObject(j);
blist.add(obj3.getString("clientName"));
}
resMap.put("branchOffices",blist);
}
}
list.add(resMap);
}
}
return AjaxResult.success(list);
}
}
return AjaxResult.error();
}
@GetMapping("/queryAll")
@ResponseBody
public AjaxResult queryList(String id){
String sendUrl=url+"contract/client/web/selectByContractId";
String result= HttpUtils.sendGet(sendUrl,"id="+id,token);
if(!"".equals(result)||null!=result){
JSONObject obj= (JSONObject) JSONObject.parse(result);
if(obj.getIntValue("code")==200){
JSONArray array=obj.getJSONArray("data");
if(array.size()>0){
return AjaxResult.success(array);
}
}
}
return AjaxResult.error();
}
@PostMapping("/addSave")
@ResponseBody
public AjaxResult addSave(String headOffice,String entName,String branchOffices,String monitorBegin,String monitorEnd){
try {
frontDeptService.addSave(headOffice, entName, branchOffices, monitorBegin, monitorEnd);
}catch (Exception e) {
e.printStackTrace();
return AjaxResult.error();
}
return AjaxResult.success();
}
@PostMapping("/addDept")
@ResponseBody
public AjaxResult addDept(@RequestBody String requestJson){
if(!"".equals(requestJson)){
// RequestJson obj= JSON.parseObject(requestJson,RequestJson.class);
JSONObject obj= (JSONObject) JSONObject.parse(requestJson);
// frontDeptService.addDept(obj);
}
return AjaxResult.success();
}
/**
* 选择部门树
*/
@GetMapping("/selectDeptTree/{deptId}")
public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap) {
if(deptId>0){
mmap.put("dept", frontDeptService.selectFrontDeptById(deptId));
}
return prefix + "/tree";
}
@GetMapping("/selectDeptTreeByEntName/{entName}")
public String selectDeptTreeByEntName(@PathVariable("entName") String entName, ModelMap mmap) {
List list=new ArrayList();
String sendUrl=url+"contract/contract/web/listForCM?contractName=" + entName;
Map map=new HashMap();
map.put("Token",token);
String result= HttpRequest.get(sendUrl).addHeaders(map).execute().body();
if(!"".equals(result)||null!=result){
JSONObject obj= (JSONObject) JSONObject.parse(result);
if(obj.getIntValue("code")==200){
JSONArray array=obj.getJSONArray("rows");
if(array.size()>0){
for(int i=0;i<array.size();i++){
Map resMap=new HashMap();
JSONObject obj1=array.getJSONObject(i);
resMap.put("headOffice",obj1.getString("contractName"));
resMap.put("contractPartyAName",obj1.getString("contractPartyAName"));
resMap.put("contractId",obj1.getString("contractId"));
resMap.put("contractTypeReal",obj1.getString("contractTypeReal"));
String contractId=obj1.getString("contractId");
String sendUrl1=url+"contract/client/web/selectByContractId?id="+contractId;
String result1= HttpRequest.get(sendUrl1).addHeaders(map).execute().body();
if(!"".equals(result1)||null!=result1){
JSONObject obj2= (JSONObject) JSONObject.parse(result1);
if(obj2.getIntValue("code")==200){
JSONArray array2=obj2.getJSONArray("data");
List blist=new ArrayList();
for(int j=0;j<array2.size();j++){
JSONObject obj3= array2.getJSONObject(j);
blist.add(obj3.getString("clientName"));
}
resMap.put("branchOffices",blist);
}
}
list.add(resMap);
}
}
}
}
mmap.put("deptList", list);
return prefix + "/treeByEntName";
}
/**
* 加载部门列表树
*/
@GetMapping("/treeData")
@ResponseBody
public List<Ztree> treeData() {
List<Ztree> ztrees = frontDeptService.selectDeptTree(new FrontDept());
return ztrees;
}
/**
* 校验部门名称
*/
@PostMapping("/checkDeptNameUnique")
@ResponseBody
public String checkDeptNameUnique(FrontDept frontDept) {
return frontDeptService.checkDeptNameUnique(frontDept);
}
/**
* 根据合同编号,调用crm接口 获取biz_types(有效报告类型) 并根据公司id 更新对 应公司及其部门对应数据
* @param frontDept
* @return
*/
@PostMapping("/updateServiceType")
@ResponseBody
public AjaxResult updateServiceType(FrontDept frontDept){
//根据合同编号,调用crm接口 获取biz_types(有效报告类型) 并根据公司id 更新对 应公司及其部门对应数据
String bizTypes = contractReportBusinessTypeService.getFromCrm(frontDept.getContractNum().toString());
frontDept.setBizTypes(bizTypes);
// frontDept.setBizTypes("60");
frontDept.setUpdateTime(new Date());
frontDeptService.updateFrontDeptByAncestors(frontDept);
return AjaxResult.success();
}
/**
* 根据合同编号,调用crm接口 获取biz_types(有效报告类型) 并根据公司id 更新对 应公司及其部门对应数据
* @param frontDept
* @return
*/
@PostMapping("/updateMon")
@ResponseBody
public AjaxResult updateMon(FrontDept frontDept){
FrontDept prDept=frontDeptService.selectFrontDeptById(frontDept.getId());
String begin=prDept.getMonitorBegin();
String end=prDept.getMonitorEnd();
//查询父公司底下用户关联
FrontUser fu=new FrontUser();
fu.setOrgId(frontDept.getId());
fu.setDataStatus("0");
fu.setDeleteStatus("0");
List<FrontUser> listFrUser=frontUserService.selectFrontUserList(fu);
for(FrontUser frUser:listFrUser){
//查询用户监控企业
MonitorCompanyNew mc=new MonitorCompanyNew();
mc.setUserId(frUser.getId()+"");
mc.setStatus("0");
mc.setMonitorStatus("0");
List<MonitorCompanyNewVo> lts = monitorCompanyNewService.selectMonitorCompanyNewList(mc);//根据用户查询企业
for(MonitorCompanyNewVo mcvo:lts){
MonitorCompanyNew mCompany = new MonitorCompanyNew();
mCompany.setCreditCode(mcvo.getCreditCode());
mCompany.setMonitorStatus("0");
mCompany.setStatus("0");
List<MonitorCompanyNewVo> ltsNew = monitorCompanyNewService.selectMonitorCompanyNewList(mCompany);//根据企业查询数量
if(ltsNew.size()==1){//假如就一个,直接修改
String addUrl = monitorApi.replace("{type}", "update");
// 更新企业监控最大时间和最小时间
String body = HttpRequest.post(addUrl).header("token", minitorToken)
.body(new JSONObject() {
{put("ename", ltsNew.get(0).getEname());}
{put("creditCode", ltsNew.get(0).getCreditCode());}
{put("mEndTime", end);}
{put("mStartTime", begin);}
}.toJSONString()).execute().body();
}else if(ltsNew.size()>1){//大于1个,则判断直接监控日期和现在结束监控日期
// 获取所有部门Id
List<String> deptIds = ltsNew.stream()
.map(MonitorCompanyNewVo::getDeptId)
.filter(StringUtils::isNotEmpty)
.distinct()
.collect(Collectors.toList());
deptIds.add(frontDept.getId()+"");
deptIds = deptIds.stream().distinct().collect(Collectors.toList());
Map<String, String> timeMap = monitorCompanyNewService.getMinMaxTimes(deptIds);
String minStartTime = timeMap.get("minStartTime");
String maxEndTime = timeMap.get("maxEndTime");
String addUrl = monitorApi.replace("{type}", "update");
// 更新企业监控最大时间和最小时间
String body = HttpRequest.post(addUrl).header("token", minitorToken)
.body(new JSONObject() {
{put("ename", ltsNew.get(0).getEname());}
{put("creditCode", ltsNew.get(0).getCreditCode());}
{put("mEndTime", maxEndTime);}
{put("mStartTime", minStartTime);}
}.toJSONString()).execute().body();
}
}
}
//查询子公司
FrontDept fd=new FrontDept();
fd.setParentId(frontDept.getId());
List<FrontDept> listFd=frontDeptService.selectFrontDeptList(fd);
for(FrontDept fd1:listFd) {
//查询子公司下的用户
FrontUser fu1 = new FrontUser();
fu1.setOrgId(frontDept.getId());
fu1.setDataStatus("0");
fu1.setDeleteStatus("0");
List<FrontUser> listFrUser1 = frontUserService.selectFrontUserList(fu1);
for (FrontUser frUser1 : listFrUser1) {
//查询用户监控企业
MonitorCompanyNew mc = new MonitorCompanyNew();
mc.setUserId(frUser1.getId() + "");
mc.setStatus("0");
mc.setMonitorStatus("0");
List<MonitorCompanyNewVo> lts = monitorCompanyNewService.selectMonitorCompanyNewList(mc);//根据用户查询企业
for (MonitorCompanyNewVo mcvo : lts) {
MonitorCompanyNew mCompany = new MonitorCompanyNew();
mCompany.setCreditCode(mcvo.getCreditCode());
mCompany.setMonitorStatus("0");
mCompany.setStatus("0");
List<MonitorCompanyNewVo> ltsNew = monitorCompanyNewService.selectMonitorCompanyNewList(mCompany);//根据企业查询数量
if (ltsNew.size() == 1) {//假如就一个,直接修改
String addUrl = monitorApi.replace("{type}", "update");
// 更新企业监控最大时间和最小时间
String body = HttpRequest.post(addUrl).header("token", minitorToken)
.body(new JSONObject() {
{
put("ename", ltsNew.get(0).getEname());
}
{
put("creditCode", ltsNew.get(0).getCreditCode());
}
{
put("mEndTime", end);
}
{
put("mStartTime", begin);
}
}.toJSONString()).execute().body();
} else if (ltsNew.size() > 1) {//大于1个,则判断直接监控日期和现在结束监控日期
// 获取所有部门Id
List<String> deptIds = ltsNew.stream()
.map(MonitorCompanyNewVo::getDeptId)
.filter(StringUtils::isNotEmpty)
.distinct()
.collect(Collectors.toList());
deptIds.add(frontDept.getId() + "");
deptIds = deptIds.stream().distinct().collect(Collectors.toList());
Map<String, String> timeMap = monitorCompanyNewService.getMinMaxTimes(deptIds);
String minStartTime = timeMap.get("minStartTime");
String maxEndTime = timeMap.get("maxEndTime");
String addUrl = monitorApi.replace("{type}", "update");
// 更新企业监控最大时间和最小时间
String body = HttpRequest.post(addUrl).header("token", minitorToken)
.body(new JSONObject() {
{
put("ename", ltsNew.get(0).getEname());
}
{
put("creditCode", ltsNew.get(0).getCreditCode());
}
{
put("mEndTime", maxEndTime);
}
{
put("mStartTime", minStartTime);
}
}.toJSONString()).execute().body();
}
}
}
//查询子公司下的部门
FrontDept fd2 = new FrontDept();
fd2.setParentId(fd1.getId());
List<FrontDept> listFd2 = frontDeptService.selectFrontDeptList(fd2);
//查询部门下的用户
for (FrontDept fd3 : listFd2) {
FrontUser fu3 = new FrontUser();
fu3.setOrgId(fd3.getId());
fu3.setDataStatus("0");
fu3.setDeleteStatus("0");
List<FrontUser> listFrUser2 = frontUserService.selectFrontUserList(fu3);
for (FrontUser frUser2 : listFrUser2) {
//查询用户监控企业
MonitorCompanyNew mc = new MonitorCompanyNew();
mc.setUserId(frUser2.getId() + "");
mc.setStatus("0");
mc.setMonitorStatus("0");
List<MonitorCompanyNewVo> lts = monitorCompanyNewService.selectMonitorCompanyNewList(mc);//根据用户查询企业
for (MonitorCompanyNewVo mcvo : lts) {
MonitorCompanyNew mCompany = new MonitorCompanyNew();
mCompany.setCreditCode(mcvo.getCreditCode());
mCompany.setMonitorStatus("0");
mCompany.setStatus("0");
List<MonitorCompanyNewVo> ltsNew = monitorCompanyNewService.selectMonitorCompanyNewList(mCompany);//根据企业查询数量
if (ltsNew.size() == 1) {//假如就一个,直接修改
String addUrl = monitorApi.replace("{type}", "update");
// 更新企业监控最大时间和最小时间
String body = HttpRequest.post(addUrl).header("token", minitorToken)
.body(new JSONObject() {
{
put("ename", ltsNew.get(0).getEname());
}
{
put("creditCode", ltsNew.get(0).getCreditCode());
}
{
put("mEndTime", end);
}
{
put("mStartTime", begin);
}
}.toJSONString()).execute().body();
} else if (ltsNew.size() > 1) {//大于1个,则判断直接监控日期和现在结束监控日期
// 获取所有部门Id
List<String> deptIds = ltsNew.stream()
.map(MonitorCompanyNewVo::getDeptId)
.filter(StringUtils::isNotEmpty)
.distinct()
.collect(Collectors.toList());
deptIds.add(frontDept.getId() + "");
deptIds = deptIds.stream().distinct().collect(Collectors.toList());
Map<String, String> timeMap = monitorCompanyNewService.getMinMaxTimes(deptIds);
String minStartTime = timeMap.get("minStartTime");
String maxEndTime = timeMap.get("maxEndTime");
String addUrl = monitorApi.replace("{type}", "update");
// 更新企业监控最大时间和最小时间
String body = HttpRequest.post(addUrl).header("token", minitorToken)
.body(new JSONObject() {
{
put("ename", ltsNew.get(0).getEname());
}
{
put("creditCode", ltsNew.get(0).getCreditCode());
}
{
put("mEndTime", maxEndTime);
}
{
put("mStartTime", minStartTime);
}
}.toJSONString()).execute().body();
}
}
}
}
}
return AjaxResult.success();
}
/**
*
* @param frontDept
* @return
*/
@PostMapping("/addNewDept")
@ResponseBody
public AjaxResult addNewDept(FrontDept frontDept){
try {
}catch (Exception e) {
e.printStackTrace();
return AjaxResult.error();
}
return AjaxResult.success();
}
public static void main(String[] args) {
// String sendUrl="http://192.168.5.17:8081/contract/contract/web/listForCM?contractName=捷成洋行企业管理";
// Map map=new HashMap();
// map.put("Token","4389cc63-7db8-45d4-abd1-242fec622c58");
// String result= HttpRequest.get(sendUrl).addHeaders(map).execute().body();
// System.out.println(result);
// List l1=new ArrayList();
// Map hmap=new HashMap();
// hmap.put("contractId","4193");
// hmap.put("contractName","捷成洋行企业管理(广州)有限公司");
//
// List l2=new ArrayList();
// Map b1=new HashMap();
// b1.put("clientName","捷成消费品(中国)有限公司上海捷成饮料分公司");
// b1.put("contractId","4193");
// Map b2=new HashMap();
// b2.put("clientName","天津滨海捷成专类化工有限公司");
// b2.put("contractId","4193");
// l2.add(b1);
// l2.add(b2);
//
// List l3=new ArrayList();
// Map b3=new HashMap();
// b3.put("deptName","部门1");
// b3.put("contractId","4193");
// b3.put("clientName","捷成消费品(中国)有限公司上海捷成饮料分公司");
//
// Map b4=new HashMap();
// b4.put("deptName","部门2");
// b4.put("contractId","4193");
// b4.put("clientName","天津滨海捷成专类化工有限公司");
// l3.add(b3);
// l3.add(b4);
//
// Map m1=new HashMap();
// m1.put("head",hmap);//总公司
// m1.put("branch",l2);//分公司
// m1.put("dept",l3);//部门
//
// System.out.println(JSON.toJSON(m1));
String s="a";
System.out.println(s.contains(","));
}
}