Przeglądaj źródła

Merge remote-tracking branch 'origin/CIS_V1.0' into CIS_V1.0

# Conflicts:
#	src/main/java/com/welampiot/dto/UserDTO.java
#	src/main/java/com/welampiot/service/UserService.java
#	src/main/java/com/welampiot/service/impl/UserServiceImpl.java
zouguihou 2 lat temu
rodzic
commit
17f7e7c97a

+ 3 - 0
src/main/java/com/welampiot/dao/GlobalLocationDao.java

@@ -18,4 +18,7 @@ public interface GlobalLocationDao {
     List<GlobalLocationDTO> getAreaByLevel(@Param("version") Integer version, @Param("level") Integer level);
 
     List<GlobalLocationDTO> getAreaByLevelAndPid(@Param("version") Integer version, @Param("level") Integer level, @Param("pid") Integer pid);
+
+    List<GlobalLocationDTO> getListByPid(@Param("pid") Integer pid);
+    List<GlobalLocationDTO> getListByPidList(@Param("pids") List pids);
 }

+ 12 - 0
src/main/java/com/welampiot/dao/SectionDao.java

@@ -0,0 +1,12 @@
+package com.welampiot.dao;
+
+import com.welampiot.dto.SectionDTO;
+
+import java.util.List;
+import java.util.Map;
+
+public interface SectionDao {
+    List<SectionDTO> getAllList();
+    List<SectionDTO> getListByPid(Integer pid);
+    List<SectionDTO> getLIstByPidList(List pidList);
+}

+ 2 - 1
src/main/java/com/welampiot/dto/UserDTO.java

