Browse Source

修改权限bug

523096025 2 năm trước cách đây
mục cha
commit
0e83cc3283

+ 3 - 0
huimv-admin/src/main/java/com/huimv/admin/controller/ProtThresholdController.java

@@ -43,6 +43,9 @@ public class ProtThresholdController {
         ProtThreshold protThreshold = protThresholdVo.getIn().setFarmId(Integer.parseInt(farmId));
         ProtThreshold protThreshold1 = protThresholdVo.getDeal().setFarmId(Integer.parseInt(farmId));
         ProtThreshold protThreshold2 = protThresholdVo.getOut().setFarmId(Integer.parseInt(farmId));
+        protThreshold.setProtType(1);
+        protThreshold1.setProtType(2);
+        protThreshold2.setProtType(3);
         List<ProtThreshold> protThresholdList = new LinkedList<>();
         protThresholdList.add(protThreshold);
         protThresholdList.add(protThreshold1);

+ 1 - 1
huimv-admin/src/main/java/com/huimv/admin/mapper/AccountGroupMapper.java

@@ -16,5 +16,5 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface AccountGroupMapper extends BaseMapper<AccountGroup> {
 
-    void removeAccountGroup(@Param("groupIds") String groupIds);
+    void removeAccountGroup(@Param("accountId") String accountId);
 }

+ 1 - 1
huimv-admin/src/main/java/com/huimv/admin/service/impl/AuthorizeServiceImpl.java

@@ -52,7 +52,7 @@ public class AuthorizeServiceImpl implements IAuthorizeService {
             return new Result(10000, "保存账号关联权限组成功", true);
         }else {
             String[] groupIdArray = accountId.split(",");
-            accountGroupMapper.removeAccountGroup(groupIds);
+            accountGroupMapper.removeAccountGroup(accountId);
 //        for (int a = 0; a < groupIdArray.length; a++) {
 //            accountGroupMapper.removeAccountGroup(accountId,groupIdArray[a]);
 //        }

+ 4 - 1
huimv-admin/src/main/java/com/huimv/admin/service/impl/EnvWarningThresholdServiceImpl.java

@@ -51,7 +51,10 @@ public class EnvWarningThresholdServiceImpl extends ServiceImpl<EnvWarningThresh
         queryWrapper.eq("farm_id", farmId);
         EnvWarningThreshold envWarningThreshold = envWarningThresholdMapper.selectOne(queryWrapper);
         JSONObject jsonObject = new JSONObject();
-        String userIds1 = envWarningThreshold.getUserIds();
+        String userIds1 = "";
+        if (ObjectUtil.isNotEmpty(envWarningThreshold)){
+            userIds1 = envWarningThreshold.getUserIds();
+        }
         if (StringUtils.isNotBlank(userIds1)){
             collect = Arrays.stream(userIds1.split(",")).map(Integer::valueOf).filter(userIds::contains).collect(Collectors.toList());
         }

+ 7 - 9
huimv-admin/src/main/java/com/huimv/admin/service/impl/GasThresholdServiceImpl.java

@@ -46,18 +46,16 @@ public class GasThresholdServiceImpl extends ServiceImpl<GasThresholdMapper, Gas
         Integer userId = TokenSign.getMemberIdByJwtToken(httpServletRequest);
         List<Integer> userIds =sysAccountMultilevelMapper.getLowerLevel( userId,farmId);
         List<Integer> collect =new ArrayList<>();
-        QueryWrapper<GasThreshold> wrapper = new QueryWrapper<>();
-        wrapper.eq("farm_id", farmId);
-        GasThreshold envWarningThreshold = gasThresholdMapper.selectOne(wrapper);
-        String userIds1 = envWarningThreshold.getUserIds();
-        if (StringUtils.isNotBlank(userIds1)){
-            collect = Arrays.stream(userIds1.split(",")).map(Integer::valueOf).filter(userIds::contains).collect(Collectors.toList());
-        }
-
-
         QueryWrapper<GasThreshold> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("farm_id", farmId);
         List<GasThreshold> gasThresholds = gasThresholdMapper.selectList(queryWrapper);
+        String userIds1 = "";
+        if (ObjectUtil.isNotEmpty(gasThresholds)){
+            userIds1 = gasThresholds.get(0).getUserIds();
+        }
+        if (StringUtils.isNotBlank(userIds1)){
+            collect = Arrays.stream(userIds1.split(",")).map(Integer::valueOf).filter(userIds::contains).collect(Collectors.toList());
+        }
         JSONObject jsonObject = new JSONObject();
         if (gasThresholds.size() == 0) {
             jsonObject.put("NH3-N", 0);

+ 14 - 7
huimv-admin/src/main/java/com/huimv/admin/service/impl/ProtThresholdServiceImpl.java

@@ -17,6 +17,7 @@ import com.huimv.admin.service.IProtThresholdService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
@@ -51,7 +52,10 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
         Integer userId = TokenSign.getMemberIdByJwtToken(httpServletRequest);
         List<Integer> userIds =sysAccountMultilevelMapper.getLowerLevel( userId,farmId);
         List<Integer> collect =new ArrayList<>();
-        String userIds1 = protThresholdList.get(0).getUserIds();
+        String userIds1 = "";
+        if (ObjectUtil.isNotEmpty(protThresholdList)){
+            userIds1 = protThresholdList.get(0).getUserIds();
+        }
         if (StringUtils.isNotBlank(userIds1)){
             collect = Arrays.stream(userIds1.split(",")).map(Integer::valueOf).filter(userIds::contains).collect(Collectors.toList());
         }
@@ -71,6 +75,7 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
             jsonObject.put("FLOW1", 0);
             jsonObject.put("FLOW2", 0);
             jsonObject.put("userIds", 0);
+            jsonObject.put("protType", 0);
             jsonObject.put("dataType", 0);
             return new Result(ResultCode.SUCCESS, jsonObject);
         } else {
@@ -84,13 +89,14 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
                     jsonObject.put("out", protThresholdList.get(i));
                 }
             }
-            jsonObject.put("userIds", protThresholdList.get(1).getUserIds());
-            return new Result(ResultCode.SUCCESS,collect);
+            jsonObject.put("userIds",collect);
+            return new Result(ResultCode.SUCCESS,jsonObject);
         }
 
     }
 
     @Override
