Bläddra i källkod

异味代码处理

linft 2 år sedan
förälder
incheckning
589eeb7b7f

+ 2 - 12
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabExitLineVertexServiceImpl.java

@@ -120,14 +120,6 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
      */
     @Override
     public int getCalculationLine(LabExitLineVertex labExitLineVertex) {
-//        List<LabExitLineVertex> labExitLineVOList = labExitLineVertexMapper.selectLabExitLineVertexList(labExitLineVertex);
-//        if(labExitLineVOList.size()>0){
-//            String relationData = labExitLineVOList.get(0).getRelationalData();
-//            List <LabExitLineJoinPointVO> relationalData = JSONArray.parseArray(relationData, LabExitLineJoinPointVO.class);
-//            V=relationalData.size();
-//            ArrayList <Integer[][]> list=flody(relationalData);
-//            display_path(list,relationalData);
-//        }
         return 1;
     }
 
@@ -740,10 +732,8 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
                     a.setSubBottle(Boolean.FALSE);
                     //这里查询一下实验室是否有气瓶
                     ResultData <List <Map<String,Object>>> beaconData = remoteAirBottleService.findBySubId(b.getId());
-                    if(beaconData.getCode()==200){
-                        if(beaconData.getData().size()>0){
-                            a.setSubBottle(Boolean.TRUE);
-                        }
+                    if(beaconData.getCode()==200 && beaconData.getData().size()>0){
+                        a.setSubBottle(Boolean.TRUE);
                     }
                 }));
         //实验室下的在线人员

+ 0 - 16
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabHaikangUserServiceImpl.java

@@ -72,12 +72,7 @@ public class LabHaikangUserServiceImpl implements LabHaikangUserService {
     @Override
     public boolean deleteByIds(Long... id) {
         for (Long i : id) {
-            LabHaikangUser haikangUser = labHaikangUserMapper.queryById(i);
             this.labHaikangUserMapper.deleteById(i);
-
-           /* if(haikangUser.isState()){
-                haiKangDoorService.deleteUserDoorByHardId(haikangUser.getHardId(), haikangUser, tokenService.getLoginUser());
-            }*/
         }
         return true;
     }
@@ -120,10 +115,6 @@ public class LabHaikangUserServiceImpl implements LabHaikangUserService {
                 SaveUtil.setCommonAttr(entitie);
                 entities.add(entitie);
             }
-//            int count = labHaikangUserMapper.insertBatch(entities);
-//            if(count > 0){
-//                haiKangDoorService.addUserDoorByHardId(haikangAddUserVo.getHardId(), entities, tokenService.getLoginUser());
-//            }
             return 1;
         }
         return 0;
@@ -151,12 +142,6 @@ public class LabHaikangUserServiceImpl implements LabHaikangUserService {
         });
 
         if(entities.size() > 0){
-
-            LabHaikangUser haikangUser = new LabHaikangUser();
-            haikangUser.setIds(entities.stream().map(LabHaikangUser::getId).collect(Collectors.toList()));
-
-            List<LabHaikangUser> list = labHaikangUserMapper.queryAll(haikangUser);
-            //haiKangDoorService.updateUserInfo(list);
             return 1;
         }
 
@@ -180,7 +165,6 @@ public class LabHaikangUserServiceImpl implements LabHaikangUserService {
             if(list.size() != ids.size()){
                 throw new ServiceException("参数异常!请重试!");
             }
-            //haiKangDoorService.addUserDoorByHardId(haikangAddUserVo.getHardId(), list, tokenService.getLoginUser());
             return list.size();
         }
         return 0;

+ 8 - 39
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabHardwareServiceImpl.java

@@ -6,7 +6,6 @@ import com.zd.common.core.annotation.DataScope;
 import com.zd.common.core.exception.NoRollException;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.redis.RedisService;
-import com.zd.common.core.security.TokenService;
 import com.zd.common.core.utils.DateUtils;
 import com.zd.common.core.utils.SaveUtil;
 import com.zd.common.core.utils.StringUtils;
