Commit 0ed8adc2 authored by chase's avatar chase

修改dffs跟jffs公式取值数据源

parent 13db73b9
......@@ -10,7 +10,6 @@ import pwc.taxtech.atms.invoice.OutputInvoiceDetailMapper;
import pwc.taxtech.atms.invoice.OutputInvoiceMapper;
import pwc.taxtech.atms.service.impl.DistributedIdService;
import pwc.taxtech.atms.vat.dao.*;
import pwc.taxtech.atms.vat.entity.OutputInvoiceDetail;
//用来获取spring托管的bean
@Component
......@@ -55,6 +54,7 @@ public class SpringContextUtil implements ApplicationContextAware {
public static AccountMappingMapper accountMappingMapper;
public static TrialBalanceMapper trialBalanceMapper;
public static AdjustmentTableMapper adjustmentTableMapper;
public static TrialBalanceFinalMapper trialBalanceFinalMapper;
/**
* 获取bean
......@@ -110,5 +110,6 @@ public class SpringContextUtil implements ApplicationContextAware {
glBalanceMapper = webApplicationContext.getBean(GlBalanceMapper.class);
trialBalanceMapper = webApplicationContext.getBean(TrialBalanceMapper.class);
adjustmentTableMapper = webApplicationContext.getBean(AdjustmentTableMapper.class);
trialBalanceFinalMapper = webApplicationContext.getBean(TrialBalanceFinalMapper.class);
}
}
......@@ -13,8 +13,7 @@ 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.*;
import pwc.taxtech.atms.vat.entity.GlBalance;
import pwc.taxtech.atms.vat.entity.GlBalanceExample;
import pwc.taxtech.atms.vat.entity.*;
import java.math.BigDecimal;
import java.util.Collections;
......@@ -28,7 +27,7 @@ public class JFFS extends FunctionBase implements FreeRefFunction {
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length < 4) {
if (args.length < 5) {
return null;
}
......@@ -36,9 +35,9 @@ public class JFFS extends FunctionBase implements FreeRefFunction {
String code = getStringParam(args[1], ec);
int year = getIntParam(args[2], ec);
int period = getIntParam(args[3], ec);
int sourceDataType = getIntParam(args[4],ec);
String formulaExpression = "JFFS(" + type + ",\"" + code + "\","
+ year + "," + period + ")";
+ year + "," + period + ","+sourceDataType+")";
logger.debug(formulaExpression);
year = getYear(year);
......@@ -65,17 +64,32 @@ public class JFFS extends FunctionBase implements FreeRefFunction {
double result = 0;
for(AccountMapping a : accountMappings){
result += count(a.getEnterpriseAccountCode(), dataSource, period, year,orgId);
if(sourceDataType == 1){
result += countForTrialBalance(a.getEnterpriseAccountCode(), dataSource, period, year,orgId);
}else if(sourceDataType == 2){
result += countForAdjBalance(a.getEnterpriseAccountCode(), dataSource, period, year,orgId);
}else if(sourceDataType == 3){
result += countForTrialFinalBalance(a.getEnterpriseAccountCode(), dataSource, period, year,orgId);
}else{
return NumberEval.ZERO;
}
}
Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.FormulaDataSourceDto,
new BigDecimal(result), period, formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId());
saveFormulaBlock(period, ec, formulaExpression, new BigDecimal(result), dataSoureId, formulaContext.getProjectId());
return new NumberEval(result);
} else if(type == 1){
double result = count(code, dataSource, period, year, orgId);
double result = 0.00;
if(sourceDataType == 1){
result = countForTrialBalance(code, dataSource, period, year, orgId);
}else if(sourceDataType == 2){
result = countForAdjBalance(code, dataSource, period, year, orgId);
}else if(sourceDataType == 3){
result = countForTrialFinalBalance(code, dataSource, period, year, orgId);
}else{
return NumberEval.ZERO;
}
Long dataSoureId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.FormulaDataSourceDto,
new BigDecimal(result), period, formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId());
......@@ -86,39 +100,99 @@ public class JFFS extends FunctionBase implements FreeRefFunction {
return NumberEval.ZERO;
}
private String periodName(int period, int year){
return year + "-" + (period > 9 ? period : ("0" + period));
private int pardePeriod(int period, int year){
return Integer.parseInt(""+year + (period > 9 ? period : ("0" + period)));
}
private double count(String code, List<ReportCellDataSourceDto> contain, int period, int year, String orgId){
private double countForTrialBalance(String code, List<ReportCellDataSourceDto> contain, int period, int year, String orgId){
Organization organization = SpringContextUtil.organizationMapper.selectByPrimaryKey(orgId);
TrialBalanceExample example = new TrialBalanceExample();
TrialBalanceExample.Criteria c1 = example.createCriteria().andSegment3EqualTo(code).andPeriodEqualTo(pardePeriod(period, year));
TrialBalanceExample.Criteria c2 = example.createCriteria().andSegment4EqualTo(code).andPeriodEqualTo(pardePeriod(period, year));
if(organization != null){
c1.andOrganizationIdEqualTo(organization.getId());
c2.andOrganizationIdEqualTo(organization.getId());
}
example.or(c2);
List<TrialBalance> list = SpringContextUtil.trialBalanceMapper.selectByExample(example);
if(CollectionUtils.isEmpty(list)){
return 0.0;
}
List<TrialBalance> temp = list.stream().filter(x -> code.equalsIgnoreCase(x.getSegment3())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(temp)){
temp = list;
}
for(TrialBalance balance : temp){
ReportCellDataSourceDto dto = new ReportCellDataSourceDto();
dto.setAmount(balance.getPeriodDr());
dto.setPeriod(period);
dto.setIsOnlyManualInput(Boolean.FALSE);
dto.setName(Constant.DataSourceName.ReportDataSource);
dto.setType( FormulaDataSourceType.TrialBalanceSource.getCode());
contain.add(dto);
}
return temp.stream().mapToDouble(a -> a.getPeriodDr().doubleValue()).sum();
}
private double countForAdjBalance(String code, List<ReportCellDataSourceDto> contain, int period, int year, String orgId){
Organization organization = SpringContextUtil.organizationMapper.selectByPrimaryKey(orgId);
AdjustmentTableExample example = new AdjustmentTableExample();
AdjustmentTableExample.Criteria c1 = example.createCriteria().andSegment3EqualTo(code).andPeriodEqualTo(pardePeriod(period, year));
AdjustmentTableExample.Criteria c2 = example.createCriteria().andSegment4EqualTo(code).andPeriodEqualTo(pardePeriod(period, year));
if(organization != null){
c1.andOrganizationIdEqualTo(organization.getId());
c2.andOrganizationIdEqualTo(organization.getId());
}
example.or(c2);
List<AdjustmentTable> list = SpringContextUtil.adjustmentTableMapper.selectByExample(example);
if(CollectionUtils.isEmpty(list)){
return 0.0;
}
List<AdjustmentTable> temp = list.stream().filter(x -> code.equalsIgnoreCase(x.getSegment3())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(temp)){
temp = list;
}
for(AdjustmentTable balance : temp){
ReportCellDataSourceDto dto = new ReportCellDataSourceDto();
dto.setAmount(balance.getPeriodDrBeq());
dto.setPeriod(period);
dto.setIsOnlyManualInput(Boolean.FALSE);
dto.setName(Constant.DataSourceName.ReportDataSource);
dto.setType( FormulaDataSourceType.TrialBalanceSource.getCode());
contain.add(dto);
}
return temp.stream().mapToDouble(a -> a.getPeriodDrBeq().doubleValue()).sum();
}
private double countForTrialFinalBalance(String code, List<ReportCellDataSourceDto> contain, int period, int year, String orgId){
Organization organization = SpringContextUtil.organizationMapper.selectByPrimaryKey(orgId);
GlBalanceExample glBalanceExample = new GlBalanceExample();
GlBalanceExample.Criteria c1 = glBalanceExample.createCriteria().andSegment3EqualTo(code).andPeriodNameEqualTo(periodName(period, year));
GlBalanceExample.Criteria c2 = glBalanceExample.createCriteria().andSegment4EqualTo(code).andPeriodNameEqualTo(periodName(period, year));
TrialBalanceFinalExample example = new TrialBalanceFinalExample();
TrialBalanceFinalExample.Criteria c1 = example.createCriteria().andSegment3EqualTo(code).andPeriodEqualTo(pardePeriod(period, year));
TrialBalanceFinalExample.Criteria c2 = example.createCriteria().andSegment4EqualTo(code).andPeriodEqualTo(pardePeriod(period, year));
if(organization != null){
c1.andSegment1EqualTo(organization.getClientCode());
c2.andSegment1EqualTo(organization.getClientCode());
c1.andOrganizationIdEqualTo(organization.getId());
c2.andOrganizationIdEqualTo(organization.getId());
}
glBalanceExample.or(c2);
List<GlBalance> list = SpringContextUtil.glBalanceMapper.selectByExample(glBalanceExample);
example.or(c2);
List<TrialBalanceFinal> list = SpringContextUtil.trialBalanceFinalMapper.selectByExample(example);
if(CollectionUtils.isEmpty(list)){
return 0.0;
}
List<GlBalance> temp = list.stream().filter(x -> code.equalsIgnoreCase(x.getSegment3())).collect(Collectors.toList());
List<TrialBalanceFinal> temp = list.stream().filter(x -> code.equalsIgnoreCase(x.getSegment3())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(temp)){
temp = list;
}
for(GlBalance glBalance : temp){
for(TrialBalanceFinal balance : temp){
ReportCellDataSourceDto dto = new ReportCellDataSourceDto();
dto.setAmount(glBalance.getPtdDr());
dto.setAmount(balance.getPeriodDr());
dto.setPeriod(period);
dto.setIsOnlyManualInput(Boolean.FALSE);
dto.setName(Constant.DataSourceName.ReportDataSource);
dto.setType( FormulaDataSourceType.TrialBalanceSource.getCode());
contain.add(dto);
}
return temp.stream().mapToDouble(a -> a.getPtdDr().doubleValue()).sum();
return temp.stream().mapToDouble(a -> a.getPeriodDr().doubleValue()).sum();
}
}
......@@ -5,8 +5,8 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.entity.TrialBalance;
import pwc.taxtech.atms.vat.entity.TrialBalanceExample;
import pwc.taxtech.atms.vat.entity.TrialBalanceFinal;
import pwc.taxtech.atms.vat.entity.TrialBalanceFinalExample;
@Mapper
public interface TrialBalanceFinalMapper extends MyVatMapper {
......@@ -16,7 +16,7 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
*
* @mbg.generated
*/
long countByExample(TrialBalanceExample example);
long countByExample(TrialBalanceFinalExample example);
/**
* This method was generated by MyBatis Generator.
......@@ -24,7 +24,7 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
*
* @mbg.generated
*/
int deleteByExample(TrialBalanceExample example);
int deleteByExample(TrialBalanceFinalExample example);
/**
* This method was generated by MyBatis Generator.
......@@ -40,7 +40,7 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
*
* @mbg.generated
*/
int insert(TrialBalance record);
int insert(TrialBalanceFinal record);
/**
* This method was generated by MyBatis Generator.
......@@ -48,7 +48,7 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
*
* @mbg.generated
*/
int insertSelective(TrialBalance record);
int insertSelective(TrialBalanceFinal record);
/**
* This method was generated by MyBatis Generator.
......@@ -56,7 +56,7 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
*
* @mbg.generated
*/
List<TrialBalance> selectByExampleWithRowbounds(TrialBalanceExample example, RowBounds rowBounds);
List<TrialBalanceFinal> selectByExampleWithRowbounds(TrialBalanceFinalExample example, RowBounds rowBounds);
/**
* This method was generated by MyBatis Generator.
......@@ -64,7 +64,7 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
*
* @mbg.generated
*/
List<TrialBalance> selectByExample(TrialBalanceExample example);
List<TrialBalanceFinal> selectByExample(TrialBalanceFinalExample example);
/**
* This method was generated by MyBatis Generator.
......@@ -72,7 +72,7 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
*
* @mbg.generated
*/
TrialBalance selectByPrimaryKey(Long id);
TrialBalanceFinal selectByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
......@@ -80,7 +80,7 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") TrialBalance record, @Param("example") TrialBalanceExample example);
int updateByExampleSelective(@Param("record") TrialBalanceFinal record, @Param("example") TrialBalanceFinalExample example);
/**
* This method was generated by MyBatis Generator.
......@@ -88,7 +88,7 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
*
* @mbg.generated
*/
int updateByExample(@Param("record") TrialBalance record, @Param("example") TrialBalanceExample example);
int updateByExample(@Param("record") TrialBalanceFinal record, @Param("example") TrialBalanceFinalExample example);
/**
* This method was generated by MyBatis Generator.
......@@ -96,7 +96,7 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(TrialBalance record);
int updateByPrimaryKeySelective(TrialBalanceFinal record);
/**
* This method was generated by MyBatis Generator.
......@@ -104,5 +104,5 @@ public interface TrialBalanceFinalMapper extends MyVatMapper {
*
* @mbg.generated
*/
int updateByPrimaryKey(TrialBalance record);
int updateByPrimaryKey(TrialBalanceFinal record);
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pwc.taxtech.atms.vat.dao.TrialBalanceFinalMapper">
<resultMap id="BaseResultMap" type="pwc.taxtech.atms.vat.entity.TrialBalance">
<resultMap id="BaseResultMap" type="pwc.taxtech.atms.vat.entity.TrialBalanceFinal">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......@@ -141,7 +141,7 @@
period_dr_beq, period_cr_beq, end_bal_beq, qtd_dr_beq, qtd_cr_beq, ytd_dr_beq, ytd_cr_beq,
create_time, update_time
</sql>
<select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceExample" resultMap="BaseResultMap">
<select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceFinalExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......@@ -177,7 +177,7 @@
delete from trial_balance_final
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceExample">
<delete id="deleteByExample" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceFinalExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......@@ -187,7 +187,7 @@
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="pwc.taxtech.atms.vat.entity.TrialBalance">
<insert id="insert" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceFinal">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......@@ -231,7 +231,7 @@
#{ytdCrBeq,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.TrialBalance">
<insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceFinal">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......@@ -566,7 +566,7 @@
</if>
</trim>
</insert>
<select id="countByExample" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceExample" resultType="java.lang.Long">
<select id="countByExample" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceFinalExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......@@ -814,7 +814,7 @@
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="pwc.taxtech.atms.vat.entity.TrialBalance">
<update id="updateByPrimaryKeySelective" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceFinal">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......@@ -983,7 +983,7 @@
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="pwc.taxtech.atms.vat.entity.TrialBalance">
<update id="updateByPrimaryKey" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceFinal">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......@@ -1044,7 +1044,7 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectByExampleWithRowbounds" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceExample" resultMap="BaseResultMap">
<select id="selectByExampleWithRowbounds" parameterType="pwc.taxtech.atms.vat.entity.TrialBalanceFinalExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
......
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