Browse Source

Merge branch 'master' of http://116.63.33.55/git/read_opc

FinalYu 2 years ago
parent
commit
b0b18f7405

+ 0 - 2
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/config/WebSocket.java

@@ -5,7 +5,6 @@ import com.example.opc_common.enums.ResultEnum;
 import com.example.opc_common.exception.CustomException;
 import com.example.opc_common.util.Blank;
 import com.example.opc_common.util.ConstantStr;
-import com.example.opc_common.util.DateUtil;
 import com.example.opc_da.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,7 +17,6 @@ import javax.websocket.Session;
 import javax.websocket.server.PathParam;
 import javax.websocket.server.ServerEndpoint;
 import java.io.IOException;
-import java.util.Date;
 import java.util.concurrent.CopyOnWriteArraySet;
 
 @Component

+ 1 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/dao/DataModelDao.java

@@ -24,4 +24,5 @@ public interface DataModelDao {
 
     List<DataModel> getDmListByItemList(List<Item> itemList);
 
+    List<Item> getItemByDaModel(Integer id);
 }

+ 13 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/DataModelServiceImpl.java

@@ -2,6 +2,7 @@ package com.example.opc_da.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.example.opc_common.entity.DataModel;
+import com.example.opc_common.entity.Item;
 import com.example.opc_common.enums.ResultEnum;
 import com.example.opc_common.util.Blank;
 import com.example.opc_common.util.MathUtil;
@@ -63,6 +64,18 @@ public class DataModelServiceImpl implements DataModelService {
 
     @Override
     public Result delDataModelById(Integer id) {
+        List<Item> itemList = dataModelDao.getItemByDaModel(id);
+        if (Blank.isNotEmpty(itemList)) {
+            String message = "此数据模型已被配置在标签【";
+            for (int i = 0; i < itemList.size(); i++) {
+                if (i != 0) {
+                    message += ",";
+                }
+                message += itemList.get(i).getItemName();
+            }
+            message += "】中,无法直接删除";
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), message);
+        }
         if (dataModelDao.delDataModelById(id) <= 0) {
             return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "删除数据模型失败");
         }

+ 3 - 4
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/DataSourceServiceImpl.java

@@ -140,11 +140,10 @@ public class DataSourceServiceImpl implements DataSourceService {
         if (Blank.isNotEmpty(itemGroupList)) {
             String message = "此数据源已被配置在组【";
             for (int i = 0; i < itemGroupList.size(); i++) {
-                if (i == 0) {
-                    message += itemGroupList.get(i).getGroupName();
-                } else {
-                    message += "," + itemGroupList.get(i).getGroupName();
+                if (i != 0) {
+                    message += ",";
                 }
+                message += itemGroupList.get(i).getGroupName();
             }
             message += "】中,无法直接删除";
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), message);

+ 8 - 8
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/UserServiceImpl.java

@@ -193,10 +193,10 @@ public class UserServiceImpl implements UserService {
         }
         switch (isExistUser.getState()) {
             case ConstantStr.NORMAL_USE:
-                String userId = Convert.toStr(redisUtil.get(ConstantStr.BACK_USER_String + isExistUser.getUserId()));
-                if (Blank.isNotEmpty(userId)) {
-                    return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "此账号在其他地方登录,请勿重新登录");
-                }
+//                String userId = Convert.toStr(redisUtil.get(ConstantStr.BACK_USER_String + isExistUser.getUserId()));
+//                if (Blank.isNotEmpty(userId)) {
+//                    return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "此账号在其他地方登录,请勿重新登录");
+//                }
                 List<Role> roleList = userDao.getRoleListByUserId(isExistUser.getUserId());
                 JSONObject json = new JSONObject();
                 isExistUser.setPassword("");
@@ -598,10 +598,10 @@ public class UserServiceImpl implements UserService {
         redisUtil.del(user.getUid() + "-captcha");
         switch (isExistUser.getState()) {
             case ConstantStr.NORMAL_USE:
-                String userId = Convert.toStr(redisUtil.get(ConstantStr.PHONE_USER_String + isExistUser.getUserId()));
-                if (Blank.isNotEmpty(userId)) {
-                    return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "此账号在其他地方登录,请勿重新登录");
-                }
+//                String userId = Convert.toStr(redisUtil.get(ConstantStr.PHONE_USER_String + isExistUser.getUserId()));
+//                if (Blank.isNotEmpty(userId)) {
+//                    return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "此账号在其他地方登录,请勿重新登录");
+//                }
                 JSONObject json = new JSONObject();
                 isExistUser.setPassword("");
                 //生成token

+ 7 - 0
chaunyi_opc/opc_da/src/main/resources/mapper/DataModelDao.xml

@@ -64,4 +64,11 @@
         </foreach>
     </select>
 
+    <select id="getItemByDaModel" resultType="com.example.opc_common.entity.Item">
+        select
+        <include refid="dataModel"/>
+        from t_item
+        where data_model_id = #{id}
+    </select>
+
 </mapper>