添加apms检验结果表生成代码,优化订单相关和apms

This commit is contained in:
2021-11-19 15:25:52 +08:00
parent aecf651292
commit 6be427ba79
12 changed files with 400 additions and 24 deletions

View File

@@ -6,6 +6,8 @@ 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.dal.entity.CommunicationLog;
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;
@@ -21,6 +23,11 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
/**
* @author xcc
* @date 2021年11月18日
* @since 1.0
*/
@RestController
@RequestMapping(CommonConstant.API_MODULE_BASE + "apms")
@Slf4j
@@ -29,65 +36,118 @@ public class ApmsController extends BaseController {
@Autowired
private OrderInfoService orderInfoService;
@Autowired
private CommunicationLogServiceBiz communicationLogServiceBiz;
static String Token = "";
static String ApiAddress = "http://59.110.171.25:9010";
@PostMapping(value = "apmsPostOrder")
@ApiOperation(value = "接收APMS推送订单信息")
public R apmsPostOrder(@Validated @RequestBody OrderParamForApms apmsPostOrderParam) {
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("Wms接收Apms订单");
communicationLog.setContent(apmsPostOrderParam.toString());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return orderInfoService.apmsPostOrder(apmsPostOrderParam);
}
@PostMapping(value = "apmsVoidOrder")
@ApiOperation(value = "APMS作废订单")
public R apmsVoidOrder(@Validated @RequestBody String idenCardNum) {
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("APMS作废订单");
communicationLog.setContent(idenCardNum);
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return orderInfoService.apmsVoidOrder(idenCardNum);
}
@PostMapping(value = "apmsCompleteOrder")
@ApiOperation(value = "APMS完成订单")
public R apmsCompleteOrder(@Validated @RequestBody ApmsCompleteOrder apmsCompleteOrder) {
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("APMS完成订单");
communicationLog.setContent(apmsCompleteOrder.toString());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return orderInfoService.apmsCompleteOrder(apmsCompleteOrder);
}
@PostMapping(value = "createProcessSheet")
@ApiOperation(value = "通知APMS开始加工处理信息")
@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(ApiAddress + "/platform/api/createProcessSheet")
.header("token", Token).form(paramMap).execute();
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("APMS创建生产单");
communicationLog.setContent(paramMap.toString());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return successful(response);
}
@PostMapping(value = "startProcess")
@ApiOperation(value = "通知APMS单开始处理")
@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(ApiAddress + "/platform/api/startProcess")
.header("token", Token).form(paramMap).execute();
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("通知APMS生产单开始处理");
communicationLog.setContent(paramMap.toString());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
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(ApiAddress + "/platform/api/endProcess")
.header("token", Token).form(paramMap).execute();
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("通知APMS订单结束处理");
communicationLog.setContent(paramMap.toString());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return successful(response);
}
@PostMapping(value = "finishProcessSheet")
@ApiOperation(value = "通知APMS结束加工处理信息")
@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(ApiAddress + "/platform/api/finishProcessSheet")
.header("token", Token).form(paramMap).execute();
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("通知APMS完成生产单接口");
communicationLog.setContent(paramMap.toString());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return successful(response);
}
@PostMapping(value = "getApmsToken")
@ApiOperation(value = "获取APMS获得Token")
@ApiOperation(value = "获取APMS Token")
public R getApmsToken() {
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("apiKey", "7ee8f59bbaeae27e");
@@ -96,7 +156,12 @@ public class ApmsController extends BaseController {
JSON parse = JSONUtil.parse(result);
Object token = parse.getByPath("token");
Token = token.toString();
//todo 记录通讯日志
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("获取APMS Token");
communicationLog.setContent(paramMap.toString());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return successful(result);
}
@@ -108,7 +173,12 @@ public class ApmsController extends BaseController {
paramMap.put("workShopCode", workShopCode);
HttpResponse response = HttpUtil.createGet(ApiAddress + "/platform/api/getStoveCodeByWorkShopCode")
.header("token", Token).form(paramMap).execute();
//todo 记录通讯日志
CommunicationLog communicationLog = new CommunicationLog();
communicationLog.setCode("APMS" + System.currentTimeMillis());
communicationLog.setLogName("APMS通过车间编码获取炉号信息");
communicationLog.setContent(paramMap.toString());
setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog);
return successful(response);
}

View File

@@ -0,0 +1,37 @@
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 ApmsCompleteOrder extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "生产单编号", required = false)
private String sheetNo;
/**
* 标识卡号APMS系统获取
*/
@ApiModelProperty(value = "标识卡号", required = true)
private String idenCardNum;
@ApiModelProperty(value = "硬度检验结果", required = true)
private String hardness;
@ApiModelProperty(value = "金相检验结果", required = true)
private String metallographic;
@ApiModelProperty(value = "心部硬度检验值", required = true)
private Float heartHardness;
}

View File

@@ -59,12 +59,21 @@ public class OrderParamForApms extends BaseParam {
/**
* 材料牌号 APMS系统获取
*/
@ApiModelProperty(value = "材料牌号")
@ApiModelProperty(value = "材料牌号")
private String materialDes;
/**
* 工艺要求 APMS系统获取
*/
@ApiModelProperty(value = "工艺要求")
@ApiModelProperty(value = "工艺要求")
private String craftIll;
@ApiModelProperty(value = "加工数量")
private Float quantity;
@ApiModelProperty(value = "加工重量")
private Float weight;
@ApiModelProperty(value = "单位")
private String unit;
}

View File

