|
@@ -0,0 +1,446 @@
|
|
|
+package io.github.pnoker.gateway.comtool;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import io.github.pnoker.gateway.dbdao.DBMgrProxy;
|
|
|
+import io.github.pnoker.gateway.dbdao.services.intef.XuChangCustomerMeterDayReadService;
|
|
|
+import io.github.pnoker.gateway.dbdao.services.intef.XuChangCustomerWaterConfigService;
|
|
|
+import io.github.pnoker.gateway.dbdao.services.intef.XuChangCustomerWaterInfoService;
|
|
|
+import io.github.pnoker.gateway.dbdao.tables.XuChangCustomerWaterConfigTable;
|
|
|
+import io.github.pnoker.gateway.dbdao.tables.XuChangCustomerWaterInfoTable;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
+import org.springframework.remoting.RemoteAccessException;
|
|
|
+
|
|
|
+import org.springframework.retry.annotation.Backoff;
|
|
|
+import org.springframework.retry.annotation.Retryable;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.net.URL;
|
|
|
+import java.net.URLConnection;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName XuchangWaterConfig
|
|
|
+ * @Description: TODO 许昌800只户表数据查询
|
|
|
+ * @Author LX
|
|
|
+ * @Date 2024/1/30
|
|
|
+ * @Version V1.0
|
|
|
+ **/
|
|
|
+@Configuration
|
|
|
+public class XuchangWaterConfig {
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(XuchangWaterConfig.class);
|
|
|
+
|
|
|
+ private static volatile String url = "";
|
|
|
+ private static volatile String user = "";
|
|
|
+ private static volatile String pwd = "";
|
|
|
+
|
|
|
+ private static XuChangCustomerWaterConfigService getXuChangCustomerWaterConfigApi(){
|
|
|
+ return DBMgrProxy.getInstance().applyXuchangCustomerWaterConfigApi();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static XuChangCustomerWaterInfoService getXuChangCustomerWaterInfoApi(){
|
|
|
+ return DBMgrProxy.getInstance().applyXuchangCustomerWaterInfoApi();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static XuChangCustomerMeterDayReadService getXuChangCustomerMeterDayReadApi(){
|
|
|
+ return DBMgrProxy.getInstance().applyXuChangCustomerMeterDayReadApi();
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 初始化方法
|
|
|
+ //TODO 远程WebService查询智能水表接口
|
|
|
+ public void init() {
|
|
|
+ try {
|
|
|
+ YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
|
|
|
+//此处是为了找到对应yaml文件的位置
|
|
|
+ yaml.setResources(new ClassPathResource("application.yml"));
|
|
|
+ Properties properties = yaml.getObject();
|
|
|
+ if(StringUtils.isEmpty(user)) {
|
|
|
+ user = properties.getProperty("xuchang.user");
|
|
|
+ }
|
|
|
+ if(StringUtils.isEmpty(pwd)) {
|
|
|
+ pwd = properties.getProperty("xuchang.pwd");
|
|
|
+ }
|
|
|
+ if(StringUtils.isEmpty(url)) {
|
|
|
+ url = properties.getProperty("xuchang.url");
|
|
|
+ }
|
|
|
+ //TODO 首先查询config配置信息, 通过配置信息查询用户以及日用量记录
|
|
|
+ List<Map<String,Object>> configList = new ArrayList<>();
|
|
|
+ int nTotals = getXuChangCustomerWaterConfigApi().totalCountsEx("", null, null, "");
|
|
|
+ if(nTotals>0){
|
|
|
+ //TODO 优化 以分页方式查询所有,初始分页行数定为3000查询速率较好
|
|
|
+ int pageNum = nTotals%3000==0?nTotals/3000:(nTotals/3000)+1;//总页数
|
|
|
+
|
|
|
+ Integer limit = 3000;
|
|
|
+ if(pageNum<=1){
|
|
|
+ limit = nTotals;//说明总数比第一页小
|
|
|
+ }
|
|
|
+ for (int i = 0; i < pageNum; i++) {
|
|
|
+ Integer offset = i*limit;
|
|
|
+ List<Map<String,Object>> arrTmpDbs = getXuChangCustomerWaterConfigApi().listAllWiths(
|
|
|
+ limit,
|
|
|
+ offset,
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ XuChangCustomerWaterConfigTable.R_INFO.DEFAULT_ORDER,
|
|
|
+ "");
|
|
|
+ if(!CollectionUtils.isEmpty(arrTmpDbs)){
|
|
|
+ configList.addAll(arrTmpDbs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ //TODO 得到配置列表后 , 查询相应信息的用户信息和户表信息并进行数据插入
|
|
|
+ //TODO 用户信息相关集合
|
|
|
+ List<Map<String,Object>> dataMaps = new ArrayList<>();
|
|
|
+ List<Map<String,Object>> upDataMaps = new ArrayList<>();
|
|
|
+ List<Map<String,Object>> upAndWheres = new ArrayList<>();//修改条件
|
|
|
+
|
|
|
+ //TODO 日用量信息相关集合
|
|
|
+ List<Map<String,Object>> dayReadDataMaps = new ArrayList<>();
|
|
|
+ List<Map<String,Object>> dayReadUpDataMaps = new ArrayList<>();
|
|
|
+ List<Map<String,Object>> dayReadUpAndWheres = new ArrayList<>();//修改条件
|
|
|
+ for(Map<String,Object> map:configList){
|
|
|
+ //TODO 查询用户信息是否存在 , 若存在则修改 , 不存在则新增
|
|
|
+ JSONArray userArray = getUserInfo(user,pwd,!StringUtils.isEmpty(map.get("user_code"))?map.get("user_code").toString():"");
|
|
|
+ if(userArray!=null&&userArray.size()>0){
|
|
|
+ JSONObject userObj = JSONObject.parseObject(userArray.get(0).toString());
|
|
|
+ Map<String,Object> andWheres = new HashMap<>();
|
|
|
+ andWheres.put(XuChangCustomerWaterInfoTable.R_INFO.METER_ADDR,userObj.getString("meterAddr"));
|
|
|
+ List<Map<String,Object>> userListRes = getXuChangCustomerWaterInfoApi().listAllWiths(1,0,andWheres,null,"","");
|
|
|
+ if(CollectionUtils.isEmpty(userListRes)){
|
|
|
+ //TODO 新增
|
|
|
+ Map<String,Object> dataMap = new HashMap<>();
|
|
|
+ dataMap.put("uid","UI"+UUID.randomUUID());
|
|
|
+ dataMap.put("user_code",userObj.getString("usercode"));
|
|
|
+ dataMap.put("user_name",userObj.getString("username"));
|
|
|
+ dataMap.put("door_plate",userObj.getString("doorplate"));
|
|
|
+ dataMap.put("address",userObj.getString("address"));
|
|
|
+ dataMap.put("meter_addr",userObj.getString("meterAddr"));
|
|
|
+ dataMap.put("meter_type_name",userObj.getString("meterTypeName"));
|
|
|
+ dataMap.put("phone",userObj.getString("phone"));
|
|
|
+ dataMap.put("reserve",userObj.getString("reserve"));
|
|
|
+ dataMap.put("remnant",userObj.getString("remnant"));
|
|
|
+ dataMap.put("gis",map.get("gis"));
|
|
|
+ dataMap.put("territory",userObj.getString("territory"));
|
|
|
+ dataMaps.add(dataMap);
|
|
|
+ }else{
|
|
|
+ //TODO 修改
|
|
|
+ Map<String,Object> dataMap = new HashMap<>();
|
|
|
+ dataMap.put("user_code",userObj.getString("usercode"));
|
|
|
+ dataMap.put("user_name",userObj.getString("username"));
|
|
|
+ dataMap.put("door_plate",userObj.getString("doorplate"));
|
|
|
+ dataMap.put("address",userObj.getString("address"));
|
|
|
+ dataMap.put("meter_addr",userObj.getString("meterAddr"));
|
|
|
+ dataMap.put("meter_type_name",userObj.getString("meterTypeName"));
|
|
|
+ dataMap.put("phone",userObj.getString("phone"));
|
|
|
+ dataMap.put("reserve",userObj.getString("reserve"));
|
|
|
+ dataMap.put("remnant",userObj.getString("remnant"));
|
|
|
+ dataMap.put("gis",map.get("gis"));
|
|
|
+ dataMap.put("territory",userObj.getString("territory"));
|
|
|
+ Map<String,Object> aw = new HashMap<>();
|
|
|
+ aw.put("uid",userListRes.get(0).get("uid"));
|
|
|
+
|
|
|
+ upAndWheres.add(aw);
|
|
|
+ upDataMaps.add(dataMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 用户信息新增/修改完毕后, 然后新增/修改日用量表信息
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ JSONArray dayReadArray = getFreezeDayDosage(user,pwd,now.minusDays(1).format(formatter),now.format(formatter),
|
|
|
+ String.valueOf(map.get(XuChangCustomerWaterConfigTable.R_INFO.METER_ADDR)==null?"":map.get(XuChangCustomerWaterConfigTable.R_INFO.METER_ADDR)),1,1000);
|
|
|
+ if(dayReadArray!=null&&dayReadArray.size()>0){
|
|
|
+ JSONObject dayReadObj = JSONObject.parseObject(dayReadArray.get(0).toString());
|
|
|
+ Map<String,Object> andWheres = new HashMap<>();
|
|
|
+ andWheres.put("insert_date",TimeTool.convertDateStr2UTC(dayReadObj.getString("insertDate")));
|
|
|
+ List<Map<String,Object>> dayReadRes = getXuChangCustomerMeterDayReadApi().listAllWiths(1,0,andWheres,null,"","");
|
|
|
+ if(CollectionUtils.isEmpty(dayReadRes)) {
|
|
|
+ //TODO 新增
|
|
|
+ Map<String,Object> dataMap = new HashMap<>();
|
|
|
+ dataMap.put("uid","UR"+UUID.randomUUID());
|
|
|
+ dataMap.put("meter_addr",dayReadObj.getString("meterAddr"));
|
|
|
+ dataMap.put("begin_date",dayReadObj.getString("beginDate"));
|
|
|
+ dataMap.put("freeze_date",dayReadObj.getString("freezeDate"));
|
|
|
+ dataMap.put("begin_number",dayReadObj.getString("beginNumber"));
|
|
|
+ dataMap.put("end_number",dayReadObj.getString("endNumber"));
|
|
|
+ dataMap.put("use_number",dayReadObj.getString("useNumber"));
|
|
|
+ dataMap.put("insert_date", TimeTool.convertDateStr2UTC(dayReadObj.getString("insertDate")));
|
|
|
+
|
|
|
+ dayReadDataMaps.add(dataMap);
|
|
|
+ }else{
|
|
|
+ //TODO 修改
|
|
|
+ Map<String,Object> dataMap = new HashMap<>();
|
|
|
+ dataMap.put("meter_addr",dayReadObj.getString("meterAddr"));
|
|
|
+ dataMap.put("begin_date",dayReadObj.getString("beginDate"));
|
|
|
+ dataMap.put("freeze_date",dayReadObj.getString("freezeDate"));
|
|
|
+ dataMap.put("begin_number",dayReadObj.getDoubleValue("beginNumber"));
|
|
|
+ dataMap.put("end_number",dayReadObj.getDoubleValue("endNumber"));
|
|
|
+ dataMap.put("use_number",dayReadObj.getDoubleValue("useNumber"));
|
|
|
+ Map<String,Object> aw = new HashMap<>();
|
|
|
+ aw.put("uid",dayReadRes.get(0).get("uid"));
|
|
|
+ aw.put("insert_date",dayReadRes.get(0).get("insert_date"));
|
|
|
+
|
|
|
+ dayReadUpDataMaps.add(dataMap);
|
|
|
+ dayReadUpAndWheres.add(aw);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int nRes = 0;
|
|
|
+ if(!CollectionUtils.isEmpty(dataMaps)) {
|
|
|
+ nRes = getXuChangCustomerWaterInfoApi().bacthInserts(dataMaps);
|
|
|
+ }
|
|
|
+ if(!CollectionUtils.isEmpty(upDataMaps)){
|
|
|
+ nRes = getXuChangCustomerWaterInfoApi().bacthUpdates(upDataMaps,upAndWheres);
|
|
|
+ }
|
|
|
+ log.info(0+"XuchangWaterConfig"
|
|
|
+ +String.format("XuchangWaterInfo_Success" + " nRes: %s====>"
|
|
|
+ ,nRes));
|
|
|
+
|
|
|
+ int nReadRes = 0;
|
|
|
+ if(!CollectionUtils.isEmpty(dayReadDataMaps)) {
|
|
|
+ nReadRes = getXuChangCustomerMeterDayReadApi().bacthInserts(dayReadDataMaps);
|
|
|
+ }
|
|
|
+ if(!CollectionUtils.isEmpty(dayReadUpDataMaps)){
|
|
|
+ nReadRes = getXuChangCustomerMeterDayReadApi().bacthUpdates(dayReadUpDataMaps,dayReadUpAndWheres);
|
|
|
+ }
|
|
|
+ log.info(0+"XuchangWaterConfig"
|
|
|
+ +String.format("XuchangMeterDayRead_Success" + " nReadRes: %s====>"
|
|
|
+ ,nReadRes));
|
|
|
+ }catch(Exception ex){
|
|
|
+ ex.printStackTrace();
|
|
|
+ log.error(2+ "XuchangWaterConfig"
|
|
|
+ +String.format("XuchangWater_Error" + " errorMsg: %s====>"
|
|
|
+ , ex.getLocalizedMessage()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //TODO 获取表当前数据
|
|
|
+ @Retryable(value = {RemoteAccessException.class}, maxAttempts = 3, backoff = @Backoff(delay = 200L, multiplier = 1))
|
|
|
+ public static JSONArray creatPostAndTransData(String A,String B,int C,String D,int page,int pageSize) {
|
|
|
+ String line = "";
|
|
|
+ // 用来存储接收到的返回值
|
|
|
+ StringBuffer resultStringBuffer = new StringBuffer();
|
|
|
+ OutputStreamWriter out = null;
|
|
|
+ try {
|
|
|
+ // 根据url连接接口
|
|
|
+ URL realUrl = new URL(url);
|
|
|
+ URLConnection urlConnection = realUrl.openConnection();
|
|
|
+ // 根据需要,将传来的接口参数组装为xml文本
|
|
|
+ String xmlInfo = getGetReadNowDataXmlInfo(A,B,C,D,page,pageSize);
|
|
|
+ byte[] xmlInfoBytes = xmlInfo.getBytes();
|
|
|
+ urlConnection.setDoInput(true);
|
|
|
+ urlConnection.setDoOutput(true);
|
|
|
+ urlConnection.setUseCaches(false);
|
|
|
+ urlConnection.setRequestProperty("Content-Type","text/xml; charset=utf-8");
|
|
|
+ urlConnection.setRequestProperty("Content-length",String.valueOf(xmlInfoBytes.length));
|
|
|
+ out = new OutputStreamWriter(urlConnection.getOutputStream());
|
|
|
+ out.write(new String(xmlInfo.getBytes(StandardCharsets.ISO_8859_1)));
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ // 开始接收返回值
|
|
|
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
|
|
|
+ for (line = bufferedReader.readLine(); line != null;line = bufferedReader.readLine()) {
|
|
|
+ resultStringBuffer.append(line);
|
|
|
+ }
|
|
|
+ // 从返回的文本中,截取出我们需要的内容
|
|
|
+ int beginIndex = resultStringBuffer.indexOf("<NBIoT_GetReadNowDataResult>") + 28;
|
|
|
+ int endIndex = resultStringBuffer.lastIndexOf("</NBIoT_GetReadNowDataResult>");
|
|
|
+ String jsonString = resultStringBuffer.toString().substring(beginIndex,endIndex);
|
|
|
+ JSONObject result = JSONObject.parseObject(jsonString);
|
|
|
+ String outResult = result.getString("outResult");
|
|
|
+ JSONArray jsonArray = null;
|
|
|
+ if(!StringUtils.isEmpty(outResult)&&"1".equals(outResult)){
|
|
|
+ jsonArray = result.getJSONArray("outData");
|
|
|
+ }else{
|
|
|
+ log.error("waterErrorCode:"+outResult+";waterErrorMsg:"+result.getString("outMsg"));
|
|
|
+ }
|
|
|
+ // List<Map> list = JSONObject.parseArray(jsonArray.toString(),Map.class);
|
|
|
+ return jsonArray;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (out != null) {
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO TODO 获取表日用量
|
|
|
+ @Retryable(value = {RemoteAccessException.class}, maxAttempts = 3, backoff = @Backoff(delay = 200L, multiplier = 1))
|
|
|
+ public static JSONArray getFreezeDayDosage(String A,String B,String C,String D,String F,int page,int pageSize) {
|
|
|
+ String line = "";
|
|
|
+ // 用来存储接收到的返回值
|
|
|
+ StringBuffer resultStringBuffer = new StringBuffer();
|
|
|
+ OutputStreamWriter out = null;
|
|
|
+ try {
|
|
|
+ // 根据url连接接口
|
|
|
+ URL realUrl = new URL(url);
|
|
|
+ URLConnection urlConnection = realUrl.openConnection();
|
|
|
+ // 根据需要,将传来的接口参数组装为xml文本
|
|
|
+ String xmlInfo = getGetFreezeDayDosageXmlInfo(A,B,C,D,F,page,pageSize);
|
|
|
+ byte[] xmlInfoBytes = xmlInfo.getBytes();
|
|
|
+ urlConnection.setDoInput(true);
|
|
|
+ urlConnection.setDoOutput(true);
|
|
|
+ urlConnection.setUseCaches(false);
|
|
|
+ urlConnection.setRequestProperty("Content-Type","text/xml; charset=utf-8");
|
|
|
+ urlConnection.setRequestProperty("Content-length",String.valueOf(xmlInfoBytes.length));
|
|
|
+ out = new OutputStreamWriter(urlConnection.getOutputStream());
|
|
|
+ out.write(new String(xmlInfo.getBytes(StandardCharsets.ISO_8859_1)));
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ // 开始接收返回值
|
|
|
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
|
|
|
+ for (line = bufferedReader.readLine(); line != null;line = bufferedReader.readLine()) {
|
|
|
+ resultStringBuffer.append(line);
|
|
|
+ }
|
|
|
+ // 从返回的文本中,截取出我们需要的内容
|
|
|
+ int beginIndex = resultStringBuffer.indexOf("<NBIoT_GetFreezeDayDosageResult>") + 32;
|
|
|
+ int endIndex = resultStringBuffer.lastIndexOf("</NBIoT_GetFreezeDayDosageResult>");
|
|
|
+ String jsonString = resultStringBuffer.toString().substring(beginIndex,endIndex);
|
|
|
+ JSONObject result = JSONObject.parseObject(jsonString);
|
|
|
+ String outResult = result.getString("outResult");
|
|
|
+ JSONArray jsonArray = null;
|
|
|
+ if(!StringUtils.isEmpty(outResult)&&"1".equals(outResult)){
|
|
|
+ jsonArray = result.getJSONArray("outData");
|
|
|
+ }else{
|
|
|
+ log.error("waterErrorCode:"+outResult+";waterErrorMsg:"+result.getString("outMsg"));
|
|
|
+ }
|
|
|
+ // List<Map> list = JSONObject.parseArray(jsonArray.toString(),Map.class);
|
|
|
+ return jsonArray;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (out != null) {
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO TODO 获取用户信息
|
|
|
+ @Retryable(value = {RemoteAccessException.class}, maxAttempts = 3, backoff = @Backoff(delay = 200L, multiplier = 1))
|
|
|
+ public static JSONArray getUserInfo(String A,String B,String C) {
|
|
|
+ String line = "";
|
|
|
+ // 用来存储接收到的返回值
|
|
|
+ StringBuffer resultStringBuffer = new StringBuffer();
|
|
|
+ OutputStreamWriter out = null;
|
|
|
+ try {
|
|
|
+ // 根据url连接接口
|
|
|
+ URL realUrl = new URL(url);
|
|
|
+ URLConnection urlConnection = realUrl.openConnection();
|
|
|
+ // 根据需要,将传来的接口参数组装为xml文本
|
|
|
+ String xmlInfo = getGetUserInfoXML(A,B,C);
|
|
|
+ byte[] xmlInfoBytes = xmlInfo.getBytes();
|
|
|
+ urlConnection.setDoInput(true);
|
|
|
+ urlConnection.setDoOutput(true);
|
|
|
+ urlConnection.setUseCaches(false);
|
|
|
+ urlConnection.setRequestProperty("Content-Type","text/xml; charset=utf-8");
|
|
|
+ urlConnection.setRequestProperty("Content-length",String.valueOf(xmlInfoBytes.length));
|
|
|
+ out = new OutputStreamWriter(urlConnection.getOutputStream());
|
|
|
+ out.write(new String(xmlInfo.getBytes(StandardCharsets.ISO_8859_1)));
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ // 开始接收返回值
|
|
|
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
|
|
|
+ for (line = bufferedReader.readLine(); line != null;line = bufferedReader.readLine()) {
|
|
|
+ resultStringBuffer.append(line);
|
|
|
+ }
|
|
|
+ // 从返回的文本中,截取出我们需要的内容
|
|
|
+ int beginIndex = resultStringBuffer.indexOf("<NBIoT_GetUserInfoResult>") + 25;
|
|
|
+ int endIndex = resultStringBuffer.lastIndexOf("</NBIoT_GetUserInfoResult>");
|
|
|
+ String jsonString = resultStringBuffer.toString().substring(beginIndex,endIndex);
|
|
|
+ JSONObject result = JSONObject.parseObject(jsonString);
|
|
|
+ String outResult = result.getString("outResult");
|
|
|
+ JSONArray jsonArray = null;
|
|
|
+ if(!StringUtils.isEmpty(outResult)&&"1".equals(outResult)){
|
|
|
+ jsonArray = result.getJSONArray("outData");
|
|
|
+ }else{
|
|
|
+ log.error("waterErrorCode:"+outResult+";waterErrorMsg:"+result.getString("outMsg"));
|
|
|
+ }
|
|
|
+ // List<Map> list = JSONObject.parseArray(jsonArray.toString(),Map.class);
|
|
|
+ return jsonArray;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (out != null) {
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String getGetReadNowDataXmlInfo(String A,String B,int C,String D,int page,int pageSize) {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ stringBuilder.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
|
|
+ stringBuilder.append("<soap:Envelope xmlns:xsi=\"http:/www.w3.org/201/XMLschema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLschema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
|
|
|
+ stringBuilder.append(" <soap:Body>");
|
|
|
+ stringBuilder.append(" <NBIoT_GetReadNowData xmlns=\"http://www.suntront.com/\">");
|
|
|
+ stringBuilder.append(" <user>"+A+"</user>");
|
|
|
+ stringBuilder.append(" <pwd>"+B+"</pwd>");
|
|
|
+ stringBuilder.append(" <pageSize>"+pageSize+"</pageSize>");
|
|
|
+ stringBuilder.append(" <currentPageIndex>"+page+"</currentPageIndex>");
|
|
|
+ stringBuilder.append(" <OrderType>"+C+"</OrderType>");
|
|
|
+ stringBuilder.append(" <meterAddr>"+D+"</meterAddr>");
|
|
|
+ stringBuilder.append(" </NBIoT_GetReadNowData>");
|
|
|
+ stringBuilder.append(" </soap:Body>");
|
|
|
+ stringBuilder.append("</soap:Envelope>");
|
|
|
+ return stringBuilder.toString();
|
|
|
+ }
|
|
|
+ private static String getGetFreezeDayDosageXmlInfo(String A,String B,String C,String D,String F,int page,int pageSize) {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ stringBuilder.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
|
|
+ stringBuilder.append("<soap:Envelope xmlns:xsi=\"http:/www.w3.org/201/XMLschema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLschema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
|
|
|
+ stringBuilder.append(" <soap:Body>");
|
|
|
+ stringBuilder.append(" <NBIoT_GetFreezeDayDosage xmlns=\"http://www.suntront.com/\">");
|
|
|
+ stringBuilder.append(" <user>"+A+"</user>");
|
|
|
+ stringBuilder.append(" <pwd>"+B+"</pwd>");
|
|
|
+ stringBuilder.append(" <pageSize>"+pageSize+"</pageSize>");
|
|
|
+ stringBuilder.append(" <currentPageIndex>"+page+"</currentPageIndex>");
|
|
|
+ stringBuilder.append(" <meterAddr>"+F+"</meterAddr>");
|
|
|
+ stringBuilder.append(" <beginDate>"+C+"</beginDate>");
|
|
|
+ stringBuilder.append(" <endDate>"+D+"</endDate>");
|
|
|
+ stringBuilder.append(" </NBIoT_GetFreezeDayDosage>");
|
|
|
+ stringBuilder.append(" </soap:Body>");
|
|
|
+ stringBuilder.append("</soap:Envelope>");
|
|
|
+ return stringBuilder.toString();
|
|
|
+ }
|
|
|
+ private static String getGetUserInfoXML(String A,String B,String C) {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ stringBuilder.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
|
|
+ stringBuilder.append("<soap:Envelope xmlns:xsi=\"http:/www.w3.org/201/XMLschema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLschema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
|
|
|
+ stringBuilder.append(" <soap:Body>");
|
|
|
+ stringBuilder.append(" <NBIoT_GetUserInfo xmlns=\"http://www.suntront.com/\">");
|
|
|
+ stringBuilder.append(" <user>"+A+"</user>");
|
|
|
+ stringBuilder.append(" <pwd>"+B+"</pwd>");
|
|
|
+ stringBuilder.append(" <userCode>"+C+"</userCode>");
|
|
|
+ stringBuilder.append(" </NBIoT_GetUserInfo>");
|
|
|
+ stringBuilder.append(" </soap:Body>");
|
|
|
+ stringBuilder.append("</soap:Envelope>");
|
|
|
+ return stringBuilder.toString();
|
|
|
+ }
|
|
|
+}
|