Commit 79b3576e authored by eddie.woo's avatar eddie.woo

modify

parent c6a1e283
package pwc.taxtech.atms.service.impl;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.stereotype.Service;
......@@ -24,7 +25,12 @@ import pwc.taxtech.atms.vat.entity.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@Service
public class ReportAnalysisService extends BaseService {
......@@ -160,39 +166,44 @@ public class ReportAnalysisService extends BaseService {
* 根据借贷方向获取TB表科目的发生额
*/
public BigDecimal getTbValueByDirection(String code, String projectId, Integer period) {
BigDecimal result = BigDecimal.ZERO;
try {
if (StringUtils.isBlank(projectId)) {
return BigDecimal.ZERO;
return result;
}
Project project = projectMapper.selectByPrimaryKey(projectId);
if (null == project) {
return BigDecimal.ZERO;
return result;
}
AccountMappingExample example = new AccountMappingExample();
example.createCriteria().andOrganizationIdEqualTo(project.getOrganizationId())
.andEnterpriseAccountSetIdEqualTo(project.getEnterpriseAccountSetId())
.andIndustryIdEqualTo(project.getIndustryId());
Optional<AccountMapping> mappingOptional = accountMappingMapper.selectByExample(example).stream().findFirst();
if (!mappingOptional.isPresent()) {
return BigDecimal.ZERO;
.andIndustryIdEqualTo(project.getIndustryId()).andStandardAccountCodeEqualTo(code);
List<AccountMapping> mappingList = accountMappingMapper.selectByExample(example).stream()
.filter(distinctByKey(AccountMapping::getEnterpriseAccountCode)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(mappingList)) {
return result;
}
Optional<StandardAccount> accountOptional = standardAccountDao.getByCodeAndIndustryId(
mappingOptional.get().getStandardAccountCode(), mappingOptional.get().getIndustryId())
.stream().findFirst();
Optional<GlBalance> optional = glBalanceDao.get(code, project.getClientCode(), project.getYear() + "-" + period);
BigDecimal val;
if (optional.isPresent()) {
if (accountOptional.get().getDirection() == StdAccountEnum.Direction.Debit.getCode()) {
val = optional.get().getPtdDr();
} else {
val = optional.get().getPtdCr();
for (AccountMapping mapping : mappingList) {
Optional<StandardAccount> accountOptional = standardAccountDao.getByCodeAndIndustryId(
mapping.getStandardAccountCode(), mapping.getIndustryId()).stream().findFirst();
Optional<GlBalance> optional = glBalanceDao.get(code, project.getClientCode(), project.getYear() + "-" +
(period < 10 ? "0" + period : period));
BigDecimal val;
if (optional.isPresent()) {
if (accountOptional.get().getDirection() == StdAccountEnum.Direction.Debit.getCode()) {
val = optional.get().getPtdDr();
} else {
val = optional.get().getPtdCr();
}
result = result.add(val);
}
return val;
}
} catch (Exception e) {
logger.error("getTbValueByDirection error.", e);
}
return BigDecimal.ZERO;
return result;
}
/**
......@@ -239,4 +250,9 @@ public class ReportAnalysisService extends BaseService {
}
return BigDecimal.ZERO;
}
private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Map<Object, Boolean> seen = new ConcurrentHashMap<>();
return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
}
}
......@@ -41,6 +41,8 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
}
},
legend: {
type: 'scroll',
bottom: 10,
data: yArray
},
xAxis: [
......@@ -55,7 +57,7 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
yAxis: [
{
type: 'value',
name: yArray[0],
name: '金额',
// min: 0,
// max: 250,
position: 'right',
......@@ -72,31 +74,13 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
},
{
type: 'value',
name: yArray[1],
// min: 0,
// max: 250,
position: 'right',
offset: 80,
axisLine: {
lineStyle: {
color: colors[1]
}
},
axisLabel: {
formatter: function (val) {
return formatNum(val);
}
}
},
{
type: 'value',
name: yArray[2],
name: '占比',
// min: 0,
// max: 25,
position: 'left',
axisLine: {
lineStyle: {
color: colors[2]
color: colors[1]
}
},
axisLabel: {
......@@ -115,13 +99,12 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
{
name: yArray[1],
type: 'bar',
yAxisIndex: 1,
data: res.data.income
},
{
name: yArray[2],
type: 'line',
yAxisIndex: 2,
yAxisIndex: 1,
data: res.data.rate
}
]
......@@ -209,6 +192,8 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
}
},
legend: {
type: 'scroll',
bottom: 10,
data: yArray
},
xAxis: [
......@@ -223,7 +208,7 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
yAxis: [
{
type: 'value',
name: yArray[0],
name: '金额',
// min: 0,
// max: 250,
position: 'right',
......@@ -240,31 +225,13 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
},
{
type: 'value',
name: yArray[1],
// min: 0,
// max: 250,
position: 'right',
offset: 80,
axisLine: {
lineStyle: {
color: colors[1]
}
},
axisLabel: {
formatter: function (val) {
return formatNum(val);
}
}
},
{
type: 'value',
name: yArray[2],
name: '占比',
// min: 0,
// max: 25,
position: 'left',
axisLine: {
lineStyle: {
color: colors[2]
color: colors[1]
}
},
axisLabel: {
......@@ -283,13 +250,12 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
{
name: yArray[1],
type: 'bar',
yAxisIndex: 1,
data: res.data.income
},
{
name: yArray[2],
type: 'line',
yAxisIndex: 2,
yAxisIndex: 1,
data: res.data.rate
}
]
......@@ -329,6 +295,8 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
}
},
legend: {
type: 'scroll',
bottom: 10,
data: yArray
},
xAxis: [
......@@ -343,7 +311,7 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
yAxis: [
{
type: 'value',
name: yArray[0],
name: '金额',
// min: 0,
// max: 250,
position: 'right',
......@@ -360,31 +328,13 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
},
{
type: 'value',
name: yArray[1],
// min: 0,
// max: 250,
position: 'right',
offset: 80,
axisLine: {
lineStyle: {
color: colors[1]
}
},
axisLabel: {
formatter: function (val) {
return formatNum(val);
}
}
},
{
type: 'value',
name: yArray[2],
name: '占比',
// min: 0,
// max: 25,
position: 'left',
axisLine: {
lineStyle: {
color: colors[2]
color: colors[1]
}
},
axisLabel: {
......@@ -403,13 +353,12 @@ vatModule.controller('VatModelAnalysisController', ['$scope', '$translate', '$ui
{
name: yArray[1],
type: 'bar',
yAxisIndex: 1,
data: res.data.income
},
{
name: yArray[2],
type: 'line',
yAxisIndex: 2,
yAxisIndex: 1,
data: res.data.rate
}
]
......
<div class="vat-model-analysis ">
<div class="col-lg-12 col-md-12" style="margin-top:20px;">
<div class="col-lg-12 col-md-12" style="margin-top:20px;height: 100%;overflow:scroll">
<div class="row">
<div class="col-lg-5 col-md-5">
<div id="burdenRateDiv" name="p_chart"></div>
......@@ -17,6 +17,14 @@
<div id="incomeVolatilityDiv" name="p_chart"></div>
</div>
</div>
<div class="row">
<div class="col-lg-5 col-md-5">
<div id="vatIncomeRateDiv" name="p_chart"></div>
</div>
<div class="col-lg-5 col-md-5 col-md-offset-1 col-lg-offset-1">
<div id="vatIncomeLineDiv" name="p_chart"></div>
</div>
</div>
</div>
<style>
......
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