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

add mapper agent

parent c1b08986
package pwc.taxtech.atms.dto.vatdto;
public class CellTemplatePerGroupDto {
private String cellTemplateID ;
private String reportTemplateID ;
private String reportTemplateGroupID ;
private String formula ;
private int rowIndex ;
private int columnIndex ;
private String reportCode ;
private String rowName ;
private String columnName ;
private Integer resultType ;
public String getCellTemplateID() {
return cellTemplateID;
}
public void setCellTemplateID(String cellTemplateID) {
this.cellTemplateID = cellTemplateID;
}
public String getReportTemplateID() {
return reportTemplateID;
}
public void setReportTemplateID(String reportTemplateID) {
this.reportTemplateID = reportTemplateID;
}
public String getReportTemplateGroupID() {
return reportTemplateGroupID;
}
public void setReportTemplateGroupID(String reportTemplateGroupID) {
this.reportTemplateGroupID = reportTemplateGroupID;
}
public String getFormula() {
return formula;
}
public void setFormula(String formula) {
this.formula = formula;
}
public int getRowIndex() {
return rowIndex;
}
public void setRowIndex(int rowIndex) {
this.rowIndex = rowIndex;
}
public int getColumnIndex() {
return columnIndex;
}
public void setColumnIndex(int columnIndex) {
this.columnIndex = columnIndex;
}
public String getReportCode() {
return reportCode;
}
public void setReportCode(String reportCode) {
this.reportCode = reportCode;
}
public String getRowName() {
return rowName;
}
public void setRowName(String rowName) {
this.rowName = rowName;
}
public String getColumnName() {
return columnName;
}
public void setColumnName(String columnName) {
this.columnName = columnName;
}
public Integer getResultType() {
return resultType;
}
public void setResultType(Integer resultType) {
this.resultType = resultType;
}
}
......@@ -5,6 +5,7 @@ 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.dto.vatdto.CellTemplatePerGroupDto;
import pwc.taxtech.atms.vat.entity.PeriodTemplate;
import pwc.taxtech.atms.vat.entity.PeriodTemplateExample;
......@@ -108,4 +109,6 @@ public interface PeriodTemplateMapper extends MyVatMapper {
void batchInsert(List<PeriodTemplate> periodTemplateList);
List<CellTemplatePerGroupDto> getCellTemplatePerGroup(Integer period,String reportTemplateGroupID);
}
\ No newline at end of file
......@@ -18,6 +18,9 @@ import pwc.taxtech.atms.service.impl.DistributedIDService;
import pwc.taxtech.atms.vat.dao.*;
import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.ReportGenerator;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaAgent;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext;
import pwc.taxtech.atms.vat.service.impl.report.functions.SGSR;
import java.io.File;
import java.io.FileNotFoundException;
......@@ -39,6 +42,8 @@ public class ReportGeneratorImpl implements ReportGenerator {
ReportMapper reportMapper;
@Autowired
CellDataMapper cellDataMapper;
@Autowired
FormulaAgent formulaAgent;
private static final Logger logger = LoggerFactory.getLogger(ReportGeneratorImpl.class);
......@@ -221,8 +226,10 @@ public class ReportGeneratorImpl implements ReportGenerator {
* @param workbook 工作簿
*/
private void addFunctionsToWorkbook(Workbook workbook) {
String[] functionNames = {"functionName"};
FreeRefFunction[] functionImpls = {};
String[] functionNames = {"SGSR"};
FormulaContext formulaContext = new FormulaContext();
formulaContext.setFormulaAgent(formulaAgent);
FreeRefFunction[] functionImpls = {new SGSR(formulaContext)};
UDFFinder udfs = new DefaultUDFFinder(functionNames, functionImpls);
UDFFinder udfToolpack = new AggregatingUDFFinder(udfs);
workbook.addToolPack(udfToolpack);
......
......@@ -12,48 +12,48 @@ public class VatAbstractService {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
CompanyBalanceMapper companyBalanceMapper;
public CompanyBalanceMapper companyBalanceMapper;
@Autowired
VatEnterpriseAccountMapper vatEnterpriseAccountMapper;
public VatEnterpriseAccountMapper vatEnterpriseAccountMapper;
@Autowired
VatStandardAccountMapper vatStandardAccountMapper;
public VatStandardAccountMapper vatStandardAccountMapper;
@Autowired
InputVATInvoiceMapper inputVATInvoiceMapper;
public InputVATInvoiceMapper inputVATInvoiceMapper;
@Autowired
OutputVATInvoiceMapper outputVATInvoiceMapper;
public OutputVATInvoiceMapper outputVATInvoiceMapper;
@Autowired
CustomsInvoiceMapper customsInvoiceMapper;
public CustomsInvoiceMapper customsInvoiceMapper;
@Autowired
OutputVATInvoiceItemMapper outputVATInvoiceItemMapper;
public OutputVATInvoiceItemMapper outputVATInvoiceItemMapper;
@Autowired
InputVATInvoiceItemMapper inputVATInvoiceItemMapper;
public InputVATInvoiceItemMapper inputVATInvoiceItemMapper;
@Autowired
ProjectMapper projectMapper;
public ProjectMapper projectMapper;
@Autowired
TaxPayerReportRuleMapper taxPayerReportRuleMapper;
public TaxPayerReportRuleMapper taxPayerReportRuleMapper;
@Autowired
ProjectServiceTypeMapper projectServiceTypeMapper;
public ProjectServiceTypeMapper projectServiceTypeMapper;
@Autowired
TemplateMapper templateMapper;
public TemplateMapper templateMapper;
@Autowired
PeriodTemplateMapper periodTemplateMapper;
public PeriodTemplateMapper periodTemplateMapper;
@Autowired
PeriodCellTemplateMapper periodCellTemplateMapper;
public PeriodCellTemplateMapper periodCellTemplateMapper;
@Autowired
PeriodCellTemplateConfigMapper periodCellTemplateConfigMapper;
public PeriodCellTemplateConfigMapper periodCellTemplateConfigMapper;
@Autowired
DataSourceMapper dataSourceMapper;
public DataSourceMapper dataSourceMapper;
@Autowired
TemplateGroupMapper templateGroupMapper;
public TemplateGroupMapper templateGroupMapper;
@Autowired
DistributedIDService distributedIDService;
public DistributedIDService distributedIDService;
@Autowired
CellTemplateMapper cellTemplateMapper;
public CellTemplateMapper cellTemplateMapper;
@Autowired
CellTemplateConfigMapper cellTemplateConfigMapper;
public CellTemplateConfigMapper cellTemplateConfigMapper;
@Autowired
EnterpriseAccountMapper enterpriseAccountMapper;
public EnterpriseAccountMapper enterpriseAccountMapper;
@Autowired
ReportGenerator reportGenerator;
public ReportGenerator reportGenerator;
}
package pwc.taxtech.atms.vat.service.impl.report.functions;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.vat.service.impl.VatAbstractService;
@Service
public class FormulaAgent extends VatAbstractService {
}
package pwc.taxtech.atms.vat.service.impl.report.functions;
import pwc.taxtech.atms.utils.FormulaResult;
import pwc.taxtech.atms.vat.dao.PeriodTemplateMapper;
import java.util.Map;
public class FormulaContext {
private Integer period;
private Integer year;
private String projectID;
private String reportTemplateGroupID;
private String reportID;
private String organizationID;
private Integer period;
private Integer year;
private Boolean isYear;
private String indexResultId;
private Integer yearBeginPeriod;
private Integer yearEndPeriod;
private Boolean ifRound;
private Boolean isValidation;
private Boolean isDetailed;
private Boolean isIndexAnalysis;
private Boolean cacheHasIndexCode;
private PeriodTemplateMapper periodTemplateMappler;
private FormulaAgent formulaAgent;
// <summary>
// 如果BB公式在cache中取上期失败,是否去上期取
// </summary>
private Boolean ifCalcStackValue;
// <summary>
// 如果为99,则实时计算;如果为-1,则不用于判断是否实时计算;其他情况会在对应时机计算并保存
// </summary>
private Integer calculateStatus;
private Map<String, FormulaResult> replaceSpecialCellFormulaDic;
public String getProjectID() {
return projectID;
}
public void setProjectID(String projectID) {
this.projectID = projectID;
}
public String getReportTemplateGroupID() {
return reportTemplateGroupID;
}
public void setReportTemplateGroupID(String reportTemplateGroupID) {
this.reportTemplateGroupID = reportTemplateGroupID;
}
public String getReportID() {
return reportID;
}
public void setReportID(String reportID) {
this.reportID = reportID;
}
public String getOrganizationID() {
return organizationID;
}
public void setOrganizationID(String organizationID) {
this.organizationID = organizationID;
}
public Integer getPeriod() {
return period;
......@@ -16,7 +78,123 @@ private Integer year;
return year;
}
public void setYear(Boolean year) {
isYear = year;
}
public String getIndexResultId() {
return indexResultId;
}
public void setIndexResultId(String indexResultId) {
this.indexResultId = indexResultId;
}
public Integer getYearBeginPeriod() {
return yearBeginPeriod;
}
public void setYearBeginPeriod(Integer yearBeginPeriod) {
this.yearBeginPeriod = yearBeginPeriod;
}
public Integer getYearEndPeriod() {
return yearEndPeriod;
}
public void setYearEndPeriod(Integer yearEndPeriod) {
this.yearEndPeriod = yearEndPeriod;
}
public Boolean getIfRound() {
return ifRound;
}
public void setIfRound(Boolean ifRound) {
this.ifRound = ifRound;
}
public Boolean getValidation() {
return isValidation;
}
public void setValidation(Boolean validation) {
isValidation = validation;
}
public Boolean getDetailed() {
return isDetailed;
}
public void setDetailed(Boolean detailed) {
isDetailed = detailed;
}
public Boolean getIndexAnalysis() {
return isIndexAnalysis;
}
public void setIndexAnalysis(Boolean indexAnalysis) {
isIndexAnalysis = indexAnalysis;
}
public Boolean getCacheHasIndexCode() {
return cacheHasIndexCode;
}
public void setCacheHasIndexCode(Boolean cacheHasIndexCode) {
this.cacheHasIndexCode = cacheHasIndexCode;
}
public Boolean getIfCalcStackValue() {
return ifCalcStackValue;
}
public void setIfCalcStackValue(Boolean ifCalcStackValue) {
this.ifCalcStackValue = ifCalcStackValue;
}
public Integer getCalculateStatus() {
return calculateStatus;
}
public void setCalculateStatus(Integer calculateStatus) {
this.calculateStatus = calculateStatus;
}
public Map<String, FormulaResult> getReplaceSpecialCellFormulaDic() {
return replaceSpecialCellFormulaDic;
}
public void setReplaceSpecialCellFormulaDic(Map<String, FormulaResult> replaceSpecialCellFormulaDic) {
this.replaceSpecialCellFormulaDic = replaceSpecialCellFormulaDic;
}
public void setYear(Integer year) {
this.year = year;
}
public PeriodTemplateMapper getPeriodTemplateMappler() {
return periodTemplateMappler;
}
public void setPeriodTemplateMappler(PeriodTemplateMapper periodTemplateMappler) {
this.periodTemplateMappler = periodTemplateMappler;
}
public Boolean getIsYear() {
return isYear;
}
public void setIsYear(Boolean isYear) {
isYear = isYear;
}
public FormulaAgent getFormulaAgent() {
return formulaAgent;
}
public void setFormulaAgent(FormulaAgent formulaAgent) {
this.formulaAgent = formulaAgent;
}
}
......@@ -5,11 +5,16 @@ import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.springframework.beans.factory.annotation.Autowired;
import pwc.taxtech.atms.vat.dao.PeriodTemplateMapper;
public class SGSRFunction implements FreeRefFunction {
public class SGSR implements FreeRefFunction {
private FormulaContext formulaContext;
public SGSRFunction(FormulaContext formulaContext){
@Autowired
PeriodTemplateMapper periodTemplateMapper;
public SGSR(FormulaContext formulaContext) {
this.formulaContext = formulaContext;
}
......@@ -50,19 +55,16 @@ public class SGSRFunction implements FreeRefFunction {
period = OperandResolver.coerceValueToInt(v4);
int curYear, curPeriod;
if(reportCode.startsWith("VAT")){
if (reportCode.startsWith("VAT")) {
int[] yearOffSet = {};
curPeriod =FormulaHelper.getPeriod(period,yearOffSet,formulaContext);
curYear = FormulaHelper.getYear(year,formulaContext)+yearOffSet[0];
}
else if(reportCode.startsWith("CIT.")){
curYear=FormulaHelper.getYear(year,formulaContext);
curPeriod=0;
}
else{
curPeriod = FormulaHelper.getPeriod(period, yearOffSet, formulaContext);
curYear = FormulaHelper.getYear(year, formulaContext) + yearOffSet[0];
} else if (reportCode.startsWith("CIT.")) {
curYear = FormulaHelper.getYear(year, formulaContext);
curPeriod = 0;
} else {
}
formulaContext.getFormulaAgent().periodTemplateMapper.getCellTemplatePerGroup(formulaContext.getPeriod(), formulaContext.getReportTemplateGroupID());
} catch (EvaluationException e) {
......
......@@ -502,4 +502,32 @@
)
</foreach>
</insert>
<resultMap id="cellTemplatePerGroupDto" type="pwc.taxtech.atms.dto.vatdto.CellTemplatePerGroupDto">
</resultMap>
<select id="getCellTemplatePerGroup" resultMap="cellTemplatePerGroupDto">
SELECT
celltemplate.id AS cellTemplateID,
template.id AS reportTemplateID,
template.template_group_id AS reportTemplateGroupID,
IFNULL(celltemplateconfig.formula,'') AS formula,
celltemplate.row_index AS rowIndex,
celltemplate.column_index AS columnIndex,
template.code AS reportCode,
celltemplate.column_name AS columnName,
celltemplate.row_name AS rowName,
celltemplate.data_type AS resultType
FROM period_template template
JOIN period_cell_template celltemplate
ON template.id = celltemplate.report_template_id
LEFT JOIN period_cell_template_config celltemplateconfig
ON celltemplateconfig.cell_template_id = celltemplate.id
WHERE template.period=#{period,jdbcType=INTEGER}
AND celltemplate.period=#{period,jdbcType=INTEGER}
AND celltemplateconfig.period==#{period,jdbcType=INTEGER}
AND celltemplateconfig.data_source_type=1
AND template.template_group_id=#{reportTemplateGroupID,jdbcType=VARCHAR}
AND template.is_active_association=1
</select>
</mapper>
\ No newline at end of file
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