|
|
@@ -0,0 +1,109 @@
|
|
|
+package com.xunmei.iot.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.xunmei.common.core.constant.CacheConstants;
|
|
|
+import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
+import com.xunmei.common.core.domain.iot.domain.IotDeviceDiagnoseThreshold;
|
|
|
+import com.xunmei.common.core.enums.OrgTypeEnum;
|
|
|
+import com.xunmei.common.core.utils.StringUtils;
|
|
|
+import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
+import com.xunmei.common.redis.utils.RedisUtils;
|
|
|
+import com.xunmei.iot.dto.cameraDiagnose.DiagnoseThresholdPageDto;
|
|
|
+import com.xunmei.iot.mapper.DiagnoseThresholdChMapper;
|
|
|
+import com.xunmei.iot.service.DiagnoseThresholdService;
|
|
|
+import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
|
|
|
+import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
|
|
|
+import com.xunmei.system.api.RemoteOrgService;
|
|
|
+import com.xunmei.system.api.domain.SysOrg;
|
|
|
+import com.xunmei.system.api.vo.SysOrgVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
+ @Resource
|
|
|
+ private RemoteOrgService orgService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DiagnoseThresholdChMapper diagnoseThresholdChMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<DiagnoseThresholdPageVo> selectSensorDataPage(DiagnoseThresholdPageDto request) {
|
|
|
+ final SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
|
|
|
+ if (ObjectUtil.equal(Boolean.TRUE, request.getCheckSub())) {
|
|
|
+ request.setOrgPath(sysOrg.getPath());
|
|
|
+ request.setOrgId(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<IotDeviceDiagnoseThreshold> thresholds = diagnoseThresholdChMapper.selectAllDiagnoseThreshold();
|
|
|
+
|
|
|
+ Page<DiagnoseThresholdPageVo> page = diagnoseThresholdChMapper.selectPageData(request.getPageRequest(), request);
|
|
|
+ final List<SysOrgVO> cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
|
|
|
+
|
|
|
+ for (DiagnoseThresholdPageVo bean : page.getRecords()) {
|
|
|
+ String thresholdCodes = bean.getThresholdCodes();
|
|
|
+ final List<Long> collect = Arrays.stream(bean.getOrgPath().split("-")).map(Long::parseLong).collect(Collectors.toList());
|
|
|
+ //地区名称
|
|
|
+ cacheList.stream().filter(org -> collect.contains(org.getId()) && OrgTypeEnum.DIQU_HANG_SHE.getCode().equals(org.getType()))
|
|
|
+ .findFirst().ifPresent(org -> bean.setFirstOrgName(org.getShortName()));
|
|
|
+ //行社名称
|
|
|
+ cacheList.stream().filter(org -> collect.contains(org.getId()) && OrgTypeEnum.HANG_SHE.getCode().equals(org.getType()))
|
|
|
+ .findFirst().ifPresent(org -> bean.setSecondOrgName(org.getShortName()));
|
|
|
+
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ if(StringUtils.isNotEmpty(thresholdCodes)){
|
|
|
+ String[] codes = thresholdCodes.split(",");
|
|
|
+ boolean isMatch = false;
|
|
|
+ for(String code:codes){
|
|
|
+ for(IotDeviceDiagnoseThreshold threshold:thresholds){
|
|
|
+ if(threshold.getThresholdCode().equals(code)){
|
|
|
+ buffer.append(threshold.getThresholdName()).append("【")
|
|
|
+ .append(threshold.getValiditybegintime()).append("--").append(threshold.getValidityendtime())
|
|
|
+ .append("】").append(",");
|
|
|
+ isMatch = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(isMatch){
|
|
|
+ bean.setThresholdName(buffer.substring(0,buffer.length()-1));
|
|
|
+ }else{
|
|
|
+ bean.setThresholdName("--");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ bean.setThresholdName("--");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return TableDataInfo.build(page);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<AlarmTypeSelectedVO> thresholdTypeList() {
|
|
|
+ List<AlarmTypeSelectedVO> list = Lists.newArrayList();
|
|
|
+ AlarmTypeSelectedVO bean;
|
|
|
+ List<IotDeviceDiagnoseThreshold> thresholds = diagnoseThresholdChMapper.selectAllDiagnoseThreshold();
|
|
|
+
|
|
|
+ StringBuffer buffer;
|
|
|
+ for (IotDeviceDiagnoseThreshold threshold : thresholds) {
|
|
|
+ bean = new AlarmTypeSelectedVO();
|
|
|
+
|
|
|
+ buffer = new StringBuffer();
|
|
|
+ buffer.append(threshold.getThresholdName()).append("【")
|
|
|
+ .append(threshold.getValiditybegintime()).append("--").append(threshold.getValidityendtime())
|
|
|
+ .append("】");
|
|
|
+
|
|
|
+ bean.setValue(threshold.getThresholdCode());
|
|
|
+ bean.setLabel(buffer.toString());
|
|
|
+ list.add(bean);
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+}
|