作者 shenhailong

水电短信通知状态修改

... ... @@ -43,4 +43,6 @@ public interface LocationMapper {
String findRoomName(@Param(value = "eeId") String eeId);
String wmRoomName(@Param(value = "wmId") String eeId);
}
\ No newline at end of file
... ...
... ... @@ -9,7 +9,6 @@ import com.sunyo.energy.location.utils.Md5Utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
... ... @@ -133,7 +132,8 @@ public class ElectricityMeterServiceImp implements ElectricityMeterService {
noteForm.setInformStatus("1");
noteForm.setWaterEleType("2");
noteForm.setRoomName(roomName);
noteFormMapper.updateByPrimaryKeySelective(noteForm);
int i = noteFormMapper.updateByPrimaryKeySelective(noteForm);
log.info("充值修改短信信息表通知状态:{}", i);
}
}
return 1;
... ...
package com.sunyo.energy.location.service.imp;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.sunyo.energy.location.controller.response.ResultJson;
import com.sunyo.energy.location.dao.LocationMapper;
import com.sunyo.energy.location.dao.PayRecordsMapper;
import com.sunyo.energy.location.dao.WaterMeterMapper;
import com.sunyo.energy.location.dao.WaterMeterSaccMapper;
import com.sunyo.energy.location.dao.*;
import com.sunyo.energy.location.model.NoteForm;
import com.sunyo.energy.location.model.WaterMeter;
import com.sunyo.energy.location.model.WaterMeterSacc;
import com.sunyo.energy.location.service.WaterMeterService;
import com.sunyo.energy.location.utils.AllUtils;
import com.sunyo.energy.location.utils.HttpsUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
@Slf4j
@Service
public class WaterMeterServiceImp implements WaterMeterService {
... ... @@ -31,6 +32,9 @@ public class WaterMeterServiceImp implements WaterMeterService {
@Autowired
WaterMeterSaccMapper waterMeterSaccMapper;
@Autowired
NoteFormMapper noteFormMapper;
/**
* 查询所有水表
*/
... ... @@ -40,6 +44,34 @@ public class WaterMeterServiceImp implements WaterMeterService {
private static final String addUrl = "http://123.56.159.203:8023/nowwmrd/getSelectNowwmrdbyProjectID";
public WaterMeter findRealTime(String wmId) {
try {
Map<String, Object> datas = new HashMap<>();
datas.put("MtId", wmId);
String s = HttpsUtils.httpRequest(selectUrl, datas);
JSONArray jsonArray = JSON.parseArray(s);
WaterMeter waterMeter = new WaterMeter();
for (Object jsonObject : jsonArray) {
Map<String, Object> map = (Map) jsonObject;
if (!map.containsKey("state")) {
waterMeter.setWmId(map.get("wm_id").toString());
waterMeter.setWmErrmessage(map.get("wm_errmessage").toString());
waterMeter.setWmFmstate(map.get("wm_fmstate").toString());
waterMeter.setWmSacc(map.get("wm_sacc").toString());
waterMeter.setWmLacc(map.get("wm_lacc").toString());
waterMeter.setWmRdtime(map.get("wm_rdtime").toString());
waterMeter.setWmSignalpower(map.get("wm_signalpower").toString());
waterMeter.setWmVoltage(map.get("wm_voltage").toString());
}
}
return waterMeter;
} catch (Exception e) {
e.printStackTrace();
return new WaterMeter();
}
}
/**
* 水费充值 换算总水量 生成订单
... ... @@ -69,6 +101,21 @@ public class WaterMeterServiceImp implements WaterMeterService {
int i = waterMeterSaccMapper.updateByPrimaryKeySelective(waterMeterSacc);
if (i > 0){
resultJson.setCode("200");
WaterMeter realTime = findRealTime(wmId);
String add_sacc = AllUtils.nubmerSubtraction(map.get("Add_sacc").toString(), realTime.getWmLacc());
boolean eleMoney = AllUtils.eleMoney(new BigDecimal(add_sacc), "3");
if (eleMoney){
String roomName = locationMapper.wmRoomName(wmId);
if (noteFormMapper.count(roomName) > 0){
NoteForm noteForm = new NoteForm();
noteForm.setInformStatus("1");
noteForm.setWaterEleType("1");
noteForm.setRoomName(roomName);
int s = noteFormMapper.updateByPrimaryKeySelective(noteForm);
log.info("充值修改短信信息表通知状态:{}", s);
}
}
}else {
resultJson.setCode("203");
}
... ...
... ... @@ -61,5 +61,13 @@ public class AllUtils {
}
public static boolean eleMoney(BigDecimal bigDecimal, String money){
if (bigDecimal.compareTo(new BigDecimal(money)) == -1){
return true;
}else {
return false;
}
}
}
... ...
... ... @@ -34,6 +34,10 @@
select adrName from location where ee_id=#{eeId, jdbcType=VARCHAR}
</select>
<select id="wmRoomName" parameterType="string" resultType="string">
select adrName from location where wm_id=#{wmId, jdbcType=VARCHAR}
</select>
<select id="selectAllAdrName" resultMap="BaseResultMap" parameterType="java.lang.String">
select
*
... ...
... ... @@ -23,7 +23,7 @@
</select>
<select id="count" resultType="int" parameterType="string">
select count(*) from note_form where room_name = #{roomName,jdbcType=VARCHAR }
select count(*) from note_inform where room_name = #{roomName,jdbcType=VARCHAR} and status = '1' and water_ele_type = '2'
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from note_inform
... ...