测试apms,优化bug,优化返回值

This commit is contained in:
徐晨晨 2021-11-22 15:23:29 +08:00
parent 82704c9eb3
commit 8e46276be0
8 changed files with 220 additions and 28 deletions

View File

@ -1,6 +1,6 @@
package com.mt.wms.empty.controller;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.http.ContentType;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSON;
@ -12,6 +12,10 @@ import com.mt.wms.core.dal.service.CommunicationLogServiceBiz;
import com.mt.wms.core.vo.R;
import com.mt.wms.empty.params.*;
import com.mt.wms.empty.service.OrderInfoService;
import com.mt.wms.empty.vo.ApmsCreateProcessSheetVo;
import com.mt.wms.empty.vo.ApmsEndProcessVo;
import com.mt.wms.empty.vo.ApmsFinishProcessSheetVo;
import com.mt.wms.empty.vo.ApmsStoveVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@ -23,6 +27,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
/**
@ -41,6 +46,7 @@ public class ApmsController extends BaseController {
@Autowired
private CommunicationLogServiceBiz communicationLogServiceBiz;
// static String Token = "eyJhbGciOiJIUzI1NiJ9.eyJkYXRlIjozMTkyNzU4NDk4ODA3LCJwbGF0Rm9ybUlkIjoyLCJhcGlLZXkiOiI3ZWU4ZjU5YmJhZWFlMjdlIiwiZXhwIjozMTkyNzU4NDk4LCJpYXQiOjE2Mzc1NTg0OTh9.RH3MRQr1dCBYW996-WXN69eXu1ZFblAQHfhZHNbTmCg";
static String Token = "";
static LocalDateTime TokenExpireTime = LocalDateTime.now();
static String ApiAddress = "http://59.110.171.25:9010";
@ -89,72 +95,68 @@ public class ApmsController extends BaseController {
@ApiOperation(value = "通知APMS创建生产单接口")
public R createProcessSheet(@Validated @RequestBody ApmsCreateProcessSheet apmsCreateProcess) {
checkToken();
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("entity", apmsCreateProcess);
String paramJson = JSONUtil.toJsonStr(apmsCreateProcess);
HttpResponse response = HttpUtil.createPost(ApiAddress + "/platform/api/createProcessSheet")
.header("token", Token).form(paramMap).execute();
.header("token", Token).body(paramJson, ContentType.JSON.toString()).execute();
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("WMS通知APMS创建生产单");
communicationLog.setType(2);
communicationLog.setContent("param:" + paramMap + "\nresult:" + response.body());
communicationLog.setContent("param:" + paramJson + "\nresult:" + response.body());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return successful(response);
return successful(JSONUtil.toBean(response.body(), ApmsCreateProcessSheetVo.class));
}
@PostMapping(value = "startProcess")
@ApiOperation(value = "通知APMS生产单开始处理")
public R startProcess(@Validated @RequestBody ApmsStartProcess apmsStartProcess) {
checkToken();
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("entity", apmsStartProcess);
String paramJson = JSONUtil.toJsonStr(apmsStartProcess);
HttpResponse response = HttpUtil.createPost(ApiAddress + "/platform/api/startProcess")
.header("token", Token).form(paramMap).execute();
.header("token", Token).body(paramJson, ContentType.JSON.toString()).execute();
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("WMS通知APMS生产单开始处理");
communicationLog.setType(2);
communicationLog.setContent("param:" + paramMap + "\nresult:" + response.body());
communicationLog.setContent("param:" + paramJson + "\nresult:" + response.body());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return successful(response);
return successful(JSONUtil.toBean(response.body(), ApmsStartProcess.class));
}
@PostMapping(value = "endProcess")
@ApiOperation(value = "通知APMS生产单结束处理")
public R endProcess(@Validated @RequestBody ApmsEndProcess apmsEndProcess) {
checkToken();
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("entity", apmsEndProcess);
String paramJson = JSONUtil.toJsonStr(apmsEndProcess);
HttpResponse response = HttpUtil.createPost(ApiAddress + "/platform/api/endProcess")
.header("token", Token).form(paramMap).execute();
.header("token", Token).body(paramJson, ContentType.JSON.toString()).execute();
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("WMS通知APMS生产单结束处理");
communicationLog.setType(2);
communicationLog.setContent("param:" + paramMap + "\nresult:" + response.body());
communicationLog.setContent("param:" + paramJson + "\nresult:" + response.body());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return successful(response);
return successful(JSONUtil.toBean(response.body(), ApmsEndProcessVo.class));
}
@PostMapping(value = "finishProcessSheet")
@ApiOperation(value = "通知APMS完成生产单接口")
public R finishProcessSheet(@Validated @RequestBody ApmsFinishProcessSheet apmsFinishProcessSheet) {
checkToken();
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("entity", apmsFinishProcessSheet);
String paramJson = JSONUtil.toJsonStr(apmsFinishProcessSheet);
HttpResponse response = HttpUtil.createPost(ApiAddress + "/platform/api/finishProcessSheet")
.header("token", Token).form(paramMap).execute();
.header("token", Token).body(paramJson, ContentType.JSON.toString()).execute();
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("WMS通知APMS完成生产单");
communicationLog.setType(2);
communicationLog.setContent("param:" + paramMap + "\nresult:" + response.body());
communicationLog.setContent("param:" + paramJson + "\nresult:" + response.body());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return successful(response);
return successful(JSONUtil.toBean(response.body(), ApmsFinishProcessSheetVo.class));
}
@PostMapping(value = "getApmsToken")
@ -168,7 +170,7 @@ public class ApmsController extends BaseController {
Object token = parse.getByPath("token");
String expireTime = parse.getByPath("expireTime").toString();
Token = token.toString();
TokenExpireTime = LocalDateTimeUtil.parse(expireTime);
TokenExpireTime = LocalDateTime.parse(expireTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("WMS获取APMS Token");
@ -187,7 +189,6 @@ public class ApmsController extends BaseController {
paramMap.put("workShopCode", workShopCode);
HttpResponse response = HttpUtil.createGet(ApiAddress + "/platform/api/getStoveCodeByWorkShopCode")
.header("token", Token).form(paramMap).execute();
System.out.println(response.body());
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("APMS通过车间编码获取炉号信息");
@ -195,7 +196,7 @@ public class ApmsController extends BaseController {
communicationLog.setContent("param:" + paramMap + "\nresult:" + response.body());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return successful(response);
return successful(JSONUtil.toBean(response.body(), ApmsStoveVo.class));
}
private void checkToken() {

View File

@ -51,8 +51,8 @@ class CreateItem extends BaseParam {
private String itemCode;
@ApiModelProperty(value = "加工数量", required = true)
private String quantity;
private Integer quantity;
@ApiModelProperty(value = "加工重量", required = true)
private String weight;
private Double weight;
}

View File

@ -44,8 +44,8 @@ class FinishItem extends BaseParam {
private String itemCode;
@ApiModelProperty(value = "完成加工数量", required = true)
private String finishQuantity;
private Integer finishQuantity;
@ApiModelProperty(value = "完成加工重量", required = true)
private String finishWeight;
private Double finishWeight;
}

View File

@ -0,0 +1,40 @@
package com.mt.wms.empty.vo;
import com.mt.wms.core.base.BaseVo;
import io.swagger.annotations.ApiModel;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @author xcc
* @date 2021年11月8日
* @since 1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Builder
@ApiModel(value = "APMS返回创建生产单信息", description = "APMS返回创建生产单信息")
public class ApmsCreateProcessSheetVo extends BaseVo {
/**
* 返回消息,返回false时为失败原因
*/
private String msg;
/**
* 是否成功
*/
private Boolean success;
/**
* 生产单编号,创建成功后返回,需要记录此生产单编号,加工过程处理及结束加工处理需要传入此生产单编号
*/
private String sheetNo;
/**
* 返回状态编码:00-正常,01-token失败,02-参数错误,03-其他错误
*/
private String statusCode;
}

