Bladeren bron

首页详细数据图表响应参数实体

longw 1 jaar geleden
bovenliggende
commit
956d878da3

+ 9 - 1
module_kzks/src/main/java/org/jeecg/modules/Index/controller/IndexController.java

@@ -6,6 +6,7 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.Index.entity.dto.IndexInfoParamDto;
 import org.jeecg.modules.Index.entity.vo.ContractDataInfoVo;
 import org.jeecg.modules.Index.entity.vo.IncomeDataInfoVo;
+import org.jeecg.modules.Index.entity.vo.ReceivedDataInfoVo;
 import org.jeecg.modules.Index.service.IndexService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -33,11 +34,18 @@ public class IndexController {
         return Result.ok(reslut);
     }
 
+    @GetMapping("getTotalReceived")
+    public Result<ReceivedDataInfoVo> getTotalReceived(HttpServletRequest request) {
+        ReceivedDataInfoVo reslut = indexService.getTotalReceived(request);
+        return Result.ok(reslut);
+    }
 
-    @PostMapping("getContractAmountInfo/{Time}")
+
+    @PostMapping("getContractAmountInfo")
     public Result<String> getContractAmountInfo(HttpServletRequest request, @RequestBody IndexInfoParamDto indexInfoParamDto) {
         String result = indexService.getContractAmountInfo(request,indexInfoParamDto);
         return Result.ok(result);
     }
 
+
 }

+ 2 - 1
module_kzks/src/main/java/org/jeecg/modules/Index/entity/dto/IndexInfoParamDto.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.Index.entity.dto;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.util.Date;
@@ -7,7 +8,7 @@ import java.util.Date;
 @Data
 public class IndexInfoParamDto {
 
-    /*年/月/日*/
+    /*年/月
     private String time;
 
     /*起始时间*/

+ 16 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/entity/vo/ContractAmountVo.java

@@ -0,0 +1,16 @@
+package org.jeecg.modules.Index.entity.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/*首页图表合同纵轴数据*/
+@Data
+public class ContractAmountVo {
+
+    /*合同额*/
+    private BigDecimal contractAmount;
+
+    /*合同数*/
+    private Long contractTotal;
+}

+ 17 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/entity/vo/IndexChartInfoVo.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.Index.entity.vo;
+
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+/*首页图表响应实体*/
+public class  IndexChartInfoVo<T> {
+
+    /*横坐标集合*/
+    private List<Date> XAxisData;
+
+    /*纵坐标集合*/
+    private List<T> SeriesData;
+}

+ 23 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/entity/vo/ReceivedDataInfoVo.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.Index.entity.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/*首页已收款*/
+@Data
+public class ReceivedDataInfoVo {
+
+    /*年总收款*/
+    private BigDecimal ReceivedYearTotal;
+    /*上年同期总收款*/
+    private BigDecimal ReceivedYearTq;
+    /*同比增长率*/
+    private BigDecimal ReceivedYearTb;
+    /*当月收入*/
+    private BigDecimal ReceivedMonthTotal;
+    /*当月同比*/
+    private BigDecimal ReceivedMonthTb;
+    /*当月环比*/
+    private BigDecimal ReceivedMonthHb;
+}

+ 3 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/service/IndexService.java

@@ -5,6 +5,7 @@ import org.jeecg.modules.Index.entity.dto.IndexInfoParamDto;
 import org.jeecg.modules.Index.entity.vo.ContractDataInfoVo;
 import org.jeecg.modules.Index.entity.vo.IncomeDataInfoVo;
 import org.jeecg.modules.Index.entity.vo.LreDataInfoVo;
+import org.jeecg.modules.Index.entity.vo.ReceivedDataInfoVo;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
@@ -15,6 +16,8 @@ public interface IndexService {
 
     ContractDataInfoVo getTotalContract(HttpServletRequest request);
 
+    ReceivedDataInfoVo getTotalReceived(HttpServletRequest request);
+
     String getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto);
 
     /**

+ 160 - 2
module_kzks/src/main/java/org/jeecg/modules/Index/service/impl/IndexServiceImpl.java

@@ -11,6 +11,7 @@ import org.jeecg.modules.Index.entity.dto.IndexInfoParamDto;
 import org.jeecg.modules.Index.entity.vo.ContractDataInfoVo;
 import org.jeecg.modules.Index.entity.vo.IncomeDataInfoVo;
 import org.jeecg.modules.Index.entity.vo.LreDataInfoVo;
+import org.jeecg.modules.Index.entity.vo.ReceivedDataInfoVo;
 import org.jeecg.modules.Index.service.IndexService;
 import org.jeecg.modules.kyTaskInfo.service.IKyTaskInfoService;
 import org.jeecg.modules.projectCost.entity.ProjectCost;
@@ -80,6 +81,9 @@ public class IndexServiceImpl implements IndexService {
 
     private static final String CONTRACT_DATA_REDIS_KEY = "contractDataRedisKey:";
 
+    private static final String RECEIVED_DATA_REDIS_KEY = "receivedDataRedisKey:";
+
+
     @Override
     public IncomeDataInfoVo getTotalIncome(HttpServletRequest request) {
         //首页收入渲染对象
@@ -377,6 +381,154 @@ public class IndexServiceImpl implements IndexService {
     }
 
 
+    @Override
+    public ReceivedDataInfoVo getTotalReceived(HttpServletRequest request) {
+        BigDecimal initValue = BigDecimal.valueOf(0);
+        ReceivedDataInfoVo receivedDataInfoVo = new ReceivedDataInfoVo();
+        receivedDataInfoVo.setReceivedYearTotal(initValue);
+        receivedDataInfoVo.setReceivedYearTq(initValue);
+        receivedDataInfoVo.setReceivedYearTb(initValue);
+        receivedDataInfoVo.setReceivedMonthTotal(initValue);
+        receivedDataInfoVo.setReceivedMonthHb(initValue);
+        receivedDataInfoVo.setReceivedMonthTb(initValue);
+
+        String userNameByToken = JwtUtil.getUserNameByToken(request);
+        LoginUser sysUser = sysBaseApi.getUserByName(userNameByToken);
+
+        List<String> departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
+        if (departNames.isEmpty()) return receivedDataInfoVo;
+
+        StringBuilder stringBuilder = new StringBuilder();
+        for (String departName : departNames) {
+            stringBuilder.append(departName).append("|");
+        }
+        String depart = stringBuilder.toString();
+        ReceivedDataInfoVo cacheObject = (ReceivedDataInfoVo) redisUtil.get(RECEIVED_DATA_REDIS_KEY + depart);
+        if (ObjectUtils.isNotEmpty(cacheObject)) {
+            receivedDataInfoVo = cacheObject;
+            return receivedDataInfoVo;
+        }
+
+        ArrayList<String> tasknoList = new ArrayList<>();
+        List<String> ZrbmTasknoList = projectCostMapper.queryZrbmTasknoListbydepartNames(departNames);
+        List<String> XdbmTasknoList = projectCostMapper.queryXdbmTasknoListbydepartNames(departNames);
+        tasknoList.addAll(ZrbmTasknoList);
+        tasknoList.addAll(XdbmTasknoList);
+        if (tasknoList.isEmpty()) return receivedDataInfoVo;
+
+
+        Calendar instance = Calendar.getInstance();
+
+        Date currentYearEndDate = instance.getTime();
+        setZeroYear(instance);
+        Date currentYearBeginDate = instance.getTime();
+
+        List<BigDecimal> currentYearIncomeList = new ArrayList<>();
+        ReceivedDataInfoVo finalIncomeDataInfoVo = receivedDataInfoVo;
+        CompletableFuture.runAsync(() -> {
+            //根据年份和当前部门对应的任务号查询,部门当前年的年收入
+            BigDecimal currentYearTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, currentYearBeginDate, currentYearEndDate);
+            if (ObjectUtils.isEmpty(currentYearTotal)) currentYearTotal = BigDecimal.valueOf(0);
+            finalIncomeDataInfoVo.setReceivedYearTotal(currentYearTotal);
+            currentYearIncomeList.add(currentYearTotal);
+        }).join();
+
+        instance.setTime(new Date());
+        instance.add(Calendar.YEAR, -1);
+        //去年的今日
+        Date LastTqEndDate = instance.getTime();
+        setZeroYear(instance);
+        Date LastYearBeginDate = instance.getTime();
+
+        ArrayList<BigDecimal> lastYearTqIncomeList = new ArrayList<>();
+        //根据年份和当前部门对应的任务号查询,部门去年同期年收入
+        CompletableFuture.runAsync(() -> {
+            BigDecimal lastYearTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, LastYearBeginDate, LastTqEndDate);
+            if (ObjectUtils.isEmpty(lastYearTqTotal)) lastYearTqTotal = BigDecimal.valueOf(0);
+            finalIncomeDataInfoVo.setReceivedYearTq(lastYearTqTotal);
+            lastYearTqIncomeList.add(lastYearTqTotal);
+        }).join();
+
+
+        instance.setTime(new Date());
+        Date currentMothEndDate = instance.getTime();
+        setZeroMonth(instance);
+        Date currentMothBginDate = instance.getTime();
+
+        ArrayList<BigDecimal> currentMonthTotalList = new ArrayList<>();
+
+        CompletableFuture.runAsync(() -> {
+            BigDecimal currentMonthTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, currentMothBginDate, currentMothEndDate);
+            if (ObjectUtils.isEmpty(currentMonthTotal)) currentMonthTotal = BigDecimal.valueOf(0);
+            finalIncomeDataInfoVo.setReceivedMonthTotal(currentMonthTotal);
+            currentMonthTotalList.add(currentMonthTotal);
+        }).join();
+
+
+        instance.setTime(new Date());
+        instance.add(Calendar.MONTH, -1);
+        Date LastMothTqEndDate = instance.getTime();
+        setZeroMonth(instance);
+        Date LastMothTqBeginDate = instance.getTime();
+
+        ArrayList<BigDecimal> lastMothTqTotalList = new ArrayList<>();
+        CompletableFuture.runAsync(() -> {
+            BigDecimal lastMothTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, LastMothTqBeginDate, LastMothTqEndDate);
+            if (ObjectUtils.isEmpty(lastMothTqTotal)) lastMothTqTotal = BigDecimal.valueOf(0);
+            lastMothTqTotalList.add(lastMothTqTotal);
+        }).join();
+
+
+        instance.setTime(new Date());
+        instance.add(Calendar.YEAR, -1);
+        Date lastYearMonthTqEndDate = instance.getTime();
+        setZeroMonth(instance);
+        Date lastYearMonthTqBeginDate = instance.getTime();
+
+        ArrayList<BigDecimal> lastYearMonthTqTotalList = new ArrayList<>();
+        CompletableFuture.runAsync(() -> {
+            BigDecimal lastYearMonthTqTotal = exchangeMapper.getReceivedYearTotalByTasknoListAndByQsrqRange(tasknoList, lastYearMonthTqBeginDate, lastYearMonthTqEndDate);
+            if (ObjectUtils.isEmpty(lastYearMonthTqTotal)) lastYearMonthTqTotal = BigDecimal.valueOf(0);
+            lastYearMonthTqTotalList.add(lastYearMonthTqTotal);
+        }).join();
+
+
+        CompletableFuture.runAsync(() -> {
+            BigDecimal currentYearTotal = currentYearIncomeList.get(0);
+            BigDecimal lastYearTqTotal = lastYearTqIncomeList.get(0);
+            //去年同比
+            BigDecimal YearDifference = currentYearTotal.subtract(lastYearTqTotal);
+            BigDecimal incomeYearTb = BigDecimal.valueOf(1);
+            if (lastYearTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
+                incomeYearTb = YearDifference.divide(lastYearTqTotal, 2, RoundingMode.HALF_UP);
+            finalIncomeDataInfoVo.setReceivedYearTb(incomeYearTb);
+        }).join();
+
+        CompletableFuture.runAsync(() -> {
+            BigDecimal currentMonthTotal = currentMonthTotalList.get(0);
+            BigDecimal lastMothTqTotal = lastMothTqTotalList.get(0);
+            BigDecimal MothDifference = currentMonthTotal.subtract(lastMothTqTotal);
+            BigDecimal incomeMothHb = BigDecimal.valueOf(1);
+            if (lastMothTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
+                incomeMothHb = MothDifference.divide(lastMothTqTotal, 2, RoundingMode.HALF_UP);
+            finalIncomeDataInfoVo.setReceivedMonthHb(incomeMothHb);
+        }).join();
+
+        CompletableFuture.runAsync(() -> {
+            BigDecimal currentMonthTotal = currentMonthTotalList.get(0);
+            BigDecimal lastYearMonthTqTotal = lastYearMonthTqTotalList.get(0);
+            BigDecimal yearMothDifference = currentMonthTotal.subtract(lastYearMonthTqTotal);
+            BigDecimal incomeYearMothTb = BigDecimal.valueOf(1);
+            if (lastYearMonthTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
+                incomeYearMothTb = yearMothDifference.divide(lastYearMonthTqTotal, 2, RoundingMode.HALF_UP);
+            finalIncomeDataInfoVo.setReceivedMonthTb(incomeYearMothTb);
+        }).join();
+
+        redisUtil.set(RECEIVED_DATA_REDIS_KEY + depart, finalIncomeDataInfoVo, 1000L * 60 * 60 * 2);
+
+        return finalIncomeDataInfoVo;
+    }
+
     public void setZeroYear(Calendar instance) {
         instance.set(Calendar.MONTH, 0);
         instance.set(Calendar.DAY_OF_MONTH, 0);
@@ -401,6 +553,7 @@ public class IndexServiceImpl implements IndexService {
         switch (indexInfoParamDto.getTime()) {
             case "year":
                 resultl = getContractAmountInfoIfYear(request, indexInfoParamDto);
+                break;
             case "month":
                 resultl = getContractAmountInfoIfMonth(request, indexInfoParamDto);
             case "day":
@@ -414,20 +567,25 @@ public class IndexServiceImpl implements IndexService {
 
 
     public String getContractAmountInfoIfYear(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
+        Date beginDate = indexInfoParamDto.getBeginDate();
+        Date endDate = indexInfoParamDto.getEndDate();
+
 
 
         return null;
     }
 
     public String getContractAmountInfoIfMonth(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
-
+        Date beginDate = indexInfoParamDto.getBeginDate();
+        Date endDate = indexInfoParamDto.getEndDate();
 
         return null;
     }
 
 
     public String getContractAmountInfoIfDay(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
-
+        Date beginDate = indexInfoParamDto.getBeginDate();
+        Date endDate = indexInfoParamDto.getEndDate();
 
         return null;
     }

+ 2 - 0
module_kzks/src/main/java/org/jeecg/modules/xmcbDetail/mapper/ComContractInfoExchangeMapper.java

@@ -43,4 +43,6 @@ public interface ComContractInfoExchangeMapper extends BaseMapper<ComContractInf
     BigDecimal getIncomeYearTotalByTasknoListAndByQsrqRange(@Param("tasknoList") List<String> tasknoList, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
 
     BigDecimal getContractNumYearTotalByTasknoListAndByQsrqRange(@Param("tasknoList") List<String> tasknoList, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
+
+    BigDecimal getReceivedYearTotalByTasknoListAndByQsrqRange(@Param("tasknoList") List<String> tasknoList, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
 }

+ 15 - 2
module_kzks/src/main/java/org/jeecg/modules/xmcbDetail/mapper/xml/ComContractInfoExchangeMapper.xml

@@ -5,7 +5,8 @@
     <select id="getIncomeYearTotalByTasknoListAndByQsrqRange" resultType="java.math.BigDecimal">
         select sum(a.htfpe)
         from (select rwbh,htfpe,qsrq from com_contract_info_exchange where sjly = 20) a
-        where a.qsrq &gt; #{beginDate}
+        where a.qsrq = #{beginDate}
+        and a.qsrq &gt; #{beginDate}
         and a.qsrq &lt; #{endDate}
         and a.rwbh in
         <foreach item='item' index='index' collection='tasknoList' open='(' separator=',' close=')'>
@@ -15,7 +16,8 @@
     <select id="getContractNumYearTotalByTasknoListAndByQsrqRange" resultType="java.math.BigDecimal">
         select count(distinct(a.htbh))
         from (select rwbh,qsrq,htbh from com_contract_info_exchange where sjly = 20) a
-        where a.qsrq &gt; #{beginDate}
+        where a.qsrq = #{beginDate}
+        and a.qsrq &gt; #{beginDate}
         and a.qsrq &lt; #{endDate}
         and a.htbh is not null
         and a.rwbh in
@@ -23,4 +25,15 @@
             #{item}
         </foreach>
     </select>
+    <select id="getReceivedYearTotalByTasknoListAndByQsrqRange" resultType="java.math.BigDecimal">
+        select sum(a.rwskje)
+        from (select rwbh,dkhpdqrq,rwskje from com_contract_info_exchange where sjly = 40) a
+        where a.dkhpdqrq = #{beginDate}
+        and a.dkhpdqrq &gt; #{beginDate}
+        and a.dkhpdqrq &lt; #{endDate}
+        and a.rwbh in
+        <foreach item='item' index='index' collection='tasknoList' open='(' separator=',' close=')'>
+            #{item}
+        </foreach>
+    </select>
 </mapper>