TemplateConfigurationController.java
11.2 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
package com.lhcredit.project.business.templateConfiguration.controller;
import java.util.*;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lhcredit.common.exception.BusinessException;
import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.common.utils.security.ShiroUtils;
import com.lhcredit.project.business.customTemplate.service.ICustomTemplateService;
import com.lhcredit.project.business.frontDept.domain.FrontDept;
import com.lhcredit.project.business.frontDept.service.IFrontDeptService;
import com.lhcredit.project.business.frontUser.domain.FrontUser;
import com.lhcredit.project.business.frontUser.domain.FrontUserMon;
import com.lhcredit.project.system.dict.service.IDictDataService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
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.templateConfiguration.domain.TemplateConfiguration;
import com.lhcredit.project.business.templateConfiguration.service.ITemplateConfigurationService;
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;
/**
* 模版配置信息操作处理
*
* @author lhcredit
* @date 2025-04-01
*/
@Controller
@RequestMapping("/business/templateConfiguration")
public class TemplateConfigurationController extends BaseController {
private String prefix = "business/templateConfiguration";
private String ctx = "/business/frontDept";
@Autowired
private ITemplateConfigurationService templateConfigurationService;
@Autowired
private IFrontDeptService frontDeptService;
@Autowired
private ICustomTemplateService customTemplateService;
@Autowired
private IDictDataService dictDataService;
@Value("${crm.url}")
private String url;
@Value("${crm.token}")
private String token;
@RequiresPermissions("business:templateConfiguration:view")
@GetMapping()
public String templateConfiguration() {
return prefix + "/templateConfiguration";
}
/**
* 查询模版配置列表
*/
@RequiresPermissions("business:templateConfiguration:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(TemplateConfiguration templateConfiguration) {
startPage();
List<TemplateConfiguration> list = templateConfigurationService.selectTemplateConfigurationList(templateConfiguration);
return getDataTable(list);
}
/**
* 导出模版配置列表
*/
@RequiresPermissions("business:templateConfiguration:export")
@Log(title = "模版配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(TemplateConfiguration templateConfiguration) {
List<TemplateConfiguration> list = templateConfigurationService.selectTemplateConfigurationList(templateConfiguration);
ExcelUtil<TemplateConfiguration> util = new ExcelUtil<TemplateConfiguration>(TemplateConfiguration. class);
return util.exportExcel(list, "templateConfiguration");
}
/**
* 新增模版配置
*/
@GetMapping("/add/{orgId}")
public String add( @PathVariable("orgId")Long orgId, ModelMap mmap) {
//通过用户id获取部门信息
FrontDept frontDept = frontDeptService.selectFrontDeptById(orgId);
mmap.put("frontDept", frontDept);
//获取后台报告类型
mmap.put("backgroundReportType", dictDataService.selectDictDataByType("background_report_type"));
//获取定制报告类型
mmap.put("customReportType", customTemplateService.getByOrgId(Math.toIntExact(orgId)));
//获取委托类型
mmap.put("clientType", dictDataService.selectDictDataByType("entrust_type"));
//获取翻译字典
mmap.put("reportTranslationType", dictDataService.selectDictDataByType("report_translation_type"));
return prefix + "/add";
}
@GetMapping("/addVue/{orgId}")
public String addVue( @PathVariable("orgId")Long orgId, ModelMap mmap) {
//通过用户id获取部门信息
FrontDept frontDept = frontDeptService.selectFrontDeptById(orgId);
mmap.put("frontDept", frontDept);
//获取后台报告类型
mmap.put("backgroundReportType", dictDataService.selectDictDataByType("background_report_type"));
//获取定制报告类型
mmap.put("customReportType", customTemplateService.getByOrgId(Math.toIntExact(orgId)));
//获取委托类型
mmap.put("clientType", dictDataService.selectDictDataByType("entrust_type"));
//获取翻译字典
mmap.put("reportTranslationType", dictDataService.selectDictDataByType("report_translation_type"));
TemplateConfiguration templateConfiguration =templateConfigurationService.getTemppConfByOrg1(orgId);
mmap.put("templateConfiguration", templateConfiguration);
return prefix + "/addVue";
}
/**
* 新增保存模版配置
*/
@RequiresPermissions("business:templateConfiguration:add")
@Log(title = "模版配置", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@RequestBody TemplateConfiguration templateConfiguration) {
return toAjax(templateConfigurationService.insertTemplateConfiguration(templateConfiguration));
}
/**
* 修改模版配置
*/
@GetMapping("/edit/{orgId}")
public String edit(@PathVariable("orgId") Long orgId, ModelMap mmap) {
//获取后台报告类型
mmap.put("backgroundReportType", dictDataService.selectDictDataByType("background_report_type"));
//获取定制报告类型
mmap.put("customReportType", customTemplateService.getByOrgId(Math.toIntExact(orgId)));
//获取委托类型
mmap.put("clientType", dictDataService.selectDictDataByType("entrust_type"));
//获取翻译字典
mmap.put("reportTranslationType", dictDataService.selectDictDataByType("report_translation_type"));
TemplateConfiguration templateConfiguration =templateConfigurationService.getTemppConfByOrg(orgId);
mmap.put("templateConfiguration", templateConfiguration);
return prefix + "/edit";
}
/**
* 修改保存模版配置
*/
@Log(title = "模版配置", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@RequestBody TemplateConfiguration templateConfiguration) {
String typeId = templateConfiguration.getTypeId();
String[] params = typeId.split(",");
Set<String> uniqueParams = new HashSet<>(Arrays.asList(params));
// 使用兼容Java 8的方式创建集合
Set<String> group1 = new HashSet<>(Arrays.asList("-2", "-4", "-9"));
Set<String> group2 = new HashSet<>(Arrays.asList("-3", "-5", "-8"));
Set<String> group3 = new HashSet<>(Arrays.asList("-11", "-12"));
int group1Count = 0, group2Count = 0, group3Count = 0;
for (String param : uniqueParams) {
if (group1.contains(param)) group1Count++;
if (group2.contains(param)) group2Count++;
if (group3.contains(param)) group3Count++;
}
if (group1Count > 1 || group2Count > 1 || group3Count > 1) {
return AjaxResult.error("请勿选择多个业务类型");
}
return toAjax(templateConfigurationService.updateTemplateConfiguration(templateConfiguration));
}
/**
* 删除模版配置
*/
@RequiresPermissions("business:templateConfiguration:remove")
@Log(title = "模版配置", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids) {
return toAjax(templateConfigurationService.deleteTemplateConfigurationByIds(ids));
}
/**
* 根据部门获取模版信息
*/
@RequiresPermissions("business:templateConfiguration:getTemppConfByOrg")
@GetMapping ("/getTemppConfByOrg/{orgId}")
@ResponseBody
public AjaxResult getTemppConfByOrg(@PathVariable("orgId") Long orgId) {
return success(templateConfigurationService.getTemppConfByOrg1(orgId));
}
/**
* 查询合同信息
*/
@GetMapping("/selectDeptTreeByEntName/{entName}")
public String selectDeptTreeByEntName(@PathVariable("entName") String entName, ModelMap mmap) {
List list=new ArrayList();
String sendUrl=url+"contract/contract/web/listForCRM?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("protocolResponsibilityStaffName",obj1.getString("protocolResponsibilityStaffName"));
resMap.put("contractId",obj1.getString("contractId"));
resMap.put("remark",obj1.getString("remark"));
resMap.put("serviceRemark",obj1.getString("serviceRemark"));
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 ctx + "/treeByEntName";
}
// @GetMapping("/task")
// @ResponseBody
// public AjaxResult task() {
// int i = templateConfigurationService.task();
// return AjaxResult.success(i);
// }
}