View File

@ -0,0 +1,34 @@
package com.mt.wms.empty.vo;
import com.mt.wms.core.base.BaseVo;
import io.swagger.annotations.ApiModel;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @author xcc
* @date 2021年11月8日
* @since 1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Builder
@ApiModel(value = "APMS返回生产单结束信息", description = "APMS返回生产单结束信息")
public class ApmsEndProcessVo extends BaseVo {
/**
* 返回消息,返回false时为失败原因
*/
private String msg;
/**
* 是否成功
*/
private Boolean success;
/**
* 返回状态编码:00-正常,01-token失败,02-参数错误,03-其他错误
*/
private String statusCode;
}

View File

@ -0,0 +1,40 @@
package com.mt.wms.empty.vo;
import com.mt.wms.core.base.BaseVo;
import io.swagger.annotations.ApiModel;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @author xcc
* @date 2021年11月8日
* @since 1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Builder
@ApiModel(value = "APMS返回完成生产单信息", description = "APMS返回完成生产单信息")
public class ApmsFinishProcessSheetVo extends BaseVo {
/**
* 返回消息,返回false时为失败原因
*/
private String msg;
/**
* 是否成功
*/
private Boolean success;
/**
* 生产单编号,创建成功后返回,需要记录此生产单编号,加工过程处理及结束加工处理需要传入此生产单编号
*/
private String sheetNo;
/**
* 返回状态编码:00-正常,01-token失败,02-参数错误,03-其他错误
*/
private String statusCode;
}

View File

@ -0,0 +1,34 @@
package com.mt.wms.empty.vo;
import com.mt.wms.core.base.BaseVo;
import io.swagger.annotations.ApiModel;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @author xcc
* @date 2021年11月8日
* @since 1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Builder
@ApiModel(value = "APMS返回生产单开始信息", description = "APMS返回生产单开始信息")
public class ApmsStartProcessVo extends BaseVo {
/**
* 返回消息,返回false时为失败原因
*/
private String msg;
/**
* 是否成功
*/
private Boolean success;
/**
* 返回状态编码:00-正常,01-token失败,02-参数错误,03-其他错误
*/
private String statusCode;
}

View File

@ -0,0 +1,43 @@
package com.mt.wms.empty.vo;
import com.mt.wms.core.base.BaseVo;
import io.swagger.annotations.ApiModel;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.Map;
/**
* @author xcc
* @date 2021年11月8日
* @since 1.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Builder
@ApiModel(value = "APMS返回窑炉信息", description = "APMS返回窑炉信息")
public class ApmsStoveVo extends BaseVo {
/**
* 返回消息,返回false时为失败原因
*/
private String msg;
/**
* 是否成功
*/
private Boolean success;
/**
* 返回状态编码:00-正常,01-token失败,02-参数错误,03-其他错误
*/
private String statusCode;
/**
* 车间炉号信息明细
*/
private ArrayList<Map<String, String>> stoveCodes;
}