智慧保安后台管理项目备份
Administrator
2021-12-02 6402b58adab36c22482d27025555f345b9e0d9a6
业务统计修改
3 files modified
1 files added
335 ■■■■ changed files
src/main/java/org/springblade/modules/information/mapper/InformationMapper.java 47 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml 177 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/service/impl/InformationServiceImpl.java 31 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/vo/InformationStatisticsVO.java 80 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/mapper/InformationMapper.java
@@ -21,10 +21,12 @@
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.dispatcher.vo.DispatcherVO;
import org.springblade.modules.information.entity.Information;
import org.springblade.modules.information.vo.InformationStatisticsVO;
import org.springblade.modules.information.vo.InformationVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.information.vo.ResponseVo;
import org.springblade.modules.system.entity.Dept;
import java.util.List;
import java.util.Map;
@@ -65,7 +67,7 @@
    List<Map<Object,Object>> queryCountKh(String jurisdiction,String deptid);
    List<Map<Object,Object>> queryCountPq(String jurisdiction,String deptid);
    List<Map<String, Object>> seleP(String jurisdiction,String deptid);
    List selectYw(IPage page,String jurisdiction,String deptid,String stats,String startTime,String endTime);
    List<InformationStatisticsVO> selectYw(IPage page, String jurisdiction, String deptid, String stats, String startTime, String endTime);
    List selectUIn(IPage page,String deptid,String name,String hold,String photo,String examinationtype,String dispatch,String soil);
    List<Map<Object,Object>> selectJur();
    int selectExtypeUser();
