Commit da18b7a3 LN

韩华接口配置改为通用配置

1 个父辈 d7363090
正在显示 17 个修改的文件 包含 293 行增加192 行删除
package com.neotel.smfcore.custom.hanwha.controller; package com.neotel.smfcore.core.equipment.rest;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.custom.hanwha.util.HanwhaApiInfoUtil; import com.neotel.smfcore.core.equipment.util.EquipApiUtil;
import com.neotel.smfcore.custom.hanwha.util.bean.HanwhaApiInfo; import com.neotel.smfcore.core.equipment.util.bean.EquipApiInfo;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/hanwhaApiInfo") @RequestMapping("/equipApiInfo")
public class HanwhaApiInfoController { public class EquipApiController {
@Autowired @Autowired
private HanwhaApiInfoUtil hanwhaApiInfoUtil; private EquipApiUtil equipApiUtil;
@ApiOperation("获取列表") @ApiOperation("获取列表")
@RequestMapping("/getApiInfoList") @GetMapping("/getApiInfoList")
public ResultBean getApiInfoList(){ public PageData<EquipApiInfo> getApiInfoList() {
List<HanwhaApiInfo> apiInfoList = hanwhaApiInfoUtil.getApiInfoList(); List<EquipApiInfo> apiInfoList = equipApiUtil.getApiInfoList();
return ResultBean.newOkResult(apiInfoList); return new PageData<EquipApiInfo>(apiInfoList, apiInfoList.size());
} }
} }
package com.neotel.smfcore.core.equipment.rest;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.core.equipment.util.EquipConfigUtil;
import com.neotel.smfcore.core.equipment.util.bean.EquipConfigInfo;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController
@RequestMapping("/equipConfig")
public class EquipConfigController {
@Autowired
private EquipConfigUtil equipConfigUtil;
@ApiOperation("获取配置信息")
@GetMapping("/getConfig")
public ResultBean getCacheConfig(String equipType){
return ResultBean.newOkResult(equipConfigUtil.getConfigCache(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"});
}
equipConfigUtil.updateConfigCache(cacheConfig);
return ResultBean.newOkResult("");
}
}
...@@ -82,6 +82,11 @@ public class EquipmentController { ...@@ -82,6 +82,11 @@ public class EquipmentController {
} }
} }
} }
if(equipment.isAPIEquip()){
equipment.setActivated(false);
}else{
equipment.setActivated(true);
}
equipment = equipmentManager.save(equipment); equipment = equipmentManager.save(equipment);
equipmentCache.reloadEquipment(equipment,equipment.getCid()); equipmentCache.reloadEquipment(equipment,equipment.getCid());
return new ResponseEntity<>(HttpStatus.CREATED); return new ResponseEntity<>(HttpStatus.CREATED);
......
...@@ -20,6 +20,8 @@ public class EquipmentDto { ...@@ -20,6 +20,8 @@ public class EquipmentDto {
@ApiModelProperty("是否可用") @ApiModelProperty("是否可用")
private boolean available = true; private boolean available = true;
@ApiModelProperty("是否激活")
private boolean activated=true;
private String id; private String id;
} }
...@@ -27,7 +27,21 @@ public class Equipment extends BasePo implements Serializable { ...@@ -27,7 +27,21 @@ public class Equipment extends BasePo implements Serializable {
*/ */
private boolean available = true; private boolean available = true;
/**
* 是否激活
*/
private boolean activated=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);
} }
/**
* 是否是接口设备
* @return
*/
public boolean isAPIEquip() {
return EquipmentType.HANWHA.name().equals(type)||EquipmentType.PANACIMNEOLINK.name().equals(type);
}
} }
package com.neotel.smfcore.custom.hanwha.util; package com.neotel.smfcore.core.equipment.util;
import com.google.common.collect.Maps; import com.neotel.smfcore.core.equipment.util.bean.EquipApiInfo;
import com.neotel.smfcore.custom.hanwha.util.bean.HanwhaApiInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
public class HanwhaApiInfoUtil { public class EquipApiUtil {
//api接口信息,默认返回10条 //api接口信息,默认返回10条
public static List<HanwhaApiInfo> apiInfoList = new CopyOnWriteArrayList<>(); public static List<EquipApiInfo> apiInfoList = new CopyOnWriteArrayList<>();
public void updateApiInfoList(String url, String requestParam, String resultReturn) { public void updateApiInfoList(String url, String requestParam, String resultReturn) {
HanwhaApiInfo info = new HanwhaApiInfo(); EquipApiInfo info = new EquipApiInfo();
info.setCreateDate(new Date()); info.setCreateDate(new Date());
info.setUrl(url); info.setUrl(url);
info.setRequestParam(requestParam); info.setRequestParam(requestParam);
...@@ -29,10 +31,10 @@ public class HanwhaApiInfoUtil { ...@@ -29,10 +31,10 @@ public class HanwhaApiInfoUtil {
} }
} }
public List<HanwhaApiInfo> getApiInfoList(){ public List<EquipApiInfo> getApiInfoList() {
List<HanwhaApiInfo> resultList = new ArrayList<>(); List<EquipApiInfo> resultList = new ArrayList<>();
if (apiInfoList != null && !apiInfoList.isEmpty()){ if (apiInfoList != null && !apiInfoList.isEmpty()) {
resultList = apiInfoList.stream().sorted(Comparator.comparing(HanwhaApiInfo::getCreateDate).reversed()).collect(Collectors.toList()); resultList = apiInfoList.stream().sorted(Comparator.comparing(EquipApiInfo::getCreateDate).reversed()).collect(Collectors.toList());
} }
return resultList; return resultList;
} }
......
package com.neotel.smfcore.core.equipment.util;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.equipment.enums.EquipmentType;
import com.neotel.smfcore.core.equipment.util.bean.EquipConfigInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Service
public class EquipConfigUtil {
@Autowired
private DataCache dataCache;
private static final String Equip_Config_Cache = "Equip_Config_Cache";
public static String CacheStr(String equipType){
return Equip_Config_Cache+"_"+equipType;
}
public void updateConfigCache(EquipConfigInfo cacheConfig) {
String key=CacheStr(cacheConfig.getEquipType());
EquipConfigInfo configInfo = getConfigCache(cacheConfig.getEquipType());
configInfo.setEnableApi(cacheConfig.isEnableApi());
configInfo.setApiConfigMap(cacheConfig.getApiConfigMap());
dataCache.updateCache(key, configInfo);
log.info("updateConfigCache [" + key + "=" + JsonUtil.toJsonStr(configInfo) + "]");
}
public EquipConfigInfo getConfigCache(String equipType) {
String key=CacheStr(equipType);
EquipConfigInfo configInfo = dataCache.getCache(key);
if (configInfo == null) {
configInfo = new EquipConfigInfo();
configInfo.setEquipType(equipType);
configInfo.setEnableApi(false);
if(equipType.equals(EquipmentType.HANWHA.name())){
Map<String,Object> defMap=new HashMap<>();
defMap.put("host","");
defMap.put("webPort",1337);
defMap.put("apiPort",8082);
defMap.put("singleOrder",true);
configInfo.setApiConfigMap(defMap);
}
}
return configInfo;
}
}
package com.neotel.smfcore.custom.hanwha.util.bean; package com.neotel.smfcore.core.equipment.util.bean;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@Data @Data
public class HanwhaApiInfo { public class EquipApiInfo {
private String url; private String url;
private String requestParam; private String requestParam;
...@@ -14,5 +13,4 @@ public class HanwhaApiInfo { ...@@ -14,5 +13,4 @@ public class HanwhaApiInfo {
private String resultReturn; private String resultReturn;
private Date createDate; private Date createDate;
} }
package com.neotel.smfcore.core.equipment.util.bean;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.util.Map;
@Data
@Slf4j
public class EquipConfigInfo {
public String equipType = "";
/**
* 启用API连接 默认不启用
*/
public boolean enableApi;
/**
* 配置列表
*/
public Map<String, Object> apiConfigMap;
//韩华配置key: host ,webPort, apiPort,singleOrder
public <T> T GetConfigValue(String key,Object defValue) {
try {
if (apiConfigMap != null) {
Object result = apiConfigMap.get(key);
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;
}
return null;
}
}
...@@ -60,11 +60,11 @@ public class LiteOrderCache { ...@@ -60,11 +60,11 @@ public class LiteOrderCache {
@Autowired @Autowired
private SmfApi smfApi; private SmfApi smfApi;
//最大工单数 // //最大工单数
public int MaxOrderCount=1; // public int MaxOrderCount=1;
public boolean SingleOrderMode(){ // public boolean SingleOrderMode(){
return MaxOrderCount==1; // return MaxOrderCount==1;
} // }
/** /**
......
package com.neotel.smfcore.custom.hanwha.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.custom.hanwha.util.HanwhaCacheUtil;
import com.neotel.smfcore.custom.hanwha.util.bean.HanwhaCacheConfig;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/hanwhaConfig")
public class HanwhaConfigController {
@Autowired
private HanwhaCacheUtil hanwhaCacheUtil;
@ApiOperation("获取ip和端口号")
@RequestMapping("/getCacheConfig")
public ResultBean getCacheConfig(){
return ResultBean.newOkResult(hanwhaCacheUtil.getHostAndPortCache());
}
@ApiOperation("修改ip和端口号")
@RequestMapping("/updateCacheConfig")
public ResultBean updateCacheConfig(@RequestBody HanwhaCacheConfig 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"});
}
hanwhaCacheUtil.updateHostAndPort(cacheConfig);
return ResultBean.newOkResult("");
}
}
...@@ -13,10 +13,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -13,10 +13,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
...@@ -45,15 +42,16 @@ public class HanwhaController { ...@@ -45,15 +42,16 @@ public class HanwhaController {
@ApiOperation("更新最大工单数") @ApiOperation("更新最大工单数")
@GetMapping("/UpdateOrderMode") @PostMapping("/UpdateOrderMode")
@AnonymousAccess @AnonymousAccess
public ResultBean UpdateOrderMode(@RequestParam Integer maxOrderCount) { public ResultBean UpdateOrderMode(@RequestParam Integer maxOrderCount) {
if(ObjectUtil.isEmpty(maxOrderCount)){ // if(ObjectUtil.isEmpty(maxOrderCount)){
return ResultBean.newErrorResult(-1,"Error","Error"); // return ResultBean.newErrorResult(-1,"Error","Error");
} // }
liteOrderCache.MaxOrderCount=maxOrderCount; // liteOrderCache.MaxOrderCount=maxOrderCount;
log.info("UpdateOrderMode 设置 liteOrderCache.MaxOrderCount="+liteOrderCache.MaxOrderCount); // log.info("UpdateOrderMode 设置 liteOrderCache.MaxOrderCount="+liteOrderCache.MaxOrderCount);
return ResultBean.newOkResult(maxOrderCount); // return ResultBean.newOkResult(maxOrderCount);
return ResultBean.newOkResult("");
} }
} }
...@@ -5,8 +5,10 @@ import com.neotel.smfcore.common.exception.ApiException; ...@@ -5,8 +5,10 @@ import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.utils.DateUtil; import com.neotel.smfcore.common.utils.DateUtil;
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.JsonUtil;
import com.neotel.smfcore.core.equipment.util.EquipApiUtil;
import com.neotel.smfcore.custom.hanwha.handler.bean.*; import com.neotel.smfcore.custom.hanwha.handler.bean.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
...@@ -14,6 +16,8 @@ import java.util.*; ...@@ -14,6 +16,8 @@ import java.util.*;
@Service @Service
@Slf4j @Slf4j
public class TMSApis { public class TMSApis {
@Autowired
private EquipApiUtil equipApiUtil;
/** /**
* 3.16 RequestGetPartInfo * 3.16 RequestGetPartInfo
* Request part information of given ReelCode to TMS (when the Rack needs it). * Request part information of given ReelCode to TMS (when the Rack needs it).
...@@ -475,7 +479,9 @@ public class TMSApis { ...@@ -475,7 +479,9 @@ public class TMSApis {
private String PostJson(String url,Map<String,Object> sendData) throws ApiException { private String PostJson(String url,Map<String,Object> sendData) throws ApiException {
String responseStr = HttpHelper.postJson(url, sendData); String responseStr = HttpHelper.postJson(url, sendData);
log.info("PostJson, url=["+url+"],send=["+JsonUtil.toJsonStr(sendData)+"],response=["+responseStr+"]"); String requestParam=JsonUtil.toJsonStr(sendData);
log.info("PostJson, url=["+url+"],send=["+requestParam+"],response=["+responseStr+"]");
equipApiUtil.updateApiInfoList(url,requestParam,responseStr);
return responseStr; return responseStr;
} }
......
...@@ -14,25 +14,21 @@ import java.util.concurrent.TimeUnit; ...@@ -14,25 +14,21 @@ import java.util.concurrent.TimeUnit;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.exception.ApiException; 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.DateUtil;
import com.neotel.smfcore.common.utils.JsonUtil; import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
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.LITEORDER_STATUS;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager; 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.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem; import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.storage.bean.InventoryItem;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; 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.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil; import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
...@@ -55,28 +51,30 @@ public class TMSCommunicator implements WsMsgReceivedListener { ...@@ -55,28 +51,30 @@ public class TMSCommunicator implements WsMsgReceivedListener {
public static String wsURL; public static String wsURL;
public static String apiURL; public static String apiURL;
private static boolean enableApi=false;//是否启用api
private static String host = ""; private static String host = "";
private static int webPort = 8082; private static int webPort = 8082;
private static int apiPort = 1337 ; private static int apiPort = 1337 ;
private static String configWebPort = ""; // private static String configWebPort = "";
private static String configApiPort = ""; // private static String configApiPort = "";
private static String clientType = "NEOTEL"; private static String clientType = "NEOTEL";
private static String clientSubType = "Rack01"; private static String clientSubType = "Rack01";
@Value("${hanwha.host:}") // @Value("${hanwha.host:}")
public void setHost(String host) { // public void setHost(String host) {
TMSCommunicator.host = host; // TMSCommunicator.host = host;
} // }
//
@Value("${hanwha.webPort:}") // @Value("${hanwha.webPort:}")
public void setWebPort(String configPort) { // public void setWebPort(String configPort) {
TMSCommunicator.configWebPort = configPort; // TMSCommunicator.configWebPort = configPort;
} // }
//
@Value("${hanwha.apiPort:}") // @Value("${hanwha.apiPort:}")
public void setApiPort(String configPort) { // public void setApiPort(String configPort) {
TMSCommunicator.configApiPort = configPort; // TMSCommunicator.configApiPort = configPort;
} // }
/** /**
* API名称 * API名称
*/ */
...@@ -86,6 +84,9 @@ public class TMSCommunicator implements WsMsgReceivedListener { ...@@ -86,6 +84,9 @@ public class TMSCommunicator implements WsMsgReceivedListener {
private DataCache dataCache; private DataCache dataCache;
@Autowired @Autowired
private EquipConfigUtil equipConfigUtil;
@Autowired
private ILiteOrderManager liteOrderManager; private ILiteOrderManager liteOrderManager;
@Autowired @Autowired
...@@ -100,34 +101,43 @@ public class TMSCommunicator implements WsMsgReceivedListener { ...@@ -100,34 +101,43 @@ public class TMSCommunicator implements WsMsgReceivedListener {
// @Autowired // @Autowired
// private IDataLogManager dataLogManager; // private IDataLogManager dataLogManager;
@Autowired // @Autowired
private IComponentManager componentManager; // private IComponentManager componentManager;
@Autowired @Autowired
private TMSUtil tmsUtil; private TMSUtil tmsUtil;
private static int gRequestID = 1000; // private static int gRequestID = 1000;
public static int GetRequestID() // public static int GetRequestID()
{ // {
return gRequestID++; // return gRequestID++;
} // }
private boolean needCheck=false; private boolean needCheck=false;
@PostConstruct @PostConstruct
public void init() { public void init() {
host = dataCache.getConfigCache("hanwha.host", host); EquipConfigInfo equipConfigInfo=equipConfigUtil.getConfigCache(EquipmentType.HANWHA.name());
String webPortStr = dataCache.getConfigCache("hanwha.webPort", configWebPort); // host = dataCache.getConfigCache("hanwha.host", host);
String apiPortStr = dataCache.getConfigCache("hanwha.apiPort", configApiPort); // 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); apiName = dataCache.getConfigCache("api.name",apiName);
boolean enable= apiName != null && apiName.equalsIgnoreCase("hanwha") ; boolean enable= apiName != null && apiName.equalsIgnoreCase("hanwha") ;
if(!enable){ if(!enable){
log.info("apiName:" + apiName+",不需要连接"); log.info("apiName=" + apiName+",不需要连接");
}else if(!enableApi){
log.info("enableApi=" + enableApi+",不需要连接");
} }
else if (ObjectUtil.isEmpty(host) || ObjectUtil.isEmpty(webPortStr) || ObjectUtil.isEmpty((apiPortStr))) { else if (ObjectUtil.isEmpty(host) || webPort==0 || apiPort==0) {
// else if (ObjectUtil.isEmpty(host) || ObjectUtil.isEmpty(webPortStr) || ObjectUtil.isEmpty((apiPortStr))) {
log.info("配置不完整,不需要连接"); log.info("配置不完整,不需要连接");
} else { } else {
webPort = Integer.parseInt(webPortStr); // webPort = Integer.parseInt(webPortStr);
apiPort = Integer.parseInt(apiPortStr); // apiPort = Integer.parseInt(apiPortStr);
String apiName = dataCache.getConfigCache("api.name", ""); String apiName = dataCache.getConfigCache("api.name", "");
if (apiName != null && apiName.equalsIgnoreCase("hanwha")) { if (apiName != null && apiName.equalsIgnoreCase("hanwha")) {
updateServerInfo(host, webPort, apiPort); updateServerInfo(host, webPort, apiPort);
...@@ -188,7 +198,7 @@ public class TMSCommunicator implements WsMsgReceivedListener { ...@@ -188,7 +198,7 @@ public class TMSCommunicator implements WsMsgReceivedListener {
wsURL = String.format("ws://%s:%d/", serverHost, wport); wsURL = String.format("ws://%s:%d/", serverHost, wport);
apiURL = String.format("http://%s:%d/", serverHost, aport); apiURL = String.format("http://%s:%d/", serverHost, aport);
log.info("设置webSocketServer:[" + wsURL + "],httpServer:[" + apiURL + "]"); log.info("设置webSocketServer:[" + wsURL + "],httpServer:[" + apiURL + "],enableApi=["+enableApi+"]");
} }
private void start() { private void start() {
...@@ -223,9 +233,13 @@ public class TMSCommunicator implements WsMsgReceivedListener { ...@@ -223,9 +233,13 @@ public class TMSCommunicator implements WsMsgReceivedListener {
} }
public static boolean isEnable() { public static boolean isEnable() {
if (ObjectUtil.isEmpty(host) || ObjectUtil.isEmpty(webPort) || ObjectUtil.isEmpty(apiPort)) { if (ObjectUtil.isEmpty(host) || ObjectUtil.isEmpty(webPort) || ObjectUtil.isEmpty(apiPort)
|| webPort == 0 || apiPort == 0) {
return false; return false;
} else { } else {
if (!enableApi) {
return false;
}
return true; return true;
} }
} }
...@@ -237,8 +251,8 @@ public class TMSCommunicator implements WsMsgReceivedListener { ...@@ -237,8 +251,8 @@ public class TMSCommunicator implements WsMsgReceivedListener {
} }
} }
public boolean isConnected() { public boolean isConnected() {
if(isEnable()){ if(!isEnable()){
return true; return false;
} }
if (websocket != null &&(websocket.isConnecting()||websocket.isOpen()) ) { if (websocket != null &&(websocket.isConnecting()||websocket.isOpen()) ) {
return true; return true;
......
...@@ -7,6 +7,9 @@ import com.neotel.smfcore.core.barcode.service.manager.IComponentManager; ...@@ -7,6 +7,9 @@ import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component; import com.neotel.smfcore.core.barcode.service.po.Component;
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.LITEORDER_STATUS; import com.neotel.smfcore.core.order.enums.LITEORDER_STATUS;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager; import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
...@@ -57,6 +60,9 @@ public class TMSUtil { ...@@ -57,6 +60,9 @@ public class TMSUtil {
@Autowired @Autowired
private TMSApis tmsApis; private TMSApis tmsApis;
@Autowired
private EquipConfigUtil equipConfigUtil;
public TMSReserve GetOrderInfo(LiteOrder liteOrder) { public TMSReserve GetOrderInfo(LiteOrder liteOrder) {
TMSReserve tmsReserve = new TMSReserve(); TMSReserve tmsReserve = new TMSReserve();
...@@ -302,7 +308,14 @@ public class TMSUtil { ...@@ -302,7 +308,14 @@ public class TMSUtil {
public boolean HasExeOrder(){ public boolean HasExeOrder(){
if(liteOrderCache.SingleOrderMode()){ EquipConfigInfo config=equipConfigUtil.getConfigCache(EquipmentType.HANWHA.name());
Boolean singleOrderMode= true;
if(config!=null){
singleOrderMode= config.GetConfigValue("singleOrder",true );
}
if(singleOrderMode){
// if(liteOrderCache.SingleOrderMode()){
Query query = new Query(Criteria.where("status").ne(LITEORDER_STATUS.CLOSED)); Query query = new Query(Criteria.where("status").ne(LITEORDER_STATUS.CLOSED));
List<LiteOrder> orderList = liteOrderManager.findByQuery(query); List<LiteOrder> orderList = liteOrderManager.findByQuery(query);
List<LiteOrder> nOder=new ArrayList<>(); List<LiteOrder> nOder=new ArrayList<>();
......
package com.neotel.smfcore.custom.hanwha.util;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.custom.hanwha.util.bean.HanwhaCacheConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class HanwhaCacheUtil {
@Autowired
private DataCache dataCache;
public static final String Cache_Hanwha_HostAndPost = "Cache_Hanwha_HostAndPost";
public void updateHostAndPort(HanwhaCacheConfig cacheConfig) {
HanwhaCacheConfig hanwhaCacheConfig = dataCache.getCache(Cache_Hanwha_HostAndPost);
if (hanwhaCacheConfig == null) {
hanwhaCacheConfig = new HanwhaCacheConfig();
}
hanwhaCacheConfig.setHost(cacheConfig.getHost());
hanwhaCacheConfig.setWebPort(cacheConfig.getWebPort());
hanwhaCacheConfig.setApiPort(cacheConfig.getApiPort());
hanwhaCacheConfig.setSingleOrder(cacheConfig.isSingleOrder());
dataCache.updateCache(Cache_Hanwha_HostAndPost, hanwhaCacheConfig);
}
public HanwhaCacheConfig getHostAndPortCache(){
HanwhaCacheConfig hostAndPortCache = dataCache.getCache(Cache_Hanwha_HostAndPost);
if (hostAndPortCache == null) {
hostAndPortCache = new HanwhaCacheConfig();
}
return hostAndPortCache;
}
}
package com.neotel.smfcore.custom.hanwha.util.bean;
import lombok.Data;
@Data
public class HanwhaCacheConfig {
private String host;
private String webPort;
private String apiPort;
private boolean singleOrder = false;
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!