WebBReportTableController.java
10.5 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
package com.lhcredit.project.webbusiness.controller;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.common.utils.security.ShiroUtils;
import com.lhcredit.framework.aspectj.lang.annotation.CheckToken;
import com.lhcredit.framework.aspectj.lang.annotation.OrderCountCheck;
import com.lhcredit.framework.aspectj.lang.enums.OperatorType;
import com.lhcredit.project.business.contractBusinessType.service.IContractBusinessTypeService;
import com.lhcredit.project.business.contractReportBusinessType.service.IContractReportBusinessTypeService;
import com.lhcredit.project.business.frontUser.domain.FrontUserMon;
import com.lhcredit.project.business.frontUser.service.FrontUserServiceImpl;
import com.lhcredit.project.business.templateConfiguration.domain.TemplateConfiguration;
import com.lhcredit.project.business.templateConfiguration.service.TemplateConfigurationServiceImpl;
import com.lhcredit.project.business.templateConfigurationParameters.domain.TemplateConfigurationParameters;
import com.lhcredit.project.business.templateConfigurationParameters.service.TemplateConfigurationParametersServiceImpl;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
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.bReportTable.domain.BReportTable;
import com.lhcredit.project.business.bReportTable.service.IBReportTableService;
import com.lhcredit.framework.web.controller.BaseController;
import com.lhcredit.framework.web.domain.AjaxResult;
/**
* 报告样式信息对外接口
*
* @author lhcredit
* @date 2024-05-31
*/
@RestController
@RequestMapping("/web/bReportTable")
public class WebBReportTableController extends BaseController {
@Autowired
private IBReportTableService bReportTableService;
@Autowired
private IContractReportBusinessTypeService contractReportBusinessTypeService;
@Autowired
private FrontUserServiceImpl frontUserService;
@Autowired
private TemplateConfigurationServiceImpl templateConfigurationService;
@Autowired
private TemplateConfigurationParametersServiceImpl templateConfigurationParametersService;
/**
* 查询报告样式列表接口
*/
@ApiOperation("查询报告样式列表")
@Log(title = "报告样式", businessType = BusinessType.LIST, operatorType = OperatorType.WEB)
@GetMapping("/list")
// @CheckToken
public AjaxResult list(BReportTable bReportTable) {
startPage();
bReportTable.setIsDel(1);
List<BReportTable> list = bReportTableService.changeModel(bReportTableService.selectBReportTableList(bReportTable));
//转成map
Map<Long, BReportTable> breportTableMap = list.stream().collect(Collectors.toMap(BReportTable::getBizType, Function.identity()));
FrontUserMon userInfo = getUserInfo();
// FrontUserMon userInfo = new FrontUserMon();
// userInfo.setBizTypes("-2,60");
if(userInfo!=null){
//通过orgId 查询 当前公司所能下单的报告模板类型
TemplateConfiguration tc = new TemplateConfiguration();
tc.setOrgId(userInfo.getOrgId());
TemplateConfiguration conf = frontUserService.getTemplateConfiguration(userInfo.getOrgId());
if (conf == null){
for (BReportTable r : list) {
//设置 其无下单权限
r.setHasPermiss("0");
}
return toAjax(list);
}
String bizTypes = conf.getTypeId();
// String bizTypes = userInfo.getBizTypes();
List<String> stringList = Arrays.asList(bizTypes.split(","));
for (BReportTable reportTable : list) {
Long bizType = reportTable.getBizType();
reportTable.setHasPermiss("0");
if(stringList.contains(bizType.toString())){
reportTable.setHasPermiss("1");
}
}
//处理 企业信用报告(标准版)
// if (stringList.contains("-4")){
// BReportTable source = breportTableMap.get(-4L);
// BReportTable table = new BReportTable();
// BeanUtils.copyProperties(source, table);
// table.setBizType(-4L);
// table.setHasPermiss("1");
// table.setId("-1");
// list.add(table);
// list=list.stream().filter(f->!f.getBizType().toString().equals("-4")&&f.getHasPermiss().equals("1")).collect(Collectors.toList());
// }
if(stringList.contains("-2")){
BReportTable source = breportTableMap.get(-4L);
BReportTable table = new BReportTable();
BeanUtils.copyProperties(source, table);
table.setBizType(-2L);
table.setHasPermiss("1");
table.setId("-1");
list.add(table);
list=list.stream().filter(f->!f.getBizType().toString().equals("-4")).collect(Collectors.toList());
}
if(stringList.contains("-9")){
BReportTable source = breportTableMap.get(-4L);
BReportTable table = new BReportTable();
BeanUtils.copyProperties(source, table);
table.setBizType(-9L);
table.setHasPermiss("1");
table.setId("-1");
list.add(table);
list=list.stream().filter(f->!f.getBizType().toString().equals("-4")).collect(Collectors.toList());
}
if(stringList.contains("-15")){
BReportTable source = breportTableMap.get(-4L);
BReportTable table = new BReportTable();
BeanUtils.copyProperties(source, table);
table.setBizType(-15L);
table.setHasPermiss("1");
table.setId("-1");
list.add(table);
list=list.stream().filter(f->!f.getBizType().toString().equals("-4")).collect(Collectors.toList());
}
// if(stringList.contains("-3")){
// BReportTable source = breportTableMap.get(-3L);
// BReportTable table = new BReportTable();
// BeanUtils.copyProperties(source, table);
// table.setBizType(-3L);
// table.setHasPermiss("1");
// table.setId("-2");
// list.add(table);
// list=list.stream().collect(Collectors.toList());
// }
if(stringList.contains("-5")){
BReportTable source = breportTableMap.get(-3L);
BReportTable table = new BReportTable();
BeanUtils.copyProperties(source, table);
table.setBizType(-5L);
table.setHasPermiss("1");
table.setId("-2");
list.add(table);
list=list.stream().filter(f->!f.getBizType().toString().equals("-3")).collect(Collectors.toList());
}
if(stringList.contains("-8")){
BReportTable source = breportTableMap.get(-3L);
BReportTable table = new BReportTable();
BeanUtils.copyProperties(source, table);
table.setBizType(-8L);
table.setHasPermiss("1");
table.setId("-2");
list.add(table);
list=list.stream().filter(f->!f.getBizType().toString().equals("-3")).collect(Collectors.toList());
}
// if(stringList.contains("-11")){
// BReportTable source = breportTableMap.get(-11L);
// BReportTable table = new BReportTable();
// BeanUtils.copyProperties(source, table);
// table.setBizType(-11L);
// table.setHasPermiss("1");
// table.setId("-3");
// list.add(table);
// list=list.stream().collect(Collectors.toList());
// }
if(stringList.contains("-12")){
BReportTable source = breportTableMap.get(-11L);
BReportTable table = new BReportTable();
BeanUtils.copyProperties(source, table);
table.setBizType(-12L);
table.setHasPermiss("1");
table.setId("-3");
list.add(table);
list=list.stream().filter(f->!f.getBizType().toString().equals("-11")).collect(Collectors.toList());
}
}
if (CollectionUtils.isNotEmpty(list)){
List<BReportTable> collect1 = list.stream().filter(f ->StringUtils.isNotEmpty(f.getHasPermiss()) &&f.getHasPermiss().equals("1")).collect(Collectors.toList());
List<BReportTable> collect2 = list.stream().filter(f ->StringUtils.isNotEmpty(f.getHasPermiss()) && !f.getHasPermiss().equals("1")).collect(Collectors.toList());
List<BReportTable> collect3= list.stream().filter(f ->StringUtils.isEmpty(f.getHasPermiss())).collect(Collectors.toList());
collect1.addAll(collect2);
collect1.addAll(collect3);
return toAjax(collect1);
}
return toAjax(list);
}
@GetMapping("/test")
public AjaxResult t(String id){
return success(contractReportBusinessTypeService.getFromCrm(id));
}
@CheckToken
@GetMapping("/clientType")
public AjaxResult BussinessType(){
FrontUserMon userInfo = getUserInfo();
// FrontUserMon userInfo = new FrontUserMon();
// userInfo.setOrgId(24l);
if(userInfo!=null){
/*Long contractId = userInfo.getContractId();
JSONObject obj = contractBusinessTypeService.findByCId(contractId);
return success(obj);*/
Long orgId = userInfo.getOrgId();
List<TemplateConfigurationParameters> params = templateConfigurationParametersService.getTempConfParamsByOrg(orgId,"report_type");
if (CollectionUtils.isEmpty(params))
return AjaxResult.success("暂无数据");
return AjaxResult.success(params);
}
return null;
}
}