| dao/src/main/java/com/sandu/ximon/dao/mapper/PoleMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| dao/src/main/resources/mapper/PoleMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
dao/src/main/java/com/sandu/ximon/dao/mapper/PoleMapper.java
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import java.util.List; /** * @Entity com.sandu.ximon.dao.domain.Pole */ @@ -11,7 +13,9 @@ public interface PoleMapper extends BaseMapper<Pole> { boolean updateDeviceCode(Long id); boolean updateDeviceCode(Long id); List<Pole> queryPoleOnLineStatesList(Long userid, Integer isTrue, Integer bingStates, Long groupid, String keyword); } dao/src/main/resources/mapper/PoleMapper.xml
@@ -38,4 +38,37 @@ SET device_code=null WHERE id = #{id} </update> <select id="queryPoleOnLineStatesList" resultType="com.sandu.ximon.dao.domain.Pole"> SELECT t1.* FROM pole t1 LEFT JOIN pole_group_relation t2 ON t1.id = t2.pole_id LEFT JOIN pole_group t3 ON t3.group_id = t2.pole_group_id <where> <if test="userid != null"> AND (t1.user_id = #{userid} OR t1.client_id = #{userid}) </if> <if test="keyword != null and keyword != ''"> AND ( t1.pole_name LIKE CONCAT(CONCAT('%', #{keyword}), '%') OR t1.device_code LIKE CONCAT(CONCAT('%', #{keyword}), '%')) </if> <if test="isTrue != null and isTrue == 1"> AND t1.device_type = -1 </if> <if test="isTrue != null and isTrue == 0"> AND t1.device_type != -1 </if> <if test="groupid != null"> AND t3.group_id = #{groupid} </if> <if test="bingStates != null and bingStates == 0 "> AND t1.user_id != -1 </if> <if test="bingStates != null and bingStates == 1 "> AND t1.user_id = -1 </if> </where> GROUP BY t1.id </select> </mapper> ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
@@ -75,22 +75,12 @@ if (!permissionConfig.check(MenuEnum.POLE_LIST.getCode())) { return ResponseUtil.fail("缺少对应用户权限"); } PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); List<Pole> results = poleService.queryAllStatesAndList(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), param); CommonPage commonPage = poleService.queryAllStatesAndList(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), param); List<PoleBindVO> listResult = new ArrayList<>(); for (Pole pole : results) { for (Pole pole : (List<Pole>) commonPage.getList()) { PoleBindVO bindByPoleId = poleService.getBindByPoleId(pole.getId()); bindByPoleId.setPole(pole); listResult.add(bindByPoleId); } CommonPage commonPage = CommonPage.restPage(listResult); int size = results.size(); commonPage.setTotal((long) size); commonPage.setTotalPage(size / baseConditionVO.getPageSize() + 1); if (size % baseConditionVO.getPageSize() == 0) { commonPage.setTotalPage(size / baseConditionVO.getPageSize()); } return ResponseUtil.success(commonPage); } @@ -100,15 +90,8 @@ if (!permissionConfig.check(MenuEnum.POLE_LIST.getCode())) { return ResponseUtil.fail("缺少对应用户权限"); } PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); List<Pole> results = poleService.queryAllStatesAndList(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), param); CommonPage commonPage = CommonPage.restPage(results); int size = results.size(); commonPage.setTotal((long) size); commonPage.setTotalPage(size / baseConditionVO.getPageSize() + 1); if (size % baseConditionVO.getPageSize() == 0) { commonPage.setTotalPage(size / baseConditionVO.getPageSize()); } CommonPage commonPage = poleService.queryAllStatesAndList(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), param); return ResponseUtil.success(commonPage); } ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.pagehelper.PageHelper; import com.sandu.common.domain.CommonPage; import com.sandu.common.execption.BusinessException; import com.sandu.common.object.BaseConditionVO; import com.sandu.common.redis.RedisService; @@ -14,6 +15,7 @@ import com.sandu.common.util.SpringContextHolder; import com.sandu.ximon.admin.dto.DeviceStatus; import com.sandu.ximon.admin.dto.WaterQualityDataDto; import com.sandu.ximon.admin.entity.Command; import com.sandu.ximon.admin.manager.iot.frame.A1Frame; import com.sandu.ximon.admin.manager.iot.frame.FrameBuilder; import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame; @@ -31,6 +33,7 @@ import com.sandu.ximon.admin.redis.LightKey; import com.sandu.ximon.admin.security.SecurityUtils; import com.sandu.ximon.admin.utils.LightemitUtils; import com.sandu.ximon.admin.utils.ListPagingUtils; import com.sandu.ximon.admin.utils.RedisUtils; import com.sandu.ximon.admin.utils.response.VnnoxResult; import com.sandu.ximon.admin.vo.PoleBindVO; @@ -260,83 +263,23 @@ return result; } public List<Pole> queryAllStatesAndList(Integer pageNo, Integer pageSize, PoleStatesParam param) { List<Pole> list = new ArrayList<>(); LambdaQueryWrapper<Pole> wrapper = new LambdaQueryWrapper<>(); public CommonPage queryAllStatesAndList(Integer pageNo, Integer pageSize, PoleStatesParam param) { if (param == null) { param = new PoleStatesParam(); } System.out.println(param); List<Pole> poleList; if (SecurityUtils.getClientId() == null) { wrapper = Wrappers.lambdaQuery(Pole.class); poleList = poleMapper.queryPoleOnLineStatesList(null, param.getIsTrue(), param.getBingStates(), param.getGroupid(), param.getKeyword()); } else { wrapper = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, SecurityUtils.getUserId()).or( w -> { w.eq(Pole::getUserId, SecurityUtils.getUserId()); }); } if (param.getKeyword() != null && !param.getKeyword().isEmpty()) { wrapper.like(Pole::getPoleCode, param.getKeyword()).or( wrappers -> { wrappers.like(Pole::getPoleName, param.getKeyword()); } ); poleList = poleMapper.queryPoleOnLineStatesList(SecurityUtils.getUserId(), param.getIsTrue(), param.getBingStates(), param.getGroupid(), param.getKeyword()); } PageHelper.startPage(pageNo, pageSize); list = list(wrapper); if (param.getGroupid() != null) { // List<Long> poleIds = new ArrayList<>(); List<Pole> pole = new ArrayList<>(); List<PoleGroupRelation> relations = groupRelationService.list(Wrappers.lambdaQuery(PoleGroupRelation.class) .eq(PoleGroupRelation::getPoleGroupId, param.getGroupid())); relations.forEach(relation -> { pole.add(getById(relation.getPoleId())); } ); list = pole; } //是否绑定 if (param.getBingStates() != 2) { // 绑定/未绑定 list = isBind(list, param); //已绑定的是否是真实灯杆 if (param.getIsTrue() != 2) { list = isTrue(list, param); //绑定的真实灯杆是否在线 if (param.getOnLineStates() != 2) { list = isOnLine(list, param); } } //全部灯杆 实体/虚拟 else { //查询全部灯杆是否在线 if (param.getOnLineStates() != 2) { list = isOnLine(list, param); } } } //全部 绑定/未绑定 else { // 判断灯杆类型 if (param.getIsTrue() != 2) { // 实体/虚拟 list = isTrue(list, param); // 灯杆的在线判断 if (param.getOnLineStates() != 2) { //在线/离线 list = isOnLine(list, param); } } //全类型灯杆 else { //判断在线状态 if (param.getOnLineStates() != 2) { //在线/离线 list = isOnLine(list, param); } } } List<Pole> PoleResult = isOnLine(poleList, param); setCount(list); return list; CommonPage commonPage = ListPagingUtils.pages(PoleResult, pageNo, pageSize); return commonPage; } /**