Commit 3a20ec59 authored by sherlock's avatar sherlock

DFFS

parent b1366f10
......@@ -4,11 +4,7 @@ import org.springframework.beans.BeansException;
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.OrganizationMapper;
import pwc.taxtech.atms.dao.ProjectDao;
import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dao.ProjectServiceTypeMapper;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.invoice.InputInvoiceMapper;
import pwc.taxtech.atms.invoice.OutputInvoiceDetailMapper;
import pwc.taxtech.atms.invoice.OutputInvoiceMapper;
......@@ -33,6 +29,7 @@ public class SpringContextUtil implements ApplicationContextAware {
public static PeriodTemplateMapper periodTemplateMapper;
public static PeriodStandardAccountMapper periodStandardAccountMapper;
public static ProjectDao projectDao;
public static GlBalanceMapper glBalanceMapper;
public static BalanceMapper balanceMapper;
// public static DataSourceMapper dataSourceMapper;
public static PeriodDataSourceMapper periodDataSourceMapper;
......@@ -54,6 +51,8 @@ public class SpringContextUtil implements ApplicationContextAware {
public static CellDataSourceMapper cellDataSourceMapper;
public static PeriodCellDataSourceMapper periodCellDataSourceMapper;
public static OrganizationMapper organizationMapper;
public static EnterpriseAccountSetOrgMapper enterpriseAccountSetOrgMapper;
public static AccountMappingMapper accountMappingMapper;
/**
* 获取bean
......@@ -66,6 +65,30 @@ public class SpringContextUtil implements ApplicationContextAware {
return SpringContextUtil.webApplicationContext.getBean(requiredType);
}
public static AccountMappingMapper getAccountMappingMapper() {
return accountMappingMapper;
}
public static void setAccountMappingMapper(AccountMappingMapper accountMappingMapper) {
SpringContextUtil.accountMappingMapper = accountMappingMapper;
}
public static EnterpriseAccountSetOrgMapper getEnterpriseAccountSetOrgMapper() {
return enterpriseAccountSetOrgMapper;
}
public static void setEnterpriseAccountSetOrgMapper(EnterpriseAccountSetOrgMapper enterpriseAccountSetOrgMapper) {
SpringContextUtil.enterpriseAccountSetOrgMapper = enterpriseAccountSetOrgMapper;
}
public static GlBalanceMapper getGlBalanceMapper() {
return glBalanceMapper;
}
public static void setGlBalanceMapper(GlBalanceMapper glBalanceMapper) {
SpringContextUtil.glBalanceMapper = glBalanceMapper;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
webApplicationContext = applicationContext;
......
......@@ -212,6 +212,9 @@ public class TemplateGroupServiceImpl extends AbstractService {
templateGroupMapper.insertSelective(templateGroup);
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
String sheetName = workbook.getSheetName(i);
if(!templateGroupDto.getSheetNameList().contains(sheetName)){
continue;
}
String newName = sheetName + CommonUtils.getUUID() + POIUtil.getFileSuffix(fileName).get();
Sheet sheet = workbook.getSheetAt(i);
Optional<Workbook> optional = POIUtil.cloneNewSheet(sheet, fileName);
......
package pwc.taxtech.atms.vat.service.impl.report.functions;
import com.grapecity.documents.excel.G;
import org.apache.commons.collections.CollectionUtils;
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.DateUtils;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.entity.AccountMapping;
import pwc.taxtech.atms.entity.AccountMappingExample;
import pwc.taxtech.atms.entity.EnterpriseAccountSetOrg;
import pwc.taxtech.atms.entity.EnterpriseAccountSetOrgExample;
import pwc.taxtech.atms.vat.entity.GlBalance;
import pwc.taxtech.atms.vat.entity.GlBalanceExample;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
public class DFFS extends FunctionBase implements FreeRefFunction {
public DFFS(FormulaContext formulaContext) {
super(formulaContext);
}
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length < 4) {
return null;
}
int type = getIntParam(args[0], ec);
String code = getStringParam(args[1], ec);
int year = getIntParam(args[2], ec);
int period = getIntParam(args[3], ec);
String formulaExpression = "DFFS(" + type + "," + code + ","
+ year + "," + period + ")";
logger.debug(formulaExpression);
year = getIntParam(args[2], ec);
Integer yearOffset = 0;
period = FormulaHelper.getPeriod(period, yearOffset, formulaContext);
String orgId = formulaContext.getOrganizationId();
year = year + yearOffset;
Date date = DateUtils.strToDate(year + "-" + period + "-" + 15);
List<GlBalance> list;
if(type == 0){
EnterpriseAccountSetOrgExample example = new EnterpriseAccountSetOrgExample();
example.createCriteria().andEffectiveDateLessThanOrEqualTo(date).andExpiredDateGreaterThanOrEqualTo(date).andOrganizationIdEqualTo(orgId);
List<EnterpriseAccountSetOrg> enterpriseAccountSetOrgs = SpringContextUtil.enterpriseAccountSetOrgMapper.selectByExample(example);
if(CollectionUtils.isEmpty(enterpriseAccountSetOrgs)){
return NumberEval.ZERO;
}
AccountMappingExample accountMappingExample = new AccountMappingExample();
accountMappingExample.createCriteria().andOrganizationIdEqualTo(orgId).andEnterpriseAccountSetIdEqualTo(enterpriseAccountSetOrgs.get(0).getEnterpriseAccountSetId());
List<AccountMapping> accountMappings = SpringContextUtil.accountMappingMapper.selectByExample(accountMappingExample);
double result = 0;
for(AccountMapping a : accountMappings){
result += count(a.getEnterpriseAccountCode());
}
new NumberEval(result);
} else if(type == 1){
return new NumberEval(count(code));
}
return null;
}
private double count(String code){
GlBalanceExample glBalanceExample = new GlBalanceExample();
GlBalanceExample.Criteria c1 = glBalanceExample.createCriteria().andSegment3EqualTo(code);
GlBalanceExample.Criteria c2 = glBalanceExample.createCriteria().andSegment4EqualTo(code);
glBalanceExample.or(c2);
List<GlBalance> list = SpringContextUtil.glBalanceMapper.selectByExample(glBalanceExample);
if(CollectionUtils.isEmpty(list)){
return 0.0;
}
List<GlBalance> temp = list.stream().filter(x -> code.equalsIgnoreCase(x.getSegment3())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(temp)){
temp = list;
}
return temp.stream().mapToDouble(a -> a.getPtdCr().doubleValue()).sum();
}
}
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