Kaynağa Gözat

电子信息牌bug修改

xuxiaofei 2 yıl önce
ebeveyn
işleme
a9cc3c0650

+ 19 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/XxpCardInfoServiceImpl.java

@@ -5,10 +5,10 @@ import com.zd.common.core.security.TokenService;
 import com.zd.common.core.utils.StringUtils;
 import com.zd.laboratory.domain.XxpCardInfo;
 import com.zd.laboratory.domain.XxpInspection;
+import com.zd.laboratory.domain.XxpUserAuth;
 import com.zd.laboratory.mapper.XxpCardInfoMapper;
-import com.zd.laboratory.mapper.XxpInspectionMapper;
+import com.zd.laboratory.mapper.XxpUserAuthMapper;
 import com.zd.laboratory.service.IXxpCardInfoService;
-import com.zd.laboratory.service.IXxpInspectionService;
 import com.zd.model.entity.SysUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -31,6 +31,8 @@ public class XxpCardInfoServiceImpl implements IXxpCardInfoService
     @Autowired
     private TokenService tokenService;
 
+    @Autowired
+    private XxpUserAuthMapper xxpUserAuthMapper;
 
     /**
      * 查询电子信息牌
@@ -105,6 +107,15 @@ public class XxpCardInfoServiceImpl implements IXxpCardInfoService
      */
     @Override
     public int deleteXxpCardInfoByIds(Long[] ids) {
+        for (Long id:ids) {
+            XxpUserAuth auth = new XxpUserAuth();
+            auth.setHardwareId(id);
+            List<XxpUserAuth> list = xxpUserAuthMapper.selectXxpUserAuthList(auth);
+            if(list.size()>0){
+                XxpCardInfo info= xxpCardInfoMapper.selectXxpCardInfoById(id);
+                throw new ServiceException("信息牌编号:"+info.getCardName()+",下存在授权人员!");
+            }
+        }
 
         return xxpCardInfoMapper.deleteXxpCardInfoByIds(ids);
     }
@@ -117,7 +128,12 @@ public class XxpCardInfoServiceImpl implements IXxpCardInfoService
      */
     @Override
     public int deleteXxpCardInfoById(Long id) {
-
+        XxpUserAuth auth = new XxpUserAuth();
+        auth.setHardwareId(id);
+        List<XxpUserAuth> list = xxpUserAuthMapper.selectXxpUserAuthList(auth);
+        if(list.size()>0){
+            throw new ServiceException("信息牌下存在授权人员!");
+        }
         return xxpCardInfoMapper.deleteXxpCardInfoById(id);
     }
 }

+ 15 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/XxpUserAuthServiceImpl.java

@@ -84,11 +84,23 @@ public class XxpUserAuthServiceImpl implements IXxpUserAuthService
             throw  new ServiceException("新增集合不能为空!");
         }
 
+        XxpUserAuth uauth = new XxpUserAuth();
         SysUser sysUser = tokenService.getLoginUser().getSysUser();
         for (XxpUserAuth auth:xxpUserAuth.getUserAuthList()) {
-            auth.setCreateTime(new Date());
-            auth.setCreateBy(sysUser.getNickName());
-            xxpUserAuthMapper.insertXxpUserAuth(auth);
+            uauth.setUserId(auth.getUserId());
+            uauth.setSubjectId(auth.getSubjectId());
+            List<XxpUserAuth> list = xxpUserAuthMapper.selectXxpUserAuthList(uauth);
+            if(list.size()>0){
+                auth.setId(list.get(0).getId());
+                auth.setUpdateTime(new Date());
+                auth.setUpdateBy(sysUser.getNickName());
+                xxpUserAuthMapper.updateXxpUserAuth(auth);
+            }else{
+                auth.setCreateTime(new Date());
+                auth.setCreateBy(sysUser.getNickName());
+                xxpUserAuthMapper.insertXxpUserAuth(auth);
+            }
+
         }
         return 1;
     }