正在显示
6 个修改的文件
包含
89 行增加
和
8 行删除
@@ -6,17 +6,28 @@ import com.github.pagehelper.PageHelper; | @@ -6,17 +6,28 @@ import com.github.pagehelper.PageHelper; | ||
6 | import com.github.pagehelper.PageInfo; | 6 | import com.github.pagehelper.PageInfo; |
7 | import com.sunyo.energy.location.controller.response.ResultJson; | 7 | import com.sunyo.energy.location.controller.response.ResultJson; |
8 | import com.sunyo.energy.location.dao.LocationMapper; | 8 | import com.sunyo.energy.location.dao.LocationMapper; |
9 | +import com.sunyo.energy.location.dao.WaterMeterMapper; | ||
10 | +import com.sunyo.energy.location.dao.WaterMeterSaccMapper; | ||
9 | import com.sunyo.energy.location.model.Location; | 11 | import com.sunyo.energy.location.model.Location; |
12 | +import com.sunyo.energy.location.model.WaterMeter; | ||
13 | +import com.sunyo.energy.location.model.WaterMeterSacc; | ||
14 | +import com.sunyo.energy.location.service.WaterMeterService; | ||
15 | +import com.sunyo.energy.location.utils.AllUtils; | ||
16 | +import com.sunyo.energy.location.utils.HttpsUtils; | ||
10 | import io.swagger.annotations.ApiOperation; | 17 | import io.swagger.annotations.ApiOperation; |
18 | +import lombok.extern.log4j.Log4j; | ||
19 | +import lombok.extern.slf4j.Slf4j; | ||
11 | import org.apache.ibatis.annotations.Param; | 20 | import org.apache.ibatis.annotations.Param; |
21 | +import org.omg.CORBA.OBJECT_NOT_EXIST; | ||
12 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; |
13 | import org.springframework.util.StringUtils; | 23 | import org.springframework.util.StringUtils; |
14 | import org.springframework.web.bind.annotation.*; | 24 | import org.springframework.web.bind.annotation.*; |
15 | 25 | ||
26 | +import java.math.BigDecimal; | ||
16 | import java.util.HashMap; | 27 | import java.util.HashMap; |
17 | import java.util.List; | 28 | import java.util.List; |
18 | import java.util.Map; | 29 | import java.util.Map; |
19 | - | 30 | +@Slf4j |
20 | @RestController | 31 | @RestController |
21 | @RequestMapping("/location") | 32 | @RequestMapping("/location") |
22 | public class LocationController { | 33 | public class LocationController { |
@@ -24,6 +35,12 @@ public class LocationController { | @@ -24,6 +35,12 @@ public class LocationController { | ||
24 | @Autowired | 35 | @Autowired |
25 | private LocationMapper locationMapper; | 36 | private LocationMapper locationMapper; |
26 | 37 | ||
38 | + @Autowired | ||
39 | + private WaterMeterSaccMapper waterMeterSaccMapper; | ||
40 | + | ||
41 | + @Autowired | ||
42 | + private WaterMeterService waterMeterService; | ||
43 | + | ||
27 | @ApiOperation(value = "查询楼层") | 44 | @ApiOperation(value = "查询楼层") |
28 | @RequestMapping(value = "/list", method = RequestMethod.GET) | 45 | @RequestMapping(value = "/list", method = RequestMethod.GET) |
29 | public ResultJson startActivityDemo(@RequestParam(value = "pageNum", required = false, defaultValue = "1") | 46 | public ResultJson startActivityDemo(@RequestParam(value = "pageNum", required = false, defaultValue = "1") |
@@ -106,16 +123,49 @@ public class LocationController { | @@ -106,16 +123,49 @@ public class LocationController { | ||
106 | 123 | ||
107 | @ApiOperation(value = "修改楼层") | 124 | @ApiOperation(value = "修改楼层") |
108 | @PutMapping(value = "/edit") | 125 | @PutMapping(value = "/edit") |
109 | - public ResultJson editLocation(@RequestBody Location location) { | 126 | + public ResultJson editLocation(@RequestBody Location location) throws Exception { |
110 | 127 | ||
111 | ResultJson resultJson = new ResultJson(); | 128 | ResultJson resultJson = new ResultJson(); |
112 | - | ||
113 | - if (locationMapper.updateByPrimaryKeySelective(location) > 0) { | 129 | + String wmId = locationMapper.findWmId(location.getAdrname()); |
130 | + WaterMeterSacc waterMeterSacc = new WaterMeterSacc(); | ||
131 | + waterMeterSacc.setOrderWmId(wmId); | ||
132 | + waterMeterSacc.setWmId(location.getWmid()); | ||
133 | + // 查询旧表实施数据 | ||
134 | + WaterMeter realTime = waterMeterService.findRealTime(wmId); | ||
135 | + // 计算旧表余量 新表累计充值量 = 旧表余量 | ||
136 | + String newWmIdSacc = AllUtils.nubmerSubtraction(realTime.getWmSacc(), realTime.getWmLacc()); | ||
137 | + log.info("旧表余量:{}",newWmIdSacc); | ||
138 | + waterMeterSacc.setWmSacc(new BigDecimal(newWmIdSacc)); | ||
139 | + // 充值新表水量 | ||
140 | + Map<String, Object> datas = new HashMap<>(); | ||
141 | + datas.put("MtId", wmId); | ||
142 | + datas.put("Add_sacc", newWmIdSacc); | ||
143 | + datas.put("Add_addmode", "2"); | ||
144 | + String status = HttpsUtils.httpRequest("http://123.56.159.203:8023/mtfmset/allWMadd", datas); | ||
145 | + datas.put("status", status); | ||
146 | + log.info("新表充值:{}",status); | ||
147 | + log.info("充值成功更新水表"); | ||
148 | + if (locationMapper.updateByPrimaryKeySelective(location) > 0 && waterMeterSaccMapper.updateWater(waterMeterSacc) > 0) { | ||
149 | + log.info("更新成功"); | ||
114 | resultJson.setCode("200"); | 150 | resultJson.setCode("200"); |
115 | } else { | 151 | } else { |
116 | resultJson.setCode("201"); | 152 | resultJson.setCode("201"); |
117 | } | 153 | } |
118 | - | ||
119 | return resultJson; | 154 | return resultJson; |
120 | } | 155 | } |
156 | + | ||
157 | + @ApiOperation(value = "远程水表阀开") | ||
158 | + @GetMapping(value = "/allAddMtfmset") | ||
159 | + public ResultJson allAddMtfmset(@RequestParam("MtId") String mtId, | ||
160 | + @RequestParam("MtFm") String mtFm) throws Exception { | ||
161 | + Map<String, Object> map = new HashMap<>(); | ||
162 | + map.put("MtId", mtId); | ||
163 | + map.put("MtFm", mtFm); | ||
164 | + | ||
165 | + String s = HttpsUtils.httpRequest("http://123.56.159.203:8023/mtfmset/allAddMtfmset", map); | ||
166 | + if (s.contains("0")){ | ||
167 | + return new ResultJson("200", "success"); | ||
168 | + } | ||
169 | + return new ResultJson("201", "error"); | ||
170 | + } | ||
121 | } | 171 | } |
@@ -18,5 +18,7 @@ public interface WaterMeterSaccMapper { | @@ -18,5 +18,7 @@ public interface WaterMeterSaccMapper { | ||
18 | 18 | ||
19 | int updateByPrimaryKeySelective(WaterMeterSacc record); | 19 | int updateByPrimaryKeySelective(WaterMeterSacc record); |
20 | 20 | ||
21 | + int updateWater(WaterMeterSacc record); | ||
22 | + | ||
21 | int updateByPrimaryKey(WaterMeterSacc record); | 23 | int updateByPrimaryKey(WaterMeterSacc record); |
22 | } | 24 | } |
@@ -77,8 +77,9 @@ public class HttpClientUtil { | @@ -77,8 +77,9 @@ public class HttpClientUtil { | ||
77 | System.out.println("GetPage:" + url); | 77 | System.out.println("GetPage:" + url); |
78 | String content = null; | 78 | String content = null; |
79 | if (url == null || url.trim().length() == 0 || paramMap == null | 79 | if (url == null || url.trim().length() == 0 || paramMap == null |
80 | - || paramMap.isEmpty()) | 80 | + || paramMap.isEmpty()) { |
81 | return null; | 81 | return null; |
82 | + } | ||
82 | HttpClient httpClient = new HttpClient(); | 83 | HttpClient httpClient = new HttpClient(); |
83 | //����header | 84 | //����header |
84 | httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT, "Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.2) Gecko/20090803 Fedora/3.5.2-2.fc11 Firefox/3.5.2");// | 85 | httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT, "Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.2) Gecko/20090803 Fedora/3.5.2-2.fc11 Firefox/3.5.2");// |
@@ -98,10 +99,11 @@ public class HttpClientUtil { | @@ -98,10 +99,11 @@ public class HttpClientUtil { | ||
98 | } | 99 | } |
99 | if (o != null && o instanceof String[]) { | 100 | if (o != null && o instanceof String[]) { |
100 | String[] s = (String[]) o; | 101 | String[] s = (String[]) o; |
101 | - if (s != null) | 102 | + if (s != null) { |
102 | for (int i = 0; i < s.length; i++) { | 103 | for (int i = 0; i < s.length; i++) { |
103 | method.addParameter(new NameValuePair(key, s[i])); | 104 | method.addParameter(new NameValuePair(key, s[i])); |
104 | } | 105 | } |
106 | + } | ||
105 | } | 107 | } |
106 | } | 108 | } |
107 | try { | 109 | try { |
@@ -117,7 +119,9 @@ public class HttpClientUtil { | @@ -117,7 +119,9 @@ public class HttpClientUtil { | ||
117 | System.out.println("time out"); | 119 | System.out.println("time out"); |
118 | e.printStackTrace(); | 120 | e.printStackTrace(); |
119 | } finally { | 121 | } finally { |
120 | - if (method != null) method.releaseConnection(); | 122 | + if (method != null) { |
123 | + method.releaseConnection(); | ||
124 | + } | ||
121 | method = null; | 125 | method = null; |
122 | httpClient = null; | 126 | httpClient = null; |
123 | } | 127 | } |
@@ -11,6 +11,8 @@ public class WaterMeterSacc { | @@ -11,6 +11,8 @@ public class WaterMeterSacc { | ||
11 | 11 | ||
12 | private BigDecimal wmSacc; | 12 | private BigDecimal wmSacc; |
13 | 13 | ||
14 | + private String orderWmId; | ||
15 | + | ||
14 | public String getWmId() { | 16 | public String getWmId() { |
15 | return wmId; | 17 | return wmId; |
16 | } | 18 | } |
@@ -42,4 +44,12 @@ public class WaterMeterSacc { | @@ -42,4 +44,12 @@ public class WaterMeterSacc { | ||
42 | public void setWmSacc(BigDecimal wmSacc) { | 44 | public void setWmSacc(BigDecimal wmSacc) { |
43 | this.wmSacc = wmSacc; | 45 | this.wmSacc = wmSacc; |
44 | } | 46 | } |
47 | + | ||
48 | + public String getOrderWmId() { | ||
49 | + return orderWmId; | ||
50 | + } | ||
51 | + | ||
52 | + public void setOrderWmId(String orderWmId) { | ||
53 | + this.orderWmId = orderWmId; | ||
54 | + } | ||
45 | } | 55 | } |
@@ -258,6 +258,7 @@ public class WaterMeterServiceImp implements WaterMeterService { | @@ -258,6 +258,7 @@ public class WaterMeterServiceImp implements WaterMeterService { | ||
258 | String s = AllUtils.nubmerDivision(payFees); | 258 | String s = AllUtils.nubmerDivision(payFees); |
259 | // 查询累计充值量 | 259 | // 查询累计充值量 |
260 | WaterMeterSacc waterMeterSacc = waterMeterSaccMapper.selectByPrimaryKey(AllUtils.wmIdUtils(wmId)); | 260 | WaterMeterSacc waterMeterSacc = waterMeterSaccMapper.selectByPrimaryKey(AllUtils.wmIdUtils(wmId)); |
261 | + // 充值水量 + 累计充值量 = 总累计充值量 | ||
261 | String allSacc = AllUtils.nubmerAdd(s, waterMeterSacc.getWmSacc()); | 262 | String allSacc = AllUtils.nubmerAdd(s, waterMeterSacc.getWmSacc()); |
262 | Map<String, Object> datas = new HashMap<>(); | 263 | Map<String, Object> datas = new HashMap<>(); |
263 | datas.put("MtId", wmId); | 264 | datas.put("MtId", wmId); |
@@ -82,6 +82,20 @@ | @@ -82,6 +82,20 @@ | ||
82 | </set> | 82 | </set> |
83 | where wm_id = #{wmId,jdbcType=VARCHAR} | 83 | where wm_id = #{wmId,jdbcType=VARCHAR} |
84 | </update> | 84 | </update> |
85 | + | ||
86 | + <update id="updateWater" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" > | ||
87 | + update water_meter_sacc | ||
88 | + <set > | ||
89 | + <if test="wmId != null" > | ||
90 | + wm_id = #{wmId,jdbcType=VARCHAR}, | ||
91 | + </if> | ||
92 | + <if test="wmSacc != null" > | ||
93 | + wm_sacc = #{wmSacc,jdbcType=VARCHAR} | ||
94 | + </if> | ||
95 | + </set> | ||
96 | + where wm_id = #{orderWmId,jdbcType=VARCHAR} | ||
97 | + </update> | ||
98 | + | ||
85 | <update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" > | 99 | <update id="updateByPrimaryKey" parameterType="com.sunyo.energy.location.model.WaterMeterSacc" > |
86 | update water_meter_sacc | 100 | update water_meter_sacc |
87 | set ardname = #{ardname,jdbcType=VARCHAR}, | 101 | set ardname = #{ardname,jdbcType=VARCHAR}, |
-
请 注册 或 登录 后发表评论