Commit 6411bc91 LN

1.panacim 增加接口日志。

2.NEOSCAN 类型改为 NS100
  COUNTING 改为 NEOCOUNTER
  HANWHA 改为 T_SOLUTION
1 个父辈 bc951296
...@@ -54,11 +54,11 @@ public class ApiInteractionController { ...@@ -54,11 +54,11 @@ public class ApiInteractionController {
public List<List<String>> getHeader() { public List<List<String>> getHeader() {
List<List<String>> header = new ArrayList<>(); List<List<String>> header = new ArrayList<>();
Locale locale = request.getLocale(); Locale locale = request.getLocale();
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.url", locale, "IP地址"))); header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.updateTime", locale, "时间")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.url", locale, "地址")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.request", locale, "参数"))); header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.request", locale, "参数")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.response", locale, "结果"))); header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.response", locale, "结果")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.state", locale, "状态"))); header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.state", locale, "状态")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.updateTime", locale, "创建时间")));
return header; return header;
} }
...@@ -69,11 +69,11 @@ public class ApiInteractionController { ...@@ -69,11 +69,11 @@ public class ApiInteractionController {
for (ApiInteraction obj : apiInfoList.getContent()) { for (ApiInteraction obj : apiInfoList.getContent()) {
List<Object> data = new ArrayList<>(); List<Object> data = new ArrayList<>();
data.add(DateUtil.toDateString(obj.getRequestDate()));
data.add(obj.getUrl()); data.add(obj.getUrl());
data.add(obj.getRequestDate()); data.add(obj.getParam());
data.add(obj.getResult()); data.add(obj.getResult());
data.add(obj.getStatus()); data.add(obj.getStatus());
data.add(DateUtil.toDateString(obj.getCreateDate()));
dataList.add(data); dataList.add(data);
} }
return dataList; return dataList;
......
package com.neotel.smfcore.core.equipment.enums; package com.neotel.smfcore.core.equipment.enums;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import java.util.List; import java.util.List;
...@@ -16,31 +15,35 @@ public enum EquipmentType { ...@@ -16,31 +15,35 @@ public enum EquipmentType {
AUTO(), AUTO(),
/** /**
* 1 扫码贴标 * 扫码贴标
*/ */
@Deprecated
NEOSCAN(), NEOSCAN(),
NS100(),
/** /**
* NS200 * NS200
*/ */
NS200(), NS200(),
/** /**
* 2 点料机 * 点料机
*/ */
COUNTING(), // COUNTING(),
NEOCOUNTER(),
/** /**
* 3 插件机 * 插件机
*/ */
NEOSTATION(), NEOSTATION(),
/** // /**
* 4 FUJINEOLINK // * 4 FUJINEOLINK
*/ // */
FUJINEOLINK(), // FUJINEOLINK(),
/** /**
* 5 PANACIMNEOLINK * 5 PANACIMNEOLINK
...@@ -55,7 +58,7 @@ public enum EquipmentType { ...@@ -55,7 +58,7 @@ public enum EquipmentType {
/** /**
* 韩华 * 韩华
*/ */
HANWHA(), T_SOLUTION(),
/** /**
* NEXIM * NEXIM
...@@ -64,12 +67,12 @@ public enum EquipmentType { ...@@ -64,12 +67,12 @@ public enum EquipmentType {
public static List<EquipmentType> availableTypeList(){ public static List<EquipmentType> availableTypeList(){
return Lists.newArrayList(AUTO,NEOSCAN,NS200,COUNTING,PANACIMNEOLINK,AGV,HANWHA,NEXIM); return Lists.newArrayList(AUTO,NS100,NS200,NEOCOUNTER,PANACIMNEOLINK,AGV,T_SOLUTION,NEXIM);
} }
public static List<String> apiTypeList(){ public static List<String> apiTypeList(){
return Lists.newArrayList(HANWHA.name(),PANACIMNEOLINK.name(),NEXIM.name()); return Lists.newArrayList(T_SOLUTION.name(),PANACIMNEOLINK.name(),NEXIM.name());
} }
} }
...@@ -64,7 +64,7 @@ public class EquipConfigController { ...@@ -64,7 +64,7 @@ public class EquipConfigController {
//判断测试哪个接口 //判断测试哪个接口
boolean result = false; boolean result = false;
if (configInfoDto.equipType.equals(EquipmentType.HANWHA.name())) { if (configInfoDto.equipType.equals(EquipmentType.T_SOLUTION.name())) {
EquipConfigInfo config = equipConfigInfoMapper.toEntity(configInfoDto); EquipConfigInfo config = equipConfigInfoMapper.toEntity(configInfoDto);
if (configInfoDto.apiTestKey.equals("webPort") ) { if (configInfoDto.apiTestKey.equals("webPort") ) {
......
...@@ -74,15 +74,18 @@ public class EquipViewController { ...@@ -74,15 +74,18 @@ public class EquipViewController {
} }
} }
if(equip.getType().equalsIgnoreCase(EquipmentType.HANWHA.name())){ if(equip.getType().equalsIgnoreCase(EquipmentType.T_SOLUTION.name())){
if(tmsCommunicator.isConnected()){ if(tmsCommunicator.isConnected()){
dto.setOnLine(true); dto.setOnLine(true);
dto.setStatus(1); dto.setStatus(1);
} }
} else if (equip.getType().equalsIgnoreCase(EquipmentType.NEXIM.name())){ } else if (equip.getType().equalsIgnoreCase(EquipmentType.NEXIM.name())){
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name); if(dto.isActivate()) {
if (config != null){ //配置了且激活就显示在线
dto.setActivate(true); FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config != null) {
// dto.setStatus(1);
}
} }
} }
......
...@@ -33,7 +33,7 @@ public class Equipment extends BasePo implements Serializable { ...@@ -33,7 +33,7 @@ public class Equipment extends BasePo implements Serializable {
private boolean activate=true; private boolean activate=true;
public boolean isNEOSCAN() { public boolean isNEOSCAN() {
return EquipmentType.NEOSCAN.name().equals(type)||EquipmentType.NS200.name().equals(type); return EquipmentType.NEOSCAN.name().equals(type)||EquipmentType.NS200.name().equals(type)||EquipmentType.NS100.name().equals(type);
} }
......
...@@ -43,13 +43,16 @@ public class EquipConfigUtil { ...@@ -43,13 +43,16 @@ public class EquipConfigUtil {
configInfo = new EquipConfigInfo(); configInfo = new EquipConfigInfo();
configInfo.setEquipType(equipType); configInfo.setEquipType(equipType);
configInfo.setEnableApi(false); configInfo.setEnableApi(false);
if(equipType.equals(EquipmentType.HANWHA.name())){ if(equipType.equals(EquipmentType.T_SOLUTION.name())){
LinkedHashMap<String,Object> defMap=new LinkedHashMap<>(); LinkedHashMap<String,Object> defMap=new LinkedHashMap<>();
defMap.put("host",""); defMap.put("host","");
defMap.put("webPort",1337); defMap.put("webPort",1337);
defMap.put("apiPort",8082); defMap.put("apiPort",8082);
defMap.put("singleOrder",true); defMap.put("singleOrder",true);
configInfo.setApiConfigMap(defMap); configInfo.setApiConfigMap(defMap);
}else if(equipType.equals(EquipmentType.PANACIMNEOLINK.name())){
//默认启用
configInfo.setEnableApi(true);
} }
} }
if(equipType.equals(EquipmentType.PANACIMNEOLINK.name())) { if(equipType.equals(EquipmentType.PANACIMNEOLINK.name())) {
......
...@@ -494,11 +494,11 @@ public class TMSApis { ...@@ -494,11 +494,11 @@ public class TMSApis {
String responseStr = HttpHelper.postJsonWithAuth(url, sendData, null, 3000, 10000); String responseStr = HttpHelper.postJsonWithAuth(url, sendData, null, 3000, 10000);
log.info("PostJson, url=[" + url + "],send=[" + requestParam + "],response=[" + responseStr + "]"); log.info("PostJson, url=[" + url + "],send=[" + requestParam + "],response=[" + responseStr + "]");
apiInteractionManager.save(new ApiInteraction(new Date(), url, requestParam, responseStr, ApiInteraction_Status.OK, EquipmentType.HANWHA.name())); apiInteractionManager.save(new ApiInteraction(new Date(), url, requestParam, responseStr, ApiInteraction_Status.OK, EquipmentType.T_SOLUTION.name()));
return responseStr; return responseStr;
} catch (ApiException ex) { } catch (ApiException ex) {
log.error(ex.toString()); log.error(ex.toString());
apiInteractionManager.save(new ApiInteraction(new Date(), url, requestParam, ex.toString(), ApiInteraction_Status.ERROE, EquipmentType.HANWHA.name())); apiInteractionManager.save(new ApiInteraction(new Date(), url, requestParam, ex.toString(), ApiInteraction_Status.ERROE, EquipmentType.T_SOLUTION.name()));
throw ex; throw ex;
} }
......
...@@ -104,7 +104,7 @@ public class TMSCommunicator implements WsMsgReceivedListener { ...@@ -104,7 +104,7 @@ public class TMSCommunicator implements WsMsgReceivedListener {
private boolean needCheck=false; private boolean needCheck=false;
@PostConstruct @PostConstruct
public void init() { public void init() {
EquipConfigInfo equipConfigInfo = equipConfigUtil.getConfigCache(EquipmentType.HANWHA.name()); EquipConfigInfo equipConfigInfo = equipConfigUtil.getConfigCache(EquipmentType.T_SOLUTION.name());
// host = dataCache.getConfigCache("hanwha.host", host); // host = dataCache.getConfigCache("hanwha.host", host);
// String webPortStr = dataCache.getConfigCache("hanwha.webPort", configWebPort); // String webPortStr = dataCache.getConfigCache("hanwha.webPort", configWebPort);
// String apiPortStr = dataCache.getConfigCache("hanwha.apiPort", configApiPort); // String apiPortStr = dataCache.getConfigCache("hanwha.apiPort", configApiPort);
...@@ -177,7 +177,7 @@ public class TMSCommunicator implements WsMsgReceivedListener { ...@@ -177,7 +177,7 @@ public class TMSCommunicator implements WsMsgReceivedListener {
TimeUnit.SECONDS.sleep(6); TimeUnit.SECONDS.sleep(6);
} }
EquipConfigInfo equipConfigInfo = equipConfigUtil.getConfigCache(EquipmentType.HANWHA.name()); EquipConfigInfo equipConfigInfo = equipConfigUtil.getConfigCache(EquipmentType.T_SOLUTION.name());
ResetConfig(equipConfigInfo); ResetConfig(equipConfigInfo);
} catch (Exception e) { } catch (Exception e) {
log.error("webService" + e.getMessage()); log.error("webService" + e.getMessage());
......
...@@ -308,7 +308,7 @@ public class TMSUtil { ...@@ -308,7 +308,7 @@ public class TMSUtil {
public boolean HasExeOrder(){ public boolean HasExeOrder(){
EquipConfigInfo config=equipConfigUtil.getConfigCache(EquipmentType.HANWHA.name()); EquipConfigInfo config=equipConfigUtil.getConfigCache(EquipmentType.T_SOLUTION.name());
Boolean singleOrderMode= true; Boolean singleOrderMode= true;
if(config!=null){ if(config!=null){
......
...@@ -5,13 +5,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -5,13 +5,17 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants; import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.HttpHelper; import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.common.utils.StorageConstants; import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.api.bean.CodeValidateParam; import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener; import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.apiInteraction.enums.ApiInteraction_Status;
import com.neotel.smfcore.core.apiInteraction.service.manager.IApiInteractionManager; import com.neotel.smfcore.core.apiInteraction.service.manager.IApiInteractionManager;
import com.neotel.smfcore.core.apiInteraction.service.po.ApiInteraction;
import com.neotel.smfcore.core.barcode.bean.CodeBean; import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE; import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
...@@ -19,6 +23,9 @@ import com.neotel.smfcore.core.barcode.utils.CodeResolve; ...@@ -19,6 +23,9 @@ import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP; import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.equipment.enums.EquipmentType;
import com.neotel.smfcore.core.equipment.util.EquipConfigUtil;
import com.neotel.smfcore.core.equipment.util.bean.EquipConfigInfo;
import com.neotel.smfcore.core.order.LiteOrderCache; import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.enums.ORDER_COLOR; import com.neotel.smfcore.core.order.enums.ORDER_COLOR;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
...@@ -66,8 +73,15 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -66,8 +73,15 @@ public class PanaApiController extends BaseSmfApiListener {
@Autowired @Autowired
protected CodeResolve codeResolve; protected CodeResolve codeResolve;
private static IApiInteractionManager apiInteractionManager;
@Autowired
public void setApiInteractionManager(IApiInteractionManager interactionManager){
PanaApiController.apiInteractionManager=interactionManager;
}
@Autowired @Autowired
private IApiInteractionManager apiInteractionManager; private EquipConfigUtil equipConfigUtil;
@Autowired @Autowired
public void setDataCache(DataCache dataCache) { public void setDataCache(DataCache dataCache) {
...@@ -441,7 +455,7 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -441,7 +455,7 @@ public class PanaApiController extends BaseSmfApiListener {
reqParams.put("TransactionID", nextSeq("PANA")); reqParams.put("TransactionID", nextSeq("PANA"));
reqParams.put("ErrorCode","0"); reqParams.put("ErrorCode","0");
reqParams.put("Reelbarcode",barcode.getBarcode()); reqParams.put("Reelbarcode",barcode.getBarcode());
String result = HttpHelper.postJson(requestReelUrl,reqParams); String result = PostJson(requestReelUrl,reqParams);
log.info("PanaCIM 返回料盘【"+barcode.getBarcode()+"】的信息:"+result); log.info("PanaCIM 返回料盘【"+barcode.getBarcode()+"】的信息:"+result);
if(!Strings.isNullOrEmpty(result)){ if(!Strings.isNullOrEmpty(result)){
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
...@@ -526,7 +540,7 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -526,7 +540,7 @@ public class PanaApiController extends BaseSmfApiListener {
params.put("TransactionID", nextSeq("PANA")); params.put("TransactionID", nextSeq("PANA"));
params.put("ErrorCode","0"); params.put("ErrorCode","0");
params.put("Reelbarcode",barcode.getBarcode()); params.put("Reelbarcode",barcode.getBarcode());
String result = HttpHelper.postJson(requestReelUrl,params); String result = PostJson(requestReelUrl,params);
log.info("PanaCIM 返回料盘【"+codebean.getCodeStr()+"】的信息:"+result); log.info("PanaCIM 返回料盘【"+codebean.getCodeStr()+"】的信息:"+result);
if(!Strings.isNullOrEmpty(result)){ if(!Strings.isNullOrEmpty(result)){
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
...@@ -645,7 +659,7 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -645,7 +659,7 @@ public class PanaApiController extends BaseSmfApiListener {
params.put("Location","0"); params.put("Location","0");
params.put("TowerID",PanaTowerID); params.put("TowerID",PanaTowerID);
log.info("向 PanaCIM["+inNotifyApi+"] 通知料盘【"+task.getBarcode()+"】的入库信息:" + params); log.info("向 PanaCIM["+inNotifyApi+"] 通知料盘【"+task.getBarcode()+"】的入库信息:" + params);
String result = HttpHelper.postJson(inNotifyApi,params); String result = PostJson(inNotifyApi,params);
log.info("Response Of checkInNotification From PanaCIM:"+result); log.info("Response Of checkInNotification From PanaCIM:"+result);
}else{ }else{
log.info("没有配置PanaCIM接口,无需通知"); log.info("没有配置PanaCIM接口,无需通知");
...@@ -656,6 +670,19 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -656,6 +670,19 @@ public class PanaApiController extends BaseSmfApiListener {
} }
} }
private static String PostJson (String url, Map<String, Object> params)throws ApiException {
try{
String result = HttpHelper.postJson(url,params);
apiInteractionManager.save(new ApiInteraction(new Date(),url, JsonUtil.toJsonStr(params),result,ApiInteraction_Status.OK,EquipmentType.PANACIMNEOLINK.name()));
return result;
}catch (ApiException ex) {
log.error(ex.toString());
apiInteractionManager.save(new ApiInteraction(new Date(), url, JsonUtil.toJsonStr(params), ex.toString(), ApiInteraction_Status.ERROE, EquipmentType.PANACIMNEOLINK.name()));
throw ex;
}
}
/** /**
* 出库完成通知 * 出库完成通知
*/ */
...@@ -677,7 +704,7 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -677,7 +704,7 @@ public class PanaApiController extends BaseSmfApiListener {
params.put("MsdLevel","1"); params.put("MsdLevel","1");
params.put("Location","0"); params.put("Location","0");
log.info("向 PanaCIM["+outNotifyApi+"] 通知料盘【"+task.getBarcode()+"】的出库信息:" + params); log.info("向 PanaCIM["+outNotifyApi+"] 通知料盘【"+task.getBarcode()+"】的出库信息:" + params);
String result = HttpHelper.postJson(outNotifyApi,params); String result = PostJson(outNotifyApi,params);
log.info("Response Of deliverNotification From PanaCIM:"+result); log.info("Response Of deliverNotification From PanaCIM:"+result);
}else{ }else{
...@@ -690,7 +717,15 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -690,7 +717,15 @@ public class PanaApiController extends BaseSmfApiListener {
@Override @Override
public boolean isForThisApi(String apiName) { public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("PanaCIM"); boolean result = apiName != null && apiName.equalsIgnoreCase("PanaCIM");
//判断是否启用,如果未启用不连接
if (result) {
EquipConfigInfo equipConfigInfo = equipConfigUtil.getConfigCache(EquipmentType.PANACIMNEOLINK.name());
if (!equipConfigInfo.enableApi) {
return false;
}
}
return result;
} }
...@@ -698,19 +733,22 @@ public class PanaApiController extends BaseSmfApiListener { ...@@ -698,19 +733,22 @@ public class PanaApiController extends BaseSmfApiListener {
* 测试是否可连接 * 测试是否可连接
* @return * @return
*/ */
public boolean TestApi(){ public static boolean TestApi(){
String keepAliveUrl=getkeepAliveUrl(); String keepAliveUrl=getkeepAliveUrl();
try{ try{
Map<String,Object> result = HttpHelper.getJsonResult(keepAliveUrl,new HashMap<>(),3000); Map<String,Object> result = HttpHelper.getJsonResult(keepAliveUrl,new HashMap<>(),3000);
if(result!=null&&result.size()==2){ if(result!=null&&result.size()==2){
int code=(Integer)result.get("code"); int code=(Integer)result.get("code");
String responseContent=result.get("responseContent").toString();
if(code==200){ if(code==200){
apiInteractionManager.save(new ApiInteraction(new Date(),keepAliveUrl,"",responseContent, ApiInteraction_Status.OK,EquipmentType.PANACIMNEOLINK.name()));
return true; return true;
} }
} }
}catch (Exception ex){ }catch (Exception ex){
log.error(keepAliveUrl+" error :"+ex.toString()); log.error(keepAliveUrl+" error :"+ex.toString());
apiInteractionManager.save(new ApiInteraction(new Date(),keepAliveUrl,"",ex.toString(), ApiInteraction_Status.ERROE,EquipmentType.PANACIMNEOLINK.name()));
} }
return false; return false;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!