Commit 3c3df714 LN

韩华接口代码

1 个父辈 fb5e5a98
正在显示 27 个修改的文件 包含 2362 行增加13 行删除
......@@ -130,6 +130,8 @@ public class MenuInit {
//电子看板
addDefaultFunctionMenu(1, boardMap, "仪表盘2", "eleckanban", "eleckanban/index", "kanban");
//SP仪表盘
addDefaultFunctionMenu(0, boardMap, "SP仪表盘", "spkanban", "kanban/spkanban/index", "kanban");
//设备看板
addDefaultFunctionMenu(1,null,"设备互联","lockMaterial", "lockMaterial/material/index","kanban",DEFAULT_SHOW_MENU);
......
......@@ -180,7 +180,7 @@ public class HttpHelper {
//httpClient.close();
return responseContent;
} catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
throw new ApiException("Request to [" + url + "]["+requestBody+"] failed:" + e.getMessage());
} finally {
try {
if (response != null) {
......
......@@ -2,9 +2,7 @@ package com.neotel.smfcore.core.api;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.init.MenuInit;
import com.neotel.smfcore.core.api.listener.ISmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
......@@ -84,6 +82,8 @@ public class SmfApi {
@Value("${api.fetchOrderUrl:}")
protected String fetchOrderUrl = "";
@Value("${api.deviceStatusUrl:}")
protected String deviceStatusUrl = "";
@PostConstruct
public void init(){
......@@ -99,6 +99,7 @@ public class SmfApi {
fetchInListUrl = dataCache.getConfigCache("api.fetchInListUrl",fetchInListUrl);
fetchOrderUrl = dataCache.getConfigCache("api.fetchOrderUrl",fetchOrderUrl);
loginCheckUrl=dataCache.getConfigCache("api.loginCheckUrl",loginCheckUrl);
deviceStatusUrl=dataCache.getConfigCache("api.deviceStatusUrl",deviceStatusUrl);
}
/**
......@@ -277,7 +278,22 @@ public class SmfApi {
}
return null;
}
/**
* 设备状态变化是调用
* @return
* @throws ValidateException
*/
public boolean deviceStatusChanges(String[] cids,Integer[] status) throws ValidateException {
if (isUrlExist(deviceStatusUrl)) {
for (ISmfApiListener apiListener : apiListenerList) {
if (apiListener.isForThisApi(apiName)) {
return apiListener.deviceStatusChanges(deviceStatusUrl, cids, status);
}
}
}
return true;
}
public String getApiName(){
return apiName;
}
......
......@@ -73,7 +73,7 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
return component;
}
protected Component resolveComponent(Barcode barcode){
return resolveComponent(barcode, COMPONENT_TYPE.COMPONENT);
return resolveComponent(barcode, COMPONENT_TYPE.COMPONENT);
}
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task){
......@@ -100,7 +100,7 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
}
@Override
public LiteOrder fetchOrder(String fetchOrderUrl, String orderNumber, String username){
public LiteOrder fetchOrder(String fetchOrderUrl, String orderNumber, String username) {
return null;
}
......@@ -110,7 +110,7 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
}
@Override
public DataLog canCheckOut(String outCheckUrl, DataLog dataLog) throws ValidateException{
public DataLog canCheckOut(String outCheckUrl, DataLog dataLog) throws ValidateException {
return null;
}
......@@ -120,7 +120,7 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
}
@Override
public InList fetchInList(String fetchInListUrl, String number){
public InList fetchInList(String fetchInListUrl, String number) {
return null;
}
protected String getData(Map<String, Object> dataMap, String dataKey) {
......@@ -131,7 +131,7 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
return data.toString();
}
}
protected Integer getIntData(Map<String, Object> dataMap, String dataKey,Integer defValue) {
protected Integer getIntData(Map<String, Object> dataMap, String dataKey, Integer defValue) {
try {
Object data = dataMap.get(dataKey);
if (data == null) {
......@@ -147,4 +147,9 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
}
return defValue;
}
@Override
public boolean deviceStatusChanges(String deviceStatusUrl, String[] cids,Integer[] status) {
return true;
}
}
......@@ -72,4 +72,12 @@ public interface ISmfApiListener {
InList fetchInList(String fetchInListUrl, String number);
/**
* 设备状态变化
* @param deviceStatusUrl
* @param cids
* @return
*/
boolean deviceStatusChanges(String deviceStatusUrl, String[] cids,Integer[] status );
}
......@@ -855,16 +855,25 @@ public class BaseDeviceHandler implements IDeviceHandler {
List<MsgInfo> mergeMsgList = statusBean.MsgDataProcess();
//判断是否刚刚上线
StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid());
int preStatus=-1;
if (bean == null || bean.getBoxStatus() == null) {
DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp());
DevicesStatusUtil.updateClientMsg(statusBean.getCid(),new ArrayList<>());
} else if (bean.timeOut() && (bean.getOfflineTime() > -1)) {
DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp());
DevicesStatusUtil.updateClientMsg(statusBean.getCid(), new ArrayList<>());
}else{
preStatus=statusBean.getStatus();
}
if(ObjectUtil.isNotEmpty(mergeMsgList)&& mergeMsgList.size()>0) {
DevicesStatusUtil.updateClientMsg(statusBean.getCid(), mergeMsgList);
}
//状态变化
if(statusBean.getStatus()!=preStatus){
smfApi.deviceStatusChanges(new String[]{statusBean.getCid()},new Integer[]{statusBean.getStatus()});
}
// //判断是否刚刚上线
// StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid());
// if (bean == null || bean.getBoxStatus() == null) {
......
......@@ -6,6 +6,7 @@ import com.google.common.collect.Maps;
import com.neotel.smfcore.common.init.MenuInit;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.dashboard.bean.dto.box.MesInfoDto;
import com.neotel.smfcore.core.device.bean.MsgInfo;
import com.neotel.smfcore.core.device.bean.StatusBean;
......@@ -45,6 +46,14 @@ public class DevicesStatusUtil {
DevicesStatusUtil.menuInit = init;
}
private static SmfApi smfApi;
@Autowired
private void setSmfApi(SmfApi init) {
DevicesStatusUtil.smfApi = init;
}
/**
* 状态 map,key为 cid value 为状态 Bean
*/
......@@ -292,6 +301,7 @@ public class DevicesStatusUtil {
if (bean.getOfflineTime() == -1 && bean.timeOut()) {
bean.setOfflineTime(System.currentTimeMillis());
DeviceMessageUtil.addOfflineMessage(bean.getCid(), "");
smfApi.deviceStatusChanges(new String[]{bean.getCid()},new Integer[]{-1});
}
}
}
......
package com.neotel.smfcore.custom.hanwha.client;
import lombok.extern.slf4j.Slf4j;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
@Slf4j
public class MyWebSocketClient extends WebSocketClient {
private WsMsgReceivedListener msgReceivedListener; // 消息接收监听器
public MyWebSocketClient(URI serverUri, WsMsgReceivedListener listener) {
super(serverUri);
this.msgReceivedListener =listener;
}
@Override
public void onOpen(ServerHandshake serverHandshake) {
log.info("onOpen ");
log.info((new Date().toString()) + "connect webSServer ok ");
cancelReconnect();
if(msgReceivedListener!=null) {
msgReceivedListener.onOpen();
}
}
@Override
public void onMessage(String s) {
log.info("onMessage: "+s);
if(msgReceivedListener!=null){
msgReceivedListener.onMsgReceived(s);
}
}
@Override
public void onClose(int i, String s, boolean b) {
log.info("onClose: code:{} reason:{} {}", i, s, b);
startReconnect();
}
@Override
public void onError(Exception e) {
log.error("web socket client onerror :"+e.toString());
//关闭后重新连接
try {
close();
}catch (Exception ex){
log.error("web socket client onerror close error:"+e.toString());
}
startReconnect();
}
private static final long RECONNECT_DELAY = 5000; // 重连延迟时间,单位:毫秒
private Timer reconnectTimer; // 重连定时器
private void startReconnect() {
try {
if (reconnectTimer == null) {
reconnectTimer = new Timer();
reconnectTimer.schedule(new TimerTask() {
@Override
public void run() {
try {
log.info("startReconnect ");
// 创建新的WebSocket连接
reconnect();
} catch (Exception e) {
log.error("出错:" + e.toString());
}
}
}, RECONNECT_DELAY);
}
} catch (Exception exception) {
log.error("startReconnect error :" + exception.toString());
}
}
private void cancelReconnect() {
try{
if (reconnectTimer != null) {
log.info("cancelReconnect ");
reconnectTimer.cancel();
reconnectTimer = null;
}
}catch (Exception exception){
log.error("cancelReconnect error :"+exception.toString());
}
}
// private void reconnect() throws URISyntaxException {
// URI serverUri = super.getURI();
// MyWebSocketClient newClient = new MyWebSocketClient(serverUri);
// newClient.connect();
// }
}
package com.neotel.smfcore.custom.hanwha.client;
public interface WsMsgReceivedListener {
void onMsgReceived(String message);
void onOpen();
}
package com.neotel.smfcore.custom.hanwha.controller;
public class HanwhaController {
}
package com.neotel.smfcore.custom.hanwha.handler;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.custom.hanwha.handler.bean.TMSPart;
import com.neotel.smfcore.custom.hanwha.handler.bean.TMSPartReelPos;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
@Slf4j
public class HanwhaApiHandler extends BaseSmfApiListener {
//配置說明
// api:
// name: hanwha
// inCheckUrl: webservice/RequestGetPartInfo
// outNotifyUrl: webservice/RequestSyncPartReelPosInfo
// inNotifyUrl: webservice/RequestSyncPartReelPosInfo
// deviceStatusUrl: webservice/RequestUpdateStorageConnectionInfo
//
// hanwha:
// host: 127.0.0.1
// webPort: 18189
// apiPort: 8374
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("hanwha")&& TMSCommunicator.isEnable();
}
@Autowired
private TMSApis tmsApis;
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if (task.isFinished()) {
if (task.isPutInTask()) {
List<TMSPartReelPos> list = new ArrayList<>();
TMSPartReelPos bean = TMSPartReelPos.newBean(task.getPartNumber(), task.getBarcode(), task.getNum(), task.getCid(), task.getPosName(), 1, task.getUpdateDate().getTime(), -1);
list.add(bean);
log.info("barcode["+task.getBarcode()+"],pn["+task.getPartNumber()+"],posName["+task.getPosName()+"]入库完成,调用 RequestSyncPartReelPosInfo");
tmsApis.RequestSyncPartReelPosInfo(0, list);
}
}
}
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if (task.isFinished()) {
if (task.isCheckOutTask()) {
List<TMSPartReelPos> list = new ArrayList<>();
TMSPartReelPos bean = TMSPartReelPos.newBean(task.getPartNumber(), task.getBarcode(), task.getNum(), task.getCid(), task.getPosName(), 2, -1, task.getUpdateDate().getTime());
list.add(bean);
log.info("barcode[" + task.getBarcode() + "],pn[" + task.getPartNumber() + "],posName[" + task.getPosName() + "]出库完成,调用 RequestSyncPartReelPosInfo");
tmsApis.RequestSyncPartReelPosInfo(0, list);
}
}
}
@Override
public Barcode canPutInAfterResolve(String inCheckUrl, CodeValidateParam params, Barcode barcode) throws ValidateException {
log.info("barcode[" + barcode.getBarcode() + "] 准备入库,调用 RequestGetPartInfo");
List<TMSPart> result = tmsApis.RequestGetPartInfo(0, barcode.getFullCode());
if (result.size() > 0) {
String pn = result.get(0).getPartName();
String code = result.get(0).getReelCode();
boolean needS = false;
if (ObjectUtil.isNotEmpty(pn)) {
barcode.setPartNumber(pn);
needS = true;
}
if (ObjectUtil.isNotEmpty(code)) {
barcode.setBarcode(code);
needS = true;
}
int count = result.get(0).getResponseCount();
if (count > 0) {
barcode.setAmount(count);
needS = true;
}
if (needS) {
log.info("barcode[" + barcode.getBarcode() + "] 准备入库,调用 RequestGetPartInfo ,更改pn=[" + barcode.getPartNumber() + "],code=[" + barcode.getBarcode() + "],count=[" + barcode.getAmount() + "]");
barcodeManager.saveBarcode(barcode);
}
}
return barcode;
}
@Override
public boolean deviceStatusChanges(String deviceStatusUrl, String[] cids,Integer[] statusList ) {
log.info("deviceStatusChanges ,设备状态变化["+ JsonUtil.toJsonStr(cids) +"],["+ JsonUtil.toJsonStr(statusList) +"],通知TMS");
UpdateStorageConnectionInfo(cids,statusList);
return true;
}
public void UpdateStorageConnectionInfo(String[] cids,Integer[] statusList) {
if (!TMSCommunicator.isEnable()) {
return;
}
List<String> storageIds = new ArrayList<>();
List<String> storageTypes = new ArrayList<>();
List<Integer> isConns = new ArrayList<>();
int i = 0;
for (String cid : cids) {
Storage storage = dataCache.getStorage(cid);
if (storage == null) {
continue;
}
String type = "Storage";
if (storage.isNLShelf() || storage.isNLPShelf() || storage.isNLMShelf() || storage.isShelf()) {
type = "Rack";
}
int status = -1;
if (statusList != null && statusList.length > i) {
status = statusList[i];
} else {
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
if (bean == null || bean.timeOut()) {
status = -1;
} else {
status = bean.getStatus();
}
}
String conCode = TMS_Code.CODE_1020;
if (status <= 0) {
//初始化失败
conCode = TMS_Code.CODE_0002;
} else if (status == 1) {
conCode = TMS_Code.CODE_1020;
} else if (status <= 4) {
//报警
conCode = TMS_Code.CODE_1024;
} else if (status == 5) {
conCode = TMS_Code.CODE_1023;
} else {
//忙碌
conCode = TMS_Code.CODE_1010;
}
storageIds.add(storage.getCid());
storageTypes.add(type);
isConns.add(Integer.parseInt(conCode));
i++;
}
if (storageIds.size() > 0) {
tmsApis.RequestUpdateStorageConnectionInfo(0, storageIds, storageTypes, isConns);
}
}
}
package com.neotel.smfcore.custom.hanwha.handler;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.custom.hanwha.handler.bean.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
@Slf4j
public class TMSApis {
/**
* 3.16 RequestGetPartInfo
* Request part information of given ReelCode to TMS (when the Rack needs it).
* @param RequestID
* @param ReelCode
* @return
*/
public List<TMSPart> RequestGetPartInfo(int RequestID, String ReelCode)
{
List<TMSPart> list = new ArrayList<>();
try {
String url = TMSCommunicator.apiURL + "webservice/RequestGetPartInfo";
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("RequestID", RequestID);
dataMap.put("Indate", getInDataStr());
dataMap.put("ReelCode", ReelCode);
Map<String, Object> sendData = new HashMap<>();
sendData.put("data", dataMap);
String responseStr = PostJson(url, sendData);
if (!ObjectUtil.isNotEmpty(responseStr)) {
Map<String, Object> dataMap2 = JsonUtil.toMap(responseStr);
List<Object> jArray = (List<Object>) dataMap2.get("Data");
for (Object obj : jArray) {
Map<String, Object> map = (Map<String, Object>) (obj);
TMSPart item = new TMSPart();
item.setPartName(getMapValue(map, "PartName"));
item.setReelCode(getMapValue(map, "ReelCode"));
item.setResponseCount((Integer)getMapValue(map, "Count"));
item.setRequestCount((Integer)getMapValue(map, "Count"));
list.add(item);
}
return list;
}
}
catch (Exception ex)
{
log.error("RequestGetPartInfo RegisterID=[" + RequestID + "] ReelCode=["+ReelCode+"] error :" + ex.toString());
}
return list;
}
/**
* 3.17 RequestSyncPartReelPosInfo
* Rack sends the updated part(position) information to TMS when the rack status
* has changed by reel input/output. Rack should send this on boot-up also
* @param RequestID
* @param SyncPartReelPosDatas
* @return
*/
public List<TMSPart> RequestSyncPartReelPosInfo(int RequestID, List<TMSPartReelPos> SyncPartReelPosDatas)
{
List<TMSPart> result=new ArrayList<>();
try
{
String url = TMSCommunicator.apiURL + "webservice/RequestSyncPartReelPosInfo";
Map<String,Object> dataMap = new HashMap<>();
dataMap.put("RequestID", RequestID);
dataMap.put("Indate", getInDataStr());
List<Object> jArray = new ArrayList<>();
for (TMSPartReelPos pos : SyncPartReelPosDatas)
{
jArray.add(pos.getJson());
}
dataMap.put("SyncPartReelPosDatas", jArray);
Map<String, Object> sendData = new HashMap<>();
sendData.put("data", dataMap);
String responseStr = PostJson(url, sendData);
result=new ArrayList<>();
if (!ObjectUtil.isNotEmpty(responseStr)) {
Map<String, Object> reviceMap = JsonUtil.toMap(responseStr);
List<Object> jArray2 = (List<Object>) (reviceMap.get("Data"));
for (Object object : jArray2) {
String str = JsonUtil.toJsonStr(object);
Map<String, Object> map = JsonUtil.toMap(str);
TMSPart item = new TMSPart();
item.setPartName(getMapValue(map, "PartName"));
item.setReelCode(getMapValue(map, "ReelCode").toString());
item.setRequestCount(getMapValue(map, "Count"));
item.setResponseCount(getMapValue(map, "Count"));
result.add(item);
}
}
return result;
}
catch (Exception ex) {
log.error("RequestSyncPartReelPosInfo RegisterID=[" + RequestID + "] error :" + ex.toString());
return result;
}
}
/**
* 3.18 RequestSyncRackStatusInfo
* When Rack’ Status change, send to TMS about Rack’s Status.
* @param RequestID
* @param SyncRackStatusDatas
* @return
*/
public List<TMSRackStatus> RequestSyncRackStatusInfo(int RequestID, List<TMSRackStatus> SyncRackStatusDatas)
{
List<TMSRackStatus> result = new ArrayList<>();
try {
String url = TMSCommunicator.apiURL + "webservice/RequestSyncRackStatusInfo";
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("RequestID", RequestID);
dataMap.put("Indate", getInDataStr());
List<Object> jArray = new ArrayList<>();
for (TMSRackStatus SyncRackStatusData : SyncRackStatusDatas) {
jArray.add(SyncRackStatusData.getJson());
}
dataMap.put("SyncRackStatusDatas", jArray);
Map<String, Object> sendData = new HashMap<>();
sendData.put("data", dataMap);
String responseStr = PostJson(url, sendData);
if (!ObjectUtil.isNotEmpty(responseStr)) {
List<Object> resList = JsonUtil.toList(responseStr, Object.class);
for (Object obj : resList) {
Map<String, Object> map = JsonUtil.toMap(JsonUtil.toJsonStr(obj));
TMSRackStatus item = new TMSRackStatus();
item.setRackID (getMapValue(map, "RackID")) ;
item.setRowID (getMapValue(map, "RowID")) ;
item.setColID (getMapValue(map, "ColID")) ;
item.setIndate (getMapValue(map, "Indate"));
item.setOutdate (getMapValue(map, "Outdate"));
result.add(item);
}
return result;
}
}
catch (Exception ex)
{
log.error("RequestSyncRackStatusInfo RegisterID=[" + RequestID + "] error :" + ex.toString());
}
return result;
}
/**
*3.21 RequestUpdateStorageConnectionInfo
* When Rack’s Connection Status changed, send to TMS about Rack Connection
* Status.
* @param RequestID
* @param StorageID
* @param StorageType
* @param IsConn
* @return
*/
public int RequestUpdateStorageConnectionInfo(int RequestID, List<String> StorageID, List<String> StorageType, List<Integer> IsConn) {
try {
String url = TMSCommunicator.apiURL + "webservice/RequestUpdateStorageConnectionInfo";
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("RequestID", RequestID);
dataMap.put("Indate", getInDataStr());
dataMap.put("StorageID", StorageID);
dataMap.put("StorageType", StorageType);
dataMap.put("IsConn", IsConn);
Map<String, Object> sendData = new HashMap<>();
sendData.put("data", dataMap);
String responseStr = PostJson(url, sendData);
if (ObjectUtil.isNotEmpty(responseStr)) {
return Integer.parseInt(responseStr);
}
return 1;
} catch (Exception ex) {
log.error("RequestUpdateStorageConnectionInfo RegisterID=[" + RequestID + "] error :" + ex.toString());
return 1;
}
}
private static <T> T getMapValue(Map<String,Object> resultMap, String key ) throws ApiException {
if (key != null && !key.isEmpty()) {
Object value = resultMap.get(key);
if (value != null) {
return (T) value;
}
}
return null;
}
public boolean SendUpdateRegisterPartInfoEvent() {
try {
String url = TMSCommunicator.apiURL + "webservice/SendUpdateRegisterPartInfoEvent";
Map<String,String> dataMap=new HashMap<>();
dataMap.put("Indate",getInDataStr());
Map<String,Object> sendData=new HashMap<>();
sendData.put("data",JsonUtil.toJsonStr(dataMap));
String responseStr = PostJson(url, sendData);
return true;
} catch (Exception ex) {
log.error("SendUpdateRegisterPartInfoEvent error :" + ex.toString());
return false;
}
}
private String getInDataStr(){
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String timeStr = DateUtil.toDateString((new Date().getTime()),"yyyy-MM-dd HH:mm:ss");
return timeStr;
}
public String GetLTSData(String BoardSN)
{
try
{
String url = TMSCommunicator.apiURL + "mes/lts";
Map<String,String> dataMap=new HashMap<>();
dataMap.put("Indate",getInDataStr());
Map<String,Object> sendData=new HashMap<>();
sendData.put("data",JsonUtil.toJsonStr(dataMap));
sendData.put("strBoardSN",BoardSN);
String responseStr = PostJson(url, sendData);
return responseStr;
}
catch (Exception ex)
{
log.error("GetLTSData BoardSN=["+BoardSN+"] error :" + ex.toString());
return null;
}
}
public int UpdateRegisterIDList(List<String> RegisterIDList)
{
try
{
String url = TMSCommunicator.apiURL + "webservice/UpdateRegisterIDList";
Map<String,String> dataMap=new HashMap<>();
dataMap.put("Indate",getInDataStr());
dataMap.put("RegisterIDList",JsonUtil.toJsonStr(RegisterIDList));
Map<String,Object> sendData=new HashMap<>();
sendData.put("data",JsonUtil.toJsonStr(dataMap));
String responseStr = PostJson(url, sendData);
if(ObjectUtil.isNotEmpty(responseStr)){
return Integer.parseInt(responseStr);
}
return 1;
}
catch (Exception ex)
{
log.error("UpdateRegisterIDList RegisterIDList=["+JsonUtil.toJsonStr(RegisterIDList)+"] error :" + ex.toString());
return 1;
}
}
public int GetStateOfTagRegister(String RegisterID) {
try {
String url = TMSCommunicator.apiURL + "webservice/GetStateOfTagRegister";
Map<String, String> dataMap = new HashMap<>();
dataMap.put("Indate", getInDataStr());
dataMap.put("RegisterID", RegisterID);
Map<String, Object> sendData = new HashMap<>();
sendData.put("data", dataMap);
String responseStr = PostJson(url, sendData);
if (ObjectUtil.isNotEmpty(responseStr)) {
return Integer.parseInt(responseStr);
}
return 1;
} catch (Exception ex) {
log.error("GetStateOfTagRegister RegisterID=[" + RegisterID + "] error :" + ex.toString());
return 1;
}
}
public int RegisterPartInfo(String PartName, String ReelCode, int Count, int Flag, String RegisterID) {
try {
String url = TMSCommunicator.apiURL + "webservice/RegisterPartInfo";
Map<String, String> dataMap = new HashMap<>();
dataMap.put("Indate", getInDataStr());
dataMap.put("PartName", PartName);
dataMap.put("ReelCode", ReelCode);
dataMap.put("Count", Count + "");
dataMap.put("Flag", Flag + "");
dataMap.put("RegisterID", RegisterID);
Map<String, Object> sendData = new HashMap<>();
sendData.put("data", dataMap);
String responseStr = PostJson(url, sendData);
if (ObjectUtil.isNotEmpty(responseStr)) {
return Integer.parseInt(responseStr);
}
return 1;
} catch (Exception ex) {
log.error("RegisterPartInfo PartName=[" + PartName + "],ReelCode=[" + ReelCode + "], error :" + ex.toString());
return 1;
}
}
public TMSResultMsg RequestUpdateReelCount(int RequestID, String ReelCode, int Count) {
try {
TMSResultMsg tMSResultMsg = new TMSResultMsg();
String url = TMSCommunicator.apiURL + "webservice/RequestUpdateReelCount";
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("RequestID", RequestID);
dataMap.put("Indate", getInDataStr());
dataMap.put("ReelCode", ReelCode);
dataMap.put("Count", Count);
Map<String, Object> sendData = new HashMap<>();
sendData.put("data", dataMap);
String responseData = PostJson(url, sendData);
if (!ObjectUtil.isNotEmpty(responseData)) {
Map<String, Object> reviceData = JsonUtil.toMap(responseData);
tMSResultMsg.setResult( Integer.parseInt(reviceData.get("result").toString()));
tMSResultMsg.setResultMsg( reviceData.get("resultMsg").toString());
return tMSResultMsg;
}
tMSResultMsg=new TMSResultMsg(1,"No Data");
return tMSResultMsg;
} catch (Exception ex) {
log.error("RequestUpdateReelCount RegisterID=[" + RequestID + "],ReelCode=[" + ReelCode + "],count=[" + Count + "] error :" + ex.toString());
TMSResultMsg tMSResultMsg2 = new TMSResultMsg(1,ex.toString());
return tMSResultMsg2;
}
}
public TMSResultMsg RequestUserCheck(int RequestID, String UserId) {
try {
TMSResultMsg tMSResultMsg = new TMSResultMsg();
String url = TMSCommunicator.apiURL + "webservice/RequestUserCheck";
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("RequestID", RequestID);
dataMap.put("Indate", getInDataStr());
dataMap.put("UserId", UserId);
Map<String, Object> sendData = new HashMap<>();
sendData.put("data", dataMap);
String responseData = PostJson(url, sendData);
if (!ObjectUtil.isNotEmpty(responseData)) {
Map<String, Object> reviceData = JsonUtil.toMap(responseData);
tMSResultMsg.setResult( Integer.parseInt(reviceData.get("result").toString()));
tMSResultMsg.setResultMsg( reviceData.get("resultMsg").toString());
return tMSResultMsg;
}
tMSResultMsg=new TMSResultMsg(1,"No Data");
return tMSResultMsg;
} catch (Exception ex) {
log.error("RequestUserCheck RegisterID=[" + RequestID + "],UserId=[" + UserId + "] error :" + ex.toString());
TMSResultMsg tMSResultMsg2 = new TMSResultMsg(1,ex.toString());
return tMSResultMsg2;
}
}
public TMSPartReelStatus RequestSyncPartReelStatusInfo(int RequestID, TMSPartReelStatus SyncPartReelStatusData)
{
try
{
String url = TMSCommunicator.apiURL + "webservice/RequestSyncPartReelStatusInfo";
Map<String,Object> dataMap = new HashMap<>();
dataMap.put("RequestID", RequestID);
dataMap.put("Indate", getInDataStr());
dataMap.put("SyncPartReelStatusData", SyncPartReelStatusData.getJson());
Map<String, Object> sendData = new HashMap<>();
sendData.put("data", dataMap);
String responseStr = PostJson(url, sendData);
TMSPartReelStatus tMSPartReelStatus = new TMSPartReelStatus();
if (!ObjectUtil.isNotEmpty(responseStr))
{
// tMSPartReelStatus=JsonUtil.toObj(responseStr,TMSPartReelStatus.class);
Map<String,Object> resultMap = JsonUtil.toMap(responseStr);
tMSPartReelStatus.setReserveCode(getMapValue(resultMap, "ResultCode"));
tMSPartReelStatus.setIndex((Integer)getMapValue(resultMap, "index"));
tMSPartReelStatus.setPartName(getMapValue(resultMap, "PartName"));
tMSPartReelStatus.setReelCode(getMapValue(resultMap, "ReelCode"));
tMSPartReelStatus.setRequestCount((Integer)getMapValue(resultMap, "RequestCount"));
tMSPartReelStatus.setResponseCount((Integer)getMapValue(resultMap, "ResponseCount"));
tMSPartReelStatus.setRackID(getMapValue(resultMap, "RackID"));
tMSPartReelStatus.setRowID(getMapValue(resultMap, "RowID"));
tMSPartReelStatus.setColID(getMapValue(resultMap, "ColID"));
tMSPartReelStatus.setResultCode(getMapValue(resultMap, "ResultCode"));
tMSPartReelStatus.setTowerLamp((boolean)getMapValue(resultMap, "TowerLamp"));
return tMSPartReelStatus;
}
return tMSPartReelStatus;
}
catch (Exception ex) {
log.error("RequestSyncPartReelStatusInfo RegisterID=[" + RequestID + "] error :" + ex.toString());
return new TMSPartReelStatus();
}
}
public List<TMSPartReelStatus> RequestSyncPartReelStatusListInfo(int RequestID, List<TMSPartReelStatus> SyncPartReelStatusDatas)
{
List<TMSPartReelStatus> list = new ArrayList<>();
try {
String url = TMSCommunicator.apiURL + "webservice/RequestSyncPartReelStatusListInfo";
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("RequestID", RequestID);
dataMap.put("Indate", getInDataStr());
List<Object> jArray = new ArrayList<>();
for (TMSPartReelStatus SyncPartReelStatusData : SyncPartReelStatusDatas) {
jArray.add(SyncPartReelStatusData.getJson());
}
dataMap.put("SyncPartReelStatusDatas", jArray);
Map<String, Object> sendData = new HashMap<>();
sendData.put("data", dataMap);
String responseStr = PostJson(url, sendData);
if (!ObjectUtil.isNotEmpty(responseStr)) {
List<Object> resList = JsonUtil.toList(responseStr, Object.class);
for (Object obj : resList) {
Map<String, Object> map = JsonUtil.toMap(JsonUtil.toJsonStr(obj));
TMSPartReelStatus item = new TMSPartReelStatus();
item.setReserveCode(getMapValue(map, "ResultCode"));
item.setPartName(getMapValue(map, "PartName"));
item.setReelCode(getMapValue(map, "ReelCode"));
item.setRequestCount(getMapValue(map, "RequestCount"));
item.setResponseCount(getMapValue(map, "ResponseCount"));
item.setRackID(getMapValue(map, "RackID"));
item.setRowID(getMapValue(map, "RowID"));
item.setColID(getMapValue(map, "ColID"));
item.setResultCode(getMapValue(map, "ResultCode"));
item.setTowerLamp(getMapValue(map, "TowerLamp"));
list.add(item);
}
return list;
}
}
catch (Exception ex) {
log.error("RequestSyncPartReelStatusListInfo RegisterID=[" + RequestID + "] error :" + ex.toString());
}
return list;
}
private String PostJson(String url,Map<String,Object> sendData) throws ApiException {
String responseStr = HttpHelper.postJson(url, sendData);
log.info("PostJson, url=["+url+"],send=["+JsonUtil.toJsonStr(sendData)+"],response=["+responseStr+"]");
return responseStr;
}
}
package com.neotel.smfcore.custom.hanwha.handler;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
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.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.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.hanwha.client.MyWebSocketClient;
import com.neotel.smfcore.custom.hanwha.client.WsMsgReceivedListener;
import com.neotel.smfcore.custom.hanwha.handler.bean.*;
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 TMSCommunicator implements WsMsgReceivedListener {
private static MyWebSocketClient websocket;
public static String wsURL;
public static String apiURL;
private static String host = "";
private static int webPort = 8082;
private static int apiPort = 1337 ;
private static String configWebPort = "";
private static String configApiPort = "";
private static String clientType = "NEOTEL";
private static String clientSubType = "Rack01";
@Value("${hanwha.host:}")
public void setHost(String host) {
TMSCommunicator.host = host;
}
@Value("${hanwha.webPort:}")
public void setWebPort(String configPort) {
TMSCommunicator.configWebPort = configPort;
}
@Value("${hanwha.apiPort:}")
public void setApiPort(String configPort) {
TMSCommunicator.configApiPort = configPort;
}
@Autowired
private TMSApis apis;
@Autowired
private DataCache dataCache;
@Autowired
private ILiteOrderManager liteOrderManager;
@Autowired
private LiteOrderCache liteOrderCache;
@Autowired
private TaskService taskService;
@Autowired
private IStoragePosManager storagePosManager;
private static int gRequestID = 1000;
public static int GetRequestID()
{
return gRequestID++;
}
@PostConstruct
public void init() {
host = dataCache.getConfigCache("hanwha.host", host);
String webPortStr = dataCache.getConfigCache("hanwha.webPort", configWebPort);
String apiPortStr = dataCache.getConfigCache("hanwha.apiPort", configApiPort);
if (ObjectUtil.isEmpty(host) || ObjectUtil.isEmpty(webPortStr) || ObjectUtil.isEmpty((apiPortStr))) {
log.info("配置不完整,不需要连接");
} else {
webPort = Integer.parseInt(webPortStr);
apiPort = Integer.parseInt(apiPortStr);
String apiName = dataCache.getConfigCache("api.name", "");
if (apiName != null && apiName.equalsIgnoreCase("hanwha")) {
updateServerInfo(host, webPort, apiPort);
start();
}
}
}
private void updateServerInfo(String serverHost, int wport, int aport) {
host = serverHost;
webPort = wport;
apiPort = aport;
wsURL = String.format("ws://%s:%d/", serverHost, wport);
apiURL = String.format("http://%s:%d/", serverHost, aport);
log.info("设置webSocketServer:[" + wsURL + "],httpServer:[" + apiURL + "]");
}
private void start() {
try {
websocket = new MyWebSocketClient(new URI(wsURL), this);
websocket.setConnectionLostTimeout(3000);
websocket.connect();
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
@Override
public void onMsgReceived(String message) {
parseMessage(message);
}
@Override
public void onOpen() {
Initialize(clientType, clientSubType);
SyncData();
}
public static boolean isEnable() {
if (ObjectUtil.isEmpty(host) || ObjectUtil.isEmpty(webPort) || ObjectUtil.isEmpty(apiPort)) {
return false;
} else {
return true;
}
}
public void close() {
if (websocket != null) {
websocket.close();
}
}
// public void send(String message) {
// if (websocket == null) {
// throw new NullPointerException();
// }
// websocket.send(message);
// }
public void SendData(Map<String, Object> messageMap) {
if (websocket == null) {
throw new NullPointerException();
}
String message = JsonUtil.toJsonStr(messageMap);
websocket.send(message);
log.info("websocket SendData :" + message);
}
private String getIp() {
try {
InetAddress localhost = InetAddress.getLocalHost();
String ip = localhost.getHostAddress();
return ip;
} catch (Exception e) {
log.error("出错:" + e.toString());
}
return "";
}
private String getPid() {
try {
String pidInfo = ManagementFactory.getRuntimeMXBean().getName();
String[] pidSplit = pidInfo.split("@");
String pid = pidSplit[0];
return pid;
} catch (Exception e) {
log.error("出错:" + e.toString());
}
return "";
}
public void Initialize(String ClientType, String ClientSubType) {
// 定义日期时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 格式化日期时间为字符串
String timeStr = LocalDateTime.now().format(formatter);
Map<String, Object> map = new HashMap<>();
map.put("Topic", "INITIALIZE");
map.put("ClientType", ClientType);
map.put("ClientSubType", ClientSubType);
map.put("ClientIP", getIp());
map.put("PID", getPid());
map.put("Date", timeStr);
SendData(map);
}
/**
* 权限验证API列表
*/
@Autowired
private SmfApi smfApi;
@Autowired
private TMSApis tmsApis;
private void SyncData(){
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
// 在这里编写您要执行的方法逻辑
List<String> cids= new ArrayList<>(dataCache.getAllStorage().keySet());
SyncStorageConnectionInfo(cids.toArray(new String[cids.size()]),new Integer[]{});
List<Map<String, StoragePos>> allUsedPoss= dataCache.getAllUsedPosMap();
SyncReelData(allUsedPoss);
}
});
thread.start();
}
public void SyncStorageConnectionInfo(String[] cids,Integer[] statusList) {
if (!TMSCommunicator.isEnable()) {
return;
}
log.info("WebSocket 已连接,开始同步设备状态");
List<String> storageIds = new ArrayList<>();
List<String> storageTypes = new ArrayList<>();
List<Integer> isConns = new ArrayList<>();
int i = 0;
for (String cid : cids) {
Storage storage = dataCache.getStorage(cid);
if (storage == null) {
continue;
}
String type = "Storage";
if (storage.isNLShelf() || storage.isNLPShelf() || storage.isNLMShelf() || storage.isShelf()) {
type = "Rack";
}
int status = -1;
if (statusList != null && statusList.length > i) {
status = statusList[i];
} else {
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
if (bean == null || bean.timeOut()) {
status = -1;
} else {
status = bean.getStatus();
}
}
String conCode = TMS_Code.CODE_1020;
if (status <= 0) {
//初始化失败
conCode = TMS_Code.CODE_0002;
} else if (status == 1) {
conCode = TMS_Code.CODE_1020;
} else if (status <= 4) {
//报警
conCode = TMS_Code.CODE_1024;
} else if (status == 5) {
conCode = TMS_Code.CODE_1023;
} else {
//忙碌
conCode = TMS_Code.CODE_1010;
}
storageIds.add(storage.getCid());
storageTypes.add(type);
isConns.add(Integer.parseInt(conCode));
i++;
}
if (storageIds.size() > 0) {
tmsApis.RequestUpdateStorageConnectionInfo(0, storageIds, storageTypes, isConns);
}
}
public void SyncReelData(List<Map<String, StoragePos>> allUsedPosList) {
if (!TMSCommunicator.isEnable()) {
return;
}
log.info("WebSocket 已连接,开始同步物料信息");
List<TMSPartReelPos> list = new ArrayList<>();
for (Map<String, StoragePos> map : allUsedPosList) {
for (StoragePos pos :
map.values()) {
if (pos.getBarcode() == null) {
continue;
}
Storage storage = dataCache.getStorageById(pos.getStorageId());
if(storage==null){
log.error("posName["+pos.getPosName()+"],storageId["+pos.getStorageId()+"]未找到料仓");
continue;
}
Barcode barcode = pos.getBarcode();
TMSPartReelPos bean = TMSPartReelPos.newBean(barcode.getPartNumber(), barcode.getBarcode(), barcode.getAmount(),
storage.getCid(), pos.getPosName(), 4, barcode.getPutInDate().getTime(), -1);
list.add(bean);
}
}
List<TMSPart> result = tmsApis.RequestSyncPartReelPosInfo(0, list);
}
private void parseMessage(String message) {
if (message == null || message.isEmpty() || message.startsWith("MOU")) {
return;
}
try {
Map<String, Object> msgMap = JsonUtil.toMap(message);
if (msgMap.containsKey("topicName")) {
String machineState = msgMap.get("machineState").toString();
ChanagedMachineState(0, "", "", machineState);
} else if (msgMap.containsKey("Topic")) {
// TMSResultBean rBean = JsonUtil.toObj(message, TMSResultBean.class);
// rBean.id=Integer.parseInt(msgMap.get("id").toString());
String topic = getMapValue(msgMap, "Topic");
int requestID = 0;
if (msgMap.containsKey("id")) {
requestID = (Integer) getMapValue(msgMap, "id");
}
List<String> partItems;
List<Integer> partCounts;
boolean towerLamp;
String registerID;
String reelCode;
int count;
log.info("onMsgReceived: requestID=["+requestID+"],message:["+message+"],Topic=["+topic+"]");
switch (topic) {
case "RequestDeliveryReserve":
partItems = getMapValue(msgMap, "PartNames");
partCounts = getMapValue(msgMap, "Counts");
RequestDeliveryReserve(requestID, partItems, partCounts);
break;
case "RequestDeliveryOrder":
partItems = getMapValue(msgMap, "PartNames");
partCounts = getMapValue(msgMap, "Counts");
towerLamp = (boolean) getMapValue(msgMap, "TowerLamp");
//3.8 RequestDeliveryOrder
RequestDeliveryOrder(requestID, partItems, partCounts, towerLamp);
break;
case "RequestDeliveryOrderByLocation":
List<TMSPos> Locations = getMapValue(msgMap, "Locations");
//3.10 RequestDeliveryOrderByLocation
RequestDeliveryOrderByLocation(requestID, Locations);
break;
case "RequestDeliveryOrderByReelCd":
List<String> reelCds = getMapValue(msgMap, "ReelCds");
//3.12 RequestDeliveryOrderByReelCd
RequestDeliveryOrderByReelCd(requestID, reelCds);
break;
case "RequestResultOfDeliveryReserve":
String reserveCode = getMapValue(msgMap, "ReserveCode");
RequestResultOfDeliveryReserve(requestID, reserveCode);
break;
case "RequestListOfDeliveryReserve":
RequestListOfDeliveryReserve(requestID);
break;
case "RequestUpdateDeliveryReserveState":
List<String> reserveCodes = getMapValue(msgMap, "ReserveCodes");
List<Integer> resultCodes = getMapValue(msgMap, "ResultCodes");
//
//3.14 RequestUpdateDeliveryReserveState
RequestUpdateDeliveryReserveState(requestID, reserveCodes, resultCodes);
break;
case "RequestRegisterPartInfo":
String partName = getMapValue(msgMap, "PartName");
reelCode = getMapValue(msgMap, "ReelCode");
count = getMapValue(msgMap, "Count");
int flag = getMapValue(msgMap, "Flag");
registerID = getMapValue(msgMap, "RegisterID");
//
RequestRegisterPartInfo(requestID, partName, reelCode, count, flag, registerID);
break;
case "RequestGetStateOfTagRegister":
registerID = getMapValue(msgMap, "RegisterID");
RequestGetStateOfTagRegister(requestID, registerID);
break;
case "RequestReStoreIn":
reelCode = getMapValue(msgMap, "ReelCode");
count = getMapValue(msgMap, "Count");
//RequestReStoreIn
RequestReStoreIn(requestID, reelCode, count);
break;
case "UpdatedRegisterPartInfoEvent":
UpdatedRegisterPartInfoEvent();
break;
case "RequestPrintLabelOrderCode":
TMSOrderCodeInfo orderCodeInfo = getMapValue(msgMap, "OrderCodeInfo");
RequestPrintLabelOrderCode(requestID, orderCodeInfo);
break;
case "RequestPrintLabelDockingCart":
TMSDockingCartInfo dockingCartInfo = getMapValue(msgMap, "DockingCartInfo");
RequestPrintLabelDockingCart(requestID, dockingCartInfo);
break;
default:
log.error("onMsgReceived:未找到对应的TOPIC: Topic=["+topic+"],requestID=["+requestID+"],message:["+message+"]");
return;
}
}
} catch (Exception e) {
log.error("处理消息出错:message=[" + message + "],error:" + e.toString());
}
}
private static <T> T getMapValue(Map<String,Object> resultMap, String key ) throws ApiException {
if (key != null && !key.isEmpty()) {
Object value = resultMap.get(key);
if (value != null) {
return (T) value;
}
}
return null;
}
private LiteOrder createOrder(int requestID, List<LiteOrderItem> items,String orderNo,boolean autoOut) {
if (items.size() <= 0) {
return null;
}
LiteOrder liteOrder = new LiteOrder(orderNo, items);
liteOrder.setSource("DeliveryOrder");
LiteOrder dbOrder = liteOrderManager.findByOrderNo(liteOrder.getOrderNo());
if (dbOrder != null) {
orderNo = orderNo + "-" + requestID;
dbOrder = liteOrderManager.findByOrderNo(orderNo);
if (dbOrder == null) {
liteOrder.setOrderNo(orderNo);
} else {
log.info("RequestDelivery :数据库中已存在工单号为[" + orderNo + "],创建工单失败");
return null;
}
}
log.info("RequestDelivery:新建工单:" + liteOrder.getOrderNo() + ",共" + items.size() + "条工单详情,自动执行:"+autoOut);
liteOrder = liteOrderManager.createWithItems(liteOrder);
liteOrderCache.addOrderToMap(liteOrder);
if (autoOut) {
try {
liteOrderCache.checkOutLiteOrder(liteOrder.getOrderNo(), false);
liteOrder = liteOrderCache.getLiteOrder(liteOrder.getOrderNo());
} catch (ValidateException ex) {
log.error("RequestDelivery 自动执行工单[" + liteOrder.getOrderNo() + "] error:" + ex.toString());
}
}
return liteOrder;
}
/**
* 3.8 RequestDeliveryOrder
* @param requestID
* @param partItem
* @param partCount
* @param towerLamp
*/
private void RequestDeliveryOrder(int requestID, List<String> partItem, List<Integer> partCount, boolean towerLamp) {
// 3.9 ResponseDeliveryOrder
try{
if(partItem.size()>0&&partCount.size()>0) {
String soName = "DeliveryOrder-" + DateUtil.toDateString(new Date(), "yyyyMMddHHmmss");
List<LiteOrderItem> liteOrderItems = new ArrayList<>();
int index = 0;
for (String pn : partItem) {
int count = partCount.get(index);
if (ObjectUtil.isNotEmpty(pn) && count > 0) {
LiteOrderItem item = new LiteOrderItem();
item.setPn(pn);
item.setNeedNum(count);
liteOrderItems.add(item);
}
index++;
}
LiteOrder liteOrder = createOrder(requestID, liteOrderItems, soName, true);
liteOrder = liteOrderCache.getLiteOrder(liteOrder.getOrderNo());
if(liteOrder!=null) {
List<DataLog> dataLogs = taskService.getAllTasks();
List<TMSPart> parts = new ArrayList<>();
for (LiteOrderItem item :
liteOrder.getOrderItems()) {
int curroNum = 0;
for (DataLog task :
dataLogs) {
if (task.isCheckOutTask() && task.getSourceName().equals(liteOrder.getOrderNo()) && task.getPartNumber().equals(item.getPn())) {
int requestNum = task.getNum();
curroNum += task.getNum();
if (curroNum > item.getNeedNum()) {
requestNum = task.getNum() - (curroNum - item.getNeedNum());
}
TMSPart p = TMSPart.newBean(task.getPartNumber(), task.getBarcode(), requestNum, task.getNum(), TMS_Code.CODE_1010, task.getCid(), task.getPosName());
parts.add(p);
}
}
if (curroNum <= 0) {
//未出库
TMSPart p = TMSPart.newBean(item.getPn(), "", item.getNeedNum(), item.getOutNum(), TMS_Code.CODE_2019, "", "");
parts.add(p);
}
}
ResponseDeliveryOrder(requestID, parts, liteOrder.getOrderNo());
}
}
}catch (Exception exception){
log.error("RequestDeliveryOrder error:"+exception.toString());
}
ResponseDeliveryOrder(requestID,new ArrayList<>(),"");
}
/**
* 3.10 RequestDeliveryOrderByLocation
* @param requestID
* @param Locations
*/
private void RequestDeliveryOrderByLocation(int requestID, List<TMSPos> Locations) {
// 3.11 ResponseDeliveryOrderByLocation
try {
Map<String, String> posResultMap = new HashMap<>();
if (Locations == null || Locations.size() <= 0) {
ResponseDeliveryOrderByLocation(requestID, new ArrayList<>(), new ArrayList<>(), "");
return;
}
String soName = "DeliveryOrderByLocation-" + DateUtil.toDateString(new Date(), "yyyyMMddHHmmss");
List<LiteOrderItem> liteOrderItems = new ArrayList<>();
for (TMSPos tmsPos : Locations) {
String cid = tmsPos.getRackID();
Storage storage = dataCache.getStorage(cid);
String posName = tmsPos.getPosName();
if (storage == null || ObjectUtil.isEmpty(posName)) {
posResultMap.put("", TMS_Code.CODE_2019);
continue;
}
StoragePos pos = storagePosManager.getByPosName(posName);
if (pos == null) {
posResultMap.put(posName, TMS_Code.CODE_2019);
} else if (pos.getBarcode() == null) {
posResultMap.put(posName, TMS_Code.CODE_2041);
} else {
posResultMap.put(posName, TMS_Code.CODE_1011); //默认是开始送货时失败
LiteOrderItem item = new LiteOrderItem();
item.setRi(pos.getBarcode().getBarcode());
item.setNeedNum(1);
liteOrderItems.add(item);
}
}
LiteOrder liteOrder = createOrder(requestID, liteOrderItems, soName, true);
liteOrder = liteOrderCache.getLiteOrder(liteOrder.getOrderNo());
if (liteOrder != null) {
List<DataLog> dataLogs = taskService.getAllTasks();
List<TMSPart> parts = new ArrayList<>();
for (LiteOrderItem item : liteOrder.getOrderItems()) {
for (DataLog task :
dataLogs) {
if (task.isCheckOutTask() && task.getSourceName().equals(liteOrder.getOrderNo()) && task.getBarcode().equals(item.getRi())) {
posResultMap.put(task.getPosName(), TMS_Code.CODE_1010);//状态改为开始送货
break;
}
}
}
}
//返回消息
List<Integer> rCodes = new ArrayList<>();
for (TMSPos tmsPos : Locations) {
String code = TMS_Code.CODE_1011;
String posName = tmsPos.getPosName();
if (posResultMap.containsKey(posName)) {
code = posResultMap.get(posName);
}
rCodes.add(Integer.parseInt(code));
}
ResponseDeliveryOrderByLocation(requestID, Locations, rCodes, liteOrder.getOrderNo());
} catch (Exception exception) {
log.error("RequestDeliveryOrderByLocation error:" + exception.toString());
}
ResponseDeliveryOrderByLocation(requestID, Locations, new ArrayList<>(), "");
}
/**
* 3.12 RequestDeliveryOrderByReelCd
* @param requestID
* @param ReelCds
*/
private void RequestDeliveryOrderByReelCd(int requestID, List<String> ReelCds) {
// 3.13 ResponseDeliveryOrderByReelCd
try {
Map<String, String> posResultMap = new HashMap<>();
if (ReelCds == null || ReelCds.size() <= 0) {
ResponseDeliveryOrderByReelCd(requestID, new ArrayList<>(), new ArrayList<>(), "");
return;
}
String soName = "DeliveryOrderByReelCd-" + DateUtil.toDateString(new Date(), "yyyyMMddHHmmss");
List<LiteOrderItem> liteOrderItems = new ArrayList<>();
for (String ri : ReelCds) {
StoragePos pos = storagePosManager.getByBarcode(ri);
if (pos == null) {
posResultMap.put(ri, TMS_Code.CODE_2041);
} else {
posResultMap.put(ri, TMS_Code.CODE_1011); //默认是开始送货时失败
LiteOrderItem item = new LiteOrderItem();
item.setRi(pos.getBarcode().getBarcode());
item.setNeedNum(1);
liteOrderItems.add(item);
}
}
LiteOrder liteOrder = createOrder(requestID, liteOrderItems, soName, true);
liteOrder = liteOrderCache.getLiteOrder(liteOrder.getOrderNo());
if (liteOrder != null) {
List<DataLog> dataLogs = taskService.getAllTasks();
List<TMSPart> parts = new ArrayList<>();
for (LiteOrderItem item : liteOrder.getOrderItems()) {
for (DataLog task :
dataLogs) {
if (task.isCheckOutTask() && task.getSourceName().equals(liteOrder.getOrderNo()) && task.getBarcode().equals(item.getRi())) {
posResultMap.put(task.getBarcode(), TMS_Code.CODE_1010);//状态改为开始送货
break;
}
}
}
}
//返回消息
List<Integer> rCodes = new ArrayList<>();
for (String ri : ReelCds) {
String code = TMS_Code.CODE_1011;
if (posResultMap.containsKey(ri)) {
code = posResultMap.get(ri);
}
rCodes.add(Integer.parseInt(code));
}
ResponseDeliveryOrderByReelCd(requestID, ReelCds, rCodes, liteOrder.getOrderNo());
} catch (Exception exception) {
log.error("RequestDeliveryOrderByLocation error:" + exception.toString());
}
ResponseDeliveryOrderByReelCd(requestID, ReelCds, new ArrayList<>(), "");
}
/**
* 3.14 RequestUpdateDeliveryReserveState
* @param requestID
* @param ReserveCodes
* @param ResultCodes
*/
private void RequestUpdateDeliveryReserveState(int requestID, List<String> ReserveCodes, List<Integer> ResultCodes) {
//3.15 ResponseUpdateDeliveryReserveState
}
/**
* 3.19 RequestReStoreIn
* @param requestID
* @param ReelCode
* @param Count
*/
private void RequestReStoreIn(int requestID, String ReelCode, int Count) {
//3.20 ResponseReStoreIn
}
private void ChanagedMachineState(int requestID, String Line, String Machine, String data) {
}
private void RequestDeliveryReserve(int requestID, List<String> PartItem, List<Integer> PartCount) {
}
private void RequestResultOfDeliveryReserve(int requestID, String ReserveCode) {
}
private void RequestListOfDeliveryReserve(int requestID) {
}
private void UpdatedMessage(int NewMessageID) {
}
private void RequestRegisterPartInfo(int requestID, String PartName, String ReelCode, int Count, int Flag, String RegisterID) {
}
private void RequestGetStateOfTagRegister(int requestID, String RegisterID) {
}
private void UpdatedRegisterPartInfoEvent() {
}
// private void RequestGetRackList (int requestID){
// }
//
// private void RequestCalibration (int requestID, TMSCalibrationType CalibrationType, TMSCalibrationCommand CalibrationCommand){
// }
//
// private void RequestChangeFindOption(int requestID, TMSFindCountBaseOption CountBaseOption, TMSFindDateBaseOption DateBaseOption, TMSFindOptionPriority OptionPriority){
// }
//
// private void RequestAbnormalComplete(int requestID, String ReserveCode){
// }
//
// private void RequestReregistration(int requestID, String ReelCode){
// }
private void RequestPrintLabelOrderCode(int requestID, TMSOrderCodeInfo OrderCodeInfo) {
}
private void RequestPrintLabelDockingCart(int requestID, TMSDockingCartInfo DockingCartInfo) {
}
/**
* 3.9 ResponseDeliveryOrder
* @param requestID
* @param Parts
* @param OrderCode
*/
public void ResponseDeliveryOrder(int requestID, List<TMSPart> Parts, String OrderCode) {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponseDeliveryOrder");
dataMap.put("RequestID", requestID);
List<Map<String, Object>> arrayList = new ArrayList<>();
for (TMSPart Part : Parts) {
// Map<String, Object> dataMap2 = new HashMap<>();
// dataMap2.put("index", Part.index);
// dataMap2.put("PartName", Part.PartName);
// dataMap2.put("ReelCode", Part.ReelCode);
// dataMap2.put("RequestCount", Part.RequestCount);
// dataMap2.put("ResponseCount", Part.ResponseCount);
// dataMap2.put("ResultCode", Part.ResultCode);
arrayList.add(Part.getJson());
}
dataMap.put("PartList", arrayList);
dataMap.put("OrderCode", OrderCode);
dataMap.put("ReserveCode", OrderCode);
SendData(dataMap);
}
/**
* 3.11 ResponseDeliveryOrderByLocation
* @param requestID
* @param Locations
* @param ResultCodes
* @param OrderCode
*/
public void ResponseDeliveryOrderByLocation(int requestID, List<TMSPos> Locations, List<Integer> ResultCodes, String OrderCode) {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponseDeliveryOrderByLocation");
dataMap.put("RequestID", requestID);
List<Object> jArray = new ArrayList<>();
for (TMSPos pos : Locations) {
// Map<String, Object> dataMap2 = new HashMap<>();
// dataMap2.put("RackID", Location.RackID);
// dataMap2.put("RowID", Location.RowID);
// dataMap2.put("ColID", Location.ColID);
jArray.add(pos.getJson());
}
dataMap.put("Locations", jArray);
dataMap.put("ResultCodes", ResultCodes);
dataMap.put("OrderCode", OrderCode);
dataMap.put("ReserveCode", OrderCode);
SendData(dataMap);
}
/**
* 3.13 ResponseDeliveryOrderByReelCd
* @param requestID
* @param ReelCds
* @param ResultCodes
* @param OrderCode
*/
public void ResponseDeliveryOrderByReelCd(int requestID, List<String> ReelCds, List<Integer> ResultCodes, String OrderCode) {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponseDeliveryOrderByReelCd");
dataMap.put("RequestID", requestID);
dataMap.put("ReelCds", ReelCds);
dataMap.put("ResultCodes", ResultCodes);
dataMap.put("OrderCode", OrderCode);
dataMap.put("ReserveCode", OrderCode);
SendData(dataMap);
}
/**
* 3.15 ResponseUpdateDeliveryReserveState
* @param requestID
* @param ReserveList
* @param state
*/
public void ResponseUpdateDeliveryReserveState(int requestID, List<TMSReserve> ReserveList, int state) {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponseUpdateDeliveryReserveState");
dataMap.put("RequestID", requestID);
dataMap.put("State", state);
List<Object> jArray = new ArrayList<>();
for (TMSReserve Reserve : ReserveList) {
Map<String, Object> dataMap2 = new HashMap<>();
dataMap2.put("ReserveCode", Reserve.getReserveCode());
dataMap2.put("ResultCode", Reserve.getReserveCode());
dataMap2.put("Date", Reserve.getDate());
List<Object> jArray2 = new ArrayList<>();
for (TMSPart part : Reserve.getPartList()) {
Map<String, Object> dataMap3 = new HashMap<>();
// dataMap3.put("Index", part.index);
// dataMap3.put("PartName", part.PartName);
// dataMap3.put("RequestCount", part.RequestCount);
// dataMap3.put("ResponseCount", part.ResponseCount);
// dataMap3.put("ResultCode", part.ResultCode);
// dataMap3.put("ReelCode", part.ReelCode);
// dataMap3.put("RackID", part.RackID);
// dataMap3.put("RowID", part.RowID);
// dataMap3.put("ColID", part.ColID);
jArray2.add(part.getAJson());
}
dataMap2.put("PartList", jArray2);
jArray.add(dataMap2);
}
dataMap.put("ReserveList", jArray);
SendData(dataMap);
}
public void ResponseDeliveryReserve(int requestID, int ResultCode, String ReserveCode) {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponseDeliveryReserve");
dataMap.put("RequestID", requestID);
dataMap.put("ResultCode", ResultCode);
dataMap.put("ReserveCode", ReserveCode);
SendData(dataMap);
}
public void ResponseListOfDeliveryReserve(int requestID, List<String> Reserves, List<Integer> ResultCode) {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponseListOfDeliveryReserve");
dataMap.put("RequestID", requestID);
dataMap.put("ReserveCodes", Reserves);
dataMap.put("ResultCodes", ResultCode);
SendData(dataMap);
}
public void ResponseResultOfDeliveryReserve(int requestID, List<String> PartNames, List<Integer> PartCounts, List<Integer> ResultCodes) {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponseResultOfDeliveryReserve");
dataMap.put("RequestID", requestID);
dataMap.put("PartNames", PartNames);
dataMap.put("PartCounts", PartCounts);
dataMap.put("ResultCodes", ResultCodes);
SendData(dataMap);
}
public void ResponseReStoreIn(int requestID, String ReelCode, int Count, int ResultCode) {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponseReStoreIn");
dataMap.put("RequestID", requestID);
dataMap.put("ReelCode", ReelCode);
dataMap.put("Count", Count);
dataMap.put("ResultCode", ResultCode);
SendData(dataMap);
}
public void ResponseGetStateOfTagRegister(int requestID, int result, String RegisterID) {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponseGetStateOfTagRegister");
dataMap.put("RequestID", requestID);
dataMap.put("Result", result);
dataMap.put("RegisterID", RegisterID);
SendData(dataMap);
}
public void ResponseRegisterPartInfo(int requestID, int result, String RegisterID) {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponseRegisterPartInfo");
dataMap.put("RequestID", requestID);
dataMap.put("Result", result);
dataMap.put("RegisterID", RegisterID);
SendData(dataMap);
}
public void ResponseGetRackList(String RequestID) {
}
public void ResponseReregistrationResult(String RequestID, String ReelCode, int Result) {
}
public void ResponsePrintLabelOrderCode(int requestID, int Result, String ResultMsg) {
try {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponsePrintLabelOrderCode");
dataMap.put("RequestID", requestID);
dataMap.put("result", Result);
dataMap.put("resultMsg", ResultMsg);
SendData(dataMap);
} catch (Exception ex) {
TMSResultMsg tMSResultMsg = new TMSResultMsg(1,ex.toString());
log.error("ResponsePrintLabelOrderCode error :"+ex.toString());
}
}
public void ResponsePrintLabelDockingCart(int requestID, int Result, String ResultMsg) {
try {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Topic", "ResponsePrintLabelDockingCart");
dataMap.put("RequestID", requestID);
dataMap.put("result", Result);
dataMap.put("resultMsg", ResultMsg);
SendData(dataMap);
} catch (Exception ex) {
TMSResultMsg tMSResultMsg = new TMSResultMsg(1,ex.toString());
log.error("ResponsePrintLabelOrderCode error :"+ex.toString());
}
}
}
package com.neotel.smfcore.custom.hanwha.handler;
public class TMS_Code {
/**
* 0000 OK
*/
public static final String CODE_0000 = "0000";
// Code 内容
/**
* 0001 Failed (exception etc) 失败(异常等)
*/
public static final String CODE_0001 = "0001";
/**
* 0002 Delivery initialization failed. (Rack stand-by fail) 传输初始化失败。(机架待机失败)
*/
public static final String CODE_0002 = "0002";
/**
* 0003 Failed by alarm
*/
public static final String CODE_0003 = "0003";
/**
* 0004 Already processing for the same request.
*/
public static final String CODE_0004 = "0004";
/**
* 0100 Waiting for the DeliveryOrder request. (DeliveryReservation has requested and ready to deliver)
*/
public static final String CODE_0100 = "0100";
/**
* 0101 DeliveryReservation cancelled
*/
public static final String CODE_0101 = "0101";
/**
* 1010 Delivery started 开始送货
*/
public static final String CODE_1010 = "1010";
/**
* 1011 Error while starting the delivery. (Delivery got cancelled and state goes to normal operation mode) 开始配送时出错。(送货被取消,状态转为正常运行模式)
*/
public static final String CODE_1011 = "1011";
/**
* 1012 Delivery finished.
*/
public static final String CODE_1012 = "1012";
/**
* 1020 Idle state. (normal operation mode and can get the requests) (正常运行模式,可以接收请求)
*/
public static final String CODE_1020 = "1020";
/**
* 1021 Delivering
*/
public static final String CODE_1021 = "1021";
/**
* 1022 In the process of position request
*/
public static final String CODE_1022 = "1022";
/**
* 1023 Boot-up state 启动状态
*/
public static final String CODE_1023 = "1023";
/**
* 1024 Rack raised Alarm 机架报警
*/
public static final String CODE_1024 = "1024";
/**
* 2001 Part not enough
*/
public static final String CODE_2001 = "2001";
/**
* 2002 Out of part
*/
public static final String CODE_2002 = "2002";
/**
* 2003 Registered part but not on the rack
*/
public static final String CODE_2003 = "2003";
/**
* 2010 Waiting for the delivery(reserved)
*/
public static final String CODE_2010 = "2010";
/**
* 2011 Delivering
*/
public static final String CODE_2011 = "2011";
/**
* 2012 Delivery cancelled
*/
public static final String CODE_2012 = "2012";
/**
* 2013 Delivery finished
*/
public static final String CODE_2013 = "2013";
/**
* 2014 Cannot cancel the delivery (already start delivery)
*/
public static final String CODE_2014 = "2014";
/**
* 2015 Removed from the Rack
*/
public static final String CODE_2015 = "2015";
/**
* 2016 Delivery finished in abnormal state
*/
public static final String CODE_2016 = "2016";
/**
* 2017 Delivery deleted
*/
public static final String CODE_2017 = "2017";
/**
* 2018 Can NOT deliver because it is not reserved
*/
public static final String CODE_2018 = "2018";
/**
* 2019 Failure while Delivering 在交付时失败
*/
public static final String CODE_2019 = "2019";
/**
* 2020 Already cancelled
*/
public static final String CODE_2020 = "2020";
/**
* 2021 Delivery started in abnormal state because of Rack issue 因机架问题在异常状态下开始交付
*/
public static final String CODE_2021 = "2021";
/**
* 2022 Rack have problem while Delivering送货时机架出现问题
*/
public static final String CODE_2022 = "2022";
/**
* 2040 Failed to start the delivery (General Rack issue)无法开始交付(一般机架问题)
*/
public static final String CODE_2040 = "2040";
/**
* 2041 Failed to start the delivery (Sync issue) 无法开始交付(同步问题)
*/
public static final String CODE_2041 = "2041";
/**
* 2042 Failed to start the delivery (H/W check issue) 无法开始交付(硬件/软件检查问题)
*/
public static final String CODE_2042 = "2042";
/**
* 2043 Failed to Start/Stop delivery. (because of other job)
*/
public static final String CODE_2043 = "2043";
/**
* 2044 Failed to Start/Stop delivery. (because of system error, exception)
*/
public static final String CODE_2044 = "2044";
/**
* 2045 Rack is initializing
*/
public static final String CODE_2045 = "2045";
/**
* 2050 The reels are already on the rack. (When restocked)
*/
public static final String CODE_2050 = "2050";
// Code 내용
//0000 OK
//0001 Failed (exception etc)
//0002 Delivery initialization failed. (Rack stand-by fail)
// 0003 Failed by alarm
//0004 Already processing for the same request.
//0100 Waiting for the DeliveryOrder request. (DeliveryReservation has requested and ready to deliver)
// 0101 DeliveryReservation cancelled
//1010 Delivery started
//1011 Error while starting the delivery. (Delivery got cancelled and state goes to normal operation mode)
// 1012 Delivery finished.
// 1020 Idle state. (normal operation mode and can get the requests)
// 1021 Delivering
//1022 In the process of position request
// 1023 Boot-up state
//1024 Rack raised Alarm
//2001 Part not enough
//2002 Out of part
//2003 Registered part but not on the rack
//2010 Waiting for the delivery(reserved)
//2011 Delivering
//2012 Delivery cancelled
//2013 Delivery finished
//2014 Cannot cancel the delivery (already start delivery)
//2015 Removed from the Rack
//2016 Delivery finished in abnormal state
//2017 Delivery deleted
//2018 Can NOT deliver because it is not reserved
//2019 Failure while Delivering
//2020 Already cancelled
//2021 Delivery started in abnormal state because of Rack issue
//2022 Rack have problem while Delivering
//2040 Failed to start the delivery (General Rack issue)
//2041 Failed to start the delivery (Sync issue)
//2042 Failed to start the delivery (H/W check issue)
//2043 Failed to Start/Stop delivery. (because of other job)
// 2044 Failed to Start/Stop delivery. (because of system error, exception)
// 2045 Rack is initializing
//2050 The reels are already on the rack. (When restocked
//
// 代码 내용
//0000 确定
//0001 失败(异常等)
// 0002 输送初始化失败。(机架备用失败)
// 0003 因警报而失败
//0004 已在处理同一请求。
// 0100 等待交货订单请求。(已请求并
// 准备交付)
// 0101 已取消交货预约
//1010 开始送货
//1011 开始配送时出错。(送货被取消,状态转为正常运行模式)。
// 运行模式)。
// 1012 送货结束。
// 1020 闲置状态。
// (正常运行模式,可接收请求)
// 1021 发送
//1022 定位请求中
//17
// 1023 启动状态
//1024 机架报警
//2001 部件不足
//2002 无部件
//2003 已登记部件但不在机架上
//2010 等待交货(保留)
// 2011 发货
//2012 取消交货
//2013 发货完成
//2014 无法取消交货(已开始交货)
// 2015 从货架移除
//2016 在异常状态下完成交付
//2017 已删除交付
//2018 因未预订而无法交付
//2019 在交付时失败
//2020 已取消
//2021 因机架问题在异常状态下开始交付
//2022 送货时机架出现问题
//2040 无法开始交付(一般机架问题)
// 2041 无法开始交付(同步问题)
// 2042 无法开始交付(硬件/软件检查问题)
// 2043 启动/停止递送失败。(因为其他任务)
//
// 通过www.DeepL.com/Translator(免费版)翻译
}
package com.neotel.smfcore.custom.hanwha.handler.bean;
import lombok.Data;
import java.io.Serializable;
@Data
public class TMSDockingCartInfo implements Serializable {
private String cartCd = "";
private String cartNm = "";
private int cartSlotCount = 0;
}
package com.neotel.smfcore.custom.hanwha.handler.bean;
import lombok.Data;
import java.io.Serializable;
@Data
public class TMSOrderCodeInfo implements Serializable {
private int planID = 0;
private String modelNm ="";
private String date ="" ;
private int quantity = 0;
private String lineCd ;
private String userNm ="";
private String userID ="";
}
package com.neotel.smfcore.custom.hanwha.handler.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TMSPart extends TMSPos implements Serializable {
private int index = 0;
private String partName = "";
private String reelCode = "";
private int requestCount = 0;
private int responseCount = 0;
private String resultCode = "";
public static TMSPart newBean(String pn,String barcode,int requestCount,int responseCount,String resultCode,String cid,String posName ) {
TMSPart bean = new TMSPart();
bean.setPartName(pn);
bean.setReelCode(barcode);
bean.setRequestCount(requestCount);
bean.setResponseCount(responseCount);
bean.setRackID(cid);
bean.setPosName(posName);
bean.setResultCode(resultCode);
return bean;
}
@Override
public Map<String,Object> getJson(){
Map<String, Object> dataMap2 = new HashMap<>();
dataMap2.put("Index", index);
dataMap2.put("PartName", getPartName());
dataMap2.put("ReelCode", getReelCode());
dataMap2.put("RequestCount", getRequestCount());
dataMap2.put("ResponseCount", getResponseCount());
dataMap2.put("ResultCode", getResultCode());
return dataMap2;
}
public Map<String,Object> getAJson() {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("Index", index);
dataMap.put("PartName", getPartName());
dataMap.put("RequestCount", getRequestCount());
dataMap.put("ResponseCount", getResponseCount());
dataMap.put("ResultCode", getResultCode());
dataMap.put("ReelCode", getReelCode());
dataMap.put("RackID", getRackID());
dataMap.put("RowID", getRowID());
dataMap.put("ColID", getColID());
return dataMap;
}
}
package com.neotel.smfcore.custom.hanwha.handler.bean;
import com.neotel.smfcore.common.utils.DateUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Data
@Slf4j
public class TMSPartReelPos extends TMSPos implements Serializable {
private String partName;
private String reelCode;
private int count;
/**
* 1: Part inserted to the rack
* 2: Part removed from the rack
* 4: When the Rack initializes
*/
private int flag = 0;
private int state = 0;
//yyyy-MM-dd HH:mm:ss
private String indate;
private String outdate;
public TMSPartReelPos()
{
setCount(-1);
setRackID("");
setRowID("");
setColID("");
setIndate("");
setOutdate("");
}
@Override
public Map<String,Object> getJson() {
Map<String, Object> map = new HashMap<>();
map.put("PartName", getPartName());
map.put("ReelCode", getReelCode());
map.put("RackID", getRackID());
map.put("Count", getCount());
map.put("RowID", getRowID());
map.put("ColID", getColID());
map.put("Flag", getFlag());
map.put("Indate", getIndate());
map.put("Outdate", getOutdate());
return map;
}
public static TMSPartReelPos newBean(String pn,String barcode,int count,String cid,String posName,int flag,long inTime,long outTime) {
TMSPartReelPos bean = new TMSPartReelPos();
bean.setPartName(pn);
bean.setReelCode(barcode);
bean.setCount(count);
bean.setRackID(cid);
bean.setFlag(flag);
bean.setState(0);
bean.setPosName(posName);
String format="yyyy-MM-dd HH:mm:ss";
if (inTime > 0) {
String inStr = DateUtil.toDateString(new Date(inTime),format);
bean.setIndate(inStr);
}
if (outTime > 0) {
String outStr = DateUtil.toDateString(new Date(outTime),format);
bean.setOutdate(outStr);
}
return bean;
}
}
package com.neotel.smfcore.custom.hanwha.handler.bean;
import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@Data
public class TMSPartReelStatus extends TMSPart implements Serializable {
private String ReserveCode = "";
private boolean TowerLamp = false;
@Override
public Map<String,Object> getJson() {
Map<String, Object> map = new HashMap<>();
map.put("ReserveCode", getReserveCode());
map.put("index", getIndex());
map.put("PartName", getPartName());
map.put("ReelCode", getReelCode());
map.put("RequestCount", getRequestCount());
map.put("ResponseCount", getResponseCount());
map.put("RackID", getRackID());
map.put("RowID", getRowID());
map.put("ColID", getColID());
map.put("ResultCode", getResultCode());
map.put("TowerLamp", isTowerLamp());
return map;
}
}
package com.neotel.smfcore.custom.hanwha.handler.bean;
import cn.hutool.core.util.ObjectUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@Data
@Slf4j
public class TMSPos implements Serializable {
private String RackID;
private String RowID;
private String ColID;
public Map<String,Object> getJson()
{
Map<String,Object> jObject = new HashMap<>();
jObject.put("RackID", RackID);
jObject.put("RowID", RowID);
jObject.put("ColID", ColID);
return jObject;
}
public String getPosName(){
return getRowID()+"_"+getColID();
}
public void setPosName(String posName){
if(ObjectUtil.isEmpty(posName)){
setColID("");
setRowID("");
return;
}
//posName=rowId_colId
int index=posName.indexOf('_');
if(index>0){
setRowID(posName.substring(0,index-1));
setColID(posName.substring(index+1,posName.length()-1));
}
// String[] posArray = posName.split("_");
// if (posArray.length >= 2) {
// try {
// setColID(posArray[posArray.length - 1]);
// setRowID(posArray[posArray.length - 2]);
// } catch (Exception ex) {
// log.error("解析位置的行列失败 " + posName + "," + ex.toString());
// }
// }
}
}
package com.neotel.smfcore.custom.hanwha.handler.bean;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
public class TMSReserve implements Serializable {
private String ReserveCode = "";
private String Date = "";
private String ResultCode = "";
private List<TMSPart> PartList;
public TMSReserve()
{
PartList = new ArrayList<>();
}
}
package com.neotel.smfcore.custom.hanwha.handler.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TMSResultMsg implements Serializable {
private int result = 1;
private String resultMsg = "";
}
......@@ -384,4 +384,5 @@ smfcore.neoai=Neo Ai
smfcore.duo.offline=\u8BBE\u5907{0}\u79BB\u7EBF
smfcore.msg.op.fail=\u64CD\u4F5C\u5931\u8D25
smfcore.equip.notExist=\u8BBE\u5907\u4E0D\u5B58\u5728
smfcore.order.finished=\u5DE5\u5355[{0}]\u7684\u4EFB\u52A1\u5DF2\u5168\u90E8\u5B8C\u6210
\ No newline at end of file
smfcore.order.finished=\u5DE5\u5355[{0}]\u7684\u4EFB\u52A1\u5DF2\u5168\u90E8\u5B8C\u6210
smfcore.spkanban=SP\u4EEA\u8868\u76D8
\ No newline at end of file
......@@ -375,4 +375,5 @@ smfcore.neoai=Neo Ai
smfcore.duo.offline=Equipment {0} offline
smfcore.msg.op.fail=failure of an operation
smfcore.equip.notExist=Device does not exist
smfcore.order.finished=workorder[{0}] has completed all of its tasks
\ No newline at end of file
smfcore.order.finished=workorder[{0}] has completed all of its tasks
smfcore.spkanban=SP Dash Board
\ No newline at end of file
......@@ -371,4 +371,5 @@ smfcore.neoai=Neo Ai
smfcore.duo.offline=\u8BBE\u5907{0}\u79BB\u7EBF
smfcore.msg.op.fail=\u64CD\u4F5C\u5931\u8D25
smfcore.equip.notExist=\u8BBE\u5907\u4E0D\u5B58\u5728
smfcore.order.finished=\u30EF\u30FC\u30AF\u30AA\u30FC\u30C0\u30FC[{0}]\u306E\u30BF\u30B9\u30AF\u306F\u3059\u3079\u3066\u5B8C\u4E86\u3057\u307E\u3057\u305F
\ No newline at end of file
smfcore.order.finished=\u30EF\u30FC\u30AF\u30AA\u30FC\u30C0\u30FC[{0}]\u306E\u30BF\u30B9\u30AF\u306F\u3059\u3079\u3066\u5B8C\u4E86\u3057\u307E\u3057\u305F
smfcore.spkanban=\u30C0\u30C3\u30B7\u30E5\u30DC\u30FC\u30C9
\ No newline at end of file
......@@ -371,4 +371,5 @@ smfcore.neoai=Neo Ai
smfcore.duo.offline=\u8BBE\u5907{0}\u79BB\u7EBF
smfcore.msg.op.fail=\u64CD\u4F5C\u5931\u8D25
smfcore.equip.notExist=\u8BBE\u5907\u4E0D\u5B58\u5728
smfcore.order.finished=\u5DE5\u5355[{0}]\u7684\u4EFB\u52A1\u5DF2\u5168\u90E8\u5B8C\u6210
\ No newline at end of file
smfcore.order.finished=\u5DE5\u5355[{0}]\u7684\u4EFB\u52A1\u5DF2\u5168\u90E8\u5B8C\u6210
smfcore.spkanban=SP\u4EEA\u8868\u76D8
\ No newline at end of file
......@@ -371,4 +371,5 @@ smfcore.neoai=Neo Ai
smfcore.duo.offline=\u8A2D\u5099{0}\u96E2\u7DDA
smfcore.msg.op.fail=\u64CD\u4F5C\u5931\u6557
smfcore.equip.notExist=\u8A2D\u5099\u4E0D\u5B58\u5728
smfcore.order.finished=\u5DE5\u55AE[{0}]\u7684\u4EFB\u52D9\u5DF2\u5168\u90E8\u5B8C\u6210
\ No newline at end of file
smfcore.order.finished=\u5DE5\u55AE[{0}]\u7684\u4EFB\u52D9\u5DF2\u5168\u90E8\u5B8C\u6210
smfcore.spkanban=SP\u5100\u9336\u76E4
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!