whyclxw
2025-01-08 2e470c69d0230fb47a68ead64af5ed23c6312d63
区域管理员查看区域下的锁的状态--区域管理员
3个文件已修改
57 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/AppController.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/db_area/LockInf.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/AreaInfService.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/AppController.java
@@ -57,4 +57,10 @@
        return ainfService.getCtlog(pageNum,pageSize);
    }
    @ApiOperation(value = "区域管理员查看指定区域下的锁的状态--区域管理员")
    @GetMapping("getAreaLockById")
    public Response getAreaLockById(@RequestParam int id){
        return ainfService.getAreaLockById(id);
    }
}
src/main/java/com/whyc/pojo/db_area/LockInf.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
@@ -13,6 +14,7 @@
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
@@ -61,6 +63,13 @@
    @ApiModelProperty(value = "锁的mac地址")
    private String lockMac;
    @ApiModelProperty(value = "锁具在线状态[0-离线  1-在线]")
    private Integer lockOnline;
    @ApiModelProperty(value = "上一次更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastUpdateTime;
    @TableField(exist = false)
    private List<AuthiruzeInf> authList;
src/main/java/com/whyc/service/AreaInfService.java
@@ -295,5 +295,45 @@
        return new Response().setII(1,true,map,"区域管理员点击查看开锁操作记录--区域管理员");
    }
    //区域管理员查看区域下的锁的状态--区域管理员
    public Response getAreaLockById(int id) {
        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);
        List<LockInf> linfs=new ArrayList<>();
        map.put("allLinfs",linfs);
        List areaList=new ArrayList();
        areaList.add(id);
        getAllAreaId(id,areaList);
        //查看区域下所有的锁
        QueryWrapper linfWrapper=new QueryWrapper();
        linfWrapper.in("area_id",areaList);
        linfs=linfMapper.selectList(linfWrapper);
        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("openNum", openmap.get(0).size());//闭锁
                }
                if(open==1){
                    map.put("closeNum", openmap.get(1).size());//开锁
                }
            }
            map.put("allLinfs",linfs);
        }
        return new Response().setII(1,true,map,"区域管理员查看区域下的锁的状态--区域管理员");
    }
}