|
|
@@ -5,16 +5,20 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.jzg.commons.core.base.BaseController;
|
|
|
import com.jzg.commons.entity.report.dto.ReportOperatingProfitDataDto;
|
|
|
import com.jzg.commons.entity.report.vo.ReportSearchCommonVo;
|
|
|
+import com.jzg.commons.util.BigDecimalUtil;
|
|
|
import com.jzg.console.client.FeeAuditClient;
|
|
|
import com.jzg.console.service.ReportOperatingProfitDataService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StopWatch;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -31,6 +35,8 @@ public class ReportOperatingProfitDataServiceImpl extends ReportBaseServiceImpl
|
|
|
|
|
|
@Autowired
|
|
|
private FeeAuditClient feeAuditClient;
|
|
|
+ @Autowired
|
|
|
+ private BaseController baseController;
|
|
|
|
|
|
/**
|
|
|
* @version
|
|
|
@@ -41,109 +47,55 @@ public class ReportOperatingProfitDataServiceImpl extends ReportBaseServiceImpl
|
|
|
@Override
|
|
|
public IPage<?> getPageListByParams(ReportSearchCommonVo reportSearchCommonVo) {
|
|
|
log.info("财务数据-经营利润-列表查询: reportSearchCommonVo=[{}]", JSONUtil.toJsonStr(reportSearchCommonVo));
|
|
|
- String sql1 = """
|
|
|
-
|
|
|
- select
|
|
|
- a.ym ,
|
|
|
- sum(a.total_premium),
|
|
|
- sum(a.total_receivable_premium)
|
|
|
- -- ,sum(a.total_payable_premium)
|
|
|
- from
|
|
|
- (
|
|
|
- select
|
|
|
- io.id as order_no,
|
|
|
- io.signing_time ,
|
|
|
- DATE_FORMAT(io.signing_time, '%Y-%m') as ym,
|
|
|
- ifo.total_premium ,
|
|
|
- ifo.total_payable_premium ,
|
|
|
- ifo.total_receivable_premium,
|
|
|
- io.system_code
|
|
|
- from
|
|
|
- ins_fee_orders ifo
|
|
|
- left join ins_orders io on
|
|
|
- ifo.order_no = io.id
|
|
|
- where
|
|
|
- io.system_code = 'G111'
|
|
|
- and io.signing_time >= '2016-01-01 00:00:00'
|
|
|
- ) as a
|
|
|
- group by a.ym
|
|
|
- order by a.ym asc
|
|
|
-
|
|
|
- """;
|
|
|
-
|
|
|
- String sql11 = """
|
|
|
-
|
|
|
- select
|
|
|
- a.ym ,
|
|
|
- sum(a.total_payable_premium)
|
|
|
- from
|
|
|
- (
|
|
|
- select
|
|
|
- io.id as order_no,
|
|
|
- io.signing_time ,
|
|
|
- DATE_FORMAT(io.signing_time, '%Y-%m') as ym,
|
|
|
- ifo.total_premium ,
|
|
|
- ifo.total_payable_premium ,
|
|
|
- ifo.total_receivable_premium,
|
|
|
- io.system_code
|
|
|
- from
|
|
|
- ins_fee_orders ifo
|
|
|
- left join ins_orders io on
|
|
|
- ifo.order_no = io.id
|
|
|
- where
|
|
|
- io.system_code = 'G111'
|
|
|
- and io.signing_time >= '2016-01-01 00:00:00'
|
|
|
- and io.id in (
|
|
|
- select
|
|
|
- ifa.order_no
|
|
|
- from
|
|
|
- ins_fee_audit ifa
|
|
|
- where
|
|
|
- ifa.audit_status = 1
|
|
|
- )
|
|
|
- ) as a
|
|
|
- group by a.ym
|
|
|
- order by a.ym asc
|
|
|
-
|
|
|
- """;
|
|
|
-
|
|
|
- String sql2 = """
|
|
|
- select
|
|
|
- sum(ipiis.actual_received_amount),
|
|
|
- DATE_FORMAT(ipiis.receive_payment_date, '%Y-%m') as ym
|
|
|
- from
|
|
|
- ins_ply_income_invoice_settlement ipiis
|
|
|
- where
|
|
|
- receive_payment_date >= '2026-07-01 00:00:00'
|
|
|
- and ipiis.system_code = 'G111'
|
|
|
- group by ym
|
|
|
-
|
|
|
- """;
|
|
|
-
|
|
|
- String sql3 = """
|
|
|
- select
|
|
|
- DATE_FORMAT(suacl.create_time, '%Y-%m') as ym,
|
|
|
- sum(suacl.amount)
|
|
|
- from
|
|
|
- sys_user_account_change_log suacl
|
|
|
- where
|
|
|
- suacl.system_code = 'G111'
|
|
|
- and suacl.amount < 0
|
|
|
- and suacl.create_time >= '2026-01-01 00:00:00'
|
|
|
- group by
|
|
|
- ym
|
|
|
- """;
|
|
|
-
|
|
|
- Map<String, ReportOperatingProfitDataDto> map1 = new HashMap<>();
|
|
|
+ Integer year = LocalDate.now().getYear();
|
|
|
+ List<String> years = reportSearchCommonVo.getYear();
|
|
|
+ if(CollUtil.isNotEmpty(years)){
|
|
|
+ year = Integer.valueOf(years.get(0));
|
|
|
+ }
|
|
|
+ StopWatch stopWatch = new StopWatch("营业利润汇总");
|
|
|
+ stopWatch.start("查询总保费");
|
|
|
+ Map<String, ReportOperatingProfitDataDto> map1 = feeAuditClient.queryOperatingProfits(year,"01").getData();
|
|
|
+ stopWatch.stop();
|
|
|
+
|
|
|
+ stopWatch.start("查询总的应付");
|
|
|
+
|
|
|
Map<String, ReportOperatingProfitDataDto> map2 = new HashMap<>();
|
|
|
+ try{
|
|
|
+ map2 = feeAuditClient.queryOperatingProfits(year,"02").getData();
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("查询总的应付",e);
|
|
|
+ }
|
|
|
+ stopWatch.stop();
|
|
|
+ stopWatch.start("查询实收金额(结算金额)");
|
|
|
Map<String, ReportOperatingProfitDataDto> map3 = new HashMap<>();
|
|
|
+ try {
|
|
|
+ map3 = feeAuditClient.queryOperatingProfits(year,"03").getData();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询实收金额(结算金额)",e);
|
|
|
+ }
|
|
|
+ stopWatch.stop();
|
|
|
+ stopWatch.start("查询实际提取金额");
|
|
|
Map<String, ReportOperatingProfitDataDto> map4 = new HashMap<>();
|
|
|
+ try {
|
|
|
+ map3 = feeAuditClient.queryOperatingProfits(year,"04").getData();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询实际提取金额",e);
|
|
|
+ }
|
|
|
+ stopWatch.stop();
|
|
|
List<Map<String, ReportOperatingProfitDataDto>> allMaps = new ArrayList<>();
|
|
|
+ allMaps.add(map1);
|
|
|
+ allMaps.add(map2);
|
|
|
+ allMaps.add(map3);
|
|
|
+ allMaps.add(map4);
|
|
|
+ stopWatch.start("数据集汇总");
|
|
|
Map<String, ReportOperatingProfitDataDto> compMaps = this.mergeMaps(allMaps);
|
|
|
- List<ReportOperatingProfitDataDto> values = new ArrayList<>(compMaps.values());
|
|
|
-
|
|
|
+ stopWatch.stop();
|
|
|
|
|
|
- // Page<ReportOperatingProfitDataDto> page = new Page<>(reportSearchCommonVo.getPageNo(), reportSearchCommonVo.getPageSize());
|
|
|
+ log.info("统计营业利润,耗时明细如下:[{}]", stopWatch.prettyPrint());
|
|
|
+ List<ReportOperatingProfitDataDto> values = compMaps.values().stream()
|
|
|
+ .peek(action->{
|
|
|
+ action.setProfitMoney(BigDecimalUtil.subtract(action.getReceivableMoney(),action.getMeetMoney()));
|
|
|
+ }).sorted(Comparator.comparing(ReportOperatingProfitDataDto::getYm).reversed()).collect(Collectors.toList());
|
|
|
IPage<ReportOperatingProfitDataDto> pageList = new Page<ReportOperatingProfitDataDto>();
|
|
|
pageList.setRecords(values);
|
|
|
pageList.setTotal(CollUtil.size(values));
|
|
|
@@ -202,7 +154,7 @@ public class ReportOperatingProfitDataServiceImpl extends ReportBaseServiceImpl
|
|
|
public List<ReportOperatingProfitDataDto> getList(){
|
|
|
List<ReportOperatingProfitDataDto> list =new ArrayList<>();
|
|
|
ReportOperatingProfitDataDto reportOperatingProfitDataDto = ReportOperatingProfitDataDto.builder()
|
|
|
- .yearAndMonthTime("2023-10").sumPremium(new BigDecimal(456)).receivableMoney(new BigDecimal(456))
|
|
|
+ .ym("2023-10").sumPremium(new BigDecimal(456)).receivableMoney(new BigDecimal(456))
|
|
|
.meetMoney(new BigDecimal(23)).profitMoney(new BigDecimal(32))
|
|
|
.receivedMoney(new BigDecimal(23)).paidMoney(new BigDecimal(23)).build();
|
|
|
list.add(reportOperatingProfitDataDto);
|