| | |
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.HashMap;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | import com.moral.mapper.OrganizationMapper;
|
| | | import org.apache.commons.collections.CollectionUtils;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.util.ObjectUtils;
|
| | |
|
| | | import com.github.pagehelper.PageHelper;
|
| | | import com.moral.common.bean.Constants;
|
| | | import com.moral.common.bean.PageBean;
|
| | | import com.moral.common.util.ExampleUtil;
|
| | | import com.moral.common.util.ParameterUtils;
|
| | | import com.moral.common.util.RedisUtils;
|
| | | import com.moral.common.util.StringUtils;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | |
| | | import com.moral.entity.MonitorPoint;
|
| | | import com.moral.mapper.DeviceMapper;
|
| | | import com.moral.mapper.MonitorPointMapper;
|
| | | import com.moral.service.DeviceService;
|
| | | import com.moral.service.MonitorPointService;
|
| | | import com.moral.service.OrganizationService;
|
| | |
|
| | | import tk.mybatis.mapper.entity.Example;
|
| | | import tk.mybatis.mapper.entity.Example.Criteria;
|
| | |
| | | @Resource
|
| | | DictionaryDataMapper dictionaryDataMapper;
|
| | |
|
| | | @Resource
|
| | | private DeviceService deviceService;
|
| | | |
| | | @Resource
|
| | | private OrganizationService organizationService;
|
| | | |
| | | private static Class ENTITY_CLASS = MonitorPoint.class;
|
| | | @Override
|
| | | public List<MonitorPoint> getMonitorPointsByAreaName(Map<String, Object> parameters) {
|
| | |
| | |
|
| | | criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE);
|
| | | if (Constants.isNotSpecialOrgId(orgId)) {
|
| | | criteria.andEqualTo("organizationId", orgId);
|
| | | //criteria.andEqualTo("organizationId", orgId);
|
| | | Set<Integer> organizationIds = organizationService.getChildOrganizationIds(orgId);
|
| | | criteria.andIn("organizationId", organizationIds);
|
| | |
|
| | | }
|
| | | example.orderBy("name").asc();
|
| | | return monitorPointMapper.selectByExample(example);
|
| | |
| | | public MonitorPoint queryMonitorPointById(Integer mpointId) {
|
| | | return this.monitorPointMapper.selectByPrimaryKey(mpointId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<MonitorPoint> getMonitorPointsAndDevicesByRegion(Map<String, Object> parameters) {
|
| | | //校验参数
|
| | | Object organizationId = parameters.remove("organizationId");
|
| | | ValidateUtil.notNull(organizationId, "param.is.null");
|
| | | ValidateUtil.notNull(parameters.get("regionCode"), "param.is.null");
|
| | |
|
| | | //组装查询条件
|
| | | ParameterUtils.getRegionType4RegionCode(parameters);
|
| | | |
| | | Example example = new Example(MonitorPoint.class);
|
| | | Criteria criteria = example.createCriteria();
|
| | | criteria.andEqualTo("isDelete", Constants.IS_DELETE_FALSE);
|
| | | if (Constants.isNotSpecialOrgId(Integer.valueOf(organizationId.toString()))) {
|
| | | //criteria.andEqualTo("organizationId", organizationId);
|
| | | Set<Integer> organizationIds = organizationService.getChildOrganizationIds(Integer.valueOf(organizationId.toString()));
|
| | | criteria.andIn("organizationId", organizationIds);
|
| | | }
|
| | | criteria.andEqualTo(parameters.get("regionType") + "Code", parameters.remove("regionCode"));
|
| | | |
| | | //查询监控点数据
|
| | | List<MonitorPoint> monitorPoints = monitorPointMapper.selectByExample(example);
|
| | | //查询监控点下所有的设备
|
| | | Iterator<MonitorPoint> iterator = monitorPoints.iterator();
|
| | | while (iterator.hasNext()) {
|
| | | MonitorPoint monitorPoint = iterator.next();
|
| | | List<Device> devices = deviceService.getDevicesByMonitorPointId(monitorPoint.getId());
|
| | | if (ObjectUtils.isEmpty(devices)) {
|
| | | iterator.remove();
|
| | | } else {
|
| | | monitorPoint.setDevices(devices);
|
| | | }
|
| | | |
| | | }
|
| | | return monitorPoints;
|
| | | }
|
| | | }
|