@@ -16,7 +16,8 @@ public class UserDTO implements UserDetails{
     private String password;
     private int status;
     private String privilegeList;
-    private String url;
+    private String zoneList;
+    private int role;
 
     @Override
     public Collection<? extends GrantedAuthority> getAuthorities() {

+ 2 - 0
src/main/java/com/welampiot/service/GlobalLocationService.java

@@ -18,4 +18,6 @@ public interface GlobalLocationService {
     List<GlobalLocationDTO> getAreaByLevel(Integer version,Integer level);
 
     List<GlobalLocationDTO> getAreaByLevelAndPid(Integer version, Integer level, Integer pid);
+    List<GlobalLocationDTO> getListByPid(Integer pid);
+    List<GlobalLocationDTO> getListByPidList(List pids);
 }

+ 13 - 0
src/main/java/com/welampiot/service/SectionService.java

@@ -0,0 +1,13 @@
+package com.welampiot.service;
+
+import com.welampiot.dto.SectionDTO;
+
+import java.util.List;
+import java.util.Map;
+
+public interface SectionService {
+    List<SectionDTO> getAllList();
+
+    List<SectionDTO> getListByPid(Integer pid);
+    List<SectionDTO> getLIstByPidList(List pidList);
+}

+ 1 - 0
src/main/java/com/welampiot/service/UserService.java

@@ -12,5 +12,6 @@ public interface UserService {
     UserDTO getUserByUserName(String username);
     List<MenuDTO> queryMenuList(String username);
     int countUser();
+    UserDTO findUserByUserName(String username);
     List<PathDTO> queryUserGrantUrl(String username);
 }

+ 6 - 0
src/main/java/com/welampiot/service/impl/GlobalLocationServiceImpl.java

@@ -33,4 +33,10 @@ public class GlobalLocationServiceImpl implements GlobalLocationService {
     public List<GlobalLocationDTO> getAreaByLevelAndPid(Integer version,Integer level, Integer pid) {
         return globalLocationDao.getAreaByLevelAndPid(version,level,pid);
     }
+
+    @Override
+    public List<GlobalLocationDTO> getListByPid(Integer pid) {return globalLocationDao.getListByPid(pid);}
+
+    @Override
+    public List<GlobalLocationDTO> getListByPidList(List pids) {return globalLocationDao.getListByPidList(pids);}
 }

+ 24 - 0
src/main/java/com/welampiot/service/impl/SectionServiceImpl.java

@@ -0,0 +1,24 @@
+package com.welampiot.service.impl;
+
+import com.welampiot.dao.SectionDao;
+import com.welampiot.dto.SectionDTO;
+import com.welampiot.service.SectionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class SectionServiceImpl implements SectionService {
+    @Autowired
+    private SectionDao sectionDao;
+    @Override
+    public List<SectionDTO> getAllList() {return sectionDao.getAllList();}
+
+    @Override
+    public List<SectionDTO> getListByPid(Integer pid) {return sectionDao.getListByPid(pid);}
+
+    @Override
+    public List<SectionDTO> getLIstByPidList(List pidList) {return sectionDao.getLIstByPidList(pidList);}
+}

+ 3 - 0
src/main/java/com/welampiot/service/impl/UserServiceImpl.java

@@ -41,6 +41,9 @@ public class UserServiceImpl implements UserService {
         return 0;
     }
 
+    @Override
+    public UserDTO findUserByUserName(String username) {return userDao.findUserByUserName(username);}
+
     @Override
     public List<PathDTO> queryUserGrantUrl(String username) {
         return userDao.queryUserGrantUrl(username);

+ 109 - 0
src/main/java/com/welampiot/utils/ToolUtils.java

@@ -0,0 +1,109 @@
+package com.welampiot.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.welampiot.dao.GlobalLocationDao;
+import com.welampiot.dao.UserDao;
+import com.welampiot.dto.GlobalLocationDTO;
+import com.welampiot.dto.SectionDTO;
+import com.welampiot.dto.UserDTO;
+import com.welampiot.service.GlobalLocationService;
+import com.welampiot.service.SectionService;
+import com.welampiot.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Field;
+import java.util.*;
+
+@Component
+public class ToolUtils {
+    private UserDTO user;
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private SectionService sectionService;
+    @Autowired
+    private GlobalLocationService globalLocationService;
+
+    /**
+     * 获取用户所有路段 id
+     * @param request
+     * @return 如果返回列表为空,表示超管获取到全部路段信息,此时不需要做路段筛选
+     */
+    public List getSectionList(HttpServletRequest request){
+        String username = request.getParameter("username");
+        if (username == null || username.toString().length() == 0) return Collections.singletonList(new int[]{0});
+        UserDTO user1 = userService.findUserByUserName(username);
+        if (user1 == null) return Collections.singletonList(new int[]{0});
+
+        String provinceid = request.getParameter("provinceid");
+        provinceid = provinceid == null || provinceid.equals("0") ? request.getParameter("provinceId") : provinceid;
+        String cityid = request.getParameter("cityid");
+        cityid = cityid == null || cityid.equals("0") ? request.getParameter("cityId") : cityid;
+        String areaid = request.getParameter("areaid");
+        areaid = areaid == null || areaid.equals("0") ? request.getParameter("areaId") : areaid;
+        String sectionid = request.getParameter("sectionid");
+        sectionid = sectionid == null || sectionid.equals("0") ? request.getParameter("sectionId") : sectionid;
+
+        ArrayList<Object> sectionList = new ArrayList<>();
+        if (sectionid != null && sectionid.length() != 0 && !sectionid.equals("0")){
+            sectionList.add(sectionid);
+            return sectionList;
+        }
+        String zone = user1.getZoneList();
+        int role = user1.getRole();
+        List<SectionDTO> maps;
+        List<GlobalLocationDTO> globalLocationList;
+        ArrayList areaList = new ArrayList<>();
+        if ((cityid != null && !cityid.equals("0")) || (provinceid != null && !provinceid.equals("0")) || (areaid != null && !areaid.equals("0"))){
+            if (areaid == null || areaid.equals("0")){
+                ArrayList cityList = new ArrayList<>();
+                if (cityid == null || cityid.equals("0")){
+                    globalLocationList = globalLocationService.getListByPid(Integer.valueOf(provinceid));
+                    if (globalLocationList.isEmpty()){
+                        cityid = provinceid;
+                    }else {
+                        for (GlobalLocationDTO m :globalLocationList) {
+                            cityList.add(m.getId());
+                        }
+                    }
+                }
+                if (cityList.isEmpty()){
+                    globalLocationList = globalLocationService.getListByPid(Integer.valueOf(cityid));
+                }else {
+                    globalLocationList = globalLocationService.getListByPidList(cityList);
+                }
+                if (globalLocationList.isEmpty()){
+                    areaid = cityid;
+                }else {
+                    for (GlobalLocationDTO m :globalLocationList) {
+                        areaList.add(m.getId());
+                    }
+                }
+            }
+        }
+        if ((areaid == null || areaid.length() == 0 || areaid.equals("0")) && areaList.isEmpty()){
+            if (role != 1) {
+                return Arrays.asList(zone.split(","));
+            }else {
+                return new ArrayList<>();
+            }
+        }else {
+            if (areaid == null || areaid.equals("0")){
+                maps = sectionService.getLIstByPidList(areaList);
+                if (role != 1){
+                    return Arrays.asList(zone.split(","));
+                }
+            }else {
+                maps = sectionService.getListByPid(Integer.valueOf(areaid));
+            }
+        }
+        for (SectionDTO map:maps) {
+            sectionList.add(map.getId());
+        }
+        if (sectionList.isEmpty()) sectionList.add("0");
+        return sectionList;
+    }
+}

+ 18 - 0
src/main/resources/mapper/SectionMapper.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.welampiot.dao.SectionDao">
+    <select id="getAllList" resultType="com.welampiot.dto.SectionDTO">
+        select id,name from section
+    </select>
+    <select id="getListByPid" parameterType="java.lang.String" resultType="com.welampiot.dto.SectionDTO">
+        select id,name from section
+        where pid = #{pid,jdbcType=INTEGER}
+    </select>
+    <select id="getListByPidList" parameterType="java.util.List" resultType="com.welampiot.dto.SectionDTO">
+        select id,name from section
+        where pid in
+        <foreach item="item" collection="pidList" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+</mapper>

+ 1 - 1
src/main/resources/mapper/UserMapper.xml

@@ -9,7 +9,7 @@
         select username,password,status,privilege_list privilegeList from user where username=#{username,jdbcType=VARCHAR}
     </select>
     <select id="findUserByUserName" resultType="com.welampiot.dto.UserDTO">
-        select username,role,status,privilege_list privilegeList from user where username=#{username,jdbcType=VARCHAR}
+        select username,role,status,privilege_list privilegeList,zone_list zoneList from user where username=#{username,jdbcType=VARCHAR}
     </select>
     <select id="queryMenuList" parameterType="list" resultType="com.welampiot.dto.MenuDTO">
         <!--select id,parentid parentId,name,en_name enName,ru_name ruName,level,action from privilnode where status=1