| 
 | 
 | 
 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");
 | 
| 
 | 
 | 
                 }
 | 
...
 | 
...
 | 
 |