wpf——>Java后台
JSON传值格式【WPF】(post)
public async Task<ServiceResponse> CancleM(RevokeBatchParam revokeBatchParam)
{
HttpClient httpClient0 = new HttpClient();
try
{
httpClient0.DefaultRequestHeaders.Add("Authorization", "Bearer " + this.token);
List<KeyValuePair<string, string>> param = new List<KeyValuePair<string, string>>();
param.Add(new KeyValuePair<string, string>("revokeBatchParamStr", JsonConvert.SerializeObject(revokeBatchParam)));
Task<HttpResponseMessage> responseMessage = httpClient0.PostAsync(TQT.ServerBusiness.Properties.Resources.Http_Api + "services/servicepl/api/manufOrd/cancleMergBatch", new FormUrlEncodedContent(param));
responseMessage.Wait();
Task<string> reString = responseMessage.Result.Content.ReadAsStringAsync();
reString.Wait();
Newtonsoft.Json.Linq.JObject menuDatas = JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(reString.Result);
var result = menuDatas.GetValue("success").ToString();
if (result == "False")
{
return new ServiceResponse() { Success = false, Message = menuDatas.GetValue("message").ToString() };
}
return new ServiceResponse() { Success = true, Message = menuDatas.GetValue("message").ToString() };
}
catch (Exception ex)
{
return new ServiceResponse() { Success = false, ErrorCode = ex.Message, Message = ex.Message };
}
finally
{
httpClient0.Dispose();
}
}
JAVA接收wpf传入的json格式
@ApiOperation("撤销")
@PostMapping(value = "cancleMergBatch")
public ResultBean cancleM(String revokeBatchParamStr) {
try {
RevokeBatchParam revokeBatchParamm = JSONArray.parseObject(revokeBatchParamStr,RevokeBatchParam.class);
return manufOrdService.cancleMergBatch(revokeBatchParamm);
} catch (Exception ex) {
ex.printStackTrace();
return ResultBean.failure("撤销更新失败");
}
}
wpf——>Java后台
单个参数传值格式【WPF】(post)
public async Task<ServiceResponse> Ol(string cntrCd, string entkbn, string pgmId, string userId, string userNm)
{
HttpClient httpClient0 = new HttpClient();
try
{
httpClient0.DefaultRequestHeaders.Add("Authorization", "Bearer " + this.token);
List<KeyValuePair<string, string>> param = new List<KeyValuePair<string, string>>();
param.Add(new KeyValuePair<string, string>("cntrCd", cntrCd));
param.Add(new KeyValuePair<string, string>("entkbn", entkbn));
param.Add(new KeyValuePair<string, string>("pgmId", pgmId));
param.Add(new KeyValuePair<string, string>("userId", userId));
param.Add(new KeyValuePair<string, string>("userNm", userNm));
// String path = TQT.ServerBusiness.Properties.Resources.Http_Api + "services/common/api/exclusive/openControl?" + param;
Task<HttpResponseMessage> responseMessage = httpClient0.PostAsync(TQT.ServerBusiness.Properties.Resources.Http_Api + "services/common/api/exclusive/openControl", new FormUrlEncodedContent(param));
responseMessage.Wait();
Task<string> reString = responseMessage.Result.Content.ReadAsStringAsync();
reString.Wait();
Newtonsoft.Json.Linq.JObject menuDatas = JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(reString.Result);
var result = menuDatas.GetValue("success").ToString();
if (result == "False")
{
return new ServiceResponse() { Success = false, Message = menuDatas.GetValue("message").ToString() };
}
return new ServiceResponse() { Success = true, Message = menuDatas.GetValue("message").ToString() };
}
catch (Exception ex)
{
return new ServiceResponse() { Success = false, ErrorCode = ex.Message, Message = ex.Message };
}
finally
{
httpClient0.Dispose();
}
}
JAVA接收wpf传入的个体参数格式
@ApiOperation("打开")
@PostMapping(value = "ol")
public ResultBean ol(HttpServletRequest request,String cntrCd,String entkbn,String pgmId,String userId,String userNm) {
try {
return mService.ol(request,cntrCd,entkbn,pgmId,userId,userNm);
} catch (Exception ex) {
ex.printStackTrace();
return ResultBean.failure("打开更新失败");
}
}
wpf——>Java后台
个体传值格式【WPF】(get)
public async Task<ServiceResponse> getSameColorCd(string colorCd, string batchNo)
{
HttpClient httpClient0 = new HttpClient();
try
{
string param = "colorCd=" + colorCd
+"&batchNo=" + batchNo;
httpClient0.DefaultRequestHeaders.Add("Authorization", "Bearer " + this.token);
String url = TQT.ServerBusiness.Properties.Resources.Http_Api + "services/servicepl/api/manufOrd/getSameColorCd?" + param;
Task<HttpResponseMessage> responseMessage = httpClient0.GetAsync(url);
responseMessage.Wait();
Task<string> reString = responseMessage.Result.Content.ReadAsStringAsync();
reString.Wait();
Newtonsoft.Json.Linq.JObject menuDatas = JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(reString.Result);
//Newtonsoft.Json.Linq.JObject data = JsonConvert.DeserializeObject(menuDatas.GetValue("data").ToString());
ServiceResponse response = new ServiceResponse() { Success = true, Results = menuDatas };
return response;
}
catch (Exception e) {
LoggerHelper.WriteLog("根据色号查询异常", e);
return new ServiceResponse() { Success = false, ErrorCode = e.Message, Message = e.Message };
}
finally
{
httpClient0.Dispose();
}
}
JAVA接收wpf传入的个体参数格式
@ApiOperation("获取*****")
@GetMapping(value = "getSrCd")
public ResultBean getSaCd(String colorCd,String batchNo){
List<TManufOrdEx> tManufOrds = new ArrayList<>();
try {
tManufOrds = manufOrdService.getSrCd(colorCd,batchNo);
return ResultBean.success("获取******成功!",tManufOrds);
} catch (Exception ex) {
ex.printStackTrace();
return ResultBean.failure("获取******失败!");
}
}
wpf——>Java后台
public async Task<ServiceResponse> SubmitExhaustCylinder(ExhaustCylinderParam exhaustCylinderParam)
{
HttpClient httpClient0 = new HttpClient();
try
{
httpClient0.DefaultRequestHeaders.Add("Authorization", "Bearer " + this.token);
Dictionary<String, Object> map = new Dictionary<String, Object>();
map.Add("exhaustCylinderParamStr", exhaustCylinderParam);
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
//这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
String data = JsonConvert.SerializeObject(map, Formatting.Indented, timeConverter);
var content = new StringContent(JsonConvert.SerializeObject(exhaustCylinderParam), Encoding.UTF8, "application/json");
Task<HttpResponseMessage> responseMessage = httpClient0.PostAsync(TQT.ServerBusiness.Properties.Resources.Http_Api + "services/servicepl/api/exhaustCylinder/submitExhaustCylinder", content);
responseMessage.Wait();
Task<string> reString = responseMessage.Result.Content.ReadAsStringAsync();
reString.Wait();
Newtonsoft.Json.Linq.JObject menuDatas = JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(reString.Result);
var result = menuDatas.GetValue("success").ToString();
if (result == "False")
{
return new ServiceResponse() { Success = false, Message = menuDatas.GetValue("message").ToString() };
}
return new ServiceResponse() { Success = true, Message = menuDatas.GetValue("message").ToString() };
}
catch (Exception ex)
{
return new ServiceResponse() { Success = false, ErrorCode = ex.Message, Message = ex.Message };
}
finally
{
//防止内存溢出
httpClient0.Dispose();
}
}
JAVA接收wpf传入的json对象格式
@ApiOperation("提交调缸")
@PostMapping(value = "submitExhaustCylinder")
public ResultBean submitExhaustCylinder(HttpServletRequest request, @RequestBody ExhaustCylinderParam exhaustCylinderParam){
try {
if(exhaustCylinderParam == null){
return ResultBean.failure("无提交数据!");
}
//返回区分 1:没有数据变更 2:数据修改过,没有重复数据 3:数据修改过,和当前页面有重复数据 4 数据修改过,与库中数据有重复数据
int resultFlag = exhaustCylinderService.doubleCheckExhaustCylinder(exhaustCylinderParam);
if(resultFlag == 1 ){
return ResultBean.success("没有数据修改");
}else if(resultFlag == 5){
return ResultBean.failure("您的机台号没有对应的机台信息!");
}
return ResultBean.success("提交成功!",exhaustCylinderService.doubleCheckExhaustCylinder(exhaustCylinderParam));
} catch (Exception ex) {
ex.printStackTrace();
return ResultBean.failure("提交失败");
}
}
jarray类型转换成List对象
List<SameColorEx> data1 = req.Results.data.ToObject<List<SameColorEx>>();
接收map 并转换
///
/// 打印完成更新数据方法
///
/// 领料单实体类
/// 返回服务报文
public async Task<ServiceResponse> prtLoosenBack(TWhPick entity, string loosenBackStockExs)
{
HttpClient httpClient0 = new HttpClient();
try
{
List<KeyValuePair<string, string>> param = new List<KeyValuePair<string, string>>();
param = HttpParamConverter.Convert(entity);
param.Add(new KeyValuePair<string, string>("loosenBackStockExs", loosenBackStockExs));
httpClient0.DefaultRequestHeaders.Add("Authorization", "Bearer " + this.token);
String url = TQT.ServerBusiness.Properties.Resources.Http_Api + "services/servicepl/api/plan/prtLoosenBack";
Task<HttpResponseMessage> responseMessage = httpClient0.PostAsync(url, new FormUrlEncodedContent(param));
responseMessage.Wait();
responseMessage.Wait();
Task<string> reString = responseMessage.Result.Content.ReadAsStringAsync();
reString.Wait();
Newtonsoft.Json.Linq.JObject menuDatas = JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(reString.Result);
Newtonsoft.Json.Linq.JObject data = JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(menuDatas.GetValue("data").ToString());
ServiceResponse response = new ServiceResponse() { Success = true, Results = data };
return response;
}
catch (Exception ex)
{
LoggerHelper.WriteLog("打印完成更新数据", ex);
return new ServiceResponse() { Success = false, ErrorCode = ex.Message, Message = ex.Message };
}
finally
{
httpClient0.Dispose();
}
}
Dictionary<int, List<LoosenBackStockEx>> DetailStockBookDictionary = req.Results.data.looseDetail.ToObject<Dictionary<int, List<LoosenBackStockEx>>>();