|
|
@@ -0,0 +1,107 @@
|
|
|
+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.IotDeviceDiagnoseMission;
|
|
|
+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.DiagnoseMissionPageDto;
|
|
|
+import com.xunmei.iot.mapper.DiagnoseMissionChMapper;
|
|
|
+import com.xunmei.iot.service.DiagnoseMissionService;
|
|
|
+import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
|
|
|
+import com.xunmei.iot.vo.sensor.DiagnoseMissionPageVo;
|
|
|
+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 DiagnoseMissionServiceImpl implements DiagnoseMissionService {
|
|
|
+ @Resource
|
|
|
+ private RemoteOrgService orgService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DiagnoseMissionChMapper diagnoseMissionChMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<DiagnoseMissionPageVo> selectDiagnoseMissionPage(DiagnoseMissionPageDto 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<IotDeviceDiagnoseMission> missions = diagnoseMissionChMapper.selectAllDiagnoseMission();
|
|
|
+
|
|
|
+ Page<DiagnoseMissionPageVo> page = diagnoseMissionChMapper.selectPageData(request.getPageRequest(), request);
|
|
|
+ final List<SysOrgVO> cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
|
|
|
+
|
|
|
+ for (DiagnoseMissionPageVo bean : page.getRecords()) {
|
|
|
+ String missionId = bean.getMissionId();
|
|
|
+ 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(missionId)){
|
|
|
+ boolean isMatch = false;
|
|
|
+ for(IotDeviceDiagnoseMission mission:missions){
|
|
|
+ if(mission.getMissionId().equals(missionId)){
|
|
|
+ buffer.append(mission.getName()).append("【")
|
|
|
+ .append(mission.getBeginTime()).append("--").append(mission.getEndTime())
|
|
|
+ .append("】");
|
|
|
+ isMatch = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(isMatch){
|
|
|
+ bean.setMissionName(buffer.toString());
|
|
|
+ }else{
|
|
|
+ bean.setMissionName("--");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ bean.setMissionName("--");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return TableDataInfo.build(page);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<AlarmTypeSelectedVO> missionTypeList() {
|
|
|
+ List<AlarmTypeSelectedVO> list = Lists.newArrayList();
|
|
|
+ AlarmTypeSelectedVO bean;
|
|
|
+ List<IotDeviceDiagnoseMission> missions = diagnoseMissionChMapper.selectAllDiagnoseMission();
|
|
|
+
|
|
|
+ StringBuffer buffer;
|
|
|
+ for (IotDeviceDiagnoseMission mission : missions) {
|
|
|
+ bean = new AlarmTypeSelectedVO();
|
|
|
+
|
|
|
+ buffer = new StringBuffer();
|
|
|
+ buffer.append(mission.getName()).append("【")
|
|
|
+ .append(mission.getBeginTime()).append("--").append(mission.getEndTime())
|
|
|
+ .append("】");
|
|
|
+
|
|
|
+ bean.setValue(mission.getMissionId());
|
|
|
+ bean.setLabel(buffer.toString());
|
|
|
+ list.add(bean);
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+}
|