Commit 603470db authored by neo's avatar neo

[DEV] use component instead of service to fixed db switch bug

parent 56496b35
package pwc.taxtech.atms.vat.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.common.util.MyAsserts;
......@@ -27,7 +28,7 @@ import java.util.List;
import static pwc.taxtech.atms.constant.Constant.FIRST_OR_DEFAULT;
@Service
@Component
public class FormulaAgent extends VatAbstractService {
@Autowired
public FormulaAdminMapper adminMp;
......@@ -105,14 +106,14 @@ public class FormulaAgent extends VatAbstractService {
return adminMp.getPastProjectDbName(year, orgId);
}
public CellData getCellData(String dbName, String templateId, int periodId) {
public CellData getCellData(String dbName, String templateId,String cellId, int periodId) {
String currentProjectDb = ShardingContextHolder.getDataSourceKey();
try {
ShardingContextHolder.setDataSourceKey(dbName);
Report report = getReportByTemplate(templateId, periodId);
MyAsserts.assertNotNull(report, Exceptions.BB_REPORT_NULL);
CellData cellData = getCellDataListByTemplate(templateId, report.getId());
CellData cellData = getCellDataListByTemplate(cellId, report.getId());
MyAsserts.assertNotNull(cellData, Exceptions.BB_CELL_DATA_NULL);
return cellData;
......
......@@ -16,6 +16,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.constant.enums.CellDataSourceType;
......@@ -41,7 +42,7 @@ import java.util.stream.Collectors;
import static pwc.taxtech.atms.constant.Constant.EMPTY;
@Service
@Component
public class ReportGeneratorImpl extends VatAbstractService implements ReportGenerator {
private static final Logger logger = LoggerFactory.getLogger(ReportGeneratorImpl.class);
......
package pwc.taxtech.atms.vat.service.impl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.constant.enums.EnumServiceType;
......@@ -15,7 +16,7 @@ import pwc.taxtech.atms.vat.service.ReportService;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Component
public class ReportServiceImpl extends VatAbstractService implements ReportService {
@Override
public OperationResultDto<List<ReportDto>> getReportTemplate(String projectID, EnumServiceType serviceType, Integer periodParam) {
......
......@@ -75,7 +75,8 @@ public class BB extends FunctionBase implements FreeRefFunction {
bo.disCount();
String dbName = agent.getPastProjectDbName(curPeriod.getCurYear(),
formulaContext.getOrganizationID());
CellData cellData = agent.getCellData(dbName, cellTemplateData.getReportTemplateID(), curPeriod.getCurPeriod());
CellData cellData = agent.getCellData(dbName, cellTemplateData.getReportTemplateID(),
cellTemplateData.getCellTemplateID(), curPeriod.getCurPeriod());
nullCellDto = ReportCellDataSourceDto.extractFromGroup(bo, curPeriod, cellData, cellTemplateData);
closeDataSource.clean();
closeDataSource.addDS(nullCellDto);
......
......@@ -21,7 +21,7 @@ import java.util.List;
public class FunctionBase {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
public static final BigDecimal[] defaultTaxRates = {new BigDecimal("0.17"), new BigDecimal("0.13")
, new BigDecimal("0.11"), new BigDecimal("0.06"), new BigDecimal(" 0.05"), new BigDecimal("0.03")};
, new BigDecimal("0.11"), new BigDecimal("0.06"), new BigDecimal("0.05"), new BigDecimal("0.03")};
protected FormulaContext formulaContext;
final FormulaAgent agent;
......
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