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.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);
}

Loading…
Cancel
Save