Commit 3765bc20 authored by neo's avatar neo

[DEV] delete bb reference formula cacls

parent b22c475a
package pwc.taxtech.atms.constant.enums;
public enum EnumOperationType {
Single(0),
Add(1),
Sub(2),
Mul(3),
Div(4);
private int code;
EnumOperationType(int code) {
this.code = code;
}
public int getCode() {
return code;
}
}
package pwc.taxtech.atms.dto.vatdto;
import java.math.BigDecimal;
public class DataSourceAmount {
public BigDecimal amount;
public Integer operationType;
}
package pwc.taxtech.atms.vat.dao;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.dto.vatdto.DataSourceAmount;
import java.util.List;
@Mapper
public interface FormulaProjectMapper extends MyVatMapper {
@Select("SELECT " +
" ds.amount, cds.operation_type AS operationType " +
"FROM " +
" data_source ds " +
" JOIN " +
" cell_data_source cds ON ds.id = cds.data_source_id " +
"WHERE " +
" cds.cell_data_id = #{cellId} " +
" AND ds.type != #{code} " +
" AND ds.amount IS NOT NULL ")
List<DataSourceAmount> queryDsAmount(@Param("cellId") Long dataId, @Param("code") Integer code);
}
......@@ -4,26 +4,19 @@ import com.github.pagehelper.util.StringUtil;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.StringValueEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.CellDataSourceType;
import pwc.taxtech.atms.constant.enums.EnumOperationType;
import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dto.GroupId;
import pwc.taxtech.atms.dto.vatdto.BBParasBo;
import pwc.taxtech.atms.dto.vatdto.CellTemplatePerGroupDto;
import pwc.taxtech.atms.dto.vatdto.CloseableFormulaDataSource;
import pwc.taxtech.atms.dto.vatdto.CurrentPeriodBo;
import pwc.taxtech.atms.dto.vatdto.DataSourceAmount;
import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto;
import pwc.taxtech.atms.entitiy.ProjectExample;
import pwc.taxtech.atms.entitiy.ProjectServiceType;
import pwc.taxtech.atms.entitiy.ProjectServiceTypeExample;
import pwc.taxtech.atms.vat.entity.CellData;
......@@ -132,6 +125,8 @@ public class ReportFormulaFactory {
List<Report> reports = agent.reportMapper.selectByExample(example);
if (reports == null || reports.isEmpty()) {
LOGGER.warn("report data is empty");
ShardingContextHolder.setDataSourceKey(currentProjectDb);
return defaultEval;
}
......@@ -141,6 +136,8 @@ public class ReportFormulaFactory {
List<CellData> cellDatas = agent.cellDataMapper.selectByExample(dataExample);
if (cellDatas == null || cellDatas.isEmpty()) {
LOGGER.warn("cell data is empty");
ShardingContextHolder.setDataSourceKey(currentProjectDb);
return defaultEval;
}
......@@ -154,32 +151,19 @@ public class ReportFormulaFactory {
nullCellDto.setAmount(cellValue);
LOGGER.debug("cell static value ");
ShardingContextHolder.setDataSourceKey(currentProjectDb);
return new NumberEval(cellValue.doubleValue());
}
ShardingContextHolder.setDataSourceKey(currentProjectDb);
// Boolean hasValuedDataSource = false;//TODO: Calculate other referenced formula
// BigDecimal dataSourceAmount = new BigDecimal(0);
// List<DataSourceAmount> amounts = agent.projectMp.queryDsAmount(cellData.getId(),
// CellDataSourceType.Formula.getCode());
// if (amounts != null || !amounts.isEmpty())
// for (DataSourceAmount m : amounts)
// if (m.operationType.intValue() == EnumOperationType.Sub.getCode())
// dataSourceAmount = dataSourceAmount.subtract(m.amount);
// else dataSourceAmount = dataSourceAmount.add(m.amount);
//
// if (!StringUtil.isEmpty(cellTemplateData.getFormula())) {
//
// }
//TODO: Calculate other referenced formula
} catch (EvaluationException e) {
LOGGER.warn("resole args some exception", e);
e.printStackTrace();
} catch (Exception e) {
LOGGER.warn("unsupport exception", e);
e.printStackTrace();
}
return null;
return defaultEval;
}
}
......
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