Commit 1d2cb258 authored by sherlock's avatar sherlock

DFFS periodName filter

parent c1ae7f3b
...@@ -53,12 +53,11 @@ public class DFFS extends FunctionBase implements FreeRefFunction { ...@@ -53,12 +53,11 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
period = FormulaHelper.getPeriod(period, yearOffset, formulaContext); period = FormulaHelper.getPeriod(period, yearOffset, formulaContext);
String orgId = formulaContext.getOrganizationId(); String orgId = formulaContext.getOrganizationId();
year = year + yearOffset; year = year + yearOffset;
Date date = DateUtils.strToDate(year + "-" + period + "-" + 15);
List<ReportCellDataSourceDto> dataSource = Lists.newArrayList(); List<ReportCellDataSourceDto> dataSource = Lists.newArrayList();
if(type == 0){ if(type == 0){
EnterpriseAccountSetOrgExample example = new EnterpriseAccountSetOrgExample(); EnterpriseAccountSetOrgExample example = new EnterpriseAccountSetOrgExample();
example.createCriteria().andEffectiveDateLessThanOrEqualTo(date).andExpiredDateGreaterThanOrEqualTo(date).andOrganizationIdEqualTo(orgId); example.createCriteria().andEffectiveDateLessThanOrEqualTo(DateUtils.getNow()).andExpiredDateGreaterThanOrEqualTo(DateUtils.getNow()).andOrganizationIdEqualTo(orgId);
List<EnterpriseAccountSetOrg> enterpriseAccountSetOrgs = SpringContextUtil.enterpriseAccountSetOrgMapper.selectByExample(example); List<EnterpriseAccountSetOrg> enterpriseAccountSetOrgs = SpringContextUtil.enterpriseAccountSetOrgMapper.selectByExample(example);
if(CollectionUtils.isEmpty(enterpriseAccountSetOrgs)){ if(CollectionUtils.isEmpty(enterpriseAccountSetOrgs)){
return NumberEval.ZERO; return NumberEval.ZERO;
...@@ -69,7 +68,7 @@ public class DFFS extends FunctionBase implements FreeRefFunction { ...@@ -69,7 +68,7 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
double result = 0; double result = 0;
for(AccountMapping a : accountMappings){ for(AccountMapping a : accountMappings){
result += count(a.getEnterpriseAccountCode(), dataSource, period); result += count(a.getEnterpriseAccountCode(), dataSource, period, year);
} }
Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource), Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.FormulaDataSourceDto, FormulaDataSourceDetailType.FormulaDataSourceDto,
...@@ -79,7 +78,7 @@ public class DFFS extends FunctionBase implements FreeRefFunction { ...@@ -79,7 +78,7 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
return new NumberEval(result); return new NumberEval(result);
} else if(type == 1){ } else if(type == 1){
double result = count(code, dataSource, period); double result = count(code, dataSource, period, year);
Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource), Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.FormulaDataSourceDto, FormulaDataSourceDetailType.FormulaDataSourceDto,
new BigDecimal(result), period, formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId()); new BigDecimal(result), period, formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId());
...@@ -90,10 +89,14 @@ public class DFFS extends FunctionBase implements FreeRefFunction { ...@@ -90,10 +89,14 @@ public class DFFS extends FunctionBase implements FreeRefFunction {
return NumberEval.ZERO; return NumberEval.ZERO;
} }
private double count(String code, List<ReportCellDataSourceDto> contain, int period){ private String periodName(int period, int year){
return year + "-" + (period > 9 ? period : ("0" + period));
}
private double count(String code, List<ReportCellDataSourceDto> contain, int period, int year){
GlBalanceExample glBalanceExample = new GlBalanceExample(); GlBalanceExample glBalanceExample = new GlBalanceExample();
GlBalanceExample.Criteria c1 = glBalanceExample.createCriteria().andSegment3EqualTo(code); GlBalanceExample.Criteria c1 = glBalanceExample.createCriteria().andSegment3EqualTo(code).andPeriodNameEqualTo(periodName(period, year));
GlBalanceExample.Criteria c2 = glBalanceExample.createCriteria().andSegment4EqualTo(code); GlBalanceExample.Criteria c2 = glBalanceExample.createCriteria().andSegment4EqualTo(code).andPeriodNameEqualTo(periodName(period, year));
glBalanceExample.or(c2); glBalanceExample.or(c2);
List<GlBalance> list = SpringContextUtil.glBalanceMapper.selectByExample(glBalanceExample); List<GlBalance> list = SpringContextUtil.glBalanceMapper.selectByExample(glBalanceExample);
if(CollectionUtils.isEmpty(list)){ if(CollectionUtils.isEmpty(list)){
......
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