Browse Source

扫码报警请求体修改

develop
lau572 2 weeks ago
parent
commit
e1a80f387a
  1. 39
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

39
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;
@ -691,22 +694,30 @@ public class DcWarningServiceImpl implements IDcWarningService {
//扫码报警 处置记录 //扫码报警 处置记录
public AjaxResult addCodeScanningProcess(String alarmId,String content) throws IOException, HttpException { 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"; 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