Преглед изворни кода

Merge branch 'master' of https://gitee.com/antai-wuliu/ANTAI-API

liyg пре 2 година
родитељ
комит
3e083b6511

+ 8 - 3
src/main/java/com/steerinfo/dil/config/RequestFilter.java

@@ -33,6 +33,7 @@ public class RequestFilter implements Filter {
            String orgCode = httpRequest.getHeader("orgcode");
            String roleCodes = httpRequest.getHeader("rolecodes");
            String dilCompanyList = httpRequest.getHeader("dilCompanyList");
+           String rootCompanyMap = httpRequest.getHeader("rootCompanyMap");
            //获取cookie用户数据
            if (cookies != null && cookies.length > 0) {
                for (Cookie cookie : cookies) {
@@ -46,8 +47,10 @@ public class RequestFilter implements Filter {
                        roleCodes = URLDecoder.decode(cookie.getValue(), "utf-8");
                    } else if (cookie.getName().equals("dilCompanyList") && dilCompanyList == null) {
                        dilCompanyList = URLDecoder.decode(cookie.getValue(),"utf-8");
+                   } else if (cookie.getName().equals("rootCompanyMap") && rootCompanyMap == null) {
+                       rootCompanyMap = URLDecoder.decode(cookie.getValue(),"utf-8");
                    }
-                   else if (userId != null && userName != null && orgCode != null && roleCodes != null && dilCompanyList != null) {
+                   else if (userId != null && userName != null && orgCode != null && roleCodes != null && dilCompanyList != null && rootCompanyMap != null) {
                        //都查到了,退出
                        break;
                    }
@@ -58,8 +61,7 @@ public class RequestFilter implements Filter {
                orgCode = URLDecoder.decode(orgCode, "utf-8");
                roleCodes = URLDecoder.decode(roleCodes, "utf-8");
                dilCompanyList = URLDecoder.decode(dilCompanyList,"UTF-8");
-
-
+               rootCompanyMap = URLDecoder.decode(rootCompanyMap,"utf-8");
                //System.out.println(dilCompanyList.getClass().toString());
            }catch (Exception e){}
            httpRequest.setAttribute("userId", userId);
@@ -68,6 +70,8 @@ public class RequestFilter implements Filter {
            httpRequest.setAttribute("roleCodes", roleCodes);
            Object dilCompanyListObject = JSONObject.parse(dilCompanyList);
            httpRequest.setAttribute("dilCompanyList",dilCompanyListObject);;
+           Object rootCompanyMapObject = JSONObject.parse(rootCompanyMap);
+           httpRequest.setAttribute("rootCompanyMap",rootCompanyMapObject);
            //获取RequestBody数据
            BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
            StringBuilder strBuilder = new StringBuilder();
@@ -83,6 +87,7 @@ public class RequestFilter implements Filter {
                params.put("orgCode", orgCode);
                params.put("roleCodes",roleCodes);
                params.put("dilCompanyList",dilCompanyListObject);
+               params.put("rootCompanyMap",rootCompanyMapObject);
                //将新的RequestBody写入新的请求对象保存
                ServletRequest requestWrapper = new RequestWrapper(httpRequest, params.toJSONString());
                chain.doFilter(requestWrapper, response);

+ 2 - 0
src/main/java/com/steerinfo/dil/controller/BackgroundProcessingController.java

@@ -46,8 +46,10 @@ public class BackgroundProcessingController extends BaseRESTfulController {
             Map<String, Object> userInfo = (Map<String, Object>) dataMap.get("user");
             // 根据用户名去查询该用户绑定的公司及下属公司
             List<Map<String, Object>> companyList = backgroundProcessingMapper.getCompanyList(loginName);
+            Map<String,Object> rootCompanyMap = backgroundProcessingMapper.getCompanyRootMap(loginName);
             //List<Map<String,Object>> currentCompanyList = backgroundProcessingMapper.getCurrentCompanyList(loginName);
             userInfo.put("dilCompanyList", companyList);
+            userInfo.put("rootCompanyMap",rootCompanyMap);
             //userInfo.put("currentCompanyList",currentCompanyList);
             // 根据查询到的公司ID
             //System.out.println(userInfo);

+ 2 - 0
src/main/java/com/steerinfo/dil/mapper/BackgroundProcessingMapper.java

@@ -90,4 +90,6 @@ public interface BackgroundProcessingMapper {
 
     List<Map<String, Object>> getCurrentCompanyList(String loginName);
 
+    Map<String,Object> getCompanyRootMap(String loginName);
+
 }

+ 17 - 0
src/main/resources/com/steerinfo/dil/mapper/BackgroundProcessingMapper.xml

@@ -47,5 +47,22 @@
         AND
         RP.PERSONNEL_JOB_NUMBER = #{userName}
     </select>
+    <select id="getCompanyRootMap" resultType="java.util.Map">
+        SELECT DISTINCT
+            rc.company_id "rootCompanyId",
+            rc.COMPANY_NAME "rootCompanyName"
+        FROM
+            RMS_COMPANY RC START WITH RC.COMPANY_ID IN (
+            SELECT
+                RPC.COMPANY_ID
+            FROM
+                RMS_PERSONNEL RP
+                    LEFT JOIN RMS_PERSONNEL_COMPANY RPC ON RP.PERSONNEL_ID = RPC.PERSONNEL_ID
+            WHERE
+                RPC.DELETED = 0
+              AND RP.PERSONNEL_JOB_NUMBER = #{userName}
+        ) CONNECT BY PRIOR rc.PARENT_COMPANY_ID = RC.COMPANY_ID
+        ORDER BY LEVEL DESC FETCH NEXT 1 ROW ONLY
+    </select>
 
 </mapper>

+ 34 - 3
src/main/resources/com/steerinfo/dil/mapper/UniversalMapper.xml

@@ -9,8 +9,15 @@
             </if>
         </if>
     </sql>
-
-
+    <sql id="companyFilter">
+        <if test="!roleCodes.contains('admin') and dilCompanyList != null and dilCompanyList.size > 0">
+            AND ${prop}
+            in
+            <foreach collection="dilCompanyList" item="item" open="(" close=")" separator=",">
+                #{item.companyId}
+            </foreach>
+        </if>
+    </sql>
     <!--   查询所有的汽车衡  -->
     <select id="getColumnNoRoutList" resultType="java.lang.String" parameterType="map">
         select DTCR.COLUMN_NAME from DIL_TABLE_COLUMN_ROLE DTCR
@@ -84,6 +91,7 @@
         RC.SSO_ID "ssoId",
         RC.SSO_CODE "ssoCode",
         RC.COMPANY_ID "id",
+        RC.COMPANY_ID   "key",
         RC.COMPANY_ID "value",
         <if test="companyType==null">
             RC.COMPANY_TYPE || '-' ||
@@ -132,8 +140,16 @@
             <if test="index!=null and index!=''">
                 AND REGEXP_LIKE(RC.COMPANY_NAME, #{index})
             </if>
+            <if test="!roleCodes.contains('admin') and dilCompanyList != null and dilCompanyList.size > 0">
+                AND RC.COMPANY_ID in
+                <foreach collection="dilCompanyList" item="item" open="(" close=")" separator=",">
+                    #{item.companyId}
+                </foreach>
+            </if>
         </where>
-        FETCH NEXT 10 ROWS ONLY
+        <if test="noRow == null">
+            FETCH NEXT 10 ROWS ONLY
+        </if>
         )
         <if test="id!=null and id.size>0">
         UNION
@@ -141,6 +157,7 @@
             RC.SSO_ID "ssoId",
             RC.SSO_CODE "ssoCode",
             RC.COMPANY_ID "id",
+            RC.COMPANY_ID   "key",
             RC.COMPANY_ID "value",
             <if test="companyType==null">
                 RC.COMPANY_TYPE || '-' ||
@@ -269,6 +286,12 @@
             <if test="operationPointType!=null and operationPointType!=''">
                 AND REGEXP_LIKE(OPERATION_POINT_TYPE, #{operationPointType})
             </if>
+            <if test="receivingPointId!=null and receivingPointId!=''">
+                AND REGEXP_LIKE("id", #{receivingPointId})
+            </if>
+            <if test="shippingPointId!=null and shippingPointId!=''">
+                AND REGEXP_LIKE("id", #{shippingPointId})
+            </if>
             <if test="index!=null and index!=''">
                 AND REGEXP_LIKE(OPERATION_POINT_NAME, #{index})
             </if>
@@ -807,11 +830,19 @@
         ON ROP.OPERATION_POINT_ID = RTR.START_POINT_ID
         LEFT JOIN RMS_OPERATION_POINT ROP2
         ON ROP2.OPERATION_POINT_ID = RTR.END_POINT_ID
+        <where>
+            <include refid="companyFilter" >
+                <property name="prop" value="rdb.COMPANY_ID"/>
+            </include>
+        </where>
         )
         <where>
             <if test="index!=null and index!=''">
                 AND REGEXP_LIKE("label", #{index})
             </if>
+            <if test="businessCompanyId!=null and businessCompanyId!=''">
+                AND REGEXP_LIKE("businessCompanyId", #{businessCompanyId})
+            </if>
         </where>
     </select>
 

+ 1 - 1
src/main/resources/log4j.properties

@@ -1,5 +1,5 @@
 ## LOG4J配置
-log4j.rootCategory=INFO,stdout,RUNNING,errorfile
+log4j.rootCategory=INFO,RUNNING,stdout
 ## 控制台输出
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout