Commit 61fd6d18 LN

1.增加micron接口及测试功能。

2.增加获取库存接口:/rest/api/inventory
1 个父辈 a17f019f
package com.neotel.smfcore.common.utils; package com.neotel.smfcore.common.utils;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.neotel.smfcore.common.exception.ApiException; import com.neotel.smfcore.common.exception.ApiException;
...@@ -133,12 +134,24 @@ public class HttpHelper { ...@@ -133,12 +134,24 @@ public class HttpHelper {
} }
} }
public static MicronResult getMicronJson(String url ) throws ApiException { public static MicronResult getMicronJson(String url ) throws ApiException {
if(ObjectUtil.isEmpty(url)) {
return new MicronResult();
}
HttpGet httpGet = new HttpGet(url); HttpGet httpGet = new HttpGet(url);
httpGet.addHeader("Content-Type", "application/json;charset=utf-8"); httpGet.addHeader("Content-Type", "application/json;charset=utf-8");
// 设置请求参数 // // 设置请求参数
// if (params != null && !params.isEmpty()) {
// ObjectMapper mapper = new ObjectMapper();
// try {
// String requestBody = mapper.writeValueAsString(params);
// httpGet.seb(new StringEntity(requestBody,CONTENT_CHARSET));
// } catch (JsonProcessingException e) {
// throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
// } catch (Exception e) {
// throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
// }
// }
try { try {
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(httpGet); CloseableHttpResponse response = httpClient.execute(httpGet);
...@@ -152,6 +165,7 @@ public class HttpHelper { ...@@ -152,6 +165,7 @@ public class HttpHelper {
result = new MicronResult(); result = new MicronResult();
} }
result.setHttpCode(code); result.setHttpCode(code);
result.setResponseData(responseContent);
response.close(); response.close();
httpClient.close(); httpClient.close();
return result; return result;
...@@ -162,11 +176,15 @@ public class HttpHelper { ...@@ -162,11 +176,15 @@ public class HttpHelper {
} }
public static MicronResult postMicronJson(String url , Map<String, Object> params) throws ApiException { public static MicronResult postMicronJson(String url , Map<String, Object> params) throws ApiException {
try { try {
if(ObjectUtil.isEmpty(url)) {
return new MicronResult();
}
String responseContent = postJson(url, params); String responseContent = postJson(url, params);
MicronResult result = JsonUtil.toObj(responseContent, MicronResult.class); MicronResult result = JsonUtil.toObj(responseContent, MicronResult.class);
if (result == null) { if (result == null) {
result = new MicronResult(); result = new MicronResult();
} }
result.setResponseData(responseContent);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
......
...@@ -66,4 +66,7 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> { ...@@ -66,4 +66,7 @@ public interface IStoragePosManager extends IBaseManager<StoragePos> {
List<StoragePos> findPosList(String storageId, List<String> posNames); List<StoragePos> findPosList(String storageId, List<String> posNames);
List<StoragePos> getSameSizeContinuityEmptyPosList(Storage storage, Barcode barcode) throws ValidateException; List<StoragePos> getSameSizeContinuityEmptyPosList(Storage storage, Barcode barcode) throws ValidateException;
List<StoragePos> findByBarcodesAndPartNums(List<String> storageIds, List<String> partNums, List<String> reelIds);
} }
...@@ -557,6 +557,26 @@ public class StoragePosManagerImpl implements IStoragePosManager { ...@@ -557,6 +557,26 @@ public class StoragePosManagerImpl implements IStoragePosManager {
return new ArrayList<>(); return new ArrayList<>();
} }
@Override
public List<StoragePos> findByBarcodesAndPartNums(List<String> storageIds, List<String> partNums, List<String> reelIds) {
//构造查询条件
Query query = new Query();
Criteria criteria = Criteria.where("barcode").exists(true);
if(storageIds != null && !storageIds.isEmpty()){
criteria.and("storageId").in(storageIds);
}
if (reelIds != null && !reelIds.isEmpty()){
criteria.and("barcode.barcode").in(reelIds);
}
if (partNums != null && !partNums.isEmpty()){
criteria.and("barcode.partNumber").in(partNums);
}
query.addCriteria(criteria);
return storagePosDao.findByQuery(query);
}
/** /**
* 获取下一库位的库位名(后缀数字+1) * 获取下一库位的库位名(后缀数字+1)
*/ */
......
...@@ -6,6 +6,11 @@ import lombok.NoArgsConstructor; ...@@ -6,6 +6,11 @@ import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data @Data
@Slf4j @Slf4j
@AllArgsConstructor @AllArgsConstructor
...@@ -22,7 +27,7 @@ public class MaterialInfo implements Serializable { ...@@ -22,7 +27,7 @@ public class MaterialInfo implements Serializable {
private String Label2DID; private String Label2DID;
private String TowerID; private String TowerID;
private String StorageBin; private String StorageBin;
private Integer Qty; private String Qty;
private String XRayCheck; private String XRayCheck;
private String ErrorCode; private String ErrorCode;
private String ErrorMessage; private String ErrorMessage;
...@@ -36,4 +41,72 @@ public class MaterialInfo implements Serializable { ...@@ -36,4 +41,72 @@ public class MaterialInfo implements Serializable {
private String FromTowerID; private String FromTowerID;
private String FromStorageBin; private String FromStorageBin;
public static MaterialInfo NewMaterial(Map<String,String> map) {
MaterialInfo mInfo = new MaterialInfo();
try {
mInfo.setLabel2DID(map.getOrDefault("Label2DID", ""));
mInfo.setTowerID(map.getOrDefault("TowerID", ""));
mInfo.setStorageBin(map.getOrDefault("StorageBin", ""));
mInfo.setXRayCheck(map.getOrDefault("X-RayCheck", ""));
mInfo.setErrorCode(map.getOrDefault("ErrorCode", ""));
mInfo.setErrorMessage(map.getOrDefault("ErrorMessage", ""));
mInfo.setQty( map.getOrDefault("Qty", "0"));
mInfo.setFromTowerID(map.getOrDefault("FromTowerID", ""));
mInfo.setFromStorageBin(map.getOrDefault("FromStorageBin", ""));
} catch (Exception ex) {
}
return mInfo;
}
public static List<MaterialInfo> GetObjList(List<Map<String,String>> arrList){
List<MaterialInfo> materialInfos=new ArrayList<>();
for (Map<String, String> o :
arrList) {
MaterialInfo mInfo = MaterialInfo.NewMaterial(o);
materialInfos.add(mInfo);
}
return materialInfos;
}
public static List<Map<String,String>> ToLoadingList(List<MaterialInfo> list){
List<Map<String,String>> arrList=new ArrayList<>();
for (MaterialInfo obj :list
) {
Map<String,String> map=new HashMap<>();
map.put("Label2DID",obj.getLabel2DID());
map.put("TowerID",obj.getTowerID());
map.put("StorageBin",obj.getStorageBin());
map.put("X-RayCheck",obj.getXRayCheck());
map.put("ErrorCode",obj.getErrorCode());
map.put("ErrorMessage",obj.getErrorMessage());
map.put("Qty",obj.getQty().toString());
arrList.add(map);
}
return arrList;
}
public static List<Map<String,String>> ToDispatchList(List<MaterialInfo> list){
List<Map<String,String>> arrList=new ArrayList<>();
for (MaterialInfo obj :list
) {
Map<String,String> map=new HashMap<>();
map.put("FromTowerID",obj.getFromTowerID());
map.put("FromStorageBin",obj.getFromStorageBin());
map.put("Qty",obj.getQty().toString());
arrList.add(map);
}
return arrList;
}
} }
...@@ -22,6 +22,8 @@ public class MicronResult implements Serializable { ...@@ -22,6 +22,8 @@ public class MicronResult implements Serializable {
private String status; private String status;
private String message; private String message;
private String responseData;
public boolean isSuccess() { public boolean isSuccess() {
if (ObjectUtil.isNotEmpty(status) && status.equals("Success")) { if (ObjectUtil.isNotEmpty(status) && status.equals("Success")) {
return true; return true;
......
package com.neotel.smfcore.custom.micron1053.controller;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.custom.micron1053.bean.MaterialInfo;
import com.neotel.smfcore.custom.micron1053.bean.MicronResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/rest/api")
@Slf4j
public class MicronApi extends BaseSmfApiListener {
private static MicronConfig config;
@Autowired
public void setConfig(MicronConfig config){
MicronApi.config=config;
}
@Override
public boolean isForThisApi(String apiName) {
// return apiName != null && apiName.equalsIgnoreCase("Micron");
return ObjectUtil.isNotEmpty(config.micronAddr);
}
private static String GetSkipSap(String skipSap) {
if(skipSap.toUpperCase().toString().equals("TRUE")||skipSap.toUpperCase().toString().equals("YES")){
return "YES";
}
return "NO";
}
public static MicronResult validateMRB(String mbrId, String skipSap) {
//Validate if MBR (From Warehouse )  is valid
// if (skipSap instanceof Boolean) {
//
// skipSapStr = (boolean) skipSap ? "YES" : "NO";
// } else {
// skipSapStr = skipSap.toString();
// }
String skipSapStr = GetSkipSap(skipSap);
String url =config. getUrl(MessageFormat.format("validate/mrb/{0}/{1}", mbrId, skipSapStr));
try {
MicronResult result = HttpHelper.getMicronJson(url);
return result;
} catch (Exception e) {
log.error(url + "出错", e);
}
return null;
}
public static MicronResult validateREQ(String reqId) {
//Validate if REQ (From Outside Shelf) is valid
String url = config.getUrl(MessageFormat.format("validate/req/{0}", reqId));
try {
MicronResult result = HttpHelper.getMicronJson(url);
return result;
} catch (Exception e) {
log.error(url + "出错", e);
}
return null;
}
public static MicronResult validateMCL(String PurchaseOrder, String PackagingSlip, String skipSap) {
//Validate if MCL GR  is valid
//validate/mcl/{PurchaseOrder}/{PackagingSlip}/{SkipSap}
// {PurchaseOrder}=<purchase order>,
// {PackagingSlip}=<packaging slide>,
// {SkipSAP}="YES|No"
String skipSapStr = GetSkipSap(skipSap);
String url = config.getUrl(MessageFormat.format("validate/mcl/{0}/{1}/{2}", PurchaseOrder, PackagingSlip, skipSapStr));
try {
MicronResult result = HttpHelper.getMicronJson(url);
return result;
} catch (Exception e) {
log.error(url + "出错", e);
}
return null;
}
public static MicronResult validateMaterial(String Label2DID, String LoadingMode) {
//Validate the material before loading into the storage bin
//validate/material
// {
// "Label2DID" : "<2DID String that contains SAP P/N; S/N; Supplier..etc>",
// "LoadingMode" : "MBR|REQ|GR|MCL|RET|NPI"
// }
String url = config.getUrl( "validate/material" );
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("Label2DID", Label2DID);
dataMap.put("LoadingMode", LoadingMode);
try {
MicronResult result = HttpHelper.postMicronJson(url, dataMap);
return result;
} catch (Exception e) {
log.error(url + "出错", e);
}
return null;
}
public static MicronResult loadReport(String JobId, List<MaterialInfo> materialInfos) {
//Update material storage location at rod or magazine slot level (One JobID per rod or slot).
//load-report
// {
// "JobId": "<job Id>",
// "Materials": [
// {
// "Label2DID": "<Label2DID>",
// "TowerID": "<TowerID>|null",
// "StorageBin": "<StorageBin>|null",
// "Qty": "<Label Qty>|<X-Ray Qty>",
// "X-RayCheck": "Yes|No|N/A",
// "ErrorCode": "0-Success|1-Rejected",
// "ErrorMessage": "N/A|<ErrorMessage>"
// }
//]
// }
String url = config.getUrl( "load-report" );
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("JobId", JobId);
dataMap.put("Materials", MaterialInfo.ToLoadingList(materialInfos));
try {
MicronResult result = HttpHelper.postMicronJson(url, dataMap);
return result;
} catch (Exception e) {
log.error(url + "出错", e);
}
return null;
}
public static MicronResult dispatchList(String Facility, String DispatchType) {
//Get ready Pretask/LinePrep/RET list from Auto Kitting System
//dispatch-list/{Facility}/{DispatchType}
// {Facility} = "Grouping that need to align with KitView"
// {DispatchType}="PreTask|LinePrep|RET"
String url = config.getUrl(MessageFormat.format("dispatch-list/{0}/{1}", Facility, DispatchType));
try {
MicronResult result = HttpHelper.getMicronJson(url);
return result;
} catch (Exception e) {
log.error(url + "出错", e);
}
return null;
}
public static MicronResult dispatchMaterial(String DispatchType, String Id) {
//Get dispatch Material list  from Autokitting system to fullfil the Pretask or LinePrep
//dispatch-material/{DispatchType}/{Id}
// {DispatchType}="PreTask|LinePrep|RET"
// Id="<PretaskId>|<LinePrepId>|<RetId>"
String url = config.getUrl(String.format("dispatch-material/{0}/{1}", DispatchType, Id));
try {
MicronResult result = HttpHelper.getMicronJson(url);
return result;
} catch (Exception e) {
log.error(url + "出错", e);
}
return null;
}
public static MicronResult dispatchReport(String JobId, String dispatchType, List<MaterialInfo> materialInfos) {
//Update dispatch information by Job Level
//dispatch-report
// "JobId": "<JobId>",
// "DispatchType": "PreTask|LinePrep|RET|Warehouse|Controlled",
// "Materials": [
// {
// "Label2DID": "<Label2DID>",
// "FromTowerID": "<TowerID>",
// "FromStorageBin": "<StorageBin>",
// "Qty": "<Qty>",
// }
//]
String url = config.getUrl( "dispatch-report" );
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("JobId", JobId);
dataMap.put("DispatchType", dispatchType);
dataMap.put("Materials", MaterialInfo.ToDispatchList(materialInfos));
try {
MicronResult result = HttpHelper.postMicronJson(url, dataMap);
return result;
} catch (Exception e) {
log.error(url + "出错", e);
}
return null;
}
}
package com.neotel.smfcore.custom.micron1053.controller;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.custom.micron1053.bean.MaterialInfo;
import com.neotel.smfcore.custom.micron1053.bean.MicronResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/rest/api")
@Slf4j
public class MicronApiController extends BaseSmfApiListener {
@Autowired
private IStoragePosManager storagePosManager;
@RequestMapping(value = "/inventory-report")
@ResponseBody
public Map<String,Object> inventoryReport(@RequestBody Map<String,String> map) {
Map<String, Object> result = new HashMap<String, Object>();
try {
String TransactionID = map.get("TransactionID");
String TowerID = map.get("TowerID");
log.info("收到 PanaCIM 的getInventory 命令:TransactionID="+TransactionID+" TowerID="+TowerID);
/**
* {
"ErrorCode":0,
"ReelBarCodes":
[{"JobID":"1234","Location":"0","Msd":false,"Msdlevel":"1","PartNo":"part123","Quantity":123,"ReelBarcode":"123456789","TowerID":"InoAuto A"},
{"JobID":"1234","Location":"0","Msd":false,"Msdlevel":"1","PartNo":"part321","Quantity":321,"ReelBarcode":"123456789","TowerID":"InoAuto B"},
{"JobID":"1234","Location":"0","Msd":false,"Msdlevel":"1","PartNo":"part213","Quantity":213,"ReelBarcode":"123456789","TowerID":"InoAuto C"}],
"TransactionID":"testme"
}
*/
Collection<Storage> allStorage = dataCache.getAllStorage().values();
List<Storage> storageList = Lists.newArrayList();
if(Strings.isNullOrEmpty(TowerID)){
storageList.addAll(allStorage);
}else{
for (Storage storage : allStorage) {
if(storage.getName().equals(TowerID)){
storageList.add(storage);
break;
}
}
}
List ReelBarCodes = Lists.newArrayList();
for (Storage storage : storageList) {
List<StoragePos> poses = storagePosManager.findNotEmptyByStorageId(storage.getId());
for (StoragePos pos : poses){
Barcode barcode = pos.getBarcode();
Map<String,Object> item = Maps.newHashMap();
item.put("TowerID",TowerID);
item.put("JobID",barcode.getLockName());
item.put("ReelBarcode",barcode.getBarcode());
item.put("PartNo",barcode.getPartNumber());
item.put("Quantity",barcode.getAmount());
item.put("Msd",false);
item.put("msdlevel","");
item.put("Location","0");
ReelBarCodes.add(item);
}
}
result.put("TransactionID",TransactionID);
result.put("ErrorCode","0");
result.put("ReelBarCodes",ReelBarCodes);
} catch (Exception e) {
log.error("PanaCIM的指令 getInventory 出错",e);
result.put("ErrorCode","200");
}
return result;
}
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("Micron");
}
private String getUrl(String apiName){
return apiName;
}
public boolean validateMRB(String mbrId,boolean skipSap) {
//Validate if MBR (From Warehouse )  is valid
String skipSapStr = skipSap ? "YES" : "NO";
String url = getUrl(String.format("validate/mrb/{0}/{1}", mbrId, skipSap));
try {
MicronResult result = HttpHelper.getMicronJson(url);
if (result != null && result.isSuccess()) {
return true;
}
} catch (Exception e) {
log.error(url + "出错", e);
}
return false;
}
public boolean validateREQ(String reqId) {
//Validate if REQ (From Outside Shelf) is valid
String url = getUrl(String.format("validate/req/{0}", reqId));
try {
MicronResult result = HttpHelper.getMicronJson(url);
if (result != null && result.isSuccess()) {
return true;
}
} catch (Exception e) {
log.error(url + "出错", e);
}
return false;
}
public boolean validateMCL(String PurchaseOrder,String PackagingSlip,boolean skipSap ) {
//Validate if MCL GR  is valid
//validate/mcl/{PurchaseOrder}/{PackagingSlip}/{SkipSap}
// {PurchaseOrder}=<purchase order>,
// {PackagingSlip}=<packaging slide>,
// {SkipSAP}="YES|No"
String skipSapStr = skipSap ? "YES" : "NO";
String url = getUrl(String.format("validate/mcl/{0}/{1}/{2}", PurchaseOrder, PackagingSlip, skipSapStr));
try {
MicronResult result = HttpHelper.getMicronJson(url);
if (result != null && result.isSuccess()) {
return true;
}
} catch (Exception e) {
log.error(url + "出错", e);
}
return false;
}
public boolean validateMaterial(String Label2DID,String LoadingMode ) {
//Validate the material before loading into the storage bin
//validate/material
// {
// "Label2DID" : "<2DID String that contains SAP P/N; S/N; Supplier..etc>",
// "LoadingMode" : "MBR|REQ|GR|MCL|RET|NPI"
// }
String url = getUrl(String.format("validate/material"));
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("Label2DID", Label2DID);
dataMap.put("LoadingMode", LoadingMode);
try {
MicronResult result = HttpHelper.postMicronJson(url,dataMap);
if (result != null && result.isSuccess()) {
return true;
}
} catch (Exception e) {
log.error(url + "出错", e);
}
return false;
}
public boolean loadReport(String JobId , MaterialInfo[] materialInfos) {
//Update material storage location at rod or magazine slot level (One JobID per rod or slot).
//load-report
// {
// "JobId": "<job Id>",
// "Materials": [
// {
// "Label2DID": "<Label2DID>",
// "TowerID": "<TowerID>|null",
// "StorageBin": "<StorageBin>|null",
// "Qty": "<Label Qty>|<X-Ray Qty>",
// "X-RayCheck": "Yes|No|N/A",
// "ErrorCode": "0-Success|1-Rejected",
// "ErrorMessage": "N/A|<ErrorMessage>"
// }
//]
// }
String url = getUrl(String.format("load-report"));
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("JobId", JobId);
dataMap.put("Materials", materialInfos);
try {
MicronResult result = HttpHelper.postMicronJson(url,dataMap);
if (result != null && result.isSuccess()) {
return true;
}
} catch (Exception e) {
log.error(url + "出错", e);
}
return false;
}
public boolean dispatchList(String Facility,String DispatchType ) {
//Get ready Pretask/LinePrep/RET list from Auto Kitting System
//dispatch-list/{Facility}/{DispatchType}
// {Facility} = "Grouping that need to align with KitView"
// {DispatchType}="PreTask|LinePrep|RET"
String url = getUrl(String.format("dispatch-list/{0}/{1}", Facility, DispatchType));
try {
MicronResult result = HttpHelper.getMicronJson(url);
if (result != null && result.isSuccess()) {
return true;
}
} catch (Exception e) {
log.error(url + "出错", e);
}
return false;
}
public boolean dispatchMaterial(String DispatchType,String Id ) {
//Get dispatch Material list  from Autokitting system to fullfil the Pretask or LinePrep
//dispatch-material/{DispatchType}/{Id}
// {DispatchType}="PreTask|LinePrep|RET"
// Id="<PretaskId>|<LinePrepId>|<RetId>"
String url = getUrl(String.format("dispatch-material/{0}/{1}", DispatchType, Id));
try {
MicronResult result = HttpHelper.getMicronJson(url);
if (result != null && result.isSuccess()) {
return true;
}
} catch (Exception e) {
log.error(url + "出错", e);
}
return false;
}
public boolean dispatchReport(String JobId ,String dispatchType, MaterialInfo[] materialInfos) {
//Update dispatch information by Job Level
//dispatch-report
// "JobId": "<JobId>",
// "DispatchType": "PreTask|LinePrep|RET|Warehouse|Controlled",
// "Materials": [
// {
// "Label2DID": "<Label2DID>",
// "FromTowerID": "<TowerID>",
// "FromStorageBin": "<StorageBin>",
// "Qty": "<Qty>",
// }
//]
String url = getUrl(String.format("dispatch-report"));
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("JobId", JobId);
dataMap.put("DispatchType", dispatchType);
dataMap.put("Materials", materialInfos);
try {
MicronResult result = HttpHelper.postMicronJson(url,dataMap);
if (result != null && result.isSuccess()) {
return true;
}
} catch (Exception e) {
log.error(url + "出错", e);
}
return false;
}
}
package com.neotel.smfcore.custom.micron1053.controller;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.core.device.util.DataCache;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
@Service
@Slf4j
public class MicronConfig {
@Value("${micron.addr}")
public String micronAddr;
@Autowired
private DataCache dataCache;
public String getUrl(String apiName) {
if (ObjectUtil.isEmpty(micronAddr)) {
return "";
}
String url = micronAddr + apiName;
if (micronAddr.endsWith("/")) {
if (apiName.startsWith("/")) {
url = micronAddr + apiName.substring(1, apiName.length());
}
} else {
if (!apiName.startsWith("/")) {
url = micronAddr + "/" + apiName;
}
}
return micronAddr + apiName;
}
@PostConstruct
public void init() {
// host = dataCache.GetConfigCache("siemens.host", "siemens.host", url);
// port = dataCache.GetConfigCache("siemens.port", "siemens.port", url);
// url = dataCache.GetConfigCache("siemens.url", "siemens.url", url);
// action_GetMaterialLot = dataCache.GetConfigCache("siemens.action.GetMaterialLot", "siemens.action.GetMaterialLot", action_GetMaterialLot);
// action_ProcessMaterialLot = dataCache.GetConfigCache("siemens.action.ProcessMaterialLot", "siemens.action.ProcessMaterialLot", action_ProcessMaterialLot);
log.info("Micron sesrver addr:" + micronAddr );
}
}
package com.neotel.smfcore.custom.micron1053.controller;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.custom.micron1053.bean.MaterialInfo;
import com.neotel.smfcore.custom.micron1053.bean.MicronResult;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "API测试")
@RequestMapping("rest/api/test")
public class MicronTestController {
@Autowired
private MicronApi apiController;
@ApiOperation("API-001 validate/mrb/{Id}/{SkipSap}")
@GetMapping("/validateMRB")
@AnonymousAccess
public String validateMRB(String Id, String SkipSap) {
MicronResult result = apiController.validateMRB(Id, SkipSap);
if (ObjectUtil.isEmpty(result)) {
return "";
}
return result.getResponseData();
}
@ApiOperation("API-002 validate/req/{Id}")
@GetMapping("/validateREQ")
@AnonymousAccess
public String validateREQ(String Id) {
MicronResult result = apiController.validateREQ(Id);
if (ObjectUtil.isEmpty(result)) {
return "";
}
return result.getResponseData();
}
@ApiOperation("API-003 validate/mcl/{PurchaseOrder}/{PackagingSlip}/{SkipSap}")
@GetMapping("/validateMCL")
@AnonymousAccess
public String validateMCL(String PurchaseOrder, String PackagingSlip, String skipSap) {
MicronResult result = apiController.validateMCL(PurchaseOrder, PackagingSlip, skipSap);
if (ObjectUtil.isEmpty(result)) {
return "";
}
return result.getResponseData();
}
@ApiOperation("API-004 validate/material")
@GetMapping("/validateMaterial")
@AnonymousAccess
public String validateMaterial(String Label2DID, String LoadingMode) {
MicronResult result = apiController.validateMaterial(Label2DID, LoadingMode);
if (ObjectUtil.isEmpty(result)) {
return "";
}
return result.getResponseData();
}
@ApiOperation("API-005 load-report")
@GetMapping("/loadReport")
@AnonymousAccess
public String loadReport(String params ) {
Map<String,Object> paramsMap=JsonUtil.toMap(params);
String JobId = paramsMap.get("JobId").toString();
Object obj=paramsMap.get("Materials");
List<Map<String,String>> arr=(List<Map<String, String>>)obj;
List<MaterialInfo> materialInfos=MaterialInfo.GetObjList(arr);
MicronResult result = apiController.loadReport(JobId, materialInfos);
if (ObjectUtil.isEmpty(result)) {
return "";
}
return result.getResponseData();
}
@ApiOperation("API-007 dispatch-list/{Facility}/{DispatchType}")
@GetMapping("/dispatchList")
@AnonymousAccess
public String dispatchList(String Facility, String DispatchType) {
MicronResult result = apiController.dispatchList(Facility, DispatchType);
if (ObjectUtil.isEmpty(result)) {
return "";
}
return result.getResponseData();
}
@ApiOperation("API-009 dispatch-material/{DispatchType}/{Id}")
@GetMapping("/dispatchMaterial")
@AnonymousAccess
public String dispatchMaterial(String DispatchType, String Id) {
MicronResult result = apiController.dispatchMaterial(DispatchType, Id);
if (ObjectUtil.isEmpty(result)) {
return "";
}
return result.getResponseData();
}
@ApiOperation("API-010 dispatch-report")
@GetMapping("/dispatchReport")
@AnonymousAccess
public String dispatchReport(String params) {
Map<String,Object> paramsMap=JsonUtil.toMap(params);
String JobId = paramsMap.get("JobId").toString();
String dispatchType = paramsMap.get("DispatchType").toString();
Object obj=paramsMap.get("Materials");
List<Map<String,String>> arr=(List<Map<String, String>>)obj;
List<MaterialInfo> materialInfos=MaterialInfo.GetObjList(arr);
MicronResult result = apiController.dispatchReport(JobId, dispatchType, materialInfos);
if (ObjectUtil.isEmpty(result)) {
return "";
}
return result.getResponseData();
}
}
package com.neotel.smfcore.custom.neotel;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.storage.bean.UsageItem;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.annotation.AnonymousPostMapping;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
@Slf4j
@RestController
@RequestMapping("/rest/api")
public class NeotelController {
@Autowired
protected ILiteOrderManager liteOrderManager;
@Autowired
protected LiteOrderCache liteOrderCache;
@Autowired
private DataCache dataCache;
@Autowired
private IStoragePosManager storagePosManager;
// @ApiOperation("6.1创建需求单")
// @RequestMapping("/outInfo")
// @AnonymousAccess
// public ResultBean outInfo(@RequestBody List<Map<String, Object>> paramList) {
// log.info("{}收到数据为:{}", "创建需求单outInfo", JsonUtil.toJsonStr(paramList));
// if (!paramList.isEmpty()) {
// for (Map<String, Object> paramMap : paramList) {
// if (paramMap.get("hSerial") == null) {
// return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"hSerial"});
// }
// if (paramMap.get("outItems") == null) {
// return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"outItems"});
// }
// String orderNo = paramMap.get("hSerial").toString(); //需求单号
// LiteOrder order = liteOrderManager.findByOrderNo(orderNo);
// if(order != null){
// return ResultBean.newErrorResult(101, "smfcore.liteOrder.exist", "需求单{0}已存在", new String[]{orderNo});
// }
//
// boolean execute = false;
// if (paramMap.get("execute") != null) {
// execute = Boolean.valueOf(paramMap.get("execute").toString());
// }
//
// String line = paramMap.get("line") == null ? "" : paramMap.get("line").toString(); //线别
// String so = paramMap.get("so") == null ? "" : paramMap.get("so").toString(); //工单号
// //需求单详情数据
// List<LiteOrderItem> orderItemList = new ArrayList<>();
// List<Map> outItemList = JsonUtil.toList(paramMap.get("outItems").toString(), Map.class);
// if (!outItemList.isEmpty()) {
// for (Map outItem : outItemList) {
// LiteOrderItem orderItem = new LiteOrderItem();
// if (outItem.get("slotNum") != null) {
// orderItem.setSlotNum(Integer.valueOf(outItem.get("slotNum").toString())); //站位编号
// }
// if (outItem.get("reelId") != null) {
// String reelId = outItem.get("reelId").toString();
// orderItem.setRi(reelId); //料盘唯一码
// orderItem.setNeedNum(1);
// }
// orderItemList.add(orderItem);
// }
// }
// boolean singleOut = false;
// if (paramMap.get("singleOut") != null) {
// singleOut = Boolean.valueOf(paramMap.get("singleOut").toString());
// }
// //开始保存数据
// LiteOrder liteOrder = new LiteOrder();
// liteOrder.setOrderNo(orderNo);
// liteOrder.setLine(line);
// liteOrder.setSo(so);
// liteOrder.setOrderItems(orderItemList);
// liteOrder = liteOrderManager.createWithItems(liteOrder);
// liteOrderCache.addOrderToMap(liteOrder);
// if(execute){
// liteOrderCache.checkOutLiteOrder(liteOrder.getOrderNo(),false, singleOut);
// }
// }
// return ResultBean.newOkResult("");
// }
// return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "需求单信息不能为空");
// }
// @ApiOperation("6.2关闭需求单")
// @RequestMapping("/closeOutInfo")
// @AnonymousAccess
// public ResultBean closeOutInfo(@RequestBody Map<String, String> paramMap) {
// String orderNo = paramMap.get("hSerial"); //需求工单
// if (ObjectUtils.isEmpty(orderNo)) {
// return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"hSerial"});
// }
// String result = liteOrderCache.closeOrder(orderNo);
// if ("smfcore.order.close.success".equals(result)) {
// return ResultBean.newOkResult("");
// } else {
// return ResultBean.newErrorResult(1, "", "关闭失败");
// }
// }
@ApiOperation("6.5 获取实时库存")
@RequestMapping("/inventory")
@AnonymousAccess
public ResultBean inventory(@RequestBody Map<String, List<String>> paramMap) {
List<String> partNums = paramMap.get("partNums");
List<String> reelIds = paramMap.get("reelIds");
List<String> cids = paramMap.get("towerIds");
List<String> storageIds = new ArrayList<>();
if(cids != null){
for (String cid : cids) {
Storage storage = dataCache.getStorage(cid);
if(storage != null){
storageIds.add(storage.getId());
}
}
}
List<StoragePos> storagePosList = storagePosManager.findByBarcodesAndPartNums(storageIds, partNums, reelIds);
if (storagePosList != null) {
List<Map<String, Object>> resultMapList = new ArrayList<>();
for (StoragePos storagePos : storagePosList) {
Barcode barcode = storagePos.getBarcode();
if (barcode != null) {
if (barcode.getSubCodeList() != null && !barcode.getSubCodeList().isEmpty()) {
for (Barcode subBarcode : barcode.getSubCodeList()) {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("reelId", subBarcode.getBarcode());
resultMap.put("qty", subBarcode.getAmount());
resultMap.put("towerId", storagePos.getStorageId());
resultMap.put("location", storagePos.getPosName());
resultMap.put("partNum", subBarcode.getPartNumber());
resultMapList.add(resultMap);
}
} else {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("reelId", barcode.getBarcode());
resultMap.put("qty", barcode.getAmount());
resultMap.put("towerId", storagePos.getStorageId());
resultMap.put("location", storagePos.getPosName());
resultMap.put("partNum", barcode.getPartNumber());
resultMapList.add(resultMap);
}
}
}
return ResultBean.newOkResult(resultMapList);
}
return ResultBean.newErrorResult(1, "", "未找到实时库存信息");
}
// @ApiOperation("6.4 设备状态获取")
// @RequestMapping("/deviceStatus")
// @AnonymousAccess
// public ResultBean deviceStatus(@RequestBody Map<String, Object> paramMap) {
// Collection<Storage> storageList = Lists.newArrayList();
// List<String> deviceKeyList = paramMap.get("deviceKeyList") == null ? null : JsonUtil.toList(paramMap.get("deviceKeyList").toString(), String.class);
// //如果没有的话 就查询所有的
// if (deviceKeyList == null || deviceKeyList.size() < 1) {
// storageList.addAll(dataCache.getAllStorage().values());
// } else {
// for (String cid : deviceKeyList) {
// Storage storage = dataCache.getStorage(cid);
// storageList.add(storage);
// }
// }
// List<Map<String, Object>> results = Lists.newArrayList();
// for (Storage storage : storageList) {
// StatusBean statusBean = DevicesStatusUtil.getStatusBean(storage.getCid());
// if(statusBean == null){
// statusBean = new StatusBean();
// }
// Map<String, BoxStatusBean> boxStatusMap = statusBean.getBoxStatus();
// int status = -1;
// if (boxStatusMap != null) {
// BoxStatusBean boxStatusBean = boxStatusMap.get("1");
// if (boxStatusBean != null) {
// status = boxStatusBean.getStatus();
// }
// }
// int storageStatus = status;
// if (status == StorageConstants.STATUS.OFFLINE || statusBean.timeOut()) {
// //离线
// storageStatus = -1;
// }
// String msg = statusBean.getMsg();
// String msgType = statusBean.getDeviceType();
// Map<String, Object> itemMap = new HashMap<>();
// itemMap.put("deviceKey", storage.getType() + "." + storage.getCid());
// itemMap.put("name", storage.getName());
// itemMap.put("status", storageStatus);
// itemMap.put("msg", msg);
// itemMap.put("msgType", msgType);
// itemMap.put("startTime", storage.getCreateDate());
// itemMap.put("updateTime", storage.getUpdateDate());
// Map<String, Object> deviceDataMap = new HashMap<>();
// Map<String, Object> emptySlotMap = Maps.newHashMap();
// Map<String, Object> totalSlotMap = Maps.newHashMap();
// Map<String, UsageItem> usageMap = storage.getUsageMap();
// for (UsageItem usageItem : usageMap.values()) {
// String sizeStr = usageItem.getSizeStr();
// int total = usageItem.getTotalCount();
// int used = usageItem.getUsedCount();
// totalSlotMap.put(sizeStr, total);
// emptySlotMap.put(sizeStr, total - used);
// }
// deviceDataMap.put("towerId", storage.getCid());
// deviceDataMap.put("status", statusBean.getStatus());
// deviceDataMap.put("name", storage.getName());
// deviceDataMap.put("doorReelSignal", statusBean.getDoorReelSingnal());
// deviceDataMap.put("barcode", statusBean.getData().get("barcode"));
// deviceDataMap.put("emptySlot", emptySlotMap);
// deviceDataMap.put("totalSlot", totalSlotMap);
// itemMap.put("deviceData", deviceDataMap);
// results.add(itemMap);
// }
// return ResultBean.newOkResult(results);
// }
}
...@@ -44,3 +44,6 @@ menu: ...@@ -44,3 +44,6 @@ menu:
show: show:
hide: hide:
micron:
addr:
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!