1
|
package com.sunyo.energy.location.service.imp;
|
1
|
package com.sunyo.energy.location.service.imp;
|
2
|
|
2
|
|
3
|
import com.alibaba.fastjson.JSON;
|
3
|
import com.alibaba.fastjson.JSON;
|
|
|
4
|
+import com.alibaba.fastjson.JSONArray;
|
4
|
import com.sunyo.energy.location.controller.response.ResultJson;
|
5
|
import com.sunyo.energy.location.controller.response.ResultJson;
|
5
|
-import com.sunyo.energy.location.dao.LocationMapper;
|
|
|
6
|
-import com.sunyo.energy.location.dao.PayRecordsMapper;
|
|
|
7
|
-import com.sunyo.energy.location.dao.WaterMeterMapper;
|
|
|
8
|
-import com.sunyo.energy.location.dao.WaterMeterSaccMapper;
|
6
|
+import com.sunyo.energy.location.dao.*;
|
|
|
7
|
+import com.sunyo.energy.location.model.NoteForm;
|
|
|
8
|
+import com.sunyo.energy.location.model.WaterMeter;
|
9
|
import com.sunyo.energy.location.model.WaterMeterSacc;
|
9
|
import com.sunyo.energy.location.model.WaterMeterSacc;
|
10
|
import com.sunyo.energy.location.service.WaterMeterService;
|
10
|
import com.sunyo.energy.location.service.WaterMeterService;
|
11
|
import com.sunyo.energy.location.utils.AllUtils;
|
11
|
import com.sunyo.energy.location.utils.AllUtils;
|
12
|
import com.sunyo.energy.location.utils.HttpsUtils;
|
12
|
import com.sunyo.energy.location.utils.HttpsUtils;
|
|
|
13
|
+import lombok.extern.slf4j.Slf4j;
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
14
|
import org.springframework.beans.factory.annotation.Autowired;
|
14
|
import org.springframework.stereotype.Service;
|
15
|
import org.springframework.stereotype.Service;
|
15
|
import java.math.BigDecimal;
|
16
|
import java.math.BigDecimal;
|
16
|
import java.util.*;
|
17
|
import java.util.*;
|
17
|
|
18
|
|
18
|
-
|
19
|
+@Slf4j
|
19
|
@Service
|
20
|
@Service
|
20
|
public class WaterMeterServiceImp implements WaterMeterService {
|
21
|
public class WaterMeterServiceImp implements WaterMeterService {
|
21
|
|
22
|
|
|
@@ -31,6 +32,9 @@ public class WaterMeterServiceImp implements WaterMeterService { |
|
@@ -31,6 +32,9 @@ public class WaterMeterServiceImp implements WaterMeterService { |
31
|
@Autowired
|
32
|
@Autowired
|
32
|
WaterMeterSaccMapper waterMeterSaccMapper;
|
33
|
WaterMeterSaccMapper waterMeterSaccMapper;
|
33
|
|
34
|
|
|
|
35
|
+ @Autowired
|
|
|
36
|
+ NoteFormMapper noteFormMapper;
|
|
|
37
|
+
|
34
|
/**
|
38
|
/**
|
35
|
* 查询所有水表
|
39
|
* 查询所有水表
|
36
|
*/
|
40
|
*/
|
|
@@ -40,6 +44,34 @@ public class WaterMeterServiceImp implements WaterMeterService { |
|
@@ -40,6 +44,34 @@ public class WaterMeterServiceImp implements WaterMeterService { |
40
|
|
44
|
|
41
|
private static final String addUrl = "http://123.56.159.203:8023/nowwmrd/getSelectNowwmrdbyProjectID";
|
45
|
private static final String addUrl = "http://123.56.159.203:8023/nowwmrd/getSelectNowwmrdbyProjectID";
|
42
|
|
46
|
|
|
|
47
|
+ public WaterMeter findRealTime(String wmId) {
|
|
|
48
|
+ try {
|
|
|
49
|
+ Map<String, Object> datas = new HashMap<>();
|
|
|
50
|
+ datas.put("MtId", wmId);
|
|
|
51
|
+
|
|
|
52
|
+ String s = HttpsUtils.httpRequest(selectUrl, datas);
|
|
|
53
|
+ JSONArray jsonArray = JSON.parseArray(s);
|
|
|
54
|
+ WaterMeter waterMeter = new WaterMeter();
|
|
|
55
|
+ for (Object jsonObject : jsonArray) {
|
|
|
56
|
+
|
|
|
57
|
+ Map<String, Object> map = (Map) jsonObject;
|
|
|
58
|
+ if (!map.containsKey("state")) {
|
|
|
59
|
+ waterMeter.setWmId(map.get("wm_id").toString());
|
|
|
60
|
+ waterMeter.setWmErrmessage(map.get("wm_errmessage").toString());
|
|
|
61
|
+ waterMeter.setWmFmstate(map.get("wm_fmstate").toString());
|
|
|
62
|
+ waterMeter.setWmSacc(map.get("wm_sacc").toString());
|
|
|
63
|
+ waterMeter.setWmLacc(map.get("wm_lacc").toString());
|
|
|
64
|
+ waterMeter.setWmRdtime(map.get("wm_rdtime").toString());
|
|
|
65
|
+ waterMeter.setWmSignalpower(map.get("wm_signalpower").toString());
|
|
|
66
|
+ waterMeter.setWmVoltage(map.get("wm_voltage").toString());
|
|
|
67
|
+ }
|
|
|
68
|
+ }
|
|
|
69
|
+ return waterMeter;
|
|
|
70
|
+ } catch (Exception e) {
|
|
|
71
|
+ e.printStackTrace();
|
|
|
72
|
+ return new WaterMeter();
|
|
|
73
|
+ }
|
|
|
74
|
+ }
|
43
|
|
75
|
|
44
|
/**
|
76
|
/**
|
45
|
* 水费充值 换算总水量 生成订单
|
77
|
* 水费充值 换算总水量 生成订单
|
|
@@ -69,6 +101,21 @@ public class WaterMeterServiceImp implements WaterMeterService { |
|
@@ -69,6 +101,21 @@ public class WaterMeterServiceImp implements WaterMeterService { |
69
|
int i = waterMeterSaccMapper.updateByPrimaryKeySelective(waterMeterSacc);
|
101
|
int i = waterMeterSaccMapper.updateByPrimaryKeySelective(waterMeterSacc);
|
70
|
if (i > 0){
|
102
|
if (i > 0){
|
71
|
resultJson.setCode("200");
|
103
|
resultJson.setCode("200");
|
|
|
104
|
+
|
|
|
105
|
+ WaterMeter realTime = findRealTime(wmId);
|
|
|
106
|
+ String add_sacc = AllUtils.nubmerSubtraction(map.get("Add_sacc").toString(), realTime.getWmLacc());
|
|
|
107
|
+ boolean eleMoney = AllUtils.eleMoney(new BigDecimal(add_sacc), "3");
|
|
|
108
|
+ if (eleMoney){
|
|
|
109
|
+ String roomName = locationMapper.wmRoomName(wmId);
|
|
|
110
|
+ if (noteFormMapper.count(roomName) > 0){
|
|
|
111
|
+ NoteForm noteForm = new NoteForm();
|
|
|
112
|
+ noteForm.setInformStatus("1");
|
|
|
113
|
+ noteForm.setWaterEleType("1");
|
|
|
114
|
+ noteForm.setRoomName(roomName);
|
|
|
115
|
+ int s = noteFormMapper.updateByPrimaryKeySelective(noteForm);
|
|
|
116
|
+ log.info("充值修改短信信息表通知状态:{}", s);
|
|
|
117
|
+ }
|
|
|
118
|
+ }
|
72
|
}else {
|
119
|
}else {
|
73
|
resultJson.setCode("203");
|
120
|
resultJson.setCode("203");
|
74
|
}
|
121
|
}
|