| | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.ximon.admin.param.PoleGroupParam; |
| | | import com.sandu.ximon.admin.param.GroupParam; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.dao.domain.PoleGroup; |
| | | import com.sandu.ximon.dao.domain.PoleGroupRelation; |
| | | import com.sandu.ximon.dao.enums.OrderByEnums; |
| | | import com.sandu.ximon.dao.mapper.PoleGroupMapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | private final PoleGroupRelationService poleGroupRelationService; |
| | | |
| | | public boolean addGroup(PoleGroupParam param) { |
| | | public boolean addGroup(GroupParam param) { |
| | | PoleGroup group = new PoleGroup(); |
| | | if(SecurityUtils.getClientId()!=null){ |
| | | if (SecurityUtils.getClientId() != null) { |
| | | group.setClientId(SecurityUtils.getUserId()); |
| | | } |
| | | |
| | | group.setGroupName(param.getGroupName()); |
| | | return save(group); |
| | | } |
| | | |
| | | public boolean updateGroup(Long groupId, PoleGroupParam param) { |
| | | public boolean updateGroup(Long groupId, GroupParam param) { |
| | | PoleGroup poleGroup = getById(groupId); |
| | | if (poleGroup == null) { |
| | | throw new BusinessException("未找到该分组"); |
| | |
| | | if (poleGroup == null) { |
| | | throw new BusinessException("未找到该分组"); |
| | | } |
| | | /** |
| | | * 刪除 |
| | | */ |
| | | poleGroupRelationService.remove(Wrappers.lambdaQuery(PoleGroupRelation.class).eq(PoleGroupRelation::getPoleGroupId, groupId)); |
| | | return removeById(groupId); |
| | | } |
| | | |
| | | public List<PoleGroup> groupList(BaseConditionVO baseConditionVO,String keyword) { |
| | | public List<PoleGroup> groupList(BaseConditionVO baseConditionVO, String keyword, Integer order, Integer seq) { |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | if (clientId == null) { |
| | | return list(Wrappers.lambdaQuery(PoleGroup.class).like(PoleGroup::getGroupName,keyword)); |
| | | } else { |
| | | return list(Wrappers.lambdaQuery(PoleGroup.class).eq(PoleGroup::getClientId, clientId).like(PoleGroup::getGroupName,keyword)); |
| | | |
| | | //排序字段 |
| | | String orderByResult = "group_id"; |
| | | //正序、倒叙 |
| | | String orderBySeq = OrderByEnums.ASC.getCode(); |
| | | if (order != null) { |
| | | switch (order) { |
| | | case 1: |
| | | orderByResult = OrderByEnums.POLE_GROUP_UPDATE_TIME.getCode(); |
| | | break; |
| | | case 2: |
| | | orderByResult = OrderByEnums.POLE_GROUP_CREATE_TIME.getCode(); |
| | | break; |
| | | default: |
| | | } |
| | | } |
| | | if (seq != null) { |
| | | switch (seq) { |
| | | case 1: |
| | | orderBySeq = OrderByEnums.ASC.getCode(); |
| | | break; |
| | | case 2: |
| | | orderBySeq = OrderByEnums.DESC.getCode(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | //排序方式 |
| | | String orderBy = orderByResult + " " + orderBySeq; |
| | | |
| | | if (baseConditionVO != null) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), orderBy); |
| | | } |
| | | |
| | | List<PoleGroup> list; |
| | | if (clientId == null) { |
| | | list = list(Wrappers.lambdaQuery(PoleGroup.class).like(PoleGroup::getGroupName, keyword)); |
| | | |
| | | } else { |
| | | list = list(Wrappers.lambdaQuery(PoleGroup.class).eq(PoleGroup::getClientId, clientId).like(PoleGroup::getGroupName, keyword)); |
| | | } |
| | | |
| | | list.forEach(poleGroup -> { |
| | | poleGroup.setPoleCount(poleGroupRelationService.list(Wrappers.lambdaQuery(PoleGroupRelation.class).eq(PoleGroupRelation::getPoleGroupId, poleGroup.getGroupId())).size()); |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 绑定灯杆 |
| | | */ |
| | | public boolean bindPole(Long groupId,List<Long> poleIdList) { |
| | | public boolean bindPole(Long groupId, List<Long> poleIdList) { |
| | | PoleGroup poleGroup = getById(groupId); |
| | | if (poleGroup == null) { |
| | | throw new BusinessException("未找到该分组"); |
| | | } |
| | | return poleGroupRelationService.saveBinding(groupId,poleIdList); |
| | | return poleGroupRelationService.saveBinding(groupId, poleIdList); |
| | | } |
| | | } |