Commit 710821ad authored by ZWT's avatar ZWT

feat(吉林演示): 松原

1.修改风电站运行状态接口,增加模拟实际发电功率处理逻辑,完成接口冒烟测试;
2.修改天气数据处理定时任务,解决晚上十一点半天气预报数据处理异常问题,修改风资源预测数据和光伏资源预测数据时间处理逻辑,完成接口冒烟测试;
3.修改风机预测数据模块相关功能接口,增加判断当前部署环境逻辑,解决查询全量数据问题;
4.修改风机预测数据生成模块第三方风力发电数据生成功能,增加数据拆分逻辑,区分15分数据层级,完成功能冒烟测试;
5.修改风机预测监控页面历史风速统计接口,统计数据不显示问题及小数位过多问题;
6.修改天气预报数据爬取定时任务,解决8:00-11:00期间没有数据问题,完成功能验证;
7,修改风资源预测历史数据处理定时任务,修改查询逻辑,解决未保存历史预测数据问题;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 79e00805
...@@ -255,4 +255,13 @@ public class BaseUtils { ...@@ -255,4 +255,13 @@ public class BaseUtils {
} }
return cycleRatio; return cycleRatio;
} }
/**
* 获取uuid字符串
*
* @return {@link String }
*/
public static String randomUUIDString() {
return UUID.randomUUID(true).toString(true);
}
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package pps.core.common.utils; ...@@ -2,6 +2,7 @@ package pps.core.common.utils;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
...@@ -10,7 +11,6 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook; ...@@ -10,7 +11,6 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import xstartup.base.util.XDateUtils; import xstartup.base.util.XDateUtils;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.*; import java.util.*;
...@@ -130,24 +130,6 @@ public class ExcelUtils { ...@@ -130,24 +130,6 @@ public class ExcelUtils {
} }
} }
/**
* 根据文件后缀名类型获取对应的工作簿对象
*
* @param inputStream 读取文件的输入流
* @param fileType 文件后缀名类型(xls或xlsx)
* @return 包含文件数据的工作簿对象
* @throws IOException
*/
public static Workbook getWorkbook(InputStream inputStream, String fileType) throws IOException {
Workbook workbook = null;
if (CharSequenceUtil.equalsIgnoreCase(fileType, XLS)) {
workbook = new HSSFWorkbook(inputStream);
} else if (CharSequenceUtil.equalsIgnoreCase(fileType, XLSX)) {
workbook = new XSSFWorkbook(inputStream);
}
return workbook;
}
/** /**
* 读取Excel文件内容 * 读取Excel文件内容
* *
...@@ -156,26 +138,27 @@ public class ExcelUtils { ...@@ -156,26 +138,27 @@ public class ExcelUtils {
* @return 读取结果列表,读取失败时返回null * @return 读取结果列表,读取失败时返回null
*/ */
public static List<Map<String, Object>> readExcel(InputStream inputStream, String fileName, List<String> headerList, Integer sheetIndex) { public static List<Map<String, Object>> readExcel(InputStream inputStream, String fileName, List<String> headerList, Integer sheetIndex) {
Workbook workbook; Workbook workbook = null;
try { try {
// 获取Excel后缀名 // 获取Excel后缀名
String fileType = fileName.substring(fileName.lastIndexOf(".") + 1); String fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
// 获取Excel工作簿 // 获取Excel工作簿
workbook = getWorkbook(inputStream, fileType); if (CharSequenceUtil.equalsIgnoreCase(fileType, XLS)) {
workbook = new HSSFWorkbook(inputStream);
} else if (CharSequenceUtil.equalsIgnoreCase(fileType, XLSX)) {
workbook = new XSSFWorkbook(inputStream);
}
if (ObjectUtil.isNull(workbook)) {
return Collections.emptyList();
}
// 读取excel中的数据 // 读取excel中的数据
return parseExcel(workbook, headerList, sheetIndex); return parseExcel(workbook, headerList, sheetIndex);
} catch (Exception e) { } catch (Exception e) {
logger.warning("解析Excel失败,文件名:" + fileName + " 错误信息:" + e.getMessage()); logger.warning("解析Excel失败,文件名:" + fileName + " 错误信息:" + e.getMessage());
return null;
} finally { } finally {
try { IoUtil.close(inputStream);
if (null != inputStream) {
inputStream.close();
}
} catch (Exception e) {
logger.warning("关闭数据流出错!错误信息:" + e.getMessage());
}
} }
return Collections.emptyList();
} }
/** /**
......
...@@ -114,17 +114,4 @@ public class RSAUtil { ...@@ -114,17 +114,4 @@ public class RSAUtil {
} }
return result; return result;
} }
public static void main(String[] args) {
//公钥
String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2S4SMvvQJ7uO8shBO6STUhgT3zp/WbHT0j89rDQ4Q1dGV6nsCMQJNfJ6jhdQNxNSwfoZGf4bLbXfxxvdgMqisYxwBcOgfxZkEsmAl1MXr9JmNgD6MkqvxK3WCb8NsyeUsOK7frvL7OJjo2P9LLbR5SS2iBXz4Vh+2GT0C/aZmbyF0lW+qd8LTr3VPIuz0/m5cLqmatsZs3w//2rca2kaBpJ5PhL1g5OXCII76HuKQHJYsKspcziLZwtX1c5q6PFCnHFMQl6hRL62p6DgRY9PmFAUKRP3fFJWmyhevwd+6mh4Ra+puSosd1SSfWZATsT1CBUZEtnHBIfzO0Uqq25xKQIDAQAB";
//私钥
String privateKey = "11111";
String string = "{\"loginName\":\"pps\",\"phone\":\"15000000000\"}";
System.out.println("加密内容 : " + string);
String encryptRes = RSAUtil.rsaEncrypt(string, publicKey);
System.out.println("res加密后的密文 : " + encryptRes);
String decryptRes = RSAUtil.RsaDecrypt(encryptRes, privateKey);
System.out.println("res加密密文解密后的内容 : " + decryptRes);
}
} }
\ No newline at end of file
...@@ -1134,7 +1134,6 @@ public class SysOrganizationService { ...@@ -1134,7 +1134,6 @@ public class SysOrganizationService {
//新增组织机构属性表 //新增组织机构属性表
public void insertSysOrganizationProperty(XContext context, Date date, String uuid, String mediaTypes, PpsUserSession session) { public void insertSysOrganizationProperty(XContext context, Date date, String uuid, String mediaTypes, PpsUserSession session) {
//新增组织机构属性表 //新增组织机构属性表
SysOrganizationPropertyMapper propertyMapper = context.getBean(SysOrganizationPropertyMapper.class);
List<SysOrganizationPropertyEnt> list = new ArrayList<>(); List<SysOrganizationPropertyEnt> list = new ArrayList<>();
for (String mediumType : CharSequenceUtil.splitToArray(mediaTypes, ',')) { for (String mediumType : CharSequenceUtil.splitToArray(mediaTypes, ',')) {
SysOrganizationPropertyEnt propertyEnt = new SysOrganizationPropertyEnt(); SysOrganizationPropertyEnt propertyEnt = new SysOrganizationPropertyEnt();
...@@ -1157,6 +1156,7 @@ public class SysOrganizationService { ...@@ -1157,6 +1156,7 @@ public class SysOrganizationService {
list.add(propertyEnt); list.add(propertyEnt);
} }
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
SysOrganizationPropertyMapper propertyMapper = context.getBean(SysOrganizationPropertyMapper.class);
list.forEach(propertyMapper::insert); list.forEach(propertyMapper::insert);
} }
} }
......
package pps.core.system.service; package pps.core.system.service;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import pps.core.common.constant.BusinessConstant; import pps.core.common.constant.BusinessConstant;
import pps.core.common.session.PpsUserSession; import pps.core.common.session.PpsUserSession;
import pps.core.common.utils.BaseUtils;
import pps.core.system.entity.*; import pps.core.system.entity.*;
import pps.core.system.mapper.*; import pps.core.system.mapper.*;
import pps.core.system.service.data.sys_user.*; import pps.core.system.service.data.sys_user.*;
...@@ -23,12 +26,9 @@ import xstartup.error.XError; ...@@ -23,12 +26,9 @@ import xstartup.error.XError;
import xstartup.feature.api.annotation.XApiPost; import xstartup.feature.api.annotation.XApiPost;
import xstartup.helper.XTransactionHelper; import xstartup.helper.XTransactionHelper;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@XText("用户管理") @XText("用户管理")
...@@ -74,17 +74,15 @@ public class SysUserService { ...@@ -74,17 +74,15 @@ public class SysUserService {
return XTransactionHelper.begin(context, () -> { return XTransactionHelper.begin(context, () -> {
SysUserMapper mapper = context.getBean(SysUserMapper.class); SysUserMapper mapper = context.getBean(SysUserMapper.class);
//查询是否存在相同的登录名,如果存在,提示错误信息 //查询是否存在相同的登录名,如果存在,提示错误信息
QueryWrapper<SysUserEnt> isExitQueryWrapper = new QueryWrapper<>(); List<SysUserEnt> isExit = mapper.selectList(new LambdaQueryWrapper<SysUserEnt>()
isExitQueryWrapper.lambda().eq(SysUserEnt::getLoginName, input.getLoginName()); .eq(SysUserEnt::getLoginName, input.getLoginName()));
List<SysUserEnt> isExit = mapper.selectList(isExitQueryWrapper);
if (CollUtil.isNotEmpty(isExit)) { if (CollUtil.isNotEmpty(isExit)) {
return XServiceResult.error(993, "登录账户已存在!"); return XServiceResult.error(993, "登录账户已存在!");
} }
//查询是否存在有相同的Iam登录名,如果存在,提示错误信息 //查询是否存在有相同的Iam登录名,如果存在,提示错误信息
if (CharSequenceUtil.isNotBlank(input.getIamLoginName())) { if (CharSequenceUtil.isNotBlank(input.getIamLoginName())) {
isExitQueryWrapper.clear(); List<SysUserEnt> isIamExit = mapper.selectList(new LambdaQueryWrapper<SysUserEnt>()
isExitQueryWrapper.lambda().eq(SysUserEnt::getIamLoginName, input.getIamLoginName()); .eq(SysUserEnt::getIamLoginName, input.getIamLoginName()));
List<SysUserEnt> isIamExit = mapper.selectList(isExitQueryWrapper);
if (CollUtil.isNotEmpty(isIamExit)) { if (CollUtil.isNotEmpty(isIamExit)) {
return XServiceResult.error(993, "Iam登录账户已存在!"); return XServiceResult.error(993, "Iam登录账户已存在!");
} }
...@@ -95,7 +93,7 @@ public class SysUserService { ...@@ -95,7 +93,7 @@ public class SysUserService {
return XServiceResult.error(993, "请输入密码!"); return XServiceResult.error(993, "请输入密码!");
} }
entity.setPassword(input.getPassword()); entity.setPassword(input.getPassword());
String uuid = UUID.randomUUID().toString(); String uuid = BaseUtils.randomUUIDString();
entity.setId(uuid); entity.setId(uuid);
PpsUserSession session = context.getSession(PpsUserSession.class); PpsUserSession session = context.getSession(PpsUserSession.class);
if (ObjectUtil.isNotNull(session)) { if (ObjectUtil.isNotNull(session)) {
...@@ -116,22 +114,16 @@ public class SysUserService { ...@@ -116,22 +114,16 @@ public class SysUserService {
} }
//新增用户和组织机构关系表 //新增用户和组织机构关系表
public XServiceResult insertSysUserOrganizationRel(XContext context, String uuid, String ouId, PpsUserSession session) throws XServiceException { public void insertSysUserOrganizationRel(XContext context, String uuid, String ouId, PpsUserSession session) throws XServiceException {
return XTransactionHelper.begin(context, () -> { XTransactionHelper.begin(context, () -> {
SysUserOrganizationRelMapper sorMapper = context.getBean(SysUserOrganizationRelMapper.class); SysUserOrganizationRelMapper sorMapper = context.getBean(SysUserOrganizationRelMapper.class);
SysUserOrganizationRelEnt relEnt = new SysUserOrganizationRelEnt(); SysUserOrganizationRelEnt relEnt = new SysUserOrganizationRelEnt();
relEnt.setId(UUID.randomUUID().toString()); relEnt.setId(BaseUtils.randomUUIDString());
relEnt.setUserId(uuid); relEnt.setUserId(uuid);
relEnt.setOuId(ouId); relEnt.setOuId(ouId);
Date date = new Date(); Date date = new Date();
relEnt.setEffectTime(date); relEnt.setEffectTime(date);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); relEnt.setEndTime(DateUtil.parseDate("9999-12-31"));
String datetime = "9999-12-31";
try {
relEnt.setEndTime(sdf.parse(datetime));
} catch (ParseException e) {
context.getLogger().error(e);
}
if (ObjectUtil.isNotNull(session)) { if (ObjectUtil.isNotNull(session)) {
relEnt.setCreateById(session.getId()); relEnt.setCreateById(session.getId());
relEnt.setCreateByName(session.getUserName()); relEnt.setCreateByName(session.getUserName());
......
...@@ -94,7 +94,6 @@ public class SysUserWithUserGroupRelService { ...@@ -94,7 +94,6 @@ public class SysUserWithUserGroupRelService {
if (CollUtil.isNotEmpty(sysUserGroupEnts)) { if (CollUtil.isNotEmpty(sysUserGroupEnts)) {
delMapper.deleteBatchIds(sysUserGroupEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList())); delMapper.deleteBatchIds(sysUserGroupEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList()));
} }
SysUserWithUserGroupRelMapper mapper = context.getBean(SysUserWithUserGroupRelMapper.class);
List<SysUserWithUserGroupRelEnt> list = new ArrayList<>(); List<SysUserWithUserGroupRelEnt> list = new ArrayList<>();
for (String userGroupId : input.getUserGroupIdList()) { for (String userGroupId : input.getUserGroupIdList()) {
SysUserWithUserGroupRelEnt entity = new SysUserWithUserGroupRelEnt(); SysUserWithUserGroupRelEnt entity = new SysUserWithUserGroupRelEnt();
...@@ -103,6 +102,7 @@ public class SysUserWithUserGroupRelService { ...@@ -103,6 +102,7 @@ public class SysUserWithUserGroupRelService {
entity.setSort(input.getSort()); entity.setSort(input.getSort());
list.add(entity); list.add(entity);
} }
SysUserWithUserGroupRelMapper mapper = context.getBean(SysUserWithUserGroupRelMapper.class);
list.forEach(mapper::insert); list.forEach(mapper::insert);
return XServiceResult.OK; return XServiceResult.OK;
} }
...@@ -118,7 +118,6 @@ public class SysUserWithUserGroupRelService { ...@@ -118,7 +118,6 @@ public class SysUserWithUserGroupRelService {
if (CollUtil.isNotEmpty(sysUserGroupEnts)) { if (CollUtil.isNotEmpty(sysUserGroupEnts)) {
delMapper.deleteBatchIds(sysUserGroupEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList())); delMapper.deleteBatchIds(sysUserGroupEnts.stream().map(SysUserWithUserGroupRelEnt::getId).collect(Collectors.toList()));
} }
SysUserWithUserGroupRelMapper mapper = context.getBean(SysUserWithUserGroupRelMapper.class);
List<SysUserWithUserGroupRelEnt> list = new ArrayList<>(); List<SysUserWithUserGroupRelEnt> list = new ArrayList<>();
for (String userId : input.getUserIdList()) { for (String userId : input.getUserIdList()) {
SysUserWithUserGroupRelEnt entity = new SysUserWithUserGroupRelEnt(); SysUserWithUserGroupRelEnt entity = new SysUserWithUserGroupRelEnt();
...@@ -127,6 +126,7 @@ public class SysUserWithUserGroupRelService { ...@@ -127,6 +126,7 @@ public class SysUserWithUserGroupRelService {
entity.setSort(input.getSort()); entity.setSort(input.getSort());
list.add(entity); list.add(entity);
} }
SysUserWithUserGroupRelMapper mapper = context.getBean(SysUserWithUserGroupRelMapper.class);
list.forEach(mapper::insert); list.forEach(mapper::insert);
return XServiceResult.OK; return XServiceResult.OK;
} }
......
...@@ -284,8 +284,7 @@ public class BaseDataService { ...@@ -284,8 +284,7 @@ public class BaseDataService {
try { try {
String jsonString = XJsonUtils.toJson(calcBaseDataInput); String jsonString = XJsonUtils.toJson(calcBaseDataInput);
context.getLogger().info(jsonString); context.getLogger().info(jsonString);
Object ret = HttpUtils.send2("http://121.36.43.217:8098/model/predict", Object ret = HttpUtils.send2("http://121.36.43.217:8098/model/predict", jsonString);
jsonString);
returnMap = XJsonUtils.toMap(ret.toString()); returnMap = XJsonUtils.toMap(ret.toString());
return returnMap; return returnMap;
} catch (Exception e) { } catch (Exception e) {
......
...@@ -54,9 +54,8 @@ public class PlantPowerDataService { ...@@ -54,9 +54,8 @@ public class PlantPowerDataService {
public XFileResult downloadImportTemplate(XContext context) { public XFileResult downloadImportTemplate(XContext context) {
String fileSavePath = XStorageTool.getAbsolutePath("/temp/excel/导入模板_" + DateUtil.formatDate(DateUtil.date()) + ".xlsx"); String fileSavePath = XStorageTool.getAbsolutePath("/temp/excel/导入模板_" + DateUtil.formatDate(DateUtil.date()) + ".xlsx");
String templateFilePath = "template/import_plant_data_template.xlsx"; String templateFilePath = "template/import_plant_data_template.xlsx";
InputStream templateInputStream = this.getClass().getClassLoader().getResourceAsStream(templateFilePath); try (InputStream templateInputStream = this.getClass().getClassLoader().getResourceAsStream(templateFilePath)) {
byte[] excelContent = ExportExcelUtils.genSingleExcelFileData(templateInputStream, null); byte[] excelContent = ExportExcelUtils.genSingleExcelFileData(templateInputStream, null);
try {
ExportExcelUtils.outputFileData(excelContent, fileSavePath); ExportExcelUtils.outputFileData(excelContent, fileSavePath);
} catch (Exception e) { } catch (Exception e) {
context.getLogger().error(e); context.getLogger().error(e);
......
...@@ -47,10 +47,7 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower ...@@ -47,10 +47,7 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower
*/ */
@Override @Override
public XListResult<DynamicQueryPlantPredictedPowerOutput> queryAveragePowerGenerationListByParam(XContext context, DynamicQueryPlantPredictedPowerInput input) { public XListResult<DynamicQueryPlantPredictedPowerOutput> queryAveragePowerGenerationListByParam(XContext context, DynamicQueryPlantPredictedPowerInput input) {
String plantId = input.getPlantId();
List<String> plantIds = input.getPlantIds(); List<String> plantIds = input.getPlantIds();
String yearTime = input.getYearTime();
String monthTime = input.getMonthTime();
String startTime = input.getStartTime(); String startTime = input.getStartTime();
String endTime = input.getEndTime(); String endTime = input.getEndTime();
Integer dateType = input.getDateType(); Integer dateType = input.getDateType();
...@@ -86,10 +83,7 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower ...@@ -86,10 +83,7 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower
@Override @Override
public XListResult<DynamicQueryPlantPredictedPowerOutput> queryAveragePowerHalfHour(XContext context, DynamicQueryPlantPredictedPowerInput input) { public XListResult<DynamicQueryPlantPredictedPowerOutput> queryAveragePowerHalfHour(XContext context, DynamicQueryPlantPredictedPowerInput input) {
String plantId = input.getPlantId();
List<String> plantIds = input.getPlantIds(); List<String> plantIds = input.getPlantIds();
String yearTime = input.getYearTime();
String monthTime = input.getMonthTime();
String startTime = input.getStartTime(); String startTime = input.getStartTime();
String endTime = input.getEndTime(); String endTime = input.getEndTime();
Integer dateType = input.getDateType(); Integer dateType = input.getDateType();
...@@ -132,10 +126,7 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower ...@@ -132,10 +126,7 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower
*/ */
@Override @Override
public XListResult<DynamicQueryPlantPredictedPowerOutput> queryAveragePowerGenerationHourListByParam(XContext context, DynamicQueryPlantPredictedPowerInput input) { public XListResult<DynamicQueryPlantPredictedPowerOutput> queryAveragePowerGenerationHourListByParam(XContext context, DynamicQueryPlantPredictedPowerInput input) {
String plantId = input.getPlantId();
List<String> plantIds = input.getPlantIds(); List<String> plantIds = input.getPlantIds();
String yearTime = input.getYearTime();
String monthTime = input.getMonthTime();
String startTime = input.getStartTime(); String startTime = input.getStartTime();
String endTime = input.getEndTime(); String endTime = input.getEndTime();
Integer dateType = input.getDateType(); Integer dateType = input.getDateType();
......
package pps.core.prediction.utils; package pps.core.prediction.utils;
import java.io.*; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
public class HttpUtils { public class HttpUtils {
...@@ -22,13 +23,11 @@ public class HttpUtils { ...@@ -22,13 +23,11 @@ public class HttpUtils {
OutputStream outputStream = null; OutputStream outputStream = null;
OutputStreamWriter outputStreamWriter = null; OutputStreamWriter outputStreamWriter = null;
InputStream inputStream = null; InputStream inputStream = null;
InputStreamReader inputStreamReader = null;
BufferedReader reader = null;
String resultBuffer = ""; String resultBuffer = "";
try { try {
outputStream = httpURLConnection.getOutputStream(); outputStream = httpURLConnection.getOutputStream();
outputStreamWriter = new OutputStreamWriter(outputStream); outputStreamWriter = new OutputStreamWriter(outputStream);
outputStreamWriter.write(param.toString()); outputStreamWriter.write(param);
outputStreamWriter.flush(); outputStreamWriter.flush();
if (httpURLConnection.getResponseCode() >= 300) { if (httpURLConnection.getResponseCode() >= 300) {
throw new Exception( throw new Exception(
...@@ -36,8 +35,6 @@ public class HttpUtils { ...@@ -36,8 +35,6 @@ public class HttpUtils {
} }
inputStream = httpURLConnection.getInputStream(); inputStream = httpURLConnection.getInputStream();
resultBuffer = convertStreamToString(inputStream); resultBuffer = convertStreamToString(inputStream);
} catch (Exception e) {
e.printStackTrace();
} finally { } finally {
if (outputStreamWriter != null) { if (outputStreamWriter != null) {
outputStreamWriter.close(); outputStreamWriter.close();
...@@ -55,8 +52,7 @@ public class HttpUtils { ...@@ -55,8 +52,7 @@ public class HttpUtils {
public static String convertStreamToString(InputStream is) { public static String convertStreamToString(InputStream is) {
StringBuilder sb1 = new StringBuilder(); StringBuilder sb1 = new StringBuilder();
byte[] bytes = new byte[4096]; byte[] bytes = new byte[4096];
int size = 0; int size;
try { try {
while ((size = is.read(bytes)) > 0) { while ((size = is.read(bytes)) > 0) {
String str = new String(bytes, 0, size, "UTF-8"); String str = new String(bytes, 0, size, "UTF-8");
...@@ -73,19 +69,4 @@ public class HttpUtils { ...@@ -73,19 +69,4 @@ public class HttpUtils {
} }
return sb1.toString(); return sb1.toString();
} }
public static void main(String[] args) throws Exception {
Map<String, String> object = new HashMap<>();
object.put("pipelineId", "11");
object.put("stationId", "11");
object.put("customerId", "11");
object.put("startTime", "2022-10-23 00:00:00");
object.put("strByteString", "11");
String parm = "pipelineId=" + "12" +
"&stationId=" + "12" +
"&customerId=" + "12" +
"&startTime=" + "2022-12-01 00:00:00" +
"&strByteString=" + "12";
send2("http://10.20.89.75/interface/pdf/InsertSIFile?" + parm, parm);
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment