数据接收功能修改
This commit is contained in:
parent
00193a7252
commit
cacf21776c
@ -244,7 +244,7 @@ public class MyMqttCallback implements MqttCallback {
|
|||||||
fields.put(v,(Double.parseDouble(msg.get(k).toString()) - 400) * 1.25);
|
fields.put(v,(Double.parseDouble(msg.get(k).toString()) - 400) * 1.25);
|
||||||
break;
|
break;
|
||||||
case "temp":
|
case "temp":
|
||||||
fields.put(v,Double.parseDouble(msg.get(k).toString()) * 0.1);
|
fields.put(v,Double.parseDouble(msg.get(k).toString()) / 10.0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fields.put(v,msg.get(k));
|
fields.put(v,msg.get(k));
|
||||||
@ -258,7 +258,7 @@ public class MyMqttCallback implements MqttCallback {
|
|||||||
int alarmNum = alarmRulesApi.alarmRulesFilter(fields, rules);
|
int alarmNum = alarmRulesApi.alarmRulesFilter(fields, rules);
|
||||||
logger.info("本次产生报警{}条",alarmNum);
|
logger.info("本次产生报警{}条",alarmNum);
|
||||||
}
|
}
|
||||||
influxDBService.insert(measurement,tags, fields);
|
influxDBService.insert(measurement, tags, fields);
|
||||||
logger.info("数据已插入{}表中!",measurement);
|
logger.info("数据已插入{}表中!",measurement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,16 +23,16 @@ import java.util.stream.Collectors;
|
|||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DataQueryService implements IDataQueryService{
|
public class DataQueryService implements IDataQueryService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private InfluxDBService influxDBService;
|
private InfluxDBService influxDBService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> selectDataListByPages(String equipId,String tableName,String startTime,String endTime, Integer pageSize, Integer pageNum){
|
public Map<String, Object> selectDataListByPages(String equipId, String tableName, String startTime, String endTime, Integer pageSize, Integer pageNum) {
|
||||||
Map<String, Object> resMap = new HashMap<>();
|
Map<String, Object> resMap = new HashMap<>();
|
||||||
//TODO 分页查找条数,根据设备id、表名、时间范围、页码、每页条数
|
//TODO 分页查找条数,根据设备id、表名、时间范围、页码、每页条数
|
||||||
List<Map<String, Object>> dataList = queryDataByTime(tableName, null, startTime, endTime, pageNum, pageSize);
|
List<Map<String, Object>> dataList = queryDataByTime(tableName, equipId, startTime, endTime, pageNum, pageSize);
|
||||||
dataList.forEach(map -> {
|
dataList.forEach(map -> {
|
||||||
try {
|
try {
|
||||||
String time = map.get("time").toString();
|
String time = map.get("time").toString();
|
||||||
@ -41,10 +41,14 @@ public class DataQueryService implements IDataQueryService{
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//TODO 时间需要将查询到的UTC时间转为系统时间(北京时间)
|
//TODO 时间需要将查询到的UTC时间转为系统时间(北京时间)
|
||||||
// DateUtils.tranUTC2LocalDateTime("2024-08-28T08:00:00Z");
|
// DateUtils.tranUTC2LocalDateTime("2024-08-28T08:00:00Z");
|
||||||
//TODO 查询数据总条数
|
//TODO 查询数据总条数
|
||||||
long total = countDataList(tableName, "x_push_temp", null, startTime, endTime);
|
long total = 0L;
|
||||||
|
if (dataList.size() != 0) {
|
||||||
|
List<String> keys = new ArrayList<>(dataList.get(0).keySet());
|
||||||
|
total = countDataList(tableName, keys.get(0), null, startTime, endTime);
|
||||||
|
}
|
||||||
resMap.put("list", dataList);
|
resMap.put("list", dataList);
|
||||||
resMap.put("total", total);
|
resMap.put("total", total);
|
||||||
return resMap;
|
return resMap;
|
||||||
@ -70,13 +74,13 @@ public class DataQueryService implements IDataQueryService{
|
|||||||
// }
|
// }
|
||||||
List<Map<String, Object>> list = selectDataByColumnNameandDateSegmentation(equipId, tableName, columnName, startTime, endTime, intervalHours);
|
List<Map<String, Object>> list = selectDataByColumnNameandDateSegmentation(equipId, tableName, columnName, startTime, endTime, intervalHours);
|
||||||
Map<String, Object> resMap = new HashMap<>();
|
Map<String, Object> resMap = new HashMap<>();
|
||||||
if (list.size() == 0){
|
if (list.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Object> columnList = new ArrayList<>();
|
List<Object> columnList = new ArrayList<>();
|
||||||
List<String> timelist = new ArrayList<>();
|
List<String> timelist = new ArrayList<>();
|
||||||
if(intervalHours > 6){
|
if (intervalHours > 6) {
|
||||||
columnName = "mean";
|
columnName = "mean";
|
||||||
}
|
}
|
||||||
for (Map<String, Object> data : list) {
|
for (Map<String, Object> data : list) {
|
||||||
@ -93,49 +97,49 @@ public class DataQueryService implements IDataQueryService{
|
|||||||
/**
|
/**
|
||||||
* 根据设备id获取排屑电流数据
|
* 根据设备id获取排屑电流数据
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> getCurrentData(String equipId, String startTime, String endTime){
|
public Map<String, Object> getCurrentData(String equipId, String startTime, String endTime) {
|
||||||
String tableName = "gateway_current_data";
|
String tableName = "gateway_current_data";
|
||||||
String columnName = "chip_removal_1,chip_removal_2";
|
String columnName = "chip_removal_1,chip_removal_2";
|
||||||
return getAllData2ChartData(equipId,tableName,columnName, startTime, endTime);
|
return getAllData2ChartData(equipId, tableName, columnName, startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备id获取液压数据
|
* 根据设备id获取液压数据
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> getPressData(String equipId, String startTime, String endTime){
|
public Map<String, Object> getPressData(String equipId, String startTime, String endTime) {
|
||||||
String tableName = "gateway_hy_data";
|
String tableName = "gateway_hy_data";
|
||||||
String columnName = "hy_1,hy_2,hy_3";
|
String columnName = "hy_1,hy_2,hy_3";
|
||||||
return getAllData2ChartData(equipId,tableName,columnName, startTime, endTime);
|
return getAllData2ChartData(equipId, tableName, columnName, startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备id获取温度数据
|
* 根据设备id获取温度数据
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> getTempData(String equipId, String startTime, String endTime){
|
public Map<String, Object> getTempData(String equipId, String startTime, String endTime) {
|
||||||
String tableName = "gateway_temp_data";
|
String tableName = "gateway_temp_data";
|
||||||
String columnName = "cr1_temp,cr2_temp,x0_temp,xp_temp,xn_temp,y0_temp,yp_temp,yn_temp,z0_temp,zp_temp,zn_temp";
|
String columnName = "cr1_temp,cr2_temp,x0_temp,xp_temp,xn_temp,y0_temp,yp_temp,yn_temp,z0_temp,zp_temp,zn_temp";
|
||||||
return getAllData2ChartData(equipId,tableName,columnName, startTime, endTime);
|
return getAllData2ChartData(equipId, tableName, columnName, startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备id获取振动数据
|
* 根据设备id获取振动数据
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> getVibrData(String equipId, String startTime, String endTime){
|
public Map<String, Object> getVibrData(String equipId, String startTime, String endTime) {
|
||||||
String tableName = "gateway_aclr_data";
|
String tableName = "gateway_aclr_data";
|
||||||
String columnName = "x_aclr_rms,x_speed_rms,x_dis_rms,y_aclr_rms,y_speed_rms,y_dis_rms,z_aclr_rms,z_speed_rms,z_dis_rms," +
|
String columnName = "x_aclr_rms,x_speed_rms,x_dis_rms,y_aclr_rms,y_speed_rms,y_dis_rms,z_aclr_rms,z_speed_rms,z_dis_rms," +
|
||||||
"x_aclr_peak,x_speed_peak,x_dis_peak,y_aclr_peak,y_speed_peak,y_dis_peak,z_aclr_peak,z_speed_peak,z_dis_peak";
|
"x_aclr_peak,x_speed_peak,x_dis_peak,y_aclr_peak,y_speed_peak,y_dis_peak,z_aclr_peak,z_speed_peak,z_dis_peak";
|
||||||
return getAllData2ChartData(equipId,tableName,columnName, startTime, endTime);
|
return getAllData2ChartData(equipId, tableName, columnName, startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备id获取工作数据
|
* 根据设备id获取工作数据
|
||||||
*/
|
*/
|
||||||
public Map<String, Object> getWorkData(String equipId, String startTime, String endTime){
|
public Map<String, Object> getWorkData(String equipId, String startTime, String endTime) {
|
||||||
String tableName = "gateway_fanuc_data";
|
String tableName = "gateway_fanuc_data";
|
||||||
String columnName = "power_time,process_num,total_process,work_time";
|
String columnName = "power_time,process_num,total_process,work_time";
|
||||||
Map<String, Object> resultMap = getAllData2ChartData(equipId,tableName,columnName, startTime, endTime);
|
Map<String, Object> resultMap = getAllData2ChartData(equipId, tableName, columnName, startTime, endTime);
|
||||||
if(resultMap == null){
|
if (resultMap == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<Double> workTimeList = (List<Double>) resultMap.get("work_time");
|
List<Double> workTimeList = (List<Double>) resultMap.get("work_time");
|
||||||
@ -145,42 +149,42 @@ public class DataQueryService implements IDataQueryService{
|
|||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getAllData2ChartData(String equipId,String tableName,String columns, String startTime, String endTime){
|
public Map<String, Object> getAllData2ChartData(String equipId, String tableName, String columns, String startTime, String endTime) {
|
||||||
LocalDateTime stime = DateUtils.tranUTCtoLocalDateTime(startTime);
|
LocalDateTime stime = DateUtils.tranUTCtoLocalDateTime(startTime);
|
||||||
LocalDateTime etime = DateUtils.tranUTCtoLocalDateTime(endTime);
|
LocalDateTime etime = DateUtils.tranUTCtoLocalDateTime(endTime);
|
||||||
long intervalHours = ChronoUnit.HOURS.between(stime, etime);
|
long intervalHours = ChronoUnit.HOURS.between(stime, etime);
|
||||||
List<Map<String, Object>> list = selectDataByColumnNameandDateSegmentation(equipId, tableName, columns, startTime, endTime, intervalHours);
|
List<Map<String, Object>> list = selectDataByColumnNameandDateSegmentation(equipId, tableName, columns, startTime, endTime, intervalHours);
|
||||||
Map<String, Object> resMap = new HashMap<>();
|
Map<String, Object> resMap = new HashMap<>();
|
||||||
if (list.size() == 0){
|
if (list.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Object> columnList = new ArrayList<>();
|
List<Object> columnList = new ArrayList<>();
|
||||||
List<String> timelist = new ArrayList<>();
|
List<String> timelist = new ArrayList<>();
|
||||||
String[] columnName = columns.split(",");
|
String[] columnName = columns.split(",");
|
||||||
if(intervalHours > 6){
|
if (intervalHours > 6) {
|
||||||
for(int i=0;i < columnName.length;i++){
|
for (int i = 0; i < columnName.length; i++) {
|
||||||
columnName[i] = "mean_" + columnName[i];
|
columnName[i] = "mean_" + columnName[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
for (String cn : columnName) {
|
for (String cn : columnName) {
|
||||||
if(cn.trim().length() == 0){
|
if (cn.trim().length() == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String realCn = cn;
|
String realCn = cn;
|
||||||
if(cn.startsWith("mean")){
|
if (cn.startsWith("mean")) {
|
||||||
realCn = cn.replaceFirst("mean_", "");
|
realCn = cn.replaceFirst("mean_", "");
|
||||||
}
|
}
|
||||||
resMap.put(realCn, list.stream().map(map->{
|
resMap.put(realCn, list.stream().map(map -> {
|
||||||
Double data = (Double)map.get(cn);
|
Double data = (Double) map.get(cn);
|
||||||
if("gateway_temp_data".equals(tableName)){//温度处理
|
if ("gateway_temp_data".equals(tableName)) {//温度处理
|
||||||
return data/10.0;
|
return data / 10.0;
|
||||||
}
|
}
|
||||||
if("work_time".equals(columnName) || "power_time".equals(columnName)){//时间转小时
|
if ("work_time".equals(columnName) || "power_time".equals(columnName)) {//时间转小时
|
||||||
return data/60.0;
|
return data / 60.0;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}).collect(Collectors.toList()));
|
}).collect(Collectors.toList()));
|
||||||
resMap.put("time", list.stream().map(map -> DateUtils.utcToCst(map.get("time").toString())).collect(Collectors.toList()));
|
resMap.put("time", list.stream().map(map -> DateUtils.utcToCst(map.get("time").toString())).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
@ -189,19 +193,18 @@ public class DataQueryService implements IDataQueryService{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*按照策略分段查询数据列表
|
* 按照策略分段查询数据列表
|
||||||
*/
|
*/
|
||||||
private List<Map<String, Object>> selectDataByColumnNameandDateSegmentation(String equipId, String tableName, String columnName, String startTime, String endTime,long intervalHours)
|
private List<Map<String, Object>> selectDataByColumnNameandDateSegmentation(String equipId, String tableName, String columnName, String startTime, String endTime, long intervalHours) {
|
||||||
{
|
|
||||||
List<Map<String, Object>> list = new ArrayList<>();
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
if(intervalHours <= 6){//6小时内全查
|
if (intervalHours <= 6) {//6小时内全查
|
||||||
list = selectDataByColumnNameandDate(null,tableName, columnName, startTime, endTime);
|
list = selectDataByColumnNameandDate(null, tableName, columnName, startTime, endTime);
|
||||||
}else if(intervalHours <= 7*24 ){//7天内,每30s一个
|
} else if (intervalHours <= 7 * 24) {//7天内,每30s一个
|
||||||
list = selectLongTimeDataByColumnNameandDate(null,tableName, columnName, startTime, endTime, "30s");
|
list = selectLongTimeDataByColumnNameandDate(null, tableName, columnName, startTime, endTime, "30s");
|
||||||
}else if(intervalHours <= 30*24 ){//30天内,每2min一个
|
} else if (intervalHours <= 30 * 24) {//30天内,每2min一个
|
||||||
list = selectLongTimeDataByColumnNameandDate(null,tableName, columnName, startTime, endTime, "2m");
|
list = selectLongTimeDataByColumnNameandDate(null, tableName, columnName, startTime, endTime, "2m");
|
||||||
}else if (intervalHours <= 90*24){//90天以上,每6min一个
|
} else if (intervalHours <= 90 * 24) {//90天以上,每6min一个
|
||||||
list = selectLongTimeDataByColumnNameandDate(null,tableName, columnName, startTime, endTime, "6m");
|
list = selectLongTimeDataByColumnNameandDate(null, tableName, columnName, startTime, endTime, "6m");
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -209,26 +212,26 @@ public class DataQueryService implements IDataQueryService{
|
|||||||
private List<Map<String, Object>> queryDataByTime(String tableName, String equipId, String beginTime, String endTime, Integer pageNum, Integer pageSize) {
|
private List<Map<String, Object>> queryDataByTime(String tableName, String equipId, String beginTime, String endTime, Integer pageNum, Integer pageSize) {
|
||||||
StringBuilder sql = new StringBuilder("select * from ")
|
StringBuilder sql = new StringBuilder("select * from ")
|
||||||
.append("\"").append(tableName).append("\"");
|
.append("\"").append(tableName).append("\"");
|
||||||
if(equipId != null){
|
if (equipId != null) {
|
||||||
sql.append(" where equip_id = '").append(equipId).append("'");
|
sql.append(" where equip_id = '").append(equipId).append("'");
|
||||||
}
|
}
|
||||||
if(beginTime != null){
|
if (beginTime != null) {
|
||||||
if(!sql.toString().contains("where")){
|
if (!sql.toString().contains("where")) {
|
||||||
sql.append(" where");
|
sql.append(" where");
|
||||||
}else{
|
} else {
|
||||||
sql.append(" and");
|
sql.append(" and");
|
||||||
}
|
}
|
||||||
sql.append(" time >= '").append(beginTime).append("'");
|
sql.append(" time >= '").append(beginTime).append("'");
|
||||||
}
|
}
|
||||||
if(endTime != null){
|
if (endTime != null) {
|
||||||
if(!sql.toString().contains("where")){
|
if (!sql.toString().contains("where")) {
|
||||||
sql.append(" where");
|
sql.append(" where");
|
||||||
}else{
|
} else {
|
||||||
sql.append(" and");
|
sql.append(" and");
|
||||||
}
|
}
|
||||||
sql.append(" time <= '").append(endTime).append("'");
|
sql.append(" time <= '").append(endTime).append("'");
|
||||||
}
|
}
|
||||||
if(pageNum != null || pageSize != null) {
|
if (pageNum != null || pageSize != null) {
|
||||||
sql.append(" order by time desc ")
|
sql.append(" order by time desc ")
|
||||||
.append(" limit ").append(pageSize)
|
.append(" limit ").append(pageSize)
|
||||||
.append(" offset ").append((pageNum - 1) * pageSize);
|
.append(" offset ").append((pageNum - 1) * pageSize);
|
||||||
@ -238,24 +241,24 @@ public class DataQueryService implements IDataQueryService{
|
|||||||
return influxDBService.queryResultProcess(influxDBService.query(sql.toString()));
|
return influxDBService.queryResultProcess(influxDBService.query(sql.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private long countDataList(String tableName,String field, String equipId, String beginTime, String endTime){
|
private long countDataList(String tableName, String field, String equipId, String beginTime, String endTime) {
|
||||||
StringBuilder sql = new StringBuilder("select count(").append(field).append(") from ")
|
StringBuilder sql = new StringBuilder("select count(").append(field).append(") from ")
|
||||||
.append("\"").append(tableName).append("\"");
|
.append("\"").append(tableName).append("\"");
|
||||||
if(equipId != null){
|
if (equipId != null) {
|
||||||
sql.append(" where equip_id = '").append(equipId).append("'");
|
sql.append(" where equip_id = '").append(equipId).append("'");
|
||||||
}
|
}
|
||||||
if(beginTime != null){
|
if (beginTime != null) {
|
||||||
if(!sql.toString().contains("where")){
|
if (!sql.toString().contains("where")) {
|
||||||
sql.append(" where");
|
sql.append(" where");
|
||||||
}else{
|
} else {
|
||||||
sql.append(" and");
|
sql.append(" and");
|
||||||
}
|
}
|
||||||
sql.append(" time >= '").append(beginTime).append("'");
|
sql.append(" time >= '").append(beginTime).append("'");
|
||||||
}
|
}
|
||||||
if(endTime != null){
|
if (endTime != null) {
|
||||||
if(!sql.toString().contains("where")){
|
if (!sql.toString().contains("where")) {
|
||||||
sql.append(" where");
|
sql.append(" where");
|
||||||
}else{
|
} else {
|
||||||
sql.append(" and");
|
sql.append(" and");
|
||||||
}
|
}
|
||||||
sql.append(" time <= '").append(endTime).append("'");
|
sql.append(" time <= '").append(endTime).append("'");
|
||||||
@ -266,30 +269,31 @@ public class DataQueryService implements IDataQueryService{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据字段名称和起止时间查询数据
|
* 根据字段名称和起止时间查询数据
|
||||||
* @param tableName 表名
|
*
|
||||||
|
* @param tableName 表名
|
||||||
* @param columnName 字段名称
|
* @param columnName 字段名称
|
||||||
* @param beginTime 起始时间
|
* @param beginTime 起始时间
|
||||||
* @param endTime 结束时间
|
* @param endTime 结束时间
|
||||||
* @return 数据
|
* @return 数据
|
||||||
*/
|
*/
|
||||||
private List<Map<String, Object>> selectDataByColumnNameandDate(String equipId, String tableName, String columnName, String beginTime, String endTime){
|
private List<Map<String, Object>> selectDataByColumnNameandDate(String equipId, String tableName, String columnName, String beginTime, String endTime) {
|
||||||
StringBuilder sql = new StringBuilder("select time,").append(columnName).append(" from ")
|
StringBuilder sql = new StringBuilder("select time,").append(columnName).append(" from ")
|
||||||
.append("\"").append(tableName).append("\"");//TODO 修改时间
|
.append("\"").append(tableName).append("\"");//TODO 修改时间
|
||||||
if(equipId != null){
|
if (equipId != null) {
|
||||||
sql.append(" where equip_id = '").append(equipId).append("'");
|
sql.append(" where equip_id = '").append(equipId).append("'");
|
||||||
}
|
}
|
||||||
if(beginTime != null){
|
if (beginTime != null) {
|
||||||
if(!sql.toString().contains("where")){
|
if (!sql.toString().contains("where")) {
|
||||||
sql.append(" where");
|
sql.append(" where");
|
||||||
}else{
|
} else {
|
||||||
sql.append(" and");
|
sql.append(" and");
|
||||||
}
|
}
|
||||||
sql.append(" time >= '").append(beginTime).append("'");
|
sql.append(" time >= '").append(beginTime).append("'");
|
||||||
}
|
}
|
||||||
if(endTime != null){
|
if (endTime != null) {
|
||||||
if(!sql.toString().contains("where")){
|
if (!sql.toString().contains("where")) {
|
||||||
sql.append(" where");
|
sql.append(" where");
|
||||||
}else{
|
} else {
|
||||||
sql.append(" and");
|
sql.append(" and");
|
||||||
}
|
}
|
||||||
sql.append(" time <= '").append(endTime).append("'");
|
sql.append(" time <= '").append(endTime).append("'");
|
||||||
@ -300,27 +304,27 @@ public class DataQueryService implements IDataQueryService{
|
|||||||
/**
|
/**
|
||||||
* 查询长时间数据,每分钟取一条展示(最长3个月)
|
* 查询长时间数据,每分钟取一条展示(最长3个月)
|
||||||
*/
|
*/
|
||||||
private List<Map<String, Object>> selectLongTimeDataByColumnNameandDate(String equipId,String tableName, String columnName, String beginTime, String endTime, String interval){
|
private List<Map<String, Object>> selectLongTimeDataByColumnNameandDate(String equipId, String tableName, String columnName, String beginTime, String endTime, String interval) {
|
||||||
if(columnName.split(",").length > 1){
|
if (columnName.split(",").length > 1) {
|
||||||
columnName = "*";
|
columnName = "*";
|
||||||
}
|
}
|
||||||
StringBuilder sql = new StringBuilder("select time, mean(").append(columnName).append(") from ")
|
StringBuilder sql = new StringBuilder("select time, mean(").append(columnName).append(") from ")
|
||||||
.append("\"").append(tableName).append("\"");
|
.append("\"").append(tableName).append("\"");
|
||||||
if(equipId != null){
|
if (equipId != null) {
|
||||||
sql.append(" where equip_id = '").append(equipId).append("'");
|
sql.append(" where equip_id = '").append(equipId).append("'");
|
||||||
}
|
}
|
||||||
if(beginTime != null){
|
if (beginTime != null) {
|
||||||
if(!sql.toString().contains("where")){
|
if (!sql.toString().contains("where")) {
|
||||||
sql.append(" where");
|
sql.append(" where");
|
||||||
}else{
|
} else {
|
||||||
sql.append(" and");
|
sql.append(" and");
|
||||||
}
|
}
|
||||||
sql.append(" time >= '").append(beginTime).append("'");
|
sql.append(" time >= '").append(beginTime).append("'");
|
||||||
}
|
}
|
||||||
if(endTime != null){
|
if (endTime != null) {
|
||||||
if(!sql.toString().contains("where")){
|
if (!sql.toString().contains("where")) {
|
||||||
sql.append(" where");
|
sql.append(" where");
|
||||||
}else{
|
} else {
|
||||||
sql.append(" and");
|
sql.append(" and");
|
||||||
}
|
}
|
||||||
sql.append(" time <= '").append(endTime).append("'");
|
sql.append(" time <= '").append(endTime).append("'");
|
||||||
|
@ -104,6 +104,8 @@ public class NoticeController {
|
|||||||
Assert.notNull(notice, "公告不能为空");
|
Assert.notNull(notice, "公告不能为空");
|
||||||
// 直接插入站内信表
|
// 直接插入站内信表
|
||||||
notice.setId(null);
|
notice.setId(null);
|
||||||
|
notice.setCreateTime(null);
|
||||||
|
notice.setUpdateTime(null);
|
||||||
NotifyMessageDO notifyMessage = BeanUtils.toBean(notice, NotifyMessageDO.class);
|
NotifyMessageDO notifyMessage = BeanUtils.toBean(notice, NotifyMessageDO.class);
|
||||||
notifyMessage.setTemplateNickname(SecurityFrameworkUtils.getLoginUserNickname());
|
notifyMessage.setTemplateNickname(SecurityFrameworkUtils.getLoginUserNickname());
|
||||||
notifyMessage.setTemplateType(notice.getType());
|
notifyMessage.setTemplateType(notice.getType());
|
||||||
|
@ -55,17 +55,17 @@ public interface NotifyMessageMapper extends BaseMapperX<NotifyMessageDO> {
|
|||||||
|
|
||||||
default List<NotifyMessageDO> selectUnreadListByUserIdAndUserType(Long userId, Integer userType, Integer size) {
|
default List<NotifyMessageDO> selectUnreadListByUserIdAndUserType(Long userId, Integer userType, Integer size) {
|
||||||
return selectList(new QueryWrapperX<NotifyMessageDO>() // 由于要使用 limitN 语句,所以只能用 QueryWrapperX
|
return selectList(new QueryWrapperX<NotifyMessageDO>() // 由于要使用 limitN 语句,所以只能用 QueryWrapperX
|
||||||
.eq("user_id", userId)
|
// .eq("user_id", userId)
|
||||||
.eq("user_type", userType)
|
// .eq("user_type", userType)
|
||||||
.eq("read_status", false)
|
.eq("read_status", false)
|
||||||
.orderByDesc("id").limitN(size));
|
.orderByDesc("id").limitN(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
default Long selectUnreadCountByUserIdAndUserType(Long userId, Integer userType) {
|
default Long selectUnreadCountByUserIdAndUserType(Long userId, Integer userType) {
|
||||||
return selectCount(new LambdaQueryWrapperX<NotifyMessageDO>()
|
return selectCount(new LambdaQueryWrapperX<NotifyMessageDO>()
|
||||||
.eq(NotifyMessageDO::getReadStatus, false)
|
.eq(NotifyMessageDO::getReadStatus, false));
|
||||||
.eq(NotifyMessageDO::getUserId, userId)
|
// .eq(NotifyMessageDO::getUserId, userId)
|
||||||
.eq(NotifyMessageDO::getUserType, userType));
|
// .eq(NotifyMessageDO::getUserType, userType));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user