个税申报-在线对比
This commit is contained in:
parent
3a9b772cb9
commit
54823f2fbd
|
|
@ -25,5 +25,10 @@ public class SalaryItemConstant {
|
||||||
*/
|
*/
|
||||||
public static final String RESULT_EXPORT_FIELD_SIGN="_salaryAcctResultExportFieldSign";
|
public static final String RESULT_EXPORT_FIELD_SIGN="_salaryAcctResultExportFieldSign";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个税申报在线对比缓存表头字段key
|
||||||
|
*/
|
||||||
|
public static final String TAX_DECLARE_CONTRAST_FIELD_SIGN="_taxDeclareContrastFieldSign";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.engine.salary.entity.taxdeclaration.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个税申报表表头
|
||||||
|
* <p>Copyright: Copyright (c) 2023</p>
|
||||||
|
* <p>Company: 泛微软件</p>
|
||||||
|
*
|
||||||
|
* @author qiantao
|
||||||
|
* @version 1.0
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class TaxReportColumnDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申报表的列名
|
||||||
|
*/
|
||||||
|
private String reportColumnName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申报表的列索引
|
||||||
|
*/
|
||||||
|
private String reportColumnDataIndex;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,8 @@ package com.engine.salary.entity.taxdeclaration.param;
|
||||||
import com.engine.salary.common.BaseQueryParam;
|
import com.engine.salary.common.BaseQueryParam;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对比查询
|
* 对比查询
|
||||||
* <p>Copyright: Copyright (c) 2023</p>
|
* <p>Copyright: Copyright (c) 2023</p>
|
||||||
|
|
@ -28,4 +30,9 @@ public class ContrastQueryParam extends BaseQueryParam {
|
||||||
* 是否只显示差异项
|
* 是否只显示差异项
|
||||||
*/
|
*/
|
||||||
private boolean onlyShowDiffItem;
|
private boolean onlyShowDiffItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选对比项目
|
||||||
|
*/
|
||||||
|
private List<String> columns;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.engine.salary.service;
|
package com.engine.salary.service;
|
||||||
|
|
||||||
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationValueListDTO;
|
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationValueListDTO;
|
||||||
|
import com.engine.salary.entity.taxdeclaration.dto.TaxReportColumnDTO;
|
||||||
import com.engine.salary.entity.taxdeclaration.param.ContrastQueryParam;
|
import com.engine.salary.entity.taxdeclaration.param.ContrastQueryParam;
|
||||||
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationValueListQueryParam;
|
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationValueListQueryParam;
|
||||||
import com.engine.salary.entity.taxdeclaration.param.TaxDeclareRecordDetailSaveParam;
|
import com.engine.salary.entity.taxdeclaration.param.TaxDeclareRecordDetailSaveParam;
|
||||||
|
|
@ -8,6 +9,7 @@ import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO;
|
||||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationValuePO;
|
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationValuePO;
|
||||||
import com.engine.salary.entity.taxdeclaration.po.TaxDeclareRecordPO;
|
import com.engine.salary.entity.taxdeclaration.po.TaxDeclareRecordPO;
|
||||||
import com.engine.salary.util.page.PageInfo;
|
import com.engine.salary.util.page.PageInfo;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -94,10 +96,27 @@ public interface TaxDeclarationValueService {
|
||||||
*/
|
*/
|
||||||
Map<String, Object> contrast(ContrastQueryParam param);
|
Map<String, Object> contrast(ContrastQueryParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在线对比表头列表
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
|
Map<String, List<TaxReportColumnDTO>> contrastHeaderList(ContrastQueryParam param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存在线对比表头列表
|
||||||
|
* @param columnIndex
|
||||||
|
*/
|
||||||
|
void cacheContrastHeader(List<String> columnIndex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出在线对比
|
||||||
|
*/
|
||||||
|
XSSFWorkbook exportContrast(ContrastQueryParam param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据主键删除
|
* 根据主键删除
|
||||||
* @param deleteId
|
* @param deleteId
|
||||||
*/
|
*/
|
||||||
void deleteById(Long deleteId);
|
void deleteById(Long deleteId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
package com.engine.salary.service.impl;
|
package com.engine.salary.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import com.cloudstore.dev.api.util.Util_DataCache;
|
||||||
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
||||||
import com.engine.common.util.ServiceUtil;
|
import com.engine.common.util.ServiceUtil;
|
||||||
import com.engine.core.impl.Service;
|
import com.engine.core.impl.Service;
|
||||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||||
|
import com.engine.salary.constant.SalaryItemConstant;
|
||||||
import com.engine.salary.encrypt.EncryptUtil;
|
import com.engine.salary.encrypt.EncryptUtil;
|
||||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||||
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO;
|
import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO;
|
||||||
|
|
@ -12,6 +14,7 @@ import com.engine.salary.entity.extemp.po.ExtEmpPO;
|
||||||
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationValueList;
|
import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationValueList;
|
||||||
import com.engine.salary.entity.taxdeclaration.dto.ContrastListDTO;
|
import com.engine.salary.entity.taxdeclaration.dto.ContrastListDTO;
|
||||||
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationValueListDTO;
|
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationValueListDTO;
|
||||||
|
import com.engine.salary.entity.taxdeclaration.dto.TaxReportColumnDTO;
|
||||||
import com.engine.salary.entity.taxdeclaration.param.ContrastQueryParam;
|
import com.engine.salary.entity.taxdeclaration.param.ContrastQueryParam;
|
||||||
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationValueListQueryParam;
|
import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationValueListQueryParam;
|
||||||
import com.engine.salary.entity.taxdeclaration.param.TaxDeclareRecordDetailSaveParam;
|
import com.engine.salary.entity.taxdeclaration.param.TaxDeclareRecordDetailSaveParam;
|
||||||
|
|
@ -33,15 +36,17 @@ import com.engine.salary.service.*;
|
||||||
import com.engine.salary.util.JsonUtil;
|
import com.engine.salary.util.JsonUtil;
|
||||||
import com.engine.salary.util.SalaryEntityUtil;
|
import com.engine.salary.util.SalaryEntityUtil;
|
||||||
import com.engine.salary.util.SalaryEnumUtil;
|
import com.engine.salary.util.SalaryEnumUtil;
|
||||||
|
import com.engine.salary.util.db.IdGenerator;
|
||||||
import com.engine.salary.util.db.MapperProxyFactory;
|
import com.engine.salary.util.db.MapperProxyFactory;
|
||||||
|
import com.engine.salary.util.excel.ExcelUtilPlus;
|
||||||
import com.engine.salary.util.page.PageInfo;
|
import com.engine.salary.util.page.PageInfo;
|
||||||
import com.engine.salary.util.page.SalaryPageUtil;
|
import com.engine.salary.util.page.SalaryPageUtil;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.engine.salary.util.db.IdGenerator;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import weaver.general.Util;
|
import weaver.general.Util;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
|
@ -321,6 +326,22 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar
|
||||||
// 查询个税申报表表头
|
// 查询个税申报表表头
|
||||||
IncomeCategoryEnum incomeCategoryEnum = SalaryEnumUtil.enumMatchByValue(taxDeclaration.getIncomeCategory(), IncomeCategoryEnum.class);
|
IncomeCategoryEnum incomeCategoryEnum = SalaryEnumUtil.enumMatchByValue(taxDeclaration.getIncomeCategory(), IncomeCategoryEnum.class);
|
||||||
List<TaxReportColumnPO> taxReportColumns = getTaxReportColumnService(user).listByIncomeCategory(incomeCategoryEnum);
|
List<TaxReportColumnPO> taxReportColumns = getTaxReportColumnService(user).listByIncomeCategory(incomeCategoryEnum);
|
||||||
|
// 筛选表头
|
||||||
|
// 获取缓存中保存的设置
|
||||||
|
String cacheKey = user.getUID() + SalaryItemConstant.TAX_DECLARE_CONTRAST_FIELD_SIGN;
|
||||||
|
String cacheValue = (String) Util_DataCache.getObjVal(cacheKey);
|
||||||
|
List<String> selectedItems = JsonUtil.parseList(cacheValue, String.class) == null ? new ArrayList<>() : JsonUtil.parseList(cacheValue, String.class);
|
||||||
|
if (CollectionUtils.isNotEmpty(selectedItems)) {
|
||||||
|
Map<String, TaxReportColumnPO> columnMap = SalaryEntityUtil.convert2Map(taxReportColumns, TaxReportColumnPO::getReportColumnDataIndex);
|
||||||
|
List<TaxReportColumnPO> finalColumn = new ArrayList<>();
|
||||||
|
selectedItems.stream().forEach(index -> {
|
||||||
|
TaxReportColumnPO c = columnMap.get(index);
|
||||||
|
if (c!=null) {
|
||||||
|
finalColumn.add(c);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
taxReportColumns = finalColumn;
|
||||||
|
}
|
||||||
List<String> columns = SalaryEntityUtil.properties(taxReportColumns, TaxReportColumnPO::getReportColumnName, Collectors.toList());
|
List<String> columns = SalaryEntityUtil.properties(taxReportColumns, TaxReportColumnPO::getReportColumnName, Collectors.toList());
|
||||||
// 人员id
|
// 人员id
|
||||||
Set<Long> employeeIds = SalaryEntityUtil.properties(taxDeclarationValues, TaxDeclarationValuePO::getEmployeeId);
|
Set<Long> employeeIds = SalaryEntityUtil.properties(taxDeclarationValues, TaxDeclarationValuePO::getEmployeeId);
|
||||||
|
|
@ -370,6 +391,7 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar
|
||||||
for (Map<String, Object> local : localList) {
|
for (Map<String, Object> local : localList) {
|
||||||
AtomicBoolean hasDiff = new AtomicBoolean(false);
|
AtomicBoolean hasDiff = new AtomicBoolean(false);
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("工号", local.get("jobNum"));
|
||||||
result.put("姓名", local.get("姓名"));
|
result.put("姓名", local.get("姓名"));
|
||||||
result.put("证件类型", local.get("证件类型"));
|
result.put("证件类型", local.get("证件类型"));
|
||||||
result.put("证件号码", local.get("证件号码"));
|
result.put("证件号码", local.get("证件号码"));
|
||||||
|
|
@ -413,6 +435,72 @@ public class TaxDeclarationValueServiceImpl extends Service implements TaxDeclar
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, List<TaxReportColumnDTO>> contrastHeaderList(ContrastQueryParam param) {
|
||||||
|
Map<String, List<TaxReportColumnDTO>> resultMap = new HashMap<>();
|
||||||
|
TaxDeclarationPO taxDeclaration = getTaxDeclarationService(user).getById(param.getTaxDeclarationId());
|
||||||
|
if (taxDeclaration == null) {
|
||||||
|
throw new SalaryRunTimeException("无申报表");
|
||||||
|
}
|
||||||
|
// 查询个税申报表表头
|
||||||
|
IncomeCategoryEnum incomeCategoryEnum = SalaryEnumUtil.enumMatchByValue(taxDeclaration.getIncomeCategory(), IncomeCategoryEnum.class);
|
||||||
|
List<TaxReportColumnPO> taxReportColumns = getTaxReportColumnService(user).listByIncomeCategory(incomeCategoryEnum);
|
||||||
|
List<TaxReportColumnDTO> defaultDtoList = new ArrayList<>();
|
||||||
|
taxReportColumns.stream().forEach(po -> {defaultDtoList.add(TaxReportColumnDTO.builder().id(po.getId()).reportColumnName(po.getReportColumnName()).reportColumnDataIndex(po.getReportColumnDataIndex()).build());});
|
||||||
|
resultMap.put("defaultList",defaultDtoList);
|
||||||
|
// 获取缓存中保存的设置
|
||||||
|
String cacheKey = user.getUID() + SalaryItemConstant.TAX_DECLARE_CONTRAST_FIELD_SIGN;
|
||||||
|
String cacheValue = (String) Util_DataCache.getObjVal(cacheKey);
|
||||||
|
List<String> selectedItems = JsonUtil.parseList(cacheValue, String.class) == null ? new ArrayList<>() : JsonUtil.parseList(cacheValue, String.class);
|
||||||
|
if (CollectionUtils.isEmpty(selectedItems)) {
|
||||||
|
// 默认全选
|
||||||
|
resultMap.put("selectedList", defaultDtoList);
|
||||||
|
resultMap.put("unSelectedList", Collections.emptyList());
|
||||||
|
} else {
|
||||||
|
Map<String, TaxReportColumnDTO> columnMap = SalaryEntityUtil.convert2Map(defaultDtoList, TaxReportColumnDTO::getReportColumnDataIndex);
|
||||||
|
List<TaxReportColumnDTO> selectedColumn = new ArrayList<>();
|
||||||
|
selectedItems.stream().forEach(index -> {
|
||||||
|
TaxReportColumnDTO taxReportColumnDTO = columnMap.get(index);
|
||||||
|
if (taxReportColumnDTO != null) {
|
||||||
|
// 已选择的项目
|
||||||
|
selectedColumn.add(taxReportColumnDTO);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 过滤出未选择的项目
|
||||||
|
List<TaxReportColumnDTO> unSelectedList = defaultDtoList.stream().filter(po -> !selectedItems.contains(po.getReportColumnDataIndex())).collect(Collectors.toList());
|
||||||
|
resultMap.put("selectedList", selectedColumn);
|
||||||
|
resultMap.put("unSelectedList", unSelectedList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cacheContrastHeader(List<String> columnIndex) {
|
||||||
|
String cacheKey = user.getUID() + SalaryItemConstant.TAX_DECLARE_CONTRAST_FIELD_SIGN;
|
||||||
|
Util_DataCache.setObjVal(cacheKey, JsonUtil.toJsonString(columnIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XSSFWorkbook exportContrast(ContrastQueryParam param) {
|
||||||
|
param.setPageSize(1000000000);
|
||||||
|
param.setCurrent(1);
|
||||||
|
// 获取线下对比结果
|
||||||
|
Map<String, Object> contrastMap = contrast(param);
|
||||||
|
List<String> header = (List<String>)contrastMap.get("columns");
|
||||||
|
PageInfo<Map<String, Object>> pageInfo = (PageInfo<Map<String, Object>>)contrastMap.get("pageInfo");
|
||||||
|
List<Map<String, Object>> list = pageInfo.getList();
|
||||||
|
|
||||||
|
List<WeaTableColumn> empInfoColumns = new ArrayList<>();
|
||||||
|
empInfoColumns.add(new WeaTableColumn("100px", "工号", "jobNum"));
|
||||||
|
empInfoColumns.add(new WeaTableColumn("100px", "姓名", "username"));
|
||||||
|
empInfoColumns.add(new WeaTableColumn("100px", "证件类型", "cardType"));
|
||||||
|
empInfoColumns.add(new WeaTableColumn("100px", "证件号码", "cardNum"));
|
||||||
|
|
||||||
|
return ExcelUtilPlus.genWorkbook4TaxDeclareContrast(empInfoColumns, header, list, "在线对比结果");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteById(Long deleteId) {
|
public void deleteById(Long deleteId) {
|
||||||
getTaxDeclarationValueMapper().deleteByIds(Collections.singletonList(deleteId));
|
getTaxDeclarationValueMapper().deleteByIds(Collections.singletonList(deleteId));
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
package com.engine.salary.util.excel;
|
package com.engine.salary.util.excel;
|
||||||
|
|
||||||
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
||||||
import com.engine.salary.component.WeaTableColumnGroup;
|
import com.engine.salary.component.WeaTableColumnGroup;
|
||||||
|
import com.engine.salary.entity.taxdeclaration.dto.ContrastListDTO;
|
||||||
import com.engine.salary.util.SalaryDateUtil;
|
import com.engine.salary.util.SalaryDateUtil;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.xssf.usermodel.*;
|
import org.apache.poi.xssf.usermodel.*;
|
||||||
|
|
@ -10,6 +13,7 @@ import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
@ -691,23 +695,29 @@ public class ExcelUtilPlus {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getFinalHeight(Object o, int width, float finalHeight, float height) {
|
public static float getFinalHeight(Object o, int width, float finalHeight, float height) {
|
||||||
if (o != null && getStrlength(o.toString()) > width) {
|
if (o != null) {
|
||||||
|
if (getStrlength(o.toString()) > width || o.toString().contains("\n")) {
|
||||||
float remainder = getStrlength(o.toString()) % width;
|
float remainder = getStrlength(o.toString()) % width;
|
||||||
int multiple = getStrlength(o.toString()) / width;
|
int multiple = getStrlength(o.toString()) / width;
|
||||||
int finalMultiple = remainder > 0 ? (multiple + 1) : multiple;
|
int finalMultiple = remainder > 0 ? (multiple + 1) : multiple;
|
||||||
|
// 处理换行符
|
||||||
|
int leastMultiple = StringUtils.countMatches(o.toString(), "\n") + 1;
|
||||||
|
finalMultiple = Math.max(leastMultiple, finalMultiple);
|
||||||
float compareHeight = height * finalMultiple;
|
float compareHeight = height * finalMultiple;
|
||||||
finalHeight = Math.max(finalHeight, compareHeight);
|
finalHeight = Math.max(finalHeight, compareHeight);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return finalHeight;
|
return finalHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getStrlength(String str) {
|
public static int getStrlength(String str) {
|
||||||
int strLength = 0;
|
int strLength = 0;
|
||||||
|
String finalStr = str.replace("\n", "");
|
||||||
String chinese = "[\u0391-\uFFE5]";
|
String chinese = "[\u0391-\uFFE5]";
|
||||||
/* 获取字段值的长度,如果含中文字符,则每个中文字符长度为2,否则为1 */
|
/* 获取字段值的长度,如果含中文字符,则每个中文字符长度为2,否则为1 */
|
||||||
for (int i = 0; i < str.length(); i++) {
|
for (int i = 0; i < finalStr.length(); i++) {
|
||||||
/* 从字符串中获取一个字符 */
|
/* 从字符串中获取一个字符 */
|
||||||
String temp = str.substring(i, i + 1);
|
String temp = finalStr.substring(i, i + 1);
|
||||||
/* 判断是否为中文字符 */
|
/* 判断是否为中文字符 */
|
||||||
if (temp.matches(chinese)) {
|
if (temp.matches(chinese)) {
|
||||||
/* 中文字符长度为2 */
|
/* 中文字符长度为2 */
|
||||||
|
|
@ -720,4 +730,134 @@ public class ExcelUtilPlus {
|
||||||
return strLength;
|
return strLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static XSSFWorkbook genWorkbook4TaxDeclareContrast(List<WeaTableColumn> empInfoColumns, List<String> header, List<Map<String, Object>> rowList, String sheetName) {
|
||||||
|
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||||
|
|
||||||
|
// 设置title样式
|
||||||
|
XSSFCellStyle titleCellStyle = workbook.createCellStyle();
|
||||||
|
XSSFFont titleFont = workbook.createFont();
|
||||||
|
titleFont.setBold(true);
|
||||||
|
titleFont.setFontName("仿宋");
|
||||||
|
titleFont.setFontHeightInPoints((short) 15);
|
||||||
|
titleCellStyle.setFont(titleFont);
|
||||||
|
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
titleCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());//背景色
|
||||||
|
titleCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||||
|
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
titleCellStyle.setBorderLeft(BorderStyle.THIN);
|
||||||
|
titleCellStyle.setBorderRight(BorderStyle.THIN);
|
||||||
|
titleCellStyle.setBorderTop(BorderStyle.THIN);
|
||||||
|
titleCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||||
|
|
||||||
|
// 设置主体样式
|
||||||
|
XSSFCellStyle cellStyle = workbook.createCellStyle();
|
||||||
|
XSSFFont font = workbook.createFont();
|
||||||
|
font.setFontName("宋体");
|
||||||
|
font.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||||
|
cellStyle.setFont(font);// 选择需要用到的字体格式
|
||||||
|
cellStyle.setWrapText(true);
|
||||||
|
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||||
|
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
cellStyle.setBorderLeft(BorderStyle.THIN);
|
||||||
|
cellStyle.setBorderRight(BorderStyle.THIN);
|
||||||
|
cellStyle.setBorderTop(BorderStyle.THIN);
|
||||||
|
cellStyle.setBorderBottom(BorderStyle.THIN);
|
||||||
|
|
||||||
|
XSSFFont fontRed = workbook.createFont();
|
||||||
|
fontRed.setFontName("宋体");
|
||||||
|
fontRed.setFontHeightInPoints((short) 10);// 设置字体大小
|
||||||
|
fontRed.setColor(IndexedColors.RED.getIndex());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
XSSFSheet sheet = workbook.createSheet(sheetName);
|
||||||
|
//自适应宽度
|
||||||
|
sheet.autoSizeColumn(0, true);
|
||||||
|
//默认列宽
|
||||||
|
sheet.setDefaultColumnWidth(20);
|
||||||
|
//默认行高
|
||||||
|
sheet.setDefaultRowHeightInPoints(18);
|
||||||
|
|
||||||
|
//处理合并单元格
|
||||||
|
XSSFRow row0 = sheet.createRow(0);
|
||||||
|
|
||||||
|
int startIndex = 0;
|
||||||
|
// 设置表头人员信息
|
||||||
|
for (int i = 0; i < empInfoColumns.size(); i++) {
|
||||||
|
WeaTableColumn empColumn = empInfoColumns.get(i);
|
||||||
|
XSSFCell rowZeroCell = row0.createCell(startIndex, CellType.STRING);
|
||||||
|
rowZeroCell.setCellValue(empColumn.getText());
|
||||||
|
rowZeroCell.setCellStyle(titleCellStyle);
|
||||||
|
//设置列宽
|
||||||
|
sheet.setColumnWidth(startIndex, Math.max(19, empColumn.getText().length() * 4) * 256);
|
||||||
|
startIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置表头项目字段
|
||||||
|
for (int i = 0; i < header.size(); i++) {
|
||||||
|
String h = header.get(i);
|
||||||
|
XSSFCell rowZeroCell = row0.createCell(startIndex, CellType.STRING);
|
||||||
|
rowZeroCell.setCellValue(h);
|
||||||
|
rowZeroCell.setCellStyle(titleCellStyle);
|
||||||
|
//设置列宽
|
||||||
|
sheet.setColumnWidth(startIndex, Math.max(19, h.length() * 4) * 256);
|
||||||
|
startIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置行内容
|
||||||
|
for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) {
|
||||||
|
Map<String, Object> rowMap = rowList.get(rowIndex);
|
||||||
|
XSSFRow row = sheet.createRow(rowIndex + 1);
|
||||||
|
float height = 18;
|
||||||
|
float finalHeight = 18;
|
||||||
|
float maxHeight = 0;
|
||||||
|
// 设置人员信息
|
||||||
|
for (int j = 0; j < empInfoColumns.size(); j++) {
|
||||||
|
String column = empInfoColumns.get(j).getText();
|
||||||
|
XSSFCell cell = row.createCell(j);
|
||||||
|
String cellValue = rowMap.get(column) == null ? "" : rowMap.get(column).toString();
|
||||||
|
cell.setCellStyle(cellStyle);
|
||||||
|
cell.setCellType(CellType.STRING);
|
||||||
|
cell.setCellValue(cellValue);
|
||||||
|
//判断是否要调整高度
|
||||||
|
int width = sheet.getColumnWidth(j) / 256;
|
||||||
|
finalHeight = getFinalHeight(cellValue, width, finalHeight, height);
|
||||||
|
maxHeight = Math.max(finalHeight, maxHeight);
|
||||||
|
}
|
||||||
|
// 列索引
|
||||||
|
int cellIndex = empInfoColumns.size();
|
||||||
|
// 设置项目信息
|
||||||
|
for (int i = 0; i < header.size(); i++) {
|
||||||
|
String h = header.get(i);
|
||||||
|
XSSFCell cell = row.createCell(cellIndex);
|
||||||
|
cell.setCellStyle(cellStyle);
|
||||||
|
|
||||||
|
cell.setCellType(CellType.STRING);
|
||||||
|
ContrastListDTO contrastListDTO = rowMap.get(h) != null ? (ContrastListDTO)rowMap.get(h) : new ContrastListDTO();
|
||||||
|
String local = StringUtils.isBlank(contrastListDTO.getLocal()) ? "系统值:" : "系统值:" + contrastListDTO.getLocal();
|
||||||
|
String online = StringUtils.isBlank(contrastListDTO.getOnline()) ? "线上值:" : "线上值:" + contrastListDTO.getOnline();
|
||||||
|
Object diff = contrastListDTO.getDiff();
|
||||||
|
if (diff == null) {
|
||||||
|
cell.setCellValue(local + "\n" + online);
|
||||||
|
} else {
|
||||||
|
String value = local + "\n" + online + "\n差值:" + diff;
|
||||||
|
XSSFRichTextString textString = new XSSFRichTextString(value);
|
||||||
|
textString.applyFont(0, value.indexOf("差值:"), font);
|
||||||
|
textString.applyFont(value.indexOf("差值:"), value.length(), fontRed);
|
||||||
|
cell.setCellValue(textString);
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否要调整高度
|
||||||
|
int width = sheet.getColumnWidth(i) / 256;
|
||||||
|
finalHeight = getFinalHeight(cell.getStringCellValue(), width, finalHeight, height);
|
||||||
|
maxHeight = Math.max(finalHeight, maxHeight);
|
||||||
|
cellIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
row.setHeightInPoints(maxHeight);
|
||||||
|
}
|
||||||
|
return workbook;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,71 @@ public class TaxDeclarationController {
|
||||||
return new ResponseResult<ContrastQueryParam, Map<String, Object>>(user).run(getTaxDeclareRecordWrapper(user)::contrast, param);
|
return new ResponseResult<ContrastQueryParam, Map<String, Object>>(user).run(getTaxDeclareRecordWrapper(user)::contrast, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在线对比表头列表
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/contrastHeaderList")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String contrastHeaderList(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ContrastQueryParam param) {
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
return new ResponseResult<ContrastQueryParam, Map<String, List<TaxReportColumnDTO>>>(user).run(getTaxDeclareRecordWrapper(user)::contrastHeaderList, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存在线对比表头列表
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/cacheContrastHeader")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public String cacheContrastHeader(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ContrastQueryParam param) {
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
return new ResponseResult<List<String>, Void>(user).run(getTaxDeclareRecordWrapper(user)::cacheContrastHeader, param.getColumns());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出在线对比
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Path("/exportContrast")
|
||||||
|
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
|
public Response exportContrast(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ContrastQueryParam param) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
XSSFWorkbook workbook = getTaxDeclareRecordWrapper(user).exportContrast(param);
|
||||||
|
String fileName = "在线对比结果-" + LocalDate.now();
|
||||||
|
try {
|
||||||
|
fileName = URLEncoder.encode(fileName + ".xlsx", "UTF-8");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamingOutput output = outputStream -> {
|
||||||
|
workbook.write(outputStream);
|
||||||
|
outputStream.flush();
|
||||||
|
};
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
return Response.ok(output).header("Content-disposition", "attachment;filename=" + fileName).header("Cache-Control", "no-cache").build();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("在线对比结果导出异常", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 作废
|
* 作废
|
||||||
|
|
|
||||||
|
|
@ -647,6 +647,32 @@ public class TaxDeclareRecordWrapper extends Service {
|
||||||
return getTaxDeclarationValueService(user).contrast(param);
|
return getTaxDeclarationValueService(user).contrast(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在线对比表头列表
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
|
public Map<String, List<TaxReportColumnDTO>> contrastHeaderList(ContrastQueryParam param) {
|
||||||
|
return getTaxDeclarationValueService(user).contrastHeaderList(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在线对比表头列表
|
||||||
|
* @param columnIndex
|
||||||
|
*/
|
||||||
|
public void cacheContrastHeader(List<String> columnIndex) {
|
||||||
|
getTaxDeclarationValueService(user).cacheContrastHeader(columnIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出在线对比
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public XSSFWorkbook exportContrast(ContrastQueryParam param) {
|
||||||
|
return getTaxDeclarationValueService(user).exportContrast(param);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新数据
|
* 刷新数据
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue