智慧保安后台管理项目备份
zengh
2021-08-15 0cab6d8afcc97e8bc94ef200e24d8839281f44c8
Merge remote-tracking branch 'origin/master'
14 files modified
219 ■■■■ changed files
src/main/java/org/springblade/common/utils/InvestigateUtil.java 16 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/entity/Apply.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml 41 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/apply/vo/ApplyVO.java 21 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/controller/InformationController.java 22 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/mapper/InformationMapper.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml 19 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/service/IInformationService.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/information/service/impl/InformationServiceImpl.java 8 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/investigate/Investigate.java 56 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/IUserService.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/InvestigateUtil.java
@@ -4,6 +4,9 @@
import okhttp3.Request;
import okhttp3.Response;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
/**
 * @author zhongrj
 * @date 2021-08-12
@@ -25,4 +28,17 @@
        }
        return null;
    }
    // 工具方法
    public static <T> Consumer<T> consumerWithIndex(BiConsumer<T, Integer> consumer) {
        class Obj {
            int i;
        }
        Obj obj = new Obj();
        return t -> {
            int index = obj.i++;
            consumer.accept(t, index);
        };
    }
}
src/main/java/org/springblade/modules/apply/entity/Apply.java
@@ -158,11 +158,13 @@
    /**
     * 审核状态
     */
    @TableField("examination_type")
    private String examinationType;
    /**
     * 审核明细
     */
    @TableField("examination_mx")
    private String examinationMx;
    /**
src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml
@@ -5,28 +5,41 @@
    <!--考试报名分页信息-->
    <select id="selectApplyPage" resultType="org.springblade.modules.apply.vo.ApplyVO">
        SELECT
            sa.id,sa.user_id userId,sa.candidate_no candidateNo,apply_time,exam_id examId,
            ke.total_score paperScore,ke.exam_type examType,ke.start_time examTime,ke.exam_name examName,
            bu.real_name realName,sa.examination_type,sa.examination_mx,
            bd.dept_name deptName
        sa.id,sa.apply_status applyStatus,sa.user_id userId,sa.candidate_no candidateNo,apply_time,exam_id examId,
        sa.examination_type examinationType,sa.examination_mx examinationMx,
        ke.total_score paperScore,ke.exam_type examType,ke.start_time examTime,ke.exam_name examName,
        bu.real_name realName,bu.is_apply isApply,
        bd.dept_name deptName,bu.cardid idCardNo,"保安证" applyCard
        FROM
            sys_apply sa
        sys_apply sa
        left join
            ksxt_exam ke
        ksxt_exam ke
        on
            sa.exam_id = ke.id
        sa.exam_id = ke.id
        left join
            blade_user bu
        blade_user bu
        on
            sa.user_id = bu.id
        sa.user_id = bu.id
        left join
            blade_dept bd
        blade_dept bd
        on
            bd.id = bu.dept_id
        bd.id = bu.dept_id
        WHERE
            1=1
        <if test="apply.name!=null and  apply.name!=''">
            and sa.name like concat('%', #{apply.name},'%')
        1=1
        and is_exam = 1
        and sa.apply_status = 2
        and bu.is_apply = 1
        <if test="apply.realName!=null and  apply.realName!=''">
            and bu.real_name like concat('%', #{apply.realName},'%')
        </if>
        <if test="apply.deptName!=null and  apply.deptName!=''">
            and bd.dept_name like concat('%', #{apply.deptName},'%')
        </if>
        <if test="apply.userId!=null and  apply.userId!=''">
            and sa.user_id like concat('%', #{apply.userId},'%')
        </if>
        <if test="apply.examinationType!=null and  apply.examinationType!=''">
            and sa.examination_type = #{apply.examinationType}
        </if>
        <if test="apply.applyStatus!=null">
            and apply_status = #{apply.applyStatus}
src/main/java/org/springblade/modules/apply/vo/ApplyVO.java
@@ -63,8 +63,29 @@
    private String idCardNo;
    /**
     * 报考的证件
     */
    private String applyCard;
    /**
     * 用户ids
     */
    private String userIds;
    /**
     * 报名状态
     */
    private Integer isApply;
    /**
     * 保安姓名
     */
    private String realName;
    /**
     * 性别 1:男  2:女
     */
    private Integer sex;
}
src/main/java/org/springblade/modules/information/controller/InformationController.java
@@ -605,16 +605,19 @@
    }
    /**
     * 统计保安员资格异常的数量
     * @param jurisdiction
     * @param deptid
     * @param type 1:当天  2:当月 3:全部
     * @return
     */
    @PostMapping("/selectExtype")
    public R selectExtype(String jurisdiction,String deptid) {
    public R selectExtype(String jurisdiction,String deptid,String type) {
        Map<String, Object> map = new HashMap<String, Object>();
        Integer count=0;
        List<Map<String, Object>> lists = new ArrayList<>();
        List<Map<Object, Object>> maps = informationService.selectExtype(jurisdiction, deptid);
        List<Map<Object, Object>> maps = informationService.selectExtype(jurisdiction, deptid,type);
        for (int i=0;i<maps.size();i++){
            String num = maps.get(i).get("num").toString();
            count+= Integer.valueOf(num);
@@ -625,15 +628,20 @@
        return R.data(lists);
    }
    /**
     * 统计保安员表现差的数量
     * @param jurisdiction
     * @param deptid
     * @param type 1:当天  2:当月 3:全部
     * @return
     */
    @PostMapping("/selectBx")
    public R selectBx(String jurisdiction,String deptid) {
    public R selectBx(String jurisdiction,String deptid,String type) {
        Map<String, Object> map = new HashMap<String, Object>();
        Integer count=0;
        List<Map<String, Object>> lists = new ArrayList<>();
        List<Map<Object, Object>> maps = informationService.selectBx(jurisdiction, deptid);
        List<Map<Object, Object>> maps = informationService.selectBx(jurisdiction, deptid,type);
        for (int i=0;i<maps.size();i++){
            String num = maps.get(i).get("num").toString();
            count+= Integer.valueOf(num);
@@ -663,13 +671,13 @@
            //辖区名称
            String jurname = list.get(i).get("dept_name").toString();
            //保安员表现差预警数量
            List<Map<Object, Object>> mapbx = informationService.selectBx(jurisdiction, "");
            List<Map<Object, Object>> mapbx = informationService.selectBx(jurisdiction, "","");
            for (int ibx=0;ibx<mapbx.size();ibx++){
                String num = mapbx.get(ibx).get("num").toString();
                count+= Integer.valueOf(num);
            }
            //保安员资格异常的数量
            List<Map<Object, Object>> mapEx = informationService.selectExtype(jurisdiction, "");
            List<Map<Object, Object>> mapEx = informationService.selectExtype(jurisdiction, "","");
            for (int iex=0;iex<mapEx.size();iex++){
                String num = mapEx.get(iex).get("num").toString();
                count+= Integer.valueOf(num);
src/main/java/org/springblade/modules/information/mapper/InformationMapper.java
@@ -59,8 +59,8 @@
    List<Map<Object,Object>> queryCountKh(String jurisdiction,String deptid);
    List<Map<Object,Object>> queryCountPq(String jurisdiction,String deptid);
    List<Map<Object,Object>> selectJur();
    List<Map<Object,Object>> selectExtype(String jurisdiction,String deptid);
    List<Map<Object,Object>> selectBx(String jurisdiction,String deptid);
    List<Map<Object,Object>> selectExtype(String jurisdiction,String deptid,String type);
    List<Map<Object,Object>> selectBx(String jurisdiction,String deptid,String type);
    List<Map<Object,Object>> seCountI(String jurisdiction,String deptid);
    String seCountUm(String jurisdiction,String deptid);
    String seCountUg(String jurisdiction,String deptid);
src/main/java/org/springblade/modules/information/mapper/InformationMapper.xml
@@ -65,7 +65,8 @@
        SELECT IFNULL(B.confess, 0)  AS confess,
               IFNULL(C.staff, 0)    AS staff,
               IFNULL(D.security, 0) AS security,
               IFNULL(E.armed, 0)    AS armed
               IFNULL(E.armed, 0)    AS armed,
               IFNULL(F.region, 0)    AS region
        FROM (SELECT jurisdiction FROM sys_information GROUP BY jurisdiction) A
                 LEFT JOIN (SELECT COUNT(stats) AS confess, jurisdiction
                            FROM sys_information
@@ -83,6 +84,10 @@
                            FROM sys_information
                            WHERE stats = 3
                            GROUP BY jurisdiction) E ON A.jurisdiction = E.jurisdiction
                 LEFT JOIN (SELECT COUNT(stats) AS region, jurisdiction
                            FROM sys_information
                            WHERE stats = 4
                            GROUP BY jurisdiction) F ON A.jurisdiction = E.jurisdiction
        WHERE A.jurisdiction = #{departmentid}
    </select>
@@ -729,6 +734,12 @@
        <if test="deptid!=null and deptid!=''">
            and u.dept_id =#{deptid}
        </if>
        <if test="type=1">
            and to_days(u.update_time) = to_days(now());
        </if>
        <if test="type=2">
            and DATE_FORMAT(u.update_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
        </if>
        GROUP BY d.dept_name,
        j.dept_name
    </select>
@@ -747,6 +758,12 @@
        <if test="deptid!=null and deptid!=''">
            and u.departmentid =#{deptid}
        </if>
        <if test="type=1">
            and to_days(u.time) = to_days(now());
        </if>
        <if test="type=2">
            and DATE_FORMAT(u.time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )
        </if>
        GROUP BY d.dept_name,
        j.dept_name
    </select>
src/main/java/org/springblade/modules/information/service/IInformationService.java
@@ -61,9 +61,9 @@
    Map<String, String> queryYearCz(String year,String jurisdiction,String deptid);
    Map<String, String> queryYearKh(String year,String jurisdiction,String deptid);
    Map<String, String> queryYearBanan(String year,String jurisdiction,String deptid);
    List<Map<Object,Object>> selectExtype(String jurisdiction,String deptid);
    List<Map<Object,Object>> selectExtype(String jurisdiction,String deptid,String type);
    List<Map<Object,Object>> selectJur();
    List<Map<Object,Object>> selectBx(String jurisdiction,String deptid);
    List<Map<Object,Object>> selectBx(String jurisdiction,String deptid,String type);
    Map<String, String> queryYearDe(String year,String jurisdiction,String deptid);
    Map selectPcount(String jurisdiction,String deptid);
    Map selectWPcount(String jurisdiction,String deptid);
src/main/java/org/springblade/modules/information/service/impl/InformationServiceImpl.java
@@ -141,8 +141,8 @@
    }
    @Override
    public List<Map<Object, Object>> selectExtype(String jurisdiction, String deptid) {
        return baseMapper.selectExtype(jurisdiction, deptid);
    public List<Map<Object, Object>> selectExtype(String jurisdiction, String deptid,String type) {
        return baseMapper.selectExtype(jurisdiction, deptid,type);
    }
    @Override
@@ -151,8 +151,8 @@
    }
    @Override
    public List<Map<Object, Object>> selectBx(String jurisdiction, String deptid) {
        return baseMapper.selectBx(jurisdiction, deptid);
    public List<Map<Object, Object>> selectBx(String jurisdiction, String deptid,String type) {
        return baseMapper.selectBx(jurisdiction, deptid,type);
    }
    @Override
src/main/java/org/springblade/modules/investigate/Investigate.java
@@ -5,11 +5,19 @@
import org.json.JSONArray;
import org.json.JSONObject;
import org.springblade.common.utils.InvestigateUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springframework.retry.backoff.Sleeper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
/**
 * @author zhongrj
@@ -19,6 +27,8 @@
@RestController
@AllArgsConstructor
public class Investigate {
    private final IUserService userService;
    /**
     *
@@ -31,6 +41,46 @@
        return InvestigateUtil.httpGet(idCardNo);
    }
    /**
     *
     * @param idCardNo 身份证号码
     * @return
     */
    @GetMapping("/investigate/byUser")
    public R investigateByUser(){
        //查询用户数据,未删除的
        List<User> users = userService.getAllUserList();
        //遍历
        users.forEach(InvestigateUtil.consumerWithIndex((user,index) ->{
            if (index==99){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            String body = InvestigateUtil.httpGet(user.getCardid());
            JSONObject jsonObject = new JSONObject(body);
            Object data = jsonObject.get("data");
            JSONObject jsonData = new JSONObject(data.toString());
            JSONArray res = jsonData.getJSONArray("res");
            if (res.length()==0){
                //没有数据正常
                user.setExaminationType("0");
            }else {
                user.setExaminationType("1");
                user.setExaminationMx(res.getJSONObject(0).get("zdxsfzqkry").toString());
            }
            //更新用户数据
            userService.updateById(user);
        }));
        return R.data(users.size());
    }
    /**
     * 数据反向测试
     * @param body 数据反向测试
@@ -38,16 +88,10 @@
     */
    @PostMapping("/investigate/testBody")
    public String testBody(@RequestBody String body){
        System.out.println("body = " + body);
        JSONObject jsonObject = new JSONObject(body);
        Object data = jsonObject.get("data");
        System.out.println("data = " + data.toString());
        JSONObject jsonData = new JSONObject(data.toString());
        Object res = jsonData.get("res");
        System.out.println("res = " + res);
        JSONArray jsonArray = jsonData.getJSONArray("res");
        System.out.println("jsonArray = " + jsonArray);
        System.out.println("jsonArray.length() = " + jsonArray.length());
        if (jsonArray.length()>0){
            String zdxsfzqkry = jsonArray.getJSONObject(0).get("zdxsfzqkry").toString();
            return zdxsfzqkry;
src/main/java/org/springblade/modules/system/mapper/UserMapper.java
@@ -67,4 +67,10 @@
     * 自定义用户列表(只有保安员)
     */
    List<User> selectUserPageSecurity(IPage<User> page, @Param("user") User user, @Param("deptIdList") List<Long> deptIdList, @Param("tenantId") String tenantId);
    /**
     * 查询所有未注销用户
     * @return
     */
    List<User> getAllUserList();
}
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -176,4 +176,9 @@
        update blade_user set hold=#{hold} where cardid=#{cardid}
    </update>
    <!--查询所有未注销用户-->
    <select id="getAllUserList" resultType="org.springblade.modules.system.entity.User">
        select id,cardid from blade_user where is_deleted = 0
    </select>
</mapper>
src/main/java/org/springblade/modules/system/service/IUserService.java
@@ -212,4 +212,10 @@
     * 自定义用户列表(只有保安员)
     */
    IPage<User> selectUserPageSecurity(IPage<User> page, User user, Long deptId, String s);
    /**
     * 查询所有未注销用户
     * @return
     */
    List<User> getAllUserList();
}
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -436,4 +436,13 @@
        List<Long> deptIdList = SysCache.getDeptChildIds(deptId);
        return page.setRecords(baseMapper.selectUserPageSecurity(page, user, deptIdList, tenantId));
    }
    /**
     * 查询所有未注销用户
     * @return
     */
    @Override
    public List<User> getAllUserList() {
        return baseMapper.getAllUserList();
    }
}