Commit c9966fe9 zshaohui

Merge remote-tracking branch 'origin/master'

2 个父辈 3afe1705 e28b51ff
正在显示 29 个修改的文件 包含 743 行增加206 行删除
......@@ -150,7 +150,7 @@ public class MenuInit {
addDefaultFunctionMenu(2, poutOut,"PN出库", "tacticsOuput", "neolight/tacticsOuput/index", "tacticsOuput",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(3,poutOut,"工单出库","workOrder", "neolight/workOrder/index","orderOut",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(4,poutOut,"工单","orderkanban", "orderkanban/index","kanban");
// addDefaultFunctionMenu(4,poutOut,"工单","orderkanban", "orderkanban/index","kanban");
addDefaultFunctionMenu(5,poutOut,"库位出库", "posOutput", "system/posOutput/index", "swagger");
addDefaultFunctionMenu(6, poutOut, "物料标签", "labelOuput", "neolight/labelOuput/index", "mgroup");
addDefaultFunctionMenu(7, poutOut, "料盒操作", "materialBox", "neolight/materialBox/index", "mIbox");
......@@ -163,7 +163,7 @@ public class MenuInit {
// addDefaultFunctionMenu(12, poutOut, "单盘入库", "singleDiskWarehousing", "system/singleDiskWarehousing/index", "headIcon");
addDefaultFunctionMenu(13, poutOut, "呆滞物料", "sluggishMaterials", "system/sluggishMaterials/index", "sMaterial");
//addDefaultFunctionMenu(16, poutOut,"生成工单", "createOrder", "system/createOrder/index", "createOrder");
addDefaultFunctionMenu(91,poutOut, "共享文件夹", "orderSetting", "system/orderSetting/index", "sysSet",DEFAULT_SHOW_MENU);
// addDefaultFunctionMenu(91,poutOut, "共享文件夹", "orderSetting", "system/orderSetting/index", "sysSet",DEFAULT_SHOW_MENU);
//MSD管理:MSD库存.MSD追溯性.MSD设置
......@@ -195,7 +195,8 @@ public class MenuInit {
Menu pMenuLog = Menu.CreatePMenu("日志管理", 8, "log","log",null);
addDefaultFunctionMenu(61, pMenuLog, "物料日志", "taskLog", "neolight/taskLog/index", "education",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(62, pMenuLog, "消息查询", "message", "neolight/message/index", "messagefind",DEFAULT_SHOW_MENU);
addDefaultFunctionMenu(63, pMenuLog, "接口异常", "interfaceException", "neolight/interfaceException/index", "messagefind");
//暂未找到页面
// addDefaultFunctionMenu(63, pMenuLog, "接口异常", "interfaceException", "neolight/interfaceException/index", "messagefind");
//报表:出入库、库存
Menu pMenuReport = Menu.CreatePMenu("报表", 9, "report","inOutData",null);
......@@ -234,6 +235,7 @@ public class MenuInit {
// Menu orderSet = new Menu(, "orderSetting", "工单设置", "orderSetting", "system/orderSetting/index", "sysSet");
addDefaultFunctionMenu(106,poutSet, "料架设置", "shelfSetting", "system/shelfSetting/index", "translation",NL_SHOW_MENU);
addDefaultFunctionMenu(107,poutSet, "其他设备", "storageOther", "storage/storageOther/index", "storageOther");
addDefaultFunctionMenu(108,poutSet, "工单设置", "orderSetting", "system/orderSetting/index", "sysSet",DEFAULT_SHOW_MENU);
Menu helpAbout = Menu.CreatePMenu("帮助", 9999, "help", "help",null);
addDefaultFunctionMenu(99991, helpAbout, "说明书", "instruction", "system/instruction/index","aboutBook");
......
......@@ -28,6 +28,7 @@ import org.apache.logging.log4j.util.Strings;
import org.springframework.util.CollectionUtils;
import java.io.*;
import java.net.InetAddress;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
......@@ -148,6 +149,9 @@ public class HttpHelper {
return postJsonWithAuth(url, params, null);
}
public static String postJsonWithAuth(String url, Object params, String auth) throws ApiException {
return postJsonWithAuth(url,params,auth,CONNECTION_TIMEOUT,READ_DATA_TIMEOUT);
}
public static String postJsonWithAuth(String url, Object params, String auth,int conTimeout,int socketTimeout) throws ApiException {
String requestBody = "";
// 设置请求参数
......@@ -171,6 +175,16 @@ public class HttpHelper {
if (auth != null && !auth.isEmpty()) {
httpPost.addHeader("Authorization", auth);
}
if(conTimeout>0&&socketTimeout>0){
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(conTimeout) // 设置连接超时时间为3秒
.setSocketTimeout(socketTimeout) // 设置请求超时时间为3秒
.build();
httpPost.setConfig(requestConfig);
}
httpPost.setEntity(new StringEntity(requestBody, CONTENT_CHARSET));
httpClient = HttpClients.createDefault();
response = httpClient.execute(httpPost);
......@@ -452,6 +466,59 @@ public class HttpHelper {
}
}
public static Map<String,Object> getJsonResult(String url, Object params,int timeoutMS) throws ApiException {
// 设置请求参数
if (params != null) {
try {
ObjectMapper mapper = new ObjectMapper();
String requestBody = mapper.writeValueAsString(params);
List<NameValuePair> nameValuePairs = new LinkedList<>();
nameValuePairs.add(new BasicNameValuePair("JSON", requestBody));
String paramStr = EntityUtils.toString(new UrlEncodedFormEntity(nameValuePairs));
url = appendString(url, paramStr);
// url=url+"?JSON="+requestBody;
} catch (Exception e) {
throw new ApiException("getJson append params to [" + url + "] exception:" + e.getMessage());
}
}
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
try {
HttpGet httpGet = new HttpGet(url);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(timeoutMS).build();
httpGet.setConfig(requestConfig);
httpGet.addHeader("Content-Type", "application/json;charset=utf-8");
httpClient = HttpClients.createDefault();
response = httpClient.execute(httpGet);
int code = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, CONTENT_CHARSET);
Map<String,Object> resultMap=new HashMap<>();
resultMap.put("code",code);
resultMap.put("responseContent",responseContent);
return resultMap;
//response.close();
//httpClient.close();
// return responseContent;
} catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
} finally {
try {
if (response != null) {
response.close();
}
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static String getJson(String url, Object params) throws ApiException {
// 设置请求参数
if (params != null) {
......@@ -637,5 +704,17 @@ public class HttpHelper {
stringBuffer.append(paramStr);
return stringBuffer.toString();
}
public static boolean pingIP(String ipAddress, int timeout) {
try {
InetAddress address = InetAddress.getByName(ipAddress);
if (address.isReachable(timeout)) {
return true;
}
} catch (Exception e) {
log.error(e.toString());
}
return false;
}
}
package com.neotel.smfcore.core.apiInteraction.bean.query;
import com.neotel.smfcore.common.annotation.QueryCondition;
import com.neotel.smfcore.common.bean.BetweenData;
import com.neotel.smfcore.core.apiInteraction.enums.ApiInteraction_Status;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class ApiInteractionQuery {
@QueryCondition(blurry = "url,param,result")
private String blurry;
@QueryCondition(type = QueryCondition.Type.BETWEEN, propName = "createDate")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private BetweenData<Date> createDate;
@QueryCondition
private Date requestDate;
//private String url;
......@@ -15,7 +25,9 @@ public class ApiInteractionQuery {
//private String param;
//private String result;
private String status = ApiInteraction_Status.OK;
@QueryCondition
private String status ="";
@QueryCondition
private String type="";
}
package com.neotel.smfcore.core.apiInteraction.controller;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.base.IExcelDownLoad;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.core.apiInteraction.bean.query.ApiInteractionQuery;
import com.neotel.smfcore.core.apiInteraction.service.manager.IApiInteractionManager;
import com.neotel.smfcore.core.apiInteraction.service.po.ApiInteraction;
import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -13,6 +19,13 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@Slf4j
@RequestMapping("/apiInteraction")
@RestController
......@@ -26,7 +39,45 @@ public class ApiInteractionController {
@AnonymousAccess
public PageData list(ApiInteractionQuery query, Pageable pageable){
Query q = QueryHelp.getQuery(query);
return apiInteractionManager.findByPage(q,pageable);
PageData<ApiInteraction> result= apiInteractionManager.findByPage(q,pageable);
return result;
}
@ApiOperation("接口记录导出")
@RequestMapping("/download")
@AnonymousAccess
public void download(ApiInteractionQuery query, Pageable pageable, HttpServletResponse response, HttpServletRequest request)throws IOException {
Query q = QueryHelp.getQuery(query);
FileUtil.downloadExcel(q, pageable, response, new IExcelDownLoad() {
@Override
public List<List<String>> getHeader() {
List<List<String>> header = new ArrayList<>();
Locale locale = request.getLocale();
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.updateTime", 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.url", locale, "地址")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.equipApiMsg.state", locale, "状态")));
return header;
}
@Override
public List<List<Object>> getPageData(Query query, Pageable pageable) {
PageData<ApiInteraction> apiInfoList = apiInteractionManager.findByPage(q,pageable);
List<List<Object>> dataList = new ArrayList<>();
for (ApiInteraction obj : apiInfoList.getContent()) {
List<Object> data = new ArrayList<>();
data.add(DateUtil.toDateString(obj.getRequestDate()));
data.add(obj.getParam());
data.add(obj.getResult());
data.add(obj.getUrl());
data.add(obj.getStatus());
dataList.add(data);
}
return dataList;
}
});
}
}
......@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.apiInteraction.service.po;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.core.apiInteraction.enums.ApiInteraction_Status;
import com.neotel.smfcore.core.equipment.enums.EquipmentType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -14,6 +15,17 @@ import java.util.Date;
@NoArgsConstructor
public class ApiInteraction extends BasePo implements Serializable {
public ApiInteraction(Date date,String url,String param,String result,String status){
this.requestDate=date;
this.url=url;
this.param=param;
this.result=result;
this.status=status;
this.type=EquipmentType.NEXIM.name();
}
private Date requestDate;
private String url;
......@@ -23,4 +35,7 @@ public class ApiInteraction extends BasePo implements Serializable {
private String result;
private String status = ApiInteraction_Status.OK;
//设备类型,nexim,hanwa,pancim
private String type="";
}
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,6 +67,12 @@ public enum EquipmentType {
public static List<EquipmentType> availableTypeList(){
return Lists.newArrayList(AUTO,NEOSCAN,NS200,COUNTING,NEOSTATION,FUJINEOLINK,PANACIMNEOLINK,AGV,HANWHA,NEXIM);
return Lists.newArrayList(AUTO,NS100,NS200,NEOCOUNTER,PANACIMNEOLINK,AGV,T_SOLUTION,NEXIM);
}
public static List<String> apiTypeList(){
return Lists.newArrayList(T_SOLUTION.name(),PANACIMNEOLINK.name(),NEXIM.name());
}
}
package com.neotel.smfcore.core.equipment.rest;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.core.equipment.util.EquipApiUtil;
import com.neotel.smfcore.core.equipment.util.bean.EquipApiInfo;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/equipApiInfo")
public class EquipApiController {
@Autowired
private EquipApiUtil equipApiUtil;
@ApiOperation("获取列表")
@GetMapping("/getApiInfoList")
public PageData<EquipApiInfo> getApiInfoList() {
List<EquipApiInfo> apiInfoList = equipApiUtil.getApiInfoList();
return new PageData<EquipApiInfo>(apiInfoList, apiInfoList.size());
}
}
......@@ -2,8 +2,16 @@ package com.neotel.smfcore.core.equipment.rest;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.core.equipment.enums.EquipmentType;
import com.neotel.smfcore.core.equipment.rest.dto.EquipConfigInfoDto;
import com.neotel.smfcore.core.equipment.rest.mapstruct.EquipConfigInfoMapper;
import com.neotel.smfcore.core.equipment.util.EquipConfigUtil;
import com.neotel.smfcore.core.equipment.util.bean.EquipConfigInfo;
import com.neotel.smfcore.custom.hanwha.handler.TMSApis;
import com.neotel.smfcore.custom.hanwha.handler.TMSCommunicator;
import com.neotel.smfcore.custom.panacim.PanaApiController;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -14,40 +22,95 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("/equipConfig")
public class EquipConfigController {
@Autowired
private EquipConfigInfoMapper equipConfigInfoMapper;
@Autowired
private EquipConfigUtil equipConfigUtil;
@Autowired
private EquipConfigUtil equipConfigUtil;
@Autowired
private PanaApiController panaApiController;
@ApiOperation("获取配置信息")
@GetMapping("/getConfig")
public ResultBean getCacheConfig(String equipType){
return ResultBean.newOkResult(equipConfigUtil.getConfigCache(equipType));
@Autowired
private TMSApis tmsApis;
@Autowired
private TMSCommunicator tmsCommunicator;
@ApiOperation("获取配置信息")
@GetMapping("/getConfig")
public ResultBean getCacheConfig(String equipType) {
EquipConfigInfo configInfo= equipConfigUtil.getConfigCache(equipType);
return ResultBean.newOkResult(equipConfigInfoMapper.toDto(configInfo));
}
@ApiOperation("更改配置信息")
@PostMapping("/updateConfig")
public ResultBean updateConfig(@RequestBody EquipConfigInfo cacheConfig) {
if (ObjectUtil.isEmpty(cacheConfig.getEquipType())) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"equipType"});
}
equipConfigUtil.updateConfigCache(cacheConfig);
return ResultBean.newOkResult("");
}
@ApiOperation("测试接口是否连通")
@PostMapping("/apiTest")
public ResultBean apiTest(@RequestBody EquipConfigInfoDto configInfoDto) {
if (ObjectUtil.isEmpty(configInfoDto.getEquipType())) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"equipType"});
}
//判断测试哪个接口
@ApiOperation("更改配置信息")
@PostMapping("/updateConfig")
public ResultBean updateConfig(@RequestBody EquipConfigInfo cacheConfig) {
// String host = cacheConfig.getHost();
// String apiPort = cacheConfig.getApiPort();
// String webPort = cacheConfig.getWebPort();
// log.info("收到修改ip和端口号,host为[{}],apiPort为[{}],webPort为[{}]",host,apiPort,webPort);
//
// if (StringUtils.isEmpty(host)){
// return ResultBean.newErrorResult(1,"smfcore.valueCanotNull", "{0}不能为空", new String[]{"host"});
// }
// if (StringUtils.isEmpty(webPort)){
// return ResultBean.newErrorResult(1,"smfcore.valueCanotNull", "{0}不能为空", new String[]{"webPort"});
// }
// if (StringUtils.isEmpty(apiPort)){
// return ResultBean.newErrorResult(1,"smfcore.valueCanotNull", "{0}不能为空", new String[]{"apiPort"});
// }
if(ObjectUtil.isEmpty(cacheConfig.getEquipType())){
return ResultBean.newErrorResult(1,"smfcore.valueCanotNull", "{0}不能为空", new String[]{"equipType"});
boolean result = false;
if (configInfoDto.equipType.equals(EquipmentType.T_SOLUTION.name())) {
EquipConfigInfo config = equipConfigInfoMapper.toEntity(configInfoDto);
String ip = config.GetConfigValue("host", "");
if (ObjectUtil.isEmpty(ip)) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"host"});
}
if (configInfoDto.apiTestKey.equals("webPort")) {
int webPort = config.GetConfigValue("webPort", 0);
String webUrl = String.format("ws://%s:%d/", ip, webPort);
if (ObjectUtil.isEmpty(webPort) || webPort == 0) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"webPort"});
}
if (TMSCommunicator.wsURL.equals(webUrl)) {
result = tmsCommunicator.isConnected();
} else {
result = tmsApis.TestWebSocket(ip, webPort);
}
} else if (configInfoDto.apiTestKey.equals("host")) {
result = HttpHelper.pingIP(ip, 1000);
} else {
int apiPort = config.GetConfigValue("apiPort", 0);
if (ObjectUtil.isEmpty(apiPort) || apiPort == 0) {
return ResultBean.newErrorResult(1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"apiPort"});
}
result = tmsApis.TestApi(ip, apiPort);
}
} else if (configInfoDto.equipType.equals(EquipmentType.PANACIMNEOLINK.name())) {
if (configInfoDto.apiTestKey.equals(Constants.Cache_PanaCIMIP)) {
result = panaApiController.TestIp(1000);
} else {
result = panaApiController.TestApi();
}
equipConfigUtil.updateConfigCache(cacheConfig);
return ResultBean.newOkResult("");
}
if (result) {
return ResultBean.newOkResult("OK");
} else {
return ResultBean.newErrorResult(-1, "smfcore.equipconfig.connectTimeout", "连接超时");
}
}
}
......@@ -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())){
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config != null){
dto.setActivate(true);
if(dto.isActivate()) {
//配置了且激活就显示在线
FujiConfig config = dataCache.getCache(FujiCacheConfig.FujiConfig_Cache_Name);
if (config != null) {
// dto.setStatus(1);
}
}
}
......
package com.neotel.smfcore.core.equipment.rest;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
......@@ -59,6 +60,13 @@ public class EquipmentController {
Query query= QueryHelp.getQuery(criteria);
PageData<Equipment> pages = equipmentManager.findByPage(query, pageable);
List<EquipmentDto> equipmentDtos =equipmentMapper.toDto(pages.getContent());
for (int i=0;i<equipmentDtos.size();i++){
if(EquipmentType.apiTypeList().contains(equipmentDtos.get(i).getType())){
equipmentDtos.get(i).setAPIEquip(true);
}
}
return new PageData(equipmentDtos,pages.getTotalElements());
}
......@@ -111,6 +119,7 @@ public class EquipmentController {
} if(StringUtils.isEmpty(equipment.getType())){
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"type"} );
}
String oldCid="";
for (Equipment equ : equipmentCache.getAllEquipment().values()) {
if (!equipment.getId().equals(equ.getId())){
if(equipment.getName().equals(equ.getName())){
......@@ -119,10 +128,15 @@ public class EquipmentController {
if(equipment.getCid().equals(equ.getCid())){
throw new ValidateException("smfcore.valueAlreadyExist","{0}[{1}]已存在",new String[]{"cid",equipment.getCid()});
}
}else{
oldCid=equ.getCid();
}
}
if(ObjectUtil.isEmpty(oldCid)){
oldCid=equipment.getCid();
}
equipmentManager.save(equipment);
equipmentCache.reloadEquipment(equipment,equipment.getCid());
equipmentCache.reloadEquipment(equipment,oldCid);
return new ResponseEntity<>(HttpStatus.OK);
}
......
package com.neotel.smfcore.core.equipment.rest.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.LinkedHashMap;
@Data
public class EquipConfigInfoDto {
@ApiModelProperty("设备类型")
public String equipType = "";
@ApiModelProperty("启用API连接 默认不启用")
public boolean enableApi;
@ApiModelProperty("配置列表")
public LinkedHashMap<String, Object> apiConfigMap;
@ApiModelProperty("测试连接的Key")
public String apiTestKey;
}
......@@ -23,5 +23,7 @@ public class EquipmentDto {
@ApiModelProperty("是否激活")
private boolean activate=true;
@ApiModelProperty("是否是第三方对接设备")
private boolean aPIEquip=false;
private String id;
}
package com.neotel.smfcore.core.equipment.rest.mapstruct;
import com.neotel.smfcore.common.base.BaseMapper;
import com.neotel.smfcore.core.equipment.rest.dto.EquipConfigInfoDto;
import com.neotel.smfcore.core.equipment.util.bean.EquipConfigInfo;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring" ,unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface EquipConfigInfoMapper extends BaseMapper<EquipConfigInfoDto, EquipConfigInfo> {
}
......@@ -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);
}
......@@ -42,7 +42,10 @@ public class Equipment extends BasePo implements Serializable {
* @return
*/
public boolean isAPIEquip() {
return EquipmentType.HANWHA.name().equals(type)||EquipmentType.PANACIMNEOLINK.name().equals(type)||
EquipmentType.FUJINEOLINK.name().equals(type)||EquipmentType.NEXIM.name().equals(type);
if(EquipmentType.apiTypeList().contains(type)){
return true;
}
return false;
}
}
package com.neotel.smfcore.core.equipment.util;
import com.neotel.smfcore.core.equipment.util.bean.EquipApiInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
@Slf4j
@Service
public class EquipApiUtil {
//api接口信息,默认返回10条
public static List<EquipApiInfo> apiInfoList = new CopyOnWriteArrayList<>();
public void updateApiInfoList(String url, String requestParam, String resultReturn) {
EquipApiInfo info = new EquipApiInfo();
info.setCreateDate(new Date());
info.setUrl(url);
info.setRequestParam(requestParam);
info.setResultReturn(resultReturn);
apiInfoList.add(info);
if (apiInfoList != null && apiInfoList.size() > 10) {
apiInfoList.remove(0);
}
}
public List<EquipApiInfo> getApiInfoList() {
List<EquipApiInfo> resultList = new ArrayList<>();
if (apiInfoList != null && !apiInfoList.isEmpty()) {
resultList = apiInfoList.stream().sorted(Comparator.comparing(EquipApiInfo::getCreateDate).reversed()).collect(Collectors.toList());
}
return resultList;
}
}
package com.neotel.smfcore.core.equipment.util;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.equipment.enums.EquipmentType;
......@@ -42,15 +43,34 @@ 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())) {
//增加配置
LinkedHashMap<String, Object> defMap = new LinkedHashMap<>();
String ip=dataCache.getCache(Constants.Cache_PanaCIMIP);
if(ip==null){
ip="";
}
String port=dataCache.getCache(Constants.Cache_PanaCIMPort);
if(port==null){
port="";
}
defMap.put("PanaCIMIP", ip);
defMap.put("PanaCIMPort", port);
configInfo.setApiConfigMap(defMap);
}
return configInfo;
}
}
package com.neotel.smfcore.core.equipment.util.bean;
import lombok.Data;
import java.util.Date;
@Data
public class EquipApiInfo {
private String url;
private String requestParam;
private String resultReturn;
private Date createDate;
}
......@@ -28,13 +28,17 @@ public class EquipConfigInfo {
try {
if (apiConfigMap != null) {
Object result = apiConfigMap.get(key);
if (result != null) {
if (result instanceof String && defValue instanceof Integer) {
return (T) (Integer) Integer.parseInt((String) result);
}
else if (result != null) {
return (T) result;
}
}
} catch (Exception exception) {
log.error("GetConfigValue 出错: type=" + equipType + ",key=" + key + ", error =" + exception.toString());
}
if (defValue != null) {
return (T) defValue;
......@@ -42,4 +46,5 @@ public class EquipConfigInfo {
return null;
}
}
......@@ -34,6 +34,8 @@ public class OrderSetting implements Serializable {
*/
public Map<String,String> appendData = new HashMap<>();
@ApiModelProperty("缺料不自动关闭工单")
private boolean closeWorkOrder = false;
/**
* 是否显示料架亮灯方式
*/
......
......@@ -151,6 +151,10 @@ public class SettingsController {
break;
}
}
Boolean closeWorkOrder = dataCache.getCache(Constants.CACHE_closeWorkOrder);
if(closeWorkOrder!=null){
orderSetting.setCloseWorkOrder(closeWorkOrder);
}
return orderSetting;
}
......@@ -208,6 +212,7 @@ public class SettingsController {
}
dataCache.updateCache(Constants.CACHE_OrderSetting, orderSetting);
dataCache.updateCache(Constants.CACHE_closeWorkOrder,orderSetting.isCloseWorkOrder());
log.info("更改工单设置:"+Constants.CACHE_OrderSetting+"=" + orderSetting.toString());
return ResultBean.newOkResult("保存成功");
......
......@@ -5,19 +5,31 @@ 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.core.equipment.util.EquipApiUtil;
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.device.bean.StatusBean;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.equipment.enums.EquipmentType;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.custom.hanwha.client.MyWebSocketClient;
import com.neotel.smfcore.custom.hanwha.handler.bean.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.net.URI;
import java.util.*;
@Service
@Slf4j
public class TMSApis {
@Autowired
private EquipApiUtil equipApiUtil;
private IApiInteractionManager apiInteractionManager;
@Autowired
private DataCache dataCache;
/**
* 3.16 RequestGetPartInfo
* Request part information of given ReelCode to TMS (when the Rack needs it).
......@@ -477,12 +489,113 @@ public class TMSApis {
private String PostJson(String url,Map<String,Object> sendData) throws ApiException {
String requestParam = JsonUtil.toJsonStr(sendData);
try {
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.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.T_SOLUTION.name()));
throw ex;
}
String responseStr = HttpHelper.postJson(url, sendData);
String requestParam=JsonUtil.toJsonStr(sendData);
log.info("PostJson, url=["+url+"],send=["+requestParam+"],response=["+responseStr+"]");
equipApiUtil.updateApiInfoList(url,requestParam,responseStr);
return responseStr;
}
public boolean TestApi(String ip,int apiPort ) {
try {
List<String> cids = new ArrayList<>(dataCache.getAllStorage().keySet());
Integer[] statusList= new Integer[0];
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 = "0";
if(status>=1){
conCode="2";
}
storageIds.add(storage.getCid());
storageTypes.add(type);
isConns.add(Integer.parseInt(conCode));
i++;
break;
}
String RequestID="0";
String url = String.format("http://%s:%d/", ip, apiPort) + "webservice/RequestUpdateStorageConnectionInfo";
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("RequestID", RequestID);
dataMap.put("Indate", getInDataStr());
dataMap.put("StorageID", storageIds);
dataMap.put("StorageType", storageTypes);
dataMap.put("IsConn", isConns);
Map<String, Object> sendData = new HashMap<>();
sendData.put("data", dataMap);
String responseStr = PostJson(url, sendData);
return true;
} catch (Exception ex) {
return false;
}
}
public boolean TestWebSocket( String ip ,int webPort) {
try {
String webUrl = String.format("ws://%s:%d/", ip, webPort);
MyWebSocketClient websocket = new MyWebSocketClient(new URI(webUrl), null );
websocket.setConnectionLostTimeout(3000);
try {
// 设置连接超时时间为3秒
websocket.connect();
//等待3秒看是否连接
for (int i=0;i<100;i++){
Thread.sleep(30);
if(websocket.isOpen()){
log.info("TestWebSocket "+webUrl+" 已连接");
return true;
}
}
} catch (Exception e) {
return false;
} finally {
try {
websocket.close();
} catch (Exception e) {
log.info(e.toString());
}
}
} catch (Exception ex) {
log.info(ex.toString());
}
return false;
}
}
......@@ -98,41 +98,30 @@ public class TMSCommunicator implements WsMsgReceivedListener {
@Autowired
private IStoragePosManager storagePosManager;
// @Autowired
// private IDataLogManager dataLogManager;
// @Autowired
// private IComponentManager componentManager;
@Autowired
private TMSUtil tmsUtil;
// private static int gRequestID = 1000;
// public static int GetRequestID()
// {
// return gRequestID++;
// }
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);
host=equipConfigInfo.GetConfigValue("host","");
webPort = equipConfigInfo.GetConfigValue("webPort",0);
apiPort = equipConfigInfo.GetConfigValue("apiPort",0);
enableApi=equipConfigInfo.isEnableApi();
apiName = dataCache.getConfigCache("api.name",apiName);
boolean enable= apiName != null && apiName.equalsIgnoreCase("hanwha") ;
if(!enable){
log.info("apiName=" + apiName+",不需要连接");
}else if(!enableApi){
log.info("enableApi=" + enableApi+",不需要连接");
}
else if (ObjectUtil.isEmpty(host) || webPort==0 || apiPort==0) {
host = equipConfigInfo.GetConfigValue("host", "");
webPort = equipConfigInfo.GetConfigValue("webPort", 0);
apiPort = equipConfigInfo.GetConfigValue("apiPort", 0);
enableApi = equipConfigInfo.isEnableApi();
apiName = dataCache.getConfigCache("api.name", apiName);
updateServerInfo(host, webPort, apiPort,enableApi);
boolean enable = apiName != null && apiName.equalsIgnoreCase("hanwha");
if (!enable) {
log.info("apiName=" + apiName + ",不需要连接");
} else if (!enableApi) {
log.info("enableApi=" + enableApi + ",不需要连接");
} else if (ObjectUtil.isEmpty(host) || webPort == 0 || apiPort == 0) {
// else if (ObjectUtil.isEmpty(host) || ObjectUtil.isEmpty(webPortStr) || ObjectUtil.isEmpty((apiPortStr))) {
log.info("配置不完整,不需要连接");
} else {
......@@ -140,7 +129,6 @@ public class TMSCommunicator implements WsMsgReceivedListener {
// apiPort = Integer.parseInt(apiPortStr);
String apiName = dataCache.getConfigCache("api.name", "");
if (apiName != null && apiName.equalsIgnoreCase("hanwha")) {
updateServerInfo(host, webPort, apiPort);
Thread closeTask = new Thread(new Runnable() {
@Override
public void run() {
......@@ -148,39 +136,118 @@ public class TMSCommunicator implements WsMsgReceivedListener {
Thread.sleep(20000);
start();
Thread.sleep(5000);
needCheck=true;
}catch (Exception e){
needCheck = true;
} catch (Exception e) {
log.error("开始连接webService出错:" + e.getMessage());
}
}
} );
});
closeTask.start();
// StartCheckRun();
}
}
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@Override
public void run() {
log.info("启动 webService 状态检查");
while(true) {
try {
if(waitSync&&System.currentTimeMillis()>syncTime){
SyncData();
}
TimeUnit.SECONDS.sleep(6);
if (needCheck) {
stateCheck();
}
} catch (Exception e) {
log.error("webService" + e.getMessage());
StartCheckRun();
}
private void StartCheckRun() {
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@Override
public void run() {
log.info("启动 webService 状态检查");
while (true) {
try {
if (isEnable() && apiName != null && apiName.equalsIgnoreCase("hanwha")) {
if (waitSync && System.currentTimeMillis() > syncTime) {
SyncData();
}
TimeUnit.SECONDS.sleep(6);
if (needCheck) {
stateCheck();
}
} else {
if (isConnected()) {
//当前需要禁用webSocket连接
close();
}
TimeUnit.SECONDS.sleep(6);
}
EquipConfigInfo equipConfigInfo = equipConfigUtil.getConfigCache(EquipmentType.T_SOLUTION.name());
ResetConfig(equipConfigInfo);
} catch (Exception e) {
log.error("webService" + e.getMessage());
}
});
// start();
}
}
});
}
private void ResetConfig(EquipConfigInfo nconfig) {
try {
//重新设置韩华接口时调用
String nhost = nconfig.GetConfigValue("host", "");
int nwebPort = nconfig.GetConfigValue("webPort", 0);
int napiPort = nconfig.GetConfigValue("apiPort", 0);
if (enableApi == nconfig.enableApi && nhost == host && webPort == nwebPort && napiPort == apiPort) {
return;
}
if (nconfig.enableApi) {
//当前启用
if (enableApi) {
//如果ip端口不一致,需要关闭webSocket重新连接
String nwsURL = String.format("ws://%s:%d/", nhost, nwebPort);
if (!wsURL.equals(nwsURL)) {
log.info("更改韩华配置,wsURL = " + wsURL + ",需要更改为:" + nwsURL + ",关闭webSocket连接重新连接");
updateServerInfo(nhost, nwebPort, napiPort, nconfig.enableApi);
close();
} else {
updateServerInfo(nhost, nwebPort, napiPort, nconfig.enableApi);
}
} else {
//当前禁用
updateServerInfo(nhost, nwebPort, napiPort, nconfig.enableApi);
log.info("更改韩华配置,之前禁用连接,现在启用连接,开始启动webSocket连接");
Thread closeTask = new Thread(new Runnable() {
@Override
public void run() {
if (isEnable()) {
try {
Thread.sleep(5000);
start();
Thread.sleep(5000);
needCheck = true;
} catch (Exception e) {
log.error("开始连接webService出错:" + e.getMessage());
}
}
}
});
closeTask.start();
}
} else {
//如果原来启用当前禁用
if (enableApi) {
log.info("更改韩华配置,之前启用连接,现在禁用连接,关闭webSocket连接,更新配置");
updateServerInfo(nhost, nwebPort, napiPort, nconfig.enableApi);
close();//关闭连接
}
}
} catch (Exception exception) {
log.error("ResetConfig error :" + exception.toString());
}
}
private void stateCheck(){
if(websocket.isOpen()||websocket.isConnecting()){
......@@ -190,11 +257,11 @@ public class TMSCommunicator implements WsMsgReceivedListener {
}
}
private void updateServerInfo(String serverHost, int wport, int aport) {
private void updateServerInfo(String serverHost, int wport, int aport,boolean enableApiParam) {
host = serverHost;
webPort = wport;
apiPort = aport;
enableApi=enableApiParam;
wsURL = String.format("ws://%s:%d/", serverHost, wport);
apiURL = String.format("http://%s:%d/", serverHost, aport);
......
......@@ -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,12 +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;
......@@ -18,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;
......@@ -36,6 +44,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
......@@ -65,6 +74,16 @@ public class PanaApiController extends BaseSmfApiListener {
@Autowired
protected CodeResolve codeResolve;
private static IApiInteractionManager apiInteractionManager;
@Autowired
public void setApiInteractionManager(IApiInteractionManager interactionManager){
PanaApiController.apiInteractionManager=interactionManager;
}
@Autowired
private EquipConfigUtil equipConfigUtil;
@Autowired
public void setDataCache(DataCache dataCache) {
PanaApiController.dataCache = dataCache;
......@@ -134,6 +153,12 @@ public class PanaApiController extends BaseSmfApiListener {
return "";
}
private static String getkeepAliveUrl(){
if(!Strings.isNullOrEmpty(PanaCIMIP)){
return "http://"+PanaCIMIP + ":" + PanaCIMPort + "/api/Storage/keepAlive";
}
return "";
}
@RequestMapping(value = "/keepAlive")
@ResponseBody
......@@ -431,7 +456,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();
......@@ -516,7 +541,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();
......@@ -635,7 +660,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接口,无需通知");
......@@ -646,6 +671,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;
}
}
/**
* 出库完成通知
*/
......@@ -667,7 +705,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{
......@@ -680,6 +718,59 @@ 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;
}
/**
* 测试是否可连接
* @return
*/
public static boolean TestApi(){
String keepAliveUrl=getkeepAliveUrl();
try{
if(ObjectUtil.isEmpty(keepAliveUrl)){
log.error("未找到地址 keepAliveUrl,返回false");
return false;
}
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;
}
public boolean TestIp(int timeout) {
try {
if (timeout <= 0) {
timeout = 1000;
}
InetAddress address = InetAddress.getByName(PanaCIMIP);
if (address.isReachable(timeout)) {
return true;
}
} catch (Exception ex) {
log.error("TestIp" + PanaCIMIP + " error :" + ex.toString());
}
return false;
}
}
......@@ -406,4 +406,10 @@ smfcore.storageOther=\u5176\u4ED6\u8BBE\u5907
smfcore.humiture.ntemperature2=\u51B7\u85CF\u6E29\u5EA62
smfcore.humiture.ntemperature3=\u51B7\u85CF\u6E29\u5EA63
smfcore.humiture.codetemperature2=\u5236\u51B7\u6E29\u5EA62
smfcore.humiture.wtemperature=\u56DE\u6E29\u6E29\u5EA6
\ No newline at end of file
smfcore.humiture.wtemperature=\u56DE\u6E29\u6E29\u5EA6
smfcore.equipconfig.connectTimeout=\u8FDE\u63A5\u8D85\u65F6
smfcore.equipApiMsg.url=URL
smfcore.equipApiMsg.request=\u8BF7\u6C42\u4FE1\u606F
smfcore.equipApiMsg.response=\u7ED3\u679C\u4FE1\u606F
smfcore.equipApiMsg.updateTime=\u65F6\u95F4
smfcore.equipApiMsg.state=\u7C7B\u578B
\ No newline at end of file
......@@ -397,4 +397,10 @@ smfcore.storageOther = Other Devices
smfcore.humiture.ntemperature2=Refrigeration zone temperature 2
smfcore.humiture.ntemperature3=Refrigeration zone temperature 3
smfcore.humiture.codetemperature2=Cooling Temperature 2
smfcore.humiture.wtemperature=Return temperature zone temperature
\ No newline at end of file
smfcore.humiture.wtemperature=Return temperature zone temperature
smfcore.equipconfig.connectTimeout=Connection Timeout
smfcore.equipApiMsg.url=URL/Source
smfcore.equipApiMsg.request=Parameter
smfcore.equipApiMsg.response=Result/Details
smfcore.equipApiMsg.updateTime=Time
smfcore.equipApiMsg.state=Type
\ No newline at end of file
......@@ -393,4 +393,10 @@ smfcore.storageOther = \u305D\u306E\u4ED6\u6A5F\u5668
smfcore.humiture.ntemperature2=\u51B7\u85CF\u6E29\u5EA62
smfcore.humiture.ntemperature3=\u51B7\u85CF\u6E29\u5EA63
smfcore.humiture.codetemperature2=\u5236\u51B7\u6E29\u5EA62
smfcore.humiture.wtemperature=\u56DE\u6E29\u6E29\u5EA6
\ No newline at end of file
smfcore.humiture.wtemperature=\u56DE\u6E29\u6E29\u5EA6
smfcore.equipconfig.connectTimeout=\u63A5\u7D9A\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8
smfcore.equipApiMsg.url=URL
smfcore.equipApiMsg.request=\u30EA\u30AF\u30A8\u30B9\u30C8\u60C5\u5831
smfcore.equipApiMsg.response=\u30EC\u30B9\u30DD\u30F3\u30B9\u60C5\u5831
smfcore.equipApiMsg.updateTime=\u6642\u9593
smfcore.equipApiMsg.state=\u30B9\u30C6\u30FC\u30BF\u30B9
......@@ -393,4 +393,10 @@ smfcore.storageOther=\u5176\u4ED6\u8BBE\u5907
smfcore.humiture.ntemperature2=\u51B7\u85CF\u6E29\u5EA62
smfcore.humiture.ntemperature3=\u51B7\u85CF\u6E29\u5EA63
smfcore.humiture.codetemperature2=\u5236\u51B7\u6E29\u5EA62
smfcore.humiture.wtemperature=\u56DE\u6E29\u6E29\u5EA6
\ No newline at end of file
smfcore.humiture.wtemperature=\u56DE\u6E29\u6E29\u5EA6
smfcore.equipconfig.connectTimeout=\u8FDE\u63A5\u8D85\u65F6
smfcore.equipApiMsg.url=URL
smfcore.equipApiMsg.request=\u8BF7\u6C42\u4FE1\u606F
smfcore.equipApiMsg.response=\u7ED3\u679C\u4FE1\u606F
smfcore.equipApiMsg.updateTime=\u65F6\u95F4
smfcore.equipApiMsg.state=\u7C7B\u578B
\ No newline at end of file
......@@ -393,4 +393,10 @@ smfcore.storageOther=\u5176\u4ED6\u8A2D\u5099
smfcore.humiture.ntemperature2=\u51B7\u85CF\u6E29\u5EA62
smfcore.humiture.ntemperature3=\u51B7\u85CF\u6E29\u5EA63
smfcore.humiture.codetemperature2=\u5236\u51B7\u6E29\u5EA62
smfcore.humiture.wtemperature=\u56DE\u6E29\u6E29\u5EA6
\ No newline at end of file
smfcore.humiture.wtemperature=\u56DE\u6E29\u6E29\u5EA6
smfcore.equipconfig.connectTimeout=\u8FDE\u63A5\u8D85\u65F6
smfcore.equipApiMsg.url=URL
smfcore.equipApiMsg.request=\u8BF7\u6C42\u4FE1\u606F
smfcore.equipApiMsg.response=\u7ED3\u679C\u4FE1\u606F
smfcore.equipApiMsg.updateTime=\u65F6\u95F4
smfcore.equipApiMsg.state=\u7C7B\u578B
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!