APMS相关接口

This commit is contained in:
徐晨晨 2021-11-16 20:17:29 +08:00
parent c626d34010
commit 579b77daaa
6 changed files with 297 additions and 0 deletions

View File

@ -20,6 +20,11 @@
<groupId>com.mt</groupId> <groupId>com.mt</groupId>
<artifactId>wms-basic</artifactId> <artifactId>wms-basic</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.5.7</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +1,121 @@
package com.mt.wms.empty.controller;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import com.mt.wms.core.base.BaseController;
import com.mt.wms.core.constants.CommonConstant;
import com.mt.wms.core.vo.R;
import com.mt.wms.empty.params.*;
import com.mt.wms.empty.service.OrderInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
@RestController
@RequestMapping(CommonConstant.API_MODULE_BASE + "apms")
@Slf4j
@Api(value = "Apms相关接口", tags = "Apms相关接口", hidden = false)
public class ApmsController extends BaseController {
@Autowired
private OrderInfoService orderInfoService;
static String Token = "";
static String ApiAdress = "http://59.110.171.25:9010";
@PostMapping(value = "apmsPostOrder")
@ApiOperation(value = "接收APMS推送订单信息")
public R apmsPostOrder(@Validated @RequestBody OrderParamForApms apmsPostOrderParam) {
return orderInfoService.apmsPostOrder(apmsPostOrderParam);
}
@PostMapping(value = "createProcessSheet")
@ApiOperation(value = "通知APMS开始加工处理信息")
public R createProcessSheet(@Validated @RequestBody ApmsCreateProcessSheet apmsCreateProcess) {
//todo
checkToken();
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("entity", apmsCreateProcess);
HttpResponse response = HttpUtil.createPost(ApiAdress + "/platform/api/createProcessSheet")
.header("token", Token).form(paramMap).execute();
return successful(response);
}
@PostMapping(value = "startProcess")
@ApiOperation(value = "获取APMS订单开始处理")
public R startProcess(@Validated @RequestBody ApmsStartProcess apmsStartProcess) {
//todo
checkToken();
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("entity", apmsStartProcess);
HttpResponse response = HttpUtil.createPost(ApiAdress + "/platform/api/startProcess")
.header("token", Token).form(paramMap).execute();
return successful(response);
}
@PostMapping(value = "endProcess")
@ApiOperation(value = "通知APMS订单结束处理")
public R endProcess(@Validated @RequestBody ApmsEndProcess apmsEndProcess) {
//todo
checkToken();
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("entity", apmsEndProcess);
HttpResponse response = HttpUtil.createPost(ApiAdress + "/platform/api/endProcess")
.header("token", Token).form(paramMap).execute();
return successful(response);
}
@PostMapping(value = "finishProcessSheet")
@ApiOperation(value = "通知APMS结束加工处理信息")
public R finishProcessSheet(@Validated @RequestBody ApmsFinishProcessSheet apmsFinishProcessSheet) {
//todo
checkToken();
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("entity", apmsFinishProcessSheet);
HttpResponse response = HttpUtil.createPost(ApiAdress + "/platform/api/finishProcessSheet")
.header("token", Token).form(paramMap).execute();
return successful(response);
}
@PostMapping(value = "getApmsToken")
@ApiOperation(value = "获取APMS获得Token")
public R getApmsToken() {
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("apiKey", "7ee8f59bbaeae27e");
paramMap.put("platFormCode", "CUC");
String result = HttpUtil.get(ApiAdress + "/platform/api/getToken", paramMap);
JSON parse = JSONUtil.parse(result);
Object token = parse.getByPath("token");
Token = token.toString();
//todo 记录通讯日志
return successful(result);
}
@PostMapping(value = "getStoveCodeByWorkShopCode")
@ApiOperation(value = "APMS通过车间编码获取炉号信息")
public R getStoveCodeByWorkShopCode(String workShopCode) {
checkToken();
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("workShopCode", workShopCode);
HttpResponse response = HttpUtil.createGet(ApiAdress + "/platform/api/getStoveCodeByWorkShopCode")
.header("token", Token).form(paramMap).execute();
//todo 记录通讯日志
return successful(response);
}
private void checkToken() {
if (Token.isEmpty())
{
getApmsToken();
}
}
}

View File

@ -0,0 +1,58 @@
package com.mt.wms.empty.params;
import com.mt.wms.core.base.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "Apms创建生产单", description = "Apms创建生产单")
public class ApmsCreateProcessSheet extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "生产单-明细数据", required = false)
private List<CreateItem> items;
@ApiModelProperty(value = "备注", required = false)
private String remark;
@ApiModelProperty(value = "开始加工时间:yyyy-MM-dd HH:mm:ss", required = true)
private String startTime;
@ApiModelProperty(value = "开始加工人:为APMS账号", required = true)
private String startUser;
@ApiModelProperty(value = "配炉号", required = true)
private String stoveCode;
@ApiModelProperty(value = "炉号备注", required = false)
private String stoveRemark;
@ApiModelProperty(value = "工艺号", required = false)
private String techCode;
@ApiModelProperty(value = "车间编码", required = true)
private String workShopCode;
}
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "Apms生产单详细", description = "Apms生产单详细")
class CreateItem extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "标识卡号", required = true)
private String itemCode;
@ApiModelProperty(value = "加工数量", required = true)
private String quantity;
@ApiModelProperty(value = "加工重量", required = true)
private String weight;
}

View File

@ -0,0 +1,28 @@
package com.mt.wms.empty.params;
import com.mt.wms.core.base.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "Apms结束处理", description = "Apms结束处理")
public class ApmsEndProcess extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "生产单编号,创建成功后返回的编号", required = false)
private String sheetNo;
@ApiModelProperty(value = "结束处理时间:yyyy-MM-dd HH:mm:ss", required = true)
private String endTime;
@ApiModelProperty(value = "结束处理人:为APMS账号", required = true)
private String endUser;
}

View File

@ -0,0 +1,51 @@
package com.mt.wms.empty.params;
import com.mt.wms.core.base.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "Apms创建生产单", description = "Apms创建生产单")
public class ApmsFinishProcessSheet extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "生产单-明细数据", required = false)
private List<FinishItem> items;
@ApiModelProperty(value = "完成加工时间:yyyy-MM-dd HH:mm:ss", required = true)
private String endTime;
@ApiModelProperty(value = "完成加工人:为APMS账号", required = true)
private String endUser;
@ApiModelProperty(value = "配炉号", required = true)
private String stoveCode;
@ApiModelProperty(value = "备注", required = false)
private String remark;
}
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "Apms生产单详细", description = "Apms生产单详细")
class FinishItem extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "标识卡号", required = true)
private String itemCode;
@ApiModelProperty(value = "完成加工数量", required = true)
private String finishQuantity;
@ApiModelProperty(value = "完成加工重量", required = true)
private String finishWeight;
}

View File

@ -0,0 +1,34 @@
package com.mt.wms.empty.params;
import com.mt.wms.core.base.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "Apms开始处理", description = "Apms开始处理")
public class ApmsStartProcess extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "生产单编号,创建成功后返回的编号", required = false)
private String sheetNo;
@ApiModelProperty(value = "开始加工时间:yyyy-MM-dd HH:mm:ss", required = true)
private String startTime;
@ApiModelProperty(value = "开始加工人:为APMS账号", required = true)
private String startUser;
@ApiModelProperty(value = "配炉号", required = true)
private String stoveCode;
@ApiModelProperty(value = "工艺号", required = false)
private String techCode;
}