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

modify

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