Commit 3a967848 authored by eddie.woo's avatar eddie.woo

modify

parent e02c2c8c
package pwc.taxtech.atms.vat.service.impl.report.functions; package pwc.taxtech.atms.vat.service.impl.report.functions;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.ss.formula.OperationEvaluationContext; import org.apache.poi.ss.formula.OperationEvaluationContext;
...@@ -8,6 +9,10 @@ import org.apache.poi.ss.formula.eval.ValueEval; ...@@ -8,6 +9,10 @@ import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction; import org.apache.poi.ss.formula.functions.FreeRefFunction;
import pwc.taxtech.atms.common.util.DateUtils; import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.common.util.SpringContextUtil; import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.DataSourceName;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceType;
import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto;
import pwc.taxtech.atms.entity.Organization; import pwc.taxtech.atms.entity.Organization;
import pwc.taxtech.atms.entity.Project; import pwc.taxtech.atms.entity.Project;
import pwc.taxtech.atms.vat.dao.HlOutputInterfaceLineMapper; import pwc.taxtech.atms.vat.dao.HlOutputInterfaceLineMapper;
...@@ -44,6 +49,7 @@ public class WPSR extends FunctionBase implements FreeRefFunction { ...@@ -44,6 +49,7 @@ public class WPSR extends FunctionBase implements FreeRefFunction {
return ZERO_EVAL; return ZERO_EVAL;
} }
ValueEval result = ZERO_EVAL; ValueEval result = ZERO_EVAL;
String formulaExpression = "WPSR(" + type + "," + rate + ")";
try { try {
int period = formulaContext.getPeriod(); int period = formulaContext.getPeriod();
int year = formulaContext.getYear(); int year = formulaContext.getYear();
...@@ -57,10 +63,28 @@ public class WPSR extends FunctionBase implements FreeRefFunction { ...@@ -57,10 +63,28 @@ public class WPSR extends FunctionBase implements FreeRefFunction {
HlOutputInterfaceLineExample lineExample = new HlOutputInterfaceLineExample(); HlOutputInterfaceLineExample lineExample = new HlOutputInterfaceLineExample();
lineExample.createCriteria().andSjfyrqBetween(periodStart, periodEnd).andSfkpNotEqualTo("1") lineExample.createCriteria().andSjfyrqBetween(periodStart, periodEnd).andSfkpNotEqualTo("1")
.andEbsSrbjEqualTo("1").andYwstidEqualTo(organization.getCode()); //排除 状态1:已开票,即未开票和预开票 .andEbsSrbjEqualTo("1").andYwstidEqualTo(organization.getCode()); //排除 状态1:已开票,即未开票和预开票
List<HlOutputInterfaceLine> lineList = interfaceLineMapper.selectByExample(lineExample); //todo 无订单业务 List<HlOutputInterfaceLine> lineList = interfaceLineMapper.selectByExample(lineExample);
BigDecimal tmp = BigDecimal.ZERO;
if (!CollectionUtils.isEmpty(lineList)) { if (!CollectionUtils.isEmpty(lineList)) {
result = new StringEval(getSum(lineList, rateStr).toPlainString()); tmp = tmp.add(getSum(lineList, rateStr));
}
//无订单业务
HlOutputInterfaceLineExample lineExampleWdd = new HlOutputInterfaceLineExample();
lineExampleWdd.createCriteria().andSjfyrqBetween(periodStart, periodEnd).andContextEqualTo("ETMS")
.andEbsSrbjEqualTo("1").andYwstidEqualTo(organization.getCode()).andTaxrateEqualTo(rateStr);
HlOutputInterfaceLineExample.Criteria criteria2 = lineExampleWdd.createCriteria().andSjfyrqBetween(periodStart, periodEnd)
.andContextEqualTo("ETMS").andEbsSrbjEqualTo("1").andYwstidEqualTo(organization.getCode())
.andTaxrateEqualTo(rateStr.substring(1));// 兼容税率为.16 这种数据
lineExampleWdd.or(criteria2);
List<HlOutputInterfaceLine> lineListWdd = interfaceLineMapper.selectByExample(lineExampleWdd);
if (!CollectionUtils.isEmpty(lineListWdd)) {
List<String> idList = lineListWdd.stream().map(HlOutputInterfaceLine::getUuid).collect(Collectors.toList());
HlOutputOrderKpsqmxbExample mxbExample = new HlOutputOrderKpsqmxbExample();
mxbExample.createCriteria().andIdIn(idList);
tmp = tmp.add(kpsqmxbMapper.selectByExample(mxbExample).stream().map(o -> NumberUtils.createBigDecimal(o.getHjje())).
reduce(BigDecimal.ZERO, BigDecimal::add));
} }
result = new StringEval(tmp.toPlainString());
} else if (2 == type) { } else if (2 == type) {
//跨月开票 //跨月开票
HlOutputInterfaceLineExample lineExample = new HlOutputInterfaceLineExample(); HlOutputInterfaceLineExample lineExample = new HlOutputInterfaceLineExample();
...@@ -74,6 +98,27 @@ public class WPSR extends FunctionBase implements FreeRefFunction { ...@@ -74,6 +98,27 @@ public class WPSR extends FunctionBase implements FreeRefFunction {
} catch (Exception e) { } catch (Exception e) {
logger.error("evaluate WPSR error.", e); logger.error("evaluate WPSR error.", e);
} }
//todo data source 显示优化
try {
BigDecimal val = NumberUtils.createBigDecimal(result.toString());
ReportCellDataSourceDto dto = new ReportCellDataSourceDto();
dto.setAmount(val);
dto.setName(DataSourceName.ReportDataSource);
dto.setPeriod(formulaContext.getPeriod());
dto.setProjectId(formulaContext.getProjectId());
// dto.setRowIndex(pCell.rowIndex-1);
// dto.setColumnIndex(pCell.columnIndex-1);
dto.setColumnName("");
dto.setRowName("");
dto.setReportName(ec.getWorkbook().getSheetName(ec.getSheetIndex()));
dto.setType(FormulaDataSourceType.Report.getCode());
Long dataSourceId = saveDataSource(ec, Lists.newArrayList(dto), FormulaDataSourceDetailType.InputInvoiceDataSourceDto, val, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, val, dataSourceId,
formulaContext.getProjectId());
} catch (Exception e) {
logger.error("saveDataSource or saveFormulaBlock error.", e);
}
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment