Преглед изворни кода

index首页合同收入(修正)

longw пре 1 година
родитељ
комит
f79aec3522

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

@@ -3,7 +3,8 @@ package org.jeecg.modules.Index.controller;
 import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.modules.Index.entity.IncomeDataInfoVO;
+import org.jeecg.modules.Index.entity.ContractDataInfoVo;
+import org.jeecg.modules.Index.entity.IncomeDataInfoVo;
 import org.jeecg.modules.Index.service.IndexService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -21,10 +22,15 @@ public class IndexController {
     private IndexService indexService;
 
     @GetMapping("getTotalIncome")
-    public Result<IncomeDataInfoVO> getTotalIncome(HttpServletRequest request) {
-        IncomeDataInfoVO reslut = indexService.getTotalIncome(request);
+    public Result<IncomeDataInfoVo> getTotalIncome(HttpServletRequest request) {
+        IncomeDataInfoVo reslut = indexService.getTotalIncome(request);
         return Result.ok(reslut);
     }
 
 
+    @GetMapping("getTotalContract")
+    public Result<ContractDataInfoVo> getTotalContract(HttpServletRequest request) {
+        ContractDataInfoVo reslut = indexService.getTotalContract(request);
+        return Result.ok(reslut);
+    }
 }

+ 21 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/entity/ContractDataInfoVo.java

@@ -0,0 +1,21 @@
+package org.jeecg.modules.Index.entity;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class ContractDataInfoVo {
+    /*年总收入*/
+    private BigDecimal ContractYearTotal;
+    /*上年同期总收入*/
+    private BigDecimal ContractYearTq;
+    /*同比增长率*/
+    private BigDecimal ContractYearTb;
+    /*当月收入*/
+    private BigDecimal ContractMonthTotal;
+    /*当月同比*/
+    private BigDecimal ContractMonthTb;
+    /*当月环比*/
+    private BigDecimal ContractMonthHb;
+}

+ 1 - 1
module_kzks/src/main/java/org/jeecg/modules/Index/entity/IncomeDataInfoVO.java

@@ -5,7 +5,7 @@ import lombok.Data;
 import java.math.BigDecimal;
 
 @Data
-public class IncomeDataInfoVO {
+public class IncomeDataInfoVo {
 
     /*年总收入*/
     private BigDecimal IncomeYearTotal;

+ 5 - 2
module_kzks/src/main/java/org/jeecg/modules/Index/service/IndexService.java

@@ -1,9 +1,12 @@
 package org.jeecg.modules.Index.service;
 
-import org.jeecg.modules.Index.entity.IncomeDataInfoVO;
+import org.jeecg.modules.Index.entity.ContractDataInfoVo;
+import org.jeecg.modules.Index.entity.IncomeDataInfoVo;
 
 import javax.servlet.http.HttpServletRequest;
 
 public interface IndexService {
-    IncomeDataInfoVO getTotalIncome(HttpServletRequest request);
+    IncomeDataInfoVo getTotalIncome(HttpServletRequest request);
+
+    ContractDataInfoVo getTotalContract(HttpServletRequest request);
 }

+ 163 - 13
module_kzks/src/main/java/org/jeecg/modules/Index/service/impl/IndexServiceImpl.java

@@ -5,7 +5,8 @@ import org.jeecg.common.system.api.ISysBaseAPI;
 import org.jeecg.common.system.util.JwtUtil;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.RedisUtil;
-import org.jeecg.modules.Index.entity.IncomeDataInfoVO;
+import org.jeecg.modules.Index.entity.ContractDataInfoVo;
+import org.jeecg.modules.Index.entity.IncomeDataInfoVo;
 import org.jeecg.modules.Index.service.IndexService;
 import org.jeecg.modules.projectCost.mapper.ProjectCostMapper;
 import org.jeecg.modules.system.mapper.SysDepartMapper;
@@ -39,11 +40,13 @@ public class IndexServiceImpl implements IndexService {
 
     private static final String INCOME_DATA_REDIS_KEY = "incomeDataRedisKey:";
 
+    private static final String CONTRACT_DATA_REDIS_KEY = "contractDataRedisKey:";
+
     @Override
-    public IncomeDataInfoVO getTotalIncome(HttpServletRequest request) {
+    public IncomeDataInfoVo getTotalIncome(HttpServletRequest request) {
         //首页收入渲染对象
         BigDecimal initValue = BigDecimal.valueOf(0);
-        IncomeDataInfoVO incomeDataInfoVO = new IncomeDataInfoVO();
+        IncomeDataInfoVo incomeDataInfoVO = new IncomeDataInfoVo();
         incomeDataInfoVO.setIncomeYearTotal(initValue);
         incomeDataInfoVO.setIncomeYearTq(initValue);
         incomeDataInfoVO.setIncomeYearTb(initValue);
@@ -62,7 +65,7 @@ public class IndexServiceImpl implements IndexService {
             stringBuilder.append(departName).append("|");
         }
         String depart = stringBuilder.toString();
-        IncomeDataInfoVO cacheObject = (IncomeDataInfoVO)redisUtil.get(INCOME_DATA_REDIS_KEY + depart);
+        IncomeDataInfoVo cacheObject = (IncomeDataInfoVo) redisUtil.get(INCOME_DATA_REDIS_KEY + depart);
         if (ObjectUtils.isNotEmpty(cacheObject)) {
             incomeDataInfoVO = cacheObject;
             return incomeDataInfoVO;
@@ -83,12 +86,12 @@ public class IndexServiceImpl implements IndexService {
         Date currentYearBeginDate = instance.getTime();
 
         List<BigDecimal> currentYearIncomeList = new ArrayList<>();
-        IncomeDataInfoVO finalIncomeDataInfoVO = incomeDataInfoVO;
+        IncomeDataInfoVo finalIncomeDataInfoVo = incomeDataInfoVO;
         CompletableFuture.runAsync(() -> {
             //根据年份和当前部门对应的任务号查询,部门当前年的年收入
             BigDecimal currentYearTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRange(tasknoList, currentYearBeginDate, currentYearEndDate);
             if (ObjectUtils.isEmpty(currentYearTotal)) currentYearTotal = BigDecimal.valueOf(0);
-            finalIncomeDataInfoVO.setIncomeYearTotal(currentYearTotal);
+            finalIncomeDataInfoVo.setIncomeYearTotal(currentYearTotal);
             currentYearIncomeList.add(currentYearTotal);
         }).join();
 
@@ -104,7 +107,7 @@ public class IndexServiceImpl implements IndexService {
         CompletableFuture.runAsync(() -> {
             BigDecimal lastYearTqTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRange(tasknoList, LastYearBeginDate, LastTqEndDate);
             if (ObjectUtils.isEmpty(lastYearTqTotal)) lastYearTqTotal = BigDecimal.valueOf(0);
-            finalIncomeDataInfoVO.setIncomeYearTq(lastYearTqTotal);
+            finalIncomeDataInfoVo.setIncomeYearTq(lastYearTqTotal);
             lastYearTqIncomeList.add(lastYearTqTotal);
         }).join();
 
@@ -119,7 +122,7 @@ public class IndexServiceImpl implements IndexService {
         CompletableFuture.runAsync(() -> {
             BigDecimal currentMonthTotal = exchangeMapper.getIncomeYearTotalByTasknoListAndByQsrqRange(tasknoList, currentMothBginDate, currentMothEndDate);
             if (ObjectUtils.isEmpty(currentMonthTotal)) currentMonthTotal = BigDecimal.valueOf(0);
-            finalIncomeDataInfoVO.setIncomeMonthTotal(currentMonthTotal);
+            finalIncomeDataInfoVo.setIncomeMonthTotal(currentMonthTotal);
             currentMonthTotalList.add(currentMonthTotal);
         }).join();
 
@@ -160,7 +163,7 @@ public class IndexServiceImpl implements IndexService {
             BigDecimal incomeYearTb = BigDecimal.valueOf(1);
             if (lastYearTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
                 incomeYearTb = YearDifference.divide(lastYearTqTotal, 2, RoundingMode.HALF_UP);
-            finalIncomeDataInfoVO.setIncomeYearTb(incomeYearTb);
+            finalIncomeDataInfoVo.setIncomeYearTb(incomeYearTb);
         }).join();
 
         CompletableFuture.runAsync(() -> {
@@ -170,7 +173,7 @@ public class IndexServiceImpl implements IndexService {
             BigDecimal incomeMothHb = BigDecimal.valueOf(1);
             if (lastMothTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
                 incomeMothHb = MothDifference.divide(lastMothTqTotal, 2, RoundingMode.HALF_UP);
-            finalIncomeDataInfoVO.setIncomeMonthHb(incomeMothHb);
+            finalIncomeDataInfoVo.setIncomeMonthHb(incomeMothHb);
         }).join();
 
         CompletableFuture.runAsync(() -> {
@@ -180,12 +183,159 @@ public class IndexServiceImpl implements IndexService {
             BigDecimal incomeYearMothTb = BigDecimal.valueOf(1);
             if (lastYearMonthTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
                 incomeYearMothTb = yearMothDifference.divide(lastYearMonthTqTotal, 2, RoundingMode.HALF_UP);
-            finalIncomeDataInfoVO.setIncomeMonthTb(incomeYearMothTb);
+            finalIncomeDataInfoVo.setIncomeMonthTb(incomeYearMothTb);
+        }).join();
+
+        redisUtil.set(INCOME_DATA_REDIS_KEY + depart, finalIncomeDataInfoVo, 1000L * 60 * 60 * 2);
+
+        return finalIncomeDataInfoVo;
+    }
+
+    @Override
+    public ContractDataInfoVo getTotalContract(HttpServletRequest request) {
+        //首页收入渲染对象
+        BigDecimal initValue = BigDecimal.valueOf(0);
+        ContractDataInfoVo contractDataInfoVo = new ContractDataInfoVo();
+        contractDataInfoVo.setContractYearTotal(initValue);
+        contractDataInfoVo.setContractYearTq(initValue);
+        contractDataInfoVo.setContractYearTb(initValue);
+        contractDataInfoVo.setContractMonthTotal(initValue);
+        contractDataInfoVo.setContractMonthHb(initValue);
+        contractDataInfoVo.setContractMonthTb(initValue);
+
+        String userNameByToken = JwtUtil.getUserNameByToken(request);
+        LoginUser sysUser = sysBaseApi.getUserByName(userNameByToken);
+
+        List<String> departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
+        if (departNames.isEmpty()) return contractDataInfoVo;
+
+        StringBuilder stringBuilder = new StringBuilder();
+        for (String departName : departNames) {
+            stringBuilder.append(departName).append("|");
+        }
+        String depart = stringBuilder.toString();
+        ContractDataInfoVo cacheObject = (ContractDataInfoVo) redisUtil.get(CONTRACT_DATA_REDIS_KEY + depart);
+        if (ObjectUtils.isNotEmpty(cacheObject)) {
+            contractDataInfoVo = cacheObject;
+            return contractDataInfoVo;
+        }
+
+        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 contractDataInfoVo;
+
+        Calendar instance = Calendar.getInstance();
+
+        Date currentYearEndDate = instance.getTime();
+        setZeroYear(instance);
+        Date currentYearBeginDate = instance.getTime();
+
+        List<BigDecimal> currentYearIncomeList = new ArrayList<>();
+        ContractDataInfoVo finalContractDataInfoVo = contractDataInfoVo;
+        CompletableFuture.runAsync(() -> {
+            //根据年份和当前部门对应的任务号查询,部门当前年的年收入
+            BigDecimal currentYearTotal = exchangeMapper.getContractNumYearTotalByTasknoListAndByQsrqRange(tasknoList, currentYearBeginDate, currentYearEndDate);
+            if (ObjectUtils.isEmpty(currentYearTotal)) currentYearTotal = BigDecimal.valueOf(0);
+            finalContractDataInfoVo.setContractYearTotal(currentYearTotal);
+            currentYearIncomeList.add(currentYearTotal);
         }).join();
 
-        redisUtil.set(INCOME_DATA_REDIS_KEY + depart, finalIncomeDataInfoVO, 1000L * 60 * 60 * 2);
+        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.getContractNumYearTotalByTasknoListAndByQsrqRange(tasknoList, LastYearBeginDate, LastTqEndDate);
+            if (ObjectUtils.isEmpty(lastYearTqTotal)) lastYearTqTotal = BigDecimal.valueOf(0);
+            finalContractDataInfoVo.setContractYearTq(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.getContractNumYearTotalByTasknoListAndByQsrqRange(tasknoList, currentMothBginDate, currentMothEndDate);
+            if (ObjectUtils.isEmpty(currentMonthTotal)) currentMonthTotal = BigDecimal.valueOf(0);
+            finalContractDataInfoVo.setContractMonthTotal(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.getContractNumYearTotalByTasknoListAndByQsrqRange(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.getContractNumYearTotalByTasknoListAndByQsrqRange(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 contractYearTb = BigDecimal.valueOf(1);
+            if (lastYearTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
+                contractYearTb = YearDifference.divide(lastYearTqTotal, 2, RoundingMode.HALF_UP);
+            finalContractDataInfoVo.setContractYearTb(contractYearTb);
+        }).join();
+
+        CompletableFuture.runAsync(() -> {
+            BigDecimal currentMonthTotal = currentMonthTotalList.get(0);
+            BigDecimal lastMothTqTotal = lastMothTqTotalList.get(0);
+            BigDecimal MothDifference = currentMonthTotal.subtract(lastMothTqTotal);
+            BigDecimal contractMothHb = BigDecimal.valueOf(1);
+            if (lastMothTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
+                contractMothHb = MothDifference.divide(lastMothTqTotal, 2, RoundingMode.HALF_UP);
+            finalContractDataInfoVo.setContractMonthHb(contractMothHb);
+        }).join();
+
+        CompletableFuture.runAsync(() -> {
+            BigDecimal currentMonthTotal = currentMonthTotalList.get(0);
+            BigDecimal lastYearMonthTqTotal = lastYearMonthTqTotalList.get(0);
+            BigDecimal yearMothDifference = currentMonthTotal.subtract(lastYearMonthTqTotal);
+            BigDecimal contractYearMothTb = BigDecimal.valueOf(1);
+            if (lastYearMonthTqTotal.compareTo(BigDecimal.valueOf(0)) != 0)
+                contractYearMothTb = yearMothDifference.divide(lastYearMonthTqTotal, 2, RoundingMode.HALF_UP);
+            finalContractDataInfoVo.setContractMonthTb(contractYearMothTb);
+        }).join();
+
+        redisUtil.set(CONTRACT_DATA_REDIS_KEY + depart, finalContractDataInfoVo, 1000L * 60 * 60 * 2);
+
 
-        return finalIncomeDataInfoVO;
+        return finalContractDataInfoVo;
     }
 
     public void setZeroYear(Calendar instance) {

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

@@ -9,6 +9,7 @@ import org.jeecg.modules.xmcbDetail.vo.ComContractInfoExchangeHTEVO;
 import org.jeecg.modules.xmcbDetail.vo.ComContractInfoExchangeYSKVO;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -36,4 +37,6 @@ public interface ComContractInfoExchangeMapper extends BaseMapper<ComContractInf
     public List<ComContractInfoExchangeYSKVO> getCrmYskDetail(@Param("taskno") String taskno);
 
     BigDecimal getIncomeYearTotalByTasknoListAndByQsrqRange(@Param("tasknoList") List<String>   tasknoList,@Param("beginDate") Date beginDate,@Param("endDate") Date endDate);
+
+    BigDecimal getContractNumYearTotalByTasknoListAndByQsrqRange(ArrayList<String> tasknoList, Date currentYearBeginDate, Date currentYearEndDate);
 }

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

@@ -12,4 +12,15 @@
             #{item}
         </foreach>
     </select>
+    <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}
+        and a.qsrq &lt; #{endDate}
+        and a.htbh is not null
+        and a.rwbh in
+        <foreach item='item' index='index' collection='tasknoList' open='(' separator=',' close=')'>
+            #{item}
+        </foreach>
+    </select>
 </mapper>