@@ -50,4 +50,12 @@ public interface CurrTaskDetService {
* @return 结果
*/
List<CurrTaskDet> getTaskDetailsByMainId(IdParam idParam);
/**
* 查询某个标识卡号的详细任务列表
*
* @param idenCardNum 标识卡号
* @return 结果
*/
List<CurrTaskDet> getTaskDetailsByIdenCardNum(String idenCardNum);
}

View File

@@ -3,10 +3,7 @@ package com.mt.wms.empty.service;
import com.mt.wms.core.params.IdParam;
import com.mt.wms.core.vo.PageVo;
import com.mt.wms.core.vo.R;
import com.mt.wms.empty.params.OrderInfoBasePageParam;
import com.mt.wms.empty.params.OrderInfoPersonCreateParam;
import com.mt.wms.empty.params.OrderInfoTaskDetParam;
import com.mt.wms.empty.params.OrderParamForApms;
import com.mt.wms.empty.params.*;
import com.mt.wms.empty.vo.OrderInfoTaskDetVo;
import com.mt.wms.empty.vo.OrderInfoVo;
@@ -77,4 +74,21 @@ public interface OrderInfoService {
* @return 结果
*/
R voidOrder(IdParam idParam);
/**
* APMS作废订单
*
* @param idenCardNum 标识卡号
* @return 结果
*/
R apmsVoidOrder(String idenCardNum);
/**
* APMS返回订单结果
*
* @param apmsCompleteOrder 订单检验结果
* @return 结果
*/
R apmsCompleteOrder(ApmsCompleteOrder apmsCompleteOrder);
}

View File

@@ -71,4 +71,12 @@ public class CurrTaskDetServiceImpl extends BaseService implements CurrTaskDetSe
.eq(CurrTaskDet.VALID, 1);
return currTaskDetServiceBiz.list(queryWrapper);
}
@Override
public List<CurrTaskDet> getTaskDetailsByIdenCardNum(String idenCardNum) {
QueryWrapper<CurrTaskDet> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(CurrTaskDet.IDEN_CARD_NUM, idenCardNum)
.eq(CurrTaskDet.VALID, 1);
return currTaskDetServiceBiz.list(queryWrapper);
}
}

View File

@@ -11,16 +11,16 @@ import com.mt.wms.basic.vo.KilnInfoVo;
import com.mt.wms.basic.vo.VehicleVo;
import com.mt.wms.core.api.Assert;
import com.mt.wms.core.base.BaseService;
import com.mt.wms.core.dal.entity.CurrTaskDet;
import com.mt.wms.core.dal.entity.OrderInfo;
import com.mt.wms.core.dal.service.CommunicationLogServiceBiz;
import com.mt.wms.core.dal.service.OrderInfoServiceBiz;
import com.mt.wms.core.params.IdParam;
import com.mt.wms.core.vo.PageVo;
import com.mt.wms.core.vo.R;
import com.mt.wms.empty.controller.ApmsController;
import com.mt.wms.empty.enums.OrderSourceEnum;
import com.mt.wms.empty.params.OrderInfoBasePageParam;
import com.mt.wms.empty.params.OrderInfoPersonCreateParam;
import com.mt.wms.empty.params.OrderInfoTaskDetParam;
import com.mt.wms.empty.params.OrderParamForApms;
import com.mt.wms.empty.params.*;
import com.mt.wms.empty.service.CurrTaskDetService;
import com.mt.wms.empty.service.CurrTaskService;
import com.mt.wms.empty.service.OrderInfoHisService;
@@ -67,17 +67,20 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic
@Autowired
LocationInfoService locationInfoService;
@Autowired
CommunicationLogServiceBiz communicationLogServiceBiz;
@Autowired
ApmsController apmsControl;
@Override
public R apmsPostOrder(OrderParamForApms apmsPostOrderParam) {
OrderInfo orderInfo = new OrderInfo();
BeanUtils.copyProperties(apmsPostOrderParam,orderInfo);
BeanUtils.copyProperties(apmsPostOrderParam, orderInfo);
setCommonField(orderInfo);
//设定来源信息为apms
orderInfo.setOrderSource(OrderSourceEnum.APMS.getValue());
orderInfo.setInterCode("APMS"+System.currentTimeMillis());
orderInfo.setInterCode("APMS" + System.currentTimeMillis());
orderInfoService.save(orderInfo);
//todo 记录通讯日志信息
return successful("Wms接收Apms订单成功。");
}
@@ -101,7 +104,6 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic
orderInfo.setOrderSource(OrderSourceEnum.PERSON.getValue());
orderInfo.setInterCode("PERSONAL"+System.currentTimeMillis());
orderInfoService.save(orderInfo);
//todo 通知apms创建了一个订单
return successful("人工创建订单成功。");
}
@@ -181,4 +183,24 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic
orderInfoService.updateById(byId);
return successful("操作成功。");
}
@Override
public R apmsVoidOrder(String idenCardNum) {
OrderInfo byId = orderInfoService.getOne(new QueryWrapper<OrderInfo>().eq(OrderInfo.IDEN_CARD_NUM, idenCardNum));
//确定是否有订单在生产
List<CurrTaskDet> taskDetailsByIdenCardNum = currTaskDetService.getTaskDetailsByIdenCardNum(idenCardNum);
if (taskDetailsByIdenCardNum.size() > 0)
{
return failed("操作失败,已经存在生产中的任务单。");
}
else
{
return voidOrder(IdParam.builder().id(byId.getId()).build());
}
}
@Override
public R apmsCompleteOrder(ApmsCompleteOrder apmsCompleteOrder) {
return null;
}
}