From 579b77daaa90485d588fdb2d872ebce7df3190d8 Mon Sep 17 00:00:00 2001 From: Lin-XCC <754310653@QQ.COM> Date: Tue, 16 Nov 2021 20:17:29 +0800 Subject: [PATCH] =?UTF-8?q?APMS=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 6.program/wms-empty/pom.xml | 5 + .../wms/empty/controller/ApmsController.java | 121 ++++++++++++++++++ .../empty/params/ApmsCreateProcessSheet.java | 58 +++++++++ .../mt/wms/empty/params/ApmsEndProcess.java | 28 ++++ .../empty/params/ApmsFinishProcessSheet.java | 51 ++++++++ .../mt/wms/empty/params/ApmsStartProcess.java | 34 +++++ 6 files changed, 297 insertions(+) create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCreateProcessSheet.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsEndProcess.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsFinishProcessSheet.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsStartProcess.java diff --git a/6.program/wms-empty/pom.xml b/6.program/wms-empty/pom.xml index cf26262..2846fbf 100644 --- a/6.program/wms-empty/pom.xml +++ b/6.program/wms-empty/pom.xml @@ -20,6 +20,11 @@ com.mt wms-basic + + cn.hutool + hutool-all + 5.5.7 + \ No newline at end of file diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java new file mode 100644 index 0000000..0cac0f5 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java @@ -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 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 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 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 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 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 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(); + } + } +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCreateProcessSheet.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCreateProcessSheet.java new file mode 100644 index 0000000..0422593 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCreateProcessSheet.java @@ -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 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; +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsEndProcess.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsEndProcess.java new file mode 100644 index 0000000..011651f --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsEndProcess.java @@ -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; +} + diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsFinishProcessSheet.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsFinishProcessSheet.java new file mode 100644 index 0000000..a43e462 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsFinishProcessSheet.java @@ -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 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; +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsStartProcess.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsStartProcess.java new file mode 100644 index 0000000..29f9920 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsStartProcess.java @@ -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; +} +