Commit cb092a3f authored by frank.xa.zhang's avatar frank.xa.zhang

fixed issues for formula validate

parent c1904df7
......@@ -248,7 +248,8 @@ public class CellTemplateServiceImpl extends AbstractService implements CellTemp
List<FormulaConfig> dataSourceList = formulaConfigMapper.selectByExample(example);
List<String> nameList = new ArrayList<>();
FormulaHelper formulaHelper = new FormulaHelper();
String tmpFormula = formulaHelper.formatFormula(formula).toUpperCase();
// String tmpFormula = formulaHelper.formatFormula(formula).toUpperCase();
String tmpFormula = formula.toUpperCase();
for (FormulaConfig dataSource : dataSourceList) {
if (tmpFormula.contains(dataSource.getFormulaName().toUpperCase() + "(") && !nameList.contains(dataSource.getDataSourceName())) {
......
......@@ -65,7 +65,9 @@ public final class FormulaHelper {
while (!regexMatchObjectStack.empty()) {
RegexMatchObject obj = regexMatchObjectStack.pop();
formula = formula.substring(0, obj.getIndex()) + obj.getExpression() + formula.substring(obj.getIndex(), obj.getLength());
formula = formula.substring(0, obj.getIndex())
+ obj.getExpression()
+ formula.substring(obj.getIndex(), obj.getIndex() + obj.getLength());
}
return formula.trim();
}
......
package pwc.taxtech.atms.service.impl;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.FormulaParseException;
import org.apache.poi.ss.formula.FormulaParser;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.TemplateFormulaService;
......@@ -22,8 +27,17 @@ public class TemplateFormulaServiceImpl extends AbstractService implements Templ
}
try {
String tidyFormula = formulaHelper.formatFormula(formula);
//String tidyFormula = formulaHelper.formatFormula(formula);
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFEvaluationWorkbook xssfEvaluationWorkbook = XSSFEvaluationWorkbook.create(workbook);
try {
FormulaParser.parse(formula, xssfEvaluationWorkbook, FormulaType.CELL, 0);
result.setResult(true);
return result;
} catch (FormulaParseException e) {
result.setResult(false);
result.setResultMsg(e.getMessage());
}
/*todo: find the replace solution for here to check formual is correct or not
//var sourceCode = m_engine.CreateScriptSourceFromString(tidyFormula, SourceCodeKind.AutoDetect);
//var compileCode = sourceCode.Compile();
......
......@@ -124,7 +124,9 @@ public interface DataSourceMapper extends MyVatMapper {
void clearDataSourceDetailWithPeriod(@Param("period") Integer period);
void clearCellDataWithPeriod(@Param("exceptReportTemplateIDs") String exceptReportTemplateIDs);
void clearCellDataWithPeriod(@Param("exceptReportTemplateIDs") String exceptReportTemplateIDs,@Param("period")Integer period);
void clearReportWithPeriod(Integer period);
List<DataSourceExtendDto> getFormulaDataSource(Long reportID);
}
\ No newline at end of file
......@@ -105,4 +105,6 @@ public interface PeriodFormulaBlockMapper extends MyVatMapper {
* @mbg.generated
*/
int updateByPrimaryKey(PeriodFormulaBlock record);
void updateReportId(@Param("reportId") Long reportId,@Param("cellTemplateConfigIds") List<Long> cellTemplateConfigIds,@Param("period") Integer period);
}
\ No newline at end of file
......@@ -24,14 +24,7 @@ import pwc.taxtech.atms.dto.vatdto.CellCalcInfoDto;
import pwc.taxtech.atms.dto.vatdto.CellTemplateConfigGroupDto;
import pwc.taxtech.atms.dto.vatdto.PeriodCellTemplateConfigExtendDto;
import pwc.taxtech.atms.entitiy.Project;
import pwc.taxtech.atms.vat.entity.CellData;
import pwc.taxtech.atms.vat.entity.PeriodCellTemplate;
import pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfig;
import pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfigExample;
import pwc.taxtech.atms.vat.entity.PeriodCellTemplateExample;
import pwc.taxtech.atms.vat.entity.PeriodTemplate;
import pwc.taxtech.atms.vat.entity.PeriodTemplateExample;
import pwc.taxtech.atms.vat.entity.Report;
import pwc.taxtech.atms.vat.entity.*;
import pwc.taxtech.atms.vat.service.ReportGenerator;
import pwc.taxtech.atms.vat.service.impl.report.functions.FSJZ;
import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaContext;
......@@ -69,7 +62,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria().andIdIn(templateIds);
List<PeriodTemplate> periodTemplateList = periodTemplateMapper.selectByExample(periodTemplateExample);
List<Long> periodTemplateIDList = periodTemplateList.stream().map(PeriodTemplate::getTemplateId).collect(Collectors.toList());
List<Long> periodTemplateIDList = periodTemplateList.stream()
.map(PeriodTemplate::getTemplateId)
.collect(Collectors.toList());
Long templateGroupID = periodTemplateList.size() > 0 ? periodTemplateList.get(0).getTemplateGroupId() : 0;
......@@ -80,7 +75,8 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
PeriodCellTemplateConfigExample periodCellTemplateConfigExample = new PeriodCellTemplateConfigExample();
// only get formula config
periodCellTemplateConfigExample.createCriteria().andReportTemplateIdIn(periodTemplateIDList);
List<PeriodCellTemplateConfig> periodCellTemplateConfigList = periodCellTemplateConfigMapper.selectByExample(periodCellTemplateConfigExample);
List<PeriodCellTemplateConfig> periodCellTemplateConfigList =
periodCellTemplateConfigMapper.selectByExample(periodCellTemplateConfigExample);
Map<String, String> templateCodeAndPath = new HashMap<>();
periodTemplateList.forEach(a -> templateCodeAndPath.put(a.getCode(), getTemplatePath(a.getPath())));
......@@ -90,10 +86,10 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
Workbook newWorkbook = workbook.get();
FormulaContext formulaContext = new FormulaContext();
formulaContext.setFormulaAgent(formulaAgent);
formulaContext.setPeriod(6);//todo: assign value later
formulaContext.setPeriod(period);
formulaContext.setReportTemplateGroupID(templateGroupID);
formulaContext.setProjectID(project.getID());
formulaContext.setYear(project.getYear());//todo: assign value later
formulaContext.setYear(project.getYear());
formulaContext.setOrganizationID(project.getOrganizationID());
addFunctionsToWorkbook(newWorkbook, formulaContext);
......@@ -101,7 +97,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
for (int i = 0; i < sheetCount; i++) {
Sheet sheet = newWorkbook.getSheetAt(i);
String code = sheet.getSheetName();
Optional<PeriodTemplate> periodTemplate = periodTemplateList.stream().filter(a -> a.getCode().equals(code)).findFirst();
Optional<PeriodTemplate> periodTemplate = periodTemplateList.stream()
.filter(a -> a.getCode().equals(code))
.findFirst();
Long templateID;
if (periodTemplate.isPresent()) {
templateID = periodTemplate.get().getTemplateId();
......@@ -110,18 +108,18 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
}
if (templateID > 0) {
//todo: get cell template and cell template config with templateID
//get cell template and cell template config with templateID
Map<PeriodCellTemplate, PeriodCellTemplateConfig> cellTemplatePeriodCellTemplateConfigMap = new HashMap<>();
List<PeriodCellTemplate> tempPeriodCellTemplateList = periodCellTemplateList.stream()
.filter(a -> a.getReportTemplateId().equals(templateID))
.collect(Collectors.toList());
tempPeriodCellTemplateList.forEach(a -> {
Optional<PeriodCellTemplateConfig> tempCellTemplateConfig = periodCellTemplateConfigList.stream()
.filter(item -> item.getCellTemplateId().equals(a.getCellTemplateId()) && item.getDataSourceType().equals(CellDataSourceType.Formula.getCode()))
.filter(item -> item.getCellTemplateId().equals(a.getCellTemplateId())
&& item.getDataSourceType().equals(CellDataSourceType.Formula.getCode()))
.findFirst();
if (tempCellTemplateConfig.isPresent()) {
cellTemplatePeriodCellTemplateConfigMap.put(a, tempCellTemplateConfig.get());
}
tempCellTemplateConfig.ifPresent(periodCellTemplateConfig ->
cellTemplatePeriodCellTemplateConfigMap.put(a, periodCellTemplateConfig));
});
cellTemplatePeriodCellTemplateConfigMap.forEach((k, v) -> {
......@@ -138,7 +136,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
cell = row.getCell(k.getColumnIndex());
//todo:后面单独处理kv的公式
if (StringUtils.isNotBlank(v.getFormula())&&!v.getFormula().contains("@")) {
if (StringUtils.isNotBlank(v.getFormula()) && !v.getFormula().contains("@")) {
cell.setCellFormula(v.getFormula());
}
});
......@@ -151,7 +149,9 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
for (int i = 0; i < sheetCount; i++) {
Sheet sheet = newWorkbook.getSheetAt(i);
String code = sheet.getSheetName();
Optional<PeriodTemplate> periodTemplate = periodTemplateList.stream().filter(a -> a.getCode().equals(code)).findFirst();
Optional<PeriodTemplate> periodTemplate = periodTemplateList.stream()
.filter(a -> a.getCode().equals(code))
.findFirst();
Long templateID;
if (periodTemplate.isPresent()) {
templateID = periodTemplate.get().getTemplateId();
......@@ -173,23 +173,49 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
report.setUpdateTime(createTime);
reportMapper.insertSelective(report);
List<PeriodCellTemplateConfig> periodCellTemplateConfigs = periodCellTemplateConfigList.stream().filter(a -> a.getReportTemplateId().equals(templateID)).collect(Collectors.toList());
List<PeriodCellTemplateConfig> periodCellTemplateConfigs = periodCellTemplateConfigList.stream()
.filter(a -> a.getReportTemplateId().equals(templateID))
.collect(Collectors.toList());
//update formulablock table reportid field
List<Long> cellTemplateConfigIds = periodCellTemplateConfigs.stream()
.map(PeriodCellTemplateConfig::getCellTemplateId)
.collect(Collectors.toList());
periodFormulaBlockMapper.updateReportId(reportID, cellTemplateConfigIds, period);
for (PeriodCellTemplateConfig periodCellTemplateConfig : periodCellTemplateConfigs) {
Optional<PeriodCellTemplate> tempPeriodCellTemplate = periodCellTemplateList.stream().filter(a -> a.getCellTemplateId().equals(periodCellTemplateConfig.getCellTemplateId())).findFirst();
if (tempPeriodCellTemplate != null) {
Optional<PeriodCellTemplate> tempPeriodCellTemplate = periodCellTemplateList.stream()
.filter(a -> a.getCellTemplateId().equals(periodCellTemplateConfig.getCellTemplateId()))
.findFirst();
if (tempPeriodCellTemplate.isPresent()) {
CellData cellData = new CellData();
cellData.setId(distributedIDService.nextId());
cellData.setReportId(reportID);
cellData.setCellTemplateId(tempPeriodCellTemplate.get().getCellTemplateId());
String data;
if (sheet.getRow(tempPeriodCellTemplate.get().getRowIndex()) != null && sheet.getRow(tempPeriodCellTemplate.get().getRowIndex()).getCell(tempPeriodCellTemplate.get().getColumnIndex()) != null) {
data = Double.toString(sheet.getRow(tempPeriodCellTemplate.get().getRowIndex()).getCell(tempPeriodCellTemplate.get().getColumnIndex()).getNumericCellValue());
if (sheet.getRow(tempPeriodCellTemplate.get().getRowIndex()) != null
&& sheet.getRow(tempPeriodCellTemplate.get().getRowIndex())
.getCell(tempPeriodCellTemplate.get().getColumnIndex()) != null) {
data = Double.toString(sheet.getRow(tempPeriodCellTemplate.get().getRowIndex())
.getCell(tempPeriodCellTemplate.get().getColumnIndex()).getNumericCellValue());
} else {
data = EMPTY;
}
cellData.setData(data);
cellData.setFormulaExp(EMPTY);
PeriodFormulaBlockExample periodFormulaBlockExample = new PeriodFormulaBlockExample();
periodFormulaBlockExample.createCriteria().andPeriodEqualTo(period)
.andCellTemplateIdEqualTo(tempPeriodCellTemplate.get().getCellTemplateId());
//todo: 这里可能一个单元格不止一个公式,需要根据公式的内容来进行替换具体的解析公式
Optional<PeriodFormulaBlock> periodFormulaBlock =
periodFormulaBlockMapper.selectByExample(periodFormulaBlockExample).stream().findFirst();
if (periodFormulaBlock.isPresent()) {
cellData.setFormulaExp(periodFormulaBlock.get().getFormulaExpression());
} else {
cellData.setFormulaExp(EMPTY);
}
cellData.setCreateBy("Admin");
cellData.setCreateTime(createTime);
cellData.setUpdateBy("Admin");
......@@ -203,7 +229,6 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
} else {
return "GenerateReport failed";
}
return "generate report successful";
}
......
......@@ -114,7 +114,8 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
dataSourceMapper.clearTaxPayerReportWithPeriod(period);
dataSourceMapper.clearDataSourceWithPeriod(period);
dataSourceMapper.clearDataSourceDetailWithPeriod(period);
dataSourceMapper.clearCellDataWithPeriod(strExceptTemplateIDs);
dataSourceMapper.clearCellDataWithPeriod(strExceptTemplateIDs,period);
dataSourceMapper.clearReportWithPeriod(period);
// 根据templategroupid 把 template 插入到 periodTemplate
TemplateExample example = new TemplateExample();
......
......@@ -267,7 +267,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
PeriodFormulaBlock periodFormulaBlock = new PeriodFormulaBlock();
periodFormulaBlock.setId(SpringContextUtil.distributedIDService.nextId());
periodFormulaBlock.setPeriod(period);
periodFormulaBlock.setReportId(0L);
periodFormulaBlock.setReportId(0L);//todo:update reportID when report data generated
periodFormulaBlock.setCellTemplateId(cellTemplateID);
periodFormulaBlock.setFormulaExpression(formulaExpression);
periodFormulaBlock.setData(val.toString());
......
......@@ -36,6 +36,4 @@ public class FormulaContext {
private FormulaAgent formulaAgent;
//private Map<String, FormulaResult> replaceSpecialCellFormulaDic;
}
......@@ -93,7 +93,7 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, `type`, `name`, amount, description, key_value_data_id, create_by, create_time,
id, `type`, `name`, amount, description, key_value_data_id, create_by, create_time,
update_by, update_time, row_name, `column_name`, row_index, remap_batch_id, column_index
</sql>
<select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.DataSourceExample" resultMap="BaseResultMap">
......@@ -119,7 +119,7 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
select
<include refid="Base_Column_List" />
from data_source
where id = #{id,jdbcType=BIGINT}
......@@ -147,16 +147,16 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into data_source (id, `type`, `name`,
amount, description, key_value_data_id,
create_by, create_time, update_by,
update_time, row_name, `column_name`,
insert into data_source (id, `type`, `name`,
amount, description, key_value_data_id,
create_by, create_time, update_by,
update_time, row_name, `column_name`,
row_index, remap_batch_id, column_index
)
values (#{id,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
#{amount,jdbcType=DECIMAL}, #{description,jdbcType=VARCHAR}, #{keyValueDataId,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
#{updateTime,jdbcType=TIMESTAMP}, #{rowName,jdbcType=VARCHAR}, #{columnName,jdbcType=VARCHAR},
values (#{id,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
#{amount,jdbcType=DECIMAL}, #{description,jdbcType=VARCHAR}, #{keyValueDataId,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
#{updateTime,jdbcType=TIMESTAMP}, #{rowName,jdbcType=VARCHAR}, #{columnName,jdbcType=VARCHAR},
#{rowIndex,jdbcType=INTEGER}, #{remapBatchId,jdbcType=VARCHAR}, #{columnIndex,jdbcType=INTEGER}
)
</insert>
......@@ -454,35 +454,38 @@
<delete id="clearCellTemplateWithPeriod">
DELETE FROM period_cell_template WHERE period=#{period,jdbcType=INTEGER}
<if test="exceptReportTemplateIDs!=null and exceptReportTemplateIDs!=''">
and id not in (${exceptReportTemplateIDs});
and report_template_id not in (${exceptReportTemplateIDs});
</if>
</delete>
<delete id="clearCellTemplateConfigWithPeriod">
DELETE FROM period_cell_template_config WHERE period=#{period,jdbcType=INTEGER}
<if test="exceptReportTemplateIDs!=null and exceptReportTemplateIDs!=''">
and id not in (${exceptReportTemplateIDs});
and report_template_id not in (${exceptReportTemplateIDs});
</if>
</delete>
<delete id="clearTemplateWithPeriod">
DELETE FROM period_template WHERE period=#{period,jdbcType=INTEGER}
<if test="exceptReportTemplateIDs!=null and exceptReportTemplateIDs!=''">
and id not in (${exceptReportTemplateIDs});
and template_id not in (${exceptReportTemplateIDs});
</if>
</delete>
<delete id="clearTaxPayerReportWithPeriod">
DELETE FROM period_tax_payer_report_rule WHERE period=#{period,jdbcType=INTEGER};
</delete>
<delete id="clearDataSourceWithPeriod">
DELETE d FROM data_source d JOIN period_formula_block f ON d.id = f.data_source_id WHERE f.Period = #{period,jdbcType=INTEGER};
DELETE d FROM data_source d JOIN period_formula_block f ON d.id = f.data_source_id WHERE f.period = #{period,jdbcType=INTEGER};
</delete>
<delete id="clearDataSourceDetailWithPeriod">
DELETE d FROM data_source_detail d JOIN period_formula_block f ON d.data_source_id = f.data_source_id WHERE f.Period = #{period,jdbcType=INTEGER};
DELETE d FROM data_source_detail d JOIN period_formula_block f ON d.data_source_id = f.data_source_id WHERE f.period = #{period,jdbcType=INTEGER};
</delete>
<delete id="clearCellDataWithPeriod">
DELETE FROM cell_data
<if test="exceptReportTemplateIDs!=null and exceptReportTemplateIDs!=''">
WHERE report_id not in (${exceptReportTemplateIDs});
</if>
DELETE c FROM cell_data c join report r on c.report_id=r.id where r.period = #{period,jdbcType=INTEGER};
<!--<if test="exceptReportTemplateIDs!=null and exceptReportTemplateIDs!=''">-->
<!--WHERE report_id not in (${exceptReportTemplateIDs});-->
<!--</if>-->
</delete>
<delete id="clearReportWithPeriod">
DELETE FROM report WHERE period=#{period,jdbcType=INTEGER};
</delete>
<resultMap id="DataSourceExtendDtoMap" type="pwc.taxtech.atms.dto.vatdto.DataSourceExtendDto">
<id column="id" jdbcType="BIGINT" property="id" />
......@@ -504,7 +507,6 @@
<result column="cell_template_id" jdbcType="BIGINT" property="cellTemplateID" />
<result column="cell_data_id" jdbcType="BIGINT" property="cellDataID" />
</resultMap>
<select id="getFormulaDataSource" parameterType="java.lang.Long" resultMap="DataSourceExtendDtoMap">
SELECT
ds.*,
......
<?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.PeriodFormulaBlockMapper">
<resultMap id="BaseResultMap" type="pwc.taxtech.atms.vat.entity.PeriodFormulaBlock">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="period" jdbcType="INTEGER" property="period" />
<result column="report_id" jdbcType="BIGINT" property="reportId" />
<result column="cell_template_id" jdbcType="BIGINT" property="cellTemplateId" />
<result column="formula_expression" jdbcType="VARCHAR" property="formulaExpression" />
<result column="data" jdbcType="VARCHAR" property="data" />
<result column="data_source_id" jdbcType="BIGINT" property="dataSourceId" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
<resultMap id="BaseResultMap" type="pwc.taxtech.atms.vat.entity.PeriodFormulaBlock">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="period" jdbcType="INTEGER" property="period"/>
<result column="report_id" jdbcType="BIGINT" property="reportId"/>
<result column="cell_template_id" jdbcType="BIGINT" property="cellTemplateId"/>
<result column="formula_expression" jdbcType="VARCHAR" property="formulaExpression"/>
<result column="data" jdbcType="VARCHAR" property="data"/>
<result column="data_source_id" jdbcType="BIGINT" property="dataSourceId"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</trim>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, period, report_id, cell_template_id, formula_expression, `data`, data_source_id,
create_by, create_time, update_by, update_time
</sql>
<select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlockExample"
resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from period_formula_block
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List"/>
from period_formula_block
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from period_formula_block
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlockExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from period_formula_block
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</delete>
<insert id="insert" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlock">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into period_formula_block (id, period, report_id,
cell_template_id, formula_expression, `data`,
data_source_id, create_by, create_time,
update_by, update_time)
values (#{id,jdbcType=BIGINT}, #{period,jdbcType=INTEGER}, #{reportId,jdbcType=BIGINT},
#{cellTemplateId,jdbcType=BIGINT}, #{formulaExpression,jdbcType=VARCHAR}, #{data,jdbcType=VARCHAR},
#{dataSourceId,jdbcType=BIGINT}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlock">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into period_formula_block
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="period != null">
period,
</if>
<if test="reportId != null">
report_id,
</if>
<if test="cellTemplateId != null">
cell_template_id,
</if>
<if test="formulaExpression != null">
formula_expression,
</if>
<if test="data != null">
`data`,
</if>
<if test="dataSourceId != null">
data_source_id,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="period != null">
#{period,jdbcType=INTEGER},
</if>
<if test="reportId != null">
#{reportId,jdbcType=BIGINT},
</if>
<if test="cellTemplateId != null">
#{cellTemplateId,jdbcType=BIGINT},
</if>
<if test="formulaExpression != null">
#{formulaExpression,jdbcType=VARCHAR},
</if>
<if test="data != null">
#{data,jdbcType=VARCHAR},
</if>
<if test="dataSourceId != null">
#{dataSourceId,jdbcType=BIGINT},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlockExample"
resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from period_formula_block
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, period, report_id, cell_template_id, formula_expression, `data`, data_source_id,
create_by, create_time, update_by, update_time
</sql>
<select id="selectByExample" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlockExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from period_formula_block
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include refid="Base_Column_List" />
from period_formula_block
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from period_formula_block
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlockExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from period_formula_block
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlock">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into period_formula_block (id, period, report_id,
cell_template_id, formula_expression, `data`,
data_source_id, create_by, create_time,
update_by, update_time)
values (#{id,jdbcType=BIGINT}, #{period,jdbcType=INTEGER}, #{reportId,jdbcType=BIGINT},
#{cellTemplateId,jdbcType=BIGINT}, #{formulaExpression,jdbcType=VARCHAR}, #{data,jdbcType=VARCHAR},
#{dataSourceId,jdbcType=BIGINT}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlock">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
insert into period_formula_block
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="period != null">
period,
</if>
<if test="reportId != null">
report_id,
</if>
<if test="cellTemplateId != null">
cell_template_id,
</if>
<if test="formulaExpression != null">
formula_expression,
</if>
<if test="data != null">
`data`,
</if>
<if test="dataSourceId != null">
data_source_id,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="period != null">
#{period,jdbcType=INTEGER},
</if>
<if test="reportId != null">
#{reportId,jdbcType=BIGINT},
</if>
<if test="cellTemplateId != null">
#{cellTemplateId,jdbcType=BIGINT},
</if>
<if test="formulaExpression != null">
#{formulaExpression,jdbcType=VARCHAR},
</if>
<if test="data != null">
#{data,jdbcType=VARCHAR},
</if>
<if test="dataSourceId != null">
#{dataSourceId,jdbcType=BIGINT},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlockExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from period_formula_block
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update period_formula_block
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.period != null">
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update period_formula_block
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.period != null">
period = #{record.period,jdbcType=INTEGER},
</if>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=BIGINT},
</if>
<if test="record.cellTemplateId != null">
cell_template_id = #{record.cellTemplateId,jdbcType=BIGINT},
</if>
<if test="record.formulaExpression != null">
formula_expression = #{record.formulaExpression,jdbcType=VARCHAR},
</if>
<if test="record.data != null">
`data` = #{record.data,jdbcType=VARCHAR},
</if>
<if test="record.dataSourceId != null">
data_source_id = #{record.dataSourceId,jdbcType=BIGINT},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateBy != null">
update_by = #{record.updateBy,jdbcType=VARCHAR},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update period_formula_block
set id = #{record.id,jdbcType=BIGINT},
period = #{record.period,jdbcType=INTEGER},
</if>
<if test="record.reportId != null">
report_id = #{record.reportId,jdbcType=BIGINT},
</if>
<if test="record.cellTemplateId != null">
cell_template_id = #{record.cellTemplateId,jdbcType=BIGINT},
</if>
<if test="record.formulaExpression != null">
formula_expression = #{record.formulaExpression,jdbcType=VARCHAR},
</if>
<if test="record.data != null">
`data` = #{record.data,jdbcType=VARCHAR},
</if>
<if test="record.dataSourceId != null">
data_source_id = #{record.dataSourceId,jdbcType=BIGINT},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateBy != null">
update_by = #{record.updateBy,jdbcType=VARCHAR},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update period_formula_block
set id = #{record.id,jdbcType=BIGINT},
period = #{record.period,jdbcType=INTEGER},
report_id = #{record.reportId,jdbcType=BIGINT},
cell_template_id = #{record.cellTemplateId,jdbcType=BIGINT},
formula_expression = #{record.formulaExpression,jdbcType=VARCHAR},
`data` = #{record.data,jdbcType=VARCHAR},
data_source_id = #{record.dataSourceId,jdbcType=BIGINT},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_by = #{record.updateBy,jdbcType=VARCHAR},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlock">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update period_formula_block
<set>
<if test="period != null">
period = #{period,jdbcType=INTEGER},
</if>
<if test="reportId != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlock">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update period_formula_block
<set>
<if test="period != null">
period = #{period,jdbcType=INTEGER},
</if>
<if test="reportId != null">
report_id = #{reportId,jdbcType=BIGINT},
</if>
<if test="cellTemplateId != null">
cell_template_id = #{cellTemplateId,jdbcType=BIGINT},
</if>
<if test="formulaExpression != null">
formula_expression = #{formulaExpression,jdbcType=VARCHAR},
</if>
<if test="data != null">
`data` = #{data,jdbcType=VARCHAR},
</if>
<if test="dataSourceId != null">
data_source_id = #{dataSourceId,jdbcType=BIGINT},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlock">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update period_formula_block
set period = #{period,jdbcType=INTEGER},
report_id = #{reportId,jdbcType=BIGINT},
</if>
<if test="cellTemplateId != null">
cell_template_id = #{cellTemplateId,jdbcType=BIGINT},
</if>
<if test="formulaExpression != null">
formula_expression = #{formulaExpression,jdbcType=VARCHAR},
</if>
<if test="data != null">
`data` = #{data,jdbcType=VARCHAR},
</if>
<if test="dataSourceId != null">
data_source_id = #{dataSourceId,jdbcType=BIGINT},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlock">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update period_formula_block
set period = #{period,jdbcType=INTEGER},
report_id = #{reportId,jdbcType=BIGINT},
cell_template_id = #{cellTemplateId,jdbcType=BIGINT},
formula_expression = #{formulaExpression,jdbcType=VARCHAR},
`data` = #{data,jdbcType=VARCHAR},
data_source_id = #{dataSourceId,jdbcType=BIGINT},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectByExampleWithRowbounds" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlockExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from period_formula_block
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectByExampleWithRowbounds" parameterType="pwc.taxtech.atms.vat.entity.PeriodFormulaBlockExample"
resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List"/>
from period_formula_block
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<update id="updateReportId">
update period_formula_block
set report_id=#{reportId,jdbcType=BIGINT}
where period=#{period,jdbcType=INTEGER} and cell_template_id in
<foreach collection="cellTemplateConfigIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</update>
</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