|
@@ -6,6 +6,7 @@ import com.welampiot.dto.*;
|
|
|
import com.welampiot.service.*;
|
|
|
import com.welampiot.utils.ExcelUtil;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
+import com.welampiot.utils.WebUtils;
|
|
|
import com.welampiot.vo.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -15,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -47,6 +50,8 @@ public class DataController {
|
|
|
private RepairPersonnelService repairPersonnelService;
|
|
|
@Autowired
|
|
|
private LampInfoCacheByDayService lampInfoCacheByDayService;
|
|
|
+ @Autowired
|
|
|
+ private SectionCacheByDayService sectionCacheByDayService;
|
|
|
|
|
|
@RequestMapping(value = "/info",method = RequestMethod.POST)
|
|
|
public BaseResult<InfoResponseVO> info(HttpServletRequest request){
|
|
@@ -57,12 +62,12 @@ public class DataController {
|
|
|
InfoResponseVO data = new InfoResponseVO();
|
|
|
data.setCompany(toolUtils.getUser().getCompany());
|
|
|
data.setCompanyAddress(toolUtils.getUser().getAddress());
|
|
|
- Integer userId = toolUtils.getUser().getId();
|
|
|
- Integer role = toolUtils.getUser().getRole();
|
|
|
+
|
|
|
//设备数量,路灯数量,灯杆数量
|
|
|
LampCountVO lampCountVO = new LampCountVO();
|
|
|
if (!sectionList.isEmpty()) lampCountVO.setSectionList(sectionList);
|
|
|
data.setLampCount(lampService.getCountByVO(lampCountVO)); // 灯控总数
|
|
|
+ data.setDevCount(data.getLampCount()); // 灯控总数
|
|
|
lampCountVO.setOnlineStatus(1);
|
|
|
lampCountVO.setLampStatus(1);
|
|
|
data.setLightCount(lampService.getCountByVO(lampCountVO)); // 亮灯数
|
|
@@ -85,61 +90,67 @@ public class DataController {
|
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
lampCountVO.setStartDate(simpleDateFormat.format(new Date()).toString());
|
|
|
- Float dayConsumptionByVO = lampService.getDayConsumptionByVO(lampCountVO);
|
|
|
- data.setDayConsumption((float) (Math.round(dayConsumptionByVO*100)/100f));
|
|
|
+// Float dayConsumptionByVO = lampService.getDayConsumptionByVO(lampCountVO);
|
|
|
+// data.setDayConsumption((float) (Math.round(dayConsumptionByVO*100)/100f));
|
|
|
simpleDateFormat = new SimpleDateFormat("yyyy-MM-01 00:00:00");
|
|
|
// 当月
|
|
|
LampVO lampVO = new LampVO();
|
|
|
lampVO.setSectionList(sectionList);
|
|
|
+ // 灯控故障数,在线数
|
|
|
+ data.setAlarmCount(lampService.getAlarmCountByVO(lampVO));
|
|
|
+ data.setOnlineCount(lampService.getOnlineCountByVO(lampVO));
|
|
|
+
|
|
|
LampInfoLogNewDTO comBySectionList = lampService.getComBySectionList(lampVO);
|
|
|
- comBySectionList.getDayGeneraEnergy();
|
|
|
-// lampCountVO.setStartDate(simpleDateFormat.format(new Date()).toString());
|
|
|
+ data.setDaySavePower((float) (Math.round(Float.valueOf(comBySectionList.getDayEleSave())*100)/100f));
|
|
|
+ data.setDayConsumption((float) (Math.round(Float.valueOf(comBySectionList.getDayGeneraEnergy())*100)/100f));
|
|
|
+
|
|
|
Float monthConsumption = Float.valueOf(comBySectionList.getDayGeneraEnergy())+Float.valueOf(comBySectionList.getMonthGeneraEnergyCache());
|
|
|
-// monthConsumption = monthConsumption == null ? 0 : monthConsumption;
|
|
|
- data.setMonthConsumption((float) (Math.round((dayConsumptionByVO+monthConsumption)*100)/100f));
|
|
|
+ data.setMonthConsumption((float) (Math.round((monthConsumption)*100)/100f));
|
|
|
// 当年
|
|
|
simpleDateFormat = new SimpleDateFormat("yyyy-01-01 00:00:00");
|
|
|
-// lampCountVO.setStartDate(simpleDateFormat.format(new Date()).toString());
|
|
|
-// Float yearConsumption = lampService.getConsumptionByVO(lampCountVO);
|
|
|
-// yearConsumption = yearConsumption == null ? 0 : yearConsumption;
|
|
|
Float yearConsumption = Float.valueOf(comBySectionList.getDayGeneraEnergy())+Float.valueOf(comBySectionList.getYearGeneraEnergyCache());
|
|
|
- data.setYearConsumption((float) (Math.round((dayConsumptionByVO+yearConsumption)*100)/100f));
|
|
|
+ data.setYearConsumption((float) (Math.round((yearConsumption)*100)/100f));
|
|
|
// 累计
|
|
|
-// lampCountVO.setStartDate(null);
|
|
|
-// Float totalConsumption = lampService.getConsumptionByVO(lampCountVO);
|
|
|
-// totalConsumption = totalConsumption == null ? 0 : totalConsumption;
|
|
|
- Float totalConsumption = Float.valueOf(comBySectionList.getDayGeneraEnergy())+Float.valueOf(comBySectionList.getTotalGeneraEnergyCache());
|
|
|
- data.setTotalConsumption((float) (Math.round((dayConsumptionByVO+totalConsumption)*100)/100f));
|
|
|
-// Date startDate = new Date(System.currentTimeMillis() - 20*24*3600*1000);
|
|
|
+ double v = (double) (Math.round(Float.valueOf(comBySectionList.getDayGeneraEnergy())*100)/100f);
|
|
|
+ double v2 = (double) (Math.round(Float.valueOf(comBySectionList.getTotalGeneraEnergyCache())*100)/100f);
|
|
|
+ data.setTotalConsumption(WebUtils.round(v+v2,2));
|
|
|
+ data.setTotalElectricharge(WebUtils.round(data.getTotalConsumption() * 0.75,2));
|
|
|
+ data.setTotalCarbonEmission(WebUtils.round(data.getTotalConsumption() * 0.785/1000,3));
|
|
|
+
|
|
|
+ Double totalEleSaveCache = Double.valueOf(comBySectionList.getDayEleSave())+Double.valueOf(comBySectionList.getTotalEleSaveCache());
|
|
|
+ data.setTotalSavePower(WebUtils.round(totalEleSaveCache,2));
|
|
|
+ data.setTotalSaveElectricharge(WebUtils.round(data.getTotalSavePower() * 0.75,2));
|
|
|
+ data.setTotalSaveCarbonEmission(WebUtils.round(data.getTotalSavePower() * 0.785/1000,3));
|
|
|
+
|
|
|
Date endDate = new Date(System.currentTimeMillis() - 24*3600*1000);
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(endDate);
|
|
|
calendar.add(Calendar.MONDAY, -1);
|
|
|
|
|
|
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
|
|
|
-// Date startDate = simpleDateFormat.format(calendar.getTime());
|
|
|
-// for (int i = 0; i < 30; i++) {
|
|
|
-// long t = startDate.getTime() + i * 24 * 3600 * 1000;
|
|
|
-// }
|
|
|
- lampCountVO.setStartDate(simpleDateFormat.format(calendar.getTime()));
|
|
|
- lampCountVO.setEndDate(simpleDateFormat.format(endDate).toString());
|
|
|
- System.out.println(lampCountVO.getStartDate());
|
|
|
- System.out.println(lampCountVO.getEndDate());
|
|
|
- List<LampLogVO> consumptionListByVO = lampService.getConsumptionListByVO(lampCountVO);
|
|
|
+ SectionCacheByDayDTO sectionCacheByDayDTO = new SectionCacheByDayDTO();
|
|
|
+ sectionCacheByDayDTO.setStartDate(simpleDateFormat.format(calendar.getTime()));
|
|
|
+ sectionCacheByDayDTO.setEndDate(simpleDateFormat.format(endDate).toString());
|
|
|
+
|
|
|
+ List<SectionCacheByDayDTO> consumptionListByDTO = sectionCacheByDayService.getConsumptionListByDTO(sectionCacheByDayDTO);
|
|
|
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
List date = new ArrayList<>();
|
|
|
List value = new ArrayList<>();
|
|
|
List savePower = new ArrayList<>();
|
|
|
- for (LampLogVO t :consumptionListByVO) {
|
|
|
- String updateTime = simpleDateFormat.format(t.getUpdateTime()).toString();
|
|
|
+ List lightDev = new ArrayList<>();
|
|
|
+ for (SectionCacheByDayDTO t :consumptionListByDTO) {
|
|
|
+// String updateTime = simpleDateFormat.format(t.getUpdateTime()).toString();
|
|
|
+ String updateTime = t.getUpdateTime();
|
|
|
Float consumption = t.getConsumption();
|
|
|
Float powerSave = t.getPowerSave();
|
|
|
date.add(updateTime);
|
|
|
value.add((float) (Math.round((consumption)*100)/100f));
|
|
|
savePower.add((float) (Math.round((powerSave)*100)/100f));
|
|
|
+ lightDev.add(t.getLightCount());
|
|
|
}
|
|
|
data.setDate(date);
|
|
|
data.setValue(value);
|
|
|
+ data.setLightDev(lightDev);
|
|
|
data.setSavePower(savePower);
|
|
|
return BaseResult.success(data);
|
|
|
}
|