Merge branch 'master' of codeup.aliyun.com:6428039c708c83a3fd907211/hzwmiot/hzwmiot24_java
This commit is contained in:
commit
5ae93c94d2
@ -16,7 +16,6 @@ import com.fastbee.iot.model.anfang.UploadedPhotos;
|
||||
import com.fastbee.iot.service.impl.DeviceServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
@ -248,68 +248,96 @@ public class DeviceDetailServiceImpl implements IDeviceDetailService {
|
||||
List<ThingsModel> taiyangnengModels = thingsModelService.selectThingsModelList(thingsModel1);
|
||||
taiyangnengModels.sort(Comparator.comparing(ThingsModel::getModelOrder));
|
||||
List<HashMap<Object, Object>> list = new ArrayList<>();
|
||||
if (StringUtils.isNotEmpty(taiyangnengIds)) {
|
||||
Device taiyangnengDevice = deviceMapper.selectDeviceByDeviceId(Long.parseLong(taiyangnengIds));
|
||||
List<DeviceLog> deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{
|
||||
setSerialNumber(taiyangnengDevice.getSerialNumber());
|
||||
setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, -1)).toString());
|
||||
setEndTime(DateUtil.endOfDay(dateTime).toString());
|
||||
}});
|
||||
Map<String, List<DeviceLog>> taiyangnengCollect = deviceLogs.stream().sorted(Comparator
|
||||
.comparing(DeviceLog::getCreateTime, Comparator
|
||||
.nullsFirst(Comparator.naturalOrder())).reversed()).collect(Collectors.groupingBy(t -> t.getIdentity()));
|
||||
for (ThingsModel thingsModel : taiyangnengModels) {
|
||||
HashMap<Object, Object> hashMap = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", thingsModel.getIdentifier());
|
||||
put("unit", "");
|
||||
put("value", 0);
|
||||
put("name", thingsModel.getModelName());
|
||||
}};
|
||||
if (StringUtils.isNotEmpty(thingsModel.getSpecs())) {
|
||||
String specs = thingsModel.getSpecs();
|
||||
JSONObject parse = (JSONObject) JSON.parse(specs);
|
||||
if (parse.containsKey("unit")) {
|
||||
hashMap.put("unit", parse.get("unit"));
|
||||
CommonResult<HaiWeiDeviceInfoVo> cache = haiWeiService.getCache(Long.parseLong(taiyangnengIds));
|
||||
if(cache != null){
|
||||
HaiWeiDeviceInfoVo checkedData = cache.getCheckedData();
|
||||
if(checkedData != null){
|
||||
List<HaiWeiPropertyVo> propertyList = checkedData.getPropertyList();
|
||||
for (HaiWeiPropertyVo haiWeiPropertyVo : propertyList) {
|
||||
if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_kaixian")){
|
||||
continue;
|
||||
}
|
||||
HashMap<Object, Object> hashMap = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", haiWeiPropertyVo.getNameEn());
|
||||
put("unit", haiWeiPropertyVo.getUnit());
|
||||
put("value", haiWeiPropertyVo.getValue());
|
||||
put("name", haiWeiPropertyVo.getNameCn());
|
||||
}};
|
||||
if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_MpptDown")){
|
||||
hashMap.put("value", Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?
|
||||
"异常":"正常");
|
||||
}
|
||||
if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_市电状态")){
|
||||
hashMap.put("value", Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?
|
||||
"市电":"太阳能");
|
||||
}
|
||||
list.add(hashMap);
|
||||
}
|
||||
|
||||
if (hashMap.size() > 1) {
|
||||
List<DeviceLog> deviceLogs1 = taiyangnengCollect.get(thingsModel.getIdentifier());
|
||||
if (deviceLogs1 != null) {
|
||||
if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) {
|
||||
if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
hashMap.put("upType", 1);
|
||||
} else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
hashMap.put("upType", -1);
|
||||
}
|
||||
hashMap.put("value", deviceLogs1.get(0).getLogValue());
|
||||
} else {
|
||||
hashMap.put("value", "--");
|
||||
hashMap.put("upType", 0);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (hashMap.size() > 0) {
|
||||
List<DeviceLog> deviceLogs2 = taiyangnengCollect.get(thingsModel.getIdentifier());
|
||||
if (deviceLogs2 != null) {
|
||||
hashMap.put("value", deviceLogs2.get(0).getLogValue());
|
||||
}
|
||||
}
|
||||
list.add(hashMap);
|
||||
}
|
||||
} else {
|
||||
for (ThingsModel thingsModel : taiyangnengModels) {
|
||||
HashMap<Object, Object> hashMap = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", thingsModel.getIdentifier());
|
||||
put("unit", "");
|
||||
put("value", 0);
|
||||
put("name", thingsModel.getModelName());
|
||||
}};
|
||||
list.add(hashMap);
|
||||
}
|
||||
}
|
||||
// if (StringUtils.isNotEmpty(taiyangnengIds)) {
|
||||
// Device taiyangnengDevice = deviceMapper.selectDeviceByDeviceId(Long.parseLong(taiyangnengIds));
|
||||
// List<DeviceLog> deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{
|
||||
// setSerialNumber(taiyangnengDevice.getSerialNumber());
|
||||
// setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, -1)).toString());
|
||||
// setEndTime(DateUtil.endOfDay(dateTime).toString());
|
||||
// }});
|
||||
// Map<String, List<DeviceLog>> taiyangnengCollect = deviceLogs.stream().sorted(Comparator
|
||||
// .comparing(DeviceLog::getCreateTime, Comparator
|
||||
// .nullsFirst(Comparator.naturalOrder())).reversed()).collect(Collectors.groupingBy(t -> t.getIdentity()));
|
||||
// for (ThingsModel thingsModel : taiyangnengModels) {
|
||||
// HashMap<Object, Object> hashMap = new HashMap<Object, Object>() {{
|
||||
// put("upType", 0);
|
||||
// put("identifier", thingsModel.getIdentifier());
|
||||
// put("unit", "");
|
||||
// put("value", 0);
|
||||
// put("name", thingsModel.getModelName());
|
||||
// }};
|
||||
// if (StringUtils.isNotEmpty(thingsModel.getSpecs())) {
|
||||
// String specs = thingsModel.getSpecs();
|
||||
// JSONObject parse = (JSONObject) JSON.parse(specs);
|
||||
// if (parse.containsKey("unit")) {
|
||||
// hashMap.put("unit", parse.get("unit"));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (hashMap.size() > 1) {
|
||||
// List<DeviceLog> deviceLogs1 = taiyangnengCollect.get(thingsModel.getIdentifier());
|
||||
// if (deviceLogs1 != null) {
|
||||
// if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) {
|
||||
// if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
// hashMap.put("upType", 1);
|
||||
// } else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
// hashMap.put("upType", -1);
|
||||
// }
|
||||
// hashMap.put("value", deviceLogs1.get(0).getLogValue());
|
||||
// } else {
|
||||
// hashMap.put("value", "--");
|
||||
// hashMap.put("upType", 0);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// } else if (hashMap.size() > 0) {
|
||||
// List<DeviceLog> deviceLogs2 = taiyangnengCollect.get(thingsModel.getIdentifier());
|
||||
// if (deviceLogs2 != null) {
|
||||
// hashMap.put("value", deviceLogs2.get(0).getLogValue());
|
||||
// }
|
||||
// }
|
||||
// list.add(hashMap);
|
||||
// }
|
||||
// } else {
|
||||
// for (ThingsModel thingsModel : taiyangnengModels) {
|
||||
// HashMap<Object, Object> hashMap = new HashMap<Object, Object>() {{
|
||||
// put("upType", 0);
|
||||
// put("identifier", thingsModel.getIdentifier());
|
||||
// put("unit", "");
|
||||
// put("value", 0);
|
||||
// put("name", thingsModel.getModelName());
|
||||
// }};
|
||||
// list.add(hashMap);
|
||||
// }
|
||||
// }
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -332,68 +360,100 @@ public class DeviceDetailServiceImpl implements IDeviceDetailService {
|
||||
List<ThingsModel> liuliangModels = thingsModelService.selectThingsModelList(thingsModel1);
|
||||
liuliangModels.sort(Comparator.comparing(ThingsModel::getModelOrder));
|
||||
List<HashMap<Object, Object>> list = new ArrayList<>();
|
||||
if (StringUtils.isNotEmpty(liuliangIds)) {
|
||||
Device taiyangnengDevice = deviceMapper.selectDeviceByDeviceId(Long.parseLong(liuliangIds));
|
||||
List<DeviceLog> deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{
|
||||
setSerialNumber(taiyangnengDevice.getSerialNumber());
|
||||
setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, -1)).toString());
|
||||
setEndTime(DateUtil.endOfDay(dateTime).toString());
|
||||
}});
|
||||
Map<String, List<DeviceLog>> taiyangnengCollect = deviceLogs.stream().sorted(Comparator
|
||||
.comparing(DeviceLog::getCreateTime, Comparator
|
||||
.nullsFirst(Comparator.naturalOrder())).reversed()).collect(Collectors.groupingBy(t -> t.getIdentity()));
|
||||
for (ThingsModel thingsModel : liuliangModels) {
|
||||
HashMap<Object, Object> hashMap = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", thingsModel.getIdentifier());
|
||||
put("unit", "");
|
||||
put("value", 0);
|
||||
put("name", thingsModel.getModelName());
|
||||
}};
|
||||
if (StringUtils.isNotEmpty(thingsModel.getSpecs())) {
|
||||
String specs = thingsModel.getSpecs();
|
||||
JSONObject parse = (JSONObject) JSON.parse(specs);
|
||||
if (parse.containsKey("unit")) {
|
||||
hashMap.put("unit", parse.get("unit"));
|
||||
CommonResult<HaiWeiDeviceInfoVo> cache = haiWeiService.getCache(Long.parseLong(liuliangIds));
|
||||
if(cache != null){
|
||||
HaiWeiDeviceInfoVo checkedData = cache.getCheckedData();
|
||||
if(checkedData != null){
|
||||
List<HaiWeiPropertyVo> propertyList = checkedData.getPropertyList();
|
||||
for (HaiWeiPropertyVo haiWeiPropertyVo : propertyList) {
|
||||
if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_kaixian")){
|
||||
continue;
|
||||
}
|
||||
HashMap<Object, Object> hashMap = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", haiWeiPropertyVo.getNameEn());
|
||||
put("unit", haiWeiPropertyVo.getUnit());
|
||||
put("value", haiWeiPropertyVo.getValue());
|
||||
put("name", haiWeiPropertyVo.getNameCn());
|
||||
}};
|
||||
if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_guanxian")){
|
||||
hashMap.put("value", Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?
|
||||
"关闭":"开启");
|
||||
}
|
||||
if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_FlowDown")){
|
||||
hashMap.put("value", Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?
|
||||
"异常":"正常");
|
||||
}
|
||||
if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_mCon")){
|
||||
hashMap.put("value", Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?
|
||||
"异常":"正常");
|
||||
}
|
||||
list.add(hashMap);
|
||||
}
|
||||
|
||||
if (hashMap.size() > 1) {
|
||||
List<DeviceLog> deviceLogs1 = taiyangnengCollect.get(thingsModel.getIdentifier());
|
||||
if (deviceLogs1 != null) {
|
||||
if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) {
|
||||
if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
hashMap.put("upType", 1);
|
||||
} else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
hashMap.put("upType", -1);
|
||||
}
|
||||
hashMap.put("value", deviceLogs1.get(0).getLogValue());
|
||||
} else {
|
||||
hashMap.put("value", "--");
|
||||
hashMap.put("upType", 0);
|
||||
}
|
||||
|
||||
}
|
||||
} else if (hashMap.size() > 0) {
|
||||
List<DeviceLog> deviceLogs2 = taiyangnengCollect.get(thingsModel.getIdentifier());
|
||||
if (deviceLogs2 != null) {
|
||||
hashMap.put("value", deviceLogs2.get(0).getLogValue());
|
||||
}
|
||||
}
|
||||
list.add(hashMap);
|
||||
}
|
||||
} else {
|
||||
for (ThingsModel thingsModel : liuliangModels) {
|
||||
HashMap<Object, Object> hashMap = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", thingsModel.getIdentifier());
|
||||
put("unit", "");
|
||||
put("value", 0);
|
||||
put("name", thingsModel.getModelName());
|
||||
}};
|
||||
list.add(hashMap);
|
||||
}
|
||||
}
|
||||
// if (StringUtils.isNotEmpty(liuliangIds)) {
|
||||
// Device taiyangnengDevice = deviceMapper.selectDeviceByDeviceId(Long.parseLong(liuliangIds));
|
||||
// List<DeviceLog> deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{
|
||||
// setSerialNumber(taiyangnengDevice.getSerialNumber());
|
||||
// setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, -1)).toString());
|
||||
// setEndTime(DateUtil.endOfDay(dateTime).toString());
|
||||
// }});
|
||||
// Map<String, List<DeviceLog>> taiyangnengCollect = deviceLogs.stream().sorted(Comparator
|
||||
// .comparing(DeviceLog::getCreateTime, Comparator
|
||||
// .nullsFirst(Comparator.naturalOrder())).reversed()).collect(Collectors.groupingBy(t -> t.getIdentity()));
|
||||
// for (ThingsModel thingsModel : liuliangModels) {
|
||||
// HashMap<Object, Object> hashMap = new HashMap<Object, Object>() {{
|
||||
// put("upType", 0);
|
||||
// put("identifier", thingsModel.getIdentifier());
|
||||
// put("unit", "");
|
||||
// put("value", 0);
|
||||
// put("name", thingsModel.getModelName());
|
||||
// }};
|
||||
// if (StringUtils.isNotEmpty(thingsModel.getSpecs())) {
|
||||
// String specs = thingsModel.getSpecs();
|
||||
// JSONObject parse = (JSONObject) JSON.parse(specs);
|
||||
// if (parse.containsKey("unit")) {
|
||||
// hashMap.put("unit", parse.get("unit"));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (hashMap.size() > 1) {
|
||||
// List<DeviceLog> deviceLogs1 = taiyangnengCollect.get(thingsModel.getIdentifier());
|
||||
// if (deviceLogs1 != null) {
|
||||
// if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) {
|
||||
// if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
// hashMap.put("upType", 1);
|
||||
// } else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) {
|
||||
// hashMap.put("upType", -1);
|
||||
// }
|
||||
// hashMap.put("value", deviceLogs1.get(0).getLogValue());
|
||||
// } else {
|
||||
// hashMap.put("value", "--");
|
||||
// hashMap.put("upType", 0);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// } else if (hashMap.size() > 0) {
|
||||
// List<DeviceLog> deviceLogs2 = taiyangnengCollect.get(thingsModel.getIdentifier());
|
||||
// if (deviceLogs2 != null) {
|
||||
// hashMap.put("value", deviceLogs2.get(0).getLogValue());
|
||||
// }
|
||||
// }
|
||||
// list.add(hashMap);
|
||||
// }
|
||||
// } else {
|
||||
// for (ThingsModel thingsModel : liuliangModels) {
|
||||
// HashMap<Object, Object> hashMap = new HashMap<Object, Object>() {{
|
||||
// put("upType", 0);
|
||||
// put("identifier", thingsModel.getIdentifier());
|
||||
// put("unit", "");
|
||||
// put("value", 0);
|
||||
// put("name", thingsModel.getModelName());
|
||||
// }};
|
||||
// list.add(hashMap);
|
||||
// }
|
||||
// }
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -242,24 +242,24 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
put("name", haiWeiPropertyVo.getNameCn());
|
||||
}};
|
||||
rMap.put("xiangmen", hashMap1);
|
||||
} else if (haiWeiPropertyVo.getNameEn().equals("内门上锁")) {
|
||||
} else if (haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_lock1Con")) {
|
||||
HashMap<Object, Object> hashMap1 = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", "三菱FX2N_1_lock1Con");
|
||||
put("unit", "");
|
||||
put("value", Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?"正常":"异常");
|
||||
put("name", haiWeiPropertyVo.getNameCn());
|
||||
put("name", "内门上锁");
|
||||
}};
|
||||
rMap.put("三菱FX2N_1_lock1Con", hashMap1);
|
||||
} else if (haiWeiPropertyVo.getNameEn().equals("内门下锁")) {
|
||||
rMap.put("内门上锁", hashMap1);
|
||||
} else if (haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_lock2Con")) {
|
||||
HashMap<Object, Object> hashMap1 = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
put("identifier", "三菱FX2N_1_lock2Con");
|
||||
put("unit", "");
|
||||
put("value", Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?"正常":"异常");
|
||||
put("name", haiWeiPropertyVo.getNameCn());
|
||||
put("name", "内门下锁");
|
||||
}};
|
||||
rMap.put("三菱FX2N_1_lock2Con", hashMap1);
|
||||
rMap.put("内门下锁", hashMap1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -351,7 +351,7 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
|
||||
}
|
||||
|
||||
}
|
||||
rMap.put("阀门状态", hashMap1);
|
||||
rMap.put("水表状态", hashMap1);
|
||||
}else{
|
||||
HashMap<Object, Object> hashMap1 = new HashMap<Object, Object>() {{
|
||||
put("upType", 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user