Commit 3706ccc0 authored by frank.xa.zhang's avatar frank.xa.zhang

change to periodXXX table

parent 9022afd5
package pwc.taxtech.atms.controller; package pwc.taxtech.atms.controller;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -80,17 +81,29 @@ public class ReportController { ...@@ -80,17 +81,29 @@ public class ReportController {
} }
@RequestMapping(value = "getStdAccountByIndustry/{industryId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "getStdAccountByIndustry/{industryId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<List<VatEnterpriseAccount>> getStdAccountByIndustry(@PathVariable String industryId) { public OperationResultDto<List<VatEnterpriseAccount>> getStdAccountByIndustry(@PathVariable String industryId, @RequestHeader String from) {
return reportService.getStdAccountByIndustry(industryId); String projectId = StringUtils.EMPTY;
if (StringUtils.isNotBlank(from) && from.split("@").length > 0) {
projectId = from.split("@")[0];
}
return reportService.getStdAccountByIndustry(industryId, projectId);
} }
@RequestMapping(value = "getCellAccountRange/{reportTemplateId}/{period}/{rowIndex}/{columnIndex}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "getCellAccountRange/{reportTemplateId}/{period}/{rowIndex}/{columnIndex}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<List<VatEnterpriseAccountResultDto>> getCellAccountRange(@PathVariable Long reportTemplateId, @PathVariable Integer period, @PathVariable int rowIndex, @PathVariable int columnIndex) { public OperationResultDto<List<VatEnterpriseAccountResultDto>> getCellAccountRange(@PathVariable Long reportTemplateId, @PathVariable Integer period, @PathVariable int rowIndex, @PathVariable int columnIndex,@RequestHeader String from) {
return reportService.getCellAccountRange(reportTemplateId, period, rowIndex, columnIndex); String projectId = StringUtils.EMPTY;
if (StringUtils.isNotBlank(from) && from.split("@").length > 0) {
projectId = from.split("@")[0];
}
return reportService.getCellAccountRange(reportTemplateId, period, rowIndex, columnIndex,projectId);
} }
@RequestMapping(value = "addCellManualData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "addCellManualData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto addCellManualDataSource(@RequestBody ManualDataSourceDto data, @RequestHeader String from) { public OperationResultDto addCellManualDataSource(@RequestBody ManualDataSourceDto data, @RequestHeader String from) {
String projectId = StringUtils.EMPTY;
if (StringUtils.isNotBlank(from) && from.split("@").length > 0) {
projectId = from.split("@")[0];
}
return reportService.addCellManualDataSource(data, from); return reportService.addCellManualDataSource(data, from);
} }
......
...@@ -9,5 +9,5 @@ public interface ReportGenerator { ...@@ -9,5 +9,5 @@ public interface ReportGenerator {
String generateData(String projectId, List<Long> templateIds, Boolean ifDeleteManualDataSource, List<String> exceptCellTemplates, String generateData(String projectId, List<Long> templateIds, Boolean ifDeleteManualDataSource, List<String> exceptCellTemplates,
Integer periodParam, Optional<String> generator); Integer periodParam, Optional<String> generator);
List<CellCalcInfoDto> getCellCalcInfo(List<Long> templateIdList, Integer periodParam); List<CellCalcInfoDto> getCellCalcInfo(List<Long> templateIdList, Integer periodParam,String projectId);
} }
...@@ -30,9 +30,9 @@ public interface ReportService { ...@@ -30,9 +30,9 @@ public interface ReportService {
OperationResultDto<PeriodCellTemplateConfig> getCellTemplateConfig(Long reportTemplateId, Integer periodParam, int rowIndex, int columnIndex); OperationResultDto<PeriodCellTemplateConfig> getCellTemplateConfig(Long reportTemplateId, Integer periodParam, int rowIndex, int columnIndex);
OperationResultDto<List<VatEnterpriseAccount>> getStdAccountByIndustry(String industryId); OperationResultDto<List<VatEnterpriseAccount>> getStdAccountByIndustry(String industryId,String projectId);
OperationResultDto<List<VatEnterpriseAccountResultDto>> getCellAccountRange(Long reportTemplateId, Integer period, int rowIndex, int columnIndex); OperationResultDto<List<VatEnterpriseAccountResultDto>> getCellAccountRange(Long reportTemplateId, Integer period, int rowIndex, int columnIndex,String projectId);
/** /**
* 添加手工数据源方法接口 * 添加手工数据源方法接口
......
...@@ -398,6 +398,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -398,6 +398,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
cellData.setCreateTime(createTime); cellData.setCreateTime(createTime);
cellData.setUpdateBy("Admin"); cellData.setUpdateBy("Admin");
cellData.setUpdateTime(createTime); cellData.setUpdateTime(createTime);
cellData.setProjectId(projectId);
periodCellDataMapper.insertSelective(cellData); periodCellDataMapper.insertSelective(cellData);
//after insert celldata, insert the celldatasource for link celldata and datasource //after insert celldata, insert the celldatasource for link celldata and datasource
...@@ -501,7 +502,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -501,7 +502,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
workbook.addToolPack(udfToolpack); workbook.addToolPack(udfToolpack);
} }
public List<CellCalcInfoDto> getCellCalcInfo(List<Long> templateIdList, Integer periodParam) { public List<CellCalcInfoDto> getCellCalcInfo(List<Long> templateIdList, Integer periodParam,String projectId) {
//already finished by 20180711 //already finished by 20180711
int period = 0; int period = 0;
if (periodParam != null) { if (periodParam != null) {
...@@ -511,7 +512,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -511,7 +512,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
List<PeriodCellTemplateConfigExtendDto> periodCellTemplateConfigExtendDtos = List<PeriodCellTemplateConfigExtendDto> periodCellTemplateConfigExtendDtos =
periodCellTemplateConfigMapper.getPeriodCellTemplateConfigExtendDtos(templateIdList, period); periodCellTemplateConfigMapper.getPeriodCellTemplateConfigExtendDtos(templateIdList, period);
fixedPCTParsedFormula(periodCellTemplateConfigExtendDtos); fixedPCTParsedFormula(periodCellTemplateConfigExtendDtos,projectId);
List<CellCalcInfoDto> cellCalcInfoDtos = new ArrayList<>(); List<CellCalcInfoDto> cellCalcInfoDtos = new ArrayList<>();
periodCellTemplateConfigExtendDtos.stream().collect(Collectors.groupingBy(a -> periodCellTemplateConfigExtendDtos.stream().collect(Collectors.groupingBy(a ->
new CellTemplateConfigGroupDto(a.getColumnIndex(), a.getRowIndex() new CellTemplateConfigGroupDto(a.getColumnIndex(), a.getRowIndex()
...@@ -543,7 +544,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -543,7 +544,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
return cellCalcInfoDtos; return cellCalcInfoDtos;
} }
private void fixedPCTParsedFormula(List<PeriodCellTemplateConfigExtendDto> periodCellTemplateConfigExtendDtos) { private void fixedPCTParsedFormula(List<PeriodCellTemplateConfigExtendDto> periodCellTemplateConfigExtendDtos,String projectId) {
Map<String, List<PCTEntity>> formulaMapToPCT = new HashMap<>(); Map<String, List<PCTEntity>> formulaMapToPCT = new HashMap<>();
Map<PeriodCellTemplateConfig, List<String>> configMapToPCTs = new HashMap<>(); Map<PeriodCellTemplateConfig, List<String>> configMapToPCTs = new HashMap<>();
Set<PCTEntity> parameter = new HashSet<>(); Set<PCTEntity> parameter = new HashSet<>();
...@@ -590,7 +591,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen ...@@ -590,7 +591,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
}); });
if (!parameter.isEmpty()) { if (!parameter.isEmpty()) {
List<PCTEntity> pctResults = periodCellDataMapper.queryByPCTs(parameter); List<PCTEntity> pctResults = periodCellDataMapper.queryByPCTs(parameter,projectId);
Map<PCTEntity, BigDecimal> pctCache = new HashMap<>(); Map<PCTEntity, BigDecimal> pctCache = new HashMap<>();
pctResults.forEach(m -> { pctResults.forEach(m -> {
BigDecimal data = null; BigDecimal data = null;
......
...@@ -267,7 +267,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -267,7 +267,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
// periodCellTemplateConfig.setVoucherKeyword(cellTemplateConfig.getVoucherKeyword()); // periodCellTemplateConfig.setVoucherKeyword(cellTemplateConfig.getVoucherKeyword());
periodCellTemplateConfig.setCellTemplateConfigId(cellTemplateConfig.getId()); periodCellTemplateConfig.setCellTemplateConfigId(cellTemplateConfig.getId());
periodCellTemplateConfig.setKeyValueParsedFormula(StringUtils.EMPTY); periodCellTemplateConfig.setKeyValueParsedFormula(StringUtils.EMPTY);
periodCellTemplateConfig.setProjectId(projectId);
if (cellTemplateConfig.getFormula().contains("@")) { if (cellTemplateConfig.getFormula().contains("@")) {
String regex = "@[0-9A-Z.]+"; String regex = "@[0-9A-Z.]+";
Pattern pp = Pattern.compile(regex); Pattern pp = Pattern.compile(regex);
...@@ -438,7 +438,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -438,7 +438,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
List<Long> templateIds = new ArrayList<>(); List<Long> templateIds = new ArrayList<>();
templateIds.add(report.getTemplateId()); templateIds.add(report.getTemplateId());
List<CellCalcInfoDto> cellCfgList = reportGenerator.getCellCalcInfo(templateIds, report.getPeriod()); List<CellCalcInfoDto> cellCfgList = reportGenerator.getCellCalcInfo(templateIds, report.getPeriod(), project.getId());
PeriodCellDataExample cellDataExample = new PeriodCellDataExample(); PeriodCellDataExample cellDataExample = new PeriodCellDataExample();
cellDataExample.createCriteria().andReportIdEqualTo(reportId); cellDataExample.createCriteria().andReportIdEqualTo(reportId);
...@@ -663,11 +663,11 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -663,11 +663,11 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
} }
@Override @Override
public OperationResultDto<List<VatEnterpriseAccount>> getStdAccountByIndustry(String industryId) { public OperationResultDto<List<VatEnterpriseAccount>> getStdAccountByIndustry(String industryId, String projectId) {
OperationResultDto resultDto = new OperationResultDto(); OperationResultDto resultDto = new OperationResultDto();
try { try {
PeriodEnterpriseAccountExample example = new PeriodEnterpriseAccountExample(); PeriodEnterpriseAccountExample example = new PeriodEnterpriseAccountExample();
example.createCriteria().andIsActiveEqualTo(true); example.createCriteria().andIsActiveEqualTo(true).andProjectIdEqualTo(projectId);
periodEnterpriseAccountMapper.selectByExample(example); periodEnterpriseAccountMapper.selectByExample(example);
List<PeriodEnterpriseAccount> vatEnterpriseAccounts = periodEnterpriseAccountMapper.selectByExample(example); List<PeriodEnterpriseAccount> vatEnterpriseAccounts = periodEnterpriseAccountMapper.selectByExample(example);
if (vatEnterpriseAccounts == null) { if (vatEnterpriseAccounts == null) {
...@@ -687,7 +687,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -687,7 +687,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
} }
@Override @Override
public OperationResultDto<List<VatEnterpriseAccountResultDto>> getCellAccountRange(Long reportTemplateId, Integer periodParam, int rowIndex, int columnIndex) { public OperationResultDto<List<VatEnterpriseAccountResultDto>> getCellAccountRange(Long reportTemplateId, Integer periodParam, int rowIndex, int columnIndex, String projectId) {
OperationResultDto resultDto = new OperationResultDto(); OperationResultDto resultDto = new OperationResultDto();
try { try {
...@@ -701,7 +701,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -701,7 +701,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
} }
PeriodEnterpriseAccountExample example = new PeriodEnterpriseAccountExample(); PeriodEnterpriseAccountExample example = new PeriodEnterpriseAccountExample();
example.createCriteria().andAcctCodeIn(Arrays.asList(periodCellTemplateConfig.getAccountCodes().split(","))); example.createCriteria().andAcctCodeIn(Arrays.asList(periodCellTemplateConfig.getAccountCodes().split(","))).andProjectIdEqualTo(projectId);
List<PeriodEnterpriseAccount> vatEnterpriseAccounts = periodEnterpriseAccountMapper.selectByExample(example); List<PeriodEnterpriseAccount> vatEnterpriseAccounts = periodEnterpriseAccountMapper.selectByExample(example);
List<VatEnterpriseAccountResultDto> vatEnterpriseAccountResultDtos = new ArrayList<>(); List<VatEnterpriseAccountResultDto> vatEnterpriseAccountResultDtos = new ArrayList<>();
for (PeriodEnterpriseAccount vatEnterpriseAccount : vatEnterpriseAccounts) { for (PeriodEnterpriseAccount vatEnterpriseAccount : vatEnterpriseAccounts) {
...@@ -740,6 +740,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -740,6 +740,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
cellData.setCreateTime(new Date()); cellData.setCreateTime(new Date());
cellData.setUpdateBy("admin"); cellData.setUpdateBy("admin");
cellData.setUpdateTime(new Date()); cellData.setUpdateTime(new Date());
cellData.setProjectId(projectId);
periodCellDataMapper.insertSelective(cellData); periodCellDataMapper.insertSelective(cellData);
data.setCellId(cellData.getId()); data.setCellId(cellData.getId());
} else { } else {
...@@ -794,6 +795,8 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -794,6 +795,8 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
cellDataSource.setCellTemplateId(Long.parseLong(data.getCellTemplateId())); cellDataSource.setCellTemplateId(Long.parseLong(data.getCellTemplateId()));
cellDataSource.setCreateTime(new Date()); cellDataSource.setCreateTime(new Date());
cellDataSource.setUpdateTime(new Date()); cellDataSource.setUpdateTime(new Date());
cellDataSource.setProjectId(projectId);
cellDataSource.setPeriod(data.getPeriod());
updateCellValueForDataSourceChange(cellDataSource.getCellDataId(), new BigDecimal("0"), data.getAmount()); updateCellValueForDataSourceChange(cellDataSource.getCellDataId(), new BigDecimal("0"), data.getAmount());
periodDataSourceMapper.insertSelective(dataSourceModel); periodDataSourceMapper.insertSelective(dataSourceModel);
periodCellDataSourceMapper.insertSelective(cellDataSource); periodCellDataSourceMapper.insertSelective(cellDataSource);
...@@ -893,7 +896,8 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -893,7 +896,8 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
cellDataSource.setDataSourceId(dataSource.getId()); cellDataSource.setDataSourceId(dataSource.getId());
cellDataSource.setCreateTime(new Date()); cellDataSource.setCreateTime(new Date());
cellDataSource.setUpdateTime(new Date()); cellDataSource.setUpdateTime(new Date());
cellDataSource.setPeriod(dataSource.getPeriod());
cellDataSource.setProjectId(dataSource.getProjectId());
periodCellDataSourceMapper.insertSelective(cellDataSource); periodCellDataSourceMapper.insertSelective(cellDataSource);
operationResultDto.setData(dataSource.getId().toString()); operationResultDto.setData(dataSource.getId().toString());
......
...@@ -21,6 +21,7 @@ public class VatAbstractService { ...@@ -21,6 +21,7 @@ public class VatAbstractService {
public VatEnterpriseAccountMapper vatEnterpriseAccountMapper; public VatEnterpriseAccountMapper vatEnterpriseAccountMapper;
@Autowired @Autowired
public PeriodStandardAccountMapper periodStandardAccountMapper; public PeriodStandardAccountMapper periodStandardAccountMapper;
@Autowired
public PeriodEnterpriseAccountMapper periodEnterpriseAccountMapper; public PeriodEnterpriseAccountMapper periodEnterpriseAccountMapper;
@Autowired @Autowired
public InputVatInvoiceMapper inputVATInvoiceMapper; public InputVatInvoiceMapper inputVATInvoiceMapper;
......
...@@ -92,7 +92,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction { ...@@ -92,7 +92,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
if (balanceStdManual != null) { if (balanceStdManual != null) {
List<VatEnterpriseAccount> vatEnterpriseAccountList = SpringContextUtil List<VatEnterpriseAccount> vatEnterpriseAccountList = SpringContextUtil
.periodEnterpriseAccountMapper .periodEnterpriseAccountMapper
.getListWithAccountCode(accountCode); .getListWithAccountCode(accountCode,formulaContext.getProjectId(),period);
if (period == 99) { if (period == 99) {
val = new BigDecimal(((balanceStdManual.getYearDebitNet() != null ? balanceStdManual.getYearDebitNet() : 0).doubleValue() val = new BigDecimal(((balanceStdManual.getYearDebitNet() != null ? balanceStdManual.getYearDebitNet() : 0).doubleValue()
- (balanceStdManual.getYearCreditNet() != null ? balanceStdManual.getYearCreditNet() : 0).doubleValue()) - (balanceStdManual.getYearCreditNet() != null ? balanceStdManual.getYearCreditNet() : 0).doubleValue())
......
...@@ -118,11 +118,12 @@ public interface PeriodCellDataMapper extends MyVatMapper { ...@@ -118,11 +118,12 @@ public interface PeriodCellDataMapper extends MyVatMapper {
" PERIOD_REPORT R " + " PERIOD_REPORT R " +
"WHERE " + "WHERE " +
" C.REPORT_ID = R.ID AND " + " C.REPORT_ID = R.ID AND " +
" and C.PROJECT_ID = #{projectId} " +
" " + " " +
" <foreach item=\"item\" index=\"index\" collection=\"list\"" + " <foreach item=\"item\" index=\"index\" collection=\"list\"" +
" open=\"(\" separator=\"OR\" close=\")\">" + " open=\"(\" separator=\"OR\" close=\")\">" +
" ( R.PERIOD=#{item.period} AND C.CELL_TEMPLATE_ID=#{item.cellTemplateId} )" + " ( R.PERIOD=#{item.period} AND C.CELL_TEMPLATE_ID=#{item.cellTemplateId} )" +
" </foreach>" + " </foreach>" +
"</script>") "</script>")
List<PCTEntity> queryByPCTs(@Param("list") Set<PCTEntity> parameter); List<PCTEntity> queryByPCTs(@Param("list") Set<PCTEntity> parameter,@Param("projectId") String projectId);
} }
\ No newline at end of file
...@@ -107,6 +107,6 @@ public interface PeriodEnterpriseAccountMapper extends MyVatMapper { ...@@ -107,6 +107,6 @@ public interface PeriodEnterpriseAccountMapper extends MyVatMapper {
*/ */
int updateByPrimaryKey(PeriodEnterpriseAccount record); int updateByPrimaryKey(PeriodEnterpriseAccount record);
List<VatEnterpriseAccount> getListWithAccountCode(@Param("accountCode") String accountCode); List<VatEnterpriseAccount> getListWithAccountCode(@Param("accountCode") String accountCode,@Param("projectId") String projectId,@Param("period") int period);
} }
\ No newline at end of file
...@@ -523,4 +523,7 @@ ...@@ -523,4 +523,7 @@
order by ${orderByClause} order by ${orderByClause}
</if> </if>
</select> </select>
<select id="getListWithAccountCode" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT * FROM EnterpriseAccount WHERE StdCode IS NOT NULL AND StdCode LIKE '${accountCode}%' AND IsLeaf=1
</select>
</mapper> </mapper>
\ No newline at end of file
<?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.PeriodEnterpriseAccountMapper">
<select id="getListWithAccountCode" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT * FROM PERIOD_ENTERPRISE_ACCOUNT WHERE STD_CODE IS NOT NULL AND STD_CODE LIKE '${accountCode}%'
AND IS_LEAF=1 AND PROJECT_ID=#{projectId,jdbcType=VARCHAR} and PERIOD=#{period,jdbcType=INTEGER}
</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