Compare commits

...

2 Commits

  1. 36
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

36
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.httpclient.request.RequestParams;
import com.zc.common.core.websocket.WebSocketService; import com.zc.common.core.websocket.WebSocketService;
import com.zc.common.core.websocket.constant.WebSocketEvent; import com.zc.common.core.websocket.constant.WebSocketEvent;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray; import org.json.JSONArray;
@ -694,19 +697,26 @@ public class DcWarningServiceImpl implements IDcWarningService {
String url = configService.selectConfigByKey("alarmCode"); String url = configService.selectConfigByKey("alarmCode");
url = url + "/warning/addProcess"; url = url + "/warning/addProcess";
RequestParams requestParams = new RequestParams(); OkHttpClient client = new OkHttpClient();
requestParams.put("warningInfoId",alarmId); MultipartBody.Builder builder = new MultipartBody.Builder().setType(MultipartBody.FORM);
requestParams.put("processType","1"); SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
requestParams.put("processTitle",content); // 添加表单字段
requestParams.put("processTime",new Date()); builder.addFormDataPart("warningInfoId", alarmId);
builder.addFormDataPart("processType", "1");
OkHttp okHttp = new OkHttp(); builder.addFormDataPart("processTitle", content);
Response response // 请求响应 builder.addFormDataPart("processTime", sf.format(new Date()));
= okHttp
.headers(new HashMap<>()) // 创建请求体
.url(url) // 请求地址 MultipartBody requestBody = builder.build();
.data(requestParams)
.post(); // 请求方法 // 创建请求
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.build();
// 执行请求
Response response = client.newCall(request).execute();
return JSON.parseObject(response.body().string(), AjaxResult.class); return JSON.parseObject(response.body().string(), AjaxResult.class);
} }

Loading…
Cancel
Save