feat(接口): 自动进站接口

This commit is contained in:
syngna_qiao 2024-12-31 20:31:13 +08:00
parent 187d6beea4
commit 2f3c5b67d7
2 changed files with 74 additions and 26 deletions

View File

@ -0,0 +1,62 @@
package com.foreverwin.iep.integration.handler.def.sh;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.foreverwin.iep.integration.constant.Msg;
import com.foreverwin.iep.integration.domain.InvokeRequest;
import com.foreverwin.iep.integration.domain.InvokeResponse;
import com.foreverwin.iep.integration.service.HandlerService;
import com.foreverwin.iep.integration.utils.JS;
import com.foreverwin.iep.wip.domain.NlvStartRequest;
import com.foreverwin.iep.wip.feign.RemoteWipService;
import com.foreverwin.mom.common.core.util.I18nUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* 进站接口
*/
@AllArgsConstructor
@Service("lot.start.process")
public class LotStart implements HandlerService {
private final RemoteWipService remoteWipService;
@Override
public InvokeResponse call(InvokeRequest invokeRequest) {
String messageContent = invokeRequest.getMessageContent();
// 将json对象jsonObject转成EapExtrudeRecordRequest对象
NlvStartRequest startRequest = JSONObject.parseObject(messageContent, NlvStartRequest.class);
remoteWipService.lotStart(startRequest).getData();
InvokeResponse response = new InvokeResponse(invokeRequest);
response.setTransTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
response.setResult("S");
response.setMessageContent(Msg.SUCCESS);
return response;
}
@Override
public String validation(InvokeRequest invokeRequest) {
JSONObject jsonObject = JS.parseObject(invokeRequest.getMessageContent());
if (ObjectUtil.isNull(jsonObject)) {
return I18nUtil.getI18nText("int.invoke.error3", I18nUtil.getI18nText("int.invoke.msg9"));
}
JSONArray lotNoList = jsonObject.getJSONArray("LOT_NO_LIST");
if(lotNoList == null || lotNoList.size() == 0) {
return "LOT_NO_LIST不能为空";
}
if(StrUtil.isBlank(jsonObject.getString("OPERATION"))) {
return "OPERATION不能为空";
}
if(StrUtil.isBlank(jsonObject.getString("RESOURCE"))) {
return "RESOURCE不能为空";
}
invokeRequest.setKeyValue(lotNoList.getString(0));
return null;
}
}

View File

@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
class EapExtrudeRecordTest {
class LotStartTest {
public static final String origin = "http://127.0.0.1:8091";
public static final String mesOrigin = "http://localhost:8080";
@ -32,7 +32,7 @@ class EapExtrudeRecordTest {
String token = getToken();
postRequest.setHeader(HttpHeaders.AUTHORIZATION, "Bearer "+ token);
postRequest.setHeader("TENANT-ID", "2031");
postRequest.setHeader("TENANT-ID", "3041");
postRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8");
String assembleMsgBody = assembleMsgBody();
@ -55,30 +55,16 @@ class EapExtrudeRecordTest {
jsonObject.put("REQ_ID", StrUtil.uuid());
jsonObject.put("SEND_TIME","2024-11-29 12:00:00");
jsonObject.put("SITE","3041");
jsonObject.put("SENDER","EAP");
jsonObject.put("MESSAGE_ID","material.data.process");
jsonObject.put("FACTORY","009");
jsonObject.put("LINE_ID","WC01");
jsonObject.put("OPERATION","JMLS");
jsonObject.put("SENDER","SH");
jsonObject.put("MESSAGE_ID","lot.start.process");
jsonObject.put("FAB_NO","009");
jsonObject.put("WORK_CENTER","WC01");
jsonObject.put("OPERATION","JMFQ");
jsonObject.put("RESOURCE","LS001");
jsonObject.put("EXTRUDER_RESOURCE","TLK02");
jsonObject.put("PROCESS_RESOURCE","TT02");
jsonObject.put("MAIN_UOM","KG");
jsonObject.put("MAIN_QTY","12");
jsonObject.put("SUB_UOM","KG");
jsonObject.put("SUB_QTY","3");
jsonObject.put("TRANS_TYPE","1");
jsonObject.put("TRANS_DATE","2024-11-29 12:00:00");
jsonObject.put("START_DATE_TIME","2024-11-29 12:00:00");
jsonObject.put("END_DATE_TIME","2024-11-30 12:00:00");
JSONArray details = new JSONArray();
JSONObject detail = new JSONObject();
detail.put("SUB_RESOURCE","TT0201");
detail.put("SET_VALUE","22.1");
detail.put("ACTUAL_VALUE","33");
detail.put("ACTUAL_QTY","66");
details.add(detail);
jsonObject.put("DETAILS", details);
JSONArray lotNoList = new JSONArray();
lotNoList.add("0120241228H002");
jsonObject.put("LOT_NO_LIST", lotNoList);
return jsonObject.toJSONString();
}
@ -91,7 +77,7 @@ class EapExtrudeRecordTest {
pair.add(new BasicNameValuePair("password", "dAPopZNYLST8ew=="));
postRequest.setHeader(HttpHeaders.AUTHORIZATION, "Basic bW9tOm1vbQ==");
postRequest.setHeader("TENANT-ID", "2031");
postRequest.setHeader("TENANT-ID", "3041");
postRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
postRequest.setEntity(new UrlEncodedFormEntity(pair, "UTF-8"));