2 files added
12 files modified
| | |
| | | package com.moral.common.bean; |
| | | |
| | | import com.moral.common.util.ResourceUtil; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 系统常量. |
| | | */ |
| | | @Component |
| | | public class Constants { |
| | | |
| | | /** The Constant IS_DELETE_TRUE. */ |
| | |
| | | public static final String IS_USED_FALSE = "0"; |
| | | |
| | | public static final String IS_USED_TRUE = "1"; |
| | | private static final Integer[] specialOrgIds = new Integer[]{-1}; |
| | | private static Integer[] specialOrgIds; |
| | | @PostConstruct |
| | | private void loadSpecialOrgIds(){ |
| | | String orgIds = ResourceUtil.getValue("specialOrgIds"); |
| | | if(!StringUtils.isBlank(orgIds)){ |
| | | String [] orgIdArray = orgIds.split(","); |
| | | if(!ArrayUtils.isEmpty(orgIdArray)){ |
| | | List<Integer> orgIdList = Arrays.asList(orgIdArray).stream().map(Integer::new).collect(Collectors.toList()); |
| | | specialOrgIds = orgIdList.toArray(new Integer[orgIdList.size()]); |
| | | } |
| | | } |
| | | |
| | | } |
| | | public static final Boolean isNotSpecialOrgId(Integer orgId) { |
| | | if(ArrayUtils.isEmpty(specialOrgIds)){ |
| | | return true; |
| | | } |
| | | for(int i = 0; i < specialOrgIds.length; ++i) { |
| | | if (specialOrgIds[i].equals(orgId)) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | //device 状态 |
| | | public static final String DEVICE_STATE_NORMAL ="0"; |
| | | public static final String DEVICE_STATE_MILD = "1"; |
| | | public static final String DEVICE_STATE_MIDDLE ="2"; |
| | | public static final String DEVICE_STATE_SERIOUS ="3"; |
| | | public static final String DEVICE_STATE_OFFLINE ="4"; |
| | | } |
| | | |
New file |
| | |
| | | package com.moral.common.bean; |
| | | |
| | | import com.moral.common.exception.Exceptions; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by dgw on 2017/4/10. |
| | | */ |
| | | public class JsonData { |
| | | private Integer total;//一共多少条记录 |
| | | private List rows = new ArrayList();// 数据 |
| | | private boolean success = true;//操作是否成功 |
| | | private String msg = "";//提示信息 |
| | | private String errorTrace;//错误的详细信息 |
| | | private Object extData ;//扩展数据 |
| | | |
| | | /** |
| | | * 数据总条数 |
| | | * @return |
| | | */ |
| | | public Integer getTotal() { |
| | | return total; |
| | | } |
| | | |
| | | /** |
| | | * 数据总条数 |
| | | * @return |
| | | */ |
| | | public void setTotal(Integer total) { |
| | | this.total = total; |
| | | } |
| | | |
| | | /** |
| | | * 每页显示条数 |
| | | * @return |
| | | */ |
| | | public List getRows() { |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * 每页显示条数 |
| | | * @return |
| | | */ |
| | | public void setRows(List rows) { |
| | | this.rows = rows; |
| | | } |
| | | |
| | | /** |
| | | * 操作是否成功 |
| | | * @param success |
| | | */ |
| | | public void setSuccess(boolean success){ |
| | | this.success = success; |
| | | } |
| | | |
| | | /** |
| | | * 操作是否成功 |
| | | * @param |
| | | */ |
| | | public boolean getSuccess(){ |
| | | return success; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 提示信息 |
| | | * @param msg |
| | | */ |
| | | public void setMsg(String msg){ |
| | | this.msg = msg; |
| | | } |
| | | |
| | | /** |
| | | * 提示信息 |
| | | * @param |
| | | */ |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | /** |
| | | * 错误详细信息 |
| | | * @return |
| | | */ |
| | | public String getErrorTrace() { |
| | | return errorTrace; |
| | | } |
| | | |
| | | /** |
| | | * 错误详细信息 |
| | | * @return |
| | | */ |
| | | public void setErrorTrace(String errorTrace) { |
| | | this.errorTrace = errorTrace; |
| | | } |
| | | |
| | | /** |
| | | * 扩展信息 |
| | | * @return |
| | | */ |
| | | public Object getExtData() { |
| | | return extData; |
| | | } |
| | | |
| | | /** |
| | | * 扩展信息 |
| | | * @return |
| | | */ |
| | | public void setExtData(Object extData) { |
| | | this.extData = extData; |
| | | } |
| | | |
| | | /** |
| | | * 设置一个异常对象,将异常信息转换成字符串提供给errorTrace |
| | | * @param e |
| | | */ |
| | | public void setException(Exception e){ |
| | | this.errorTrace = Exceptions.getStackTraceAsString(e); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.common.exception; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.io.StringWriter; |
| | | |
| | | /** |
| | | * Created by dgw on 2017/4/10. |
| | | */ |
| | | public class Exceptions { |
| | | /** |
| | | * 将CheckedException转换为UncheckedException. |
| | | */ |
| | | public static RuntimeException unchecked(Exception e) { |
| | | if (e instanceof RuntimeException) { |
| | | return (RuntimeException) e; |
| | | } else { |
| | | return new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 将ErrorStack转化为String. |
| | | */ |
| | | public static String getStackTraceAsString(Exception e) { |
| | | StringWriter stringWriter = new StringWriter(); |
| | | e.printStackTrace(new PrintWriter(stringWriter)); |
| | | return stringWriter.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 判断异常是否由某些底层的异常引起. |
| | | */ |
| | | public static boolean isCausedBy(Exception ex, Class<? extends Exception>... causeExceptionClasses) { |
| | | Throwable cause = ex.getCause(); |
| | | while (cause != null) { |
| | | for (Class<? extends Exception> causeClass : causeExceptionClasses) { |
| | | if (causeClass.isInstance(cause)) { |
| | | return true; |
| | | } |
| | | } |
| | | cause = cause.getCause(); |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | |
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith;
|
| | |
|
| | | import java.io.*;
|
| | | import java.util.HashMap;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.*;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.alibaba.fastjson.*;
|
| | | import com.moral.common.bean.JsonData;
|
| | | import com.moral.common.bean.PageResult;
|
| | | import com.moral.common.xml.Version;
|
| | | import com.moral.entity.Account;
|
| | | import com.moral.entity.Device;
|
| | | import com.moral.entity.MapBounds;
|
| | | import com.moral.entity.MonitorPoint;
|
| | | import com.moral.service.*;
|
| | | import org.apache.commons.collections.CollectionUtils;
|
| | | import org.apache.commons.lang.ArrayUtils;
|
| | | import org.apache.commons.net.ftp.FTPClient;
|
| | | import org.apache.log4j.Logger;
|
| | | import org.dom4j.Document;
|
| | |
| | | import org.springframework.ui.Model;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.alibaba.fastjson.JSONReader;
|
| | | import com.alibaba.fastjson.TypeReference;
|
| | | import com.moral.common.bean.ResultBean;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import org.springframework.web.servlet.ModelAndView;
|
| | |
| | | }
|
| | | return version;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 地图接口
|
| | | * 开始
|
| | | */
|
| | | /**
|
| | | * 地图主页
|
| | | * @param model
|
| | | * @param code
|
| | | * @param accountId
|
| | | * @return
|
| | | */
|
| | | @RequestMapping(value = "/map-page", method = RequestMethod.GET)
|
| | | public ModelAndView map(ModelAndView model, @RequestParam("areaCode")int code, @RequestParam("accountId")int accountId){
|
| | | Account account = accountService.getAccountById(accountId);
|
| | |
| | | resultBean.setCode(ResultBean.SUCCESS);
|
| | | return resultBean;
|
| | | }
|
| | | @RequestMapping(value="/get-devices",method = RequestMethod.GET)
|
| | | @ResponseBody
|
| | | public ResultBean getDevices(@RequestParam("orgId")Integer orgId,MapBounds mapBounds){
|
| | | ResultBean<List<Device>> resultBean = new ResultBean();
|
| | | Map<String,Object> paramMap = new HashMap<String, Object>();
|
| | | paramMap.put("orgId", orgId);
|
| | | paramMap.put("mapBounds",mapBounds);
|
| | | List<Device> list = deviceService.query(paramMap);
|
| | | resultBean.setData(list);
|
| | | resultBean.setCode(ResultBean.SUCCESS);
|
| | | return resultBean;
|
| | | }
|
| | | @RequestMapping(value = "get-devices-for-popup",method = RequestMethod.GET)
|
| | | @ResponseBody
|
| | | public PageResult getDevicesForPopup(
|
| | |
| | | ){
|
| | | return deviceService.query(orgId,name,pageSize,pageNo);
|
| | | }
|
| | | @RequestMapping(value = "get-devices-by-mid-oid",method = RequestMethod.GET)
|
| | | @ResponseBody
|
| | | public PageResult getDevicesByMidOid(
|
| | | @RequestParam("orgId")Integer orgId,
|
| | | @RequestParam("mpId")Integer mpId,
|
| | | Integer pageSize,
|
| | | Integer pageNo
|
| | | ){
|
| | | return deviceService.query(orgId,mpId,pageSize,pageNo);
|
| | | }
|
| | | @RequestMapping(value="/get-real-state-data",method = RequestMethod.POST)
|
| | | @ResponseBody
|
| | | public JsonData getRealStateAndData(@RequestBody JSONObject paramMap){
|
| | | JsonData jsonData = new JsonData();
|
| | | Map<String,Object> returnMap = new HashMap<String, Object>();
|
| | | returnMap.put("layer", paramMap.getString("layer"));
|
| | | //覆盖控件的数据刷新
|
| | | if(!CollectionUtils.isEmpty(paramMap.getJSONArray("markerKeys"))) {
|
| | | JSONArray markerKeys = paramMap.getJSONArray("markerKeys");
|
| | | List<Map<String, String>> markers = null;
|
| | | if("equipments".equals(paramMap.getString("layer"))) {
|
| | | markers = deviceService.queryDevicesState(markerKeys.toJavaList(String.class),true);
|
| | | }else {//返回监控点id和state
|
| | | String orgId= paramMap.getString("orgId");
|
| | | String areaCode= paramMap.getString("areaCode");
|
| | | for(Object mPointId:markerKeys) {
|
| | | markers = monitorPointService.queryMonitroPointsState(markerKeys.toJavaList(Integer.class));
|
| | | }
|
| | | }
|
| | | returnMap.put("markers", markers);
|
| | | }
|
| | | if(paramMap.getJSONArray("popupEquMacs")!=null&¶mMap.getJSONArray("popupEquMacs").size()>0) {
|
| | | JSONArray popupEquMacs = paramMap.getJSONArray("popupEquMacs");
|
| | | List<Map<String, String>> popupEquWithStates = null;
|
| | | for(Object mac:popupEquMacs) {
|
| | | popupEquWithStates = deviceService.queryDevicesState(popupEquMacs.toJavaList(String.class),false);
|
| | | }
|
| | | //返回搜索结果的状态
|
| | | returnMap.put("popupEquStates", popupEquWithStates);
|
| | | }
|
| | | jsonData.setExtData(returnMap);
|
| | | return jsonData;
|
| | | }
|
| | | }
|
| | |
| | | package com.moral.entity;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.persistence.Id;
|
| | | import javax.persistence.Transient;
|
| | |
| | | private DeviceVersion deviceVersion;
|
| | | @Transient
|
| | | private MonitorPoint monitorPoint;
|
| | | @Transient
|
| | | private List<Integer> organizationIds;
|
| | | } |
| | |
| | | List<String> getDeviceMacByMonitorPointAndDeviceVersion(@Param("monitorPointId")Integer monitorPointId,@Param("deviceVersionId")Integer deviceVersionId);
|
| | |
|
| | | List<Map<String, Object>> getDeviceVersionIdByMonitorPoint(Integer monitorPointId);
|
| | |
|
| | | List<Device> selectByOrgIdAndDevName(@Param("orgId")Integer orgId,@Param("devName")String devName);
|
| | | List<Device> selectByOrgIdAndMpId(@Param("orgId")Integer orgId,@Param("mpId")Integer mpId);
|
| | | List<Device> selectByMap(Map<String, Object> params);
|
| | | Device selectWithOrgIdsByMac(String mac);
|
| | | } |
| | |
| | | import java.util.Map;
|
| | | import com.moral.common.bean.PageBean;
|
| | | import com.moral.common.bean.PageResult;
|
| | | import com.moral.common.bean.ResultBean;
|
| | | import com.moral.entity.Device;
|
| | |
|
| | | public interface DeviceService {
|
| | |
| | |
|
| | | Device getDeviceByMac(String mac);
|
| | |
|
| | | List<Device> query(Map<String,Object> map);
|
| | | PageResult query(Integer orgId, String deviceName,Integer pageSize,Integer pageNo);
|
| | |
|
| | | PageResult query(Integer orgId, Integer mpId, Integer pageSize, Integer pageNo);
|
| | |
|
| | | PageBean queryByPageBean(PageBean pageBean);
|
| | |
|
| | |
| | | void addOrModify(Device device);
|
| | |
|
| | | List<Device> getDevicesByMonitorPointId(Integer monitorPointId);
|
| | |
|
| | | List<Map<String,String>> queryDevicesState(List<String> macList,Boolean withData);
|
| | | }
|
| | |
| | | public void deleteByIds(Integer... ids);
|
| | |
|
| | | List<MonitorPoint> getMonitorPointsByName(String name);
|
| | |
|
| | | List<Map<String,String>> queryMonitroPointsState(List<Integer> idList);
|
| | | }
|
| | |
| | | package com.moral.service.impl;
|
| | |
|
| | | import java.util.*;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import com.alibaba.fastjson.TypeReference;
|
| | | import com.github.pagehelper.Page;
|
| | | import com.moral.common.bean.Constants;
|
| | | import com.moral.common.bean.PageBean;
|
| | | import com.moral.common.bean.PageResult;
|
| | | import com.moral.common.util.ExampleUtil;
|
| | | import com.moral.common.util.RedisUtils;
|
| | | import org.apache.commons.collections.MapUtils;
|
| | | import org.apache.commons.lang3.BooleanUtils;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.util.ObjectUtils;
|
| | |
| | | @Resource
|
| | | private AccountService accountService;
|
| | | private Class ENTITY_CLASS = Device.class;
|
| | | @Resource
|
| | | RedisUtils redisUtils;
|
| | | @Override
|
| | | public Map<String, Object> getDeviceStatesByAccount(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("accountId"), "param.is.null");
|
| | |
| | | return device;
|
| | | }
|
| | |
|
| | | /**
|
| | | *
|
| | | * @param map
|
| | | * map里 包括 组织id和4个坐标点
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public List<Device> query(Map<String, Object> map) {
|
| | | List <Device> list = deviceMapper.selectByMap(map);
|
| | | loadDeviceState(list);
|
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据组织id和设备名称 分页查询设备
|
| | | * @param orgId
|
| | | * @param deviceName
|
| | | * @param pageSize
|
| | | * @param pageNo
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public PageResult query(Integer orgId, String deviceName, Integer pageSize, Integer pageNo) {
|
| | | if(!ObjectUtils.isEmpty(pageSize)&&!ObjectUtils.isEmpty(pageNo)){
|
| | | PageHelper.startPage(pageNo,pageSize);
|
| | | }
|
| | | List list = deviceMapper.selectByOrgIdAndDevName(orgId,deviceName);
|
| | | List<Device> list = deviceMapper.selectByOrgIdAndDevName(orgId,deviceName);
|
| | | //从redis里取状态
|
| | | loadDeviceState(list);
|
| | | if(list instanceof Page){
|
| | | return new PageResult(((Page) list).getTotal(),list);
|
| | | }
|
| | | return new PageResult(null,list);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据组织id和监控点id 分页查询设备
|
| | | * @param orgId
|
| | | * @param mpId
|
| | | * @param pageSize
|
| | | * @param pageNo
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public PageResult query(Integer orgId, Integer mpId, Integer pageSize, Integer pageNo) {
|
| | | if(!ObjectUtils.isEmpty(pageSize)&&!ObjectUtils.isEmpty(pageNo)){
|
| | | PageHelper.startPage(pageNo,pageSize);
|
| | | }
|
| | | List<Device> list = deviceMapper.selectByOrgIdAndMpId(orgId,mpId);
|
| | | //从redis里取状态
|
| | | loadDeviceState(list);
|
| | | if(list instanceof Page){
|
| | | return new PageResult(((Page) list).getTotal(),list);
|
| | | }
|
| | | return new PageResult(null,list);
|
| | | }
|
| | | private void loadDeviceState(List<Device> list){
|
| | | //从redis里取状态
|
| | | list.stream().map( device -> {
|
| | | String state = getSateFromRedis(device.getMonitorPointId(),device.getMac());
|
| | | device.setState(state);
|
| | | return device;
|
| | | }).count();
|
| | | }
|
| | | private String getSateFromRedis(Integer mpId,String mac){
|
| | |
|
| | | Map<String,String> states = getStateMapFromRedis(mpId,mac);
|
| | | String state = null;
|
| | | if(states != null){
|
| | | state = states.get("state");
|
| | | }
|
| | | state = state == null ?Constants.DEVICE_STATE_OFFLINE:state;
|
| | | return state;
|
| | | }
|
| | | public Map<String,String> getStateMapFromRedis(Integer mpId,String mac){
|
| | | StringBuilder key = new StringBuilder();
|
| | | //拼凑key
|
| | | key.append("state_").append(mpId).append("_").append(mac);
|
| | | return redisUtils.get(key.toString(),new TypeReference<Map<String,String>>(){});
|
| | | }
|
| | | private Device getDeviceWithOrgIdsByMac(String mac) {
|
| | | String key = "device_"+mac;
|
| | | Device device = redisUtils.get(key,Device.class);
|
| | | if(device==null) {
|
| | | device = deviceMapper.selectWithOrgIdsByMac(mac);
|
| | | if(device!=null){
|
| | | redisUtils.set(key,device);
|
| | | }
|
| | | }
|
| | | return device;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | return deviceMapper.select(device);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 返回map{mac:,state:}
|
| | | * @param macList
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public List<Map<String,String>> queryDevicesState(List<String> macList,Boolean withData) {
|
| | | List<Map<String,String>> list = macList.stream().map(mac->{
|
| | | Device device = getDeviceWithOrgIdsByMac(mac);
|
| | | Map<String,String> resultMap = new HashMap<>();
|
| | | Map<String,String> stateMap = getStateMapFromRedis(device.getMonitorPointId(),mac);
|
| | | if(!MapUtils.isEmpty(stateMap)){
|
| | | resultMap.putAll(stateMap);
|
| | | }else{
|
| | | resultMap.put("state",Constants.DEVICE_STATE_OFFLINE);
|
| | | }
|
| | | if(BooleanUtils.isTrue(withData)){
|
| | | String dataKey = "data_"+mac;
|
| | | Map<String,String> dataMap = redisUtils.get(dataKey,new TypeReference<Map<String,String>>(){});
|
| | | if(!MapUtils.isEmpty(dataMap)){
|
| | | resultMap.putAll(dataMap);
|
| | | }
|
| | | }else{
|
| | | resultMap.put("mac",mac);
|
| | | }
|
| | | return resultMap;
|
| | | }).collect(Collectors.toList());
|
| | | return list;
|
| | | }
|
| | | }
|
| | |
| | | package com.moral.service.impl;
|
| | |
|
| | | import java.util.Arrays;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | public List<MonitorPoint> queryWithStateByMap(Map<String, Object> params){
|
| | | List<MonitorPoint> monitorPointList = monitorPointMapper.selectByMap(params);
|
| | | for(MonitorPoint monitorPoint:monitorPointList){
|
| | | loadStateFromRedis(monitorPoint);
|
| | | Integer state = getStateFromRedis(monitorPoint.getId());
|
| | | monitorPoint.setState(state);
|
| | | }
|
| | | return monitorPointList;
|
| | | }
|
| | | private void loadStateFromRedis(MonitorPoint monitorPoint){
|
| | | private Integer getStateFromRedis(Integer monitorPointId){
|
| | | StringBuilder key = new StringBuilder();
|
| | | key.append("*_").append(monitorPoint.getId()).append("_*");
|
| | | key.append("state_").append(monitorPointId).append("_*");
|
| | | List<Map> stateList = redisUtils.getList(key.toString(),Map.class);
|
| | | int state = -1;
|
| | | if(stateList!=null){
|
| | |
| | | }
|
| | | }
|
| | | state = state==-1?4:state;
|
| | | monitorPoint.setState(state);
|
| | | return state;
|
| | | }
|
| | | @Override
|
| | | public PageBean queryByPageBean(PageBean pageBean) {
|
| | |
| | | List<MonitorPoint> monitorPoints = monitorPointMapper.selectByExample(example);
|
| | | return monitorPoints;
|
| | | }
|
| | |
|
| | | /**
|
| | | *
|
| | | * @param idList
|
| | | * @return {id:,state:}
|
| | | */
|
| | | @Override
|
| | | public List<Map<String, String>> queryMonitroPointsState(List<Integer> idList) {
|
| | | List<Map<String, String>> list = idList.stream().map( id -> {
|
| | | Integer state = getStateFromRedis(id);
|
| | | Map<String,String> stateMap = new HashMap<>();
|
| | | stateMap.put("id",id.toString());
|
| | | stateMap.put("state",state.toString());
|
| | | return stateMap;
|
| | | }).collect(Collectors.toList());
|
| | | return list;
|
| | | }
|
| | | }
|
| | |
| | | </if> |
| | | GROUP BY d.state |
| | | </select> |
| | | <select id="selectByOrgIdAndDevName" resultMap="BaseResultMap"> |
| | | SELECT * from device dev |
| | | left join monitor_point mpt on dev.monitor_point_id = mpt.id |
| | | where |
| | | mpt.organization_id = #{orgId} |
| | | <if test="devName!=null and ''!=devName"> |
| | | and dev.name like #{devName} |
| | | </if> |
| | | </select> |
| | | <select id="getSensorsByDevice" resultType="java.util.Map"> |
| | | SELECT |
| | | s.`key`, |
| | |
| | | monitor_point_id = #{monitorPointId} |
| | | AND device_version_id = #{deviceVersionId} |
| | | </select> |
| | | <select id="selectByOrgIdAndDevName" resultMap="BaseResultMap"> |
| | | SELECT * from device dev |
| | | left join monitor_point mpt on dev.monitor_point_id = mpt.id |
| | | <where> |
| | | <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)"> |
| | | mpt.organization_id = #{orgId} |
| | | </if> |
| | | <if test="devName!=null and ''!=devName"> |
| | | and dev.name like CONCAT('%',#{devName},'%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | <select id="selectByOrgIdAndMpId" resultMap="BaseResultMap"> |
| | | SELECT * from device dev |
| | | left join monitor_point mpt on dev.monitor_point_id = mpt.id |
| | | <where> |
| | | <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)"> |
| | | mpt.organization_id = #{orgId} |
| | | </if> |
| | | and dev.monitor_point_id = #{mpId} |
| | | </where> |
| | | </select> |
| | | <select id="selectByMap" parameterType="java.util.Map" resultMap="BaseResultMap"> |
| | | SELECT dev.* from device dev |
| | | left join monitor_point mpt on dev.monitor_point_id = mpt.id |
| | | <where> |
| | | <if test="@com.moral.common.bean.Constants@isNotSpecialOrgId(orgId)"> |
| | | mpt.organization_id = #{orgId,jdbcType=VARCHAR} |
| | | </if> |
| | | <![CDATA[ |
| | | AND dev.longitude < #{mapBounds.Ge,jdbcType=NUMERIC} |
| | | AND dev.longitude > #{mapBounds.Le,jdbcType=NUMERIC} |
| | | AND dev.latitude < #{mapBounds.Fe,jdbcType=NUMERIC} |
| | | AND dev.latitude > #{mapBounds.Ke,jdbcType=NUMERIC} |
| | | ]]> |
| | | </where> |
| | | </select> |
| | | <resultMap id="BaseResultWithOrgIdsMap" type="com.moral.entity.Device" extends="BaseResultMap"> |
| | | <collection property="organizationIds" column="id" select="selectOrganizationIds"></collection> |
| | | </resultMap> |
| | | <!-- resultMap引用 --> |
| | | <select id="selectOrganizationIds" resultType="INTEGER"> |
| | | call proc_organization_id_select(#{id,jdbcType=INTEGER}); |
| | | </select> |
| | | <select id="selectWithOrgIdsByMac" parameterType="java.lang.String" resultMap="BaseResultWithOrgIdsMap"> |
| | | select |
| | | id,device_version_id,mac,monitor_point_id |
| | | from device |
| | | where mac = #{mac,jdbcType=VARCHAR} |
| | | </select> |
| | | </mapper> |
| | |
| | | orgId=-1
|
| | | password=123456
|
| | | noFilters=/screen/**,/**/*.jsp,/**/*.js,/**/*.png,/**/*.ico |
| | | specialOrgIds=-1 |
| | |
| | | async: true, |
| | | success: function(res) { |
| | | if(res!=null&&res.total!=null) { |
| | | debugger; |
| | | var rows = res.data; |
| | | if(rows==null||rows.length == 0) { |
| | | $(option['id']).html("没有查询到任何数据!"); |
| | |
| | | //监控点对象 包装MoralMark对象 |
| | | moralMap.Equipment = function(option) { |
| | | var icon = {}; |
| | | icon["stateIcons"] = ["img/ico_coo00.png", "img/ico_coo01.png", "img/ico_coo02.png", "img/ico_coo03.png", "img/ico_coo04.png"]; |
| | | icon["stateIcons"] = ["/img/ico_coo00.png", "/img/ico_coo01.png", "/img/ico_coo02.png", "/img/ico_coo03.png", "/img/ico_coo04.png"]; |
| | | icon["width"] = 50; |
| | | icon["height"] = 60; |
| | | option["icon"] = icon; |
| | |
| | | }, |
| | | _getSensorState: function(data, key) { |
| | | var grade="grade"; |
| | | var levels; |
| | | if(data["level3"]!=null){ |
| | | if($.inArray(key,data["level3"])!=-1){ |
| | | levels = data["level3"] instanceof Array ? data["level3"]:JSON.parse(data["level3"]); |
| | | if($.inArray(key,levels)!=-1){ |
| | | return grade+"03"; |
| | | } |
| | | } |
| | | if(data["level2"] !=null){ |
| | | if($.inArray(key,data["level2"])!=-1){ |
| | | levels = data["level2"] instanceof Array ? data["level2"]:JSON.parse(data["level2"]); |
| | | if($.inArray(key,levels)!=-1){ |
| | | return grade+"02"; |
| | | } |
| | | } |
| | | if(data["level1"] !=null){ |
| | | if($.inArray(key,data["level1"])!=-1){ |
| | | levels = data["level1"] instanceof Array ? data["level1"]:JSON.parse(data["level1"]); |
| | | if($.inArray(key,levels)!=-1){ |
| | | return grade+"01"; |
| | | } |
| | | } |
| | |
| | | function showEqus(obj) { |
| | | var params = moralMap['params']; |
| | | var mpoint = obj.currentTarget.getOption(); |
| | | var url = 'get-devices?mpId=' + mpoint['id'] + "&orgId=" + params['orgId']; |
| | | var url = 'get-devices-by-mid-oid?mpId=' + mpoint['id'] + "&orgId=" + params['orgId']; |
| | | listView.load(url); |
| | | moralMap.showPopupbox("#popup_box"); |
| | | } |
| | |
| | | } |
| | | function addOverEquipments(jsonData){ |
| | | if(moralMap.layer()=="equipments"){ |
| | | var objs = jsonData["rows"]==null?[]:jsonData["rows"]; |
| | | var objs = jsonData = null?[]:jsonData; |
| | | for(var i in objs) { |
| | | var obj = objs[i]; |
| | | if(moralMap.getEquipment(obj["mac"])==null){ |
| | |
| | | }); |
| | | //地图加载完成后 加载监控点,速度慢 |
| | | moralMap.addEventListener("tilesloaded", function(type, target) { |
| | | // var endZoom = this.getZoom(); |
| | | // if(endZoom>=moralMap.getZooMConfine()){//超过界限加载设备 |
| | | // loadOverlays("getequipments",addOverEquipments); |
| | | // }else{ |
| | | // loadOverlays("get-monitorpoints",addOverMpoints); |
| | | // } |
| | | // moralMap.closePopupbox("#popup_box"); |
| | | }); |
| | | //地图放大缩小事件时,关闭弹窗 |
| | | moralMap.addEventListener('zoomstart', function(type) {}); |
| | |
| | | moralMap.addEventListener('zoomend', function(type) { |
| | | var endZoom = this.getZoom(); |
| | | if(endZoom>=moralMap.getZooMConfine()){//超过界限加载设备 |
| | | loadOverlays("getequipments",addOverEquipments); |
| | | loadOverlays("get-devices",addOverEquipments); |
| | | }else{ |
| | | loadOverlays("get-monitorpoints",addOverMpoints); |
| | | } |
| | |
| | | moralMap.addEventListener('moveend', function(type) { |
| | | var endZoom = this.getZoom(); |
| | | if(endZoom>=moralMap.getZooMConfine()){//超过界限加载设备 |
| | | loadOverlays("getequipments",addOverEquipments); |
| | | loadOverlays("get-devices",addOverEquipments); |
| | | }else{ |
| | | loadOverlays("get-monitorpoints",addOverMpoints); |
| | | } |
| | |
| | | parma["orgId"] = moralMap['params']["orgId"]; |
| | | $.ajax({ |
| | | type: "post", |
| | | url: "getstatesformap", |
| | | url: "get-real-state-data", |
| | | data:JSON.stringify(parma), |
| | | dataType:"json", |
| | | contentType:"application/json;charset=utf-8", |