From 6439b2eb693c27283437f53740ebd01d7520ab32 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Wed, 31 Jan 2024 11:34:09 +0800
Subject: [PATCH] fix:补充提交
---
screen-api/src/main/java/com/moral/api/dto/OnlineRatePageCond.java | 2 +
screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java | 95 ++++++++++++++++++++++++++++++++++++-----------
screen-api/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java | 1
screen-api/src/main/java/com/moral/api/mapper/DeviceMapper.java | 2
screen-api/src/main/resources/mapper/DeviceMapper.xml | 11 ++++-
5 files changed, 86 insertions(+), 25 deletions(-)
diff --git a/screen-api/src/main/java/com/moral/api/dto/OnlineRatePageCond.java b/screen-api/src/main/java/com/moral/api/dto/OnlineRatePageCond.java
index 6f61fbb..c3666fd 100644
--- a/screen-api/src/main/java/com/moral/api/dto/OnlineRatePageCond.java
+++ b/screen-api/src/main/java/com/moral/api/dto/OnlineRatePageCond.java
@@ -36,6 +36,8 @@
@ApiModelProperty(value = "������������")
private String endTime;
+ @ApiModelProperty(value = "������")
+ private Integer state;
}
diff --git a/screen-api/src/main/java/com/moral/api/mapper/DeviceMapper.java b/screen-api/src/main/java/com/moral/api/mapper/DeviceMapper.java
index cc01854..0ef8f55 100644
--- a/screen-api/src/main/java/com/moral/api/mapper/DeviceMapper.java
+++ b/screen-api/src/main/java/com/moral/api/mapper/DeviceMapper.java
@@ -52,6 +52,6 @@
Page<OnlineRateVo> getPage(Page page, @Param("organizationId")Integer organizationId);
//������������������������
- List<OnlineRateVo> getList(@Param("organizationId")Integer organizationId);
+ List<OnlineRateVo> getLists(@Param("organizationId")Integer organizationId,@Param("state")Integer state);
}
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
index aae96af..9c13d09 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
@@ -565,12 +565,13 @@
int nh = 1000 * 60 * 60;
String startTime = onlineRatePageCond.getStartTime();
String endTime = onlineRatePageCond.getEndTime();
- Date start = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
- Date end = DateUtils.getDate(endTime, DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+ Date start = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_EN);
+ Date end = DateUtils.getDate(endTime, DateUtils.yyyy_MM_dd_HH_EN);
long diff = end.getTime() - start.getTime(); //������������
long hour = (diff / nh)+1; //������������������������
- List<OnlineRateVo> OnlineRateVoList = deviceMapper.getList(onlineRatePageCond.getOrganizationId());
+
+ List<OnlineRateVo> OnlineRateVoList = deviceMapper.getLists(onlineRatePageCond.getOrganizationId(),onlineRatePageCond.getState());
if (!ObjectUtils.isEmpty(OnlineRateVoList)){
for (OnlineRateVo onlineRateVo : OnlineRateVoList) {
List<HistoryHourly> valueByMacAndTime = historyHourlyService.getValueByMacAndTime(onlineRateVo.getMac(), start, end);
@@ -578,9 +579,15 @@
ArrayList<Date> dates1 = new ArrayList<>();
ArrayList<Date> dates2 = new ArrayList<>();
ArrayList<Integer> list = new ArrayList<>();
- Date start1 = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_mm_ss_EN);
+ Date start1 = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_EN);
if (!ObjectUtils.isEmpty(valueByMacAndTime)){
- for (HistoryHourly historyHourly : valueByMacAndTime) {
+ //������������
+ ArrayList<HistoryHourly> collects = valueByMacAndTime.stream().collect(
+ Collectors.collectingAndThen(Collectors.toCollection(
+ () -> new TreeSet<>(Comparator.comparing(p -> p.getTime()))), ArrayList::new)
+ );
+
+ for (HistoryHourly historyHourly : collects) {
dates.add(historyHourly.getTime());
}
boolean flag= true;
@@ -615,8 +622,8 @@
}
// it.setEndTime(DateUtils.dateToDateString(dates1.get(dates1.size()-1)));
onlineRateVo.setNum(dates1.size()+"");
- onlineRateVo.setOnlineTime(valueByMacAndTime.size());
- double number = (double) valueByMacAndTime.size() / hour * 100;
+ onlineRateVo.setOnlineTime(collects.size());
+ double number = (double) collects.size() / hour * 100;
String result = String.format("%.2f", number);
onlineRateVo.setOnlineRate(result+"%");
}
@@ -698,7 +705,7 @@
new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
- return o2.compareTo(o1);
+ return o1.compareTo(o2);
}
}
);
@@ -713,8 +720,15 @@
Date start = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_HH_EN);
Date end = DateUtils.getDate(endTime, DateUtils.yyyy_MM_dd_HH_EN);
List<HistoryHourly> valueByMacAndTime = historyHourlyService.getValueByMacAndTime(mac, start, end);
+
if (!ObjectUtils.isEmpty(valueByMacAndTime)){
- for (HistoryHourly historyHourly : valueByMacAndTime) {
+
+ //������������
+ ArrayList<HistoryHourly> collect = valueByMacAndTime.stream().collect(
+ Collectors.collectingAndThen(Collectors.toCollection(
+ () -> new TreeSet<>(Comparator.comparing(p -> p.getTime()))), ArrayList::new)
+ );
+ for (HistoryHourly historyHourly : collect) {
map.put(DateUtils.dateToDateString(historyHourly.getTime()),1);
dates.add(historyHourly.getTime());
}
@@ -741,7 +755,21 @@
for (int i = 0; i < EndDates.size(); i++) {
OnlineRateLogsForm onlineRateLogsForm = new OnlineRateLogsForm();
onlineRateLogsForm.setEndTime(DateUtils.dateToDateString(EndDates.get(i)));
- onlineRateLogsForm.setStartTime(ObjectUtils.isEmpty(StartDates)?"-":DateUtils.dateToDateString(StartDates.get(i)));
+// onlineRateLogsForm.setStartTime(ObjectUtils.isEmpty(StartDates)?"-":DateUtils.dateToDateString(StartDates.get(i)));
+ if (ObjectUtils.isEmpty(StartDates)){
+ onlineRateLogsForm.setStartTime("-");
+ onlineRateLogsForm.setMun("-");
+ }else {
+ if (EndDates.size()>StartDates.size()&& i==EndDates.size()-1){
+ onlineRateLogsForm.setStartTime("-");
+ onlineRateLogsForm.setMun("-");
+ }else {
+ onlineRateLogsForm.setStartTime(DateUtils.dateToDateString(StartDates.get(i)));
+ long l = EndDates.get(i).getTime() - StartDates.get(i).getTime();
+ onlineRateLogsForm.setMun(Long.toString(Math.abs(l/nh)));
+
+ }
+ }
// if (!ObjectUtils.isEmpty(StartDates)){
// long l = EndDates.get(i).getTime() - StartDates.get(i).getTime();
// onlineRateLogsForm.setMun(Long.toString(l/nh));
@@ -770,14 +798,19 @@
String result = String.format("%.2f", number);
rsMap.put("pieChart1",endNumber);
rsMap.put("pieChart2",dates.size());
- rsMap.put("code","���"+map.size()+"���������"+"������"+dates.size()+"���������"+"���������"+result);
+ rsMap.put("code","���"+map.size()+"���������"+"������"+dates.size()+"���������"+"���������"+(result.equals("NaN")?"0":result));
} else if (type.equals("day")){
Date start = DateUtils.getDate(startTime, DateUtils.yyyy_MM_dd_EN);
Date end = DateUtils.getDate(endTime, DateUtils.yyyy_MM_dd_EN);
List<HistoryDaily> historyDailys = historyDailyService.getHistoryDailyByMacAndTimeSlot(mac, start, end);
if (!ObjectUtils.isEmpty(historyDailys)){
- for (HistoryDaily historyDaily : historyDailys) {
+ //������������
+ ArrayList<HistoryDaily> collects = historyDailys.stream().collect(
+ Collectors.collectingAndThen(Collectors.toCollection(
+ () -> new TreeSet<>(Comparator.comparing(p -> p.getTime()))), ArrayList::new)
+ );
+ for (HistoryDaily historyDaily : collects) {
map.put(DateUtils.dateToDateString(historyDaily.getTime()),1);
dates.add(historyDaily.getTime());
}
@@ -813,10 +846,11 @@
if (EndDates.size()>StartDates.size()&& i==EndDates.size()-1){
onlineRateLogsForm.setStartTime("-");
onlineRateLogsForm.setMun("-");
+ }else {
+ onlineRateLogsForm.setStartTime(DateUtils.dateToDateString(StartDates.get(i)));
+ long l = EndDates.get(i).getTime() - StartDates.get(i).getTime();
+ onlineRateLogsForm.setMun(Long.toString(Math.abs(l/nd)));
}
- onlineRateLogsForm.setStartTime(DateUtils.dateToDateString(StartDates.get(i)));
- long l = EndDates.get(i).getTime() - StartDates.get(i).getTime();
- onlineRateLogsForm.setMun(Long.toString(l/nd));
}
// if (!ObjectUtils.isEmpty(StartDates)){
// long l = EndDates.get(i).getTime() - StartDates.get(i).getTime();
@@ -847,13 +881,18 @@
String result = String.format("%.2f", number);
rsMap.put("pieChart1",endNumber);
rsMap.put("pieChart2",dates.size());
- rsMap.put("code","���"+map.size()+"������"+"������"+dates.size()+"������"+"���������"+result);
+ rsMap.put("code","���"+map.size()+"������"+"������"+dates.size()+"������"+"���������"+(result.equals("NaN")?"0":result));
}else {
- Date start = DateUtils.getDate(startTime,"yyyy-MM-dd HH:mm:00");
- Date end = DateUtils.getDate(endTime, "yyyy-MM-dd HH:mm:00");
+ Date start = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_HH_mm_EN);
+ Date end = DateUtils.getDate(endTime, DateUtils.yyyy_MM_dd_HH_mm_EN);
List<HistoryMinutely> historyMinutelys = historyHourlyService.getHistoryMinutely(mac, start, end);
if (!ObjectUtils.isEmpty(historyMinutelys)){
- for (HistoryMinutely historyMinutely : historyMinutelys) {
+ //������������
+ ArrayList<HistoryMinutely> collects = historyMinutelys.stream().collect(
+ Collectors.collectingAndThen(Collectors.toCollection(
+ () -> new TreeSet<>(Comparator.comparing(p -> p.getTime()))), ArrayList::new)
+ );
+ for (HistoryMinutely historyMinutely : collects) {
map.put(DateUtils.dateToDateString(historyMinutely.getTime()),1);
dates.add(historyMinutely.getTime());
}
@@ -881,7 +920,20 @@
for (int i = 0; i < EndDates.size(); i++) {
OnlineRateLogsForm onlineRateLogsForm = new OnlineRateLogsForm();
onlineRateLogsForm.setEndTime(DateUtils.dateToDateString(EndDates.get(i)));
- onlineRateLogsForm.setStartTime(ObjectUtils.isEmpty(StartDates)?"-":DateUtils.dateToDateString(StartDates.get(i)));
+// onlineRateLogsForm.setStartTime(ObjectUtils.isEmpty(StartDates)?"-":DateUtils.dateToDateString(StartDates.get(i)));
+ if (ObjectUtils.isEmpty(StartDates)){
+ onlineRateLogsForm.setStartTime("-");
+ onlineRateLogsForm.setMun("-");
+ }else {
+ if (EndDates.size()>StartDates.size()&& i==EndDates.size()-1){
+ onlineRateLogsForm.setStartTime("-");
+ onlineRateLogsForm.setMun("-");
+ }else {
+ onlineRateLogsForm.setStartTime(DateUtils.dateToDateString(StartDates.get(i)));
+ long l = EndDates.get(i).getTime() - StartDates.get(i).getTime();
+ onlineRateLogsForm.setMun(Long.toString(Math.abs(l/nm)));
+ }
+ }
// if (!ObjectUtils.isEmpty(StartDates)){
// long l = EndDates.get(i).getTime() - StartDates.get(i).getTime();
// onlineRateLogsForm.setMun(Long.toString(l/nm));
@@ -909,9 +961,8 @@
String result = String.format("%.2f", number);
rsMap.put("pieChart1",endNumber);
rsMap.put("pieChart2",dates.size());
- rsMap.put("code","���"+map.size()+"���������"+"������"+dates.size()+"���������"+"���������"+result);
+ rsMap.put("code","���"+map.size()+"���������"+"������"+dates.size()+"���������"+"���������"+(result.equals("NaN")?"0":result));
}
-
return rsMap;
}
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java
index 3616d86..8f75d49 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java
@@ -98,6 +98,7 @@
LambdaQueryWrapper<Organization> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Organization::getParentId,organizationId);
wrapper.eq(Organization::getIsDelete,Constants.NOT_DELETE);
+ wrapper.orderByDesc(Organization::getCreateTime);
List<Organization> organizations = organizationMapper.selectList(wrapper);
rsList.addAll(organizations);
}else {
diff --git a/screen-api/src/main/resources/mapper/DeviceMapper.xml b/screen-api/src/main/resources/mapper/DeviceMapper.xml
index 996b601..24526c4 100644
--- a/screen-api/src/main/resources/mapper/DeviceMapper.xml
+++ b/screen-api/src/main/resources/mapper/DeviceMapper.xml
@@ -274,7 +274,14 @@
select d.name,d.state,d.mac from device as d where organization_id=#{organizationId}
</select>
- <select id="getList" resultType="com.moral.api.vo.OnlineRateVo">
- select d.name,d.state,d.mac from device as d where organization_id=#{organizationId}
+
+ <select id="getLists" resultType="com.moral.api.vo.OnlineRateVo">
+ select d.name,d.state,d.mac from device as d where organization_id=#{organizationId} and is_delete=0
+ <if test="state !=null and state == 0" >
+ and state=#{state}
+ </if>
+ <if test="state !=null and state != 0">
+ and state<![CDATA[>=]]>#{state}
+ </if>
</select>
</mapper>
\ No newline at end of file
--
Gitblit v1.8.0