WebForCRMController.java
7.49 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
package com.lhcredit.project.webbusiness.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.lhcredit.common.utils.OssUtils;
import com.lhcredit.common.utils.ServletUtils;
import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.framework.aspectj.lang.annotation.CheckToken;
import com.lhcredit.framework.aspectj.lang.annotation.Log;
import com.lhcredit.framework.aspectj.lang.annotation.ReportCount;
import com.lhcredit.framework.aspectj.lang.enums.BusinessType;
import com.lhcredit.framework.aspectj.lang.enums.OperatorType;
import com.lhcredit.framework.web.controller.BaseController;
import com.lhcredit.framework.web.domain.AjaxResult;
import com.lhcredit.framework.web.page.TableDataInfo;
import com.lhcredit.project.business.bCreditReport.domain.BCreditReport;
import com.lhcredit.project.business.bCreditReport.mapper.BCreditReportMapper;
import com.lhcredit.project.business.bCreditReport.service.BCreditReportServiceImpl;
import com.lhcredit.project.business.bCreditReport.service.IBCreditReportService;
import com.lhcredit.project.business.bReportTable.domain.BReportTable;
import com.lhcredit.project.business.bReportTable.service.IBReportTableService;
import com.lhcredit.project.business.frontUser.domain.FrontUserMon;
import com.lhcredit.project.business.reportFinanceData.domain.ReportFinanceData;
import com.lhcredit.project.business.reportFinanceData.service.IReportFinanceDataService;
import com.lhcredit.project.business.reportMake.ReportMakeService;
import com.lhcredit.project.system.dict.domain.DictData;
import com.lhcredit.project.system.dict.service.DictDataServiceImpl;
import com.lhcredit.project.system.dict.service.IDictDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.compress.utils.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* 信用管家 对 crm接口
*
* @author lhcredit
* @date 2024-06-03
*/
@RestController
@RequestMapping("/api-V2.0/forCrm")
public class WebForCRMController extends BaseController {
@Autowired
private IDictDataService dictDataService;
@Autowired
private BCreditReportServiceImpl bCreditReportService;
private static Logger logger = LoggerFactory.getLogger(WebForCRMController.class);
/**
* crm系统查询 字典信息
* @param dictData
* @return
*/
@PostMapping("/getDictData")
public JSONObject getDictData(DictData dictData){
dictData.setStatus("0");
List<DictData> list = dictDataService.selectDictDataList(dictData);
JSONObject result = new JSONObject();
result.put("data", list);
result.put("code", 200);
result.put("msg", "success");
// result.setData(list);
// result.setCode(200);
// result.setMsg("操作成功");
return result;
}
/**
* crm查询信用报告
* @param bCreditReport
* @return
*/
@PostMapping("/getBcreditReportList")
public TableDataInfo getBcreditReportList(@RequestBody BCreditReport bCreditReport){
startPage(bCreditReport.getPageNum(), bCreditReport.getPageSize());
List<BCreditReport> list = bCreditReportService.getBcreditReportListForCrm(bCreditReport);
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(200);
rspData.setRows(list);
rspData.setTotal(new PageInfo(list).getTotal());
return rspData;
}
/**
* crm 查询信用报告excel导出
* @param bCreditReport
*/
@PostMapping("/exportBCreditReport")
public AjaxResult exportBCreditReport(@RequestBody BCreditReport bCreditReport) {
List<BCreditReport> list = bCreditReportService.getBcreditReportListForCrm(bCreditReport);
return AjaxResult.success(list);
// ExcelUtil<BCreditReport> excelUtil = new ExcelUtil<>(BCreditReport.class );
// return excelUtil.exportExcel(list,"信用报告");
/*Collection<BCreditReport> bCreditReports = CollUtil.newArrayList(list);
ExcelWriter writer = ExcelUtil.getWriter();
writer.write(bCreditReports,true);
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition","attachment;filename=Bcredits.xls");
ServletOutputStream outputStream = null;
try {
outputStream = response.getOutputStream();
writer.flush(outputStream,true);
} catch (IOException e) {
logger.error(e.getMessage());
throw new RuntimeException("信用报告导出到crm异常");
} finally {
writer.close();
IoUtil.close(outputStream);
}*/
}
/**
* 根据合同查询 每个合同id下的报告数量
* @param param
* @return
*/
@PostMapping("/getReportCountByContractIds")
public AjaxResult getReportCountByContractIds(@RequestBody String param) {
JSONObject paramObj = JSONObject.parseObject(param);
String contractIdStr = paramObj.getString("contractIds");
List<BCreditReport> reportCountByContractIds;
//无合同id 则查询所有
if (StringUtils.isBlank(contractIdStr)) {
reportCountByContractIds = bCreditReportService.getBCreditReportCountByContractIds(new ArrayList<>());
return AjaxResult.success(reportCountByContractIds);
}
//拆分合同id 并按照合同id查询 报告数量
String[] ids = contractIdStr.split(",");
List<Long> contractIds = Lists.newArrayList();
for (String id : ids) {
contractIds.add(Long.parseLong(id));
}
reportCountByContractIds = bCreditReportService.getBCreditReportCountByContractIds(contractIds);
return AjaxResult.success(reportCountByContractIds);
}
/**
* 查询 报告列表中的 报告类型 并返回
* @return
*/
@GetMapping("/getBCreditReportType/{contractId}")
public JSONObject getBCreditReportType(@PathVariable("contractId") Long contractId){
JSONObject object = new JSONObject();
if(contractId == null){
object.put("code", 300);
object.put("msg", "合同id不能为空");
return object;
}
List<DictData> reportTypes = bCreditReportService.getRrportType(contractId);
object.put("code", 200);
object.put("msg", "success");
object.put("data", reportTypes);
return object;
}
public static void main(String[] args) {
LocalDate now = LocalDate.now();
System.out.println(now.toString());
Integer i = new Integer(2000);
int a= 2000;
System.out.println(i.equals(a));
}
}