|
|
|
@ -48,15 +48,17 @@ public class PsdcStrategyLogService implements IPsdcStrategyLogService { |
|
|
|
|
public List<PsdcStrategyLog> selMyStrategyLog() { |
|
|
|
|
Long userId = SecurityUtils.getUserId(); |
|
|
|
|
List<PsdcStrategyLog> logList = strategyLogMapper.selMyStrategyLog(userId); |
|
|
|
|
for (PsdcStrategyLog psl : logList){ // 策略层
|
|
|
|
|
// 策略层
|
|
|
|
|
for (PsdcStrategyLog psl : logList) { |
|
|
|
|
Long code = psl.getStrategyCode(); |
|
|
|
|
PsdcStrategy res ; |
|
|
|
|
PsdcStrategy res; |
|
|
|
|
Double strategyUseEnergy = 0.0; |
|
|
|
|
List<PsdcStrategy> strategyList = strategyMapper.queryByUser(userId, code); |
|
|
|
|
if (null != strategyList && strategyList.size() > 0){ |
|
|
|
|
if (null != strategyList && strategyList.size() > 0) { |
|
|
|
|
res = strategyList.get(0); |
|
|
|
|
String[] split = res.getScenes().split(","); |
|
|
|
|
for (String s : split){ // 步骤层【1个步骤1个设备】
|
|
|
|
|
// 步骤层【1个步骤1个设备】
|
|
|
|
|
for (String s : split) { |
|
|
|
|
List<SceneVo> sceneVos = sceneMapper.findSceneByUserAndSceneCode(userId, Long.parseLong(s), null); |
|
|
|
|
// for (SceneVo sv : sceneVos) { // 设备层
|
|
|
|
|
// Integer deviceId = sv.getDeviceId();
|
|
|
|
@ -72,27 +74,27 @@ public class PsdcStrategyLogService implements IPsdcStrategyLogService { |
|
|
|
|
|
|
|
|
|
Double jssc = jssc(sdf, psl.getStartTime(), psl.getEndTime()); |
|
|
|
|
String runHours = df.format(jssc); |
|
|
|
|
if (".".equals(runHours.substring(0,1))){ |
|
|
|
|
runHours= "0" + runHours; |
|
|
|
|
if (".".equals(runHours.substring(0, 1))) { |
|
|
|
|
runHours = "0" + runHours; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// System.out.println("策略执行用时长: " + jssc + "。\n");
|
|
|
|
|
psl.setRunHours(runHours); |
|
|
|
|
psl.setSceneUseEnergy(strategyUseEnergy); |
|
|
|
|
double v = 0.0; |
|
|
|
|
if (jssc > 0.0){ |
|
|
|
|
v = strategyUseEnergy / jssc; // 时长空判断处理
|
|
|
|
|
if (jssc > 0.0) { |
|
|
|
|
// 时长空判断处理
|
|
|
|
|
v = strategyUseEnergy / jssc; |
|
|
|
|
} |
|
|
|
|
// System.out.println("触发 = " + v + "\n");
|
|
|
|
|
String s = df.format(v); |
|
|
|
|
if (".".equals(s.substring(0,1))){ |
|
|
|
|
s= "0" + s; |
|
|
|
|
if (".".equals(s.substring(0, 1))) { |
|
|
|
|
s = "0" + s; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
psl.setOneUseEnergy(s); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Date date ; |
|
|
|
|
Date date; |
|
|
|
|
try { |
|
|
|
|
date = sdf.parse(psl.getStartTime()); |
|
|
|
|
} catch (ParseException e) { |
|
|
|
@ -120,7 +122,7 @@ public class PsdcStrategyLogService implements IPsdcStrategyLogService { |
|
|
|
|
return logList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void getaDouble(int count, List<Double> listTemp, List<String> times, List<PsdcThermometerHtdata> tempList) { |
|
|
|
|
private void getaDouble(int count, List<Double> listTemp, List<String> times, List<PsdcThermometerHtdata> tempList) { |
|
|
|
|
if (tempList.size() == 0) { |
|
|
|
|
count = 1; |
|
|
|
|
} |
|
|
|
@ -130,14 +132,14 @@ public class PsdcStrategyLogService implements IPsdcStrategyLogService { |
|
|
|
|
PsdcThermometerHtdata scr1 = tempList.get(i); |
|
|
|
|
long time2 = sdf.parse(scr1.getUpdateTime()).getTime(); |
|
|
|
|
long time3 = time2 - time1; |
|
|
|
|
if(time3 >= 900000){ |
|
|
|
|
if (time3 >= 900000) { |
|
|
|
|
Double evIn = scr1.getThermometerValue() / count; |
|
|
|
|
listTemp.add(Double.parseDouble(df.format(evIn))); |
|
|
|
|
times.add(scr1.getUpdateTime().split(" ")[1].substring(0,5)); |
|
|
|
|
times.add(scr1.getUpdateTime().split(" ")[1].substring(0, 5)); |
|
|
|
|
time1 = sdf.parse(scr1.getUpdateTime()).getTime(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e){ |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -156,7 +158,7 @@ public class PsdcStrategyLogService implements IPsdcStrategyLogService { |
|
|
|
|
@Override |
|
|
|
|
public PsdcStrategyLog selMyRunStrategy() { |
|
|
|
|
PsdcStrategyLog strategyLog = strategyLogMapper.selMyRunStrategy(SecurityUtils.getUserId(), 2); |
|
|
|
|
if (null != strategyLog){ |
|
|
|
|
if (null != strategyLog) { |
|
|
|
|
String[] split = strategyLog.getRunSceneCodes().split(","); |
|
|
|
|
String code = split[split.length - 1]; |
|
|
|
|
List<PsdcScene> scenes = sceneMapper.queryBySceneCode(Integer.parseInt(code)); |
|
|
|
@ -168,11 +170,17 @@ public class PsdcStrategyLogService implements IPsdcStrategyLogService { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Double jssc(SimpleDateFormat dfs, String start, String end){ |
|
|
|
|
public Double jssc(SimpleDateFormat dfs, String start, String end) { |
|
|
|
|
try { |
|
|
|
|
Double d1 = Double.valueOf(dfs.parse(start).getTime()); |
|
|
|
|
Double d2 = Double.valueOf(dfs.parse(end).getTime()); |
|
|
|
|
Double between = (d2 - d1)/1000/3600; |
|
|
|
|
double d1 = 0.0; |
|
|
|
|
if (null != start && !"".equals(start)) { |
|
|
|
|
d1 = (double) dfs.parse(start).getTime(); |
|
|
|
|
} |
|
|
|
|
double d2 = 0.0; |
|
|
|
|
if (null != end && !"".equals(end)) { |
|
|
|
|
d2 = (double) dfs.parse(end).getTime(); |
|
|
|
|
} |
|
|
|
|
double between = (d2 - d1) / 1000 / 3600; |
|
|
|
|
return between; |
|
|
|
|
} catch (ParseException pe) { |
|
|
|
|
pe.printStackTrace(); |
|
|
|
|