EntrustOldApplyBiz.java
3.09 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
package com.cjs.cms.biz.ration;
import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.cjs.cms.action.user.fund.UserBalanceAction;
import com.cjs.cms.dao.ration.RationOldConfigDao;
import com.cjs.cms.dao.ration.TrustApplyDao;
import com.cjs.cms.util.file.FileUtil;
import com.cjs.cms.util.lang.DateEnum;
import com.cjs.cms.util.lang.DateUtil;
import com.cjs.cms.util.poi.ExcelConfig;
import com.cjs.cms.util.poi.ExcelUtil;
/**
* 申请在托管查询业务
*
* @author xiangwei
*
*/
@Service
public class EntrustOldApplyBiz {
@Value("${download.export}")
private String exportPath;
@Autowired
private RationOldConfigDao rationOldConfigDao;
@Autowired
private TrustApplyDao applyDao;
/**申请在托管选择*/
public List<Map<String, Object>> searchChoose(Map<String, Object> params) {
List<String> otcCodes = rationOldConfigDao.queryAllCode(params);
if (otcCodes.size() == 0) {
return new ArrayList<Map<String, Object>>();
}
params.put("otcCodes", otcCodes);
List<Map<String, Object>> resultMap = applyDao.queryAgree(params);
return resultMap;
}
/**申请在托管总页数*/
public int searchChooseTotal(Map<String, Object> params) {
List<String> otcCodes = rationOldConfigDao.queryAllCode(params);
if (otcCodes.size() == 0) {
return 0;
}
params.put("otcCodes", otcCodes);
return applyDao.queryAgreeTotal(params);
}
/**
* 生成权益查询excel表
*/
public File export(Map<String, Object> params) throws Exception {
String filename = "申请在托管选择_" + DateUtil.getNow(DateEnum.UNSIGNED_DATE_TIME);
filename = FileUtil.makeMonthDir(exportPath) + filename + ".xlsx";
File targetFile = new File(filename);
ExcelConfig config = new ExcelConfig();
URI template = UserBalanceAction.class.getResource("/excel/ration_apply_choose.xlsx")
.toURI();
List<String> otcCodes = rationOldConfigDao.queryAllCode(params);
if (otcCodes.size() == 0) {
new ArrayList<Map<String, Object>>();
}
params.put("otcCodes", otcCodes);
List<Map<String, Object>> resultMap = applyDao.queryAgree(params);
for (Map<String, Object> map : resultMap) {
String date = map.get("AGGREE_DATE") == null ? "" : map.get("AGGREE_DATE").toString();
if (!"".equals(date)) {
date = date.substring(0, 4) + "-" + date.substring(4, 6) + "-"
+ date.substring(6, 8);
map.put("AGGREE_DATE", date);
}
}
// 先生成Excel文件
config.setSourceTemplate(new File(template));
config.setTargetFile(targetFile);
config.setData(resultMap);
new ExcelUtil(config).writeExcel();
return targetFile;
}
}