Commit fe6b1fee authored by jichao's avatar jichao

改bug

parent c432f24a
......@@ -17,12 +17,12 @@ public interface BusParamReferRepository {
/**
* 查询网关参数
* @param params proId:项目id,ownParam:项目固定参数
* @param params proId:项目id
* @return
*/
@Select("<script>select r.OTHER_PARAM from bus_param_refer r " +
"where r.PRO_ID=#{proId} and r.OWN_PARAM=#{ownParam}</script>")
@Select("<script>select r.OWN_PARAM,r.OTHER_PARAM from bus_param_refer r " +
"where r.PRO_ID=#{proId}</script>")
@ResultMap(value = "BusParamRefer")
BusParamRefer queryOtherParam(Params params);
List<BusParamRefer> queryOtherParam(Params params);
}
package org.rcisoft.business.mainte.adaptive.service.impl;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.rcisoft.business.mainte.adaptive.dao.BusParamReferRepository;
import org.rcisoft.business.mainte.adaptive.dao.BusTemperatureRepository;
import org.rcisoft.business.mainte.adaptive.dao.TotalSensorRepository;
......@@ -20,6 +21,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
/**
......@@ -53,12 +55,21 @@ public class AdaptiveServiceImpl implements AdaptiveService {
public ClimateAdaptation climateAdaptation(String proId, String year, String month, String day) {
Calendar cal = Calendar.getInstance();
//查询实际供水温度
Params params = new Params(proId, year + "-" + month + "-" + day, ProEnum.gswd.toString(), null);
Params params = new Params(proId, year + "-" + month + "-" + day, null);
//1.从sensor表查询对应日期的所有记录
List<TotalSensor> totalSensorList = totalSensorRepository.queryTotalSensorList(params);
//2.从bus_param_refer表查询“实际供水温度”对应的code
BusParamRefer busParamRefer = busParamReferRepository.queryOtherParam(params);
String otherParam = busParamRefer.getOtherParam();
String[] code_array = new String[]{""};
String gswd_code = ProEnum.gswd.toString();
List<BusParamRefer> busParamReferList = busParamReferRepository.queryOtherParam(params);
Iterator<BusParamRefer> it = busParamReferList.iterator();
while (it.hasNext()) {
BusParamRefer busParamRefer = it.next();
if(StringUtils.equals(gswd_code, busParamRefer.getOwnParam())){
code_array[0] = busParamRefer.getOtherParam();
break;
}
}
//3.取出数据中的整点记录,根据温度的code将数据取出,放入结果中
List<Object> realList = Arrays.asList(new Object[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
//循环
......@@ -71,7 +82,7 @@ public class AdaptiveServiceImpl implements AdaptiveService {
//得到json对象
JSONObject json = JSONObject.parseObject(totalSensor.getSensorJson());
//得到供水温度
Object gswd = json.get(otherParam);
Object gswd = json.get(code_array[0]);
realList.set(hour, gswd);
}
});
......@@ -109,7 +120,7 @@ public class AdaptiveServiceImpl implements AdaptiveService {
@Override
public BuildingAdaptation buildingAdaptation(String proId, String year, String month, String day) {
Calendar cal = Calendar.getInstance();
Params params = new Params(proId, year + "-" + month + "-" + day, null, this.getCode(proId));
Params params = new Params(proId, year + "-" + month + "-" + day, this.getCode(proId));
//查询室外温度
List<BusTemperature> busTemperaturesList = busTemperatureRepository.queryBusTemperatureList(params);
List<Object> temperatureList = Arrays.asList(new Object[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
......@@ -120,18 +131,13 @@ public class AdaptiveServiceImpl implements AdaptiveService {
temperatureList.set(hour, temperature);
});
//查询建筑负荷:供水温度,回水温度,水流量
params.setOwnParam(ProEnum.gswd.toString());
BusParamRefer busParamRefer = busParamReferRepository.queryOtherParam(params);
//供水温度
String gswd_code = busParamRefer == null ? "" : busParamRefer.getOtherParam();
//回水温度
params.setOwnParam(ProEnum.hswd.toString());
busParamRefer = busParamReferRepository.queryOtherParam(params);
String hswd_code = busParamRefer == null ? "" : busParamRefer.getOtherParam();
//水流量
params.setOwnParam(ProEnum.sll.toString());
busParamRefer = busParamReferRepository.queryOtherParam(params);
String sll_code = busParamRefer == null ? "" : busParamRefer.getOtherParam();
String[] code_array = new String[]{"", "", ""};
List<BusParamRefer> busParamRefer = busParamReferRepository.queryOtherParam(params);
busParamRefer.forEach(b -> {
if(StringUtils.equals(b.getOwnParam(), ProEnum.gswd.toString())) code_array[0] = b.getOtherParam();
if(StringUtils.equals(b.getOwnParam(), ProEnum.hswd.toString())) code_array[1] = b.getOtherParam();
if(StringUtils.equals(b.getOwnParam(), ProEnum.sll.toString())) code_array[2] = b.getOtherParam();
});
//从sensor表查询对应日期的所有记录
List<TotalSensor> totalSensorList = totalSensorRepository.queryTotalSensorList(params);
List<Object> buildingList = Arrays.asList(new Object[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
......@@ -144,11 +150,11 @@ public class AdaptiveServiceImpl implements AdaptiveService {
//得到json对象
JSONObject json = JSONObject.parseObject(totalSensor.getSensorJson());
//供水温度
BigDecimal gswd = (BigDecimal) json.get(gswd_code);
BigDecimal gswd = (BigDecimal) json.get(code_array[0]);
//回水温度
BigDecimal hswd = (BigDecimal) json.get(hswd_code);
BigDecimal hswd = (BigDecimal) json.get(code_array[1]);
//水流量
BigDecimal sll = (BigDecimal) json.get(sll_code);
BigDecimal sll = (BigDecimal) json.get(code_array[2]);
//公式计算
Float building = Math.abs(gswd.subtract(hswd).multiply(sll).multiply(new BigDecimal(4.12)).divide(new BigDecimal(3.6), 1, BigDecimal.ROUND_HALF_UP).floatValue());
buildingList.set(hour, building);
......
......@@ -14,7 +14,6 @@ public class Params {
private String proId;
private String time;
private String ownParam;
private String code;
}
......@@ -12,7 +12,7 @@
DATE_FORMAT (bdi.INSP_TM,'%Y-%m-%d %H:%i:%S') AS INSP_TM
FROM
bus_device bd
RIGHT JOIN bus_device_inspect bdi ON bd.DEV_NUM = bdi.DEV_NUM
RIGHT JOIN bus_device_inspect bdi ON bd.DEV_ID = bdi.DEV_ID
LEFT JOIN bus_device_tp bdt ON bd.DEV_TP_ID = bdt.DEV_TP_ID
WHERE
bdi.FLAG = #{flag}
......@@ -28,9 +28,9 @@
DATE_FORMAT (bdi.INSP_TM,'%Y-%m-%d %H:%i:%S') AS INSP_TM
FROM
bus_device bd
RIGHT JOIN bus_device_inspect bdi ON bd.DEV_NUM = bdi.DEV_NUM
RIGHT JOIN bus_device_inspect bdi ON bd.DEV_ID = bdi.DEV_ID
LEFT JOIN bus_device_tp bdt ON bd.DEV_TP_ID = bdt.DEV_TP_ID
WHERE
bd.PRO_ID = #{proId} AND bdi.DEV_NUM = #{devNum}
bd.PRO_ID = #{proId} AND bd.DEV_NUM = #{devNum}
</select>
</mapper>
\ No newline at end of file
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