Browse Source

查询指定部门或者自己及下级部门

buzhanyi 2 years ago
parent
commit
bdf9f45edf

+ 0 - 1
purchase-admin/src/main/java/com/ozs/web/controller/statisticalAnalysis/StatisticalAnalysisController.java

@@ -16,7 +16,6 @@ import org.apache.poi.util.Units;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.apache.poi.xwpf.usermodel.XWPFParagraph;
 import org.apache.poi.xwpf.usermodel.XWPFRun;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;

+ 2 - 0
purchase-system/src/main/java/com/ozs/pm/doman/vo/requestVo/PmDemandReqVo.java

@@ -126,4 +126,6 @@ public class PmDemandReqVo extends PageVo {
 
     private Long userId;
     private Boolean isAdmin;
+    //查询全部or指定部门
+    List<Integer> deptList;
 }

+ 35 - 35
purchase-system/src/main/java/com/ozs/pm/mapper/PmDemandMapper.java

@@ -43,7 +43,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    Map<String, Integer> purchaseProjectStatistical(PmDemandReqVo pmDemandReqVo);
+    Map<String, Integer> purchaseProjectStatistical(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 统计分析-采购项目信息统计-查询已完成项目数量,预算金额数量
@@ -51,7 +51,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    Map<String, Integer> purchaseProjectStatisticalYWC(PmDemandReqVo pmDemandReqVo);
+    Map<String, Integer> purchaseProjectStatisticalYWC(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 统计分析-采购项目信息统计-查询新创建项目数量,预算金额数量
@@ -59,7 +59,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    Map<String, Integer> purchaseProjectStatisticalXCJ(PmDemandReqVo pmDemandReqVo);
+    Map<String, Integer> purchaseProjectStatisticalXCJ(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 统计分析-采购项目信息统计-查询去年完成项目数量,预算金额数量
@@ -67,74 +67,74 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    Map<String, Integer> purchaseProjectStatisticalQNWC(PmDemandReqVo pmDemandReqVo);
+    Map<String, Integer> purchaseProjectStatisticalQNWC(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 按照项目属性统计所有的项目
      *
      * @return
      */
-    List<StatisticalChartsResVo> countByProjectAttr(PmDemandReqVo pmDemandReqVo);
+    List<StatisticalChartsResVo> countByProjectAttr(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 按照采购方式统计所有的项目
      *
      * @return
      */
-    List<StatisticalChartsResVo> countByPurchaseMode(PmDemandReqVo pmDemandReqVo);
+    List<StatisticalChartsResVo> countByPurchaseMode(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 按照概算金额统计所有的项目
      *
      * @return
      */
-    StatisticalChartsResVo countByEvaluationLt(PmDemandReqVo pmDemandReqVo);
+    StatisticalChartsResVo countByEvaluationLt(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
-    StatisticalChartsResVo countByEvaluationBet(PmDemandReqVo pmDemandReqVo);
+    StatisticalChartsResVo countByEvaluationBet(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
-    StatisticalChartsResVo countByEvaluationGt(PmDemandReqVo pmDemandReqVo);
+    StatisticalChartsResVo countByEvaluationGt(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 本年度所有的逾期项目数
      *
      * @return
      */
-    StatisticalChartsResVo countProjectExceed(PmDemandReqVo pmDemandReqVo);
+    StatisticalChartsResVo countProjectExceed(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 年度逾期项目数量
      *
      * @return
      */
-    Integer countThisYear(PmDemandReqVo pmDemandReqVo);
+    Integer countThisYear(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 统计不同时间维度的逾期项目
      *
      * @return
      */
-    LinkedList<StatisticalChartsResVo> countProjectExceedYear(PmDemandReqVo pmDemandReqVo);
+    LinkedList<StatisticalChartsResVo> countProjectExceedYear(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 统计不同时间维度的逾期项目
      *
      * @return
      */
-    StatisticalChartsResVo countProjectExceedMonth(PmDemandReqVo pmDemandReqVo);
+    StatisticalChartsResVo countProjectExceedMonth(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 统计不同时间维度的逾期项目
      *
      * @return
      */
-    StatisticalChartsResVo countProjectExceedQuarter(PmDemandReqVo pmDemandReqVo);
+    StatisticalChartsResVo countProjectExceedQuarter(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 所有滞后
      *
      * @return
      */
-    List<PmDemand> countProjectExceedAll(PmDemandReqVo pmDemandReqVo);
+    List<PmDemand> countProjectExceedAll(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * //***状态:指本年度正在进行中的项目属性为“重大规划”的项目数
@@ -143,7 +143,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param
      * @return
      */
-    StatisticalChartsResVo majorProjectByStatus(PmDemandReqVo pmDemandReqVo);
+    StatisticalChartsResVo majorProjectByStatus(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * //执行滞后数量:指本年度逾期项目中,项目属性为“重大规划”的项目数
@@ -166,7 +166,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
     /**
      * @return
      */
-    List<StatisticalChartsResVo> countEveryStatusNum(PmDemandReqVo pmDemandReqVo);
+    List<StatisticalChartsResVo> countEveryStatusNum(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 通过计划ID查询项目
@@ -182,7 +182,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    Map<String, Integer> purchaseProjectExecuteNormalPropulsion(PmDemandReqVo pmDemandReqVo);
+    Map<String, Integer> purchaseProjectExecuteNormalPropulsion(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 项目执行进度统计--未完成采购任务,预算金额
@@ -190,7 +190,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    Map<String, Integer> purchaseProjectExecuteIncomplete(PmDemandReqVo pmDemandReqVo);
+    Map<String, Integer> purchaseProjectExecuteIncomplete(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 查询数据库年份最小值
@@ -205,7 +205,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    List<Map<String, Integer>> selectpurchaseProjectCompleteNumberYear(PmDemandReqVo pmDemandReqVo);
+    List<Map<String, Integer>> selectpurchaseProjectCompleteNumberYear(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 已完成项目数量统计 -- 季度
@@ -213,7 +213,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    List<Map<String, Integer>> selectpurchaseProjectCompleteNumberQuarter(PmDemandReqVo pmDemandReqVo);
+    List<Map<String, Integer>> selectpurchaseProjectCompleteNumberQuarter(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 已完成项目数量统计 -- 月份
@@ -221,7 +221,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    List<Map<String, Integer>> selectpurchaseProjectCompleteNumberMonth(PmDemandReqVo pmDemandReqVo);
+    List<Map<String, Integer>> selectpurchaseProjectCompleteNumberMonth(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 已完成采购任务数量统计 -- 年份
@@ -229,7 +229,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    List<Map<String, Integer>> selectPurchaseTaskFinishYear(PmDemandReqVo pmDemandReqVo);
+    List<Map<String, Integer>> selectPurchaseTaskFinishYear(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 已完成采购任务数量统计 -- 季度
@@ -237,7 +237,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    List<Map<String, Integer>> selectPurchaseTaskFinishQuarter(PmDemandReqVo pmDemandReqVo);
+    List<Map<String, Integer>> selectPurchaseTaskFinishQuarter(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 已完成采购任务数量统计 -- 月份
@@ -245,19 +245,19 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    List<Map<String, Integer>> selectPurchaseTaskFinishMonth(PmDemandReqVo pmDemandReqVo);
+    List<Map<String, Integer>> selectPurchaseTaskFinishMonth(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
-    List<StatisticalChartsResVo> countProjectMajorByYear();
+    List<StatisticalChartsResVo> countProjectMajorByYear(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
-    StatisticalChartsResVo countProjectMajorByQuarter(PmDemandReqVo pmDemandReqVo);
+    StatisticalChartsResVo countProjectMajorByQuarter(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
-    List<StatisticalChartsResVo> countProjectMajorByMonth(PmDemandReqVo pmDemandReqVo);
+    List<StatisticalChartsResVo> countProjectMajorByMonth(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     List<StatisticalChartsResVo> countEveryStatusNumTwo();
 
-    StatisticalChartsResVo countMajorProjectExceed(PmDemandReqVo pmDemandReqVo);
+    StatisticalChartsResVo countMajorProjectExceed(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
-    StatisticalChartsResVo countMajorProjectLastYear(PmDemandReqVo pmDemandReqVo);
+    StatisticalChartsResVo countMajorProjectLastYear(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 各阶段项目数量分布
@@ -265,7 +265,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    Map<String, String> purchaseProjectDistribution(PmDemandReqVo pmDemandReqVo);
+    Map<String, String> purchaseProjectDistribution(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 项目数量分析--年
@@ -273,7 +273,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    List<Map<String, String>> purchaseProjectNumberAnalysisYear(PmDemandReqVo pmDemandReqVo);
+    List<Map<String, String>> purchaseProjectNumberAnalysisYear(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 项目数量分析--季度
@@ -281,7 +281,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    List<Map<String, String>> purchaseProjectNumberAnalysisQuarter(PmDemandReqVo pmDemandReqVo);
+    List<Map<String, String>> purchaseProjectNumberAnalysisQuarter(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 项目数量分析--月份
@@ -289,7 +289,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    List<Map<String, String>> purchaseProjectNumberAnalysisMonth(PmDemandReqVo pmDemandReqVo);
+    List<Map<String, String>> purchaseProjectNumberAnalysisMonth(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 项目数量分析--季度  去年数据
@@ -297,7 +297,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    List<Map<String, String>> purchaseProjectNumberAnalysisOldYearQuarter(PmDemandReqVo pmDemandReqVo);
+    List<Map<String, String>> purchaseProjectNumberAnalysisOldYearQuarter(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 项目数量分析--月份  去年数据

+ 71 - 6
purchase-system/src/main/java/com/ozs/pm/service/impl/PmDemandServiceImpl.java

@@ -18,6 +18,7 @@ import com.ozs.base.domain.vo.BaseExpertVo;
 import com.ozs.base.mapper.BaseExpertMapper;
 import com.ozs.base.service.*;
 import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.common.core.domain.TreeSelect;
 import com.ozs.common.core.domain.entity.*;
 import com.ozs.common.enums.*;
 import com.ozs.common.utils.DateUtils;
@@ -1144,21 +1145,21 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
         //从子列表中随机抽取符合数据量的
 
         List<BaseExpert> alltExpertList = new ArrayList<>();
-        if(technicalExpertNumber > 0 && technicalExpertList.size() < technicalExpertNumber){
+        if (technicalExpertNumber > 0 && technicalExpertList.size() < technicalExpertNumber) {
             throw new Exception("抽取到符合条件的技术专家数量不够");
         }
         if (!ObjectUtils.isEmpty(technicalExpertList)) {
             alltExpertList.addAll(RandomUtil.getRandomList(technicalExpertList, technicalExpertNumber));
         }
 
-        if(economicExpertNumber > 0 && economicExpertList.size() < economicExpertNumber){
+        if (economicExpertNumber > 0 && economicExpertList.size() < economicExpertNumber) {
             throw new Exception("抽取到符合条件的经济专家数量不够");
         }
         if (!ObjectUtils.isEmpty(economicExpertList)) {
             alltExpertList.addAll(RandomUtil.getRandomList(economicExpertList, economicExpertNumber));
         }
 
-        if(legalAffairsExpertNumber > 0 && legalAffairsExpertList.size() < legalAffairsExpertNumber){
+        if (legalAffairsExpertNumber > 0 && legalAffairsExpertList.size() < legalAffairsExpertNumber) {
             throw new Exception("抽取到符合条件的法务专家数量不够");
         }
         if (!ObjectUtils.isEmpty(legalAffairsExpertList)) {
@@ -1188,7 +1189,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
                 alltExpertList.addAll(RandomUtil.getRandomList(spareExpertListNew, spareExpertNumber));
             }
         }
-        if(spareExpertNumber > 0 && spareExpertListNew.size() < spareExpertNumber){
+        if (spareExpertNumber > 0 && spareExpertListNew.size() < spareExpertNumber) {
             throw new Exception("抽取到符合条件的备用专家数量不够");
         }
 
@@ -1772,6 +1773,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
      */
     @Override
     public Map<String, Integer> purchaseProjectStatistical(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         Map<String, Integer> mapReturn = new HashMap<>();
         // 查询项目总数量
         Map<String, Integer> mapCount = pmDemandMapper.purchaseProjectStatistical(pmDemandReqVo);
@@ -1790,6 +1793,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
     @Override
     public List<StatisticalChartsResVo> countByProjectAttr(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         List<StatisticalChartsResVo> resVos = pmDemandMapper.countByProjectAttr(pmDemandReqVo);
         for (StatisticalChartsResVo chartsResVo : resVos) {
             for (PmProjectStatus value : PmProjectStatus.values()) {
@@ -1804,6 +1809,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
     @Override
     public List<StatisticalChartsResVo> countByPurchaseMode(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         List<StatisticalChartsResVo> resVos = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
         for (StatisticalChartsResVo chartsResVo : resVos) {
             for (ProcurementMethodSuggest value : ProcurementMethodSuggest.values()) {
@@ -1818,6 +1825,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
     @Override
     public List<StatisticalChartsResVo> countByEvaluation(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
         pmDemandReqVo.setEvaluation(100);
@@ -1853,6 +1862,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
     @Override
     public AjaxResult countProjectExceed(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         HashMap<String, String> resMap = new HashMap<>();
         //执行滞后采购项目:本年度所有的逾期项目数
         //预算金额:本年度所有逾期项目累加的预算金额
@@ -1872,6 +1883,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
      */
     @Override
     public AjaxResult exceedAnalysis(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
         List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectExceedYear(pmDemandReqVo);
         if (pmDemandReqVo.getTimeType().equals("1")) {
@@ -1916,9 +1929,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
     @Override
     public AjaxResult taskQuantityAnalysis(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
         //任务数量趋势分析:按照月、季度、年统计“项目属性”字段中“重大规划”属性的项目
-        List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectMajorByYear();
+        List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectMajorByYear(pmDemandReqVo);
         if (pmDemandReqVo.getTimeType().equals("1")) {
             resMap.put("年", byYear);
         } else if (pmDemandReqVo.getTimeType().equals("2")) {
@@ -1944,6 +1959,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public AjaxResult countEveryStatusNum(PmDemandReqVo pmDemandReqVo) {
         //指项目进行到各个阶段的数量
         //阶段包括:待选取代理、待上传招标文件、待发布公告、待开标、待发布中标公告、中标公式中
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         List<StatisticalChartsResVo> everyStatusNum = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
         if (!ObjectUtils.isEmpty(everyStatusNum) && everyStatusNum.size() > 0) {
             for (StatisticalChartsResVo vo : everyStatusNum) {
@@ -1976,6 +1993,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
     @Override
     public AjaxResult exceedMarketAnalysis(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         //所有滞后
         List<PmDemand> demandList = pmDemandMapper.countProjectExceedAll(pmDemandReqVo);
         //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
@@ -2019,6 +2038,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
     @Override
     public AjaxResult countMajorProject(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //数量:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目数
         //预算金额:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目累加的预算金额
@@ -2077,6 +2098,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
      */
     @Override
     public Map<String, Integer> purchaseProjectExecute(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         Map<String, Integer> mapReturn = new HashMap<>();
         // 正常推进项目数量、预算金额
         Map<String, Integer> mapNormalPropulsion = pmDemandMapper.purchaseProjectExecuteNormalPropulsion(pmDemandReqVo);
@@ -2095,6 +2118,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
      */
     @Override
     public List<Map<String, Integer>> purchaseProjectCompleteNumber(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         List<Map<String, Integer>> mapReturn = new ArrayList<>();
         // 统计时间类型 1:年度,2:季度,3:月份
         if ("1".equals(pmDemandReqVo.getTimeType())) {
@@ -2176,6 +2201,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
      */
     @Override
     public List<Map<String, Integer>> purchaseTaskFinish(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         List<Map<String, Integer>> mapReturn = new ArrayList<>();
         // 统计时间类型 1:年度,2:季度,3:月份
         if ("1".equals(pmDemandReqVo.getTimeType())) {
@@ -2257,6 +2284,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
      */
     @Override
     public List<Map<String, String>> purchaseProjectDistribution(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         // 项目计划 4之前(包括4)
         List<String> xmjh = new ArrayList<>();
         xmjh.add("4");
@@ -2320,6 +2349,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
      */
     @Override
     public List<Map<String, String>> purchaseProjectNumberAnalysis(PmDemandReqVo pmDemandReqVo) {
+        //是-1就是查询自己及子孙级以下,否则只查询指定部门
+        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
         List<Map<String, String>> mapReturn = new ArrayList<>();
         // 统计时间类型 1:年度,2:季度,3:月份
         if ("1".equals(pmDemandReqVo.getTimeType())) {
@@ -3114,7 +3145,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
                 if (vo.getTipsMessage().contains("超过")) {
                     vo.setIsExceedProject("1");
                     if (ObjectUtils.isEmpty(pmDemand1.getDelayReason())) {
-                       //没有原因就可以填写滞后原因
+                        //没有原因就可以填写滞后原因
                         vo.setIsWriteExceed("1");
                     }
                 }
@@ -3164,4 +3195,38 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
         DecimalFormat decimalFormat = new DecimalFormat("##.00%");
         return decimalFormat.format(d1 / d2);
     }
+
+    //查询本单位还是本单位及子孙级
+    public List<Integer> isQueryAll(Integer queryAll) {
+        List<Integer> deptList = new ArrayList<>();
+        //查询全部
+        if (queryAll.equals(-1)) {
+            Long deptId = SecurityUtils.getDeptId();
+            //获取到子孙级部门id
+            if (deptService.hasChildByDeptId(deptId)) {
+                List<Integer> children = getDeptChildren(deptId);
+                System.err.println(children.size());
+                deptList.addAll(children);
+            }
+            //指定部门
+        } else {
+            deptList.add(queryAll);
+        }
+        return deptList;
+    }
+
+    //获取到子孙级部门id
+    public List<Integer> getDeptChildren(Long deptId) {
+        List<Integer> deptList = new ArrayList<>();
+        Long did = Long.valueOf(deptId);
+        List<Long> childByDeptId = deptService.getChildIdByDeptId(did);
+        for (Long cid : childByDeptId) {
+            deptList.add(Math.toIntExact(cid));
+            if (deptService.hasChildByDeptId(cid)) {
+                deptList.addAll(getDeptChildren(cid));
+            }
+        }
+        return deptList;
+    }
+
 }

+ 11 - 3
purchase-system/src/main/java/com/ozs/system/mapper/SysDeptMapper.java

@@ -1,6 +1,7 @@
 package com.ozs.system.mapper;
 
 import java.util.List;
+
 import org.apache.ibatis.annotations.Param;
 import com.ozs.common.core.domain.entity.SysDept;
 
@@ -9,8 +10,7 @@ import com.ozs.common.core.domain.entity.SysDept;
  *
  * @author ruoyi
  */
-public interface SysDeptMapper
-{
+public interface SysDeptMapper {
     /**
      * 查询部门管理数据
      *
@@ -22,7 +22,7 @@ public interface SysDeptMapper
     /**
      * 根据角色ID查询部门树信息
      *
-     * @param roleId 角色ID
+     * @param roleId            角色ID
      * @param deptCheckStrictly 部门树选择项是否关联显示
      * @return 选中部门列表
      */
@@ -60,6 +60,14 @@ public interface SysDeptMapper
      */
     public int hasChildByDeptId(Long deptId);
 
+    /**
+     * 获取所有子孙节点id
+     *
+     * @param deptId 部门ID
+     * @return 结果
+     */
+    public List<Long> getChildIdByDeptId(Long deptId);
+
     /**
      * 查询部门是否存在用户
      *

+ 8 - 0
purchase-system/src/main/java/com/ozs/system/service/ISysDeptService.java

@@ -77,6 +77,14 @@ public interface ISysDeptService {
      */
     public boolean hasChildByDeptId(Long deptId);
 
+    /**
+     * 获取所有子孙节点id
+     *
+     * @param deptId 部门ID
+     * @return 结果
+     */
+    public List<Long> getChildIdByDeptId(Long deptId);
+
     /**
      * 查询部门是否存在用户
      *

+ 11 - 0
purchase-system/src/main/java/com/ozs/system/service/impl/SysDeptServiceImpl.java

@@ -170,6 +170,17 @@ public class SysDeptServiceImpl implements ISysDeptService {
         return result > 0;
     }
 
+    /**
+     * 获取所有子孙节点id
+     *
+     * @param deptId 部门ID
+     * @return 结果
+     */
+    @Override
+    public List<Long> getChildIdByDeptId(Long deptId) {
+        return deptMapper.getChildIdByDeptId(deptId);
+    }
+
     /**
      * 查询部门是否存在用户
      *

+ 307 - 166
purchase-system/src/main/resources/mapper/pm/PmDemandMapper.xml

@@ -29,17 +29,25 @@
             resultType="java.util.Map">
         select count(demand_id) countId
         from pm_demand
-        WHERE purchase_dept_id = #{purchaseDeptId}
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
     </select>
 
     <select id="purchaseProjectStatisticalYWC" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
         select count(d.demand_id) countYWC, ifnull(sum(c.contract_amount), 0) evaluationYWC
         from pm_demand d
-                 LEFT JOIN pm_contract_info c
-                           ON d.demand_id = c.demand_id
-                               AND d.purchase_dept_id = #{purchaseDeptId}
-                               AND d.project_status = '17'
+        LEFT JOIN pm_contract_info c
+        ON d.demand_id = c.demand_id
+        AND d.purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND d.project_status = '17'
     </select>
 
     <select id="purchaseProjectStatisticalXCJ" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
@@ -47,9 +55,13 @@
         -- DATE_FORMAT(plan_demand_sub_time,'%Y')
         select count(demand_id) countXCJ, ifnull(sum(evaluation), 0) evaluationXCJ
         from pm_demand
-        where purchase_dept_id = #{purchaseDeptId}
-          AND project_status != '17'
-          and year(plan_demand_sub_time) = year(NOW())
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND project_status != '17'
+        and year(plan_demand_sub_time) = year(NOW())
     </select>
 
     <select id="purchaseProjectStatisticalQNWC" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
@@ -57,17 +69,25 @@
         -- DATE_FORMAT(plan_demand_sub_time,'%Y')
         select count(d.demand_id) countYWC, ifnull(sum(c.contract_amount), 0) evaluationQNWC
         from pm_demand d
-                 LEFT JOIN pm_contract_info c
-                           ON d.demand_id = c.demand_id
-                               AND d.purchase_dept_id = #{purchaseDeptId}
-                               AND d.project_status = '17'
+        LEFT JOIN pm_contract_info c
+        ON d.demand_id = c.demand_id
+        AND d.purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND d.project_status = '17'
     </select>
 
     <select id="countByProjectAttr" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT project_status columnName, COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
         GROUP BY project_status
     </select>
 
@@ -75,7 +95,11 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT purchase_mode columnName, COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
         GROUP BY purchase_mode
     </select>
 
@@ -83,52 +107,76 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND evaluation &lt; #{evaluation}
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND evaluation &lt; #{evaluation}
     </select>
 
     <select id="countByEvaluationBet" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND evaluation BETWEEN #{evaluation} and #{evaluationEnd}
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND evaluation BETWEEN #{evaluation} and #{evaluationEnd}
     </select>
     <select id="countByEvaluationGt" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND evaluation &gt; #{evaluation}
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND evaluation &gt; #{evaluation}
     </select>
 
     <select id="countProjectExceed" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND (real_demand_commit_time > plan_demand_sub_time
-            or real_purchase_finish_time > plan_purchase_finish_time
-            or real_deliver_time > plan_deliver_time)
-          and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND (real_demand_commit_time > plan_demand_sub_time
+        or real_purchase_finish_time > plan_purchase_finish_time
+        or real_deliver_time > plan_deliver_time)
+        and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
     </select>
 
     <select id="countThisYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.lang.Integer">
         SELECT COUNT(demand_id) num
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
     </select>
 
     <select id="countProjectExceedYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT DATE_FORMAT(create_time, '%Y') columnName, COUNT(demand_id) num
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND (real_demand_commit_time > plan_demand_sub_time
-            or real_purchase_finish_time > plan_purchase_finish_time
-            or real_deliver_time > plan_deliver_time)
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND (real_demand_commit_time > plan_demand_sub_time
+        or real_purchase_finish_time > plan_purchase_finish_time
+        or real_deliver_time > plan_deliver_time)
         GROUP BY DATE_FORMAT(create_time, '%Y')
         order by create_time asc
     </select>
@@ -137,14 +185,18 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT DATE_FORMAT(create_time, '%Y-%m') columnName, COUNT(demand_id) num
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND (real_demand_commit_time > plan_demand_sub_time
-            or real_purchase_finish_time > plan_purchase_finish_time
-            or real_deliver_time > plan_deliver_time)
-          and MONTH(
-                      create_time) = #{month}
-          AND DATE_FORMAT(create_time
-                  , '%Y') = #{year}
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND (real_demand_commit_time > plan_demand_sub_time
+        or real_purchase_finish_time > plan_purchase_finish_time
+        or real_deliver_time > plan_deliver_time)
+        and MONTH(
+        create_time) = #{month}
+        AND DATE_FORMAT(create_time
+        , '%Y') = #{year}
         GROUP BY DATE_FORMAT(create_time, '%Y-%m')
     </select>
 
@@ -152,22 +204,30 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT DATE_FORMAT(create_time, '%Y-${quarter}季度') columnName, COUNT(demand_id) num
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND (real_demand_commit_time > plan_demand_sub_time
-            or real_purchase_finish_time > plan_purchase_finish_time
-            or real_deliver_time > plan_deliver_time)
-          and QUARTER(create_time) = #{quarter}
-          AND DATE_FORMAT(create_time, '%Y') = #{year}
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND (real_demand_commit_time > plan_demand_sub_time
+        or real_purchase_finish_time > plan_purchase_finish_time
+        or real_deliver_time > plan_deliver_time)
+        and QUARTER(create_time) = #{quarter}
+        AND DATE_FORMAT(create_time, '%Y') = #{year}
     </select>
 
     <select id="countProjectExceedAll" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="com.ozs.pm.doman.PmDemand">
         SELECT *
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND (real_demand_commit_time > plan_demand_sub_time
-            or real_purchase_finish_time > plan_purchase_finish_time
-            or real_deliver_time > plan_deliver_time)
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND (real_demand_commit_time > plan_demand_sub_time
+        or real_purchase_finish_time > plan_purchase_finish_time
+        or real_deliver_time > plan_deliver_time)
 
     </select>
 
@@ -175,21 +235,29 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND find_in_set('1', project_attr)
-          AND `project_status` = #{projectStatus}
-          AND DATE_FORMAT(create_time, '%Y') = year(now())
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND find_in_set('1', project_attr)
+        AND `project_status` = #{projectStatus}
+        AND DATE_FORMAT(create_time, '%Y') = year(now())
     </select>
 
     <select id="countMajorProjectExceed" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND (real_demand_commit_time > plan_demand_sub_time
-            or real_purchase_finish_time > plan_purchase_finish_time
-            or real_deliver_time > plan_deliver_time)
-          AND find_in_set('1', project_attr)
-          and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND (real_demand_commit_time > plan_demand_sub_time
+        or real_purchase_finish_time > plan_purchase_finish_time
+        or real_deliver_time > plan_deliver_time)
+        AND find_in_set('1', project_attr)
+        and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
     </select>
 
     <select id="taskQuantityYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
@@ -218,9 +286,13 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT project_status columnName, COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND `project_status` IN (9, 10, 11, 12, 13, 14)
-          and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND `project_status` IN (9, 10, 11, 12, 13, 14)
+        and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
         GROUP BY project_status
     </select>
 
@@ -240,20 +312,29 @@
 
     <select id="countMajorProjectLastYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
-        #           AND find_in_set('1', project_attr)
+        # AND find_in_set('1', project_attr)
         SELECT YEAR(NOW()) - 1 columnName, COUNT(d.demand_id) num, ifnull(sum(c.contract_amount), 0) evaluationTotal
         FROM pm_demand d
-                 LEFT JOIN pm_contract_info c
-                           ON d.demand_id = c.demand_id
-                               AND find_in_set('1', d.project_attr)
-                               AND d.purchase_dept_id = #{purchaseDeptId}
-                               AND DATE_FORMAT(d.create_time, '%Y') = YEAR(NOW()) - 1
+        LEFT JOIN pm_contract_info c
+        ON d.demand_id = c.demand_id
+        AND find_in_set('1', d.project_attr)
+        AND d.purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND DATE_FORMAT(d.create_time, '%Y') = YEAR(NOW()) - 1
     </select>
 
     <select id="countProjectMajorByYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT DATE_FORMAT(create_time, '%Y') columnName, COUNT(demand_id) num
         FROM `pm_demand`
-        WHERE find_in_set('1', project_attr)
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND find_in_set('1', project_attr)
         GROUP BY DATE_FORMAT(create_time, '%Y')
         order by create_time asc
     </select>
@@ -261,18 +342,26 @@
     <select id="countProjectMajorByMonth" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT DATE_FORMAT(create_time, '%Y-%m') columnName, COUNT(demand_id) num
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND find_in_set('1', project_attr)
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND find_in_set('1', project_attr)
         GROUP BY DATE_FORMAT(create_time, '%Y-%m')
     </select>
 
     <select id="countProjectMajorByQuarter" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT create_time columnName, COUNT(demand_id) num
         FROM `pm_demand`
-        WHERE purchase_dept_id = #{purchaseDeptId}
-          AND find_in_set('1', project_attr)
-          and QUARTER(create_time) = #{quarter}
-          AND DATE_FORMAT(create_time, '%Y') = #{year}
+        WHERE purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND find_in_set('1', project_attr)
+        and QUARTER(create_time) = #{quarter}
+        AND DATE_FORMAT(create_time, '%Y') = #{year}
     </select>
 
     <!-- 正常推荐项目 -->
@@ -280,19 +369,27 @@
             resultType="java.util.Map">
         select count(demand_id) countNormalPropulsion, ifnull(sum(evaluation), 0) evaluationNormalPropulsion
         from pm_demand
-        where purchase_dept_id = #{purchaseDeptId}
-          AND project_status != '17'
-          and (real_demand_commit_time > plan_demand_sub_time
-            or real_purchase_finish_time > plan_purchase_finish_time
-            or real_deliver_time > plan_deliver_time)
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND project_status != '17'
+        and (real_demand_commit_time > plan_demand_sub_time
+        or real_purchase_finish_time > plan_purchase_finish_time
+        or real_deliver_time > plan_deliver_time)
     </select>
 
     <select id="purchaseProjectExecuteIncomplete" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
         select count(demand_id) countIncomplete, ifnull(sum(evaluation), 0) evaluationIncomplete
         from pm_demand
-        where purchase_dept_id = #{purchaseDeptId}
-          AND project_status in (4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND project_status in (4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
     </select>
 
     <select id="selectMinYear" resultType="java.lang.Integer">
@@ -302,19 +399,23 @@
 
     <select id="selectpurchaseProjectCompleteNumberYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
-        select count(a.demand_id)                countNum,
-               ifnull(sum(a.evaluation), 0)      evaluation,
-               year(a.plan_demand_sub_time)      yy,
-               ifnull(sum(b.contract_amount), 0) contractAmount
+        select count(a.demand_id) countNum,
+        ifnull(sum(a.evaluation), 0) evaluation,
+        year(a.plan_demand_sub_time) yy,
+        ifnull(sum(b.contract_amount), 0) contractAmount
         from (
-                 select evaluation, plan_demand_sub_time, demand_id
-                 from pm_demand
-                 where purchase_dept_id = #{purchaseDeptId}
-                   AND project_status = '17'
-             ) a
-                 left join (
-            select contract_amount, demand_id
-            from pm_contract_info
+        select evaluation, plan_demand_sub_time, demand_id
+        from pm_demand
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND project_status = '17'
+        ) a
+        left join (
+        select contract_amount, demand_id
+        from pm_contract_info
         ) b on a.demand_id = b.demand_id
 
         group by year(plan_demand_sub_time)
@@ -322,95 +423,115 @@
 
     <select id="selectpurchaseProjectCompleteNumberQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
-        select ifnull(sum(a.evaluation), 0)      evaluation,
-               quarter(a.plan_demand_sub_time)   yy,
-               ifnull(sum(b.contract_amount), 0) contractAmount
+        select ifnull(sum(a.evaluation), 0) evaluation,
+        quarter(a.plan_demand_sub_time) yy,
+        ifnull(sum(b.contract_amount), 0) contractAmount
         from (
-                 select evaluation, plan_demand_sub_time, demand_id
-                 from pm_demand
-                 where purchase_dept_id = #{purchaseDeptId}
-                   AND project_status = '17'
-                   and year(plan_demand_sub_time) = year(NOW())
-             ) a
-                 left join (
-            select contract_amount, demand_id
-            from pm_contract_info
+        select evaluation, plan_demand_sub_time, demand_id
+        from pm_demand
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND project_status = '17'
+        and year(plan_demand_sub_time) = year(NOW())
+        ) a
+        left join (
+        select contract_amount, demand_id
+        from pm_contract_info
         ) b on a.demand_id = b.demand_id
         group by concat(Year(a.plan_demand_sub_time), quarter(a.plan_demand_sub_time))
     </select>
 
     <select id="selectpurchaseProjectCompleteNumberMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
-        select ifnull(sum(a.evaluation), 0)            evaluation,
-               date_format(plan_demand_sub_time, '%m') yy,
-               ifnull(sum(b.contract_amount), 0)       contractAmount
+        select ifnull(sum(a.evaluation), 0) evaluation,
+        date_format(plan_demand_sub_time, '%m') yy,
+        ifnull(sum(b.contract_amount), 0) contractAmount
         from (
-                 select evaluation, plan_demand_sub_time, demand_id
-                 from pm_demand
-                 where purchase_dept_id = #{purchaseDeptId}
-                   AND project_status = '17'
-                   and year(plan_demand_sub_time) = year(NOW())
-             ) a
-                 left join (
-            select contract_amount, demand_id
-            from pm_contract_info
+        select evaluation, plan_demand_sub_time, demand_id
+        from pm_demand
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND project_status = '17'
+        and year(plan_demand_sub_time) = year(NOW())
+        ) a
+        left join (
+        select contract_amount, demand_id
+        from pm_contract_info
         ) b on a.demand_id = b.demand_id
         group by date_format(a.plan_demand_sub_time, '%y%m')
     </select>
 
     <select id="selectPurchaseTaskFinishYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
-        select count(a.demand_id)                countNum,
-               ifnull(sum(a.evaluation), 0)      evaluation,
-               year(a.plan_demand_sub_time)      yy,
-               ifnull(sum(b.contract_amount), 0) contractAmount
+        select count(a.demand_id) countNum,
+        ifnull(sum(a.evaluation), 0) evaluation,
+        year(a.plan_demand_sub_time) yy,
+        ifnull(sum(b.contract_amount), 0) contractAmount
         from (
-                 select evaluation, plan_demand_sub_time, demand_id
-                 from pm_demand
-                 where purchase_dept_id = #{purchaseDeptId}
-                   AND project_status in (15, 16, 17)
-             ) a
-                 left join (
-            select contract_amount, demand_id
-            from pm_contract_info
+        select evaluation, plan_demand_sub_time, demand_id
+        from pm_demand
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND project_status in (15, 16, 17)
+        ) a
+        left join (
+        select contract_amount, demand_id
+        from pm_contract_info
         ) b on a.demand_id = b.demand_id
         group by year(a.plan_demand_sub_time)
     </select>
 
     <select id="selectPurchaseTaskFinishQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
-        select ifnull(sum(a.evaluation), 0)      evaluation,
-               quarter(a.plan_demand_sub_time)   yy,
-               ifnull(sum(b.contract_amount), 0) contractAmount
+        select ifnull(sum(a.evaluation), 0) evaluation,
+        quarter(a.plan_demand_sub_time) yy,
+        ifnull(sum(b.contract_amount), 0) contractAmount
         from (
-                 select evaluation, plan_demand_sub_time, demand_id
-                 from pm_demand
-                 where purchase_dept_id = #{purchaseDeptId}
-                   AND project_status in (15, 16, 17)
-                   and year(plan_demand_sub_time) = year(NOW())
-             ) a
-                 left join (
-            select contract_amount, demand_id
-            from pm_contract_info
+        select evaluation, plan_demand_sub_time, demand_id
+        from pm_demand
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND project_status in (15, 16, 17)
+        and year(plan_demand_sub_time) = year(NOW())
+        ) a
+        left join (
+        select contract_amount, demand_id
+        from pm_contract_info
         ) b on a.demand_id = b.demand_id
         group by concat(Year(a.plan_demand_sub_time), quarter(a.plan_demand_sub_time))
     </select>
 
     <select id="selectPurchaseTaskFinishMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
-        select ifnull(sum(a.evaluation), 0)            evaluation,
-               date_format(plan_demand_sub_time, '%m') yy,
-               ifnull(sum(b.contract_amount), 0)       contractAmount
+        select ifnull(sum(a.evaluation), 0) evaluation,
+        date_format(plan_demand_sub_time, '%m') yy,
+        ifnull(sum(b.contract_amount), 0) contractAmount
         from (
-                 select evaluation, plan_demand_sub_time, demand_id
-                 from pm_demand
-                 where purchase_dept_id = #{purchaseDeptId}
-                   AND project_status in (15, 16, 17)
-                   and year(plan_demand_sub_time) = year(NOW())
-             ) a
-                 left join (
-            select contract_amount, demand_id
-            from pm_contract_info
+        select evaluation, plan_demand_sub_time, demand_id
+        from pm_demand
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND project_status in (15, 16, 17)
+        and year(plan_demand_sub_time) = year(NOW())
+        ) a
+        left join (
+        select contract_amount, demand_id
+        from pm_contract_info
         ) b on a.demand_id = b.demand_id
         group by date_format(a.plan_demand_sub_time, '%y%m')
     </select>
@@ -428,8 +549,12 @@
 
     <select id="purchaseProjectDistribution" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
-        select count(demand_id) countNumber from pm_demand where purchase_dept_id=#{purchaseDeptId} AND project_status
-        in
+        select count(demand_id) countNumber from pm_demand where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND project_status in
         <foreach item="item" collection="projectStatusList" separator="," open="(" close=")">
             #{item}
         </foreach>
@@ -439,7 +564,11 @@
             resultType="java.util.Map">
         select count(demand_id) countNum, ifnull(sum(evaluation), 0) evaluationSum, year(plan_demand_sub_time) yy
         from pm_demand
-        where purchase_dept_id = #{purchaseDeptId}
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
         group by year(plan_demand_sub_time)
     </select>
 
@@ -447,8 +576,12 @@
             resultType="java.util.Map">
         select count(demand_id) countNum, ifnull(sum(evaluation), 0) evaluationSum, quarter(plan_demand_sub_time) yy
         from pm_demand
-        where purchase_dept_id = #{purchaseDeptId}
-          AND year(plan_demand_sub_time) = year(NOW())
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND year(plan_demand_sub_time) = year(NOW())
         group by concat(Year(plan_demand_sub_time), quarter(plan_demand_sub_time))
     </select>
 
@@ -456,19 +589,27 @@
             resultType="java.util.Map">
         select count(demand_id) countNum, ifnull(sum(evaluation), 0) evaluationSum, quarter(plan_demand_sub_time) yy
         from pm_demand
-        where purchase_dept_id = #{purchaseDeptId}
-          AND year(plan_demand_sub_time) = year(NOW() - 1)
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND year(plan_demand_sub_time) = year(NOW() - 1)
         group by concat(Year(plan_demand_sub_time), quarter(plan_demand_sub_time))
     </select>
 
     <select id="purchaseProjectNumberAnalysisMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
-        select count(demand_id)                        countNum,
-               ifnull(sum(evaluation), 0)              evaluationSum,
-               date_format(plan_demand_sub_time, '%m') yy
+        select count(demand_id) countNum,
+        ifnull(sum(evaluation), 0) evaluationSum,
+        date_format(plan_demand_sub_time, '%m') yy
         from pm_demand
-        where purchase_dept_id = #{purchaseDeptId}
-          AND year(plan_demand_sub_time) = year(NOW())
+        where purchase_dept_id in
+        <foreach collection="vo.deptList" item="item" index="index"
+                 separator="," open="(" close=")">
+            #{item}
+        </foreach>
+        AND year(plan_demand_sub_time) = year(NOW())
         group by date_format(plan_demand_sub_time, '%y%m')
     </select>
 

+ 22 - 7
purchase-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -84,16 +84,31 @@
     </select>
 
     <select id="checkDeptExistUser" parameterType="Long" resultType="int">
-		select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
-	</select>
+        select count(1)
+        from sys_user
+        where dept_id = #{deptId}
+          and del_flag = '0'
+    </select>
+
+    <select id="hasChildByDeptId" parameterType="Long" resultType="java.lang.Integer">
+        select count(1)
+        from sys_dept
+        where del_flag = '0'
+          and parent_id = #{deptId}
+        limit 1
+    </select>
 
-    <select id="hasChildByDeptId" parameterType="Long" resultType="int">
-		select count(1) from sys_dept
-		where del_flag = '0' and parent_id = #{deptId} limit 1
-	</select>
+    <select id="getChildIdByDeptId" parameterType="java.lang.Long" resultType="java.lang.Long">
+        select dept_id deptId
+        from sys_dept
+        where del_flag = '0'
+          and parent_id = #{deptId}
+    </select>
 
     <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
-		select * from sys_dept where find_in_set(#{deptId}, ancestors)
+        select *
+        from sys_dept
+        where find_in_set(#{deptId}, ancestors)
     </select>
 
     <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">