|
|
|
@ -2,12 +2,14 @@ package com.mh.user.controller;
|
|
|
|
|
|
|
|
|
|
import com.mh.common.http.HttpResult; |
|
|
|
|
import com.mh.user.annotation.SysLogger; |
|
|
|
|
import com.mh.user.entity.BuildingEntity; |
|
|
|
|
import com.mh.user.entity.EnergyEntity; |
|
|
|
|
import com.mh.user.model.SumModel; |
|
|
|
|
import com.mh.user.service.BuildingService; |
|
|
|
|
import com.mh.user.service.EnergyService; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
@ -23,192 +25,196 @@ public class EnergyController {
|
|
|
|
|
@Autowired |
|
|
|
|
BuildingService buildingService; |
|
|
|
|
|
|
|
|
|
@SysLogger(title="用能分析",optDesc = "保存能耗信息") |
|
|
|
|
@SysLogger(title = "用能分析", optDesc = "保存能耗信息") |
|
|
|
|
@PostMapping("/save") |
|
|
|
|
public HttpResult saveEnergy(@RequestBody EnergyEntity energyEntity, @RequestParam(value = "type") int type){ |
|
|
|
|
try{ |
|
|
|
|
energyService.saveEnergy(energyEntity,type); |
|
|
|
|
return HttpResult.ok(); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
return HttpResult.error("保存出错!"); |
|
|
|
|
} |
|
|
|
|
public HttpResult saveEnergy(@RequestBody EnergyEntity energyEntity, @RequestParam(value = "type") int type) { |
|
|
|
|
try { |
|
|
|
|
energyService.saveEnergy(energyEntity, type); |
|
|
|
|
return HttpResult.ok(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return HttpResult.error("保存出错!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SysLogger(title="用能分析",optDesc = "修改能耗信息") |
|
|
|
|
@SysLogger(title = "用能分析", optDesc = "修改能耗信息") |
|
|
|
|
@PostMapping("/update") |
|
|
|
|
public HttpResult updateEnergy(@RequestBody EnergyEntity energyEntity, @RequestParam(value = "type") int type){ |
|
|
|
|
try{ |
|
|
|
|
energyService.updateEnergy(energyEntity,type); |
|
|
|
|
return HttpResult.ok(); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
return HttpResult.error("修改出错!"); |
|
|
|
|
public HttpResult updateEnergy(@RequestBody EnergyEntity energyEntity, @RequestParam(value = "type") int type) { |
|
|
|
|
try { |
|
|
|
|
energyService.updateEnergy(energyEntity, type); |
|
|
|
|
return HttpResult.ok(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return HttpResult.error("修改出错!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@PostMapping("/delete") |
|
|
|
|
@SysLogger(title="用能分析",optDesc = "删除能耗信息") |
|
|
|
|
@SysLogger(title = "用能分析", optDesc = "删除能耗信息") |
|
|
|
|
public HttpResult deleteEnergy(@RequestParam(value = "curDate") String curDate, |
|
|
|
|
@RequestParam(value = "buildingId") String buildingId, |
|
|
|
|
@RequestParam(value = "type") int type){ |
|
|
|
|
try{ |
|
|
|
|
@RequestParam(value = "type") int type) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
energyService.deleteEnergy(curDate,buildingId,type); |
|
|
|
|
return HttpResult.ok(); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
return HttpResult.error("删除出错!"); |
|
|
|
|
energyService.deleteEnergy(curDate, buildingId, type); |
|
|
|
|
return HttpResult.ok(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
return HttpResult.error("删除出错!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SysLogger(title="用能分析",optDesc = "查询能耗信息") |
|
|
|
|
@SysLogger(title = "用能分析", optDesc = "查询能耗信息") |
|
|
|
|
@PostMapping("/query") |
|
|
|
|
public HttpResult queryEnergy(@RequestParam(value = "buildingId",required = false) String buildingId, |
|
|
|
|
@RequestParam(value = "startDate",required = false) String startDate, |
|
|
|
|
@RequestParam(value = "endDate",required = false) String endDate, |
|
|
|
|
public HttpResult queryEnergy(@RequestParam(value = "buildingId", required = false) String buildingId, |
|
|
|
|
@RequestParam(value = "startDate", required = false) String startDate, |
|
|
|
|
@RequestParam(value = "endDate", required = false) String endDate, |
|
|
|
|
@RequestParam(value = "level", required = false, defaultValue = "0") int level, |
|
|
|
|
@RequestParam(value = "page") int page, |
|
|
|
|
@RequestParam(value = "limit") int limit, |
|
|
|
|
@RequestParam(value = "type") int type){ |
|
|
|
|
try{ |
|
|
|
|
String areaId=""; |
|
|
|
|
if (buildingId!=null && buildingId.length()>0){ |
|
|
|
|
if (!buildingId.equals("所有")){ |
|
|
|
|
areaId=buildingService.queryAreaId(Integer.parseInt(buildingId)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
List<EnergyEntity> list=new ArrayList<>(); |
|
|
|
|
int count=0; |
|
|
|
|
if (areaId!=null && areaId.length()>0){ |
|
|
|
|
list=energyService.queryEnergy(areaId,startDate,endDate,page,limit,type); |
|
|
|
|
count=energyService.getEnergyCount(areaId,startDate,endDate,page,limit,type); |
|
|
|
|
}else{ |
|
|
|
|
list=energyService.queryEnergy(buildingId,startDate,endDate,page,limit,type); |
|
|
|
|
count=energyService.getEnergyCount(buildingId,startDate,endDate,page,limit,type); |
|
|
|
|
} |
|
|
|
|
@RequestParam(value = "type") int type) { |
|
|
|
|
try { |
|
|
|
|
// String areaId="";
|
|
|
|
|
// if (buildingId!=null && buildingId.length()>0){
|
|
|
|
|
// if (!buildingId.equals("所有")){
|
|
|
|
|
// areaId=buildingService.queryAreaId(Integer.parseInt(buildingId));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
List<EnergyEntity> list = new ArrayList<>(); |
|
|
|
|
int count = 0; |
|
|
|
|
// if (areaId!=null && areaId.length()>0){
|
|
|
|
|
list = energyService.queryEnergy(buildingId, startDate, endDate, page, limit, type, level); |
|
|
|
|
count = energyService.getEnergyCount(buildingId, startDate, endDate, page, limit, type, level); |
|
|
|
|
// }else{
|
|
|
|
|
// list=energyService.queryEnergy(buildingId,startDate,endDate,page,limit,type, level);
|
|
|
|
|
// count=energyService.getEnergyCount(buildingId,startDate,endDate,page,limit,type, level);
|
|
|
|
|
// }
|
|
|
|
|
// System.out.println("返回前端数据:"+list);
|
|
|
|
|
return HttpResult.ok(count,list); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
return HttpResult.ok(count, list); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//主界面水、电、单耗查询
|
|
|
|
|
@SysLogger(title="项目概况",optDesc = "查询能耗信息") |
|
|
|
|
@SysLogger(title = "项目概况", optDesc = "查询能耗信息") |
|
|
|
|
@PostMapping("/queryGroup") |
|
|
|
|
public HttpResult queryEnergyGroup(@RequestParam(value = "curDate",required = true) String curDate, |
|
|
|
|
@RequestParam(value = "type",required = true,defaultValue = "1") int type){ |
|
|
|
|
try{ |
|
|
|
|
List<EnergyEntity> list=new ArrayList<EnergyEntity>(); |
|
|
|
|
list=energyService.queryEnergyGroup(curDate,type); |
|
|
|
|
return HttpResult.ok(list); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
public HttpResult queryEnergyGroup(@RequestParam(value = "curDate", required = true) String curDate, |
|
|
|
|
@RequestParam(value = "type", required = true, defaultValue = "1") int type) { |
|
|
|
|
try { |
|
|
|
|
List<EnergyEntity> list = new ArrayList<EnergyEntity>(); |
|
|
|
|
list = energyService.queryEnergyGroup(curDate, type); |
|
|
|
|
return HttpResult.ok(list); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查询每天的用量
|
|
|
|
|
@SysLogger(title="用能分析",optDesc = "查询每天的用量") |
|
|
|
|
@SysLogger(title = "用能分析", optDesc = "查询每天的用量") |
|
|
|
|
@PostMapping("/queryDay") |
|
|
|
|
public HttpResult queryDayEnergy(@RequestParam(value = "buildingId",required = false) String buildingId, |
|
|
|
|
@RequestParam(value = "startDate",required = false) String startDate, |
|
|
|
|
@RequestParam(value = "endDate",required = false) String endDate, |
|
|
|
|
public HttpResult queryDayEnergy(@RequestParam(value = "buildingId", required = false) String buildingId, |
|
|
|
|
@RequestParam(value = "startDate", required = false) String startDate, |
|
|
|
|
@RequestParam(value = "endDate", required = false) String endDate, |
|
|
|
|
@RequestParam(value = "page") int page, |
|
|
|
|
@RequestParam(value = "limit") int limit){ |
|
|
|
|
try{ |
|
|
|
|
String areaId=""; |
|
|
|
|
if (buildingId!=null && buildingId.length()>0){ |
|
|
|
|
if (!buildingId.equals("所有")){ |
|
|
|
|
areaId=buildingService.queryAreaId(Integer.parseInt(buildingId)); |
|
|
|
|
@RequestParam(value = "limit") int limit) { |
|
|
|
|
try { |
|
|
|
|
String areaId = ""; |
|
|
|
|
if (buildingId != null && buildingId.length() > 0) { |
|
|
|
|
if (!buildingId.equals("所有")) { |
|
|
|
|
areaId = buildingService.queryAreaId(Integer.parseInt(buildingId)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
List<EnergyEntity> list; |
|
|
|
|
int count=0; |
|
|
|
|
if (areaId!=null && areaId.length()>0){ |
|
|
|
|
list=energyService.queryDayEnergy(areaId,startDate,endDate,page,limit); |
|
|
|
|
count=energyService.getDayEnergyCount(areaId,startDate,endDate,page,limit); |
|
|
|
|
}else{ |
|
|
|
|
list=energyService.queryDayEnergy(buildingId,startDate,endDate,page,limit); |
|
|
|
|
count=energyService.getDayEnergyCount(buildingId,startDate,endDate,page,limit); |
|
|
|
|
int count = 0; |
|
|
|
|
if (areaId != null && areaId.length() > 0) { |
|
|
|
|
list = energyService.queryDayEnergy(areaId, startDate, endDate, page, limit); |
|
|
|
|
count = energyService.getDayEnergyCount(areaId, startDate, endDate, page, limit); |
|
|
|
|
} else { |
|
|
|
|
list = energyService.queryDayEnergy(buildingId, startDate, endDate, page, limit); |
|
|
|
|
count = energyService.getDayEnergyCount(buildingId, startDate, endDate, page, limit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return HttpResult.ok(count,list); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
return HttpResult.ok(count, list); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查询小时的用量
|
|
|
|
|
@SysLogger(title="用能分析",optDesc = "查询小时的用量") |
|
|
|
|
@SysLogger(title = "用能分析", optDesc = "查询小时的用量") |
|
|
|
|
@PostMapping("/queryHour") |
|
|
|
|
public HttpResult queryHourEnergy(@RequestParam(value = "buildingId",required = false) String buildingId, |
|
|
|
|
@RequestParam(value = "curDate",required = false) String curDate, |
|
|
|
|
@RequestParam(value = "page") int page, |
|
|
|
|
@RequestParam(value = "limit") int limit){ |
|
|
|
|
try{ |
|
|
|
|
String areaId=""; |
|
|
|
|
if (buildingId!=null && buildingId.length()>0){ |
|
|
|
|
if (!buildingId.equals("所有")){ |
|
|
|
|
areaId=buildingService.queryAreaId(Integer.parseInt(buildingId)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
public HttpResult queryHourEnergy(@RequestParam(value = "buildingId", required = false) String buildingId, |
|
|
|
|
@RequestParam(value = "curDate", required = false) String curDate, |
|
|
|
|
@RequestParam(value = "level", required = false, defaultValue = "0") int level, |
|
|
|
|
@RequestParam(value = "page") int page, |
|
|
|
|
@RequestParam(value = "limit") int limit) { |
|
|
|
|
try { |
|
|
|
|
// String areaId = "";
|
|
|
|
|
// if (buildingId != null && buildingId.length() > 0) {
|
|
|
|
|
// if (!buildingId.equals("所有")) {
|
|
|
|
|
// areaId = buildingService.queryAreaId(Integer.parseInt(buildingId));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
List<EnergyEntity> list; |
|
|
|
|
int count=0; |
|
|
|
|
if (areaId!=null && areaId.length()>0){ |
|
|
|
|
list=energyService.queryHourEnergy(areaId,curDate,page,limit); |
|
|
|
|
count=energyService.getHourEnergyCount(areaId,curDate); |
|
|
|
|
}else{ |
|
|
|
|
list=energyService.queryHourEnergy(buildingId,curDate,page,limit); |
|
|
|
|
count=energyService.getHourEnergyCount(buildingId,curDate); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return HttpResult.ok(count,list); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
int count = 0; |
|
|
|
|
// if (areaId != null && areaId.length() > 0) {
|
|
|
|
|
// list = energyService.queryHourEnergy(areaId, curDate, page, limit, level);
|
|
|
|
|
//// count=energyService.getHourEnergyCount(areaId,curDate, level);
|
|
|
|
|
// count = list.size();
|
|
|
|
|
// } else {
|
|
|
|
|
list = energyService.queryHourEnergy(buildingId, curDate, page, limit, level); |
|
|
|
|
// count=energyService.getHourEnergyCount(buildingId,curDate, level);
|
|
|
|
|
count = list.size(); |
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return HttpResult.ok(count, list); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查询楼栋时段用量对比
|
|
|
|
|
@SysLogger(title="用能分析",optDesc = "查询楼栋时段用量对比") |
|
|
|
|
@SysLogger(title = "用能分析", optDesc = "查询楼栋时段用量对比") |
|
|
|
|
@PostMapping("/queryBuild") |
|
|
|
|
public HttpResult queryEnergyBuilding(@RequestParam(value = "curDate",required = false) String curDate, |
|
|
|
|
@RequestParam(value = "endDate",required = false) String endDate, |
|
|
|
|
@RequestParam(value = "type",required = false) int type, |
|
|
|
|
public HttpResult queryEnergyBuilding(@RequestParam(value = "curDate", required = false) String curDate, |
|
|
|
|
@RequestParam(value = "endDate", required = false) String endDate, |
|
|
|
|
@RequestParam(value = "type", required = false) int type, |
|
|
|
|
@RequestParam(value = "page") int page, |
|
|
|
|
@RequestParam(value = "limit") int limit){ |
|
|
|
|
try{ |
|
|
|
|
energyService.proEnergyBuilding(curDate,endDate,type); |
|
|
|
|
List<EnergyEntity> list=energyService.queryEnergyBuilding(page,limit); |
|
|
|
|
SumModel list2=energyService.queryEnergySum(); |
|
|
|
|
Map map=new HashMap<>(); |
|
|
|
|
map.put("a",list); |
|
|
|
|
map.put("b",list2); |
|
|
|
|
int count=energyService.getEnergyBuildingCount(); |
|
|
|
|
return HttpResult.ok(count,map); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
@RequestParam(value = "limit") int limit) { |
|
|
|
|
try { |
|
|
|
|
energyService.proEnergyBuilding(curDate, endDate, type); |
|
|
|
|
List<EnergyEntity> list = energyService.queryEnergyBuilding(page, limit); |
|
|
|
|
SumModel list2 = energyService.queryEnergySum(); |
|
|
|
|
Map map = new HashMap<>(); |
|
|
|
|
map.put("a", list); |
|
|
|
|
map.put("b", list2); |
|
|
|
|
int count = energyService.getEnergyBuildingCount(); |
|
|
|
|
return HttpResult.ok(count, map); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查询合计
|
|
|
|
|
@SysLogger(title="用能分析",optDesc = "查询合计") |
|
|
|
|
@SysLogger(title = "用能分析", optDesc = "查询合计") |
|
|
|
|
@PostMapping("/querySum") |
|
|
|
|
public HttpResult queryEnergySum(){ |
|
|
|
|
try{ |
|
|
|
|
SumModel list=energyService.queryEnergySum(); |
|
|
|
|
return HttpResult.ok(list); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
public HttpResult queryEnergySum() { |
|
|
|
|
try { |
|
|
|
|
SumModel list = energyService.queryEnergySum(); |
|
|
|
|
return HttpResult.ok(list); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
return HttpResult.error("查询出错!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|