| | |
| | | import com.whyc.pojo.db_area.LockInf; |
| | | import com.whyc.pojo.db_user.UserInf; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.PageInfoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | |
| | | @Autowired(required = false) |
| | | private AuthiruzeInfMapper authMapper; |
| | | |
| | | @Autowired |
| | | private ProcessSurveyService processSurveyService; |
| | | //添加锁 |
| | | public Response addLock(Integer num, LockInf lockInf) { |
| | | if(num==null){ |
| | |
| | | LockInf linf=new LockInf(); |
| | | linf.setLockId(lockId+i); |
| | | linf.setAreaId(lockInf.getAreaId()); |
| | | linf.setLockName(lockInf.getLockName()+(i+1)); |
| | | if(num>1){ |
| | | linf.setLockName(lockInf.getLockName()+(i+1)); |
| | | }else{ |
| | | linf.setLockName(lockInf.getLockName()); |
| | | } |
| | | linf.setLockType(lockInf.getLockType()); |
| | | linf.setLockState(-1); |
| | | if(lockInf.getLockAddress()!=null){ |
| | |
| | | linf.setScreenFlag(lockInf.getScreenFlag()); |
| | | linf.setLockOnline(0); |
| | | linf.setLastUpdateTime(new Date()); |
| | | linf.setModel(0); |
| | | linf.setLockOpenCount(0); |
| | | list.add(linf); |
| | | } |
| | | mapper.insertBatchSomeColumn(list); |
| | | processSurveyService.setUpThreadRestart(); |
| | | return new Response().set(1,true); |
| | | } |
| | | //获取当前最大的锁 |
| | |
| | | if(lockInf.getScreenFlag()!=null){ |
| | | wrapper.set("screen_flag",lockInf.getScreenFlag()); |
| | | } |
| | | if(lockInf.getLatitude()!=null){ |
| | | wrapper.set("longitude",lockInf.getLatitude()); |
| | | } |
| | | if(lockInf.getLongitude()!=null){ |
| | | wrapper.set("latitude",lockInf.getLongitude()); |
| | | wrapper.set("longitude",lockInf.getLongitude()); |
| | | } |
| | | if(lockInf.getLatitude()!=null){ |
| | | wrapper.set("latitude",lockInf.getLatitude()); |
| | | } |
| | | mapper.update((LockInf) ActionUtil.objeNull,wrapper); |
| | | return new Response().set(1,true); |
| | |
| | | List<LockInf> list=mapper.selectList(wrapper); |
| | | return new Response().setII(1,list!=null,list,"查询所有锁名信息(用于下拉)"); |
| | | } |
| | | //查询屏柜的全部类型(下拉) |
| | | public Response getScreenType() { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.select("distinct screen_box_type"); |
| | | List<LockInf> list=mapper.selectList(wrapper); |
| | | List<String> typeList = list.stream() |
| | | .map(LockInf::getScreenBoxType) // 提取名字 |
| | | .collect(Collectors.toList()); // 转换为列表*/ |
| | | return new Response().setII(1,list!=null,typeList,"查询屏柜的全部类型(下拉)"); |
| | | } |
| | | //查询屏柜全部品牌(下拉) |
| | | public Response getScreenProduct() { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.select("distinct screen_box_product"); |
| | | List<LockInf> list=mapper.selectList(wrapper); |
| | | List<String> typeList = list.stream() |
| | | .map(LockInf::getScreenBoxProduct) // 提取名字 |
| | | .collect(Collectors.toList()); // 转换为列表*/ |
| | | return new Response().setII(1,list!=null,typeList,"查询屏柜全部品牌(下拉)"); |
| | | } |
| | | //实时获取获取区域下所有锁的状态 |
| | | public Response getRealLock(Integer areaId, Integer pageNum, Integer pageSize) { |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("sumLinf",0); |
| | | map.put("onlineNum",0); |
| | | map.put("offLineNum",0); |
| | | map.put("openNum",0); |
| | | map.put("closeNum",0); |
| | | map.put("unLoadNum",0); |
| | | List<Integer> areaList=new ArrayList(); |
| | | areaList.add(areaId); |
| | | areaInfService.getAllAreaId(areaId,areaList); |
| | | List<LockInf> linfs=mapper.getRealLock(areaList); |
| | | 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());//在线 |
| | | } |
| | | } |
| | | 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,pageNum,pageSize); |
| | | map.put("pageInfo",pageInfo); |
| | | return new Response().setII(1,linfs!=null,map,"实时获取获取区域下所有锁的状态"); |
| | | } |
| | | } |