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

fixed code issues and add datasource for invoice and voucher

parent 244ad198
......@@ -11,6 +11,7 @@ import pwc.taxtech.atms.vat.entity.Report;
import pwc.taxtech.atms.vat.entity.VatEnterpriseAccount;
import pwc.taxtech.atms.vat.service.ReportService;
import javax.print.attribute.standard.Media;
import java.util.List;
@RestController
......@@ -73,13 +74,18 @@ public class ReportController {
return reportService.getStdAccountByIndustry(industryID);
}
@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);
@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);
}
@RequestMapping(value = "addCellManualData",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto addCellManualDataSource(@RequestBody ManualDataSourceDto data){
@RequestMapping(value = "addCellManualData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto addCellManualDataSource(@RequestBody ManualDataSourceDto data) {
return reportService.addCellManualDataSource(data);
}
@RequestMapping(value = "addDataSource", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<String> addDataSource(@RequestBody DataSourceDto datasource) {
return reportService.addDataSource(datasource);
}
}
\ No newline at end of file
......@@ -71,7 +71,12 @@ public final class CellConfigTranslater {
}
}
Optional<CellTemplateConfig> invoiceItem = configList.stream().filter(x -> x.getDataSourceType().equals(CellDataSourceType.OutputInvoice.getCode()) || x.getDataSourceType().equals(CellDataSourceType.InputInvoice.getCode()) || x.getDataSourceType().equals(CellDataSourceType.CustomInvoice.getCode())).findFirst();
Optional<CellTemplateConfig> invoiceItem = configList
.stream()
.filter(x -> x.getDataSourceType().equals(CellDataSourceType.OutputInvoice.getCode())
|| x.getDataSourceType().equals(CellDataSourceType.InputInvoice.getCode())
|| x.getDataSourceType().equals(CellDataSourceType.CustomInvoice.getCode()))
.findFirst();
if (invoiceItem.isPresent()) {
cellTemplateConfigDto.setHasInvoice(true);
cellTemplateConfigDto.setInvoiceType(invoiceItem.get().getInvoiceType());
......
package pwc.taxtech.atms.service.impl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.util.SnowFlake;
import javax.annotation.PostConstruct;
@Service
@Component
public class DistributedIDService extends BaseService {
@Value("${distributed_id_datacenter}")
private Integer dataCenterId;
......
......@@ -131,6 +131,8 @@ public interface DataSourceMapper extends MyVatMapper {
void clearReportWithPeriod(Integer period);
void clearDataWithPeriod(@Param("exceptReportTemplateIDs") String exceptReportTemplateIDs,@Param("period")Integer period);
List<DataSourceExtendDto> getFormulaDataSource(Long reportID);
List<DataSourceExtendDto> getManualDataSource(Long cellDataID);
......
......@@ -35,4 +35,6 @@ public interface ReportService {
* @return 添加结果
*/
OperationResultDto addCellManualDataSource(ManualDataSourceDto data);
OperationResultDto<String> addDataSource(DataSourceDto datasource);
}
......@@ -4,6 +4,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.common.util.SnowFlake;
import pwc.taxtech.atms.constant.enums.*;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.*;
......@@ -104,33 +105,41 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
}
List<Long> exceptTemplateIDs = templateMapper.getIDsForExceptTemplate();
String strExceptTemplateIDs = StringUtils.join(exceptTemplateIDs, ",");
String strExceptTemplateIDs = StringUtils.EMPTY;
if (exceptTemplateIDs != null && exceptTemplateIDs.size() > 0) {
strExceptTemplateIDs = StringUtils.join(exceptTemplateIDs, ",");
}
//todo: according to projectId get the templateGroupId
Long templateGroupID = projectMapper.getTemplateGroupIdByProject(projectId, EnumServiceType.VAT.getCode());
if (templateGroupID != null && templateGroupID != 0) {
// 先进行数据清理,包括period开头的所有报表配置表 条件Period
dataSourceMapper.clearFormulaBlockWithPeriod(period);
// dataSourceMapper.clearFormulaBlockWithPeriod(period);
//todo: reopen it later
//dataSourceMapper.clearTaxRuleSettingWithPeriod(period);
dataSourceMapper.clearCellTemplateWithPeriod(period, strExceptTemplateIDs);
dataSourceMapper.clearCellTemplateConfigWithPeriod(period, strExceptTemplateIDs);
dataSourceMapper.clearTemplateWithPeriod(period, strExceptTemplateIDs);
// dataSourceMapper.clearCellTemplateWithPeriod(period, strExceptTemplateIDs);
// dataSourceMapper.clearCellTemplateConfigWithPeriod(period, strExceptTemplateIDs);
// dataSourceMapper.clearTemplateWithPeriod(period, strExceptTemplateIDs);
//todo: reopen it later
//dataSourceMapper.clearTaxPayerReportWithPeriod(period);
dataSourceMapper.clearCellDataSourceDataWithPeriod(period);
dataSourceMapper.clearDataSourceDetailWithPeriod(period);
dataSourceMapper.clearDataSourceWithPeriod(period);
dataSourceMapper.clearCellDataWithPeriod(strExceptTemplateIDs, period);
dataSourceMapper.clearReportWithPeriod(period);
// dataSourceMapper.clearCellDataSourceDataWithPeriod(period);
// dataSourceMapper.clearDataSourceDetailWithPeriod(period);
// dataSourceMapper.clearDataSourceWithPeriod(period);
// dataSourceMapper.clearCellDataWithPeriod(strExceptTemplateIDs, period);
// dataSourceMapper.clearReportWithPeriod(period);
dataSourceMapper.clearDataWithPeriod(strExceptTemplateIDs, period);
// 根据templategroupid 把 template 插入到 periodTemplate
TemplateExample example = new TemplateExample();
example.createCriteria().andTemplateGroupIdEqualTo(templateGroupID);
List<Template> templates = templateMapper.selectByExample(example);
List<PeriodTemplate> periodTemplateList = new ArrayList<>();
int i = 0;
Long startTimeOut = System.currentTimeMillis();
logger.debug("templates copy start: " + startTimeOut);
for (Template template : templates) {
i++;
Long startTime = System.currentTimeMillis();
logger.debug("template copy start: " + startTime);
PeriodTemplate periodTemplate = new PeriodTemplate();
CommonUtils.copyProperties(template, periodTemplate);
periodTemplate.setId(distributedIDService.nextId());
......@@ -150,19 +159,27 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
// periodTemplate.setCreateBy(template.getCreateBy());
// periodTemplate.setUpdateBy(template.getUpdateBy());
periodTemplateList.add(periodTemplate);
logger.debug("template copy end,used time: " + (System.currentTimeMillis() - startTime) + " ms");
}
logger.debug("templates copy end,used: " + (System.currentTimeMillis() - startTimeOut) + " ms, copy: " + i + " items");
List<Long> templateIDList = periodTemplateList.stream().map(PeriodTemplate::getTemplateId).collect(Collectors.toList());
CellTemplateExample cellTemplateExample = new CellTemplateExample();
cellTemplateExample.createCriteria().andReportTemplateIdIn(templateIDList);
List<CellTemplate> cellTemplateList = cellTemplateMapper.selectByExample(cellTemplateExample);
List<PeriodCellTemplate> periodCellTemplateList = new ArrayList<>();
i = 0;
startTimeOut = System.currentTimeMillis();
logger.debug("cellTemplates copy start: " + startTimeOut);
for (CellTemplate cellTemplate : cellTemplateList) {
i++;
Long startTime = System.currentTimeMillis();
logger.debug("celltemplate copy start: " + startTime);
PeriodCellTemplate periodCellTemplate = new PeriodCellTemplate();
CommonUtils.copyProperties(cellTemplate, periodCellTemplate);
periodCellTemplate.setId(distributedIDService.nextId());
periodCellTemplate.setPeriod(period);
// periodCellTemplate.setReportTemplateId(cellTemplate.getReportTemplateId());
// periodCellTemplate.setReportTemplateId(cellTemplate.getReportTemplateId());
// periodCellTemplate.setRowIndex(cellTemplate.getRowIndex());
// periodCellTemplate.setRowName(cellTemplate.getRowName());
// periodCellTemplate.setColumnIndex(cellTemplate.getColumnIndex());
......@@ -171,20 +188,28 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
// periodCellTemplate.setCreateTime(cellTemplate.getCreateTime());
// periodCellTemplate.setUpdateTime(cellTemplate.getUpdateTime());
periodCellTemplate.setCellTemplateId(cellTemplate.getId());
// periodCellTemplate.setDataType(cellTemplate.getDataType());
// periodCellTemplate.setDataType(cellTemplate.getDataType());
// periodCellTemplate.setIsReadOnly(cellTemplate.getIsReadOnly());
// periodCellTemplate.setCopyFromId(cellTemplate.getCopyFromId());
// periodCellTemplate.setCreateBy(cellTemplate.getCreateBy());
// periodCellTemplate.setUpdateBy(cellTemplate.getUpdateBy());
periodCellTemplateList.add(periodCellTemplate);
logger.debug("celltemplate copy end,used time: " + (System.currentTimeMillis() - startTime) + " ms");
}
logger.debug("templates copy end,used: " + (System.currentTimeMillis() - startTimeOut) + " ms, copy: " + i + " items");
List<Long> cellTemplateIDList = periodCellTemplateList.stream().map(PeriodCellTemplate::getCellTemplateId).collect(Collectors.toList());
CellTemplateConfigExample cellTemplateConfigExample = new CellTemplateConfigExample();
cellTemplateConfigExample.createCriteria().andReportTemplateIdIn(templateIDList).andCellTemplateIdIn(cellTemplateIDList);
List<CellTemplateConfig> cellTemplateConfigList = cellTemplateConfigMapper.selectByExample(cellTemplateConfigExample);
List<PeriodCellTemplateConfig> periodCellTemplateConfigList = new ArrayList<>();
i = 0;
startTimeOut = System.currentTimeMillis();
logger.debug("cellTemplateConfigs copy start:" + startTimeOut);
for (CellTemplateConfig cellTemplateConfig : cellTemplateConfigList) {
i++;
Long startTime = System.currentTimeMillis();
logger.debug("cellTemplateConfig copy start: " + startTime);
PeriodCellTemplateConfig periodCellTemplateConfig = new PeriodCellTemplateConfig();
CommonUtils.copyProperties(cellTemplateConfig, periodCellTemplateConfig);
periodCellTemplateConfig.setId(distributedIDService.nextId());
......@@ -223,7 +248,9 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
}
}
periodCellTemplateConfigList.add(periodCellTemplateConfig);
logger.debug("cellTemplateConfig copy end,used time: " + (System.currentTimeMillis() - startTime) + " ms");
}
logger.debug("cellTemplateConfigs copy end,used: " + (System.currentTimeMillis() - startTimeOut) + " ms, copy: " + i + " items");
if (periodCellTemplateConfigList != null) {
periodCellTemplateConfigList.forEach(a -> {
......@@ -680,10 +707,9 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
dataSource.setUpdateBy("admin");
dataSource.setUpdateTime(new Date());
dataSourceMapper.updateByPrimaryKeySelective(dataSource);
if(!cellData.getData().equals("#VALUE!")) {
if (!cellData.getData().equals("#VALUE!")) {
cellData.setData(new BigDecimal(cellData.getData()).add(changeValue).toString());
}
else{
} else {
cellData.setData(new BigDecimal("0.0").add(changeValue).toString());
}
//cellData.setFormulaExp(cellData.getData());
......@@ -702,6 +728,42 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
return operationResultDto;
}
@Override
public OperationResultDto<String> addDataSource(DataSourceDto datasourceDto) {
OperationResultDto operationResultDto = new OperationResultDto();
CellData cellData = cellDataMapper.selectByPrimaryKey(Long.parseLong(datasourceDto.getCellDataID()!=null?datasourceDto.getCellDataID():"0"));
if (cellData == null) {
operationResultDto.setResult(false);
operationResultDto.setResultMsg("NoCellData");
return operationResultDto;
}
DataSource dataSource = null;
CommonUtils.copyProperties(datasourceDto, dataSource);
dataSource.setType(datasourceDto.getDataSourceType());
if (dataSource.getId() == null || dataSource.getId() == 0L) {
dataSource.setId(distributedIDService.nextId());
}
dataSource.setCreateTime(new Date());
dataSourceMapper.insertSelective(dataSource);
CellDataSource cellDataSource = new CellDataSource();
cellDataSource.setId(distributedIDService.nextId());
cellDataSource.setCellDataId(cellData.getId());
cellDataSource.setCellTemplateId(cellData.getCellTemplateId());
cellDataSource.setOperationType(datasourceDto.getOperationType());
cellDataSource.setDataSourceId(dataSource.getId());
cellDataSource.setCreateTime(new Date());
cellDataSource.setUpdateTime(new Date());
cellDataSourceMapper.insertSelective(cellDataSource);
operationResultDto.setData(dataSource.getId().toString());
operationResultDto.setResult(true);
return operationResultDto;
}
private void updateCellValueForDataSourceChange(Long cellDataID, BigDecimal originalAmount, BigDecimal newAmount) {
BigDecimal aValue = newAmount != null ? newAmount : new BigDecimal("0");
BigDecimal bValue = originalAmount != null ? originalAmount : new BigDecimal("0");
......
......@@ -525,6 +525,19 @@
</delete>
<delete id="clearReportWithPeriod">
DELETE FROM report WHERE period=#{period,jdbcType=INTEGER};
</delete>
<delete id="clearDataWithPeriod">
DELETE FROM period_formula_block WHERE period=#{period,jdbcType=INTEGER};
DELETE FROM period_tax_rule_setting WHERE period=#{period,jdbcType=INTEGER};
DELETE FROM period_cell_template WHERE period=#{period,jdbcType=INTEGER} and report_template_id not in (${exceptReportTemplateIDs});
DELETE FROM period_cell_template_config WHERE period=#{period,jdbcType=INTEGER} and report_template_id not in (${exceptReportTemplateIDs});
DELETE FROM period_template WHERE period=#{period,jdbcType=INTEGER} and template_id not in (${exceptReportTemplateIDs});
DELETE FROM period_tax_payer_report_rule WHERE period=#{period,jdbcType=INTEGER};
DELETE d FROM data_source_detail d JOIN data_source f ON d.data_source_id = f.id WHERE f.period = #{period,jdbcType=INTEGER};
DELETE d FROM cell_data_source d JOIN data_source f ON d.data_source_id = f.id WHERE f.period = #{period,jdbcType=INTEGER};
DELETE d FROM data_source d WHERE d.period = #{period,jdbcType=INTEGER};
DELETE c FROM cell_data c join report r on c.report_id=r.id where r.period = #{period,jdbcType=INTEGER};
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"/>
......@@ -591,12 +604,14 @@
<association property="cellData" javaType="pwc.taxtech.atms.vat.entity.CellData">
<id column="cell_data_id" jdbcType="BIGINT" property="id"/>
<result column="cell_data_data" property="data" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result column="cell_data_template_id" property="cellTemplateId" javaType="java.lang.Long" jdbcType="BIGINT"/>
<result column="cell_data_template_id" property="cellTemplateId" javaType="java.lang.Long"
jdbcType="BIGINT"/>
<result column="cell_data_report_id" property="reportId" javaType="java.lang.Long" jdbcType="BIGINT"/>
</association>
<association property="cellDataSource" javaType="pwc.taxtech.atms.vat.entity.CellDataSource">
<id column="cell_data_source_id" jdbcType="BIGINT" property="id"/>
<result column="cell_data_source_operation_type" property="operationType" javaType="java.lang.Integer" jdbcType="INTEGER"/>
<result column="cell_data_source_operation_type" property="operationType" javaType="java.lang.Integer"
jdbcType="INTEGER"/>
</association>
</resultMap>
<select id="getManualDataSource2" parameterType="java.lang.Long" resultMap="dataSourceCellDataDto">
......
......@@ -24479,12 +24479,12 @@
* @param {string} repeatName The left hand side of the repeat expression, indicating
* the name for each item in the array.
* @param {!Function} repeatListExpression A compiled expression based on the right hand side
* of the repeat expression. Points to the array to repeat over.
* @param {string|undefined} extraName The optional extra repeatName.
*/
VirtualRepeatController.prototype.link_ =
function (container, transclude, repeatName, repeatListExpression, extraName) {
this.container = container;
* of the repeat expression. Points to the array to repeat over.
this.transclude = transclude;
this.repeatName = repeatName;
this.rawRepeatListExpression = repeatListExpression;
......@@ -186,7 +186,7 @@
tick-property="ticked" button-label="key" item-label="key" max-labels="1" helper-elements="all none"
translation="langSetting" is-disabled="!hasEditPermission || !ToggleSaveAs || !editModel.hasInvoice"
on-item-click="refreshCategorySelect(data)" class="invoice-category-select"></span>
<span isteven-multi-select ng-hide="!(!editModel.chosenInvoiceOption.rateOptions || editModel.chosenInvoiceOption.rateOptions.length === 0)"
<span isteven-multi-select ng-if="!(!editModel.chosenInvoiceOption.rateOptions || editModel.chosenInvoiceOption.rateOptions.length === 0)"
input-model="editModel.chosenInvoiceOption.rateOptions" output-model="selectedRateOptions" tick-property="ticked"
button-label="key" item-label="key" max-labels="2" helper-elements="all none" translation="langSetting"
is-disabled="!hasEditPermission || !ToggleSaveAs || !editModel.hasInvoice" on-item-click="refreshTaxRateSelect(data)"
......
......@@ -252,13 +252,11 @@ var cacheModule = angular.module('app.cache', ['app.common'])
//Common Bind Module Method
var bindModule = function (thisModule, controllerProvider, compileProvider, filterProvider, provide) {
thisModule.controller = controllerProvider.register;
thisModule.directive = compileProvider.directive;
thisModule.filter = filterProvider.register;
thisModule.factory = provide.factory;
thisModule.service = provide.service;
return thisModule;
};
......@@ -835,7 +833,6 @@ var systemConfigurationModule = angular.module('app.systemConfiguration', ['ngMe
sticky: true
});
$stateProvider.state({
name: 'modelConfiguration',
url: '/modelconfiguration',
......@@ -960,7 +957,6 @@ var adminHomePageModule = angular.module('app.adminHomePage', ["isteven-multi-se
deepStateRedirect: true,
sticky: true
});
}]);
......@@ -972,11 +968,9 @@ var noPermissionPageModule = angular.module('app.noPermissionPage', ["isteven-mu
function ($controllerProvider, $compileProvider, $filterProvider, $provide, scriptDependencyProvider, $stateProvider, $urlRouterProvider) {
'use strict';
// this is required to add controller/directive/filter/service after angular bootstrap
bindModule(noPermissionPageModule, $controllerProvider, $compileProvider, $filterProvider, $provide);
$stateProvider.state({
name: 'noPermissionPage',
url: '/noPermissionPage',
......
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