作者 shenhailong

水电短信通知状态修改

@@ -43,4 +43,6 @@ public interface LocationMapper { @@ -43,4 +43,6 @@ public interface LocationMapper {
43 43
44 String findRoomName(@Param(value = "eeId") String eeId); 44 String findRoomName(@Param(value = "eeId") String eeId);
45 45
  46 + String wmRoomName(@Param(value = "wmId") String eeId);
  47 +
46 } 48 }
@@ -9,7 +9,6 @@ import com.sunyo.energy.location.utils.Md5Utils; @@ -9,7 +9,6 @@ import com.sunyo.energy.location.utils.Md5Utils;
9 import lombok.extern.slf4j.Slf4j; 9 import lombok.extern.slf4j.Slf4j;
10 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.beans.factory.annotation.Value; 11 import org.springframework.beans.factory.annotation.Value;
12 -import org.springframework.scheduling.annotation.Scheduled;  
13 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
14 13
15 import java.math.BigDecimal; 14 import java.math.BigDecimal;
@@ -133,7 +132,8 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService { @@ -133,7 +132,8 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
133 noteForm.setInformStatus("1"); 132 noteForm.setInformStatus("1");
134 noteForm.setWaterEleType("2"); 133 noteForm.setWaterEleType("2");
135 noteForm.setRoomName(roomName); 134 noteForm.setRoomName(roomName);
136 - noteFormMapper.updateByPrimaryKeySelective(noteForm); 135 + int i = noteFormMapper.updateByPrimaryKeySelective(noteForm);
  136 + log.info("充值修改短信信息表通知状态:{}", i);
137 } 137 }
138 } 138 }
139 return 1; 139 return 1;
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 }
@@ -61,5 +61,13 @@ public class AllUtils { @@ -61,5 +61,13 @@ public class AllUtils {
61 61
62 } 62 }
63 63
  64 + public static boolean eleMoney(BigDecimal bigDecimal, String money){
  65 + if (bigDecimal.compareTo(new BigDecimal(money)) == -1){
  66 + return true;
  67 + }else {
  68 + return false;
  69 + }
  70 + }
  71 +
64 72
65 } 73 }
@@ -34,6 +34,10 @@ @@ -34,6 +34,10 @@
34 select adrName from location where ee_id=#{eeId, jdbcType=VARCHAR} 34 select adrName from location where ee_id=#{eeId, jdbcType=VARCHAR}
35 </select> 35 </select>
36 36
  37 + <select id="wmRoomName" parameterType="string" resultType="string">
  38 + select adrName from location where wm_id=#{wmId, jdbcType=VARCHAR}
  39 + </select>
  40 +
37 <select id="selectAllAdrName" resultMap="BaseResultMap" parameterType="java.lang.String"> 41 <select id="selectAllAdrName" resultMap="BaseResultMap" parameterType="java.lang.String">
38 select 42 select
39 * 43 *
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 </select> 23 </select>
24 24
25 <select id="count" resultType="int" parameterType="string"> 25 <select id="count" resultType="int" parameterType="string">
26 - select count(*) from note_form where room_name = #{roomName,jdbcType=VARCHAR } 26 + select count(*) from note_inform where room_name = #{roomName,jdbcType=VARCHAR} and status = '1' and water_ele_type = '2'
27 </select> 27 </select>
28 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > 28 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
29 delete from note_inform 29 delete from note_inform