WebFinanceInfoController.java
12.4 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
package com.lhcredit.project.webbusiness.controller;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lhcredit.common.utils.DateUtils;
import com.lhcredit.common.utils.ReportErrorUtils;
import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.common.utils.security.ShiroUtils;
import com.lhcredit.framework.aspectj.lang.annotation.ReportCount;
import com.lhcredit.framework.aspectj.lang.enums.OperatorType;
import com.lhcredit.project.business.bCreditReport.domain.BCreditReport;
import com.lhcredit.project.business.bCreditReport.mapper.BCreditReportMapper;
import com.lhcredit.project.business.bCreditReport.service.IBCreditReportService;
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.business.frontUser.service.IFrontUserService;
import com.lhcredit.project.business.reportFinanceData.domain.ReportFinanceData;
import com.lhcredit.project.business.reportFinanceData.service.IReportFinanceDataService;
import com.lhcredit.project.business.reportMake.finance.FinanceDataService;
import com.lhcredit.project.business.statisticsFinancePageselect.domain.StatisticsFinancePageselect;
import com.lhcredit.project.business.statisticsFinancePageselect.service.IStatisticsFinancePageselectService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
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.financeInfo.domain.FinanceInfo;
import com.lhcredit.project.business.financeInfo.service.IFinanceInfoService;
import com.lhcredit.framework.web.controller.BaseController;
import com.lhcredit.framework.web.domain.AjaxResult;
import static com.lhcredit.common.utils.JsonPathUtils.jsonPathString;
/**
* 财务数据信息对外接口
*
* @author lhcredit
* @date 2024-06-11
*/
@RestController
@RequestMapping("/web/financeInfo")
public class WebFinanceInfoController extends BaseController {
@Autowired
private IFinanceInfoService financeInfoService;
@Autowired
private IBCreditReportService ibCreditReportService;
@Autowired
private IFrontUserService frontUserService;
@Autowired
private IReportFinanceDataService reportFinanceDataService;
@Autowired
private FinanceDataService financeDataService;
@Autowired
private BCreditReportMapper bCreditReportMapper;
@Autowired
private IFrontDeptService frontDeptService;
@Autowired
private IStatisticsFinancePageselectService financePageselectService;
public static String sourceType="2023";//作为页面调取财务数据使用的标识 目前还没有考虑 如何更新2024数据 目前最新就是2023
@ReportCount(reportType = "financeInfo")
@RequestMapping("reflushedFinance")
public AjaxResult reflushedFinance(String name ){
FrontUserMon userInfo = getUserInfo();
List<ReportFinanceData> list=new ArrayList<>();
String url = "http://cw.lhdna.com/queryDataController/queryData?name=" +name;
String str = HttpRequest.get(url).execute().body();
JSONObject jsonObject = JSONObject.parseObject(str);
JSONArray data = jsonObject.getJSONArray("data");
list= org.apache.commons.collections.CollectionUtils.isEmpty(data)?new ArrayList<>():data.toJavaList(ReportFinanceData.class);
list.forEach(v->{v.setReportTemplate("ds");v.setLastUpdataTime(new Date());});
//走查询就是记录查询记录了
StatisticsFinancePageselect statisticsFinancePageselect=new StatisticsFinancePageselect();
statisticsFinancePageselect.setUserId(userInfo.getId());
statisticsFinancePageselect.setOrgId(frontDeptService.getParentDept(userInfo.getOrgId()).getId());
statisticsFinancePageselect.setUserName(userInfo.getUserName());
statisticsFinancePageselect.setEname(name);
statisticsFinancePageselect.setDataType("工商大数");
statisticsFinancePageselect.setCreditTime(new Date());
statisticsFinancePageselect.setCountStatus(1);
if (org.apache.commons.collections.CollectionUtils.isEmpty(list)) {
statisticsFinancePageselect.setCountStatus(0);
statisticsFinancePageselect.setResultRemark("无财务");
financePageselectService.insertStatisticsFinancePageselect(statisticsFinancePageselect);
return AjaxResult.success(new JSONObject(){{put("status",4);}});//status=4 刷新无财务数据
}else{
reportFinanceDataService.saveList(list);
}
List<ReportFinanceData> ds = reportFinanceDataService.selectReportFinanceDataList(ReportFinanceData.builder().ename(name)
.reportTemplate("ds").build());
ds=ds.stream().sorted(Comparator.comparing(ReportFinanceData::getYear).reversed()).collect(Collectors.toList());
if (ds.size()>3){
ds=ds.subList(0,3);
}
JSONObject financeData =financeDataService.webTablePageFinanceCompute(ds);
statisticsFinancePageselect.setCountStatus(1);
statisticsFinancePageselect.setResultRemark(ds.stream().map(m->m.getYear()+"年")
.collect(Collectors.joining(","))+"财务数据");
financePageselectService.insertStatisticsFinancePageselect(statisticsFinancePageselect);
financeData.put("status",1);
return AjaxResult.success(financeData);//status=1 用户1年内做过报告数据
}
@RequestMapping("getWebFinanceShowData")
public AjaxResult getWebFinanceShowData(String name,String search){
FrontUserMon userInfo = getUserInfo();
FrontUser frontUser = frontUserService.selectFrontUserById(userInfo.getId());
BCreditReport bCreditReport=new BCreditReport();
if (null==userInfo.getOrgId())return AjaxResult.error("未找到机构信息");
bCreditReport.setOrgId(userInfo.getOrgId());
bCreditReport.setEnterpriseName(name);
List<String> bCreditReports = bCreditReportMapper.selectCountByFinanceStatistics(userInfo.getOrgId(),name);
List<Object> list2=financePageselectService.selectCountByFinanceStatistics(userInfo.getOrgId(),name);
if (CollectionUtils.isEmpty(bCreditReports)&& CollectionUtils.isEmpty(list2)){
return AjaxResult.success(new JSONObject(){{put("status",0);}});//status=0 用户无报告数据
}
//下单xc据也查ds
List<ReportFinanceData> ds = reportFinanceDataService.selectReportFinanceDataList(ReportFinanceData.builder().ename(name)
.reportTemplate("ds").build());
StatisticsFinancePageselect st=new StatisticsFinancePageselect();
st.setUserId(userInfo.getId());
//4个字段处理
if (CollectionUtils.isEmpty(ds)){
return AjaxResult.success(new JSONObject(){{put("status",3);}});//status=3 无财务数据
}
ds=ds.stream().sorted(Comparator.comparing(ReportFinanceData::getYear).reversed()).collect(Collectors.toList());
if (ds.size()>3){
ds=ds.subList(0,3);
}
JSONObject financeData =financeDataService.webTablePageFinanceCompute(ds);
financeData.put("status",1);
return AjaxResult.success(financeData);//status=1 用户1年内做过报告数据
}
@ReportCount(reportType = "financeInfo")
@RequestMapping("getReportSysData")
public AjaxResult getReportSysData(String ename,String orgCode){
FrontUserMon userInfo = getUserInfo();
List<FinanceInfo> oldList = financeInfoService.selectFinanceInfoList(FinanceInfo.builder().ename(ename).source(sourceType).build());
if (CollectionUtils.isEmpty(oldList)){
List<FinanceInfo> list=financeInfoService.getReportSystemApiData(ename,orgCode,userInfo.getId(),userInfo.getOrgId());
for (FinanceInfo financeInfo : list) {
financeInfo.setEname(ename);
financeInfo.setSource(sourceType);
financeInfoService.insertFinanceInfo(financeInfo);
}
//记录查询日志
StatisticsFinancePageselect statisticsFinancePageselect=new StatisticsFinancePageselect();
statisticsFinancePageselect.setUserId(userInfo.getId());
statisticsFinancePageselect.setOrgId(userInfo.getOrgId());
statisticsFinancePageselect.setUserName(userInfo.getUserName());
statisticsFinancePageselect.setEname(ename);
statisticsFinancePageselect.setDataType("工商大数");
statisticsFinancePageselect.setCreditTime(new Date());
if(list!=null&&list.size()>0){
statisticsFinancePageselect.setCountStatus(1);
statisticsFinancePageselect.setResultRemark(list.stream().map(m->m.getYear()+"年")
.collect(Collectors.joining(","))+"财务数据");
}else {
statisticsFinancePageselect.setCountStatus(0);
statisticsFinancePageselect.setResultRemark("无财务");
}
financePageselectService.insertStatisticsFinancePageselect(statisticsFinancePageselect);
oldList=list;
}
return AjaxResult.success(oldList);
}
/**
* 查询财务数据列表接口
*/
@ApiOperation("查询财务数据列表")
@Log(title = "财务数据", businessType = BusinessType.LIST, operatorType = OperatorType.WEB)
@GetMapping
public AjaxResult list(FinanceInfo financeInfo) {
startPage();
financeInfo.setDelFlag("0");
List<FinanceInfo> list = financeInfoService.changeModel(financeInfoService.selectFinanceInfoList(financeInfo));
return toAjax(list);
}
/**
* 查询财务数据详情接口
*/
@ApiOperation("查询财务数据详情")
@ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "int", paramType = "path")
@Log(title = "财务数据", businessType = BusinessType.DETAIL, operatorType = OperatorType.WEB)
@GetMapping("/{id}")
public AjaxResult detail(@PathVariable Long id) {
FinanceInfo financeInfo =financeInfoService.changeModel(financeInfoService.selectFinanceInfoById(id));
if (StringUtils.isNull(financeInfo)) {
return AjaxResult.error("该信息不存在");
}
return toAjax(financeInfo);
}
/**
* 新增保存财务数据接口
*/
@ApiOperation("新增财务数据")
@ApiImplicitParam(name = "financeInfo", value = "财务数据", dataType = "FinanceInfo")
@Log(title = "财务数据", businessType = BusinessType.INSERT, operatorType = OperatorType.WEB)
@PostMapping
public AjaxResult addSave(FinanceInfo financeInfo) {
financeInfo.setCreateBy(ShiroUtils.getLoginName());
financeInfo.setCreateTime(new Date());
financeInfo.setUpdateBy(ShiroUtils.getLoginName());
financeInfo.setUpdateTime(new Date());
return toAjax(financeInfoService.insertFinanceInfo(financeInfo));
}
/**
* 修改保存财务数据接口
*/
@ApiOperation("修改财务数据")
@ApiImplicitParam(name = "financeInfo", value = "财务数据", dataType = "FinanceInfo")
@Log(title = "财务数据", businessType = BusinessType.UPDATE, operatorType = OperatorType.WEB)
@PutMapping
public AjaxResult update(FinanceInfo financeInfo) {
if (StringUtils.isNull(financeInfo) || StringUtils.isNull(financeInfo.getId())){
return AjaxResult.error("主键id不能为空");
}
financeInfo.setUpdateBy(ShiroUtils.getLoginName());
financeInfo.setUpdateTime(new Date());
return toAjax(financeInfoService.updateFinanceInfo(financeInfo));
}
/**
* 删除财务数据接口
*/
@ApiOperation("删除财务数据")
@ApiImplicitParam(name = "ids", value = "主键id,多条以英文逗号分隔", required = true, dataType = "String", paramType = "path")
@Log(title = "财务数据", businessType = BusinessType.DELETE, operatorType = OperatorType.WEB)
@DeleteMapping("/{ids}")
public AjaxResult delete(@PathVariable String ids) {
return toAjax(financeInfoService.deleteFinanceInfoByIds(ids));
}
}