添加采集热量水流量功能
This commit is contained in:
parent
ec5ca72d97
commit
664424f52f
|
|
@ -54,7 +54,7 @@ public class AnalysisRule implements Serializable {
|
|||
@Excel(name = "热力公司ID", width = 15, dictTable = "bl_thermalcompany", dicText = "company_name", dicCode = "id")
|
||||
@Dict(dictTable = "bl_thermalcompany", dicText = "company_name", dicCode = "id")
|
||||
@ApiModelProperty(value = "热力公司ID")
|
||||
private java.lang.Integer companyId;
|
||||
private java.lang.String companyId;
|
||||
/**热力公司*/
|
||||
@Excel(name = "热力公司", width = 15)
|
||||
@ApiModelProperty(value = "热力公司")
|
||||
|
|
@ -63,7 +63,7 @@ public class AnalysisRule implements Serializable {
|
|||
@Excel(name = "锅炉房ID", width = 15, dictTable = "bl_heatsource", dicText = "source_name", dicCode = "id")
|
||||
@Dict(dictTable = "bl_heatsource", dicText = "source_name", dicCode = "id")
|
||||
@ApiModelProperty(value = "锅炉房ID")
|
||||
private java.lang.Integer sourceId;
|
||||
private java.lang.String sourceId;
|
||||
/**锅炉房*/
|
||||
@Excel(name = "锅炉房", width = 15)
|
||||
@ApiModelProperty(value = "锅炉房")
|
||||
|
|
@ -72,7 +72,7 @@ public class AnalysisRule implements Serializable {
|
|||
@Excel(name = "换热站ID", width = 15, dictTable = "bl_heatsourcestation", dicText = "station_name", dicCode = "id")
|
||||
@Dict(dictTable = "bl_heatsourcestation", dicText = "station_name", dicCode = "id")
|
||||
@ApiModelProperty(value = "换热站ID")
|
||||
private java.lang.Integer stationId;
|
||||
private java.lang.String stationId;
|
||||
/**换热站*/
|
||||
@Excel(name = "换热站", width = 15)
|
||||
@ApiModelProperty(value = "换热站")
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
package org.jeecg.modules.heating.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecg.common.system.base.entity.JeecgEntity;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
|
@ -17,10 +21,25 @@ import org.springframework.format.annotation.DateTimeFormat;
|
|||
*/
|
||||
@Data
|
||||
@TableName("bl_heatanalysis")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Heatanalysis extends JeecgEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableField(exist = false)
|
||||
private java.lang.String createBy;
|
||||
@TableField(exist = false)
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date createTime;
|
||||
@TableField(exist = false)
|
||||
private java.lang.String updateBy;
|
||||
@TableField(exist = false)
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Excel(name="热力公司", width = 15)
|
||||
private String view001Name;//公司名称
|
||||
|
|
|
|||
|
|
@ -0,0 +1,192 @@
|
|||
package org.jeecg.modules.heating.job;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.heating.entity.Heatanalysis;
|
||||
import org.jeecg.modules.heating.service.HeatanalysisService;
|
||||
import org.jeecg.modules.waterFlowConfig.entity.BlWaterFlowConfig;
|
||||
import org.jeecg.modules.waterFlowConfig.service.IBlWaterFlowConfigService;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
/**
|
||||
* 发送消息任务
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public class FlowanalysisJob implements Job {
|
||||
|
||||
@Autowired
|
||||
private HeatanalysisService heatanalysisService;
|
||||
|
||||
@Autowired
|
||||
private IBlWaterFlowConfigService WaterFlowConfigService;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
|
||||
log.info(String.format("获取热量水流量数据 ! 时间:" + DateUtils.getTimestamp()));
|
||||
QueryWrapper<BlWaterFlowConfig> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("del_flag","0");
|
||||
List<BlWaterFlowConfig> list = WaterFlowConfigService.list(queryWrapper);
|
||||
for(BlWaterFlowConfig config : list){
|
||||
try{
|
||||
String sn = config.getSn();
|
||||
String json = getWebInfo(sn);
|
||||
if(StringUtils.equals(json,"false")) continue;
|
||||
JSONObject jsonObject = new JSONObject(json);
|
||||
log.info("jsonObject:"+jsonObject);
|
||||
String success = jsonObject.getStr("success");
|
||||
if(StringUtils.equals(success,"true")){
|
||||
QueryWrapper<Heatanalysis> heatanalysisQueryWrapper = new QueryWrapper<>();
|
||||
heatanalysisQueryWrapper.eq("view031",sn);
|
||||
heatanalysisQueryWrapper.last("limit 1");
|
||||
Heatanalysis heatanalysis = heatanalysisService.getOne(heatanalysisQueryWrapper);
|
||||
if(heatanalysis != null){
|
||||
String view032_old = heatanalysis.getView032();
|
||||
String data = jsonObject.getStr("data");
|
||||
JSONObject dataObject = new JSONObject(data);
|
||||
String view032 = dataObject.getStr("logat");
|
||||
if(StringUtils.equals(view032,view032_old)){
|
||||
log.info("--------数据重复---------");
|
||||
continue;
|
||||
}
|
||||
String view033 = dataObject.getStr("ID");
|
||||
String view034 = dataObject.getStr("valid");
|
||||
String view035 = dataObject.getStr("gswd");
|
||||
String view036 = dataObject.getStr("hswd");
|
||||
String view037 = dataObject.getStr("flowRate");
|
||||
String view037_2 = dataObject.getStr("ssll");
|
||||
String view038 = dataObject.getStr("pflowAccumulator");
|
||||
String view038_2 = dataObject.getStr("zljll");
|
||||
String view039 = dataObject.getStr("nflowAccumulator");
|
||||
String view039_2 = dataObject.getStr("fljll");
|
||||
String view040 = dataObject.getStr("netflowAccumulator");
|
||||
String view040_2 = dataObject.getStr("jljll");
|
||||
String view041 = dataObject.getStr("ssrl");
|
||||
String view042 = dataObject.getStr("zljrl");
|
||||
String view043 = dataObject.getStr("fljrl");
|
||||
String view044 = dataObject.getStr("jljrl");
|
||||
String view045 = dataObject.getStr("ltsd");
|
||||
String view046 = dataObject.getStr("n");
|
||||
String view047 = dataObject.getStr("m");
|
||||
heatanalysis.setView031(sn);
|
||||
heatanalysis.setView032(view032);
|
||||
heatanalysis.setView033(view033);
|
||||
heatanalysis.setView034(view034);
|
||||
heatanalysis.setView035(view035);
|
||||
heatanalysis.setView036(view036);
|
||||
if (StringUtils.isEmpty(view037)){
|
||||
heatanalysis.setView037(view037_2);
|
||||
}else{
|
||||
heatanalysis.setView037(view037);
|
||||
}
|
||||
if (StringUtils.isEmpty(view038)){
|
||||
heatanalysis.setView038(view038_2);
|
||||
}else{
|
||||
heatanalysis.setView038(view038);
|
||||
}
|
||||
if (StringUtils.isEmpty(view039)){
|
||||
heatanalysis.setView039(view039_2);
|
||||
}else{
|
||||
heatanalysis.setView039(view039);
|
||||
}
|
||||
if (StringUtils.isEmpty(view040)){
|
||||
heatanalysis.setView040(view040_2);
|
||||
}else{
|
||||
heatanalysis.setView040(view040);
|
||||
}
|
||||
heatanalysis.setView041(view041);
|
||||
heatanalysis.setView042(view042);
|
||||
heatanalysis.setView043(view043);
|
||||
heatanalysis.setView044(view044);
|
||||
heatanalysis.setView045(view045);
|
||||
heatanalysis.setView046(view046);
|
||||
heatanalysis.setView047(view047);
|
||||
heatanalysisService.exeWater(heatanalysis);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String getWebInfo(String sn) {
|
||||
String result = "false";
|
||||
try {
|
||||
// 1. 创建URL对象
|
||||
URL url = new URL("http://49.235.190.102:8068/api/v1/feeding/snap/b501a6e0-d23f-4282-8fab-78661bf999e7/"+sn);
|
||||
|
||||
// 2. 打开连接,转换为HttpURLConnection
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
// 3. 设置请求方法为GET
|
||||
connection.setRequestMethod("GET");
|
||||
|
||||
// 4. 可选:设置请求头(例如,指定期望的响应内容类型)
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
|
||||
// 5. 获取响应代码
|
||||
int responseCode = connection.getResponseCode();
|
||||
System.out.println("Response Code: " + responseCode);
|
||||
|
||||
// 6. 如果响应成功(200 OK),读取响应体
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
// 使用BufferedReader读取输入流
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuilder response = new StringBuilder();
|
||||
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close(); // 关闭流
|
||||
|
||||
// 打印响应结果
|
||||
log.info(String.format("获取热量水流量数据 - Response Body:" + response.toString()));
|
||||
result = response.toString();
|
||||
} else {
|
||||
log.error(String.format("获取热量水流量数据 - GET request failed."));
|
||||
result = "false";
|
||||
}
|
||||
|
||||
// 7. 断开连接
|
||||
connection.disconnect();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
result = "false";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -21,4 +21,6 @@ public interface HeatanalysisMapper extends BaseMapper<Heatanalysis> {
|
|||
Page<Heatanalysis> findTwoPage(Page<Heatanalysis> page, @Param("params") Heatanalysis heatanalysis);
|
||||
Page<Heatanalysis> findExtractedOnePage(Page<Heatanalysis> page, @Param("params") Heatanalysis heatanalysis);
|
||||
Page<Heatanalysis> findExtractedTwoPage(Page<Heatanalysis> page, @Param("params") Heatanalysis heatanalysis);
|
||||
|
||||
void exeWater(Heatanalysis heatanalysis);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,6 +285,10 @@
|
|||
CALL P_Q_D_HEATANALYSIS_SIMULATE_NEW(#{code}, #{sim}, #{datatime}, #{view005}, #{view006}, #{view007}, #{view008}, #{view009}, #{view010}, #{view011}, #{view012})
|
||||
</insert>
|
||||
|
||||
<insert id="exeWater">
|
||||
CALL P_Q_D_HEATFLOWANALYSIS(#{view031}, #{view032}, #{view033}, #{view034}, #{view035}, #{view036}, #{view037}, #{view038}, #{view039}, #{view040}, #{view041}, #{view042}, #{view043}, #{view044}, #{view045}, #{view046}, #{view047})
|
||||
</insert>
|
||||
|
||||
<select id="lowest" resultType="org.jeecg.modules.heating.entity.Heatanalysis">
|
||||
SELECT * FROM (
|
||||
SELECT * FROM ${tableName} a
|
||||
|
|
|
|||
|
|
@ -22,4 +22,6 @@ public interface HeatanalysisService extends JeecgService<Heatanalysis> {
|
|||
IPage<Heatanalysis> findTwoPage(Page<Heatanalysis> page, Heatanalysis heatanalysis);
|
||||
IPage<Heatanalysis> findExtractedOnePage(Page<Heatanalysis> page, Heatanalysis heatanalysis);
|
||||
IPage<Heatanalysis> findExtractedTwoPage(Page<Heatanalysis> page, Heatanalysis heatanalysis);
|
||||
|
||||
void exeWater(Heatanalysis heatanalysis);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,4 +82,9 @@ public class HeatanalysisServiceImpl extends JeecgServiceImpl<HeatanalysisMapper
|
|||
return baseMapper.findExtractedTwoPage(page,heatanalysis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exeWater(Heatanalysis heatanalysis) {
|
||||
baseMapper.exeWater(heatanalysis);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,21 +52,21 @@ public class BlWaterFlowConfig implements Serializable {
|
|||
@Excel(name = "公司名称", width = 15, dictTable = "bl_thermalcompany", dicText = "company_name", dicCode = "id")
|
||||
@Dict(dictTable = "bl_thermalcompany", dicText = "company_name", dicCode = "id")
|
||||
@ApiModelProperty(value = "公司名称")
|
||||
private java.lang.Integer companyCompanyId;
|
||||
private java.lang.String companyCompanyId;
|
||||
/**热源名称*/
|
||||
@Excel(name = "热源名称", width = 15, dictTable = "bl_heatsource", dicText = "source_name", dicCode = "id")
|
||||
@Dict(dictTable = "bl_heatsource", dicText = "source_name", dicCode = "id")
|
||||
@ApiModelProperty(value = "热源名称")
|
||||
private java.lang.Integer sourceSourceId;
|
||||
private java.lang.String sourceSourceId;
|
||||
/**换热站名称*/
|
||||
@Excel(name = "换热站名称", width = 15, dictTable = "bl_heatsourcestation", dicText = "station_name", dicCode = "id")
|
||||
@Dict(dictTable = "bl_heatsourcestation", dicText = "station_name", dicCode = "id")
|
||||
@ApiModelProperty(value = "换热站名称")
|
||||
private java.lang.Integer stationStationId;
|
||||
private java.lang.String stationStationId;
|
||||
/**热力分所名称*/
|
||||
@Excel(name = "热力分所名称", width = 15)
|
||||
@ApiModelProperty(value = "热力分所名称")
|
||||
private java.lang.Integer substationId;
|
||||
private java.lang.String substationId;
|
||||
/**创建者*/
|
||||
@ApiModelProperty(value = "创建者")
|
||||
private java.lang.String createBy;
|
||||
|
|
|
|||
Loading…
Reference in New Issue