lyhzzz 8 tháng trước cách đây
mục cha
commit
a5bb10738f

+ 32 - 18
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -29,6 +29,7 @@ import com.fdkankan.manage.vo.response.CameraDataVo;
 import com.fdkankan.manage.vo.response.GroupByCount;
 import com.fdkankan.manage.vo.response.SceneVo;
 import lombok.extern.slf4j.Slf4j;
+import net.sf.jsqlparser.parser.JJTCCJSqlParserState;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -88,6 +89,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     @Autowired
     IJySceneUserAuthService jySceneUserAuthService;
     @Autowired
+    IJyUserShareService jyUserShareService;
+    @Autowired
     ISysUserService sysUserService;
     @Autowired
     IJySceneAuthService jySceneAuthService;
@@ -308,34 +311,45 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         }
         SysUser byId = sysUserService.getById(Long.valueOf(StpUtil.getLoginId().toString()));
         JyUser jyUser = jyUserService.getBySysId(byId.getId());
+        if(jyUser == null){
+            throw new BusinessException(ResultCode.JY_ID_NO_EXIST);
+        }
+
+        if(byId.getRoleId() == 47L ){
+            param.getUserIds().add(jyUser.getUserId());
+        }
         if(byId.getRoleId() !=1 ){
-            if(jyUser == null){
-                throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+            Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId();
+            if(loginPlatformId != null) {
+                param.setPlatformIds(Arrays.asList(loginPlatformId));
             }
-            //param.setUserId(jyUser.getUserId());
-            param.setUserIds(Arrays.asList(jyUser.getUserId()));
             List<JySceneUserAuth> list = jySceneUserAuthService.getByJyUserId(jyUser.getId());
             if(list.size() >0){
                 List<String> numList = list.stream().filter(entity -> !(entity.getLookAuth()==0 && entity.getEditAuth() ==0)).map(JySceneUserAuth::getNum).collect(Collectors.toList());
                 param.setAuthNumList(numList);
             }
-        }
-        if(byId.getRoleId() == 45L || byId.getRoleId() == 48L){
-            List<Long> userIds = new ArrayList<>();
-            //获取本平台所有用户
-            Integer loginPlatformId = jyUserPlatformService.getLoginPlatformId();
-            if(loginPlatformId != null) {
-                userIds = jyUserService.getByUserIdPlatform(loginPlatformId);
-            }
-            if(userIds.isEmpty()){
-                return PageInfo.PageInfo(new Page<>(param.getPageNum(),param.getPageSize()));
-            }
-            if(!param.getUserIds().isEmpty()){
-                userIds.addAll(param.getUserIds());
+
+            List<JyUserShare> jyUserShares = jyUserShareService.getByJyUserId(jyUser.getId());
+            List<Integer> mainUserIds = jyUserShares.stream().map(JyUserShare::getMainJyUserId).collect(Collectors.toList());
+            HashMap<Integer,Long> roleMap = new HashMap<>();
+            if(!mainUserIds.isEmpty()){
+                List<JyUser> jyUsers = jyUserService.listByIds(mainUserIds);
+                Set<Long> sysIds = jyUsers.stream().map(JyUser::getSysUserId).collect(Collectors.toSet());
+                HashMap<Long, SysUser> byIds = sysUserService.getByIds(sysIds);
+                jyUsers.forEach( e-> roleMap.put(e.getId(),byIds.get(e.getSysUserId()).getRoleId()));
+
+                for (JyUser user : jyUsers) {
+                    Long roleId = roleMap.get(user.getId());
+                    if(user.getPlatformId() != null && (roleId == 45L || roleId == 48L)){
+                        param.getPlatformIds().add(user.getPlatformId());
+                    }else {
+                        param.getUserIds().add(user.getUserId());
+                    }
+                }
             }
-            param.setUserIds(userIds);
 
         }
+
         Set<Long> userIds = null;
         HashMap<Long,JyUser> userMap = new HashMap<>();
         HashMap<String, JSONObject>  laserMap = new HashMap<>();

+ 1 - 0
src/main/java/com/fdkankan/manage/vo/request/SceneParam.java

@@ -24,4 +24,5 @@ public class SceneParam extends RequestBase {
     private Integer authType;
 
     private List<Long> userIds =  new ArrayList<>();
+    private List<Integer> platformIds = new ArrayList<>();
 }

+ 0 - 14
src/main/java/com/fdkankan/manage/vo/response/SceneVo.java

@@ -41,18 +41,4 @@ public class SceneVo {
 
     private Integer id;
 
-    private Integer roleId;
-
-    /**
-     * 场景按钮 edit,auth,down,rebuild,copy,del,authOther
-     */
-    private List<String> buttons = new ArrayList<>();
-
-
-    public List<String> getButtons() {
-        if(roleId != null && roleId == 1L){
-            buttons = Arrays.asList("edit","auth","down","rebuild","copy","del","authOther");
-        }
-        return buttons;
-    }
 }

+ 34 - 46
src/main/resources/mapper/manage/SceneProMapper.xml

@@ -28,42 +28,53 @@
     </select>
 
     <select id="pageList" resultType="com.fdkankan.manage.vo.response.SceneVo">
-        SELECT * FROM(
-        select s.scene_name ,s.num,s.create_time,c.sn_code,s.space as sceneSize
-        ,u.user_name,s.view_count,s.status,s.pay_status,'v3' as scene_version ,s.web_site , s.thumb
-        ,null as algorithmTime,s.user_id
-        from t_scene_pro s
-        <include refid="commonWhere"></include>
-        <if test="param.sceneName != null and param.sceneName!='' ">
-            and s.scene_name like concat ('%',#{param.sceneName},'%')
-        </if>
-        <if test="param.type == 5 or param.type ==7">
-            and s.is_obj = 1
-        </if>
-        and is_upgrade = 0
-        UNION
         select s.title as sceneName ,s.num,s.create_time,c.sn_code,e.space as sceneSize
         ,u.user_name,e.view_count,s.scene_status as status,s.pay_status,'v4' as scene_version,e.web_site , e.thumb
         ,algorithm_time,s.user_id
         from t_scene_plus s
         left join t_scene_plus_ext e on s.id = e.plus_id
+        left join t_user u on s.user_id = u.id
+        left join t_camera c on s.camera_id = c.id
+        left join jy_user jy on u.id = jy.user_id
         <include refid="commonWhere"></include>
-        <if test="param.sceneName != null and param.sceneName!='' ">
-            and s.title like concat ('%',#{param.sceneName},'%')
+
+        <if test="param.platformIds != null and param.platformIds.size >0">
+            and jy.platform_id in
+            <foreach item="platformId" collection="param.platformIds" open="(" separator="," close=")">
+                #{platformId}
+            </foreach>
         </if>
-        <if test="param.type == 5 or param.type ==7">
-            and e.is_obj = 1
+
+        <if test="param.userIds !=null and param.userIds.size>0">
+            and  u.id in
+            <foreach item="userId" collection="param.userIds" open="(" separator="," close=")">
+                #{userId}
+            </foreach>
         </if>
-        ) as tb
+
+        <if test="param.authNumList !=null and param.authNumList.size>0  ">
+            or (
+            <include refid="commonWhere"></include>
+            and s.num in
+            <foreach item="num" collection="param.authNumList" open="(" separator="," close=")">
+                #{num}
+            </foreach>
+            )
+        </if>
+
+
         order by create_time desc
     </select>
 
     <sql id="commonWhere">
-        left join t_user u on s.user_id = u.id
-        left join t_camera c on s.camera_id = c.id
-        left join t_camera_detail d on c.id = d.camera_id
-        left join t_company co on d.company_id = co.id
         where s.rec_status = 'A'
+        <if test="param.sceneName != null and param.sceneName!='' ">
+            and s.title like concat ('%',#{param.sceneName},'%')
+        </if>
+        <if test="param.type == 5 or param.type ==7">
+            and e.is_obj = 1
+        </if>
+
         <if test="param.snCode != null and param.snCode !='' ">
             and c.sn_code like concat ('%',#{param.snCode},'%')
         </if>
@@ -82,31 +93,8 @@
         <if test="param.type == 2 or param.type ==5">
             and s.scene_source = 4
         </if>
-
         <if test="param.type == 6 or param.type ==7">
             and s.scene_source = 5
         </if>
-        <if test="param.companyId !=null ">
-            and co.id = #{param.companyId}
-        </if>
-        <if test="param.userIds !=null and param.userIds.size&gt;0 and param.authNumList.size&lt;= 0">
-            and  u.id in
-            <foreach item="userId" collection="param.userIds" open="(" separator="," close=")">
-                #{userId}
-            </foreach>
-        </if>
-
-        <if test="param.userIds !=null and param.userIds.size&gt;0  and param.authNumList.size&gt;0 ">
-            and  (u.id in
-                <foreach item="userId" collection="param.userIds" open="(" separator="," close=")">
-                #{userId}
-                 </foreach>
-                or s.num in
-                <foreach item="num" collection="param.authNumList" open="(" separator="," close=")">
-                    #{num}
-                </foreach>
-             )
-        </if>
-
     </sql>
 </mapper>