lyhzzz 1 سال پیش
والد
کامیت
259d0e0a8b

+ 6 - 6
src/main/java/com/fdkankan/ucenter/controller/api/LaserController.java

@@ -55,12 +55,12 @@ public class LaserController extends BaseController {
             throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
         }
 
-        List<Long> userIds = userService.getLikeUserName(phone);
+        List<Long> companyIds = userService.getCompanyIdsLikeUserName(phone);
         HashMap<String,Object> map = new HashMap<>();
         Set<String> snCodeSet = new HashSet<>();
         map.put("phone",phone);
         map.put("snCodes",snCodeSet);
-        if(userIds.size() <=0){
+        if(companyIds.size() <=0){
             return Result.success(map);
         }
         List<CameraAppVo> camera = new ArrayList<>();
@@ -68,18 +68,18 @@ public class LaserController extends BaseController {
             String[] split = sceneSource.split(",");
             for (String resource : split) {
                 if("4".equals(resource)){
-                    camera.addAll( cameraDetailService.getListByUserIdsAndType(userIds, 10));
+                    camera.addAll( cameraDetailService.getListByCompanyIdsAndType(companyIds, 10));
                 }
                 if("5".equals(resource)){
-                    camera.addAll(cameraDetailService.getListByUserIdsAndType(userIds, 11));
+                    camera.addAll(cameraDetailService.getListByCompanyIdsAndType(companyIds, 11));
                 }
             }
         }
         if("4".equals(sceneSource)){
-            camera = cameraDetailService.getListByUserIdsAndType(userIds, 10);
+            camera = cameraDetailService.getListByCompanyIdsAndType(companyIds, 10);
         }
         if("5".equals(sceneSource)){
-            camera = cameraDetailService.getListByUserIdsAndType(userIds, 11);
+            camera = cameraDetailService.getListByCompanyIdsAndType(companyIds, 11);
         }
         if(camera.size() >0){
             snCodeSet = camera.stream().map(CameraAppVo::getSnCode).collect(Collectors.toSet());

+ 2 - 0
src/main/java/com/fdkankan/ucenter/mapper/ICameraDetailMapper.java

@@ -21,4 +21,6 @@ public interface ICameraDetailMapper extends BaseMapper<CameraDetail> {
 
     List<CameraAppVo> getListByUserAndType(@Param("userId") Long userId,@Param("companyId") Long companyId, @Param("cameraType") Integer cameraType);
     List<CameraAppVo> getListByUserIdsAndType(@Param("userIds") List<Long> userId, @Param("cameraType") Integer cameraType);
+
+    List<CameraAppVo> getListByCompanyIdsAndType(@Param("companyIds")List<Long> companyIds,@Param("cameraType")  Integer cameraType);
 }

+ 1 - 0
src/main/java/com/fdkankan/ucenter/service/ICameraDetailService.java

@@ -36,6 +36,7 @@ public interface ICameraDetailService extends IService<CameraDetail> {
     List<CameraAppVo> getListByUserAndType(Long userId,Long companyId, Integer cameraType);
 
     List<CameraAppVo> getListByUserIdsAndType(List<Long> userId, Integer cameraType);
+    List<CameraAppVo> getListByCompanyIdsAndType(List<Long> companyIds, Integer cameraType);
 
     boolean updateCameraBalance(Long cameraId, int body, Integer points);
 

+ 1 - 0
src/main/java/com/fdkankan/ucenter/service/IUserService.java

@@ -53,6 +53,7 @@ public interface IUserService extends IService<User> {
     Long getCountByNickName(String nickName);
 
     List<Long> getLikeUserName(String userName);
+    List<Long> getCompanyIdsLikeUserName(String userName);
 
     User getByToken(String token);
 

+ 4 - 0
src/main/java/com/fdkankan/ucenter/service/impl/CameraDetailServiceImpl.java

@@ -211,4 +211,8 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
         wrapper.eq(CameraDetail::getCompanyId,companyId);
         return this.list(wrapper);
     }
+
+    public List<CameraAppVo> getListByCompanyIdsAndType(List<Long> companyIds, Integer cameraType) {
+        return this.getBaseMapper().getListByCompanyIdsAndType(companyIds,cameraType);
+    }
 }

+ 8 - 0
src/main/java/com/fdkankan/ucenter/service/impl/UserServiceImpl.java

@@ -304,6 +304,14 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, User> implements I
     }
 
     @Override
+    public List<Long> getCompanyIdsLikeUserName(String userName) {
+        LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
+        wrapper.like(User::getUserName,userName);
+        List<Long> collect = this.list(wrapper).parallelStream().map(User::getCompanyId).collect(Collectors.toList());
+        return new ArrayList<>(collect);
+    }
+
+    @Override
     public User getByToken(String token) {
         try {
             String value = redisUtil.get(String.format(RedisKey.TOKEN_V3, token));

+ 10 - 0
src/main/resources/mapper/ucenter/CameraDetailMapper.xml

@@ -25,4 +25,14 @@
         </foreach>
           and d.goods_id = #{cameraType}
     </select>
+    <select id="getListByCompanyIdsAndType" resultType="com.fdkankan.ucenter.vo.response.CameraAppVo">
+        SELECT * FROM t_camera_detail d
+        LEFT JOIN t_camera c on d.camera_id = c.id
+        WHERE d.rec_status = 'A'
+        and d.company_id in
+        <foreach item="companyId" collection="companyIds" open="(" separator="," close=")">
+            #{companyId}
+        </foreach>
+        and d.type = #{cameraType}
+    </select>
 </mapper>