@@ -180,4 +182,47 @@
     * @return
     */
    List<ResponseVo> getSecurityHoldAndSoidAndDispatchGroupCountList(Integer type);
    /**
     * 查询当前单位是否有子级单位
     * @param informationStatisticsVO
     * @return
     */
    List<Dept> getDeptHashChildren(@Param("information") InformationStatisticsVO informationStatisticsVO);
    /**
     * 查询单位的人数
     * @param dept
     * @return
     */
    Integer selectInformationUserNumCount(@Param("dept")Dept dept);
    /**
     * 查询单位的已派遣人数
     * @param dept
     * @return
     */
    Integer selectInformationDispatcherNumCount(@Param("dept")Dept dept);
    /**
     * 查询单位持证的人数
     * @param dept
     * @return
     */
    Integer selectInformationHoldNumCount(@Param("dept")Dept dept);
    /**
     * 服务单位数
     * @param dept
     * @return
     */
    Integer selectInformationUnitNumCount(@Param("dept")Dept dept);
    /**
     * 服务单位到期数
     * @param dept
     * @return
     */
    Integer selectInformationUnitExpireNumCount(@Param("dept")Dept dept);
}
src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
@@ -1683,18 +1683,18 @@
    <!--业务统计情况-->
    <select id="selectYw" resultType="java.util.HashMap">
    <select id="selectYw" resultType="org.springblade.modules.information.vo.InformationStatisticsVO">
        SELECT
        A.enterpriseName,
        A.departmentid,
        A.stats,
        A.jurisdiction,
        j.dept_name as jurname,
        IFNULL( B.num, 0 ) AS fwnum,
        IFNULL( C.znum, 0 ) AS znum,
        IFNULL( D.dqnum, 0 ) AS dqnum,
        IFNULL( E.cznum, 0 ) AS cznum,
        IFNULL( F.pqnum, 0 ) AS pqnum
        IFNULL( F.pqnum, 0 ) AS pqnum,
        IFNULL( B.num, 0 ) AS fwnum,
        IFNULL( D.dqnum, 0 ) AS dqnum
        FROM
        (
        SELECT enterpriseName,jurisdiction, departmentid,stats FROM sys_information WHERE stats!=1 GROUP BY
@@ -1710,17 +1710,6 @@
        LEFT JOIN
        (
        SELECT
        J.znum+J.fznum as znum,
        J.dept_id
        FROM
        (
        SELECT
        A.znum,
        IFNULL( B.znum, 0 ) AS fznum,
        A.dept_id
        FROM
        (
        SELECT
        COUNT( * ) AS znum,
        bu.dept_id
        FROM
@@ -1731,22 +1720,6 @@
        AND bu.role_id = '1412226235153731586'
        GROUP BY
        bu.dept_id
        ) A
        LEFT JOIN (
        SELECT
        IFNULL( COUNT( * ), 0 ) AS znum,
        bd.parent_id
        FROM
        blade_user bu
        LEFT JOIN blade_dept bd ON bu.dept_id = bd.id
        WHERE
        bu.`status` = 1
        AND bu.is_deleted = 0
        AND bu.role_id = '1412226235153731586'
        GROUP BY
        bd.parent_id
        ) B ON B.parent_id = A.dept_id
        ) J
        ) C
        ON A.departmentid = C.dept_id
        LEFT JOIN
@@ -1767,10 +1740,15 @@
        LEFT JOIN
        (
        SELECT
        SUM(num) AS pqnum,
        count(*) AS pqnum,
        dept_id
        FROM
        sys_dispatcher
        blade_user
        where 1=1
        and status = 1
        and is_deleted = 0
        and role_id = "1412226235153731586"
        and dispatch = 0
        GROUP BY
        dept_id
        ) F
@@ -3203,4 +3181,137 @@
            and i.jurisdiction in(${jurisdiction})
        </if>
    </select>
    <!--查询当前单位是否有子级单位-->
    <select id="getDeptHashChildren" resultType="org.springblade.modules.system.entity.Dept">
        select * from blade_dept where is_deleted = 0 and parent_id = #{information.departmentid}
        and dept_category !=2
    </select>
    <!--查询单位的人数-->
    <select id="selectInformationUserNumCount" resultType="java.lang.Integer">
        SELECT COUNT( * ) FROM blade_user
        WHERE 1=1
        and role_id = '1412226235153731586'
        and is_deleted = 0
        AND status=1
        and dept_id in
            (
                SELECT
                id
                FROM
                (
                SELECT
                t1.id,t1.parent_id,t1.dept_name,
                IF
                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
                FROM
                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
                ( SELECT @pids := #{dept.id} ) t2
                ) t3
                WHERE
                ischild != 0
            )
    </select>
    <!--查询单位的已派遣人数-->
    <select id="selectInformationDispatcherNumCount" resultType="java.lang.Integer">
        SELECT COUNT( * ) FROM blade_user
        WHERE 1=1
        and role_id = '1412226235153731586'
        and is_deleted = 0
        AND status=1
        AND dispatch=0
        and dept_id in
            (
                SELECT
                id
                FROM
                (
                SELECT
                t1.id,t1.parent_id,t1.dept_name,
                IF
                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
                FROM
                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
                ( SELECT @pids := #{dept.id} ) t2
                ) t3
                WHERE
                ischild != 0
            )
    </select>
    <!--查询单位持证的人数-->
    <select id="selectInformationHoldNumCount" resultType="java.lang.Integer">
        SELECT COUNT( * ) FROM blade_user
        WHERE 1=1
        and role_id = '1412226235153731586'
        and is_deleted = 0
        AND status=1
        AND hold=1
        and dept_id in
            (
                SELECT
                id
                FROM
                (
                SELECT
                t1.id,t1.parent_id,t1.dept_name,
                IF
                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
                FROM
                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
                ( SELECT @pids := #{dept.id} ) t2
                ) t3
                WHERE
                ischild != 0
            )
    </select>
    <!--查询服务单位数-->
    <select id="selectInformationUnitNumCount" resultType="java.lang.Integer">
        SELECT COUNT(*) FROM sys_dispatcher_unit
        where
        start_time &lt;= now() and end_time &gt; now()
        and dept_id in
            (
                SELECT
                id
                FROM
                (
                SELECT
                t1.id,t1.parent_id,t1.dept_name,
                IF
                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
                FROM
                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
                ( SELECT @pids := #{dept.id} ) t2
                ) t3
                WHERE
                ischild != 0
            )
    </select>
    <!--查询服务单位到期数-->
    <select id="selectInformationUnitExpireNumCount" resultType="java.lang.Integer">
        SELECT COUNT(*) FROM sys_dispatcher_unit
        where end_time &lt; now()
        and dept_id in
            (
                SELECT
                id
                FROM
                (
                SELECT
                t1.id,t1.parent_id,t1.dept_name,
                IF
                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
                FROM
                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
                ( SELECT @pids := #{dept.id} ) t2
                ) t3
                WHERE
                ischild != 0
            )
    </select>
</mapper>
src/main/java/org/springblade/modules/information/service/impl/InformationServiceImpl.java
@@ -18,11 +18,13 @@
import org.springblade.modules.dispatcher.vo.DispatcherVO;
import org.springblade.modules.information.entity.Information;
import org.springblade.modules.information.vo.InformationStatisticsVO;
import org.springblade.modules.information.vo.InformationVO;
import org.springblade.modules.information.mapper.InformationMapper;
import org.springblade.modules.information.service.IInformationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.information.vo.ResponseVo;
import org.springblade.modules.system.entity.Dept;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -224,7 +226,34 @@
    @Override
    public IPage selectYw(IPage page,String jurisdiction, String deptid,String stats,String startTime,String endTime) {
        return page.setRecords(baseMapper.selectYw(page,jurisdiction, deptid,stats,startTime,endTime));
        List<InformationStatisticsVO> list = baseMapper.selectYw(page, jurisdiction, deptid, stats, startTime, endTime);
        if (list.size()>0) {
            //遍历
            for (InformationStatisticsVO informationStatisticsVO : list) {
                List<Dept> deptList = baseMapper.getDeptHashChildren(informationStatisticsVO);
                //有子级
                if (deptList.size()>0){
                    Dept dept = new Dept();
                    dept.setId(Long.parseLong(informationStatisticsVO.getDepartmentid()));
                    //查询当前子单位的人数
                    Integer z = baseMapper.selectInformationUserNumCount(dept) + informationStatisticsVO.getZnum();
                    informationStatisticsVO.setZnum(z);
                    //已派遣人数
                    Integer p = baseMapper.selectInformationDispatcherNumCount(dept) + informationStatisticsVO.getPqnum();
                    informationStatisticsVO.setPqnum(p);
                    //持证人数
                    Integer c = baseMapper.selectInformationHoldNumCount(dept) + informationStatisticsVO.getCznum();
                    informationStatisticsVO.setCznum(c);
                    //服务单位数
                    Integer f = baseMapper.selectInformationUnitNumCount(dept) + informationStatisticsVO.getFwnum();
                    informationStatisticsVO.setFwnum(f);
                    //服务单位到期数
                    Integer d = baseMapper.selectInformationUnitExpireNumCount(dept) + informationStatisticsVO.getDqnum();
                    informationStatisticsVO.setDqnum(d);
                }
            }
        }
        return page.setRecords(list);
    }
    @Override
src/main/java/org/springblade/modules/information/vo/InformationStatisticsVO.java
New file
@@ -0,0 +1,80 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.information.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.information.entity.Information;
/**
 * 视图实体类
 *
 * @author BladeX
 * @since 2021-12-02
 */
@Data
public class InformationStatisticsVO {
    private static final long serialVersionUID = 1L;
    /**
     * 公司名称
     */
    private String enterpriseName;
    /**
     * 公司id
     */
    private String departmentid;
    /**
     * 公司类型
     */
    private String stats;
    /**
     * 辖区名称
     */
    private String jurname;
    /**
     * 总人数
     */
    private Integer znum;
    /**
     * 持证人数
     */
    private Integer cznum;
    /**
     * 派遣人数
     */
    private Integer pqnum;
    /**
     * 服务单位数
     */
    private Integer fwnum;
    /**
     * 到期单位数
     */
    private Integer dqnum;
}