@@ -78,9 +77,6 @@ public class LabHardwareServiceImpl implements ILabHardwareService {
     @Autowired
     private RemoteCabinetService remoteCabinetService;
 
-    @Autowired
-    private TokenService tokenService;
-
     /**
      * 查询硬件
      *
@@ -162,15 +158,6 @@ public class LabHardwareServiceImpl implements ILabHardwareService {
     @DataScope(deptAlias = "xx" , userAlias = "xx", permi = PerPrefix.LABORATORY_HARDWARE)
     public List<LabHardwareVO> selectLabHardwareList(LabHardware labHardware) {
         List<LabHardwareVO> list = labHardwareMapper.selectLabHardwareList(labHardware);
-
-        /*Map<String, Object> map;
-        for (LabHardwareVO labHardwareVO : list) {
-            map = socketService.getRelayData(labHardwareVO.getRelayCode());
-            if(map != null && labHardwareVO.getBit() != null){
-                int status = Integer.parseInt(map.get("reverseBit").toString().substring(labHardwareVO.getBit() -1, labHardwareVO.getBit()));
-                labHardwareVO.setStatus(status);
-            }
-        }*/
         for (LabHardwareVO labHardwareVO : list) {
             if(labHardwareVO.getHardwareType()==2){
                 Integer code=redisService.getCacheObject(CacheConstants.RELAY_STATUS_KEY+labHardwareVO.getId());
@@ -241,20 +228,16 @@ public class LabHardwareServiceImpl implements ILabHardwareService {
             LabHardware labHardware2 = new LabHardware();
             labHardware2.setHardwareNum(labHardware.getHardwareNum());
             Predicate<List<LabHardwareVO>> p = x->x.size()>0;
-            if(StringUtils.isNotBlank(labHardware2.getHardwareNum())){
-                if(p.test(labHardwareMapper.selectLabHardwareList(labHardware2))){
-                    throw new ServiceException("设备编号重复,请重新输入。");
-                }
+            if(StringUtils.isNotBlank(labHardware2.getHardwareNum())
+                    && p.test(labHardwareMapper.selectLabHardwareList(labHardware2))){
+                throw new ServiceException("设备编号重复,请重新输入。");
             }
             int id;
             try{
                 id = labHardwareMapper.insertLabHardware(labHardware);
-
-                if(HardwareTypeEnum.HK_DOOR.equals(labHardware.getType())){
-                    if(labHardwareMapper.selectCountByType(labHardware) > 3){
-                        throw new ServiceException("添加失败:同一实验室最多添加3台门禁设备");
-                    }
-                    //haiKangDoorService.addUserAuthorizeDoor(true, labHardware, tokenService.getLoginUser());
+                if(HardwareTypeEnum.HK_DOOR.equals(labHardware.getType())
+                        && labHardwareMapper.selectCountByType(labHardware) > 3){
+                    throw new ServiceException("添加失败:同一实验室最多添加3台门禁设备");
                 }
 
             }catch (DuplicateKeyException e){
@@ -347,11 +330,6 @@ public class LabHardwareServiceImpl implements ILabHardwareService {
             }
             try{
                 id=labHardwareMapper.updateLabHardware(labHardware);
-
-                /*if(HardwareTypeEnum.HK_DOOR.equals(old.getType()) && !old.getControlScope().equals(labHardware.getControlScope())){
-                    haiKangDoorService.updateUserAuthorizeDoor(old, labHardware);
-                }*/
-
             }catch (DuplicateKeyException e){
                 throw new ServiceException("继电器编号位置重复,请重新输入。");
             }
@@ -453,7 +431,6 @@ public class LabHardwareServiceImpl implements ILabHardwareService {
         }catch (DuplicateKeyException e){
             throw new ServiceException("该硬件绑定的传感器位置已被使用,绑定失败");
         }
-
         return id;
     }
 
@@ -466,8 +443,7 @@ public class LabHardwareServiceImpl implements ILabHardwareService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int setLock(LabHardwareVO labHardwareVO) {
-        int flag = labHardwareMapper.setLock(labHardwareVO);
-        return flag;
+        return labHardwareMapper.setLock(labHardwareVO);
     }
 
     /**
@@ -479,15 +455,8 @@ public class LabHardwareServiceImpl implements ILabHardwareService {
     @Override
     @Transactional(noRollbackFor = {NoRollException.class})
     public int deleteLabHardwareByIds(Long[] ids) {
-        LabHardwareVO labHardware = labHardwareMapper.selectLabHardwareById(ids[0]);
-
         labSubjectHardwarePostionMapper.deleteLabSubjectHardwarePositionByHardId(ids[0]);
-        int flag = labHardwareMapper.deleteLabHardwareByIds(ids);
-
-        /*if(HardwareTypeEnum.HK_DOOR.equals(labHardware.getType())){
-            haiKangDoorService.deleteUserAuthorizeDoor(labHardware);
-        }*/
-        return flag;
+        return  labHardwareMapper.deleteLabHardwareByIds(ids);
     }
 
     /**