Commit 6411bc91 LN

1.panacim 增加接口日志。

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