Browse Source

feat: 系统月度使用情况统计调整

zhangying 8 months ago
parent
commit
f95683c243

+ 58 - 35
src/main/java/com/hz/employmentsite/controller/statistics/StatisticsController.java

@@ -53,8 +53,10 @@ public class StatisticsController {
      * @return
      */
     @GetMapping("/monthSystemApplyCount")
-    public BaseResponse findMonthSystemDataCount(@RequestParam String dateStr) {
-        Map<String, List<RegionSystemDataCount>> result = statisticsService.findMonthSystemDataCount(dateStr);
+    public BaseResponse findMonthSystemDataCount(@RequestParam String dateStr, @RequestParam(required = false) String regionCode,
+                                                 @RequestParam(required = false) String institutionID,
+                                                 @RequestParam(required = false) String siteID) {
+        Map<String, List<RegionSystemDataCount>> result = statisticsService.findMonthSystemDataCount(dateStr, regionCode, institutionID, siteID);
         return RespGenerstor.success(result);
     }
 
@@ -157,57 +159,78 @@ public class StatisticsController {
      * @return
      */
     @GetMapping("/export/monthSystemApplyCount")
-    public BaseResponse exportMonthSystemApplyCount(HttpServletResponse response, @RequestParam String dateStr) throws Exception {
-        Map<String, List<RegionSystemDataCount>> result = statisticsService.findMonthSystemDataCount(dateStr);
+    public BaseResponse exportMonthSystemApplyCount(HttpServletResponse response,
+                                                    @RequestParam String dateStr,
+                                                    @RequestParam(required = false) String regionCode,
+                                                    @RequestParam(required = false) String institutionID,
+                                                    @RequestParam(required = false) String siteID) throws Exception {
+        Map<String, List<RegionSystemDataCount>> result = statisticsService.findMonthSystemDataCount(dateStr, regionCode, institutionID, siteID);
         ExcelHelper.ExcelData data = excelHelper.new ExcelData();
         // 设置标题区域
         Map<String, CellRangeAddress> titleMap = new HashMap<>();
         titleMap.put("项目", new CellRangeAddress(0, 1, 0, 0));
         // 子标题
         List<String> childrenTitle = new ArrayList<>(Arrays.asList(""));
-        // 合并位置
+        // Excel数据
+        List<List<Object>> rowsData = new ArrayList();
+        // 初始合并位置
         int firstCol = 1;
-        // 生成周数标题
+        // 汇总有"驿站人员数量"
+        List<RegionSystemDataCount> 汇总 = result.get("汇总");
+        titleMap.put("汇总", new CellRangeAddress(0, 0, firstCol, firstCol + 3));
+        setRSDCExcelData(result.get("汇总"), rowsData, true);
+        // 填充子标题
+        childrenTitle.addAll(Arrays.asList("驿站人员数量","录入企业数量","收集岗位数量","登记求职人数"));
+        firstCol += 4;
+        // 生成周数标题,周数标题没有驿站人员数量
         for (Map.Entry<String, List<RegionSystemDataCount>> entry : result.entrySet()) {
             String key = entry.getKey();
-            titleMap.put(key, new CellRangeAddress(0, 0, firstCol, firstCol + 3));
-            // 填充子标题
-            childrenTitle.addAll(Arrays.asList("驿站人员数量","录入企业数量","收集岗位数量","登记求职人数"));
-            firstCol += 4;
+            if (!key.equals("汇总")){
+                titleMap.put(key, new CellRangeAddress(0, 0, firstCol, firstCol + 2));
+                // 填充子标题
+                childrenTitle.addAll(Arrays.asList("录入企业数量","收集岗位数量","登记求职人数"));
+                firstCol += 3;
+                setRSDCExcelData(result.get(key), rowsData,false);
+            }
         }
         data.setColspanTitles(Arrays.asList(titleMap));
         data.setTitles(childrenTitle);
-        // 开始生成数据
-        List<List<Object>> rowsData = new ArrayList();
-        // 遍历原始数据
-        for (List<RegionSystemDataCount> valueList : result.values()) {
-            for (RegionSystemDataCount item : valueList) {
-                boolean found = false;
-                // 判断最终结果中是否已经生成过相同的县区数据,如有则追加,不新建
-                for (List<Object> existingRow : rowsData) {
-                    if (existingRow.get(0).equals(item.getRegionName())) {
+        data.setRows(rowsData);
+        excelHelper.exportExcel(response, data);
+        return null;
+    }
+
+    /**
+     * 系统月度使用情况Excel数据生成
+     */
+    public void setRSDCExcelData (List<RegionSystemDataCount> valueList, List<List<Object>> rowsData, Boolean isSiteUserCount){
+        for (RegionSystemDataCount item : valueList) {
+            boolean found = false;
+            // 判断最终结果中是否已经生成过相同的县区数据,如有则追加,不新建
+            for (List<Object> existingRow : rowsData) {
+                if (existingRow.get(0).equals(item.getRegionName())) {
+                    if (isSiteUserCount){
                         existingRow.add(item.getSiteUserCount());
-                        existingRow.add(item.getCompanyCount());
-                        existingRow.add(item.getPostCount());
-                        existingRow.add(item.getJobUserCount());
-                        found = true;
-                        break;
                     }
+                    existingRow.add(item.getCompanyCount());
+                    existingRow.add(item.getPostCount());
+                    existingRow.add(item.getJobUserCount());
+                    found = true;
+                    break;
                 }
-                // 没有则新建
-                if (!found) {
-                    List<Object> row = new ArrayList<>();
-                    row.add(item.getRegionName());
+            }
+            // 没有则新建
+            if (!found) {
+                List<Object> row = new ArrayList<>();
+                row.add(item.getRegionName());
+                if (isSiteUserCount){
                     row.add(item.getSiteUserCount());
-                    row.add(item.getCompanyCount());
-                    row.add(item.getPostCount());
-                    row.add(item.getJobUserCount());
-                    rowsData.add(row);
                 }
+                row.add(item.getCompanyCount());
+                row.add(item.getPostCount());
+                row.add(item.getJobUserCount());
+                rowsData.add(row);
             }
         }
-        data.setRows(rowsData);
-        excelHelper.exportExcel(response, data);
-        return null;
     }
 }

+ 5 - 3
src/main/java/com/hz/employmentsite/mapper/cquery/StatisticsCQuery.java

@@ -10,7 +10,6 @@ import org.apache.ibatis.annotations.Param;
 import java.time.LocalDate;
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
 
 public interface StatisticsCQuery {
     /**
@@ -28,12 +27,15 @@ public interface StatisticsCQuery {
      * @param endDate 结束时间
      * @return 系统使用情况统计数量
      */
-    List<RegionSystemDataCount> findWeekSystemDataCount(@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
+    List<RegionSystemDataCount> findWeekSystemDataCount(@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate,
+                                                        @Param("regionCode") String regionCode, @Param("institutionID") String institutionID,
+                                                        @Param("siteID") String siteID);
 
     /**
      * 查询各区县的驿站工作人员合计数量
      */
-    List<Map<String, Object>> findRegionSiteUserCount();
+    List<RegionSystemDataCount> findRegionSiteUserCount(@Param("regionCode") String regionCode, @Param("institutionID") String institutionID,
+                                                        @Param("siteID") String siteID);
 
     /**
      * 查询各年龄段的求职人员数量

+ 9 - 12
src/main/java/com/hz/employmentsite/services/impl/statistics/StatisticsServiceImpl.java

@@ -85,9 +85,9 @@ public class StatisticsServiceImpl implements StatisticsService {
      * @return
      */
     @Override
-    public Map<String, List<RegionSystemDataCount>> findMonthSystemDataCount(String dateStr) {
+    public Map<String, List<RegionSystemDataCount>> findMonthSystemDataCount(String dateStr, String regionCode, String institutionID, String siteID) {
         // 各区县的驿站工作人员统计数量
-        List<Map<String, Object>> regionSiteUserCount = statisticsCQuery.findRegionSiteUserCount();
+        List<RegionSystemDataCount> regionSiteUserCount = statisticsCQuery.findRegionSiteUserCount(regionCode, institutionID, siteID);
 
         // 解析日期,获取每周的开始结束时间
         List<Map<String, LocalDate>> weekDate = dateUtils.getWeekDateByMonth(dateStr);
@@ -97,13 +97,10 @@ public class StatisticsServiceImpl implements StatisticsService {
         List<RegionSystemDataCount> sumData = new ArrayList<>();
         // 创建一个 map 来存储 regionCode 和 siteUserCount 的对应关系
         Map<String, Integer> siteUserCountMap = new HashMap<>();
-        for (Map<String, Object> objectMap : regionSiteUserCount) {
-            String regionCode = (String) objectMap.get("code");
-            String regionName = (String) objectMap.get("name");
-            int siteUserCount = ((Long) objectMap.get("siteUserCount")).intValue();
-            siteUserCountMap.put(regionCode, siteUserCount);
+        for (RegionSystemDataCount item : regionSiteUserCount) {
+            siteUserCountMap.put(item.getRegionCode(), item.getSiteUserCount());
             // 计算合计数量
-            RegionSystemDataCount summaryData = new RegionSystemDataCount(regionCode, regionName, siteUserCount, 0, 0, 0);
+            RegionSystemDataCount summaryData = new RegionSystemDataCount(item.getRegionCode(), item.getRegionName(), item.getSiteUserCount(), 0, 0, 0);
             sumData.add(summaryData);
         }
         // 按每周的日期进行系统使用数据查询
@@ -113,16 +110,16 @@ public class StatisticsServiceImpl implements StatisticsService {
             LocalDate endDate = weekDate.get(i).get("endDate");
 
             // 查询当前周的系统使用数据
-            List<RegionSystemDataCount> contData = statisticsCQuery.findWeekSystemDataCount(startDate, endDate);
+            List<RegionSystemDataCount> contData = statisticsCQuery.findWeekSystemDataCount(startDate, endDate, regionCode, institutionID, siteID);
 
             // 创建合计数据
             RegionSystemDataCount summaryData = new RegionSystemDataCount("100", "合计", 0, 0, 0, 0);
 
             // 填充驿站工作人员统计数量
             for (RegionSystemDataCount dataCount : contData) {
-                String regionCode = dataCount.getRegionCode();
-                if (siteUserCountMap.containsKey(regionCode)) {
-                    dataCount.setSiteUserCount(siteUserCountMap.get(regionCode));
+                String dataRegionCode = dataCount.getRegionCode();
+                if (siteUserCountMap.containsKey(dataRegionCode)) {
+                    dataCount.setSiteUserCount(siteUserCountMap.get(dataRegionCode));
                 }
                 // 合计数据累加
                 summaryData.setSiteUserCount(summaryData.getSiteUserCount() + dataCount.getSiteUserCount());

+ 1 - 1
src/main/java/com/hz/employmentsite/services/service/statistics/StatisticsService.java

@@ -25,7 +25,7 @@ public interface StatisticsService {
      * @param dateStr 月份日期
      * @return
      */
-    Map<String, List<RegionSystemDataCount>> findMonthSystemDataCount(String dateStr);
+    Map<String, List<RegionSystemDataCount>> findMonthSystemDataCount(String dateStr, String regionCode, String institutionID, String siteID);
 
     /**
      * 查询各年龄段的求职人员数量

+ 30 - 6
src/main/resources/mapping/cquery/StatisticsCQuery.xml

@@ -72,7 +72,7 @@
     <select id="findWeekSystemDataCount" resultType="com.hz.employmentsite.vo.statistics.RegionSystemDataCount">
         SELECT
             subquery.RegionCode,
-            area.`name` AS regionName,
+            subquery.RegionName,
             SUM(subquery.companyCount) AS companyCount,
             SUM(subquery.postCount) AS postCount,
             SUM(subquery.jobUserCount) AS jobUserCount
@@ -81,6 +81,7 @@
                 SELECT
                     site.SiteID,
                     site.RegionCode,
+                    area.`Name` AS RegionName,
                     -- 指定时间段的登记企业数量
                     (
                         SELECT COUNT(1)
@@ -122,26 +123,49 @@
                     ) AS jobUserCount
                 FROM
                     pc_site site
+                    LEFT JOIN area_code area ON site.RegionCode = area.`code`
+                    LEFT JOIN pc_site_institution siteInst ON site.SiteID = siteInst.SiteID
+                WHERE
+                    1=1
+                    <if test="siteID!='' and siteID!=null">
+                        and site.siteID = #{siteID}
+                    </if>
+                    <if test="institutionID!='' and institutionID!=null">
+                        and siteInst.institutionID = #{institutionID}
+                    </if>
+                    <if test="regionCode!='' and regionCode!=null">
+                        and area.`code` = #{regionCode}
+                    </if>
             ) AS subquery
-                LEFT JOIN area_code area ON subquery.RegionCode = area.`code`
         GROUP BY
-            subquery.RegionCode, area.`name`
+            subquery.RegionCode,
+            subquery.RegionName
         ORDER BY
             subquery.RegionCode;
     </select>
 
-    <select id="findRegionSiteUserCount" resultType="Map">
+    <select id="findRegionSiteUserCount" resultType="com.hz.employmentsite.vo.statistics.RegionSystemDataCount">
         SELECT
-            area.`code`,
-            area.`name`,
+            area.`code` AS regionCode,
+            area.`name` AS regionName,
             COUNT( sysUser.UserID ) AS siteUserCount
         FROM
             area_code area
                 LEFT JOIN pc_site site ON site.RegionCode = area.`code`
                 LEFT JOIN pc_site_user siteUser ON site.SiteID = siteUser.SiteID
                 LEFT JOIN sys_user sysUser ON siteUser.UserID = sysUser.UserID AND sysUser.RecordStatus = 1
+                LEFT JOIN pc_site_institution siteInst ON site.SiteID = siteInst.SiteID
         WHERE
             area.lv = 3
+            <if test="siteID!='' and siteID!=null">
+                and site.siteID = #{siteID}
+            </if>
+            <if test="institutionID!='' and institutionID!=null">
+                and siteInst.institutionID = #{institutionID}
+            </if>
+            <if test="regionCode!='' and regionCode!=null">
+                and area.`code` = #{regionCode}
+            </if>
         GROUP BY
             area.`code`,
             area.`name`

+ 2 - 1
vue/src/utils/echartsUtil.ts

@@ -41,7 +41,8 @@ export function initBarImageTable(xTitleList: any, yValueList: any, domId: any,
     series: [
       {
         data: yValueList,
-        type: 'bar'
+        type: 'bar',
+        barMaxWidth: '50px',
       }
     ]
   };

+ 6 - 2
vue/src/views/statistics/JobUserCount.vue

@@ -167,6 +167,7 @@ async function ageRangeOnSearch() {
     let bars = ['男', '女'].map((name, index) => ({
       name,
       type: 'bar',
+      barMaxWidth: '50px',
       stack: 'ageRange',
       emphasis: {focus: 'series'},
       data: index == 0 ? imageTableMaleCount : imageTableFemaleCount
@@ -248,6 +249,7 @@ async function personTypeOnSearch() {
       bars.push({
         name: key,
         type: 'bar',
+        barMaxWidth: '50px',
         stack: 'ageRange',
         emphasis: {focus: 'series'},
         data: yValueList[key]
@@ -276,10 +278,12 @@ async function regionDifficultyOnSearch() {
     result.forEach((item: any) => {
       arr.push([item.regionName, item.jobUserCount, item.difficultyCount])
     })
-    
+
     // 生成表格
     setTimeout(() => {
-      initDataSetBarImageTable(arr, [{type: 'bar'}, {type: 'bar'}], 'regionAndDifficultyImageTable', '各区县失业人员与就业困难人员情况统计')
+      initDataSetBarImageTable(arr,
+        [{type: 'bar', barMaxWidth: '50px'}, {type: 'bar', barMaxWidth: '50px',}],
+        'regionAndDifficultyImageTable', '各区县失业人员与就业困难人员情况统计')
     }, 100)
   }).finally(() => {
     searchLoading.value = false;

+ 105 - 15
vue/src/views/statistics/MonthSystemApplyCount.vue

@@ -14,9 +14,59 @@
                            @change="pickerDateChange"/>
           </a-form-item>
         </a-col>
+        <a-col :span="6">
+          <a-form-item label="所属机构" :label-col="{span:6}" name="institutionID">
+            <a-select
+              ref="select"
+              v-model:value="searchParams.institutionID"
+              :options="allInstitutions"
+              :field-names="{ label: 'text', value: 'value' }"
+              :allow-clear="true"
+              @change="loadData"
+            >
+            </a-select>
+          </a-form-item>
+        </a-col>
+        <a-col :span="6">
+          <a-form-item label="所属县区" :label-col="{span:6}" name="regionCode">
+            <a-select
+              ref="select"
+              v-model:value="searchParams.regionCode"
+              :options="regionList"
+              :field-names="{ label: 'name', value: 'code' }"
+              :allow-clear="true"
+              @change="loadData"
+            >
+            </a-select>
+          </a-form-item>
+        </a-col>
         <a-col :span="6" style="text-align: left">
           <a-button type="primary" html-type="submit" @click="loadData" :loading="tableLoading">查询</a-button>
           <a-button style="margin: 0 8px" @click="onReset">重置</a-button>
+          <a style="font-size: 12px" @click="expand = !expand">
+            <template v-if="expand">
+              <UpOutlined/>
+            </template>
+            <template v-else>
+              <DownOutlined/>
+            </template>
+            {{ expand ? '收缩' : '展开' }}
+          </a>
+        </a-col>
+      </a-row>
+      <a-row :gutter="24" v-show="expand">
+        <a-col :span="6">
+          <a-form-item label="所属驿站" :label-col="{span:6}" name="siteID">
+            <a-select
+              ref="select"
+              v-model:value="searchParams.siteID"
+              :options="allSites"
+              @change="loadData"
+              :field-names="{ label: 'siteName', value: 'siteID' }"
+              :allow-clear="true"
+            >
+            </a-select>
+          </a-form-item>
         </a-col>
       </a-row>
     </a-form>
@@ -55,15 +105,25 @@
 </template>
 
 <script setup lang="ts">
-import {computed, nextTick, onMounted, reactive, ref} from "vue";
+import {computed, onMounted, reactive, ref} from "vue";
 import {getMonthSystemDataCount} from "@/api/statistics";
 import dayjs from "dayjs";
 import BExportExcel from "@/components/basic/excel/exportExcel/exportExcel.vue";
 import {initBarImageTable, initLineImageTable} from "@/utils/echartsUtil";
+import {getInstitutionDataList} from "@/api/baseSettings/institution";
+import {getRegionCodeList} from "@/api/system/area/index";
+import type {SelectProps} from "ant-design-vue";
+import {DownOutlined, UpOutlined} from "@ant-design/icons-vue";
+import {getSiteList} from "@/api/baseSettings/siteInfo";
+
+const expand = ref(false);
 
 // 查询条件
 const searchParams = reactive({
   dateStr: "",
+  institutionID: "",
+  regionCode: "",
+  siteID: ""
 })
 // 导出Excel查询参数
 const exportSearchParams = computed(() => {
@@ -93,6 +153,12 @@ const originalColumns = ref<Array<any>>([
 ])
 // 查询方法未处理的初始数据
 const searchOriginalList = ref();
+// 运营机构
+const allInstitutions = ref<any>([]);
+// 所属区县
+const regionList = ref<SelectProps['options']>();
+// 驿站
+const allSites = ref<any>([]);
 
 // 数据加载
 function loadData() {
@@ -128,13 +194,13 @@ function analysisByTable() {
     title: '项目', dataIndex: 'regionName', key: 'regionName', align: "center", width: 200, fixed: 'left'
   }]
 
+  // 解析汇总数据
+  initTableData(searchOriginalList.value, '汇总', arr, 'hz', true);
   // 解析第一周到第五周的统计数据
   for (let i = 1; i <= 5; i++) {
     // 填充数据
-    initTableData(searchOriginalList.value, '第' + i + '周', arr, i + 'z');
+    initTableData(searchOriginalList.value, '第' + i + '周', arr, i + 'z', false);
   }
-  // 解析汇总数据
-  initTableData(searchOriginalList.value, '汇总', arr, 'hz');
   systemApplyCount.value = arr;
 }
 
@@ -225,7 +291,7 @@ function pickerDateChange(date: any, dateStr: string) {
 }
 
 // 表格数据与结构定义初始化
-function initTableData(result: any, resultKey: any, arr: any, arrNewKey: any) {
+function initTableData(result: any, resultKey: any, arr: any, arrNewKey: any, isShowSiteUser: boolean) {
   if (!result[resultKey]) {
     return;
   }
@@ -241,17 +307,9 @@ function initTableData(result: any, resultKey: any, arr: any, arrNewKey: any) {
       });
     }
   })
-  // 填充表结构
-  originalColumns.value.push({
+  let table = {
     title: resultKey,
     children: [
-      {
-        title: '驿站人员数量',
-        dataIndex: 'siteUserCount' + arrNewKey,
-        key: 'siteUserCount' + arrNewKey,
-        width: 120,
-        align: "center"
-      },
       {
         title: '录入企业数量',
         dataIndex: 'companyCount' + arrNewKey,
@@ -274,7 +332,19 @@ function initTableData(result: any, resultKey: any, arr: any, arrNewKey: any) {
         align: "center"
       },
     ]
-  })
+  }
+  // 按要求进行展示驿站人员数量
+  if (isShowSiteUser) {
+    table.children.unshift({
+      title: '驿站人员数量',
+      dataIndex: 'siteUserCount' + arrNewKey,
+      key: 'siteUserCount' + arrNewKey,
+      width: 120,
+      align: "center"
+    },)
+  }
+  // 填充表结构
+  originalColumns.value.push(table)
 }
 
 function dataTypeChange() {
@@ -288,9 +358,29 @@ function dataTypeChange() {
   }
 }
 
+const getAllInstitutions = async function () {
+  allInstitutions.value = await getInstitutionDataList();
+}
+
+const getRegionList = async function () {
+  regionList.value = await getRegionCodeList();
+}
+
+const getAllSites = () => {
+  getSiteList({
+    pageIndex: 1,
+    pageSize: 9999
+  }).then((result: any) => {
+    allSites.value = result.list;
+  })
+}
+
 onMounted(() => {
   searchParams.dateStr = dayjs().format("YYYY-MM");
   loadData();
+  getAllInstitutions();
+  getRegionList();
+  getAllSites();
 })
 </script>