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

change to periodXXX table

parent 9022afd5
package pwc.taxtech.atms.controller;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -80,17 +81,29 @@ public class ReportController {
}
@RequestMapping(value = "getStdAccountByIndustry/{industryId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<List<VatEnterpriseAccount>> getStdAccountByIndustry(@PathVariable String industryId) {
return reportService.getStdAccountByIndustry(industryId);
public OperationResultDto<List<VatEnterpriseAccount>> getStdAccountByIndustry(@PathVariable String industryId, @RequestHeader String from) {
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)
public OperationResultDto<List<VatEnterpriseAccountResultDto>> getCellAccountRange(@PathVariable Long reportTemplateId, @PathVariable Integer period, @PathVariable int rowIndex, @PathVariable int columnIndex) {
return reportService.getCellAccountRange(reportTemplateId, period, rowIndex, columnIndex);
public OperationResultDto<List<VatEnterpriseAccountResultDto>> getCellAccountRange(@PathVariable Long reportTemplateId, @PathVariable Integer period, @PathVariable int rowIndex, @PathVariable int columnIndex,@RequestHeader String from) {
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)
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);
}
......
......@@ -9,5 +9,5 @@ public interface ReportGenerator {
String generateData(String projectId, List<Long> templateIds, Boolean ifDeleteManualDataSource, List<String> exceptCellTemplates,
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 {
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
cellData.setCreateTime(createTime);
cellData.setUpdateBy("Admin");
cellData.setUpdateTime(createTime);
cellData.setProjectId(projectId);
periodCellDataMapper.insertSelective(cellData);
//after insert celldata, insert the celldatasource for link celldata and datasource
......@@ -501,7 +502,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
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
int period = 0;
if (periodParam != null) {
......@@ -511,7 +512,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
List<PeriodCellTemplateConfigExtendDto> periodCellTemplateConfigExtendDtos =
periodCellTemplateConfigMapper.getPeriodCellTemplateConfigExtendDtos(templateIdList, period);
fixedPCTParsedFormula(periodCellTemplateConfigExtendDtos);
fixedPCTParsedFormula(periodCellTemplateConfigExtendDtos,projectId);
List<CellCalcInfoDto> cellCalcInfoDtos = new ArrayList<>();
periodCellTemplateConfigExtendDtos.stream().collect(Collectors.groupingBy(a ->
new CellTemplateConfigGroupDto(a.getColumnIndex(), a.getRowIndex()
......@@ -543,7 +544,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
return cellCalcInfoDtos;
}
private void fixedPCTParsedFormula(List<PeriodCellTemplateConfigExtendDto> periodCellTemplateConfigExtendDtos) {
private void fixedPCTParsedFormula(List<PeriodCellTemplateConfigExtendDto> periodCellTemplateConfigExtendDtos,String projectId) {
Map<String, List<PCTEntity>> formulaMapToPCT = new HashMap<>();
Map<PeriodCellTemplateConfig, List<String>> configMapToPCTs = new HashMap<>();
Set<PCTEntity> parameter = new HashSet<>();
......@@ -590,7 +591,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
});
if (!parameter.isEmpty()) {
List<PCTEntity> pctResults = periodCellDataMapper.queryByPCTs(parameter);
List<PCTEntity> pctResults = periodCellDataMapper.queryByPCTs(parameter,projectId);
Map<PCTEntity, BigDecimal> pctCache = new HashMap<>();
pctResults.forEach(m -> {
BigDecimal data = null;
......
......@@ -267,7 +267,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
// periodCellTemplateConfig.setVoucherKeyword(cellTemplateConfig.getVoucherKeyword());
periodCellTemplateConfig.setCellTemplateConfigId(cellTemplateConfig.getId());
periodCellTemplateConfig.setKeyValueParsedFormula(StringUtils.EMPTY);
periodCellTemplateConfig.setProjectId(projectId);
if (cellTemplateConfig.getFormula().contains("@")) {
String regex = "@[0-9A-Z.]+";
Pattern pp = Pattern.compile(regex);
......@@ -438,7 +438,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
List<Long> templateIds = new ArrayList<>();
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();
cellDataExample.createCriteria().andReportIdEqualTo(reportId);
......@@ -663,11 +663,11 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
}
@Override
public OperationResultDto<List<VatEnterpriseAccount>> getStdAccountByIndustry(String industryId) {
public OperationResultDto<List<VatEnterpriseAccount>> getStdAccountByIndustry(String industryId, String projectId) {
OperationResultDto resultDto = new OperationResultDto();
try {
PeriodEnterpriseAccountExample example = new PeriodEnterpriseAccountExample();
example.createCriteria().andIsActiveEqualTo(true);
example.createCriteria().andIsActiveEqualTo(true).andProjectIdEqualTo(projectId);
periodEnterpriseAccountMapper.selectByExample(example);
List<PeriodEnterpriseAccount> vatEnterpriseAccounts = periodEnterpriseAccountMapper.selectByExample(example);
if (vatEnterpriseAccounts == null) {
......@@ -687,7 +687,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
}
@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();
try {
......@@ -701,7 +701,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
}
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<VatEnterpriseAccountResultDto> vatEnterpriseAccountResultDtos = new ArrayList<>();
for (PeriodEnterpriseAccount vatEnterpriseAccount : vatEnterpriseAccounts) {
......@@ -740,6 +740,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
cellData.setCreateTime(new Date());
cellData.setUpdateBy("admin");
cellData.setUpdateTime(new Date());
cellData.setProjectId(projectId);
periodCellDataMapper.insertSelective(cellData);
data.setCellId(cellData.getId());
} else {
......@@ -794,6 +795,8 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
cellDataSource.setCellTemplateId(Long.parseLong(data.getCellTemplateId()));
cellDataSource.setCreateTime(new Date());
cellDataSource.setUpdateTime(new Date());
cellDataSource.setProjectId(projectId);
cellDataSource.setPeriod(data.getPeriod());
updateCellValueForDataSourceChange(cellDataSource.getCellDataId(), new BigDecimal("0"), data.getAmount());
periodDataSourceMapper.insertSelective(dataSourceModel);
periodCellDataSourceMapper.insertSelective(cellDataSource);
......@@ -893,7 +896,8 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
cellDataSource.setDataSourceId(dataSource.getId());
cellDataSource.setCreateTime(new Date());
cellDataSource.setUpdateTime(new Date());
cellDataSource.setPeriod(dataSource.getPeriod());
cellDataSource.setProjectId(dataSource.getProjectId());
periodCellDataSourceMapper.insertSelective(cellDataSource);
operationResultDto.setData(dataSource.getId().toString());
......
......@@ -21,6 +21,7 @@ public class VatAbstractService {
public VatEnterpriseAccountMapper vatEnterpriseAccountMapper;
@Autowired
public PeriodStandardAccountMapper periodStandardAccountMapper;
@Autowired
public PeriodEnterpriseAccountMapper periodEnterpriseAccountMapper;
@Autowired
public InputVatInvoiceMapper inputVATInvoiceMapper;
......
......@@ -92,7 +92,7 @@ public class FSJZ extends FunctionBase implements FreeRefFunction {
if (balanceStdManual != null) {
List<VatEnterpriseAccount> vatEnterpriseAccountList = SpringContextUtil
.periodEnterpriseAccountMapper
.getListWithAccountCode(accountCode);
.getListWithAccountCode(accountCode,formulaContext.getProjectId(),period);
if (period == 99) {
val = new BigDecimal(((balanceStdManual.getYearDebitNet() != null ? balanceStdManual.getYearDebitNet() : 0).doubleValue()
- (balanceStdManual.getYearCreditNet() != null ? balanceStdManual.getYearCreditNet() : 0).doubleValue())
......
......@@ -118,11 +118,12 @@ public interface PeriodCellDataMapper extends MyVatMapper {
" PERIOD_REPORT R " +
"WHERE " +
" C.REPORT_ID = R.ID AND " +
" and C.PROJECT_ID = #{projectId} " +
" " +
" <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);
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 {
*/
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 @@
order by ${orderByClause}
</if>
</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>
\ 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