+    @Transactional
     public Result add(HttpServletRequest httpServletRequest, List<ProtThreshold> protThresholds) {
         for (ProtThreshold protThreshold : protThresholds) {
             if (ObjectUtil.isNotEmpty(protThreshold)) {
@@ -110,10 +116,12 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
                     uoloadIds = Arrays.stream(userIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
                 }
                 //现有id
-                String oldUserIds = threshold.getUserIds();
                 List<Integer> oldUsersIds = new ArrayList<>();
-                if (StringUtils.isNotBlank(oldUserIds)){
-                    oldUsersIds = Arrays.stream(oldUserIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
+                if(ObjectUtil.isNotEmpty(threshold)){
+                    String oldUserIds =   threshold.getUserIds();
+                    if (StringUtils.isNotBlank(oldUserIds)){
+                        oldUsersIds = Arrays.stream(oldUserIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
+                    }
                 }
                 // 现有 -下属 + 上传
                 oldUsersIds.removeAll(lowerLevelIds);
@@ -151,7 +159,6 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
                 } else if (Integer.parseInt(protThreshold.getFlow2()) < Integer.parseInt(protThreshold.getFlow1())) {
                     return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
                 } else {
-
                     if (ObjectUtil.isEmpty(threshold)) {
                         protThresholdMapper.insert(protThreshold1);
                     } else {

+ 1 - 1
huimv-admin/src/main/resources/com/huimv/admin/mapper/AccountGroupMapper.xml

@@ -4,6 +4,6 @@
 
 
     <delete id="removeAccountGroup">
-        DELETE FROM sys_account_group WHERE group_id=#{groupIds}
+        DELETE FROM sys_account_group WHERE account_id=#{accountId}
     </delete>
 </mapper>

huimv-admin/src/main/resources/com/huimv/admin/mapper/AccountMultilevelMapper.xml → huimv-admin/src/main/resources/com/huimv/admin/mapper/SysAccountMultilevelMapper.xml