| | |
| | | import com.whyc.dto.RealDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.*; |
| | | import com.whyc.pojo.plus_inf.LockAddress; |
| | | import com.whyc.pojo.plus_inf.LockInf; |
| | | import com.whyc.pojo.plus_inf.StationInf; |
| | | import com.whyc.pojo.plus_lock_ram.LockIdcard; |
| | |
| | | private BaojigroupUsrMapper bjUserMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private BaojigroupService baojiService; |
| | | |
| | | @Autowired(required = false) |
| | | private BaojigroupMapper bjMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private LockIdcardMapper idcardMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private LockAddressMapper addressMapper; |
| | | |
| | | |
| | | @Autowired |
| | | private ProcessSurveyService processSurveyService; |
| | |
| | | QueryWrapper wrapper1=new QueryWrapper(); |
| | | wrapper1.eq("station_id",stationId); |
| | | wrapper1.eq("lock_name",lockInf.getLockName()); |
| | | wrapper1.eq("del_flag",0); |
| | | wrapper1.last("limit 1"); |
| | | LockInf judgeLock=mapper.selectOne(wrapper1); |
| | | if (judgeLock!=null){ |
| | |
| | | linf.setLastUpdateTime(new Date()); |
| | | linf.setModel(0); |
| | | linf.setLockOpenCount(0); |
| | | linf.setLockIp(lockInf.getLockIp()); |
| | | int flag=mapper.insert(linf); |
| | | if(flag==1){//添加成功(包机组操作) |
| | | insertInbaoji(stationId,lockId); |
| | | //锁的默认位置插入为0 |
| | | LockAddress lockAddress=new LockAddress(); |
| | | lockAddress.setStationId(stationId); |
| | | lockAddress.setLockId(lockId); |
| | | lockAddress.setScreenFlag(0); |
| | | lockAddress.setAddressFlag(0); |
| | | addressMapper.insert(lockAddress); |
| | | } |
| | | return new Response().set(1,true); |
| | | } |
| | |
| | | wrapper4.eq("baoji_name","默认包机组"); |
| | | wrapper4.last("limit 1"); |
| | | group=bjMapper.selectOne(wrapper4); |
| | | baojiService.insertNeiZhi(group.getId()); |
| | | } |
| | | BaojigroupUsr bjUsr=new BaojigroupUsr(); |
| | | bjUsr.setUid(uinf.getUid()); |
| | |
| | | public Response delLock(Integer lockId) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("lock_id",lockId); |
| | | mapper.delete(wrapper); |
| | | wrapper.set("del_flag",1);//删除时标记为1 |
| | | int flag=mapper.update((LockInf) ActionUtil.objeNull,wrapper); |
| | | if(flag==1){ |
| | | //删除包机组下记录 |
| | | UpdateWrapper wrapper1=new UpdateWrapper(); |
| | | wrapper1.eq("lock_id",lockId); |
| | | bjLockMapper.delete(wrapper1); |
| | | //移除address |
| | | UpdateWrapper wrapper2=new UpdateWrapper(); |
| | | wrapper2.eq("lock_id",lockId); |
| | | addressMapper.delete(wrapper2); |
| | | } |
| | | return new Response().set(1,true); |
| | | } |
| | | //修改锁 |
| | |
| | | if(lockInf.getScreenFlag()!=null){ |
| | | wrapper.set("screen_flag",lockInf.getScreenFlag()); |
| | | } |
| | | |
| | | if(lockInf.getLongitude()!=null){ |
| | | wrapper.set("longitude",lockInf.getLongitude()); |
| | | } |
| | |
| | | wrapper.set("latitude",lockInf.getLatitude()); |
| | | } |
| | | mapper.update((LockInf) ActionUtil.objeNull,wrapper); |
| | | if(lockInf.getLockIp()!=null){ |
| | | UpdateWrapper wrapper1=new UpdateWrapper(); |
| | | wrapper1.set("lock_ip",lockInf.getLockIp()); |
| | | wrapper1.eq("station_id",lockInf.getStationId()); |
| | | mapper.update((LockInf) ActionUtil.objeNull,wrapper1); |
| | | processSurveyService.setUpThreadRestart(); |
| | | } |
| | | return new Response().set(1,true); |
| | | } |
| | | |
| | |
| | | map.put("closeNum",0); |
| | | map.put("unLoadNum",0); |
| | | //根据dto中stationid和包机组id查询出管理的lockid |
| | | List<Integer> lockIdList=bjLockMapper.getLocIdByStationidAndBjId(dto.getStationId(),dto.getBaojiId()); |
| | | List<LockInf> linfs=mapper.getRealLock(lockIdList); |
| | | if(linfs!=null&&linfs.size()>0){ |
| | | map.put("sumLinf",linfs.size()); |
| | | Map<Integer, List<LockInf>> onlinemap = linfs.stream().collect(Collectors.groupingBy(LockInf::getLockOnline)); |
| | | for (Integer state : onlinemap.keySet()) { |
| | | if(state==0){ |
| | | map.put("offLineNum", onlinemap.get(0).size());//离线 |
| | | try { |
| | | List<Integer> lockIdList=bjLockMapper.getLocIdByStationidAndBjId(dto.getStationId(),dto.getBaojiId()); |
| | | List<LockInf> linfs=mapper.getRealLock(lockIdList); |
| | | //包机组下锁的位置信息 |
| | | List<LockAddress> addressList=addressMapper.getAddressList(lockIdList); |
| | | //机房下所有锁的位置 |
| | | List<LockAddress> AllAddressList=addressMapper.getAllAddress(dto.getStationId()); |
| | | if(linfs!=null&&linfs.size()>0){ |
| | | map.put("sumLinf",linfs.size()); |
| | | Map<Integer, List<LockInf>> onlinemap = linfs.stream().collect(Collectors.groupingBy(LockInf::getLockOnline)); |
| | | for (Integer state : onlinemap.keySet()) { |
| | | if(state==0){ |
| | | map.put("offLineNum", onlinemap.get(0).size());//离线 |
| | | } |
| | | if(state==1){ |
| | | map.put("onlineNum", onlinemap.get(1).size());//在线 |
| | | } |
| | | } |
| | | if(state==1){ |
| | | map.put("onlineNum", onlinemap.get(1).size());//在线 |
| | | Map<Integer, List<LockInf>> openmap = linfs.stream().collect(Collectors.groupingBy(LockInf::getLockState)); |
| | | for (Integer open : openmap.keySet()) { |
| | | if(open==0){ |
| | | map.put("closeNum", openmap.get(0).size());//闭锁 |
| | | } |
| | | if(open==1){ |
| | | map.put("openNum", openmap.get(1).size());//开锁 |
| | | } |
| | | if(open==-1){ |
| | | map.put("unLoadNum", openmap.get(-1).size());//未安装 |
| | | } |
| | | } |
| | | } |
| | | Map<Integer, List<LockInf>> openmap = linfs.stream().collect(Collectors.groupingBy(LockInf::getLockState)); |
| | | for (Integer open : openmap.keySet()) { |
| | | if(open==0){ |
| | | map.put("closeNum", openmap.get(0).size());//闭锁 |
| | | } |
| | | if(open==1){ |
| | | map.put("openNum", openmap.get(1).size());//开锁 |
| | | } |
| | | if(open==-1){ |
| | | map.put("unLoadNum", openmap.get(-1).size());//未安装 |
| | | } |
| | | } |
| | | PageInfo pageInfo= PageInfoUtils.list2PageInfo(linfs, dto.getPageNum(), dto.getPageSize()); |
| | | map.put("pageInfo",pageInfo); |
| | | return new Response().setIV(1,linfs!=null,map,addressList,AllAddressList,"实时获取获取区域下所有锁的状态"); |
| | | } catch (Exception e) { |
| | | return new Response().set(1,false,"实时获取获取区域下所有锁的状态"); |
| | | } |
| | | PageInfo pageInfo= PageInfoUtils.list2PageInfo(linfs, dto.getPageNum(), dto.getPageSize()); |
| | | map.put("pageInfo",pageInfo); |
| | | return new Response().setII(1,linfs!=null,map,"实时获取获取区域下所有锁的状态"); |
| | | } |
| | | //查询锁的信息和id卡 |
| | | public Response getLockId(LockIdDto dto) { |