Commit 6edba52f authored by chenying's avatar chenying

2018.1.16

(1)添加ABB报警记录接口
parent 36a8c21c
package com.example.tdl.domain.vo;
public class AlarmTermABBVo {
private String classify;
private Long startTime;
private Long endTime;
private String companyNo;
public String getCompanyNo() {
return companyNo;
}
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
public String getClassify() {
return classify;
}
public void setClassify(String classify) {
this.classify = classify;
}
public Long getStartTime() {
return startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public Long getEndTime() {
return endTime;
}
public void setEndTime(Long endTime) {
this.endTime = endTime;
}
}
package com.example.tdl.domain.vo;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.List;
public class EasyUIResult {
// 定义jackson对象
private static final ObjectMapper MAPPER = new ObjectMapper();
private Integer total;
private List<?> rows;
public EasyUIResult() {
}
public EasyUIResult(Integer total, List<?> rows) {
this.total = total;
this.rows = rows;
}
public EasyUIResult(Long total, List<?> rows) {
this.total = total.intValue();
this.rows = rows;
}
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
public List<?> getRows() {
return rows;
}
public void setRows(List<?> rows) {
this.rows = rows;
}
/**
* Object是集合转化
*
* @param jsonData json数据
* @param clazz 集合中的类型
* @return
*/
public static EasyUIResult formatToList(String jsonData, Class<?> clazz) {
try {
JsonNode jsonNode = MAPPER.readTree(jsonData);
JsonNode data = jsonNode.get("rows");
List<?> list = null;
if (data.isArray() && data.size() > 0) {
list = MAPPER.readValue(data.traverse(),
MAPPER.getTypeFactory().constructCollectionType(List.class, clazz));
}
return new EasyUIResult(jsonNode.get("total").intValue(), list);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
package com.example.tdl.domain.vo;
public class ResultAlarmLogABBVo {
private String transportationNo;
private String cargoNo;
private String TDLSN;
private String description;
private String data;
private Long alarmTime;
private String classify;
public String getTransportationNo() {
return transportationNo;
}
public void setTransportationNo(String transportationNo) {
this.transportationNo = transportationNo;
}
public String getCargoNo() {
return cargoNo;
}
public void setCargoNo(String cargoNo) {
this.cargoNo = cargoNo;
}
public String getTDLSN() {
return TDLSN;
}
public void setTDLSN(String TDLSN) {
this.TDLSN = TDLSN;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public Long getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(Long alarmTime) {
this.alarmTime = alarmTime;
}
public String getClassify() {
return classify;
}
public void setClassify(String classify) {
this.classify = classify;
}
}
package com.example.tdl.domain.vo;
public class ResultAlarmLogCountABBVo {
private String dates;
private Integer tempCountSum;
private Integer humidCountSum;
private Integer shockCountSum;
private Integer leanCountSum;
private Integer countSum;
public String getDates() {
return dates;
}
public void setDates(String dates) {
this.dates = dates;
}
public Integer getTempCountSum() {
return tempCountSum;
}
public void setTempCountSum(Integer tempCountSum) {
this.tempCountSum = tempCountSum;
}
public Integer getHumidCountSum() {
return humidCountSum;
}
public void setHumidCountSum(Integer humidCountSum) {
this.humidCountSum = humidCountSum;
}
public Integer getShockCountSum() {
return shockCountSum;
}
public void setShockCountSum(Integer shockCountSum) {
this.shockCountSum = shockCountSum;
}
public Integer getLeanCountSum() {
return leanCountSum;
}
public void setLeanCountSum(Integer leanCountSum) {
this.leanCountSum = leanCountSum;
}
public Integer getCountSum() {
return countSum;
}
public void setCountSum(Integer countSum) {
this.countSum = countSum;
}
}
package com.example.tdl.domain.vo;
public class ResultAlarmLogCountPieGraphVo {
private Integer tempCountSum;
private Integer humidCountSum;
private Integer shockCountSum;
private Integer leanCountSum;
private Integer countSum;
public Integer getTempCountSum() {
return tempCountSum;
}
public void setTempCountSum(Integer tempCountSum) {
this.tempCountSum = tempCountSum;
}
public Integer getHumidCountSum() {
return humidCountSum;
}
public void setHumidCountSum(Integer humidCountSum) {
this.humidCountSum = humidCountSum;
}
public Integer getShockCountSum() {
return shockCountSum;
}
public void setShockCountSum(Integer shockCountSum) {
this.shockCountSum = shockCountSum;
}
public Integer getLeanCountSum() {
return leanCountSum;
}
public void setLeanCountSum(Integer leanCountSum) {
this.leanCountSum = leanCountSum;
}
public Integer getCountSum() {
return countSum;
}
public void setCountSum(Integer countSum) {
this.countSum = countSum;
}
}
package com.example.tdl.domain.vo;
public class ResultAlarmLogHouseCountPieGraphVo {
private Integer house;
private Integer tempCountSum;
private Integer humidCountSum;
private Integer shockCountSum;
private Integer leanCountSum;
private Integer countSum;
public Integer getHouse() {
return house;
}
public void setHouse(Integer house) {
this.house = house;
}
public Integer getTempCountSum() {
return tempCountSum;
}
public void setTempCountSum(Integer tempCountSum) {
this.tempCountSum = tempCountSum;
}
public Integer getHumidCountSum() {
return humidCountSum;
}
public void setHumidCountSum(Integer humidCountSum) {
this.humidCountSum = humidCountSum;
}
public Integer getShockCountSum() {
return shockCountSum;
}
public void setShockCountSum(Integer shockCountSum) {
this.shockCountSum = shockCountSum;
}
public Integer getLeanCountSum() {
return leanCountSum;
}
public void setLeanCountSum(Integer leanCountSum) {
this.leanCountSum = leanCountSum;
}
public Integer getCountSum() {
return countSum;
}
public void setCountSum(Integer countSum) {
this.countSum = countSum;
}
}
......@@ -19,6 +19,16 @@ public class ResultCircuitForABBVo {
private String gType;
private Long createTime;
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public String getTransportationNo() {
return transportationNo;
}
......
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.*;
import com.example.tdl.entity.AlarmLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface AlarmLogABBMapper {
//获取所有的数据
List<ResultAlarmLogABBVo> getAll(@Param("companyNo") String companyNo,@Param("page") Integer page,@Param("rows") Integer rows);
Integer getAllCount(@Param("companyNo") String companyNo);
List<ResultAlarmLogABBVo> getByTerm(@Param("alarmTermABBVo") AlarmTermABBVo alarmTermABBVo,@Param("page") Integer page,@Param("rows") Integer rows);
Integer getByTermCount(AlarmTermABBVo alarmTermABBVo);
List<ResultAlarmLogABBVo> getByTermForDownload(AlarmTermABBVo alarmTermABBVo);
List<ResultAlarmLogCountABBVo> getYearCountForLineGraph();
List<ResultAlarmLogCountABBVo> getDayCountForLineGraph();
ResultAlarmLogCountPieGraphVo getDaySumForPieGraph();
ResultAlarmLogCountPieGraphVo getYearSumForPieGraph();
List<ResultAlarmLogHouseCountPieGraphVo> getDayHouseSumForPieGraph();
List<ResultAlarmLogHouseCountPieGraphVo> getYearHouseSumForPieGraph();
}
package com.example.tdl.service;
import com.example.tdl.domain.vo.*;
import com.example.tdl.entity.AlarmLog;
import com.example.tdl.mapper.AlarmLogABBMapper;
import com.example.tdl.mapper.AlarmLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class AlarmLogABBService {
@Autowired
private AlarmLogABBMapper alarmLogABBMapper;
public List<ResultAlarmLogABBVo> getAll(String companyNo,Integer page,Integer rows){
return alarmLogABBMapper.getAll(companyNo,page,rows);
}
public Integer getAllCount(String companyNo){
return alarmLogABBMapper.getAllCount(companyNo);
}
public List<ResultAlarmLogABBVo> getByTerm(AlarmTermABBVo alarmTermABBVo,Integer page,Integer rows){
return alarmLogABBMapper.getByTerm(alarmTermABBVo,page,rows);
}
public Integer getByTermCount(AlarmTermABBVo alarmTermABBVo){
return alarmLogABBMapper.getByTermCount(alarmTermABBVo);
}
public List<ResultAlarmLogABBVo> getByTermForDownload(AlarmTermABBVo alarmTermABBVo){
return alarmLogABBMapper.getByTermForDownload(alarmTermABBVo);
}
public List<ResultAlarmLogCountABBVo> getYearCountForLineGraph(){
return alarmLogABBMapper.getYearCountForLineGraph();
}
public List<ResultAlarmLogCountABBVo> getDayCountForLineGraph(){
return alarmLogABBMapper.getDayCountForLineGraph();
}
public ResultAlarmLogCountPieGraphVo getDaySumForPieGraph(){
return alarmLogABBMapper.getDaySumForPieGraph();
}
public ResultAlarmLogCountPieGraphVo getYearSumForPieGraph(){
return alarmLogABBMapper.getYearSumForPieGraph();
}
public List<ResultAlarmLogHouseCountPieGraphVo> getDayHouseSumForPieGraph(){
return alarmLogABBMapper.getDayHouseSumForPieGraph();
}
public List<ResultAlarmLogHouseCountPieGraphVo> getYearHouseSumForPieGraph(){
return alarmLogABBMapper.getYearHouseSumForPieGraph();
}
}
package com.example.tdl.util;
import com.example.tdl.domain.vo.ResultAlarmLogABBVo;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.util.CellRangeAddress;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 导出报警日志EXCEL模板
*/
public class AlarmLogForABBExcelUtil {
private List<ResultAlarmLogABBVo> resultAlarmLogVos=new ArrayList<>();
//构造方法,传入要导出的数据
public AlarmLogForABBExcelUtil(List<ResultAlarmLogABBVo> resultAlarmLogVos) {
this.resultAlarmLogVos = resultAlarmLogVos;
}
/*
* 导出数据
*/
public HSSFWorkbook downloadExcel() throws Exception {
HSSFWorkbook workbook = new HSSFWorkbook(); // 创建工作簿对象
HSSFSheet sheet = workbook.createSheet("报警日志数据表"); // 创建工作表
HSSFCellStyle cellTitleStyle = getCellTitleStyle(workbook);
HSSFCellStyle cellStyle = getCellStyle(workbook);
HSSFCellStyle titleStyle = getTitleStyle(workbook);
/*
* 创建第一行(标题行)
* */
HSSFRow rowOne = sheet.createRow((short)0);
HSSFCell cellOne=null;
//循环创建列
for(int n=0;n<6;n++){
cellOne=rowOne.createCell(n);
cellOne.setCellStyle(titleStyle);
//将标题添加到列中
cellOne.setCellValue(new HSSFRichTextString("报 警 日 志 数 据 表"));
}
//设置行高
rowOne.setHeight((short)(35*20));
//合并单元格(参数1:起始行,参数2:截至行,参数3:起始列,参数4:截至列)
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
/*
* 创建第二行
* */
HSSFRow rowTwo = sheet.createRow((short)1);
HSSFCell cellTwo=null;
cellTwo=rowTwo.createCell(0);
cellTwo.setCellValue("运输编号");
cellTwo.setCellStyle(cellTitleStyle);
cellTwo=rowTwo.createCell(1);
cellTwo.setCellValue("货物编号");
cellTwo.setCellStyle(cellTitleStyle);
cellTwo=rowTwo.createCell(2);
cellTwo.setCellValue("传感器序列号");
cellTwo.setCellStyle(cellTitleStyle);
cellTwo=rowTwo.createCell(3);
cellTwo.setCellValue("描述");
cellTwo.setCellStyle(cellTitleStyle);
cellTwo=rowTwo.createCell(4);
cellTwo.setCellValue("报警数据");
cellTwo.setCellStyle(cellTitleStyle);
cellTwo=rowTwo.createCell(5);
cellTwo.setCellValue("报警时间");
cellTwo.setCellStyle(cellTitleStyle);
cellTwo=rowTwo.createCell(6);
cellTwo.setCellValue("报警参数");
cellTwo.setCellStyle(cellTitleStyle);
rowTwo.setHeight((short)(30*20));
/*
* 循环创建
* */
int rowIndex=1;
for (int s=0;s<resultAlarmLogVos.size();s++){
//从第4行开始创建
rowIndex=rowIndex+1;//2
HSSFRow row = sheet.createRow(rowIndex);
HSSFCell cell=null;
cell=row.createCell(0);
cell.setCellValue(resultAlarmLogVos.get(s).getTransportationNo());
cell.setCellStyle(cellStyle);
cell=row.createCell(1);
cell.setCellValue(resultAlarmLogVos.get(s).getCargoNo());
cell.setCellStyle(cellStyle);
cell=row.createCell(2);
cell.setCellValue(resultAlarmLogVos.get(s).getTDLSN());
cell.setCellStyle(cellStyle);
cell=row.createCell(3);
cell.setCellValue(resultAlarmLogVos.get(s).getDescription());
cell.setCellStyle(cellStyle);
cell=row.createCell(4);
cell.setCellValue(resultAlarmLogVos.get(s).getData());
cell.setCellStyle(cellStyle);
cell=row.createCell(5);
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//这个是你要转成后的时间的格式
String sd = sdf.format(new Date(resultAlarmLogVos.get(s).getAlarmTime()));
cell.setCellValue(sd);
cell.setCellStyle(cellStyle);
cell=row.createCell(6);
cell.setCellValue(resultAlarmLogVos.get(s).getClassify());
cell.setCellStyle(cellStyle);
row.setHeight((short)(25*20));
}
sheet.setColumnWidth(0, 26 * 256);
sheet.setColumnWidth(1, 20 * 256);
sheet.setColumnWidth(2, 20 * 256);
sheet.setColumnWidth(3, 30 * 256);
sheet.setColumnWidth(4, 17 * 256);
sheet.setColumnWidth(5, 25 * 256);
sheet.setColumnWidth(6, 12 * 256);
return workbook;
}
/*
* 标题单元格样式
*/
public HSSFCellStyle getTitleStyle(HSSFWorkbook workbook) {
// 设置字体
HSSFFont font = workbook.createFont();
//设置字体大小
font.setFontHeightInPoints((short) 16);
//字体加粗
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
//设置字体名字
font.setFontName("新宋体");
//设置样式;
HSSFCellStyle style = workbook.createCellStyle();
//在样式用应用设置的字体;
style.setFont(font);
//设置自动换行;
style.setWrapText(true);
//设置水平对齐的样式为居中对齐;
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//设置垂直对齐的样式为居中对齐;
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
return style;
}
/*
* 列数据信息单元格样式
*/
public HSSFCellStyle getCellTitleStyle(HSSFWorkbook workbook) {
HSSFFont font = workbook.createFont();
font.setFontHeightInPoints((short) 12);
font.setFontName("Arial");
HSSFCellStyle style = workbook.createCellStyle();
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBottomBorderColor(HSSFColor.BLACK.index);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setLeftBorderColor(HSSFColor.BLACK.index);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
//设置右边框颜色;
style.setRightBorderColor(HSSFColor.BLACK.index);
//设置顶边框;
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
//设置顶边框颜色;
style.setTopBorderColor(HSSFColor.BLACK.index);
//在样式用应用设置的字体;
style.setFont(font);
//设置自动换行;
style.setWrapText(true);
//设置水平对齐的样式为居中对齐;
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//设置垂直对齐的样式为居中对齐;
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
return style;
}
/*
* 列数据信息单元格样式
*/
public HSSFCellStyle getCellStyle(HSSFWorkbook workbook) {
HSSFFont font = workbook.createFont();
font.setFontHeightInPoints((short) 11);
font.setFontName("Arial");
HSSFCellStyle style = workbook.createCellStyle();
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBottomBorderColor(HSSFColor.BLACK.index);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setLeftBorderColor(HSSFColor.BLACK.index);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
//设置右边框颜色;
style.setRightBorderColor(HSSFColor.BLACK.index);
//设置顶边框;
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
//设置顶边框颜色;
style.setTopBorderColor(HSSFColor.BLACK.index);
//在样式用应用设置的字体;
style.setFont(font);
//设置自动换行;
style.setWrapText(true);
//设置水平对齐的样式为居中对齐;
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//设置垂直对齐的样式为居中对齐;
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
return style;
}
}
\ No newline at end of file
......@@ -40,6 +40,8 @@ public class AliyunOSSClientUtil {
private static String FOLDER6;
private static String FOLDER7;
private static CannedAccessControlList acl_pub_readwrite = CannedAccessControlList.PublicReadWrite;
//初始化属性
......@@ -54,6 +56,7 @@ public class AliyunOSSClientUtil {
FOLDER4 = OSSClientConstants.FOLDER4;
FOLDER5 = OSSClientConstants.FOLDER5;
FOLDER6 = OSSClientConstants.FOLDER6;
FOLDER7 = OSSClientConstants.FOLDER7;
}
public static String getENDPOINT() {
......@@ -136,6 +139,14 @@ public class AliyunOSSClientUtil {
AliyunOSSClientUtil.FOLDER6 = FOLDER6;
}
public static String getFOLDER7() {
return FOLDER7;
}
public static void setFOLDER7(String FOLDER7) {
AliyunOSSClientUtil.FOLDER7 = FOLDER7;
}
/**
* 获取阿里云OSS客户端对象
* @return ossClient
......@@ -268,9 +279,11 @@ public class AliyunOSSClientUtil {
}else if("truck".equals(imageType)){
key = FOLDER3+key;
}else if ("warehouse".equals(imageType)){
key = FOLDER4+key;
key = FOLDER5+key;
}else if("circuit".equals(imageType)){
key = FOLDER4+key;
key = FOLDER6+key;
}else if("alarmLogABB".equals(imageType)){
key = FOLDER7+key;
}
PutObjectResult putResult = ossClient.putObject(BACKET_NAME, key, instream, objectMetadata);
ret = putResult.getETag();
......@@ -379,6 +392,8 @@ public class AliyunOSSClientUtil {
putResult = ossClient.putObject(BACKET_NAME, FOLDER6+ fileName, is, metadata);
} else if(fileName.contains("仓库温湿度观测记录") || fileName.contains("Warehouse temperature and humidity historic data")|| fileName.contains("倉庫の温度および湿度の観測記録")){
putResult = ossClient.putObject(BACKET_NAME, FOLDER5+ fileName, is, metadata);
} else if(fileName.contains("报警日志数据")){
putResult = ossClient.putObject(BACKET_NAME, FOLDER7+ fileName, is, metadata);
} else {
putResult = ossClient.putObject(BACKET_NAME, FOLDER1+ fileName, is, metadata);
}
......
......@@ -30,6 +30,8 @@ public class OSSClientConstants {
public static final String FOLDER6="circuit/";//线路数据下载
public static final String FOLDER7="abbAlarm/";//线路数据下载
//公共读写
private static final CannedAccessControlList acl_pub_readwrite = CannedAccessControlList.PublicReadWrite;
......
This diff is collapsed.
spring.datasource.url=jdbc:mysql://47.110.153.44:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.url=jdbc:mysql://localhost:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=37774020
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
threadpool.corepoolsize = 30
threadpool.maxpoolsize = 50
server.port=8092
server.port=8888
management.security.enabled=false
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.AlarmLogABBMapper">
<!--获取所有的报警数据-->
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultAlarmLogABBVo">
select a.transportationNo,cargoNo,TDLSN,description,ifnull(`data`,"") `data`,alarmTime,classify
from alarm_log a INNER JOIN circuit c ON a.transportationNo=c.transportationNo
INNER JOIN company co ON c.company_id = co.id
WHERE co.companyNo=#{companyNo,jdbcType=VARCHAR} order by a.alarmTime DESC
LIMIT #{page,jdbcType=INTEGER},#{rows,jdbcType=INTEGER}
</select>
<select id="getAllCount" resultType="java.lang.Integer" parameterType="String">
select COUNT(a.id) from alarm_log a INNER JOIN circuit c ON a.transportationNo=c.transportationNo
INNER JOIN company co ON c.company_id = co.id
WHERE co.companyNo=#{companyNo,jdbcType=VARCHAR}
</select>
<select id="getByTerm" resultType="com.example.tdl.domain.vo.ResultAlarmLogABBVo">
select a.transportationNo,cargoNo,TDLSN,description,ifnull(`data`,"") `data`,alarmTime,classify
from alarm_log a INNER JOIN circuit c ON a.transportationNo=c.transportationNo
INNER JOIN company co ON c.company_id = co.id
WHERE co.companyNo=#{alarmTermABBVo.companyNo,jdbcType=VARCHAR}
<if test="alarmTermABBVo.classify!=null">
AND a.classify=#{alarmTermABBVo.classify,jdbcType=VARCHAR}
</if>
<if test="alarmTermABBVo.startTime!=null and alarmTermABBVo.endTime!=null">
AND a.alarmTime BETWEEN #{alarmTermABBVo.startTime,jdbcType=BIGINT} AND #{alarmTermABBVo.endTime,jdbcType=BIGINT}
</if>
order by a.alarmTime DESC
LIMIT #{page,jdbcType=INTEGER},#{rows,jdbcType=INTEGER}
</select>
<select id="getByTermCount" parameterType="com.example.tdl.domain.vo.AlarmTermABBVo" resultType="java.lang.Integer">
select COUNT(a.id) from alarm_log a INNER JOIN circuit c ON a.transportationNo=c.transportationNo
INNER JOIN company co ON c.company_id = co.id
WHERE co.companyNo=#{companyNo,jdbcType=VARCHAR}
<if test="classify!=null">
AND a.classify=#{classify,jdbcType=VARCHAR}
</if>
<if test="startTime!=null and endTime!=null">
AND a.alarmTime BETWEEN #{startTime,jdbcType=BIGINT} AND #{endTime,jdbcType=BIGINT}
</if>
</select>
<select id="getByTermForDownload" resultType="com.example.tdl.domain.vo.ResultAlarmLogABBVo" parameterType="com.example.tdl.domain.vo.AlarmTermABBVo">
select a.transportationNo,cargoNo,TDLSN,description,ifnull(`data`,"") `data`,alarmTime,classify
from alarm_log a INNER JOIN circuit c ON a.transportationNo=c.transportationNo
INNER JOIN company co ON c.company_id = co.id
WHERE co.companyNo=#{companyNo,jdbcType=VARCHAR}
<if test="classify!=null">
AND a.classify=#{classify,jdbcType=VARCHAR}
</if>
<if test="startTime!=null and endTime!=null">
AND a.alarmTime BETWEEN #{startTime,jdbcType=BIGINT} AND #{endTime,jdbcType=BIGINT}
</if>
order by a.alarmTime DESC
</select>
<select id="getYearCountForLineGraph" resultType="com.example.tdl.domain.vo.ResultAlarmLogCountABBVo">
SELECT @a :=@a+1 indexs,CONCAT_WS(" ~ ",ADDDATE(CURRENT_DATE,INTERVAL @a-1 MONTH),ADDDATE(CURRENT_DATE,INTERVAL @a MONTH)) dates,
(SELECT IFNULL(SUM(a.tempCount) ,0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL @a-1 MONTH)
AND ADDDATE(CURRENT_DATE,INTERVAL @a MONTH)) tempCountSum,
(SELECT IFNULL(SUM(a.humidCount) ,0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL @a-1 MONTH)
AND ADDDATE(CURRENT_DATE,INTERVAL @a MONTH)) humidCountSum,
(SELECT IFNULL(SUM(a.shockCount) ,0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL @a-1 MONTH)
AND ADDDATE(CURRENT_DATE,INTERVAL @a MONTH)) shockCountSum,
(SELECT IFNULL(SUM(a.leanCount) ,0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL @a-1 MONTH)
AND ADDDATE(CURRENT_DATE,INTERVAL @a MONTH)) leanCountSum,
(SELECT IFNULL(SUM(a.sum) ,0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL @a-1 MONTH)
AND ADDDATE(CURRENT_DATE,INTERVAL @a MONTH)) countSum
from mysql.help_topic, (SELECT @a :=-12 ) temp
WHERE @a &lt;0;
</select>
<select id="getDayCountForLineGraph" resultType="com.example.tdl.domain.vo.ResultAlarmLogCountABBVo">
SELECT @a := @a +1 indexs,ADDDATE(CURRENT_DATE,INTERVAL @a DAY) dates,
(SELECT IFNULL(SUM(a.tempCount),0) FROM alarm_count_abb a WHERE a.`date`=ADDDATE(CURRENT_DATE,INTERVAL @a DAY)) tempCountSum,
(SELECT IFNULL(SUM(a.humidCount),0) FROM alarm_count_abb a WHERE a.`date`=ADDDATE(CURRENT_DATE,INTERVAL @a DAY)) humidCountSum,
(SELECT IFNULL(SUM(a.shockCount),0) FROM alarm_count_abb a WHERE a.`date`=ADDDATE(CURRENT_DATE,INTERVAL @a DAY)) shockCountSum,
(SELECT IFNULL(SUM(a.leanCount),0) FROM alarm_count_abb a WHERE a.`date`=ADDDATE(CURRENT_DATE,INTERVAL @a DAY)) leanCountSum,
(SELECT IFNULL(SUM(a.sum),0) FROM alarm_count_abb a WHERE a.`date`=ADDDATE(CURRENT_DATE,INTERVAL @a DAY)) countSum
from mysql.help_topic,(SELECT @a :=-30) temp
WHERE @a &lt;0;
</select>
<select id="getDaySumForPieGraph" resultType="com.example.tdl.domain.vo.ResultAlarmLogCountPieGraphVo">
SELECT IFNULL(SUM(a.tempCount),0) tempCountSum,IFNULL(SUM(a.humidCount),0) humidCountSum,IFNULL(SUM(a.shockCount),0) shockCountSum,
IFNULL(SUM(a.leanCount),0) leanCountSum,IFNULL(SUM(a.sum),0) countSum
FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -30 DAY) AND CURRENT_DATE
</select>
<select id="getYearSumForPieGraph" resultType="com.example.tdl.domain.vo.ResultAlarmLogCountPieGraphVo">
SELECT IFNULL(SUM(a.tempCount),0) tempCountSum,IFNULL(SUM(a.humidCount),0) humidCountSum,IFNULL(SUM(a.shockCount),0) shockCountSum,
IFNULL(SUM(a.leanCount),0) leanCountSum,IFNULL(SUM(a.sum),0) countSum
FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -1 YEAR) AND CURRENT_DATE
</select>
<select id="getDayHouseSumForPieGraph" resultType="com.example.tdl.domain.vo.ResultAlarmLogHouseCountPieGraphVo">
SELECT @a := @a +1 house,
(SELECT IFNULL(SUM(a.tempCount),0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -30 DAY)
AND CURRENT_DATE AND house=@a) tempCountSum,
(SELECT IFNULL(SUM(a.humidCount),0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -30 DAY)
AND CURRENT_DATE AND house=@a) humidCountSum,
(SELECT IFNULL(SUM(a.shockCount),0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -30 DAY)
AND CURRENT_DATE AND house=@a) shockCountSum,
(SELECT IFNULL(SUM(a.leanCount),0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -30 DAY)
AND CURRENT_DATE AND house=@a) leanCountSum,
(SELECT IFNULL(SUM(a.sum),0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -30 DAY)
AND CURRENT_DATE AND house=@a) countSum
from mysql.help_topic,(SELECT @a :=0) temp
WHERE @a &lt;24;
</select>
<select id="getYearHouseSumForPieGraph" resultType="com.example.tdl.domain.vo.ResultAlarmLogHouseCountPieGraphVo">
SELECT @a := @a +1 house,
(SELECT IFNULL(SUM(a.tempCount) ,0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -1 YEAR)
AND CURRENT_DATE AND house=@a) tempCountSum,
(SELECT IFNULL(SUM(a.humidCount) ,0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -1 YEAR)
AND CURRENT_DATE AND house=@a) humidCountSum,
(SELECT IFNULL(SUM(a.shockCount) ,0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -1 YEAR)
AND CURRENT_DATE AND house=@a) shockCountSum,
(SELECT IFNULL(SUM(a.leanCount) ,0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -1 YEAR)
AND CURRENT_DATE AND house=@a) leanCountSum,
(SELECT IFNULL(SUM(a.sum) ,0) FROM alarm_count_abb a WHERE a.`date` BETWEEN ADDDATE(CURRENT_DATE,INTERVAL -1 YEAR)
AND CURRENT_DATE AND house=@a) countSum
from mysql.help_topic, (SELECT @a :=0 ) temp
WHERE @a &lt;24;
</select>
</mapper>
\ No newline at end of file
......@@ -7,7 +7,7 @@
SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,(select GROUP_CONCAT(DISTINCT classify)
from alarm_log al where al.transportationNo = c.transportationNo) alarm,transportation,
(select DISTINCT gatewaySN from tdl_gateway_log WHERE transportationNo=c.transportationNo) gSN,
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType,c.createTime
from circuit c
where c.state=1
AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
......@@ -20,7 +20,7 @@
SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,(select GROUP_CONCAT(DISTINCT classify)
from alarm_log al where al.transportationNo = c.transportationNo) alarm,transportation,
(select DISTINCT gatewaySN from tdl_gateway_log WHERE transportationNo=c.transportationNo) gSN,
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType,c.createTime
from circuit c
where c.state=1
AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
......@@ -109,7 +109,7 @@
SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,(select GROUP_CONCAT(DISTINCT classify)
from alarm_log al where al.transportationNo = c.transportationNo) alarm,transportation,
(select DISTINCT gatewaySN from tdl_gateway_log WHERE transportationNo=c.transportationNo) gSN,
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType,c.createTime
from circuit c
where c.state=1
AND c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
......@@ -121,7 +121,7 @@
SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,(select GROUP_CONCAT(DISTINCT classify)
from alarm_log al where al.transportationNo = c.transportationNo) alarm,transportation,
(select DISTINCT gatewaySN from tdl_gateway_log WHERE transportationNo=c.transportationNo) gSN,
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType,c.createTime
from circuit c
where c.state=1
and c.transportationNo=#{transportationNo,jdbcType=VARCHAR}
......@@ -137,7 +137,7 @@
SELECT alarm_id from tdl_gateway_log WHERE transportationNo=c.transportationNo)) alarmType,(select GROUP_CONCAT(DISTINCT classify)
from alarm_log al where al.transportationNo = c.transportationNo) alarm,transportation,
(select DISTINCT gatewaySN from tdl_gateway_log WHERE transportationNo=c.transportationNo) gSN,
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType
(select DISTINCT gatewayType from tdl_gateway_log WHERE transportationNo=c.transportationNo) gType,c.createTime
from circuit c where c.state=1
and c.circuitState = 1
AND company_id=(SELECT id from company where companyNo=#{companyNo,jdbcType=VARCHAR})
......
......@@ -42,6 +42,7 @@
<mapper resource="mapper/ModelMapper.xml"/>
<mapper resource="mapper/ModelInfoMapper.xml"/>
<mapper resource="mapper/AlarmLogMapper.xml"/>
<mapper resource="mapper/AlarmLogABBMapper.xml"/>
<mapper resource="mapper/ConfigMapper.xml"/>
<mapper resource="mapper/ProbesMapper.xml"/>
<mapper resource="mapper/TopicMapper.xml"/>
......
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