Commit c4501047 authored by eddie.woo's avatar eddie.woo

modify

parent 93a631d5
......@@ -105,4 +105,12 @@ public final class Constant {
public static class ReplaceKeyword {
public static final String KEY_IN = "${KeyIn}"; //手工数据源
}
/**
* SimpleDateFormat
*/
public static class DateFormat {
public static final String DEFAULT = "yyyy-MM-dd";
public static final String YEAR_MONTH = "yyyy-MM";
}
}
\ No newline at end of file
......@@ -48,4 +48,31 @@ public class StdAccountEnum {
}
}
}
public enum Direction {
Debit(1, "借方"),
Credit(-1, "贷方");
private Integer code;
private String name;
public static final Map<Integer, String> MAPPING = new HashMap<>();
Direction(Integer code, String name) {
this.code = code;
this.name = name;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
static {
for (Direction direction : Direction.values()) {
MAPPING.put(direction.getCode(), direction.getName());
}
}
}
}
package pwc.taxtech.atms.controller;
import com.alibaba.fastjson.JSON;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -11,24 +12,27 @@ import pwc.taxtech.atms.dto.vatdto.TrialBalanceParam;
import pwc.taxtech.atms.service.impl.DataImportService;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@RestController
@RequestMapping("/api/v1/DataImport/")
public class DataImportController extends BaseController{
public class DataImportController extends BaseController {
@Resource
private DataImportService dataImportService;
@PostMapping("GetBalanceDataForDisplay")
public PagingResultDto<TrialBalanceDto> getBalanceDataForDisplay(@RequestBody TrialBalanceParam param){
public String getBalanceDataForDisplay(@RequestBody TrialBalanceParam param) {
PagingResultDto<TrialBalanceDto> resultDto = new PagingResultDto<>();
PagingDto pagingDto = new PagingDto();
pagingDto.setPageIndex(1);
pagingDto.setPageSize(10);
pagingDto.setTotalCount(0);
List<TrialBalanceDto> list = dataImportService.getBalanceDataForDisplay(param);
PagingDto pagingDto = new PagingDto();
// pagingDto.setPageIndex(1);
// pagingDto.setPageSize(100);
// pagingDto.setTotalCount(list);
resultDto.setPageInfo(pagingDto);
resultDto.setList(Collections.emptyList());
return resultDto;
resultDto.setList(list);
resultDto.setCalculateData(dataImportService.calculateData(list));
// 直接返回对象,jackson解析不全
return JSON.toJSONString(resultDto);
}
}
......@@ -90,6 +90,14 @@ public class AccountMappingDao {
return mapper.selectByExample(example);
}
public List<AccountMapping> getAccountMapping(String epAccountSetId, String orgId) {
AccountMappingExample example = new AccountMappingExample();
AccountMappingExample.Criteria criteria = example.createCriteria();
criteria.andEnterpriseAccountSetIdEqualTo(epAccountSetId);
criteria.andOrganizationIdEqualTo(orgId);
return mapper.selectByExample(example);
}
public void delMapping(String epAccountCode, String epAccountSetId, String orgId, String industryId) {
AccountMappingExample example = new AccountMappingExample();
AccountMappingExample.Criteria criteria = example.createCriteria();
......
......@@ -5,7 +5,9 @@ import org.springframework.stereotype.Service;
import pwc.taxtech.atms.entity.EnterpriseAccountSetOrg;
import pwc.taxtech.atms.entity.EnterpriseAccountSetOrgExample;
import java.util.Date;
import java.util.List;
import java.util.Optional;
@Service
public class EnterpriseAccountSetOrgDao {
......@@ -19,4 +21,18 @@ public class EnterpriseAccountSetOrgDao {
criteria.andEnterpriseAccountSetIdEqualTo(accountSetId);
return mapper.selectByExample(example);
}
/**
* 查询当前有效配置
*
* @param orgId orgId
* @return Optional<EnterpriseAccountSetOrg>
*/
public Optional<EnterpriseAccountSetOrg> getByOrganization(String orgId) {
Date now = new Date();
EnterpriseAccountSetOrgExample example = new EnterpriseAccountSetOrgExample();
example.createCriteria().andOrganizationIdEqualTo(orgId).andEffectiveDateLessThanOrEqualTo(now)
.andExpiredDateGreaterThan(now);
return mapper.selectByExample(example).stream().findFirst();
}
}
package pwc.taxtech.atms.service.impl;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.config.SystemConfig;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.StdAccountEnum;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dto.vatdto.TrialBalanceDto;
import pwc.taxtech.atms.dto.vatdto.TrialBalanceParam;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.vat.dao.GlBalanceMapper;
import pwc.taxtech.atms.vat.entity.GlBalance;
import pwc.taxtech.atms.vat.entity.GlBalanceExample;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class DataImportService extends BaseService{
public class DataImportService extends BaseService {
@Resource
private GlBalanceMapper glBalanceMapper;
@Resource
private OrganizationMapper organizationMapper;
@Resource
private StandardAccountMapper standardAccountMapper;
@Resource
private SystemConfig systemConfig;
@Resource
private EnterpriseAccountSetOrgDao enterpriseAccountSetOrgDao;
@Resource
private AccountMappingDao accountMappingDao;
/**
* TB表查询
*
* @param param TrialBalanceParam
* @return List<TrialBalanceDto>
*/
public List<TrialBalanceDto> getBalanceDataForDisplay(TrialBalanceParam param) {
if (!ObjectUtils.allNotNull(param, param.getFromPeriod(), param.getToPeriod()) || StringUtils.isBlank(param.getOrgId())) {
return Collections.emptyList();
}
Organization organization = organizationMapper.selectByPrimaryKey(param.getOrgId());
if (null == organization) {
return Collections.emptyList();
}
Optional<EnterpriseAccountSetOrg> accountSetOrg = enterpriseAccountSetOrgDao.getByOrganization(organization.getId());
if (!accountSetOrg.isPresent()) {
return Collections.emptyList();
}
// mapping
List<AccountMapping> mappingList = accountMappingDao.getAccountMapping(accountSetOrg.get().getEnterpriseAccountSetId(),
organization.getId());
List<String> etCodeList = mappingList.stream().map(AccountMapping::getEnterpriseAccountCode).distinct().collect(Collectors.toList());
Map<String, List<AccountMapping>> mappingMap = mappingList.stream().collect(Collectors.groupingBy(AccountMapping::getStandardAccountCode));
//standard account
StandardAccountExample stdExample = new StandardAccountExample();
stdExample.createCriteria().andIsLeafEqualTo(Boolean.TRUE);
List<StandardAccount> stdAccountList = standardAccountMapper.selectByExample(stdExample);
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat(Constant.DateFormat.YEAR_MONTH);
Map<String, TrialBalanceDto> resultStdMap = new HashMap<>();
for (int i = param.getFromPeriod(); i <= param.getToPeriod(); i++) {
calendar.set(Calendar.MONTH, i - 1);
GlBalanceExample example = new GlBalanceExample();
//科目段
example.createCriteria().andSegment1EqualTo(organization.getClientCode())
.andPeriodNameEqualTo(dateFormat.format(calendar.getTime())).andSegment3In(etCodeList);
List<GlBalance> sg3List = glBalanceMapper.selectByExample(example);
GlBalanceExample example2 = new GlBalanceExample();
//明细段
example2.createCriteria().andSegment1EqualTo(organization.getClientCode())
.andPeriodNameEqualTo(dateFormat.format(calendar.getTime())).andSegment4In(etCodeList);
List<GlBalance> sg4List = glBalanceMapper.selectByExample(example2);
for (StandardAccount standardAccount : stdAccountList) {
if (!resultStdMap.containsKey(standardAccount.getCode())) {
resultStdMap.put(standardAccount.getCode(), new TrialBalanceDto());
}
// if (!mappingMap.containsKey(standardAccount.getCode())) {
// continue;
// }
TrialBalanceDto dto = resultStdMap.get(standardAccount.getCode());
dto.setChildren(Collections.emptyList());
dto.setAcctCode(standardAccount.getCode());
dto.setAccountName(standardAccount.getName());
List<AccountMapping> tmp = mappingMap.get(standardAccount.getCode());
if (CollectionUtils.isEmpty(tmp)) {
continue;
}
tmp.forEach(o -> {
if (StdAccountEnum.Direction.Credit.getCode().equals(standardAccount.getDirection())) {
dto.setCreditBal(add(dto.getCreditBal(), getGlBalance(o.getEnterpriseAccountCode(), sg3List, sg4List).getPtdCr()));
dto.setBegCreditBal(add(dto.getBegCreditBal(), getGlBalance(o.getEnterpriseAccountCode(), sg3List, sg4List).getBeginCrBalance()));
dto.setEndCreditBal(add(dto.getEndCreditBal(), getGlBalance(o.getEnterpriseAccountCode(), sg3List, sg4List).getEndCrBalance()));
dto.setYearCreditBal(add(dto.getYearCreditBal(), getGlBalance(o.getEnterpriseAccountCode(), sg3List, sg4List).getYtdCr()));
} else {
dto.setDebitBal(add(dto.getDebitBal(), getGlBalance(o.getEnterpriseAccountCode(), sg3List, sg4List).getPtdDr()));
dto.setBegDebitBal(add(dto.getBegDebitBal(), getGlBalance(o.getEnterpriseAccountCode(), sg3List, sg4List).getBeginDrBalance()));
dto.setEndDebitBal(add(dto.getEndDebitBal(), getGlBalance(o.getEnterpriseAccountCode(), sg3List, sg4List).getEndDrBalance()));
dto.setYearDebitBal(add(dto.getYearDebitBal(), getGlBalance(o.getEnterpriseAccountCode(), sg3List, sg4List).getYtdDr()));
}
});
}
}
return new ArrayList<>(resultStdMap.values()).stream().sorted(Comparator.comparing(TrialBalanceDto::getAcctCode))
.collect(Collectors.toList());
}
private BigDecimal add(BigDecimal v1, BigDecimal v2) {
v1 = null == v1 ? BigDecimal.ZERO : v1;
v2 = null == v2 ? BigDecimal.ZERO : v2;
return v1.add(v2);
}
private GlBalance getGlBalance(String code, List<GlBalance> seg3, List<GlBalance> seg4) {
for (GlBalance balance : seg3) {
if (StringUtils.equals(code, balance.getAttr3())) {
return balance;
}
}
for (GlBalance balance : seg4) {
if (StringUtils.equals(code, balance.getAttr3())) {
return balance;
}
}
return new GlBalance();
}
/**
* 计算总和
*
* @param list List<TrialBalanceDto>
* @return TrialBalanceDto
*/
public TrialBalanceDto calculateData(List<TrialBalanceDto> list) {
TrialBalanceDto dto = new TrialBalanceDto();
list.forEach(o -> {
dto.setCreditBal(add(dto.getCreditBal(), o.getCreditBal()));
dto.setBegCreditBal(add(dto.getBegCreditBal(), o.getBegCreditBal()));
dto.setEndCreditBal(add(dto.getEndCreditBal(), o.getEndCreditBal()));
dto.setYearCreditBal(add(dto.getYearCreditBal(), o.getYearCreditBal()));
dto.setDebitBal(add(dto.getDebitBal(), o.getDebitBal()));
dto.setBegDebitBal(add(dto.getBegDebitBal(), o.getBegDebitBal()));
dto.setEndDebitBal(add(dto.getEndDebitBal(), o.getEndDebitBal()));
dto.setYearDebitBal(add(dto.getYearDebitBal(), o.getYearDebitBal()));
});
return dto;
}
}
......@@ -245,7 +245,7 @@ public class ReportServiceImpl {
}
@Transactional
private void updateConfig(String projectId, Integer period, Boolean isMergeManualData, List<Template> templates, PeriodJob job) {
public void updateConfig(String projectId, Integer period, Boolean isMergeManualData, List<Template> templates, PeriodJob job) {
try {
job.setStatus(WrapPeriodJobDto.STATUS_BEGIN);
......
......@@ -172,9 +172,9 @@
newTree = [];
if (treeData && treeData.SubTotals) {
treeData.SubTotals.TitleName = $translate.instant('Total');
$scope.subtotals = treeData.SubTotals;
if (treeData && treeData.calculateData) {
treeData.calculateData.TitleName = $translate.instant('Total');
$scope.subtotals = treeData.calculateData;
}
$('.filter-button').popover("hide");
......@@ -272,64 +272,64 @@
columnDefs: [
{
field: 'accountCode', name: $translate.instant('AccountCode'), headerCellClass: 'dataColumn1',
field: 'acctCode', name: $translate.instant('AccountCode'), headerCellClass: 'dataColumn1',
cellTemplate:
'<div ng-if="row.entity.$$treeLevel==0" class=""><span>{{row.entity.accountCode}}<span></div>' +
'<div ng-if="row.entity.$$treeLevel==1" class="text-align-left-padding"><span>&nbsp;&nbsp;{{row.entity.accountCode}}<span></div>' +
'<div ng-if="row.entity.$$treeLevel==2" class="text-align-left-padding"><span>&nbsp;&nbsp;&nbsp;&nbsp;{{row.entity.accountCode}}<span></div>' +
'<div ng-if="row.entity.$$treeLevel==3" class="text-align-left-padding"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{row.entity.accountCode}}<span></div>' +
'<div ng-if="row.entity.$$treeLevel==4" class="text-align-left-padding"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{row.entity.accountCode}}<span></div>'
'<div ng-if="row.entity.$$treeLevel==0" class=""><span>{{row.entity.acctCode}}<span></div>' +
'<div ng-if="row.entity.$$treeLevel==1" class="text-align-left-padding"><span>&nbsp;&nbsp;{{row.entity.acctCode}}<span></div>' +
'<div ng-if="row.entity.$$treeLevel==2" class="text-align-left-padding"><span>&nbsp;&nbsp;&nbsp;&nbsp;{{row.entity.acctCode}}<span></div>' +
'<div ng-if="row.entity.$$treeLevel==3" class="text-align-left-padding"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{row.entity.acctCode}}<span></div>' +
'<div ng-if="row.entity.$$treeLevel==4" class="text-align-left-padding"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{row.entity.acctCode}}<span></div>'
},
{
field: 'accountName', width: 200, name: $translate.instant('AccountName'), headerCellClass: 'dataColumn2',
cellTemplate: '<div class=""><span>{{row.entity.accountName}}<span></div>'
, footerCellTemplate: '<div class=" alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.TitleName}}: </div>'
, footerCellTemplate: '<div class=" alignRight margin-right5 margin-top5" >合计: </div>'
},
{
field: 'debitOpeningBalance', name: $translate.instant('Debitor'), headerCellClass: 'alignCenter dataColumn3',
field: 'begDebitBal', name: $translate.instant('Debitor'), headerCellClass: 'alignCenter dataColumn3',
cellTemplate: '<div class="alignRight margin-right5"><span>{{row.entity.debitOpeningBalance}}</span></div>'
, footerCellTemplate: '<div class=" alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.BegDebitBal}}</div>'
cellTemplate: '<div class="alignRight margin-right5"><span>{{row.entity.begDebitBal || "0.00"}}</span></div>'
, footerCellTemplate: '<div class=" alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.begDebitBal || "0.00"}}</div>'
},
{
field: 'creditOpeningBalance', name: $translate.instant('Creditor'), headerCellClass: 'alignCenter dataColumn4',
field: 'begCreditBal', name: $translate.instant('Creditor'), headerCellClass: 'alignCenter dataColumn4',
cellTemplate: '<div class=" alignRight margin-right5"><span>{{row.entity.creditOpeningBalance}}</span></div>'
, footerCellTemplate: '<div class=" alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.BegCreditBal}}</div>'
cellTemplate: '<div class=" alignRight margin-right5"><span>{{row.entity.begCreditBal || "0.00"}}</span></div>'
, footerCellTemplate: '<div class=" alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.begCreditBal || "0.00"}}</div>'
},
{
field: 'accumulatedDebitAmount', name: $translate.instant('Debitor') + ' ', headerCellClass: 'alignCenter dataColumn5',
field: 'debitBal', name: $translate.instant('Debitor') + ' ', headerCellClass: 'alignCenter dataColumn5',
cellTemplate: '<div class=" alignRight margin-right5"><span>{{row.entity.accumulatedDebitAmount}}</span></div>'
, footerCellTemplate: '<div class=" alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.DebitBal}}</div>'
cellTemplate: '<div class=" alignRight margin-right5"><span>{{row.entity.debitBal || "0.00"}}</span></div>'
, footerCellTemplate: '<div class=" alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.debitBal || "0.00"}}</div>'
},
{
field: 'accumulatedCreditAmount', name: $translate.instant('Creditor') + ' ', headerCellClass: 'alignCenter dataColumn6',
field: 'creditBal', name: $translate.instant('Creditor') + ' ', headerCellClass: 'alignCenter dataColumn6',
cellTemplate: '<div class=" alignRight margin-right5"><span>{{row.entity.accumulatedCreditAmount}}</span></div>'
, footerCellTemplate: '<div class=" alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.CreditBal}}</div>'
cellTemplate: '<div class=" alignRight margin-right5"><span>{{row.entity.creditBal || "0.00"}}</span></div>'
, footerCellTemplate: '<div class=" alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.creditBal || "0.00"}}</div>'
},
{
field: 'debitClosingBalance', name: $translate.instant('Debitor') + ' ', headerCellClass: 'alignCenter dataColumn7',
cellTemplate: '<div class=" alignRight margin-right5"><span>{{row.entity.debitClosingBalance}}</span></div>'
, footerCellTemplate: '<div class="alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.EndDebitBal}}</div>'
field: 'endDebitBal', name: $translate.instant('Debitor') + ' ', headerCellClass: 'alignCenter dataColumn7',
cellTemplate: '<div class=" alignRight margin-right5"><span>{{row.entity.endDebitBal || "0.00"}}</span></div>'
, footerCellTemplate: '<div class="alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.endDebitBal || "0.00"}}</div>'
},
{
field: 'creditClosingBalance', name: $translate.instant('Creditor') + ' ', headerCellClass: 'alignCenter dataColumn8',
cellTemplate: '<div class=" alignRight margin-right5"><span>{{row.entity.creditClosingBalance}}</span></div>'
, footerCellTemplate: '<div class="alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.EndCreditBal}}</div>'
field: 'endCreditBal', name: $translate.instant('Creditor') + ' ', headerCellClass: 'alignCenter dataColumn8',
cellTemplate: '<div class=" alignRight margin-right5"><span>{{row.entity.endCreditBal || "0.00"}}</span></div>'
, footerCellTemplate: '<div class="alignRight margin-right5 margin-top5" >{{grid.appScope.subtotals.endCreditBal || "0.00"}}</div>'
}
]
};
......
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