Selaa lähdekoodia

本部门加上自己部门超额

buzhanyi 2 vuotta sitten
vanhempi
commit
c15777638b

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

@@ -36,265 +36,265 @@ import java.util.Map;
 @RequestMapping("/statistical")
 public class StatisticalAnalysisController extends BaseController {
 
-    @Resource
-    private IPmDemandService pmDemandService;
-
-    @ApiOperation(value = "项目类型情况统计")
-    @PostMapping("/countByProjectType")
-    //@PreAuthorize("@ss.hasPermi('statistical:countByProjectType')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult countByProjectType(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        //按照项目属性统计所有的项目
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        List<StatisticalChartsResVo> resVos = pmDemandService.countByProjectType(pmDemandReqVo);
-        return AjaxResult.success(resVos);
-    }
-
-    @ApiOperation(value = "采购方式分布")
-    @PostMapping("/countByPurchaseMode")
-    //@PreAuthorize("@ss.hasPermi('statistical:countByPurchaseMode')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult countByPurchaseMode(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        //按照采购方式统计所有的项目
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        List<StatisticalChartsResVo> resVos = pmDemandService.countByPurchaseMode(pmDemandReqVo);
-        return AjaxResult.success(resVos);
-    }
-
-    @ApiOperation(value = "需采转化情况统计")
-    @PostMapping("/countByPurchaseChange")
-    //@PreAuthorize("@ss.hasPermi('statistical:countByPurchaseChange')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult countByPurchaseChange(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        //按照采购方式统计所有的项目
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        List<StatisticalChartsResVo> resVos = pmDemandService.countByPurchaseChange(pmDemandReqVo);
-        return AjaxResult.success(resVos);
-    }
-
-    @ApiOperation(value = "项目金额分布")
-    @PostMapping("/countByEvaluation")
-    //@PreAuthorize("@ss.hasPermi('statistical:countByEvaluation')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult countByEvaluation(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        //按照概算金额统计所有的项目
-        //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        List<StatisticalChartsResVo> resVos = pmDemandService.countByEvaluation(pmDemandReqVo);
-        return AjaxResult.success(resVos);
-    }
-
-    @ApiOperation(value = "执行滞后分析")
-    @PostMapping("/countProjectExceed")
-    //@PreAuthorize("@ss.hasPermi('statistical:countProjectExceed')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult countProjectExceed(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        //执行滞后采购项目:本年度所有的逾期项目数
-        //预算金额:本年度所有逾期项目累加的预算金额
-        //滞后项目数量占比:指本年度逾期项目数量/本年度所有项目数量
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        return pmDemandService.countProjectExceed(pmDemandReqVo);
-    }
-
-    @ApiOperation(value = "滞后项目数量分析")
-    @PostMapping("/exceedAnalysis")
-    //@PreAuthorize("@ss.hasPermi('statistical:exceedAnalysis')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult exceedAnalysis(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        //统计不同时间维度的逾期项目
-        // 需求单位可查看本单位及其下属单位的统计数据
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        if (StringUtils.isNull(pmDemandReqVo.getTimeType())) {
-            return error("统计时间类型不能为空, 1:年度,2:季度,3:月份!");
-        }
-        return pmDemandService.exceedAnalysis(pmDemandReqVo);
-    }
-
-    @ApiOperation(value = "滞后项目时长分析")
-    @PostMapping("/exceedMarketAnalysis")
-    //@PreAuthorize("@ss.hasPermi('statistical:exceedMarketAnalysis')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult exceedMarketAnalysis(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        //按照滞后时长统计项目数量
-        //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        return pmDemandService.exceedMarketAnalysis(pmDemandReqVo);
-    }
-
-    @ApiOperation(value = "采购项目信息统计")
-    @PostMapping("/purchaseProjectStatistical")
-    //@PreAuthorize("@ss.hasPermi('statistical:purchaseProjectStatistical')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult purchaseProjectStatistical(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        // 需求单位可查看本单位及其下属单位的统计数据
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        Map<String, Integer> map = pmDemandService.purchaseProjectStatistical(pmDemandReqVo);
-        return success(map);
-    }
-
-    @ApiOperation(value = "重大规划采购任务专项计划管理情况")
-    @PostMapping("/countMajorProject")
-    //@PreAuthorize("@ss.hasPermi('statistical:countMajorProject')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult countMajorProject(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        return pmDemandService.countMajorProject(pmDemandReqVo);
-    }
-
-
-    @ApiOperation(value = "任务数量趋势分析")
-    @PostMapping("/taskQuantityAnalysis")
-    //@PreAuthorize("@ss.hasPermi('statistical:taskQuantityAnalysis')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult taskQuantityAnalysis(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        //任务数量趋势分析:按照月、季度、年统计“项目属性”字段中“重大规划”属性的项目
-        // 需求单位可查看本单位及其下属单位的统计数据
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        if (StringUtils.isNull(pmDemandReqVo.getTimeType())) {
-            return error("统计时间类型不能为空, 1:年度,2:季度,3:月份!");
-        }
-        return pmDemandService.taskQuantityAnalysis(pmDemandReqVo);
-    }
-
-    @ApiOperation(value = "各阶段采购任务数量分布")
-    @PostMapping("/countEveryStatusNum")
-    //@PreAuthorize("@ss.hasPermi('statistical:countEveryStatusNum')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult countEveryStatusNum(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        //指项目进行到各个阶段的数量
-        //阶段包括:待选取代理、待上传招标文件、待发布公告、待开标、待发布中标公告、中标公式中
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        return pmDemandService.countEveryStatusNum(pmDemandReqVo);
-    }
-
-    @ApiOperation(value = "项目执行进度统计")
-    @PostMapping("/purchaseProjectExecute")
-    //@PreAuthorize("@ss.hasPermi('statistical:purchaseProjectExecute')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult purchaseProjectExecute(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        // 需求单位可查看本单位及其下属单位的统计数据
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        List<StatisticalChartsResVo> resVos = pmDemandService.purchaseProjectExecute(pmDemandReqVo);
-        return success(resVos);
-    }
-
-    @ApiOperation(value = "已完成项目数量统计")
-    @PostMapping("/purchaseProjectCompleteNumber")
-    //@PreAuthorize("@ss.hasPermi('statistical:purchaseProjectCompleteNumber')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult purchaseProjectCompleteNumber(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        // 需求单位可查看本单位及其下属单位的统计数据
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        if (StringUtils.isNull(pmDemandReqVo.getTimeType())) {
-            return error("统计时间类型不能为空, 1:年度,2:季度,3:月份!");
-        }
-        List<Map<String, Integer>> map = pmDemandService.purchaseProjectCompleteNumber(pmDemandReqVo);
-        return success(map);
-    }
-
-    @ApiOperation(value = "已完成采购任务数量")
-    @PostMapping("/purchaseTaskFinish")
-    //@PreAuthorize("@ss.hasPermi('statistical:purchaseTaskFinish')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult purchaseTaskFinish(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        // 需求单位可查看本单位及其下属单位的统计数据
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        if (StringUtils.isNull(pmDemandReqVo.getTimeType())) {
-            return error("统计时间类型不能为空, 1:年度,2:季度,3:月份!");
-        }
-        List<Map<String, Integer>> map = pmDemandService.purchaseTaskFinish(pmDemandReqVo);
-        return success(map);
-    }
-
-    @ApiOperation(value = "各阶段项目数量分布")
-    @PostMapping("/purchaseProjectDistribution")
-    //@PreAuthorize("@ss.hasPermi('statistical:purchaseProjectDistribution')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult purchaseProjectDistribution(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        // 需求单位可查看本单位及其下属单位的统计数据
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        List<Map<String, String>> map = pmDemandService.purchaseProjectDistribution(pmDemandReqVo);
-        return success(map);
-    }
-
-    @ApiOperation(value = "采购项目--项目数量分析/预算金额(万元)")
-    @PostMapping("/purchaseProjectNumberAnalysis")
-    //@PreAuthorize("@ss.hasPermi('statistical:purchaseProjectNumberAnalysis')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult purchaseProjectNumberAnalysis(@RequestBody PmDemandReqVo pmDemandReqVo) {
-        // 需求单位可查看本单位及其下属单位的统计数据
-        if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
-            return error("登录账号的单位 不能为空!");
-        }
-        if (StringUtils.isNull(pmDemandReqVo.getTimeType())) {
-            return error("统计时间类型不能为空, 1:年度,2:季度,3:月份!");
-        }
-        List<Map<String, String>> map = pmDemandService.purchaseProjectNumberAnalysis(pmDemandReqVo);
-        return success(map);
-    }
-
-    @ApiOperation(value = "生成分析报告")
-    @PostMapping("/generateAnalysisReport")
-    //@PreAuthorize("@ss.hasPermi('statistical:generateAnalysisReport')")
-    @Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
-    public AjaxResult generateAnalysisReport(@RequestBody SysFileInfo file) {
-        //  创建一个document对象,相当于新建一个word文档(后缀名为.docx)。
-        XWPFDocument document = new XWPFDocument();
-        //        创建一个段落对象。
-        XWPFParagraph paragraph = document.createParagraph();
-        //        创建一个run。run具体是什么,我也不知道。但是run是这里面的最小单元了。
-        XWPFRun run = paragraph.createRun();
-        //        插入图片
-        //        创建一个输出流 即是该文档的保存位置
-        try {
-            //文件路径位置和文件名称
-            run.addPicture(new FileInputStream(file.getFileUrl()),
-                    XWPFDocument.PICTURE_TYPE_PNG,
-                    file.getFileName(),
-                    Units.toEMU(400),
-                    Units.toEMU(200));
-            //文件保存地址
-            OutputStream outputStream = new FileOutputStream(file.getFileMappingPath());
-            document.write(outputStream);
-            outputStream.close();
-            return AjaxResult.success("分析文档已生成");
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (InvalidFormatException e) {
-            e.printStackTrace();
-        }
-        return AjaxResult.success("分析文档已生成");
-    }
+    //@Resource
+    //private IPmDemandService pmDemandService;
+    //
+    //@ApiOperation(value = "项目类型情况统计")
+    //@PostMapping("/countByProjectType")
+    ////@PreAuthorize("@ss.hasPermi('statistical:countByProjectType')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult countByProjectType(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    //按照项目属性统计所有的项目
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    List<StatisticalChartsResVo> resVos = pmDemandService.countByProjectType(pmDemandReqVo);
+    //    return AjaxResult.success(resVos);
+    //}
+    //
+    //@ApiOperation(value = "采购方式分布")
+    //@PostMapping("/countByPurchaseMode")
+    ////@PreAuthorize("@ss.hasPermi('statistical:countByPurchaseMode')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult countByPurchaseMode(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    //按照采购方式统计所有的项目
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    List<StatisticalChartsResVo> resVos = pmDemandService.countByPurchaseMode(pmDemandReqVo);
+    //    return AjaxResult.success(resVos);
+    //}
+    //
+    //@ApiOperation(value = "需采转化情况统计")
+    //@PostMapping("/countByPurchaseChange")
+    ////@PreAuthorize("@ss.hasPermi('statistical:countByPurchaseChange')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult countByPurchaseChange(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    //按照采购方式统计所有的项目
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    List<StatisticalChartsResVo> resVos = pmDemandService.countByPurchaseChange(pmDemandReqVo);
+    //    return AjaxResult.success(resVos);
+    //}
+    //
+    //@ApiOperation(value = "项目金额分布")
+    //@PostMapping("/countByEvaluation")
+    ////@PreAuthorize("@ss.hasPermi('statistical:countByEvaluation')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult countByEvaluation(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    //按照概算金额统计所有的项目
+    //    //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    List<StatisticalChartsResVo> resVos = pmDemandService.countByEvaluation(pmDemandReqVo);
+    //    return AjaxResult.success(resVos);
+    //}
+    //
+    //@ApiOperation(value = "执行滞后分析")
+    //@PostMapping("/countProjectExceed")
+    ////@PreAuthorize("@ss.hasPermi('statistical:countProjectExceed')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult countProjectExceed(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    //执行滞后采购项目:本年度所有的逾期项目数
+    //    //预算金额:本年度所有逾期项目累加的预算金额
+    //    //滞后项目数量占比:指本年度逾期项目数量/本年度所有项目数量
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    return pmDemandService.countProjectExceed(pmDemandReqVo);
+    //}
+    //
+    //@ApiOperation(value = "滞后项目数量分析")
+    //@PostMapping("/exceedAnalysis")
+    ////@PreAuthorize("@ss.hasPermi('statistical:exceedAnalysis')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult exceedAnalysis(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    //统计不同时间维度的逾期项目
+    //    // 需求单位可查看本单位及其下属单位的统计数据
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    if (StringUtils.isNull(pmDemandReqVo.getTimeType())) {
+    //        return error("统计时间类型不能为空, 1:年度,2:季度,3:月份!");
+    //    }
+    //    return pmDemandService.exceedAnalysis(pmDemandReqVo);
+    //}
+    //
+    //@ApiOperation(value = "滞后项目时长分析")
+    //@PostMapping("/exceedMarketAnalysis")
+    ////@PreAuthorize("@ss.hasPermi('statistical:exceedMarketAnalysis')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult exceedMarketAnalysis(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    //按照滞后时长统计项目数量
+    //    //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    return pmDemandService.exceedMarketAnalysis(pmDemandReqVo);
+    //}
+    //
+    //@ApiOperation(value = "采购项目信息统计")
+    //@PostMapping("/purchaseProjectStatistical")
+    ////@PreAuthorize("@ss.hasPermi('statistical:purchaseProjectStatistical')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult purchaseProjectStatistical(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    // 需求单位可查看本单位及其下属单位的统计数据
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    Map<String, Integer> map = pmDemandService.purchaseProjectStatistical(pmDemandReqVo);
+    //    return success(map);
+    //}
+    //
+    //@ApiOperation(value = "重大规划采购任务专项计划管理情况")
+    //@PostMapping("/countMajorProject")
+    ////@PreAuthorize("@ss.hasPermi('statistical:countMajorProject')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult countMajorProject(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    return pmDemandService.countMajorProject(pmDemandReqVo);
+    //}
+    //
+    //
+    //@ApiOperation(value = "任务数量趋势分析")
+    //@PostMapping("/taskQuantityAnalysis")
+    ////@PreAuthorize("@ss.hasPermi('statistical:taskQuantityAnalysis')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult taskQuantityAnalysis(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    //任务数量趋势分析:按照月、季度、年统计“项目属性”字段中“重大规划”属性的项目
+    //    // 需求单位可查看本单位及其下属单位的统计数据
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    if (StringUtils.isNull(pmDemandReqVo.getTimeType())) {
+    //        return error("统计时间类型不能为空, 1:年度,2:季度,3:月份!");
+    //    }
+    //    return pmDemandService.taskQuantityAnalysis(pmDemandReqVo);
+    //}
+    //
+    //@ApiOperation(value = "各阶段采购任务数量分布")
+    //@PostMapping("/countEveryStatusNum")
+    ////@PreAuthorize("@ss.hasPermi('statistical:countEveryStatusNum')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult countEveryStatusNum(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    //指项目进行到各个阶段的数量
+    //    //阶段包括:待选取代理、待上传招标文件、待发布公告、待开标、待发布中标公告、中标公式中
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    return pmDemandService.countEveryStatusNum(pmDemandReqVo);
+    //}
+    //
+    //@ApiOperation(value = "项目执行进度统计")
+    //@PostMapping("/purchaseProjectExecute")
+    ////@PreAuthorize("@ss.hasPermi('statistical:purchaseProjectExecute')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult purchaseProjectExecute(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    // 需求单位可查看本单位及其下属单位的统计数据
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    List<StatisticalChartsResVo> resVos = pmDemandService.purchaseProjectExecute(pmDemandReqVo);
+    //    return success(resVos);
+    //}
+    //
+    //@ApiOperation(value = "已完成项目数量统计")
+    //@PostMapping("/purchaseProjectCompleteNumber")
+    ////@PreAuthorize("@ss.hasPermi('statistical:purchaseProjectCompleteNumber')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult purchaseProjectCompleteNumber(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    // 需求单位可查看本单位及其下属单位的统计数据
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    if (StringUtils.isNull(pmDemandReqVo.getTimeType())) {
+    //        return error("统计时间类型不能为空, 1:年度,2:季度,3:月份!");
+    //    }
+    //    List<Map<String, Integer>> map = pmDemandService.purchaseProjectCompleteNumber(pmDemandReqVo);
+    //    return success(map);
+    //}
+    //
+    //@ApiOperation(value = "已完成采购任务数量")
+    //@PostMapping("/purchaseTaskFinish")
+    ////@PreAuthorize("@ss.hasPermi('statistical:purchaseTaskFinish')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult purchaseTaskFinish(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    // 需求单位可查看本单位及其下属单位的统计数据
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    if (StringUtils.isNull(pmDemandReqVo.getTimeType())) {
+    //        return error("统计时间类型不能为空, 1:年度,2:季度,3:月份!");
+    //    }
+    //    List<Map<String, Integer>> map = pmDemandService.purchaseTaskFinish(pmDemandReqVo);
+    //    return success(map);
+    //}
+    //
+    //@ApiOperation(value = "各阶段项目数量分布")
+    //@PostMapping("/purchaseProjectDistribution")
+    ////@PreAuthorize("@ss.hasPermi('statistical:purchaseProjectDistribution')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult purchaseProjectDistribution(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    // 需求单位可查看本单位及其下属单位的统计数据
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    List<Map<String, String>> map = pmDemandService.purchaseProjectDistribution(pmDemandReqVo);
+    //    return success(map);
+    //}
+    //
+    //@ApiOperation(value = "采购项目--项目数量分析/预算金额(万元)")
+    //@PostMapping("/purchaseProjectNumberAnalysis")
+    ////@PreAuthorize("@ss.hasPermi('statistical:purchaseProjectNumberAnalysis')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult purchaseProjectNumberAnalysis(@RequestBody PmDemandReqVo pmDemandReqVo) {
+    //    // 需求单位可查看本单位及其下属单位的统计数据
+    //    if (StringUtils.isNull(pmDemandReqVo.getPurchaseDeptId())) {
+    //        return error("登录账号的单位 不能为空!");
+    //    }
+    //    if (StringUtils.isNull(pmDemandReqVo.getTimeType())) {
+    //        return error("统计时间类型不能为空, 1:年度,2:季度,3:月份!");
+    //    }
+    //    List<Map<String, String>> map = pmDemandService.purchaseProjectNumberAnalysis(pmDemandReqVo);
+    //    return success(map);
+    //}
+    //
+    //@ApiOperation(value = "生成分析报告")
+    //@PostMapping("/generateAnalysisReport")
+    ////@PreAuthorize("@ss.hasPermi('statistical:generateAnalysisReport')")
+    //@Log(title = ModularConstans.statisticalAnalysis, businessType = BusinessType.QUERY)
+    //public AjaxResult generateAnalysisReport(@RequestBody SysFileInfo file) {
+    //    //  创建一个document对象,相当于新建一个word文档(后缀名为.docx)。
+    //    XWPFDocument document = new XWPFDocument();
+    //    //        创建一个段落对象。
+    //    XWPFParagraph paragraph = document.createParagraph();
+    //    //        创建一个run。run具体是什么,我也不知道。但是run是这里面的最小单元了。
+    //    XWPFRun run = paragraph.createRun();
+    //    //        插入图片
+    //    //        创建一个输出流 即是该文档的保存位置
+    //    try {
+    //        //文件路径位置和文件名称
+    //        run.addPicture(new FileInputStream(file.getFileUrl()),
+    //                XWPFDocument.PICTURE_TYPE_PNG,
+    //                file.getFileName(),
+    //                Units.toEMU(400),
+    //                Units.toEMU(200));
+    //        //文件保存地址
+    //        OutputStream outputStream = new FileOutputStream(file.getFileMappingPath());
+    //        document.write(outputStream);
+    //        outputStream.close();
+    //        return AjaxResult.success("分析文档已生成");
+    //    } catch (IOException e) {
+    //        e.printStackTrace();
+    //    } catch (InvalidFormatException e) {
+    //        e.printStackTrace();
+    //    }
+    //    return AjaxResult.success("分析文档已生成");
+    //}
 
 
 }

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

@@ -139,6 +139,7 @@ public class PmDemandReqVo extends PageVo {
 
     @ApiModelProperty("回退序号")
     private Integer returnOrderNumber;
+
     /**
      * 要查询的需求id集合
      */
@@ -152,4 +153,8 @@ public class PmDemandReqVo extends PageVo {
      * 项目属性
      */
     private String projectAttr;
+    /**
+     * 项目类型
+     */
+    private String projectType;
 }

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

@@ -490,7 +490,7 @@ public interface PmDemandMapper extends BaseMapper<PmDemand> {
      * @param pmDemandReqVo
      * @return
      */
-    List<StatisticalChartsResVo> selectByProjectType(@Param("vo") PmDemandReqVo pmDemandReqVo);
+    StatisticalChartsResVo selectByProjectType(@Param("vo") PmDemandReqVo pmDemandReqVo);
 
     /**
      * 本月相关采购机构完成采购任务

+ 156 - 49
purchase-system/src/main/java/com/ozs/pm/service/impl/PmDemandServiceImpl.java

@@ -1911,7 +1911,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     public List<StatisticalChartsResVo> countByProjectAttr(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //直接获取每个属性的数量
         //重点采购项目
@@ -1941,7 +1945,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     public List<StatisticalChartsResVo> countByPurchaseMode(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         List<StatisticalChartsResVo> resVos = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
         for (StatisticalChartsResVo chartsResVo : resVos) {
             for (ProcurementMethodSuggest value : ProcurementMethodSuggest.values()) {
@@ -1957,7 +1965,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     public List<StatisticalChartsResVo> countByEvaluation(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
         pmDemandReqVo.setEvaluation(100);
@@ -1994,7 +2006,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     public AjaxResult countProjectExceed(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //执行滞后采购项目:本年度所有的逾期项目数
         //预算金额:本年度所有逾期项目累加的预算金额
@@ -2112,7 +2128,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
         //指项目进行到各个阶段的数量
         //阶段包括:采购需求对接,专家意见反馈,采购文件编制审核,采购公告发布,标前质疑投诉,待开标,评标结果公告,流废标处置,标后质疑
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         List<StatisticalChartsResVo> everyStatusNum = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
         if (!ObjectUtils.isEmpty(everyStatusNum) && everyStatusNum.size() > 0) {
             for (StatisticalChartsResVo vo : everyStatusNum) {
@@ -2155,7 +2175,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     public AjaxResult exceedMarketAnalysis(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         //所有滞后
         List<PmDemand> demandList = pmDemandMapper.countProjectExceedAll(pmDemandReqVo);
         //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
@@ -2200,7 +2224,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     public AjaxResult countMajorProject(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //本月度新提报重大规划采购任务数量
         pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
@@ -2282,7 +2310,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     public AjaxResult countMajorProjectCGB(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //本月度新受领重大规划采购任务数量
         pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
@@ -2404,7 +2436,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public List<StatisticalChartsResVo> purchaseProjectExecute(PmDemandReqVo pmDemandReqVo) {
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         //累计完成采购任务数量    预算金额(万元)        合同金额(万元)
         StatisticalChartsResVo tThisYear = pmDemandMapper.selectFInishAll(pmDemandReqVo);
         tThisYear.setColumnName("累计完成采购任务数量");
@@ -2512,7 +2548,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     public List<Map<String, Integer>> purchaseTaskFinish(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         List<Map<String, Integer>> mapReturn = new ArrayList<>();
         // 统计时间类型 1:年度,2:季度,3:月份
         if ("1".equals(pmDemandReqVo.getTimeType())) {
@@ -2667,7 +2707,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     public List<Map<String, String>> purchaseProjectNumberAnalysis(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         List<Map<String, String>> mapReturn = new ArrayList<>();
         // 统计时间类型 1:年度,2:季度,3:月份
         if ("1".equals(pmDemandReqVo.getTimeType())) {
@@ -3382,7 +3426,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     public List<StatisticalChartsResVo> demandSubCount(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //本级和所属采购单位新提报采购需求数量--本年度中本级及下级审核的“需求待提交”之后状态的数据
         StatisticalChartsResVo selectSTS = pmDemandMapper.selectSTS(pmDemandReqVo);
@@ -3397,6 +3445,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
         lastYear.setColumnName("上年度结转和本年度提报");
         lastYear.setColumnNamePlus("采购需求累计数量");
         lastYear.setNum(lastYear.getNum() + thisYear.getNum());
+        lastYear.setEvaluationTotal(lastYear.getEvaluationTotal().add(thisYear.getEvaluationTotal()));
         resVos.add(lastYear);
         //未按季度采购明细计划提报或调整延迟的数量--超过计划需求提报时间的项目
         StatisticalChartsResVo meiJiDu = pmDemandMapper.selectmeiJiDu(pmDemandReqVo);
@@ -3409,32 +3458,40 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     @Override
     public List<StatisticalChartsResVo> countByProjectType(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));  //项目类型情况统计--根据项目类型:物资类、服务类、工程类、装备类统计项目数量及预算金额
-        List<StatisticalChartsResVo> byProjectType = pmDemandMapper.selectByProjectType(pmDemandReqVo);
-        for (StatisticalChartsResVo vo : byProjectType) {
-            switch (vo.getColumnName()) {
-                case "0":
-                    vo.setColumnName(ProjectTypes.EQUIPMENTTYPE.getInfo());
-                    break;
-                case "1":
-                    vo.setColumnName(ProjectTypes.MATERIALTYPE.getInfo());
-                    break;
-                case "2":
-                    vo.setColumnName(ProjectTypes.SERVICESTYPE.getInfo());
-                    break;
-                case "3":
-                    vo.setColumnName(ProjectTypes.PLANTOEXAMINETYPE.getInfo());
-                    break;
-                default:
-            }
-        }
-        return byProjectType;
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
+        List<StatisticalChartsResVo> resultList = new ArrayList<>();
+        //项目类型情况统计--根据项目类型:物资类、服务类、工程类、装备类统计项目数量及预算金额
+        pmDemandReqVo.setProjectType(ProjectTypes.EQUIPMENTTYPE.getCode());
+        StatisticalChartsResVo res1 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
+        res1.setColumnName(ProjectTypes.EQUIPMENTTYPE.getInfo());
+        resultList.add(res1);
+        pmDemandReqVo.setProjectType(ProjectTypes.MATERIALTYPE.getCode());
+        StatisticalChartsResVo res2 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
+        res2.setColumnName(ProjectTypes.MATERIALTYPE.getInfo());
+        resultList.add(res2);
+        pmDemandReqVo.setProjectType(ProjectTypes.SERVICESTYPE.getCode());
+        StatisticalChartsResVo res3 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
+        res3.setColumnName(ProjectTypes.SERVICESTYPE.getInfo());
+        resultList.add(res3);
+        pmDemandReqVo.setProjectType(ProjectTypes.PLANTOEXAMINETYPE.getCode());
+        StatisticalChartsResVo res4 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
+        res4.setColumnName(ProjectTypes.PLANTOEXAMINETYPE.getInfo());
+        resultList.add(res4);
+        return resultList;
     }
 
     @Override
     public List<StatisticalChartsResVo> countByPurchaseChange(PmDemandReqVo pmDemandReqVo) {
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         List<StatisticalChartsResVo> byChange = new ArrayList<>();
         //本月相关采购机构完成采购任务--状态为“标后质疑”后的数据
         StatisticalChartsResVo thisMonth = pmDemandMapper.selectCGThisMonth(pmDemandReqVo);
@@ -3469,7 +3526,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public AjaxResult exceedReason(PmDemandReqVo pmDemandReqVo) {
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         //统计超过计划完成采购时间的项目中,处在各阶段的数据包括以下内容:
         //1、需求编制对接数量/涉及金额:状态为“采购需求对接”的数量及预算金额
         List<String> xqdj = new ArrayList<>();
@@ -3516,7 +3577,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public AjaxResult exceedReasonZj(PmDemandReqVo pmDemandReqVo) {
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         //统计超过计划完成采购时间的项目中,处在各阶段的数据包括以下内容:
         //1、需求编制对接数量/涉及金额:状态为“采购需求对接”的数量及预算金额
         List<String> xqdj = new ArrayList<>();
@@ -3556,7 +3621,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public AjaxResult exceedLink(PmDemandReqVo pmDemandReqVo) {
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         //滞留环节
         //超过计划完成采购时间的各状态数量及占比统计,包括:采购需求对接、采购文件编制审核、标签质疑投诉、待开标、流废标处置、标后质疑
         //1、 状态为“采购需求对接”的数量及预算金额
@@ -3609,7 +3678,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public AjaxResult countPurTask(PmDemandReqVo pmDemandReqVo) {
         List<StatisticalChartsResVo> resVos = new ArrayList<>();
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         //1、所属采购服务站数量
         //查询现有的采购服务站
         SysDictData dictData = new SysDictData();
@@ -3649,7 +3722,11 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public AjaxResult countMajorProjectNumCGB(PmDemandReqVo pmDemandReqVo) {
         //新增执行滞后采购任务数量分析 所有的超过计划完成采购时间的数据
         //是-1就是查询自己及子孙级以下,否则只查询指定部门
-        pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
+            pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
+        } else {
+            pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
+        }
         HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
         // 查询数据库中最小的年份
         int minYear = pmDemandMapper.selectMinYear();
@@ -3872,21 +3949,51 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
                 deptList.addAll(children);
             }
             deptList.add(Math.toIntExact(deptId));
-            //指定部门
-        } else {
-            //deptList.add(Math.toIntExact(deptId));
-            deptList.add(queryAll);
-            //if (deptService.hasChildByDeptId(deptId)) {
-            //    //获取子级部门
-            //    List<Long> childByDeptId = deptService.getChildIdByDeptId(deptId);
-            //    for (Long cid : childByDeptId) {
-            //
-            //    }
-            //}
         }
         return deptList;
     }
 
+    //查询本单位还是本单位及子孙级----要查询子单位的超额数据
+    public List<Long> isQueryZD(Integer queryZd) {
+        //指定部门--以及子单位的超额数据
+        List<Long> demandId = new ArrayList<>();
+        //先获取本部门的项目
+        LambdaQueryWrapper<PmDemand> ld = new LambdaQueryWrapper<>();
+        ld.eq(PmDemand::getPurchaseDeptId, queryZd);
+        //子部门参加审核的项目
+        List<PmDemand> deList = pmDemandMapper.selectList(ld);
+        for (PmDemand demand : deList) {
+            demandId.add(demand.getDemandId());
+        }
+        if (deptService.hasChildByDeptId(Long.valueOf(queryZd))) {
+            //获取子级部门d
+            List<Long> childByDeptId = deptService.getChildIdByDeptId(Long.valueOf(queryZd));
+            //取出所有可以进行统计的项目id
+            for (Long cid : childByDeptId) {
+                LambdaQueryWrapper<PmAuditDeptRef> ll = new LambdaQueryWrapper<>();
+                ll.eq(PmAuditDeptRef::getDeptId, cid);
+                ll.eq(PmAuditDeptRef::getRefType, "2");
+                //子部门参加审核的项目
+                List<PmAuditDeptRef> refList = pmAuditDeptRefService.list(ll);
+                //同一个数据有上级参与说明是超额
+                for (PmAuditDeptRef ref : refList) {
+                    //获取上级并查询是否参与审核
+                    SysDept dept = deptService.selectByCid(ref.getDeptId());
+                    //是否参与审核
+                    LambdaQueryWrapper<PmAuditDeptRef> pp = new LambdaQueryWrapper<>();
+                    ll.eq(PmAuditDeptRef::getDeptId, dept.getDeptId());
+                    ll.eq(PmAuditDeptRef::getRefId, ref.getRefId());
+                    //取出父级部门参加审核的项目(超额项目)
+                    List<PmAuditDeptRef> refListP = pmAuditDeptRefService.list(pp);
+                    if (!ObjectUtils.isEmpty(refListP)) {
+                        demandId.add(ref.getRefId());
+                    }
+                }
+            }
+        }
+        return demandId;
+    }
+
     //获取到子孙级部门id
     public List<Integer> getDeptChildren(Long deptId) {
         List<Integer> deptList = new ArrayList<>();

+ 8 - 0
purchase-system/src/main/java/com/ozs/system/mapper/SysDeptMapper.java

@@ -139,4 +139,12 @@ public interface SysDeptMapper {
      * @return 部门列表
      */
     public List<SysDept> selectMaxDeptByParentId(Long deptId);
+
+    /**
+     * 查询上一级
+     *
+     * @param deptId
+     * @return
+     */
+    public SysDept selectByCid(Long deptId);
 }

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

@@ -139,4 +139,12 @@ public interface ISysDeptService {
     public List<SysDept> selectChildrenDeptById(Long deptId);
 
     public List<SysDept> selectMaxDeptByParentId(Long deptId);
+
+    /**
+     * 查询上一级
+     *
+     * @param deptId
+     * @return
+     */
+    public SysDept selectByCid(Long deptId);
 }

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

@@ -381,4 +381,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
     public List<SysDept> selectMaxDeptByParentId(Long deptId) {
         return deptMapper.selectMaxDeptByParentId(deptId);
     }
+
+    @Override
+    public SysDept selectByCid(Long deptId) {
+        return deptMapper.selectByCid(deptId);
+    }
 }

+ 137 - 263
purchase-system/src/main/resources/mapper/pm/PmDemandMapper.xml

@@ -94,15 +94,8 @@
         SELECT project_attr columnName, ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
         WHERE
-        <if test="vo.deptList != null and vo.deptList.size != 0 ">
-            purchase_dept_id
-            in
-            <foreach collection="vo.deptList" item="item" index="index"
-                     separator="," open="(" close=")">
-                #{item}
-            </foreach>
-            AND
-        </if>
+        <include refid="deptListOrDemandIdAll"></include>
+        AND
         find_in_set(#{vo.projectAttr},project_attr)
     </select>
 
@@ -122,11 +115,8 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND evaluation &lt; #{vo.evaluation}
     </select>
 
@@ -134,22 +124,16 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND evaluation BETWEEN #{vo.evaluation} and #{vo.evaluationEnd}
     </select>
     <select id="countByEvaluationGt" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND evaluation &gt; #{vo.evaluation}
     </select>
 
@@ -157,11 +141,8 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND ( real_purchase_finish_time > plan_purchase_finish_time )
         and YEAR(create_time) = YEAR(NOW())
     </select>
@@ -170,11 +151,8 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND ( real_purchase_finish_time > plan_purchase_finish_time )
         and quarter(create_time) = quarter(NOW())
     </select>
@@ -183,11 +161,8 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND ( real_purchase_finish_time > plan_purchase_finish_time )
         and MONTH(create_time) = MONTH(NOW())
     </select>
@@ -196,11 +171,8 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND ( real_purchase_finish_time > plan_purchase_finish_time)
     </select>
 
@@ -283,11 +255,8 @@
             resultType="com.ozs.pm.doman.PmDemand">
         SELECT *
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         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)
@@ -297,11 +266,8 @@
     <sql id="majorProjectByStatus">
         SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND find_in_set('1', project_attr)
     </sql>
 
@@ -363,7 +329,7 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         <include refid="majorProjectByStatus"></include>
         AND YEAR(create_time ) = YEAR(now())-1
-        <if test="vo.projectStatusList!=null">
+        <if test="vo.projectStatusList!=null and vo.projectStatusList.size != 0">
             AND project_status in
             <foreach collection="vo.projectStatusList" item="item" index="index"
                      separator="," open="(" close=")">
@@ -426,11 +392,8 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT project_status columnName, ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND `project_status` IN (9, 10, 11, 12, 13, 14,15,16,17)
         and YEAR(create_time) = YEAR(NOW())
         GROUP BY project_status
@@ -510,11 +473,8 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         select ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         from pm_demand
-        where purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        where
+        <include refid="deptListOrDemandIdAll"></include>
         AND project_status !=21
         and (real_demand_commit_time &lt; plan_demand_sub_time
         or real_purchase_finish_time &lt; plan_purchase_finish_time
@@ -525,11 +485,8 @@
             resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         select ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         from pm_demand
-        where purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        where
+        <include refid="deptListOrDemandIdAll"></include>
         AND project_status !=21
     </select>
 
@@ -617,11 +574,8 @@
         from (
         select evaluation, create_time, demand_id
         from pm_demand
-        where purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        where
+        <include refid="deptListOrDemandIdAll"></include>
         AND project_status in (15, 16, 17)
         ) a
         left join (
@@ -639,11 +593,8 @@
         from (
         select evaluation, create_time, demand_id
         from pm_demand
-        where purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        where
+        <include refid="deptListOrDemandIdAll"></include>
         AND project_status in (15, 16, 17)
         and year(create_time) = year(NOW())
         ) a
@@ -662,11 +613,8 @@
         from (
         select evaluation, create_time, demand_id
         from pm_demand
-        where purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        where
+        <include refid="deptListOrDemandIdAll"></include>
         AND project_status in (15, 16, 17)
         and year(create_time) = year(NOW())
         ) a
@@ -691,12 +639,9 @@
     <select id="purchaseProjectDistribution" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
         select ifnull(count(demand_id), 0) countNumber,ifnull(sum(evaluation), 0) evaluationTotal
-        from pm_demand where purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
-        <if test="vo.projectStatusList!=null">
+        from pm_demand where
+        <include refid="deptListOrDemandIdAll"></include>
+        <if test="vo.projectStatusList!=null and vo.projectStatusList.size != 0">
             AND project_status in
             <foreach collection="vo.projectStatusList" item="item" index="index"
                      separator="," open="(" close=")">
@@ -708,12 +653,9 @@
     <select id="purchaseProjectDistributionTo" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
             resultType="java.util.Map">
         select ifnull(count(demand_id), 0) countNumber,ifnull(sum(evaluation), 0) evaluationTotal
-        from pm_demand where purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
-        <if test="vo.projectStatusList!=null">
+        from pm_demand where
+        <include refid="deptListOrDemandIdAll"></include>
+        <if test="vo.projectStatusList!=null and vo.projectStatusList.size != 0">
             AND project_status in
             <foreach collection="vo.projectStatusList" item="item" index="index"
                      separator="," open="(" close=")">
@@ -726,11 +668,8 @@
             resultType="java.util.Map">
         select ifnull(COUNT(demand_id), 0) countNum, ifnull(sum(evaluation), 0) evaluationSum, year(create_time) yy
         from pm_demand
-        where purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        where
+        <include refid="deptListOrDemandIdAll"></include>
         group by year(create_time)
     </select>
 
@@ -738,11 +677,8 @@
             resultType="java.util.Map">
         select ifnull(COUNT(demand_id), 0) countNum, ifnull(sum(evaluation), 0) evaluationSum, quarter(create_time) yy
         from pm_demand
-        where purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        where
+        <include refid="deptListOrDemandIdAll"></include>
         AND year(create_time) = year(NOW())
         group by concat(Year(create_time), quarter(create_time))
     </select>
@@ -751,11 +687,8 @@
             resultType="java.util.Map">
         select ifnull(COUNT(demand_id), 0) countNum, ifnull(sum(evaluation), 0) evaluationSum, quarter(create_time) yy
         from pm_demand
-        where purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        where
+        <include refid="deptListOrDemandIdAll"></include>
         AND year(create_time) = year(NOW() - 1)
         group by concat(Year(create_time), quarter(create_time))
     </select>
@@ -766,11 +699,8 @@
         ifnull(sum(evaluation), 0) evaluationSum,
         date_format(create_time, '%m') yy
         from pm_demand
-        where purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        where
+        <include refid="deptListOrDemandIdAll"></include>
         AND year(create_time) = year(NOW())
         group by date_format(create_time, '%y%m')
     </select>
@@ -789,24 +719,15 @@
     <select id="selectSTSLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
         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 (6,7,8,9,10,11,12,13,14,15, 16, 17)
+        WHERE <include refid="deptListOrDemandIdAll"></include> and`project_status` IN (6,7,8,9,10,11,12,13,14,15, 16,
+        17)
         and YEAR(create_time) = YEAR(NOW())-1
     </select>
 
     <select id="selectSTSThisYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
         SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
-        AND `project_status` &gt; 4
+        WHERE <include refid="deptListOrDemandIdAll"></include> and`project_status` &gt; 4
         and YEAR(create_time) = YEAR(NOW())
     </select>
 
@@ -814,11 +735,8 @@
             parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
         SELECT ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND (real_demand_commit_time &gt; plan_demand_sub_time)
     </select>
 
@@ -826,23 +744,17 @@
             parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
         SELECT project_type columnName, ifnull(COUNT(demand_id), 0) num, ifnull(sum(evaluation), 0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
-        GROUP BY project_type
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
+        and project_type=#{vo.projectType}
     </select>
 
     <select id="selectSTS" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
             parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
         SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
         FROM `pm_demand`
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND `project_status` &gt; 4
         and YEAR(create_time) = YEAR(NOW())
     </select>
@@ -853,18 +765,10 @@
         evaluationContractTotal
         FROM pm_demand d,pm_contract_info c,
         (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
-        purchase_dept_id
-        in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        <include refid="deptListOrDemandIdAll"></include>
         AND project_status &gt; 16 AND MONTH(create_time) =MONTH(NOW()) ) de
-        where d.demand_id = c.demand_id and purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        where d.demand_id = c.demand_id and
+        <include refid="dDeptListOrDemandIdAll"></include>
         AND d.project_status &gt; 16
         AND MONTH(d.create_time) = MONTH(NOW())
     </select>
@@ -875,18 +779,10 @@
         evaluationContractTotal
         FROM pm_demand d,pm_contract_info c,
         (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
-        purchase_dept_id
-        in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        <include refid="deptListOrDemandIdAll"></include>
         AND project_status &gt; 17 AND QUARTER(create_time) =QUARTER(NOW()) ) de
-        WHERE d.demand_id = c.demand_id and purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE d.demand_id = c.demand_id and
+        <include refid="dDeptListOrDemandIdAll"></include>
         AND d.project_status &gt; 17
         AND QUARTER(d.create_time) = QUARTER(NOW())
     </select>
@@ -897,18 +793,10 @@
         evaluationContractTotal
         FROM pm_demand d, pm_contract_info c,
         (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
-        purchase_dept_id
-        in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        <include refid="deptListOrDemandIdAll"></include>
         AND project_status IN (17,18) AND YEAR(create_time) = YEAR(NOW())-1 ) de
-        WHERE d.demand_id = c.demand_id and purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE d.demand_id = c.demand_id and
+        <include refid="dDeptListOrDemandIdAll"></include>
         AND d.project_status IN (17,18)
         AND YEAR(d.create_time) = YEAR(NOW())-1
     </select>
@@ -919,18 +807,10 @@
         evaluationContractTotal
         FROM pm_demand d, pm_contract_info c,
         (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
-        purchase_dept_id
-        in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        <include refid="deptListOrDemandIdAll"></include>
         AND project_status &gt; 17 AND YEAR(create_time) = YEAR(NOW()) ) de
-        WHERE d.demand_id = c.demand_id and purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE d.demand_id = c.demand_id and
+        <include refid="dDeptListOrDemandIdAll"></include>
         AND d.project_status &gt; 17
         AND YEAR(d.create_time) = YEAR(NOW())
     </select>
@@ -941,18 +821,10 @@
         evaluationContractTotal
         FROM pm_demand d, pm_contract_info c,
         (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
-        purchase_dept_id
-        in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        <include refid="deptListOrDemandIdAll"></include>
         AND project_status &gt; 17 ) de
-        WHERE d.demand_id = c.demand_id and purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE d.demand_id = c.demand_id and
+        <include refid="dDeptListOrDemandIdAll"></include>
         AND d.project_status &gt; 17
     </select>
 
@@ -960,11 +832,8 @@
             parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
         SELECT YEAR(NOW()) columnName,ifnull(COUNT(demand_id), 0) num,ifnull(sum(evaluation), 0) evaluationTotal
         FROM pm_demand
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND real_purchase_finish_time &lt;=plan_purchase_finish_time
         AND YEAR(create_time) = YEAR(NOW())
     </select>
@@ -972,12 +841,9 @@
     <sql id="countProjectExceedAndStatus">
         SELECT ifnull(COUNT(demand_id), 0) num,ifnull(sum(evaluation), 0) evaluationTotal
         FROM pm_demand
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
-        <if test="vo.projectStatusList!=null">
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
+        <if test="vo.projectStatusList!=null and vo.projectStatusList.size != 0">
             AND project_status in
             <foreach collection="vo.projectStatusList" item="item" index="index"
                      separator="," open="(" close=")">
@@ -990,13 +856,6 @@
     <select id="countProjectExceedAndStatus" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
             parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
         <include refid="countProjectExceedAndStatus"></include>
-        <if test="vo.demandIdAll !=null ">
-            AND demand_id in
-            <foreach collection="vo.demandIdAll" item="item" index="index"
-                     separator="," open="(" close=")">
-                #{item}
-            </foreach>
-        </if>
     </select>
 
     <select id="countBaseAgencyWithWhite" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
@@ -1009,11 +868,8 @@
             parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
         SELECT YEAR(NOW()) columnName,ifnull(COUNT(demand_id), 0) num,ifnull(sum(evaluation), 0) evaluationTotal
         FROM pm_demand
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
         AND project_status &gt; 8
         # AND YEAR(create_time) = YEAR(NOW())
     </select>
@@ -1022,12 +878,9 @@
             parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
         SELECT ifnull(COUNT(demand_id), 0) num,ifnull(sum(evaluation), 0) evaluationTotal
         FROM pm_demand
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
-        <if test="vo.projectStatusList!=null">
+        WHERE
+        <include refid="deptListOrDemandIdAll"></include>
+        <if test="vo.projectStatusList!=null and vo.projectStatusList.size != 0">
             AND project_status in
             <foreach collection="vo.projectStatusList" item="item" index="index"
                      separator="," open="(" close=")">
@@ -1044,18 +897,10 @@
         evaluationContractTotal
         FROM pm_demand d, pm_contract_info c,
         (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
-        purchase_dept_id
-        in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        <include refid="deptListOrDemandIdAll"></include>
         AND real_purchase_finish_time > plan_purchase_finish_time AND YEAR(create_time)=#{vo.year} ) de
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="dDeptListOrDemandIdAll"></include>
         AND d.demand_id = c.demand_id AND d.real_purchase_finish_time > d.plan_purchase_finish_time AND
         YEAR(d.create_time)=#{vo.year}
     </select>
@@ -1066,19 +911,11 @@
         evaluationContractTotal
         FROM pm_demand d, pm_contract_info c,
         (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
-        purchase_dept_id
-        in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        <include refid="deptListOrDemandIdAll"></include>
         AND real_purchase_finish_time > plan_purchase_finish_time AND YEAR(create_time)=#{vo.year} AND
         QUARTER(create_time)=#{vo.quarter}) de
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        WHERE
+        <include refid="dDeptListOrDemandIdAll"></include>
         AND d.demand_id = c.demand_id AND d.real_purchase_finish_time > d.plan_purchase_finish_time AND
         YEAR(d.create_time)=#{vo.year} AND QUARTER(d.create_time)=#{vo.quarter}
     </select>
@@ -1089,23 +926,60 @@
         evaluationContractTotal
         FROM pm_demand d, pm_contract_info c,
         (SELECT ifnull(COUNT(demand_id), 0) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
-        purchase_dept_id
-        in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
+        <include refid="deptListOrDemandIdAll"></include>
         AND real_purchase_finish_time > plan_purchase_finish_time AND
         YEAR(create_time)=#{vo.year} AND month(create_time)=#{vo.month}) de
-        WHERE purchase_dept_id in
-        <foreach collection="vo.deptList" item="item" index="index"
-                 separator="," open="(" close=")">
-            #{item}
-        </foreach>
-
+        WHERE
+        <include refid="dDeptListOrDemandIdAll"></include>
         AND d.demand_id = c.demand_id AND d.real_purchase_finish_time > d.plan_purchase_finish_time AND
         YEAR(d.create_time)=#{vo.year} AND month(d.create_time)=#{vo.month}
     </select>
 
+    <!--   统计里查询全部or查询指定部门及下级超额项目-->
+    <sql id="deptListOrDemandIdAll">
+        <if test="vo.deptList != null and vo.deptList.size != 0 ">
+            purchase_dept_id
+            in
+            <foreach collection="vo.deptList" item="item" index="index"
+                     separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="vo.deptList != null and vo.deptList.size != 0 and vo.demandIdAll != null and vo.demandIdAll.size != 0">
+            AND
+        </if>
+        <if test="vo.demandIdAll != null and vo.demandIdAll.size != 0 ">
+            demand_id
+            in
+            <foreach collection="vo.demandIdAll" item="item" index="index"
+                     separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+    </sql>
+
+
+    <sql id="dDeptListOrDemandIdAll">
+        <if test="vo.deptList != null and vo.deptList.size != 0 ">
+            d.purchase_dept_id
+            in
+            <foreach collection="vo.deptList" item="item" index="index"
+                     separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="vo.deptList != null and vo.deptList.size != 0 and vo.demandIdAll != null and vo.demandIdAll.size != 0">
+            AND
+        </if>
+        <if test="vo.demandIdAll != null and vo.demandIdAll.size != 0 ">
+            d.demand_id
+            in
+            <foreach collection="vo.demandIdAll" item="item" index="index"
+                     separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+    </sql>
+
 
 </mapper>

+ 10 - 1
purchase-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -226,6 +226,15 @@
         select *
         from sys_dept
         where del_flag = '0'
-          and parent_id = #{deptId} limit 1
+          and parent_id = #{deptId}
+        limit 1
+    </select>
+
+    <select id="selectByCid" resultType="com.ozs.common.core.domain.entity.SysDept"
+            parameterType="java.lang.Long">
+        SELECT parent_id
+        FROM sys_dept
+        WHERE dept_id = #{deptId}
+          and status = 0
     </select>
 </mapper>