| | |
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.alibaba.fastjson.JSONArray;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.moral.mapper.DictionaryDataMapper;
|
| | | import com.moral.mapper.OrganizationMapper;
|
| | | import com.moral.service.HistoryHourlyService;
|
| | | import com.moral.util.MyLatLng;
|
| | | import com.moral.util.mapUtils;
|
| | | 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.StringUtils;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.entity.Device;
|
| | | import com.moral.entity.DeviceProperty;
|
| | | import com.moral.entity.MonitorPoint;
|
| | | import com.moral.mapper.DeviceMapper;
|
| | | import com.moral.mapper.DevicePropertyMapper;
|
| | | import com.moral.mapper.DictionaryDataMapper;
|
| | | import com.moral.mapper.MonitorPointMapper;
|
| | | import com.moral.mapper.OrganizationMapper;
|
| | | import com.moral.service.DeviceService;
|
| | | import com.moral.service.HistoryHourlyService;
|
| | | import com.moral.service.MonitorPointService;
|
| | | import com.moral.service.OrganizationService;
|
| | | import com.moral.util.MyLatLng;
|
| | | import com.moral.util.mapUtils;
|
| | |
|
| | | import org.apache.commons.collections.CollectionUtils;
|
| | | import org.springframework.stereotype.Service;
|
| | | import tk.mybatis.mapper.entity.Example;
|
| | | import tk.mybatis.mapper.entity.Example.Criteria;
|
| | |
|
| | |
| | | @Resource
|
| | | private HistoryHourlyService historyHourlyService;
|
| | |
|
| | | @Resource
|
| | | DevicePropertyMapper devicePropertyMapper;
|
| | |
|
| | | private static Class ENTITY_CLASS = MonitorPoint.class;
|
| | |
|
| | | @Override
|
| | | public List<MonitorPoint> getMonitorPointsByAreaName(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("areaName"), "param.is.null");
|
| | | return monitorPointMapper.getMonitorPointsByAreaName(parameters);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<MonitorPoint> queryWithStateByMap(Map<String, Object> params){
|
| | | params.put("isDelete",Constants.IS_DELETE_FALSE);
|
| | |
| | | }
|
| | | return monitorPointList == null ? new ArrayList<>() : monitorPointList;
|
| | | }
|
| | |
|
| | | private Integer getStateFromRedis(Integer monitorPointId){
|
| | | StringBuilder key = new StringBuilder();
|
| | | key.append("state_").append(monitorPointId).append("_*");
|
| | |
| | | state = state==-1?4:state;
|
| | | return state;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public PageBean queryByPageBean(PageBean pageBean) {
|
| | | Example example = ExampleUtil.generateExample(ENTITY_CLASS,pageBean);
|
| | |
| | | List<MonitorPoint> monitorPointList = monitorPointMapper.selectWithAreaNameByExample(example);
|
| | | return new PageBean(monitorPointList);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public MonitorPoint queryWithRelationById(Integer id){
|
| | | Example example = new Example(ENTITY_CLASS);
|
| | |
| | | List<MonitorPoint> monitorPointList = monitorPointMapper.selectWithAreaNameByExample(example);
|
| | | return monitorPointList!=null&&monitorPointList.size()>0?monitorPointList.get(0):null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addOrModify(MonitorPoint monitorPoint) {
|
| | | try{
|
| | |
| | | refreshDevicesInRedis(monitorPoint.getId());
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception ex){
|
| | | } catch (Exception ex) {
|
| | | throw ex;
|
| | | }
|
| | | }
|
| | |
|
| | | /*
|
| | | 刷新当前监控点下设备 在redis里设备信息
|
| | | */
|
| | |
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteByIds(Integer... ids) {
|
| | | MonitorPoint monitorPoint = new MonitorPoint();
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | *
|
| | | * @param idList
|
| | | * @return {id:,state:}
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 获取所属组织的监控点总数
|
| | | *
|
| | | * @param orgId
|
| | | * @return
|
| | | */
|
| | |
| | | }
|
| | | return monitorPointMapper.selectCountByExample(example);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<MonitorPoint> getMonitorPointsByOrganizationId(Integer orgId) {
|
| | | Example example = new Example(MonitorPoint.class);
|
| | |
| | | example.orderBy("name").asc();
|
| | | return monitorPointMapper.selectByExample(example);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<MonitorPoint> getMonitorPointsByRegion(Map<String, Object> parameters) {
|
| | | Example example = new Example(MonitorPoint.class);
|
| | |
| | | criteria.andEqualTo(parameters.get("name").toString(), parameters.get("value"));
|
| | | return monitorPointMapper.selectByExample(example);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Integer> queryVersionsById(Integer id){
|
| | | return monitorPointMapper.selectVersionsById(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public MonitorPoint queryMonitorPointById(Integer mpointId) {
|
| | | return this.monitorPointMapper.selectByPrimaryKey(mpointId);
|
| | |
| | | List<MonitorPoint> monitorPoints = monitorPointMapper.selectByExample(example);
|
| | | //查询监控点下所有的设备
|
| | | Iterator<MonitorPoint> iterator = monitorPoints.iterator();
|
| | | while (iterator.hasNext()) {
|
| | | /*while (iterator.hasNext()) {
|
| | | MonitorPoint monitorPoint = iterator.next();
|
| | | List<Device> devices = deviceService.getDevicesByMonitorPointId(monitorPoint.getId());
|
| | | if (ObjectUtils.isEmpty(devices)) {
|
| | |
| | | monitorPoint.setDevices(devices);
|
| | | }
|
| | |
|
| | | }*/
|
| | | Example deviceExample = new Example(Device.class);//实例化
|
| | | Criteria deviceCriteria = deviceExample.createCriteria();
|
| | | deviceCriteria.orEqualTo("isDelete", Constants.IS_DELETE_FALSE);
|
| | | List<Device> devicesInfo = deviceMapper.selectByExample(deviceExample);
|
| | | Example monitorExample = new Example(MonitorPoint.class);//实例化
|
| | | Criteria monitorCriteria = monitorExample.createCriteria();
|
| | | monitorCriteria.orEqualTo("isDelete", Constants.IS_DELETE_FALSE);
|
| | | List<MonitorPoint> monitorPointInfo = monitorPointMapper.selectByExample(monitorExample);
|
| | | List<DeviceProperty> devicePropertyList = devicePropertyMapper.selectAll();
|
| | | for (Device d : devicesInfo) {
|
| | | for (DeviceProperty dp : devicePropertyList) {
|
| | | if (dp.getId().equals(d.getId())) {
|
| | | d.setDeviceProperty(dp);
|
| | | }
|
| | | }
|
| | | }
|
| | | Map<Integer, List<Device>> monitorDeviceMap = new HashMap();
|
| | | for (MonitorPoint m : monitorPointInfo) {
|
| | | List<Device> monitorDevices = new ArrayList<>();
|
| | | for (Device d : devicesInfo) {
|
| | | if (m.getId().equals(d.getMonitorPointId())) {
|
| | | monitorDevices.add(d);
|
| | | }
|
| | | }
|
| | | monitorDeviceMap.put(m.getId(), monitorDevices);
|
| | | }
|
| | | while (iterator.hasNext()) {
|
| | | MonitorPoint monitorPoint = iterator.next();
|
| | | for (Map.Entry<Integer, List<Device>> entry : monitorDeviceMap.entrySet()) {
|
| | | if (monitorPoint.getId().equals(entry.getKey())) {
|
| | | if (!CollectionUtils.isEmpty(entry.getValue())) {
|
| | | monitorPoint.setDevices(entry.getValue());
|
| | | } else {
|
| | | iterator.remove();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return monitorPoints;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> selectAllById(String id) {
|
| | | int id2 = Integer.parseInt(id);
|