Browse Source

已收款修正

longw 1 year ago
parent
commit
44cc1998d1

+ 37 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/ThreadPool/SingletonThreadPool.java

@@ -0,0 +1,37 @@
+package org.jeecg.modules.Index.ThreadPool;
+
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+public class SingletonThreadPool {
+    private static volatile SingletonThreadPool instance;
+    private final ThreadPoolExecutor executor;
+    private SingletonThreadPool() {
+        // 私有构造方法
+        int corePoolSize = 8; // 核心线程池大小
+        int maxPoolSize = 16; // 最大线程池大小
+        long keepAliveTime = 60L; // 线程空闲时间
+        TimeUnit unit = TimeUnit.SECONDS; // 线程空闲时间单位
+        BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<>(1000); // 任务队列
+        executor = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, unit, workQueue);
+    }
+    public static SingletonThreadPool getInstance() {
+        if (instance == null) {
+            synchronized (SingletonThreadPool.class) {
+                if (instance == null) {
+                    instance = new SingletonThreadPool();
+                }
+            }
+        }
+        return instance;
+    }
+    public ThreadPoolExecutor getExecutor() {
+        return executor;
+    }
+    public static ThreadPoolExecutor getNewExecutor(){
+        instance = null;
+        return getInstance().getExecutor();
+    }
+}

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

