| | |
| | | import com.moral.entity.alarm.AlarmConfig;
|
| | | import com.moral.entity.alarm.AlarmConfigValue;
|
| | | import com.moral.entity.charts.DataSortCondition;
|
| | | import com.moral.entity.layout.RealTimeDeviceLayout;
|
| | | import com.moral.service.*;
|
| | | import org.apache.commons.collections.CollectionUtils;
|
| | | import org.apache.commons.net.ftp.FTPClient;
|
| | | import org.apache.log4j.Logger;
|
| | |
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.common.xml.Version;
|
| | | import com.moral.entity.alarm.AlarmSensorLevel;
|
| | | import com.moral.service.AccountService;
|
| | | import com.moral.service.AlarmConfigService;
|
| | | import com.moral.service.AlarmDailyService;
|
| | | import com.moral.service.AreaService;
|
| | | import com.moral.service.DeviceService;
|
| | | import com.moral.service.HistoryMinutelyService;
|
| | | import com.moral.service.HistoryService;
|
| | | import com.moral.service.MachineActivateService;
|
| | | import com.moral.service.MonitorPointService;
|
| | | import com.moral.service.SensorService;
|
| | |
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiImplicitParam;
|
| | |
| | | SensorService sensorService;
|
| | | @Resource
|
| | | MonitorPointService monitorPointService;
|
| | | @Resource
|
| | | DeviceVersionService deviceVersionService;
|
| | |
|
| | | /** The screen service. */
|
| | | @Resource
|
| | |
| | |
|
| | | @Resource
|
| | | private AlarmDailyService alarmDailyService;
|
| | | @Resource
|
| | | private OrganizationLayoutService orgLayoutService;
|
| | | @Resource
|
| | | private DeviceVersionService dviceVersionService;
|
| | | /**
|
| | | * Screen login. 大屏登录
|
| | | *
|
| | |
| | | * @return the alarm levels
|
| | | */
|
| | | @GetMapping("alarm-levels")
|
| | | public Object getAlarmLevels(HttpServletRequest request, Optional<Integer> orgId, Optional<Integer> mpId) {
|
| | | public Object getAlarmLevels(HttpServletRequest request, Optional<Integer> orgId, Optional<Integer> mpId,Optional<String> mac) {
|
| | | List<Map<String,Object>> sensorAlarmList = null;
|
| | | try {
|
| | | AlarmConfig alarmConfig = null;
|
| | |
| | | alarmConfig = alarmConfigService.queryValueByOrganizationId(orgId.get()).get();
|
| | | }else if(mpId.isPresent()){
|
| | | alarmConfig = alarmConfigService.queryByMonitorPointId(mpId.get()).get();
|
| | | } else if(mac.isPresent() ){
|
| | | alarmConfig = alarmConfigService.queryByDeviceMac(mac.get()).get();
|
| | | }
|
| | | //返回值处理
|
| | | if(alarmConfig.getValue()!=null&&alarmConfig.getValue().getAlarmLevels()!=null){
|
| | |
| | | })
|
| | | @GetMapping("rtm-layout")
|
| | | public ResultBean realTimeMonitorLayout(String primaryKey,String type){
|
| | | InputStreamReader reader = null;
|
| | | Map<String,Object> map = null;
|
| | | try {
|
| | | reader = new InputStreamReader(resource.getInputStream());
|
| | | map = new JSONReader(reader).readObject(new TypeReference<Map<String,Object>>() {});
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | RealTimeDeviceLayout rtdLayout = null;
|
| | | if(type != null && type.equals("device")) {
|
| | | Device device = deviceService.getDeviceByMac(primaryKey,false);
|
| | | if(device!= null
|
| | | && device.getOrganizationIds()!=null
|
| | | && device.getOrganizationIds().size() >0
|
| | | && device.getDeviceVersionId()!=null) {
|
| | | Integer orgId = device.getOrganizationIds().get(0);
|
| | | DeviceVersion deviceVersion = deviceVersionService.queryVersionById(device.getDeviceVersionId());
|
| | | rtdLayout = orgLayoutService.queryRtdLayoutWithUnit(orgId,deviceVersion.getVersion());
|
| | | }else {
|
| | | return ResultBean.fail();
|
| | | }
|
| | |
|
| | | } else {
|
| | | MonitorPoint monitorPoint = monitorPointService.queryMonitorPointById(Integer.parseInt(primaryKey));
|
| | | List<DeviceVersion> versionList = deviceVersionService.queryByOrgId(monitorPoint.getOrganizationId());
|
| | | if(versionList.size() > 0) {
|
| | | List<Integer> versionNolist = versionList.stream().map(item -> {
|
| | | return item.getVersion();
|
| | | }).collect(Collectors.toList());
|
| | | rtdLayout = orgLayoutService.queryRtdLayoutWithUnit(monitorPoint.getOrganizationId(),versionNolist);
|
| | | if(rtdLayout == null) {
|
| | | return ResultBean.fail();
|
| | | }
|
| | | }
|
| | | }
|
| | | return new ResultBean(map);
|
| | | if(rtdLayout.getDefaultMonitorItems().size() == 0 ) {
|
| | | rtdLayout.getDefaultMonitorItems().addAll(rtdLayout.getCoreMonitorItems());
|
| | | }
|
| | | return new ResultBean(rtdLayout);
|
| | | }
|
| | |
|
| | | }
|