From e1a80f387a0ccb02480a1a34cfba500b296e79ef Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Thu, 14 Nov 2024 17:40:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E6=8A=A5=E8=AD=A6=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E4=BD=93=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DcWarningServiceImpl.java | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java index 84e59f9e..2daf0dc7 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java @@ -28,6 +28,9 @@ import com.zc.common.core.httpclient.exception.HttpException; import com.zc.common.core.httpclient.request.RequestParams; import com.zc.common.core.websocket.WebSocketService; import com.zc.common.core.websocket.constant.WebSocketEvent; +import okhttp3.MultipartBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; import okhttp3.Response; import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; @@ -691,22 +694,30 @@ public class DcWarningServiceImpl implements IDcWarningService { //扫码报警 处置记录 public AjaxResult addCodeScanningProcess(String alarmId,String content) throws IOException, HttpException { - String url = configService.selectConfigByKey("alarmCode"); +// String url = configService.selectConfigByKey("alarmCode"); + String url = "http://10.168.66.112:9002"; url = url + "/warning/addProcess"; - RequestParams requestParams = new RequestParams(); - requestParams.put("warningInfoId",alarmId); - requestParams.put("processType","1"); - requestParams.put("processTitle",content); - requestParams.put("processTime",new Date()); - - OkHttp okHttp = new OkHttp(); - Response response // 请求响应 - = okHttp - .headers(new HashMap<>()) - .url(url) // 请求地址 - .data(requestParams) - .post(); // 请求方法 + OkHttpClient client = new OkHttpClient(); + MultipartBody.Builder builder = new MultipartBody.Builder().setType(MultipartBody.FORM); + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // 添加表单字段 + builder.addFormDataPart("warningInfoId", alarmId); + builder.addFormDataPart("processType", "1"); + builder.addFormDataPart("processTitle", content); + builder.addFormDataPart("processTime", sf.format(new Date())); + + // 创建请求体 + MultipartBody requestBody = builder.build(); + + // 创建请求 + Request request = new Request.Builder() + .url(url) + .post(requestBody) + .build(); + + // 执行请求 + Response response = client.newCall(request).execute(); return JSON.parseObject(response.body().string(), AjaxResult.class); }