LocationServiceImp.java
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.sunyo.energy.location.service.imp;
import com.sunyo.energy.location.dao.LocationMapper;
import com.sunyo.energy.location.model.ElectricityMeter;
import com.sunyo.energy.location.model.WaterMeter;
import com.sunyo.energy.location.service.ElectricityMeterService;
import com.sunyo.energy.location.service.LocationService;
import com.sunyo.energy.location.service.WaterMeterService;
import com.sunyo.energy.location.utils.AllUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class LocationServiceImp implements LocationService {
@Autowired
LocationMapper locationMapper;
@Autowired
ElectricityMeterService electricityMeterService;
@Autowired
WaterMeterService waterMeterService;
@Override
public List userPayList(String roomNumber, int userId) {
try {
// 房间号如果为null 跳过
if (!StringUtils.isEmpty(roomNumber)) {
List<Map<String, Object>> list = new ArrayList<>();
/**
* 水费查询
*/
// 查询房间号 水表本地查询list
Map<String, Object> thisLocalityWaterMap = locationMapper.userPayList(roomNumber);
Map<String, Object> distanceWaterMap = new HashMap<>();
// 查询该房间号的水表编号
String wmId = locationMapper.findWmId(roomNumber);
if (!"".equals(wmId)) {
Map<String, Object> waterMaps = new HashMap<>();
WaterMeter realTime = waterMeterService.findRealTime(wmId);
String subtraction = AllUtils.nubmerSubtraction(realTime.getWmSacc(), realTime.getWmLacc());
distanceWaterMap.put("subtraction", subtraction);
distanceWaterMap.put("wmSacc", realTime.getWmSacc());
distanceWaterMap.put("wmFmstate", realTime.getWmFmstate());
distanceWaterMap.put("wmLacc", realTime.getWmLacc());
distanceWaterMap.put("wmId", wmId);
distanceWaterMap.put("roomNumber", roomNumber);
distanceWaterMap.put("userId", userId);
list.add(distanceWaterMap);
}
/**
* 电费查询 通过房间号查询设备id
*/
String eeId = locationMapper.eeId(roomNumber);
if (!"".equals(eeId)) {
ElectricityMeter energyInfoForRealTime = electricityMeterService.getEnergyInfoForRealTime(eeId);
Map<String, Object> eeMap = new HashMap<>();
if (energyInfoForRealTime != null) {
eeMap.put("deviceId", energyInfoForRealTime.getDeviceId());
eeMap.put("balance", energyInfoForRealTime.getBalance());
eeMap.put("wmId", "");
eeMap.put("roomNumber", roomNumber);
eeMap.put("userId", userId);
list.add(eeMap);
}
}
return list;
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}