Quellcode durchsuchen

Merge remote-tracking branch 'origin/master'

dongjh vor 2 Monaten
Ursprung
Commit
3f12b1820d

+ 7 - 4
jeecg-module-interlock/src/main/java/org/jeecg/modules/binlog/PostgreSQLClient.java

@@ -189,8 +189,8 @@ public class PostgreSQLClient implements ApplicationRunner {
                         String baseKzxtNormalStatus = base.getControlSystemStatusNormal(); // 用户定义的 控制系统状态正常 所对应的值
                         String baseKzxtAbnormalStatus = inversionStatus(base.getControlSystemStatusNormal()); // 获取控制系统状态异常所对应的值(取反)
 
-                        String basePlNormalStatus = base.getBypassYes();  // 用户定义的 旁路状态 所对应的值
-                        String basePlAbnormalStatus = inversionStatus(base.getBypassYes());  // 获取旁路状态 所对应的值
+                        String basePlNormalStatus = base.getBypassYes();  // 用户定义的 旁路状态 所对应的值
+                        String basePlAbnormalStatus = inversionStatus(base.getBypassYes());  // 获取旁路状态 所对应的值
 
                         String baseLsNormalStatus = base.getInterlockStatusTy();  // 用户定义的 联锁状态投用 所对应的值
                         String baseLsAbnormalStatus = inversionStatus(base.getInterlockStatusTy());  // 获取联锁状态未投用所对应的值(取反)
@@ -362,8 +362,11 @@ public class PostgreSQLClient implements ApplicationRunner {
                             if (baseKzxtAbnormalStatus.equals(inputStatusTag) || baseKzxtAbnormalStatus.equals(outputStatusTag) || baseKzxtAbnormalStatus.equals(mpStatusTag)) {
                                 kzxtcount++; // 如果控制系统状态有一个是异常 则+1;
                             }
-                            if (basePlNormalStatus.equals(detail.getBypass())){
-                                plcount++;  // 如果旁路有一个为 是 则+1;
+//                            if (basePlNormalStatus.equals(detail.getBypass())){
+//                                plcount++;  // 如果旁路有一个为 是 则+1;
+//                            }
+                            if (basePlAbnormalStatus.equals(detail.getBypass())){
+                                plcount++;  // 如果旁路有一个为故障状态 则+1;
                             }
                         }
 

+ 2 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockUser/mapper/InterlockUserMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 import org.jeecg.modules.interlockUser.entity.InterlockUser;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.system.entity.SysUser;
@@ -23,4 +24,5 @@ public interface InterlockUserMapper extends BaseMapper<InterlockUser> {
     @Select("delete from sys_user where username=#{wiseUser}")
     SysUser delSysUserByUserName(@Param("wiseUser") String wiseUser);
 
+    int updateIotUserId(@Param("userId") String userId,@Param("iotUserId") String iotUserId);
 }

+ 3 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockUser/mapper/xml/InterlockUserMapper.xml

@@ -2,4 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.interlockUser.mapper.InterlockUserMapper">
 
+    <update id="updateIotUserId">
+        update interlock_user set iot_userid = #{iotUserId} where id = #{userId}
+    </update>
 </mapper>

+ 1 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockUser/service/IInterlockUserService.java

@@ -61,4 +61,5 @@ public interface IInterlockUserService extends IService<InterlockUser> {
     //根据用户名查找用户信息
     InterlockUser getInterlockUserByUserName(String wiseUser);
 
+    int updateIotUserId(String userId, String iotUserId);
 }

+ 59 - 23
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockUser/service/impl/InterlockUserServiceImpl.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.interlockUser.service.impl;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.oConvertUtils;
@@ -110,46 +111,77 @@ public class InterlockUserServiceImpl extends ServiceImpl<InterlockUserMapper, I
         SysUserRole userRole = new SysUserRole(userId, interlockUserAdd.getRoleId());
         sysUserRoleService.save(userRole);
 
-        addSSOIoTEdgeUser(interlockUserAdd,interlockUser,eiToken);
+        int i = addSSOIoTEdgeUser(interlockUserAdd, interlockUser, eiToken);
+
+        if (i > 0){
+            this.removeById(interlockUser);
+            UpdateWrapper<InterlockSystemLimit> upQuery = new UpdateWrapper<>();
+            upQuery.eq("interlock_user_id",interlockUser.getId());
+            interlockSystemLimitService.remove(upQuery);
+            return Result.error("用户添加失败!");
+        }
 
 
         return Result.OK("用户添加成功!");
     }
 
-    private void addSSOIoTEdgeUser(InterlockUserAdd interlockUserAdd, InterlockUser interlockUser, String eiToken) {
+    private int addSSOIoTEdgeUser(InterlockUserAdd interlockUserAdd, InterlockUser interlockUser, String eiToken) {
+        int count = 0;
         try {
             restClientService.addSSOUser(interlockUserAdd.getUsername());
         } catch (Exception e) {
             log.info("SSO新增用户报错:{}",e.getMessage());
         } finally {
-            JSONObject jsonObject = restClientService.invitationSSOUserInIoTEdge(interlockUserAdd.getUsername(), eiToken);
-            String code = (String) jsonObject.get("code");
-            String iotUserId = (String) jsonObject.get("userId");
+            try {
+                JSONObject jsonObject = restClientService.invitationSSOUserInIoTEdge(interlockUserAdd.getUsername(), eiToken);
+                String code = (String) jsonObject.get("code");
+                String iotUserId = (String) jsonObject.get("userId");
 
-            interlockUser.setIotUserid(iotUserId);
-            this.updateById(interlockUser);
+                interlockUser.setIotUserid(iotUserId);
+                this.updateById(interlockUser);
 
-            if (ObjectUtil.isNotNull(code)){
-                log.info("IoTEdge邀请SSO用户失败: {}"+jsonObject.get("message").toString());
-            }
-            String rloe = "";
-            if ("0".equals(interlockUserAdd.getRole())){
-                rloe = "systemAdmin";
-                restClientService.setUserRole(iotUserId,"",rloe,eiToken);
-            }else {
-                for (InterlockSystemLimit item : interlockUserAdd.getSystemLimitList()) {
-                    //InterlockBase base = baseService.getById(item.getId());
-                    if ("1".equals(interlockUserAdd.getRole()) && ObjectUtil.isNotNull(item.getLimitType()) && "0".equals(item.getLimitType())){
-                        rloe = "groupAdmin";
-                        restClientService.setUserRole(iotUserId,item.getIotedgeGroupId(),rloe,eiToken);
-                    }else if ("1".equals(interlockUserAdd.getRole()) && ObjectUtil.isNotNull(item.getLimitType()) && "1".equals(item.getLimitType())){
-                        rloe = "groupView";
-                        restClientService.setUserRole(iotUserId,item.getIotedgeGroupId(),rloe,eiToken);
+                if (ObjectUtil.isNotNull(code)){
+                    log.info("IoTEdge邀请SSO用户失败: {}"+jsonObject.get("message").toString());
+                }
+                String rloe = "";
+                if ("0".equals(interlockUserAdd.getRole())){
+                    rloe = "systemAdmin";
+                    try {
+                        restClientService.setUserRole(iotUserId,"",rloe,eiToken);
+                    } catch (Exception e) {
+                        log.info("IoTEdge分配角色报错:{}",e.getMessage());
+                        count++;
+                    }
+                }else {
+                    for (InterlockSystemLimit item : interlockUserAdd.getSystemLimitList()) {
+                        //InterlockBase base = baseService.getById(item.getId());
+                        if ("1".equals(interlockUserAdd.getRole()) && ObjectUtil.isNotNull(item.getLimitType()) && "0".equals(item.getLimitType())){
+                            rloe = "groupAdmin";
+                            try {
+                                restClientService.setUserRole(iotUserId,item.getIotedgeGroupId(),rloe,eiToken);
+                            } catch (Exception e) {
+                                log.info("IoTEdge分配角色报错:{}",e.getMessage());
+                                count++;
+                            }
+                        }else if ("1".equals(interlockUserAdd.getRole()) && ObjectUtil.isNotNull(item.getLimitType()) && "1".equals(item.getLimitType())){
+                            rloe = "groupView";
+                            try {
+                                restClientService.setUserRole(iotUserId,item.getIotedgeGroupId(),rloe,eiToken);
+                            } catch (Exception e) {
+                                log.info("IoTEdge分配角色报错:{}",e.getMessage());
+                                count++;
+                            }
+                        }
                     }
                 }
+            } catch (Exception e) {
+                log.info("IoTEdge邀请SSO用户报错:{}",e.getMessage());
+                count++;
             }
 
         }
+
+        return count;
     }
 
     /**
@@ -348,4 +380,8 @@ public class InterlockUserServiceImpl extends ServiceImpl<InterlockUserMapper, I
         return interlockUserMapper.getInterlockUserByUserName(wiseUser);
     }
 
+    @Override
+    public int updateIotUserId(String userId, String iotUserId) {
+        return interlockUserMapper.updateIotUserId(userId, iotUserId);
+    }
 }

+ 1 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeCollectData/service/IIotedgeCollectDataService.java

@@ -33,5 +33,5 @@ public interface IIotedgeCollectDataService extends IService<IotedgeCollectData>
 
     Map<String, Object> getAllGroup();
 
-    String addIoTedgeUser(String userName,String ssoRole,InterlockUser interlockUser, String elToken);
+    String addIoTedgeUser(String userName,String ssoRole,String userId, String elToken);
 }

+ 3 - 3
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeCollectData/service/impl/IotedgeCollectDataServiceImpl.java

@@ -338,7 +338,7 @@ public class IotedgeCollectDataServiceImpl extends ServiceImpl<IotedgeCollectDat
     }
 
     @Override
-    public String addIoTedgeUser(String userName, String ssoRole, InterlockUser interlockUser, String elToken) {
+    public String addIoTedgeUser(String userName, String ssoRole, String userId, String elToken) {
         String result = "200";
 
         try {
@@ -346,8 +346,8 @@ public class IotedgeCollectDataServiceImpl extends ServiceImpl<IotedgeCollectDat
             String code = (String) jsonObject.get("code");
             String iotUserId = (String) jsonObject.get("userId");
 
-            interlockUser.setIotUserid(iotUserId);
-            interlockUserService.updateById(interlockUser);
+            //interlockUser.setIotUserid(iotUserId);
+            interlockUserService.updateIotUserId(userId,iotUserId);
 
             String rloe = "";
             if ("globalAdmin".equals(ssoRole)){

+ 22 - 3
jeecg-module-interlock/src/main/java/org/jeecg/modules/ssoClient/controller/SSOLoginLogoutController.java

@@ -398,7 +398,7 @@ public class SSOLoginLogoutController {
                         // TODO 已经单点登录成功了的用户如果在本系统不存在,新增用户?——初始密码设为123456??
                         if(result.getMessage().equals(SSOConstants.BCZ) ){
                             log.info("用户在jeecg系统用户表中不存在,新增该用户");
-                            JSONObject addJSONObject = toAddJSONObject(usernameSSO,  "123456");
+                            JSONObject addJSONObject = toAddJSONObject2(usernameSSO,  "123456");
                             addUser(addJSONObject);
                         }else if(result.getMessage().equals(SSOConstants.YZX) || result.getMessage().equals(SSOConstants.YDj)){
                             // TODO 已注销或冻结的用户怎么处理?——首先不应该允许在本系统注销或者冻结用户?——如果真的有恢复正常状态?
@@ -495,7 +495,7 @@ public class SSOLoginLogoutController {
             // TODO 已经单点登录成功了的用户如果在本系统不存在,新增用户?
             if(result.getMessage().equals(SSOConstants.BCZ) ){
                 log.info("用户在本系统不存在,新增该用户");
-                JSONObject addJSONObject = toAddJSONObject(username, password);
+                JSONObject addJSONObject = toAddJSONObject2(username, password);
                 addUser(addJSONObject);
             }else if(result.getMessage().equals(SSOConstants.YZX) || result.getMessage().equals(SSOConstants.YDj)){
                 // TODO 已注销或冻结的用户怎么处理?——首先不应该允许在本系统注销或者冻结用户?——如果真的有恢复正常状态?
@@ -574,7 +574,7 @@ public class SSOLoginLogoutController {
                 interlockSystemLimitService.saveBatch(interlockSystemLimitList);
             }
 
-            iotedgeCollectDataService.addIoTedgeUser(username,ssoRole,interlockUser,elToken);
+            iotedgeCollectDataService.addIoTedgeUser(username,ssoRole,userId,elToken);
 
             baseCommonService.addLog("添加用户,username: " + username, CommonConstant.LOG_TYPE_2, 2);
         } catch (Exception e) {
@@ -623,6 +623,25 @@ public class SSOLoginLogoutController {
         return jsonObject;
     }
 
+    /**
+     *  添加用户参数,没有角色
+     */
+    private JSONObject toAddJSONObject2(String username, String password){
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("workNo", "");
+        jsonObject.put("password", password);
+        jsonObject.put("confirmpassword", password);
+        jsonObject.put("phone", "18888888888");
+        jsonObject.put("selecteddeparts", "");
+        jsonObject.put("selectedroles", "");
+        jsonObject.put("activitiSync", "1");
+        jsonObject.put("departIds", "");
+        jsonObject.put("userIdentity", "1");
+        jsonObject.put("username", username);
+        jsonObject.put("realname", username);
+        return jsonObject;
+    }
+
     private  void  addUser(JSONObject jsonObject){
         String selectedRoles = jsonObject.getString("selectedroles");
         String selectedDeparts = jsonObject.getString("selecteddeparts");

+ 12 - 6
jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/service/impl/InterlockSummaryServiceImpl.java

@@ -219,7 +219,8 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
         String controlSystemStatusNormal = base.getControlSystemStatusNormal(); // 正常
         String controlSystemStatusAbnormal = editStatus(base.getControlSystemStatusNormal()); // 非正常
         // 旁路状态
-        String bypassYes = base.getBypassYes(); // 是
+        String bypassYes = base.getBypassYes(); // 否 无旁路
+        String bypassNo = editStatus(base.getBypassYes()); // 是  有旁路
         // 仪表状态
         String instrumentStatusNormal = base.getInstrumentStatusNormal(); // 正常
         String instrumentStatusAbnormal = editStatus(base.getInstrumentStatusNormal()); // 正常
@@ -258,8 +259,10 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
             dto.setSummaryid(summaryId);
 
 
-            //联锁状态; 旁路状态是多个的话,任何一个旁路状态为“是”,则联锁状态是“未投用(摘除)”,旁路状态都为“否”,则联锁状态是“投用”。
-            if(dto.getBypass()!=null && bypassYes.equals(dto.getBypass())) interlockStatus = interlockStatusWty;
+//            //联锁状态; 旁路状态是多个的话,任何一个旁路状态为“是”,则联锁状态是“未投用(摘除)”,旁路状态都为“否”,则联锁状态是“投用”。
+//            if(dto.getBypass()!=null && bypassYes.equals(dto.getBypass())) interlockStatus = interlockStatusWty;
+            //联锁状态:旁路状态多个的话,任何一个旁路状态是故障状态,则联锁状态是故障状态,如果旁路状态都是正常状态,则联锁状态是正常状态
+            if(dto.getBypass()!=null && bypassNo.equals(dto.getBypass())) interlockStatus = interlockStatusWty;
 
             //仪表状态
             if(dto.getInstrumentStatusJuge()!=null){
@@ -367,7 +370,8 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
         String controlSystemStatusNormal = base.getControlSystemStatusNormal(); // 正常
         String controlSystemStatusAbnormal = editStatus(base.getControlSystemStatusNormal()); // 非正常
         // 旁路状态
-        String bypassYes = base.getBypassYes(); // 是
+        String bypassYes = base.getBypassYes(); // 否   无旁路
+        String bypassNo = editStatus(base.getBypassYes()); // 是  旁路
         // 仪表状态
         String instrumentStatusNormal = base.getInstrumentStatusNormal(); // 正常
         String instrumentStatusAbnormal = editStatus(base.getInstrumentStatusNormal()); // 正常
@@ -397,8 +401,10 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
             dto.setSummaryid(summaryId);
 
 
-            //联锁状态; 旁路状态是多个的话,任何一个旁路状态为“是”,则联锁状态是“未投用(摘除)”,旁路状态都为“否”,则联锁状态是“投用”。
-            if(dto.getBypass()!=null && bypassYes.equals(dto.getBypass())) interlockStatus = interlockStatusWty;
+//            //联锁状态; 旁路状态是多个的话,任何一个旁路状态为“是”,则联锁状态是“未投用(摘除)”,旁路状态都为“否”,则联锁状态是“投用”。
+//            if(dto.getBypass()!=null && bypassYes.equals(dto.getBypass())) interlockStatus = interlockStatusWty;
+            //联锁状态:旁路状态多个的话,任何一个旁路状态是故障状态,则联锁状态是故障状态,如果旁路状态都是正常状态,则联锁状态是正常状态
+            if(dto.getBypass()!=null && bypassNo.equals(dto.getBypass())) interlockStatus = interlockStatusWty;
 
             //仪表状态
             if(dto.getInstrumentStatusJuge()!=null){