add 企业来款统计-分类统计导出

This commit is contained in:
lijiarao
2024-07-19 18:29:57 +08:00
parent ac1825f0fc
commit 4844e7135e
10 changed files with 284 additions and 1 deletions
@@ -46,6 +46,13 @@ public class StaticConfig {
StaticConfig.needPassword = needPassword;
}
public static String TEMPLATE_PATH;
@Value("${template.path.templatePath}")
public void setTemplatePath(String templatePath) {
StaticConfig.TEMPLATE_PATH = templatePath;
}
/*@Bean
public void initStatic() {
@@ -275,4 +275,7 @@ public interface PayWorkingGroupMapper extends BaseMapper<PayWorkingGroup> {
List<DepartStatistics> overallDepartmentStatistics(@Param("year") String year, @Param("type") String type);
List<DepartStatistics> allDepartmentStatistics(@Param("year") String year, @Param("type") String type);
List<CompanyComeMoneyClassificationList> queryPageListForCompanyClassification(@Param("companyComeMoneySearch") CompanyComeMoneySearch companyComeMoneySearch);
}
@@ -2696,4 +2696,30 @@
and pack = 0
) dataAll group by DATE_FORMAT(paymentDate, '%Y-%m') order by paymentDate
</select>
<select id="queryPageListForCompanyClassification"
resultType="com.jero.statistics.entity.CompanyComeMoneyClassificationList">
select chargeCompanyId as companyId,
chargeCompanyTemporaryName as companyName,
year,
chargeUse,
SUM(allMoney) as allMoney
from
v_statistical v
<where>
<if test="companyComeMoneySearch.year != null and companyComeMoneySearch.year != ''">
<foreach item="item" index="index" collection="companyComeMoneySearch.years"
open="AND year in (" separator="," close=")">
#{item}
</foreach>
</if>
<if test="companyComeMoneySearch.chargeCompanyId != null and companyComeMoneySearch.chargeCompanyId != ''">
<foreach item="item" index="index" collection="companyComeMoneySearch.chargeCompanyIds"
open="AND chargeCompanyId in (" separator="," close=")">
#{item}
</foreach>
</if>
</where>
group by chargeCompanyId,year,chargeUse
</select>
</mapper>
@@ -267,4 +267,6 @@ public interface IPayWorkingGroupService extends IService<PayWorkingGroup> {
* @param response
*/
void exportAllFile(HttpServletRequest request, HttpServletResponse response, PayWorkingGroup payWorkingGroup);
List<CompanyComeMoneyClassificationList> queryPageListForCompanyClassification(CompanyComeMoneySearch companyComeMoneySearch);
}
@@ -1023,6 +1023,11 @@ public class PayWorkingGroupServiceImpl extends ServiceImpl<PayWorkingGroupMappe
}
}
@Override
public List<CompanyComeMoneyClassificationList> queryPageListForCompanyClassification(CompanyComeMoneySearch companyComeMoneySearch) {
return payWorkingGroupMapper.queryPageListForCompanyClassification(companyComeMoneySearch);
}
private void createEntry(ZipOutputStream zipos, String folderPath, Set<String> addedEntries) throws IOException {
if (!addedEntries.contains(folderPath)) {
zipos.putNextEntry(new ZipEntry(folderPath));
@@ -1,5 +1,6 @@
package com.jero.statistics.controller;
import cn.hutool.core.collection.CollStreamUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
@@ -8,9 +9,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.AutoLog;
import com.jero.common.system.api.ISysBaseAPI;
import com.jero.common.system.vo.DictModel;
import com.jero.common.util.SpringContextUtils;
import com.jero.common.util.oConvertUtils;
import com.jero.company.entity.PayCompanyManagement;
import com.jero.company.service.IPayCompanyManagementService;
import com.jero.config.StaticConfig;
import com.jero.modules.system.mapper.SysUserMapper;
import com.jero.project.service.IPayWorkingGroupService;
import com.jero.statistics.entity.*;
@@ -20,7 +24,10 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.entity.TemplateExportParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -29,9 +36,15 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.util.*;
import static cn.hutool.poi.excel.sax.AttributeName.s;
/**
* @author zql
* @date 2021/9/23 14:07
@@ -212,6 +225,202 @@ public class CompanyComeMoneyStatisticsController {
}
/**
* 分类统计
*
* @param companyComeMoneySearch 企业来款统计
*/
@RequiresPermissions("companyPaymentStatistics:search")
@ApiOperation(value = "企业来款统计-分类统计")
@GetMapping(value = "/classification")
public Result<?> classification(CompanyComeMoneySearch companyComeMoneySearch,
HttpServletResponse response) {
String chargeCompanyId = companyComeMoneySearch.getChargeCompanyId();
List<String> chargeCompanyIds = StrUtil.split(chargeCompanyId, ',');
companyComeMoneySearch.setChargeCompanyIds(chargeCompanyIds);
String year = companyComeMoneySearch.getYear();
List<String> years = StrUtil.split(year, ',');
companyComeMoneySearch.setYears(years);
Map<String, Object> map = new HashMap<>();
//获取表头
List<DictModel> dictModels = sysBaseAPI.queryDictItemsByCode("payment_charge_use");
List<Map<String, String>> titleList = new ArrayList<>();
for (String s : years) {
Map<String, String> lm = new HashMap<>();
lm.put("name", s + "年度待确收金额");
lm.put("je", "t.je_"+s);
titleList.add(lm);
}
for (String s : years) {
for (DictModel dictModel : dictModels) {
Map<String, String> lm = new HashMap<>();
String text = dictModel.getText();
String value = dictModel.getValue();
lm.put("name", s + "年度-" + text +"-待确收金额");
lm.put("je", "t.je_"+s+"_"+value);
titleList.add(lm);
}
}
map.put("titleList", titleList);
//获取数据
List<CompanyComeMoneyClassificationList> list = payWorkingGroupService.queryPageListForCompanyClassification(companyComeMoneySearch);
List<Map<String, String>> valList = new ArrayList<>();
//先按企业id分组
Map<String, List<CompanyComeMoneyClassificationList>> companyIdKeyMap = CollStreamUtil.groupByKey(list, CompanyComeMoneyClassificationList::getCompanyId);
for (String companyId : chargeCompanyIds) {
Map<String, String> lm = new HashMap<>();
//获取单一企业数据
List<CompanyComeMoneyClassificationList> companyDateList = companyIdKeyMap.get(companyId);
if (companyDateList.isEmpty()) {
continue;
}else {
String companyName = companyDateList.get(0).getCompanyName();
lm.put("name", companyName);
}
//按年份分组
Map<String, List<CompanyComeMoneyClassificationList>> yearKeyMap = CollStreamUtil.groupByKey(companyDateList, CompanyComeMoneyClassificationList::getYear);
for (String yearKey : years) {
//获得单一年数据
List<CompanyComeMoneyClassificationList> dataList = yearKeyMap.get(yearKey);
BigDecimal bigDecimal = new BigDecimal("0.00");
for (CompanyComeMoneyClassificationList list1 : dataList) {
String allMoney = list1.getAllMoney();
bigDecimal = bigDecimal.add(new BigDecimal(allMoney));
}
lm.put("je_"+yearKey, bigDecimal.toString());
}
for (String yearKey : years) {
//获得单一年数据
List<CompanyComeMoneyClassificationList> dataList = yearKeyMap.get(yearKey);
for (DictModel dictModel : dictModels) {
BigDecimal bigDecimal = new BigDecimal("0.00");
String value = dictModel.getValue();
for (CompanyComeMoneyClassificationList list2 : dataList) {
if (list2.getChargeUse().equals(value)) {
String allMoney = list2.getAllMoney();
bigDecimal = bigDecimal.add(new BigDecimal(allMoney));
}
}
lm.put("je_"+yearKey+"_"+value, bigDecimal.toString());
}
}
valList.add(lm);
}
map.put("valList", valList);
return Result.OK(map);
}/**
* 分类统计
*
* @param companyComeMoneySearch 企业来款统计
*/
@RequiresPermissions("companyPaymentStatistics:search")
@ApiOperation(value = "企业来款统计-分类统计导出")
@GetMapping(value = "/classificationExcel")
public void classificationExcel(CompanyComeMoneySearch companyComeMoneySearch,
HttpServletResponse response) {
String chargeCompanyId = companyComeMoneySearch.getChargeCompanyId();
List<String> chargeCompanyIds = StrUtil.split(chargeCompanyId, ',');
companyComeMoneySearch.setChargeCompanyIds(chargeCompanyIds);
String year = companyComeMoneySearch.getYear();
List<String> years = StrUtil.split(year, ',');
companyComeMoneySearch.setYears(years);
Map<String, Object> map = new HashMap<>();
//获取表头
List<DictModel> dictModels = sysBaseAPI.queryDictItemsByCode("payment_charge_use");
List<Map<String, String>> titleList = new ArrayList<>();
for (String s : years) {
Map<String, String> lm = new HashMap<>();
lm.put("name", s + "年度待确收金额");
lm.put("je", "t.je_"+s);
titleList.add(lm);
}
for (String s : years) {
for (DictModel dictModel : dictModels) {
Map<String, String> lm = new HashMap<>();
String text = dictModel.getText();
String value = dictModel.getValue();
lm.put("name", s + "年度-" + text +"-待确收金额");
lm.put("je", "t.je_"+s+"_"+value);
titleList.add(lm);
}
}
map.put("titleList", titleList);
//获取数据
List<CompanyComeMoneyClassificationList> list = payWorkingGroupService.queryPageListForCompanyClassification(companyComeMoneySearch);
List<Map<String, String>> valList = new ArrayList<>();
//先按企业id分组
Map<String, List<CompanyComeMoneyClassificationList>> companyIdKeyMap = CollStreamUtil.groupByKey(list, CompanyComeMoneyClassificationList::getCompanyId);
for (String companyId : chargeCompanyIds) {
Map<String, String> lm = new HashMap<>();
//获取单一企业数据
List<CompanyComeMoneyClassificationList> companyDateList = companyIdKeyMap.get(companyId);
if (companyDateList.isEmpty()) {
continue;
}else {
String companyName = companyDateList.get(0).getCompanyName();
lm.put("name", companyName);
}
//按年份分组
Map<String, List<CompanyComeMoneyClassificationList>> yearKeyMap = CollStreamUtil.groupByKey(companyDateList, CompanyComeMoneyClassificationList::getYear);
for (String yearKey : years) {
//获得单一年数据
List<CompanyComeMoneyClassificationList> dataList = yearKeyMap.get(yearKey);
BigDecimal bigDecimal = new BigDecimal("0.00");
for (CompanyComeMoneyClassificationList list1 : dataList) {
String allMoney = list1.getAllMoney();
bigDecimal = bigDecimal.add(new BigDecimal(allMoney));
}
lm.put("je_"+yearKey, bigDecimal.toString());
}
for (String yearKey : years) {
//获得单一年数据
List<CompanyComeMoneyClassificationList> dataList = yearKeyMap.get(yearKey);
for (DictModel dictModel : dictModels) {
BigDecimal bigDecimal = new BigDecimal("0.00");
String value = dictModel.getValue();
for (CompanyComeMoneyClassificationList list2 : dataList) {
if (list2.getChargeUse().equals(value)) {
String allMoney = list2.getAllMoney();
bigDecimal = bigDecimal.add(new BigDecimal(allMoney));
}
}
lm.put("je_"+yearKey+"_"+value, bigDecimal.toString());
}
}
valList.add(lm);
}
map.put("valList", valList);
String excelName = "企业来款分类统计导出模板.xlsx";
String tPath = StaticConfig.TEMPLATE_PATH + excelName;
TemplateExportParams params = new TemplateExportParams(tPath);
params.setColForEach(true);
Workbook workbook = ExcelExportUtil.exportExcel(params, map);
try {
response.setContentType("application/ms-excel;charset=UTF-8");
response.setContentType("application/x-download");
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Disposition",
"attachment;filename=".concat(String.valueOf(URLEncoder.encode("征集问题.xls", "UTF-8"))));
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
workbook.close();
if (outputStream != null) {
outputStream.close();
}
}catch (Exception e){
}
}
}
@@ -0,0 +1,28 @@
package com.jero.statistics.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
/**
* @author zql
* @date 2021/9/23 14:09
*/
@Data
public class CompanyComeMoneyClassificationList {
@ApiModelProperty(value = "企业id")
private String companyId;
@ApiModelProperty(value = "企业名称")
private String companyName;
@ApiModelProperty(value = "年度待确收金额")
private String allMoney;
@ApiModelProperty(value = "年份")
private String year;
@ApiModelProperty(value = "来款用途")
private String chargeUse;
}
@@ -24,6 +24,7 @@ public class CompanyComeMoneySearch {
@ApiModelProperty(value = "来款年份")
private String year;
private List<String> years;
@ApiModelProperty(value = "应收总金额")
private String allMoney;
@@ -361,4 +361,6 @@ template:
#批复文件pdf
pdf: D:\\hzwl\\income_payments\\income_payments_managerment\\template\\approvalTemplate.pdf
#入会申请表word
applicationWord: E:\\biao_zhun_suo\\template\\applicationWord.docx
applicationWord: E:\\biao_zhun_suo\\template\\applicationWord.docx
#模版目录
templatePath: D:\\hzwl\\income_payments\\income_payments_managerment\\template\\
Binary file not shown.