Commit 4c98efa8 authored by frank.xa.zhang's avatar frank.xa.zhang

add code for fwnd, need debug later

parent b6ba1fd7
......@@ -5,6 +5,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import pwc.taxtech.atms.dao.FormulaAdminMapper;
import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dao.ProjectServiceTypeMapper;
import pwc.taxtech.atms.dao.dao.ProjectDao;
import pwc.taxtech.atms.service.impl.DistributedIDService;
......@@ -41,6 +42,7 @@ public class SpringContextUtil implements ApplicationContextAware {
public static InputVatInvoiceDao inputVatInvoiceDao;
public static InputVATInvoiceMapper inputVATInvoiceMapper;
public static AssetsListMapper assetsListMapper;
public static ProjectMapper projectMapper;
/**
* 获取bean
......@@ -79,5 +81,6 @@ public class SpringContextUtil implements ApplicationContextAware {
inputVatInvoiceDao = webApplicationContext.getBean(InputVatInvoiceDao.class);
inputVATInvoiceMapper = webApplicationContext.getBean(InputVATInvoiceMapper.class);
assetsListMapper = webApplicationContext.getBean(AssetsListMapper.class);
projectMapper = webApplicationContext.getBean(ProjectMapper.class);
}
}
package pwc.taxtech.atms.vat.service.impl.report.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.entitiy.Project;
import pwc.taxtech.atms.entitiy.ProjectExample;
import java.math.BigDecimal;
import java.util.List;
/// <summary>
/// 名称:FWND
/// 功能:某年度我team是否为该客户提供该项服务,取本机构本服务中某一年度系统中是否存在项目卡片,若存在返回值为1,若不存在 返回值为0
/// 备注:如今年为2017,FWND(ND(-1))=0,表示此公司在本服务下没有2016年的卡片,ND(-1)=2016表示上一年。
/// </summary>
/// <param name="year">年份</param>
/// <returns></returns>
public class FWND extends FunctionBase implements FreeRefFunction {
public FWND(FormulaContext formulaContext) {
super(formulaContext);
}
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length < 1) {
return NumberEval.ZERO;
}
int year = getIntParam(args[0], ec);
String formulaExpression = "FWND(" + year + ")";
logger.debug(formulaExpression);
ProjectExample example = new ProjectExample();
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"), 0);
return new NumberEval(1);
} else {
saveFormulaBlock(0, ec, formulaExpression, new BigDecimal("0"), 0);
return new NumberEval(0);
}
}
}
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