|
@@ -1,6 +1,8 @@
|
|
|
package com.xunmei.iot.service.impl;
|
|
package com.xunmei.iot.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
|
|
+import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -22,6 +24,7 @@ import com.xunmei.iot.service.DiagnoseThresholdService;
|
|
|
import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
|
|
import com.xunmei.iot.vo.alarmData.AlarmTypeSelectedVO;
|
|
|
import com.xunmei.iot.vo.sensor.DiagnoseThresholdAddVo;
|
|
import com.xunmei.iot.vo.sensor.DiagnoseThresholdAddVo;
|
|
|
import com.xunmei.iot.vo.sensor.DiagnoseThresholdBindVo;
|
|
import com.xunmei.iot.vo.sensor.DiagnoseThresholdBindVo;
|
|
|
|
|
+import com.xunmei.iot.vo.sensor.DiagnoseThresholdExportVo;
|
|
|
import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
|
|
import com.xunmei.iot.vo.sensor.DiagnoseThresholdPageVo;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
@@ -32,6 +35,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.DigestUtils;
|
|
import org.springframework.util.DigestUtils;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -290,6 +295,76 @@ public class DiagnoseThresholdServiceImpl implements DiagnoseThresholdService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ public void exportCamera(DiagnoseThresholdPageDto request, HttpServletResponse response){
|
|
|
|
|
+ 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();
|
|
|
|
|
+
|
|
|
|
|
+ List<DiagnoseThresholdPageVo> page = diagnoseThresholdChMapper.selectExcelData(request);
|
|
|
|
|
+ final List<SysOrgVO> cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
|
|
|
|
|
+
|
|
|
|
|
+ List<DiagnoseThresholdExportVo> exportVos = Lists.newArrayList();
|
|
|
|
|
+ DiagnoseThresholdExportVo exportVo;
|
|
|
|
|
+
|
|
|
|
|
+ for (DiagnoseThresholdPageVo bean: page) {
|
|
|
|
|
+ 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.getBeginTime()).append("--").append(threshold.getEndTime())
|
|
|
|
|
+ .append("】").append(",");
|
|
|
|
|
+ isMatch = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(isMatch){
|
|
|
|
|
+ bean.setThresholdName(buffer.substring(0,buffer.length()-1));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ bean.setThresholdName("--");
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ bean.setThresholdName("--");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ exportVo = new DiagnoseThresholdExportVo();
|
|
|
|
|
+ BeanUtils.copyProperties(bean,exportVo);
|
|
|
|
|
+
|
|
|
|
|
+ exportVos.add(exportVo);
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 设置响应头
|
|
|
|
|
+ response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("阈值关联摄像机", "utf-8"));
|
|
|
|
|
+ response.setContentType("application/octet-stream;charset=UTF-8");
|
|
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
|
|
+ // 数据导出
|
|
|
|
|
+ EasyExcel.write(response.getOutputStream(), DiagnoseThresholdExportVo.class)
|
|
|
|
|
+ .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).sheet("sheet1").doWrite(exportVos);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ // 重置response
|
|
|
|
|
+ response.reset();
|
|
|
|
|
+ response.setContentType("application/json");
|
|
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
public List<AlarmTypeSelectedVO> thresholdTypeList() {
|
|
public List<AlarmTypeSelectedVO> thresholdTypeList() {
|
|
|
List<AlarmTypeSelectedVO> list = Lists.newArrayList();
|
|
List<AlarmTypeSelectedVO> list = Lists.newArrayList();
|
|
|
AlarmTypeSelectedVO bean;
|
|
AlarmTypeSelectedVO bean;
|