Commit 2704734c authored by neo's avatar neo

[DEV] fixed bb when cacls add manual

parent d9177a0e
......@@ -13,11 +13,9 @@ import pwc.taxtech.atms.entity.ProjectServiceTypeExample;
import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.vat.dao.CellDataMapper;
import pwc.taxtech.atms.vat.dao.PeriodCellDataMapper;
import pwc.taxtech.atms.vat.dao.PeriodDataSourceMapper;
import pwc.taxtech.atms.vat.dao.PeriodReportMapper;
import pwc.taxtech.atms.vat.entity.PeriodCellData;
import pwc.taxtech.atms.vat.entity.PeriodCellDataExample;
import pwc.taxtech.atms.vat.entity.PeriodReport;
import pwc.taxtech.atms.vat.entity.PeriodReportExample;
import pwc.taxtech.atms.vat.entity.*;
import java.util.List;
......@@ -35,6 +33,8 @@ public class FormulaAgent {
private PeriodCellDataMapper periodCellDataMapper;
@Autowired
private ProjectServiceTypeMapper projectServiceTypeMapper;
@Autowired
private PeriodDataSourceMapper periodDataSourceMapper;
public List<CellTemplatePerGroupDto> getCellTemplateGroupDto(Long templateGroupId, String projectId) {
ProjectServiceTypeExample pst = new ProjectServiceTypeExample();
......@@ -56,6 +56,14 @@ public class FormulaAgent {
return cellTemplates;
}
public List<PeriodDataSource> queryManualDataSource(Long templateId, String projectId,Integer period){
PeriodDataSourceExample example = new PeriodDataSourceExample();
example.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period)
.andCellTemplateIdEqualTo(templateId).andTypeEqualTo(10);
return periodDataSourceMapper.selectByExample(example);
}
private PeriodReport getReportByTemplate(String templateId, Integer periodId, String projectId) {
PeriodReportExample example = new PeriodReportExample();
example.createCriteria().andProjectIdEqualTo(projectId).andTemplateIdEqualTo(Long.valueOf(templateId))
......
......@@ -95,7 +95,7 @@ public class ReportGeneratorImpl {
String code = sheet.getSheetName();
logger.info("-------------------------------------Begin Job [{}]------------------------------------------------------", code);
setStatus(job, STATUS_END);
setStatus(job,code,STATUS_BEGIN);
setStatus(job, code, STATUS_BEGIN);
job.setCurrentStep(code);
periodJobMapper.updateByPrimaryKey(job);
......@@ -177,104 +177,86 @@ public class ReportGeneratorImpl {
periodCellTemplateConfigMapper.updateByPrimaryKeySelective(periodCellTemplateConfig);
}
String regexNormalCell = "[A-Z]{1,2}((?!0)[0-9]{1,3})";
p = Pattern.compile(regexNormalCell);
m = p.matcher(sourceFormula);
while (m.find()) {
//如果找到普通单元格的公式,就去workbook里查找对应的格子取数据,然后放到DataSource,作为普通单元格数据源的数据
//找到一个格子就加一条数据
String findStr = m.group();//A12,A13,A15,how to get A and 12 or A and 13
String regexColumn = "[A-Z]{1,2}";
Pattern pp = Pattern.compile(regexColumn);
Matcher mm = pp.matcher(findStr);
while (mm.find()) {
String colStr = mm.group();
int colNum = FormulaHelper.excelColStrToNum(colStr, colStr.length());
int rowNum = Integer.parseInt(StringUtils.removeStart(findStr, colStr));
Row row = sheet.getRow(rowNum - 1);
if (row != null) {
Cell cell = row.getCell(colNum - 1);
if (cell != null) {
//开始取值然后存放到DataSource
PeriodDataSource dataSource = new PeriodDataSource();
dataSource.setId(distributedIdService.nextId());
dataSource.setColumnIndex(colNum - 1);
dataSource.setRowIndex(rowNum - 1);
if (((XSSFCell) cell).getRawValue() != "#VALUE!") {
// if(StringUtils.isNotBlank(cell.getStringCellValue())
// && StringUtils.isNumeric(cell.getStringCellValue().replace(".", ""))){
// dataSource.setAmount(new BigDecimal(cell.getStringCellValue()));
// }
// else if(StringUtils.isBlank(cell.getStringCellValue())){
// dataSource.setAmount(new BigDecimal(Double.toString(cell.getNumericCellValue())));
// }
//// else {
//// cell.setCellFormula(cell.getStringCellValue());
//// FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook);
//// dataSource.setAmount(new BigDecimal(formulaEvaluator.evaluate(cell).getNumberValue()));
//// }
dataSource.setAmount(new BigDecimal(
((XSSFCell) cell).getRawValue() != null ?
((XSSFCell) cell).getRawValue()
: (StringUtils.isNotBlank(cell.getStringCellValue())) ?
cell.getStringCellValue()
: Double.toString(cell.getNumericCellValue())));
} else {
dataSource.setAmount(new BigDecimal("0.0"));
}
dataSource.setName("ReportDataSource");
dataSource.setDescription(findStr);
dataSource.setCreateTime(new Date());
dataSource.setUpdateTime(new Date());
dataSource.setCreateBy("Admin");
dataSource.setUpdateBy("Admin");
dataSource.setPeriod(period);
dataSource.setCellTemplateId(periodCellTemplateConfig.getCellTemplateId());
dataSource.setType(FormulaDataSourceType.Report.getCode());
dataSource.setProjectId(projectId);
periodDataSourceMapper.insertSelective(dataSource);
//这里有个问题就是DataSource的数据有了,但是celldatasource的数据没有,后面无法关联celldata和DataSource
//解决办法就是 在存DataSource的时候就先把celldata的数据加好
//然后把celldatasource的数据也加好
//然后在外面去更新celldata和celldatasource的数据
//还有就是把公式里的数据源放到内存,在所有算完之后再统一加数据源
String regexNormalCell = "[A-Z]{1,2}((?!0)[0-9]{1,3})";
p = Pattern.compile(regexNormalCell);
m = p.matcher(sourceFormula);
while (m.find()) {
//如果找到普通单元格的公式,就去workbook里查找对应的格子取数据,然后放到DataSource,作为普通单元格数据源的数据
//找到一个格子就加一条数据
String findStr = m.group();//A12,A13,A15,how to get A and 12 or A and 13
String regexColumn = "[A-Z]{1,2}";
Pattern pp = Pattern.compile(regexColumn);
Matcher mm = pp.matcher(findStr);
while (mm.find()) {
String colStr = mm.group();
int colNum = FormulaHelper.excelColStrToNum(colStr, colStr.length());
int rowNum = Integer.parseInt(StringUtils.removeStart(findStr, colStr));
Row row = sheet.getRow(rowNum - 1);
if (row != null) {
Cell cell = row.getCell(colNum - 1);
if (cell != null) {
//开始取值然后存放到DataSource
PeriodDataSource dataSource = new PeriodDataSource();
dataSource.setId(distributedIdService.nextId());
dataSource.setColumnIndex(colNum - 1);
dataSource.setRowIndex(rowNum - 1);
if (((XSSFCell) cell).getRawValue() != "#VALUE!") {
dataSource.setAmount(new BigDecimal(
((XSSFCell) cell).getRawValue() != null ?
((XSSFCell) cell).getRawValue()
: (StringUtils.isNotBlank(cell.getStringCellValue())) ?
cell.getStringCellValue()
: Double.toString(cell.getNumericCellValue())));
} else {
dataSource.setAmount(new BigDecimal("0.0"));
}
dataSource.setName("ReportDataSource");
dataSource.setDescription(findStr);
dataSource.setCreateTime(new Date());
dataSource.setUpdateTime(new Date());
dataSource.setCreateBy("Admin");
dataSource.setUpdateBy("Admin");
dataSource.setPeriod(period);
dataSource.setCellTemplateId(periodCellTemplateConfig.getCellTemplateId());
dataSource.setType(FormulaDataSourceType.Report.getCode());
dataSource.setProjectId(projectId);
periodDataSourceMapper.insertSelective(dataSource);
//这里有个问题就是DataSource的数据有了,但是celldatasource的数据没有,后面无法关联celldata和DataSource
//解决办法就是 在存DataSource的时候就先把celldata的数据加好
//然后把celldatasource的数据也加好
//然后在外面去更新celldata和celldatasource的数据
//还有就是把公式里的数据源放到内存,在所有算完之后再统一加数据源
}
}
}
}
Optional<PeriodCellTemplate> tempPeriodCellTemplate = resources.getPeriodCellTemplates().stream()
.filter(a -> a.getCellTemplateId().equals(periodCellTemplateConfig.getCellTemplateId()))
.findFirst();
if (tempPeriodCellTemplate.isPresent()) {
PeriodCellData cellData = new PeriodCellData();
Long cellDataId = distributedIdService.nextId();
cellData.setId(cellDataId);
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) {
Cell cell = sheet.getRow(tempPeriodCellTemplate.get().getRowIndex())
.getCell(tempPeriodCellTemplate.get().getColumnIndex());
data = ((XSSFCell) cell).getRawValue();
if (data != null && data.equals("#VALUE!")) {
FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook);
try{
data = formulaEvaluator.evaluate(cell).getStringValue();
}catch (Exception e){
logger.error(e.getStackTrace().toString());
data = "0.0";
}
Optional<PeriodCellTemplate> tempPeriodCellTemplate = resources.getPeriodCellTemplates().stream()
.filter(a -> a.getCellTemplateId().equals(periodCellTemplateConfig.getCellTemplateId()))
.findFirst();
if (tempPeriodCellTemplate.isPresent()) {
PeriodCellData cellData = new PeriodCellData();
Long cellDataId = distributedIdService.nextId();
cellData.setId(cellDataId);
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) {
Cell cell = sheet.getRow(tempPeriodCellTemplate.get().getRowIndex())
.getCell(tempPeriodCellTemplate.get().getColumnIndex());
data = ((XSSFCell) cell).getRawValue();
if (data != null && data.equals("#VALUE!")) {
FormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator((XSSFWorkbook) workbook);
try {
data = formulaEvaluator.evaluate(cell).getStringValue();
} catch (Exception e) {
logger.error(e.getStackTrace().toString());
data = "0.0";
}
//evaluator.evaluate(cell);
// if (cell.getCellTypeEnum().equals(CellType.NUMERIC)||cell.getCellTypeEnum().equals(CellType.FORMULA)) {
// data = Double.toString(cell.getNumericCellValue());
// } else {
// data = cell.getStringCellValue();
// }
}
} else {
data = "0.0";
}
......@@ -291,19 +273,11 @@ public class ReportGeneratorImpl {
cellData.setData(data);
}
//cellData.setData(new BigDecimal(data).toString());
// PeriodFormulaBlockExample periodFormulaBlockExample = new PeriodFormulaBlockExample();
// periodFormulaBlockExample.createCriteria().andPeriodEqualTo(period)
// .andCellTemplateIdEqualTo(tempPeriodCellTemplate.get().getCellTemplateId());
if (StringUtils.isBlank(resultFormula)) {
resultFormula = null;
}
// if (isFind) {
cellData.setFormulaExp(resultFormula);
// } else {
// cellData.setFormulaExp(EMPTY);
// }
cellData.setCreateBy("Admin");
cellData.setCreateTime(new Date());
cellData.setUpdateBy("Admin");
......@@ -355,9 +329,10 @@ public class ReportGeneratorImpl {
if (cellDataList.size() == 1) {
PeriodCellData cellData = cellDataList.get(0);
PeriodDataSource dataSource = dataSourceList.get(0);
cellData.setData(dataSource.getAmount() + "");
if (StringUtils.isEmpty(cellData.getData().trim()))
cellData.setData("0.0");
if (StringUtils.isEmpty(cellData.getFormulaExp().trim()))
cellData.setFormulaExp(dataSource.getAmount() + "");
cellData.setFormulaExp("0.0");
PeriodCellDataSource cellDataSource = new PeriodCellDataSource();
cellDataSource.setId(distributedIdService.nextId());
......@@ -384,8 +359,8 @@ public class ReportGeneratorImpl {
cellData.setPeriod(period);
PeriodDataSource dataSource = dataSourceList.get(0);
cellData.setData(dataSource.getAmount() + "");
cellData.setFormulaExp(dataSource.getAmount() + "");
cellData.setData("0.0");
cellData.setFormulaExp("0.0");
PeriodCellDataSource cellDataSource = new PeriodCellDataSource();
cellDataSource.setId(distributedIdService.nextId());
......@@ -616,7 +591,6 @@ public class ReportGeneratorImpl {
List<PeriodCellTemplateConfigExtendDto> periodCellTemplateConfigExtendDtos =
periodCellTemplateConfigMapper.getPeriodCellTemplateConfigExtendDtos(templateIdList, period, projectId);
fixedPCTParsedFormula(periodCellTemplateConfigExtendDtos, projectId, period);
List<CellCalcInfoDto> cellCalcInfoDtos = new ArrayList<>();
Map<String, List<PeriodCellTemplateConfigExtendDto>> myStream = new HashMap<>();
for (PeriodCellTemplateConfigExtendDto pctce : periodCellTemplateConfigExtendDtos) {
......@@ -649,84 +623,6 @@ public class ReportGeneratorImpl {
return cellCalcInfoDtos;
}
private void fixedPCTParsedFormula
(List<PeriodCellTemplateConfigExtendDto> periodCellTemplateConfigExtendDtos, String projectId, int period) {
Map<String, List<PCTEntity>> formulaMapToPCT = new HashMap<>();
Map<PeriodCellTemplateConfig, List<String>> configMapToPCTs = new HashMap<>();
Set<PCTEntity> parameter = new HashSet<>();
periodCellTemplateConfigExtendDtos.forEach(p -> {
String formula = p.getFormula();
String parsedFormula = p.getParsedFormula();
if (formula.contains("BB(")) {
logger.debug("period cell template config contains bb formula {}", formula);
if (parsedFormula.contains("PCT(")) {
List<String> parsedPCTs = new ArrayList<>();
byte[] parsedFormulaBytes = parsedFormula.getBytes();
Integer begin = null;
for (int i = 0; i < parsedFormulaBytes.length; i++) {
if (i < parsedFormulaBytes.length - 3 && parsedFormulaBytes[i] == 'P' && parsedFormulaBytes[i + 1] == 'C'
&& parsedFormulaBytes[i + 2] == 'T' && parsedFormulaBytes[i + 3] == '(') {
begin = i;
} else if (parsedFormulaBytes[i] == ')' && begin != null) {
parsedPCTs.add(new String(Arrays.copyOfRange(parsedFormulaBytes, begin, i + 1)));
begin = null;
}
}
if (!parsedPCTs.isEmpty()) {
configMapToPCTs.put(p, parsedPCTs);
}
parsedPCTs.stream().forEach(m -> {
String periodCPT = m.substring(m.indexOf("(") + 1, m.indexOf(")"));
if (periodCPT.contains(",")) {
formulaMapToPCT.put(m, Arrays.asList(periodCPT.split(",")).stream().map(n -> new PCTEntity(n))
.collect(Collectors.toList()));
} else {
formulaMapToPCT.put(m, Lists.newArrayList(new PCTEntity(periodCPT)));
}
parameter.addAll(formulaMapToPCT.get(m));
});
} else {
logger.warn("bb formula parsedformula must contains PCT but not found {}", parsedFormula);
}
}
});
if (!parameter.isEmpty()) {
List<PCTEntity> pctResults = periodCellDataMapper.queryByPCTs(parameter, projectId);
Map<PCTEntity, PCTEntity> pctCache = new HashMap<>();
pctResults.forEach(m -> {
pctCache.put(m, m);
});
configMapToPCTs.forEach((k, v) -> {
v.forEach(pctStr -> {
List<PCTEntity> entities = formulaMapToPCT.get(pctStr);
StringBuilder result = new StringBuilder("0");
for (PCTEntity entity : entities) {
if (pctCache.containsKey(entity)) {
PCTEntity pct = pctCache.get(entity);
if (pct.getDsCount() == 1 && pct.getAmount() != null) {
result.append("+").append(pct.getAmount());
} else if (pct.getDsCount() > 1 && pct.getAmount() != null && !StringUtils.isEmpty(pct.getFormulaExp().trim())) {
result.append("+").append(pct.getFormulaExp()).append("+").append(pct.getAmount());
} else if (pct.getAmount() == null && !StringUtils.isNotEmpty(pct.getData())) {
result.append(pct.getData());
}
}
}
k.setParsedFormula(k.getParsedFormula().replace(pctStr, result.toString()));
});
});
}
}
private String convertListToString(List<String> list) {
StringBuilder stringBuilder = new StringBuilder();
list.forEach(s -> {
......
......@@ -15,6 +15,7 @@ import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto;
import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.exception.FormulaException;
import pwc.taxtech.atms.vat.entity.PeriodCellData;
import pwc.taxtech.atms.vat.entity.PeriodDataSource;
import java.lang.reflect.Field;
import java.math.BigDecimal;
......@@ -94,24 +95,30 @@ public class BB extends FunctionBase implements FreeRefFunction {
WorkbookEvaluator evaluator = (WorkbookEvaluator) evaluatorField.get(ec);
int index = ec.getWorkbook().getSheetIndex(bo.getReportCode());
if (index < 0) logger.warn("not found sheet code {}", bo.getReportCode());
if (index < 0)
logger.warn("[BB_Exception] not found sheet code {} with {}", bo.getReportCode(), bo.toString());
ValueEval eval = evaluator.evaluate(ec.getWorkbook().getSheet(index)
.getCell(bo.getRowIndex() - 1, bo.getColumnIndex() - 1));
bo.putPeriodCellTempate(formulaContext.getPeriod(), Long.parseLong(cellTemplateData.getCellTemplateId()));
if (eval instanceof ErrorEval) {
LOGGER.warn("error eval for bb {} and error code {} and error String {}", bo.toString(),
LOGGER.warn("[BB_Exception] error eval for bb {} and error code {} and error String {}", bo.toString(),
((ErrorEval) eval).getErrorCode(), ((ErrorEval) eval).getErrorString());
}
cellValue = new BigDecimal(OperandResolver.coerceValueToDouble(eval));
nullCellDto.extractFromGroup(bo, formulaContext.getPeriod(), formulaContext.getYear(), cellTemplateData);
List<PeriodDataSource> dss = agent.queryManualDataSource(Long.parseLong(cellTemplateData.getCellTemplateId()),
formulaContext.getProjectId(), bo.getPeriod());
if (dss.isEmpty()) {
cellValue = cellValue.add(dss.get(0).getAmount());
}
nullCellDto.setAmount(cellValue);
return cellValue;
}
// bo.disCount();
PeriodCellData cellData = null;
String projectId = agent.getPastProjectId(curPeriod.getCurYear(),
......@@ -120,15 +127,19 @@ public class BB extends FunctionBase implements FreeRefFunction {
MyAsserts.assertNotEmpty(projectId, Exceptions.PROJECT_EMPTY);
cellData = agent.getCellData(cellTemplateData.getReportTemplateId(),
cellTemplateData.getCellTemplateId(), curPeriod.getCurPeriod(), formulaContext.getProjectId());
List<PeriodDataSource> dss = agent.queryManualDataSource(Long.parseLong(cellTemplateData.getCellTemplateId()),
formulaContext.getProjectId(), formulaContext.getPeriod());
nullCellDto.extractFromGroup(bo, curPeriod, cellData, cellTemplateData);
// todo: fix datasource name by templateList(neo)
MyAsserts.assertNotNull(cellData.getData(), Exceptions.BB_CELL_DATA_NULL);
if (dss.isEmpty())
MyAsserts.assertNotNull(cellData.getData(), Exceptions.BB_CELL_DATA_NULL);
else cellValue = dss.get(0).getAmount();
// cellValue= RoundValue(cellValue, cellDataType)TODO:maybe fixd round by cellDataTyep(KV neo)
cellValue = new BigDecimal(cellData.getData()).setScale(4,
BigDecimal.ROUND_HALF_DOWN);
if (cellData.getData()!=null) {
cellValue = cellValue.add( new BigDecimal(cellData.getData()).setScale(4,
BigDecimal.ROUND_HALF_DOWN));
}
nullCellDto.setAmount(cellValue);
if (rootBo != null) {
rootBo.putPeriodCellTempate(curPeriod.getCurPeriod(), Long.parseLong(cellTemplateData.getCellTemplateId()));
......@@ -138,9 +149,12 @@ public class BB extends FunctionBase implements FreeRefFunction {
LOGGER.debug("cell static value ");
return cellValue;
} catch (Exception e) {
logger.warn("[BB_Exception] some error {}", bo.toString());
throw e;
} finally {
if (rootBo == null) {
LOGGER.warn("error for bb cacls for {} and current for {}", bo.toString(), curPeriod.toString());
LOGGER.warn("[BB_Exception] error for bb cacls for {} and current for {}", bo.toString(), curPeriod.toString());
Long dataSourceId = saveDataSource(ec, dataSource, FormulaDataSourceDetailType.ReportCellDataSourceDto,
cellValue, formulaContext.getPeriod(),
formulaContext.getReportTemplateGroupId(), bo.getColumnIndex() - 1, bo.getRowIndex() - 1,
......
......@@ -2,15 +2,12 @@ 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 org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.entity.CellData;
import pwc.taxtech.atms.vat.entity.CellDataExample;
import pwc.taxtech.atms.vat.entity.PCTEntity;
import java.util.List;
import java.util.Set;
@Mapper
public interface CellDataMapper extends MyVatMapper {
......@@ -110,19 +107,4 @@ public interface CellDataMapper extends MyVatMapper {
*/
int updateByPrimaryKey(CellData record);
@Select("<script>" +
"SELECT " +
" R.PERIOD, C.CELL_TEMPLATE_ID AS CELLTEMPLATEID, DATA " +
"FROM " +
" CELL_DATA C, " +
" REPORT R " +
"WHERE " +
" C.REPORT_ID = R.ID AND " +
" " +
" <foreach item=\"item\" index=\"index\" collection=\"list\"" +
" open=\"(\" separator=\"OR\" close=\")\">" +
" ( R.PERIOD=#{item.period} AND C.CELL_TEMPLATE_ID=#{item.cellTemplateId} )" +
" </foreach>" +
"</script>")
List<PCTEntity> queryByPCTs(@Param("list") Set<PCTEntity> parameter);
}
\ No newline at end of file
......@@ -2,16 +2,12 @@ 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 org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyVatMapper;
import pwc.taxtech.atms.vat.dpo.MergerManaualCellData;
import pwc.taxtech.atms.vat.entity.PCTEntity;
import pwc.taxtech.atms.vat.entity.PeriodCellData;
import pwc.taxtech.atms.vat.entity.PeriodCellDataExample;
import java.util.List;
import java.util.Set;
@Mapper
public interface PeriodCellDataMapper extends MyVatMapper {
......@@ -111,51 +107,5 @@ public interface PeriodCellDataMapper extends MyVatMapper {
*/
int updateByPrimaryKey(PeriodCellData record);
int batchInsert2(List<PeriodCellData> list);
int batchInsert(List<PeriodCellData> list);
@Select("<script>" +
"SELECT " +
" count( pcds.DATA_SOURCE_ID ) AS dsCount, " +
" pcd.ID as cellId, " +
" pcd.DATA as data, " +
" pcd.FORMULA_EXP as formulaExp, " +
" pcd.CELL_TEMPLATE_ID as cellTemplateId, " +
" pcd.PERIOD as period, " +
" temp.AMOUNT as amount " +
"FROM " +
" PERIOD_CELL_DATA pcd " +
" JOIN PERIOD_CELL_DATA_SOURCE pcds ON pcd.ID = pcds.CELL_DATA_ID " +
" LEFT JOIN ( " +
" SELECT " +
" pcd.ID, " +
" pds.TYPE, " +
" pds.AMOUNT, " +
" pds.PERIOD, " +
" pds.PROJECT_ID " +
" FROM " +
" PERIOD_CELL_DATA pcd " +
" JOIN PERIOD_CELL_DATA_SOURCE pcds ON pcd.ID = pcds.CELL_DATA_ID " +
" JOIN PERIOD_DATA_SOURCE pds ON pcds.DATA_SOURCE_ID = pds.ID " +
" WHERE " +
" pcd.PROJECT_ID = #{projectId} " +
" AND pds.TYPE = 10 " +
" ) temp ON pcd.ID = temp.ID AND pcd.PROJECT_ID = temp.PROJECT_ID and pcd.PERIOD = temp.period " +
"WHERE " +
" pcd.PERIOD = 10 " +
" AND pcd.PROJECT_ID = #{projectId} AND " +
" <foreach item=\"item\" index=\"index\" collection=\"list\"" +
" open=\"(\" separator=\"OR\" close=\")\">" +
" ( pcd.PERIOD=#{item.period} AND pcd.CELL_TEMPLATE_ID=#{item.cellTemplateId} )" +
" </foreach>" +
"GROUP BY " +
" pcd.ID, " +
" pcd.DATA, " +
" pcd.FORMULA_EXP, " +
" pcd.CELL_TEMPLATE_ID, " +
" pcd.PERIOD, " +
" temp.AMOUNT" +
"</script>")
List<PCTEntity> queryByPCTs(@Param("list") Set<PCTEntity> parameter, @Param("projectId") String projectId);
}
\ No newline at end of file
package pwc.taxtech.atms.vat.entity;
public class PCTEntity {
Integer period;
Long cellTemplateId;
String data;
String formulaExp;
Long cellId;
String amount;
Integer dsCount;
public PCTEntity() {
}
public PCTEntity(String pctStr) {
String[] pct = pctStr.split(":");
this.period = Integer.parseInt(pct[0]);
this.cellTemplateId = Long.parseLong(pct[1]);
}
@Override
public int hashCode() {
return (period + "" + cellTemplateId).hashCode();
}
@Override
public boolean equals(Object obj) {
PCTEntity target = (PCTEntity) obj;
return period.intValue() == target.period.intValue()
&& cellTemplateId.longValue() == target.cellTemplateId.longValue();
}
public Integer getPeriod() {
return period;
}
public void setPeriod(Integer period) {
this.period = period;
}
public Long getCellTemplateId() {
return cellTemplateId;
}
public void setCellTemplateId(Long cellTemplateId) {
this.cellTemplateId = cellTemplateId;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getFormulaExp() {
return formulaExp;
}
public void setFormulaExp(String formulaExp) {
this.formulaExp = formulaExp;
}
public Long getCellId() {
return cellId;
}
public void setCellId(Long cellId) {
this.cellId = cellId;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public Integer getDsCount() {
return dsCount;
}
public void setDsCount(Integer dsCount) {
this.dsCount = dsCount;
}
}
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