@@ -2,10 +2,12 @@ package org.jeecg.modules.Index.controller;
 
 import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.formula.functions.T;
 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.IndexChartInfoVo;
 import org.jeecg.modules.Index.entity.vo.ReceivedDataInfoVo;
 import org.jeecg.modules.Index.service.IndexService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,8 +45,7 @@ public class IndexController {
 
     @PostMapping("getContractAmountInfo")
     public Result<String> getContractAmountInfo(HttpServletRequest request, @RequestBody IndexInfoParamDto indexInfoParamDto) {
-        String result = indexService.getContractAmountInfo(request,indexInfoParamDto);
-        return Result.ok(result);
+        return Result.ok(indexService.getContractAmountInfo(request,indexInfoParamDto));
     }
 
 

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

@@ -9,7 +9,7 @@ public class IndexInfoParamDto {
 
 
     /*年/月*/
-    private String Time;
+    private String time;
 
     /*起始时间*/
     private String beginDate;

+ 19 - 0
module_kzks/src/main/java/org/jeecg/modules/Index/entity/pojo/ContractAmount.java

@@ -0,0 +1,19 @@
+package org.jeecg.modules.Index.entity.pojo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/*首页图表合同纵轴数据*/
+@Data
+public class ContractAmount {
+
+    /*合同额*/
+    private BigDecimal contractAmount;
+
+    /*合同数*/
+    private Long contractTotal;
+
+    /*年份或者月份*/
+    private String Date;
+}

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

@@ -10,8 +10,8 @@ import java.util.List;
 public class  IndexChartInfoVo<T> {
 
     /*横坐标集合*/
-    private List<String> XAxisData;
+    private List<String> xAxisData;
 
     /*纵坐标集合*/
-    private List<T> SeriesData;
+    private List<T> seriesData;
 }

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

@@ -1,11 +1,9 @@
 package org.jeecg.modules.Index.service;
 
+import org.apache.poi.ss.formula.functions.T;
 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.LreDataInfoVo;
-import org.jeecg.modules.Index.entity.vo.ReceivedDataInfoVo;
+import org.jeecg.modules.Index.entity.vo.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
@@ -18,7 +16,7 @@ public interface IndexService {
 
     ReceivedDataInfoVo getTotalReceived(HttpServletRequest request);
 
-    String getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto);
+   String getContractAmountInfo(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto);
 
     /**
      * 通过登录的用户找到相应的部门,可能一个或两个

+ 82 - 10
module_kzks/src/main/java/org/jeecg/modules/Index/service/impl/IndexServiceImpl.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.Index.service.impl;
 
+import com.alibaba.fastjson2.JSONObject;
+import com.alibaba.fastjson2.TypeReference;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
@@ -8,10 +10,8 @@ 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.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.entity.pojo.ContractAmount;
+import org.jeecg.modules.Index.entity.vo.*;
 import org.jeecg.modules.Index.service.IndexService;
 import org.jeecg.modules.kyTaskInfo.service.IKyTaskInfoService;
 import org.jeecg.modules.projectCost.entity.ProjectCost;
@@ -27,6 +27,8 @@ import org.springframework.stereotype.Service;
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
 
@@ -83,6 +85,11 @@ public class IndexServiceImpl implements IndexService {
 
     private static final String RECEIVED_DATA_REDIS_KEY = "receivedDataRedisKey:";
 
+    private static final String CONTRACT_AMOUNT_VO_DATA_REDIS_KEY = "ContractAmountVoDataRedisKey:";
+
+    private static final String YEAR = "year";
+
+    private static final String MONTH = "month";
 
     @Override
     public IncomeDataInfoVo getTotalIncome(HttpServletRequest request) {
@@ -556,8 +563,6 @@ public class IndexServiceImpl implements IndexService {
                 break;
             case "month":
                 resultl = getContractAmountInfoIfMonth(request, indexInfoParamDto);
-            case "day":
-                resultl = getContractAmountInfoIfDay(request, indexInfoParamDto);
             default:
                 resultl = null;
         }
@@ -567,22 +572,89 @@ public class IndexServiceImpl implements IndexService {
 
 
     public String getContractAmountInfoIfYear(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
+        IndexChartInfoVo<ContractAmountVo> resVo = new IndexChartInfoVo<>();
+        Date beginDate = dateFormat(indexInfoParamDto.getBeginDate(), YEAR);
+        Date endDate = dateFormat(indexInfoParamDto.getEndDate(), YEAR);
+        endDate = endDateProcess(endDate, YEAR);
+
+        String userNameByToken = JwtUtil.getUserNameByToken(request);
+        LoginUser sysUser = sysBaseApi.getUserByName(userNameByToken);
+
+        List<String> departNames = sysDepartMapper.getSysUserOfDepartNameList(sysUser.getId());
+        if (departNames.isEmpty()) return JSONObject.toJSONString(resVo);
+
+        StringBuilder stringBuilder = new StringBuilder();
+        for (String departName : departNames) {
+            stringBuilder.append(departName).append("|");
+        }
+        String depart = stringBuilder.toString();
+        Object cacheObject = redisUtil.get(RECEIVED_DATA_REDIS_KEY + depart);
+        IndexChartInfoVo<ContractAmountVo> Object = JSONObject.parseObject(JSONObject.toJSONString(cacheObject), new TypeReference<IndexChartInfoVo<ContractAmountVo>>() {
+        });
+        if (ObjectUtils.isNotEmpty(cacheObject)) {
+            resVo = Object;
+            return JSONObject.toJSONString(resVo);
+        }
+
+        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 JSONObject.toJSONString(resVo);
+
+        List<ContractAmount> contractAmount = exchangeMapper.getContractAmountandNumByYear(tasknoList,beginDate,endDate);
+
+
+
+
+
 
 
 
-        return null;
-    }
 
-    public String getContractAmountInfoIfMonth(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
 
 
         return null;
     }
 
+    public String getContractAmountInfoIfMonth(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
+        IndexChartInfoVo<ContractAmountVo> resVo = new IndexChartInfoVo<>();
+        Date beginDate = dateFormat(indexInfoParamDto.getBeginDate(), "month");
+        Date endDate = dateFormat(indexInfoParamDto.getEndDate(), "month");
+        endDate = endDateProcess(endDate, "month");
 
-    public String getContractAmountInfoIfDay(HttpServletRequest request, IndexInfoParamDto indexInfoParamDto) {
+        return null;
+    }
 
+    public Date endDateProcess(Date endDate, String time) {
+        Calendar instance = Calendar.getInstance();
+        instance.setTime(endDate);
+        if ("year".equals(time)) {
+            instance.add(Calendar.YEAR, 1);
+        } else if ("month".equals(time)) {
+            instance.add(Calendar.MONTH, 1);
+        }
+        return instance.getTime();
+    }
 
+    public Date dateFormat(String DateString, String time) {
+        switch (time) {
+            case "year":
+                SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");
+                try {
+                    return yearFormat.parse(DateString);
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+            case "month":
+                SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-MM");
+                try {
+                    return monthFormat.parse(DateString);
+                } catch (ParseException e) {
+                    throw new RuntimeException(e);
+                }
+        }
         return null;
     }
 

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
+import org.jeecg.modules.Index.entity.pojo.ContractAmount;
 import org.jeecg.modules.xmcbDetail.entity.ComContractInfoExchange;
 import org.jeecg.modules.xmcbDetail.vo.ComContractInfoExchangeHTEVO;
 import org.jeecg.modules.xmcbDetail.vo.ComContractInfoExchangeYSKVO;
@@ -45,4 +46,6 @@ public interface ComContractInfoExchangeMapper extends BaseMapper<ComContractInf
     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);
+
+    List<ContractAmount> getContractAmountandNumByYear(@Param("tasknoList") List<String> tasknoList, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
 }

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

@@ -33,4 +33,15 @@
             #{item}
         </foreach>
     </select>
+    <select id="getContractAmountandNumByYear" resultType="org.jeecg.modules.Index.entity.pojo.ContractAmount">
+        select sum(a.htfpe),count(distinct(a.htbh)),YEAR(qsrq)
+        from (select rwbh,htfpe,qsrq,htbh from com_contract_info_exchange where sjly = 20) a
+        where a.qsrq between #{beginDate}
+        and #{endDate}
+        and a.rwbh in
+        <foreach item='item' index='index' collection='tasknoList' open='(' separator=',' close=')'>
+            #{item}
+        </foreach>
+        GROUP BY YEAR(qsrq);
+    </select>
 </mapper>