完善APMS接口。
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
package com.mt.wms.empty.controller;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.date.LocalDateTimeUtil;
 | 
			
		||||
import cn.hutool.http.HttpResponse;
 | 
			
		||||
import cn.hutool.http.HttpUtil;
 | 
			
		||||
import cn.hutool.json.JSON;
 | 
			
		||||
@@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -40,6 +42,7 @@ public class ApmsController extends BaseController {
 | 
			
		||||
    private CommunicationLogServiceBiz communicationLogServiceBiz;
 | 
			
		||||
 | 
			
		||||
    static String Token = "";
 | 
			
		||||
    static LocalDateTime TokenExpireTime = LocalDateTime.now();
 | 
			
		||||
    static String ApiAddress = "http://59.110.171.25:9010";
 | 
			
		||||
 | 
			
		||||
    @PostMapping(value = "apmsPostOrder")
 | 
			
		||||
@@ -47,8 +50,9 @@ public class ApmsController extends BaseController {
 | 
			
		||||
    public R apmsPostOrder(@Validated @RequestBody OrderParamForApms apmsPostOrderParam) {
 | 
			
		||||
        CommunicationLog communicationLog = new CommunicationLog();
 | 
			
		||||
        communicationLog.setCode("APMS" + System.currentTimeMillis());
 | 
			
		||||
        communicationLog.setLogName("Wms接收Apms订单");
 | 
			
		||||
        communicationLog.setLogName("WMS接收APMS订单");
 | 
			
		||||
        communicationLog.setContent(apmsPostOrderParam.toString());
 | 
			
		||||
        communicationLog.setType(3);
 | 
			
		||||
        setCommonField(communicationLog);
 | 
			
		||||
        communicationLogServiceBiz.save(communicationLog);
 | 
			
		||||
        return orderInfoService.apmsPostOrder(apmsPostOrderParam);
 | 
			
		||||
@@ -60,6 +64,7 @@ public class ApmsController extends BaseController {
 | 
			
		||||
        CommunicationLog communicationLog = new CommunicationLog();
 | 
			
		||||
        communicationLog.setCode("APMS" + System.currentTimeMillis());
 | 
			
		||||
        communicationLog.setLogName("APMS作废订单");
 | 
			
		||||
        communicationLog.setType(3);
 | 
			
		||||
        communicationLog.setContent(idenCardNum);
 | 
			
		||||
        setCommonField(communicationLog);
 | 
			
		||||
        communicationLogServiceBiz.save(communicationLog);
 | 
			
		||||
@@ -67,19 +72,21 @@ public class ApmsController extends BaseController {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping(value = "apmsCompleteOrder")
 | 
			
		||||
    @ApiOperation(value = "APMS完成订单")
 | 
			
		||||
    @ApiOperation(value = "APMS完成订单,返回加工单检验结果")
 | 
			
		||||
    public R apmsCompleteOrder(@Validated @RequestBody ApmsCompleteOrder apmsCompleteOrder) {
 | 
			
		||||
        CommunicationLog communicationLog = new CommunicationLog();
 | 
			
		||||
        communicationLog.setCode("APMS" + System.currentTimeMillis());
 | 
			
		||||
        communicationLog.setLogName("APMS完成订单");
 | 
			
		||||
        communicationLog.setLogName("APMS完成订单,返回WMS加工单检验结果");
 | 
			
		||||
        communicationLog.setType(3);
 | 
			
		||||
        communicationLog.setContent(apmsCompleteOrder.toString());
 | 
			
		||||
        setCommonField(communicationLog);
 | 
			
		||||
        communicationLogServiceBiz.save(communicationLog);
 | 
			
		||||
        //APMS完成订单,返回检验结果,更新结果和后续处理
 | 
			
		||||
        return orderInfoService.apmsCompleteOrder(apmsCompleteOrder);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping(value = "createProcessSheet")
 | 
			
		||||
    @ApiOperation(value = "APMS创建生产单接口")
 | 
			
		||||
    @ApiOperation(value = "通知APMS创建生产单接口")
 | 
			
		||||
    public R createProcessSheet(@Validated @RequestBody ApmsCreateProcessSheet apmsCreateProcess) {
 | 
			
		||||
        checkToken();
 | 
			
		||||
        HashMap<String, Object> paramMap = new HashMap<>();
 | 
			
		||||
@@ -88,8 +95,9 @@ public class ApmsController extends BaseController {
 | 
			
		||||
                .header("token", Token).form(paramMap).execute();
 | 
			
		||||
        CommunicationLog communicationLog = new CommunicationLog();
 | 
			
		||||
        communicationLog.setCode("APMS" + System.currentTimeMillis());
 | 
			
		||||
        communicationLog.setLogName("APMS创建生产单");
 | 
			
		||||
        communicationLog.setContent(paramMap.toString());
 | 
			
		||||
        communicationLog.setLogName("WMS通知APMS创建生产单");
 | 
			
		||||
        communicationLog.setType(2);
 | 
			
		||||
        communicationLog.setContent("param:" + paramMap + "\nresult:" + response.body());
 | 
			
		||||
        setCommonField(communicationLog);
 | 
			
		||||
        communicationLogServiceBiz.save(communicationLog);
 | 
			
		||||
        return successful(response);
 | 
			
		||||
@@ -105,15 +113,16 @@ public class ApmsController extends BaseController {
 | 
			
		||||
                .header("token", Token).form(paramMap).execute();
 | 
			
		||||
        CommunicationLog communicationLog = new CommunicationLog();
 | 
			
		||||
        communicationLog.setCode("APMS" + System.currentTimeMillis());
 | 
			
		||||
        communicationLog.setLogName("通知APMS生产单开始处理");
 | 
			
		||||
        communicationLog.setContent(paramMap.toString());
 | 
			
		||||
        communicationLog.setLogName("WMS通知APMS生产单开始处理");
 | 
			
		||||
        communicationLog.setType(2);
 | 
			
		||||
        communicationLog.setContent("param:" + paramMap + "\nresult:" + response.body());
 | 
			
		||||
        setCommonField(communicationLog);
 | 
			
		||||
        communicationLogServiceBiz.save(communicationLog);
 | 
			
		||||
        return successful(response);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping(value = "endProcess")
 | 
			
		||||
    @ApiOperation(value = "通知APMS订单结束处理")
 | 
			
		||||
    @ApiOperation(value = "通知APMS生产单结束处理")
 | 
			
		||||
    public R endProcess(@Validated @RequestBody ApmsEndProcess apmsEndProcess) {
 | 
			
		||||
        checkToken();
 | 
			
		||||
        HashMap<String, Object> paramMap = new HashMap<>();
 | 
			
		||||
@@ -122,8 +131,9 @@ public class ApmsController extends BaseController {
 | 
			
		||||
                .header("token", Token).form(paramMap).execute();
 | 
			
		||||
        CommunicationLog communicationLog = new CommunicationLog();
 | 
			
		||||
        communicationLog.setCode("APMS" + System.currentTimeMillis());
 | 
			
		||||
        communicationLog.setLogName("通知APMS订单结束处理");
 | 
			
		||||
        communicationLog.setContent(paramMap.toString());
 | 
			
		||||
        communicationLog.setLogName("WMS通知APMS生产单结束处理");
 | 
			
		||||
        communicationLog.setType(2);
 | 
			
		||||
        communicationLog.setContent("param:" + paramMap + "\nresult:" + response.body());
 | 
			
		||||
        setCommonField(communicationLog);
 | 
			
		||||
        communicationLogServiceBiz.save(communicationLog);
 | 
			
		||||
        return successful(response);
 | 
			
		||||
@@ -139,8 +149,9 @@ public class ApmsController extends BaseController {
 | 
			
		||||
                .header("token", Token).form(paramMap).execute();
 | 
			
		||||
        CommunicationLog communicationLog = new CommunicationLog();
 | 
			
		||||
        communicationLog.setCode("APMS" + System.currentTimeMillis());
 | 
			
		||||
        communicationLog.setLogName("通知APMS完成生产单接口");
 | 
			
		||||
        communicationLog.setContent(paramMap.toString());
 | 
			
		||||
        communicationLog.setLogName("WMS通知APMS完成生产单");
 | 
			
		||||
        communicationLog.setType(2);
 | 
			
		||||
        communicationLog.setContent("param:" + paramMap + "\nresult:" + response.body());
 | 
			
		||||
        setCommonField(communicationLog);
 | 
			
		||||
        communicationLogServiceBiz.save(communicationLog);
 | 
			
		||||
        return successful(response);
 | 
			
		||||
@@ -155,11 +166,14 @@ public class ApmsController extends BaseController {
 | 
			
		||||
        String result = HttpUtil.get(ApiAddress + "/platform/api/getToken", paramMap);
 | 
			
		||||
        JSON parse = JSONUtil.parse(result);
 | 
			
		||||
        Object token = parse.getByPath("token");
 | 
			
		||||
        String expireTime = parse.getByPath("expireTime").toString();
 | 
			
		||||
        Token = token.toString();
 | 
			
		||||
        TokenExpireTime = LocalDateTimeUtil.parse(expireTime);
 | 
			
		||||
        CommunicationLog communicationLog = new CommunicationLog();
 | 
			
		||||
        communicationLog.setCode("APMS" + System.currentTimeMillis());
 | 
			
		||||
        communicationLog.setLogName("获取APMS Token");
 | 
			
		||||
        communicationLog.setContent(paramMap.toString());
 | 
			
		||||
        communicationLog.setLogName("WMS获取APMS Token");
 | 
			
		||||
        communicationLog.setType(2);
 | 
			
		||||
        communicationLog.setContent("param:" + paramMap + "\nresult:" + result);
 | 
			
		||||
        setCommonField(communicationLog);
 | 
			
		||||
        communicationLogServiceBiz.save(communicationLog);
 | 
			
		||||
        return successful(result);
 | 
			
		||||
@@ -173,10 +187,12 @@ 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通过车间编码获取炉号信息");
 | 
			
		||||
        communicationLog.setContent(paramMap.toString());
 | 
			
		||||
        communicationLog.setType(2);
 | 
			
		||||
        communicationLog.setContent("param:" + paramMap + "\nresult:" + response.body());
 | 
			
		||||
        setCommonField(communicationLog);
 | 
			
		||||
        communicationLogServiceBiz.save(communicationLog);
 | 
			
		||||
        return successful(response);
 | 
			
		||||
@@ -187,5 +203,9 @@ public class ApmsController extends BaseController {
 | 
			
		||||
        {
 | 
			
		||||
            getApmsToken();
 | 
			
		||||
        }
 | 
			
		||||
        else if (TokenExpireTime.isBefore(LocalDateTime.now()))
 | 
			
		||||
        {
 | 
			
		||||
            getApmsToken();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ import lombok.experimental.Accessors;
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = false)
 | 
			
		||||
@Accessors(chain = true)
 | 
			
		||||
@ApiModel(value = "apms订单对象", description = "用于推送新的订单信息")
 | 
			
		||||
@ApiModel(value = "apms订单对象", description = "用于APMS推送新的订单信息")
 | 
			
		||||
public class OrderParamForApms extends BaseParam {
 | 
			
		||||
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
@@ -68,10 +68,10 @@ public class OrderParamForApms extends BaseParam {
 | 
			
		||||
    @ApiModelProperty(value = "工艺要求")
 | 
			
		||||
    private String craftIll;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "加工数量")
 | 
			
		||||
    @ApiModelProperty(value = "加工数量", required = true)
 | 
			
		||||
    private Float quantity;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "加工重量")
 | 
			
		||||
    @ApiModelProperty(value = "加工重量", required = true)
 | 
			
		||||
    private Float weight;
 | 
			
		||||
 | 
			
		||||
    @ApiModelProperty(value = "单位")
 | 
			
		||||
 
 | 
			
		||||
@@ -11,8 +11,10 @@ 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.ApmsCheckResult;
 | 
			
		||||
import com.mt.wms.core.dal.entity.CurrTaskDet;
 | 
			
		||||
import com.mt.wms.core.dal.entity.OrderInfo;
 | 
			
		||||
import com.mt.wms.core.dal.service.ApmsCheckResultServiceBiz;
 | 
			
		||||
import com.mt.wms.core.dal.service.CommunicationLogServiceBiz;
 | 
			
		||||
import com.mt.wms.core.dal.service.OrderInfoServiceBiz;
 | 
			
		||||
import com.mt.wms.core.params.IdParam;
 | 
			
		||||
@@ -34,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
@@ -69,6 +72,9 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    CommunicationLogServiceBiz communicationLogServiceBiz;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    ApmsCheckResultServiceBiz apmsCheckResultServiceBiz;
 | 
			
		||||
    @Autowired
 | 
			
		||||
    ApmsController apmsControl;
 | 
			
		||||
 | 
			
		||||
@@ -201,6 +207,14 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public R apmsCompleteOrder(ApmsCompleteOrder apmsCompleteOrder) {
 | 
			
		||||
        return null;
 | 
			
		||||
        //通过标识卡号与生产单号进行更新检验结果
 | 
			
		||||
        ApmsCheckResult one = apmsCheckResultServiceBiz.getOne(new QueryWrapper<ApmsCheckResult>().eq(ApmsCheckResult.IDEN_CARD_NUM, apmsCompleteOrder.getIdenCardNum()).eq(ApmsCheckResult.SHEET_NO, apmsCompleteOrder.getSheetNo()));
 | 
			
		||||
        one.setMetallography(apmsCompleteOrder.getMetallographic());
 | 
			
		||||
        one.setHeartHardness(apmsCompleteOrder.getHeartHardness());
 | 
			
		||||
        one.setHardness(apmsCompleteOrder.getHardness());
 | 
			
		||||
        one.setUpdateTime(LocalDateTime.now());
 | 
			
		||||
        apmsCheckResultServiceBiz.updateById(one);
 | 
			
		||||
        OrderInfo one1 = orderInfoService.getOne(new QueryWrapper<OrderInfo>().eq(OrderInfo.IDEN_CARD_NUM, apmsCompleteOrder.getIdenCardNum()));
 | 
			
		||||
        return completeOrder(IdParam.builder().id(one1.getId()).build());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user