Commit b406d747 authored by jichao's avatar jichao

系统检测--暖通空调--单个设备弹出页面,查找参数报错的bug

parent 6d026bd7
...@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
* Created by JiChao on 2018/5/3. * Created by JiChao on 2018/5/3.
...@@ -42,4 +43,13 @@ public class ReportController { ...@@ -42,4 +43,13 @@ public class ReportController {
public void downloadTemperature(HttpServletResponse response, @RequestParam String proId, @RequestParam String start, @RequestParam String end) { public void downloadTemperature(HttpServletResponse response, @RequestParam String proId, @RequestParam String start, @RequestParam String end) {
reportServiceImpl.downloadTemperature(response, proId, start, end); reportServiceImpl.downloadTemperature(response, proId, start, end);
} }
// @ApiOperation(value="得到存在的文件名称", notes="得到存在的文件名称")
// @RequestMapping("/getExistFiles")
// public Result getExistFiles(@RequestParam String proId, @RequestParam Integer year, @RequestParam Integer month) {
// return Result.builder(new PersistModel(1),
// MessageConstant.MESSAGE_ALERT_SUCCESS,
// MessageConstant.MESSAGE_ALERT_ERROR,
// reportServiceImpl.getExistFiles(proId, year, month));
// }
} }
package org.rcisoft.business.device.report.service; package org.rcisoft.business.device.report.service;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
* Created by JiChao on 2018/5/3. * Created by JiChao on 2018/5/3.
...@@ -26,4 +27,13 @@ public interface ReportService { ...@@ -26,4 +27,13 @@ public interface ReportService {
*/ */
void downloadTemperature(HttpServletResponse response, String proId, String start, String end); void downloadTemperature(HttpServletResponse response, String proId, String start, String end);
/**
* 得到存在的文件名称
* @param proId
* @param year
* @param month
* @return
*/
// List<Integer> getExistFiles(String proId, Integer year, Integer month);
} }
...@@ -66,7 +66,11 @@ public class ReportServiceImpl implements ReportService { ...@@ -66,7 +66,11 @@ public class ReportServiceImpl implements ReportService {
File file = new File(fileName); File file = new File(fileName);
if (!file.getParentFile().exists()) file.getParentFile().mkdirs(); if (!file.getParentFile().exists()) file.getParentFile().mkdirs();
try(OutputStream outputStream = response.getOutputStream()) { try(OutputStream outputStream = response.getOutputStream()) {
file = this.createExcel(proId, year, month, day, file); // 如果已经存在文件,直接下载
if (!file.exists()) {
// 不存在直接生成一个文件,生成文件太耗时间
file = this.createExcel(proId, year, month, day, file);
}
//转成字节 //转成字节
bytes = FileUtils.readFileToByteArray(file); bytes = FileUtils.readFileToByteArray(file);
//设置下载头 //设置下载头
...@@ -89,6 +93,22 @@ public class ReportServiceImpl implements ReportService { ...@@ -89,6 +93,22 @@ public class ReportServiceImpl implements ReportService {
} }
} }
// @Override
// public List<Integer> getExistFiles(String proId, Integer year, Integer month) {
// // 返回值
// List<Integer> resultList = new ArrayList<>();
// // 文件夹名称
// String dirName = filePath + proId + File.separator + year + File.separator + month;
// File file = new File(dirName);
// if (file.exists()) {
// String[] names = file.list();
// for (String name : names) {
// resultList.add(Integer.parseInt(StringUtils.split(name, ".")[0]));
// }
// }
// return resultList;
// }
/** /**
* 查找,组合数据,生成文件 * 查找,组合数据,生成文件
* @param proId * @param proId
...@@ -272,4 +292,5 @@ public class ReportServiceImpl implements ReportService { ...@@ -272,4 +292,5 @@ public class ReportServiceImpl implements ReportService {
workbook.close(); workbook.close();
} }
} }
} }
...@@ -32,7 +32,11 @@ public interface DeviceParamRepository { ...@@ -32,7 +32,11 @@ public interface DeviceParamRepository {
@ResultType(String.class) @ResultType(String.class)
String selectSensorCode(@Param("proId") String proId); String selectSensorCode(@Param("proId") String proId);
@Select("<script>select d.DEV_NM devNm,r.DEV_NUM devNum,r.OTHER_PARAM param,r.PRO_ID proId from bus_device_meter m,bus_param_refer r,bus_device d where m.MET_NUM=r.DEV_NUM and m.DEV_NUM=d.DEV_NUM and m.PRO_ID=#{proId} order by d.DEV_NUM desc</script>") @Select("<script>SELECT d.DEV_NM devNm,r.DEV_NUM devNum,r.OTHER_PARAM param,d.PRO_ID proId " +
"FROM bus_device d " +
"left join bus_device_meter m on m.DEV_NUM = d.DEV_NUM " +
"left join bus_param_refer r on m.MET_NUM = r.DEV_NUM " +
"WHERE d.PRO_ID = #{proId} order by d.DEV_NUM desc</script>")
@ResultType(ParamStatus.class) @ResultType(ParamStatus.class)
List<ParamStatus> selectDeviceAll(@Param("proId") String proId); List<ParamStatus> selectDeviceAll(@Param("proId") String proId);
......
...@@ -153,11 +153,15 @@ public class SystemServiceImpl implements SystemService { ...@@ -153,11 +153,15 @@ public class SystemServiceImpl implements SystemService {
String devCode = ""; String devCode = "";
// 电量的键 // 电量的键
String devParam = ""; String devParam = "";
// proId
String proId = "";
// 根据devNum查询 // 根据devNum查询
Map<String, String> deviceMap = deviceParamRepository.selectPower(devNum); Map<String, String> deviceMap = deviceParamRepository.selectPower(devNum);
devCode = deviceMap.get("devCode"); if (deviceMap != null) {
devParam = deviceMap.get("devParam"); devCode = deviceMap.get("devCode");
String proId = deviceMap.get("proId"); devParam = deviceMap.get("devParam");
proId = deviceMap.get("proId");
}
// 如果不为空,需要将devCode截取一下 // 如果不为空,需要将devCode截取一下
if (StringUtils.isNotEmpty(devCode) && StringUtils.isNotEmpty(devParam) && StringUtils.isNotEmpty(proId)) if (StringUtils.isNotEmpty(devCode) && StringUtils.isNotEmpty(devParam) && StringUtils.isNotEmpty(proId))
devCode = devCode.split(proId + "_")[1]; devCode = devCode.split(proId + "_")[1];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment