Commit 29735f86 authored by neo.wang's avatar neo.wang

Merge branch 'dev_oracle_neo' into 'dev_oracle'

[dev] add project id for period formula block

See merge request root/atms!124
parents 9e7efe14 a34a02c0
......@@ -249,12 +249,13 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
.map(PeriodCellTemplateConfig::getCellTemplateId)
.collect(Collectors.toList());
if (cellTemplateConfigIds.size() > 0) {
periodFormulaBlockMapper.updateReportId(reportId, cellTemplateConfigIds, period);
periodFormulaBlockMapper.updateReportId(reportId, cellTemplateConfigIds, period, projectId);
}
for (PeriodCellTemplateConfig periodCellTemplateConfig : periodCellTemplateConfigs) {
PeriodFormulaBlockExample periodFormulaBlockExample2 = new PeriodFormulaBlockExample();
periodFormulaBlockExample2.createCriteria()
.andProjectIdEqualTo(projectId)
.andCellTemplateIdEqualTo(periodCellTemplateConfig.getCellTemplateId())
.andReportIdEqualTo(reportId)
.andPeriodEqualTo(period);
......@@ -263,11 +264,11 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
//TODO:如果formula 为 ND(100) +ND(22) ,需要使用正则表达式拆分出自定义公式,然后根据自定义公式取formulablock 的数据进行替换
String regex = "[A-Z]*\\([\\-A-Za-z0-9\\\"\\,\\.\\u4e00-\\u9fa5\\%]*\\)";
Pattern p = Pattern.compile(regex);
String sourceFormula = StringUtils.isNotBlank(periodCellTemplateConfig.getKeyValueParsedFormula())?
periodCellTemplateConfig.getKeyValueParsedFormula():
String sourceFormula = StringUtils.isNotBlank(periodCellTemplateConfig.getKeyValueParsedFormula()) ?
periodCellTemplateConfig.getKeyValueParsedFormula() :
periodCellTemplateConfig.getFormula();
String resultFormula = StringUtils.isNotBlank(periodCellTemplateConfig.getKeyValueParsedFormula())?
periodCellTemplateConfig.getKeyValueParsedFormula():
String resultFormula = StringUtils.isNotBlank(periodCellTemplateConfig.getKeyValueParsedFormula()) ?
periodCellTemplateConfig.getKeyValueParsedFormula() :
periodCellTemplateConfig.getFormula();
Matcher m = p.matcher(sourceFormula);
Boolean isFind = false;
......
......@@ -444,7 +444,8 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
List<CellData> currentCellDataList = cellDataMapper.selectByExample(cellDataExample);
PeriodFormulaBlockExample periodFormulaBlockExample = new PeriodFormulaBlockExample();
periodFormulaBlockExample.createCriteria().andPeriodEqualTo(report.getPeriod()).andReportIdEqualTo(reportId);
periodFormulaBlockExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(report.getPeriod())
.andReportIdEqualTo(reportId);
List<PeriodFormulaBlock> formulaBlocks = periodFormulaBlockMapper.selectByExample(periodFormulaBlockExample);
dataDto.setFormulaBlocks(formulaBlocks);
//todo: 关键字数据源稍后再加
......
......@@ -140,7 +140,7 @@ public class BB extends FunctionBase implements FreeRefFunction {
cellValue, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId(), bo.getColumnIndex() - 1, bo.getRowIndex() - 1);
saveFormulaBlock(formulaContext.getPeriod(), ec,
bo.expression(), bo.expressionData(), dataSourceId);
bo.expression(), bo.expressionData(), dataSourceId, formulaContext.getProjectId());
}
}
}
......
......@@ -135,7 +135,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
//save datasource
Long dataSourceId = saveDataSource(ec, formulaDataSourceDtoList, FormulaDataSourceDetailType.BSPLFormulaDataSourceDto, val, period, formulaContext.getReportTemplateGroupId());
//save formulablock
saveFormulaBlock(period, ec, formulaExpression, val, dataSourceId);
saveFormulaBlock(period, ec, formulaExpression, val, dataSourceId, formulaContext.getProjectId());
return new NumberEval(val.doubleValue());
} else {
......@@ -199,7 +199,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
Long dataSourceId = saveDataSource(ec, dsList, FormulaDataSourceDetailType.BSPLFormulaDataSourceDto, val,
period, formulaContext.getReportTemplateGroupId());
//save formulablock
saveFormulaBlock(period, ec, formulaExpression, val, dataSourceId);
saveFormulaBlock(period, ec, formulaExpression, val, dataSourceId, formulaContext.getProjectId());
return new NumberEval(val.doubleValue());
}
}
......
......@@ -36,10 +36,10 @@ public class FWND extends FunctionBase implements FreeRefFunction {
example.createCriteria().andOrganizationIdEqualTo(formulaContext.getOrganizationId()).andYearEqualTo(year);
List<Project> projects = SpringContextUtil.projectMapper.selectByExample(example);
if (projects != null && projects.size() > 0) {
saveFormulaBlock(0, ec, formulaExpression, new BigDecimal("1"), 0L);
saveFormulaBlock(0, ec, formulaExpression, new BigDecimal("1"), 0L, formulaContext.getProjectId());
return new NumberEval(1);
} else {
saveFormulaBlock(0, ec, formulaExpression, new BigDecimal("0"), 0L);
saveFormulaBlock(0, ec, formulaExpression, new BigDecimal("0"), 0L, formulaContext.getProjectId());
return new NumberEval(0);
}
}
......
......@@ -15,10 +15,12 @@ import pwc.taxtech.atms.vat.entity.DataSourceDetail;
import pwc.taxtech.atms.vat.entity.PeriodFormulaBlock;
import pwc.taxtech.atms.vat.service.impl.FormulaAgent;
import javax.tools.JavaCompiler;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FunctionBase {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
......@@ -130,8 +132,8 @@ public class FunctionBase {
dataSource.setPeriod(period);
SpringContextUtil.dataSourceMapper.insertSelective(dataSource);
for (Object obj : dataSourceList) {
if (obj.getClass()==java.util.ArrayList.class) {
for (Object obj2 : (ArrayList<Object>)obj) {
if (obj.getClass() == java.util.ArrayList.class) {
for (Object obj2 : (ArrayList<Object>) obj) {
DataSourceDetail dataSourceDetail = new DataSourceDetail();
dataSourceDetail.setId(SpringContextUtil.distributedIdService.nextId());
dataSourceDetail.setDataSourceId(dataSourceId);
......@@ -152,11 +154,12 @@ public class FunctionBase {
}
public void saveFormulaBlock(int period, OperationEvaluationContext ec,
String formulaExpression, BigDecimal val, Long dataSourceId) {
String formulaExpression, BigDecimal val, Long dataSourceId, String projectId) {
Long cellTemplateId = getCellTemplateId(period, ec);
Date creatime = new Date();
PeriodFormulaBlock periodFormulaBlock = new PeriodFormulaBlock();
periodFormulaBlock.setId(SpringContextUtil.distributedIdService.nextId());
periodFormulaBlock.setProjectId(projectId);
periodFormulaBlock.setPeriod(period);
periodFormulaBlock.setReportId(0L);
periodFormulaBlock.setCellTemplateId(cellTemplateId);
......@@ -171,10 +174,11 @@ public class FunctionBase {
}
public void saveFormulaBlock(int period, OperationEvaluationContext ec,
String formulaExpression, String val, Long dataSourceId) {
String formulaExpression, String val, Long dataSourceId, String projectId) {
Long cellTemplateId = getCellTemplateId(period, ec);
Date creatime = new Date();
PeriodFormulaBlock periodFormulaBlock = new PeriodFormulaBlock();
periodFormulaBlock.setProjectId(projectId);
periodFormulaBlock.setId(SpringContextUtil.distributedIdService.nextId());
periodFormulaBlock.setPeriod(period);
periodFormulaBlock.setReportId(0L);
......
......@@ -89,7 +89,7 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSourceDtoList),
FormulaDataSourceDetailType.FormulaDataSourceDto, decimal_zero, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, decimal_zero, dataSourceId);
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, decimal_zero, dataSourceId, formulaContext.getProjectId());
return NumberEval.ZERO;
}
}
......@@ -112,7 +112,7 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSourceDtoList),
FormulaDataSourceDetailType.FormulaDataSourceDto, val, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, val, dataSourceId);
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, val, dataSourceId, formulaContext.getProjectId());
return new NumberEval(val.doubleValue());
} else {
//todo: @本期应(实)纳税额 ,@GDZC.BQ.QMYE 这种类型的数据,重新计算,按照keyvalue的配置
......@@ -131,7 +131,7 @@ public class GZSD extends FunctionBase implements FreeRefFunction {
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSourceDtoList),
FormulaDataSourceDetailType.FormulaDataSourceDto, decimal_zero, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, decimal_zero, dataSourceId);
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, decimal_zero, dataSourceId, formulaContext.getProjectId());
return NumberEval.ZERO;
}
......
......@@ -13,7 +13,12 @@ import pwc.taxtech.atms.dto.vatdto.InputInvoiceDataSourceDto;
import pwc.taxtech.atms.vat.entity.InputVatInvoice;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/// <summary>
......@@ -58,13 +63,13 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
certificationPeriod = getPeriod(certificationPeriod, yearOffset);
if (yearOffset < 0) {
saveFormulaBlock(period,ec,formulaExpression,new BigDecimal("0.0"),0L);
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal("0.0"), 0L, formulaContext.getProjectId());
return NumberEval.ZERO;
}
period = getPeriod(period, yearOffset);
if (yearOffset < 0) {
saveFormulaBlock(period,ec,formulaExpression,new BigDecimal("0.0"),0L);
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal("0.0"), 0L, formulaContext.getProjectId());
return NumberEval.ZERO;
}
......@@ -94,13 +99,13 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
inputVATInvoices = SpringContextUtil.inputVatInvoiceDao.getInputVATInvoice(period, invoiceType, null,
null, Constant.InputInvoiceCertificationResult.NotPass);
} else {
saveFormulaBlock(period,ec,formulaExpression,new BigDecimal("0.0"),0L);
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal("0.0"), 0L, formulaContext.getProjectId());
return NumberEval.ZERO;
}
if (certificationPeriod != -99 && certificationPeriod != 99
&& (certificationPeriod < 1 || certificationPeriod > 12)) {
saveFormulaBlock(period,ec,formulaExpression,new BigDecimal("0.0"),0L);
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal("0.0"), 0L, formulaContext.getProjectId());
return NumberEval.ZERO;
} else if (!formulaContext.getIsYear()) {
if (certificationPeriod == -99) {
......@@ -154,25 +159,29 @@ public class JXFP extends FunctionBase implements FreeRefFunction {
double val = dataSource.stream().mapToDouble(a -> a.getAmount().doubleValue()).sum();
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.InputInvoiceDataSourceDto,
BigDecimal.valueOf(val),formulaContext.getPeriod(),formulaContext.getReportTemplateGroupId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId);
BigDecimal.valueOf(val), formulaContext.getPeriod(), formulaContext.getReportTemplateGroupId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId,
formulaContext.getProjectId());
return new NumberEval(val);
} else if (resultType == 1) {
double val = dataSource.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum();
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.InputInvoiceDataSourceDto,
BigDecimal.valueOf(val),formulaContext.getPeriod(),formulaContext.getReportTemplateGroupId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId);
BigDecimal.valueOf(val), formulaContext.getPeriod(), formulaContext.getReportTemplateGroupId());
saveFormulaBlock(formulaContext.getPeriod(), ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId,
formulaContext.getProjectId());
return new NumberEval(val);
} else if (resultType == 2) {
double val = dataSource.size();
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.InputInvoiceDataSourceDto,
BigDecimal.valueOf(val),formulaContext.getPeriod(),formulaContext.getReportTemplateGroupId());
saveFormulaBlock(period, ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId);
BigDecimal.valueOf(val), formulaContext.getPeriod(), formulaContext.getReportTemplateGroupId());
saveFormulaBlock(period, ec, formulaExpression, BigDecimal.valueOf(val), dataSourceId,
formulaContext.getProjectId());
return new NumberEval(val);
}
saveFormulaBlock(period,ec,formulaExpression,new BigDecimal("0.0"),0L);
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal("0.0"), 0L,
formulaContext.getProjectId());
return NumberEval.ZERO;
}
}
......@@ -14,7 +14,11 @@ import pwc.taxtech.atms.dto.vatdto.InputInvoiceDetailDataSourceDto;
import pwc.taxtech.atms.vat.dpo.InputVATInvoiceResultDto;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
......@@ -84,7 +88,7 @@ public class JXFPMX extends FunctionBase implements FreeRefFunction {
if (!goodsName.equals("99")) {
inputInvoice = inputInvoice.stream()
.filter(a -> a.getGoodsMapping() != null&&a.getGoodsMapping().getStdGoodsName()!=null && a.getGoodsMapping().getStdGoodsName().equals(goodsName))
.filter(a -> a.getGoodsMapping() != null && a.getGoodsMapping().getStdGoodsName() != null && a.getGoodsMapping().getStdGoodsName().equals(goodsName))
.collect(Collectors.toList());
}
......@@ -133,15 +137,15 @@ public class JXFPMX extends FunctionBase implements FreeRefFunction {
double val = dataSouce.stream().mapToDouble(a -> a.getAmount().doubleValue()).sum();
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSouce),
FormulaDataSourceDetailType.InputInvoiceDetailDataSourceDto,
new BigDecimal(val),period,formulaContext.getReportTemplateGroupId());
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSourceId);
new BigDecimal(val), period, formulaContext.getReportTemplateGroupId());
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSourceId, formulaContext.getProjectId());
return new NumberEval(val);
} else if (amountType == 1) {
double val = dataSouce.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum();
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSouce),
FormulaDataSourceDetailType.InputInvoiceDetailDataSourceDto,
new BigDecimal(val),period,formulaContext.getReportTemplateGroupId());
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSourceId);
new BigDecimal(val), period, formulaContext.getReportTemplateGroupId());
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSourceId, formulaContext.getProjectId());
return new NumberEval(val);
}
......
......@@ -115,15 +115,15 @@ public class XXFP extends FunctionBase implements FreeRefFunction {
double val = dataSource.stream().mapToDouble(a -> a.getAmount().doubleValue()).sum();
Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.OutputInvoiceDataSourceDto,
new BigDecimal(val),period,formulaContext.getReportTemplateGroupId());
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSoureId);
new BigDecimal(val), period, formulaContext.getReportTemplateGroupId());
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSoureId, formulaContext.getProjectId());
return new NumberEval(val);
} else if (amountType == 1) {
double val = dataSource.stream().mapToDouble(a -> a.getTaxAmount().doubleValue()).sum();
Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.OutputInvoiceDataSourceDto,
new BigDecimal(val),period,formulaContext.getReportTemplateGroupId());
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSoureId);
new BigDecimal(val), period, formulaContext.getReportTemplateGroupId());
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(val), dataSoureId, formulaContext.getProjectId());
return new NumberEval(val);
}
return NumberEval.ZERO;
......
......@@ -129,7 +129,7 @@ public class ZC extends FunctionBase implements FreeRefFunction {
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.AssetDetailDataSourceDto,
totalData, formulaContext.getPeriod(), formulaContext.getReportTemplateGroupId());
saveFormulaBlock(0, ec, formulaExpression, totalData, dataSourceId);
saveFormulaBlock(0, ec, formulaExpression, totalData, dataSourceId, formulaContext.getProjectId());
return new NumberEval(totalData.doubleValue());
}
}
......@@ -107,5 +107,6 @@ public interface PeriodFormulaBlockMapper extends MyVatMapper {
*/
int updateByPrimaryKey(PeriodFormulaBlock record);
void updateReportId(@Param("reportId") Long reportId, @Param("cellTemplateConfigIds") List<Long> cellTemplateConfigIds, @Param("period") Integer period);
void updateReportId(@Param("reportId") Long reportId, @Param("cellTemplateConfigIds") List<Long> cellTemplateConfigIds,
@Param("period") Integer period, @Param("projectId") String projectId);
}
\ No newline at end of file
......@@ -9,6 +9,7 @@
REPORT_ID= #{reportId,jdbcType=BIGINT}
WHERE
PERIOD= #{period,jdbcType=INTEGER}
AND PROJECT_ID= #{projectId,jdbcType=INTEGER}
AND CELL_TEMPLATE_ID IN
<foreach collection="cellTemplateConfigIds" open="(" close=")" separator="," item="item">
#{item}
......
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