Commit d8819168 LN

Merge remote-tracking branch 'origin/master'

2 个父辈 9cf3156a aae33481
正在显示 19 个修改的文件 包含 356 行增加159 行删除
...@@ -50,6 +50,7 @@ public class HttpHelper { ...@@ -50,6 +50,7 @@ public class HttpHelper {
/** /**
* 兼容smdBox接口 * 兼容smdBox接口
*
* @param url * @param url
* @param paramMap * @param paramMap
* @param user * @param user
...@@ -146,7 +147,6 @@ public class HttpHelper { ...@@ -146,7 +147,6 @@ public class HttpHelper {
} }
return postJsonWithAuth(url, params, null); return postJsonWithAuth(url, params, null);
} }
public static String postJsonWithAuth(String url, Object params, String auth) throws ApiException { public static String postJsonWithAuth(String url, Object params, String auth) throws ApiException {
String requestBody = ""; String requestBody = "";
...@@ -180,7 +180,7 @@ public class HttpHelper { ...@@ -180,7 +180,7 @@ public class HttpHelper {
//httpClient.close(); //httpClient.close();
return responseContent; return responseContent;
} catch (Exception e) { } catch (Exception e) {
throw new ApiException("Request to [" + url + "]["+requestBody+"] failed:" + e.getMessage()); throw new ApiException("Request to [" + url + "][" + requestBody + "] failed:" + e.getMessage());
} finally { } finally {
try { try {
if (response != null) { if (response != null) {
...@@ -198,8 +198,74 @@ public class HttpHelper { ...@@ -198,8 +198,74 @@ public class HttpHelper {
} }
} }
public static String postJson(String url, Map<String, Object> params, Map<String, String> headerMap) throws ApiException {
// 设置请求参数
if (params == null || params.isEmpty()) {
params = null;
}
return postJsonWithAuth(url, params, null, headerMap);
}
public static String postJsonWithAuth(String url, Object params, String auth, Map<String, String> headerMap) throws ApiException {
String requestBody = "";
// 设置请求参数
if (params != null) {
try {
ObjectMapper mapper = new ObjectMapper();
requestBody = mapper.writeValueAsString(params);
} catch (JsonProcessingException e) {
throw new ApiException("Request params to [" + url + "] Json failed:" + e.getMessage());
} catch (Exception e) {
throw new ApiException("Request params to [" + url + "] json exception:" + e.getMessage());
}
}
HttpPost httpPost = null;
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
try {
httpPost = new HttpPost(url);
httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
if (headerMap != null && !headerMap.isEmpty()) {
for (Entry<String, String> entry : headerMap.entrySet()) {
httpPost.addHeader(entry.getKey(), entry.getValue());
}
}
if (auth != null && !auth.isEmpty()) {
httpPost.addHeader("Authorization", auth);
}
httpPost.setEntity(new StringEntity(requestBody, CONTENT_CHARSET));
httpClient = HttpClients.createDefault();
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, CONTENT_CHARSET);
//response.close();
//httpClient.close();
return responseContent;
} catch (Exception e) {
throw new ApiException("Request to [" + url + "][" + requestBody + "] failed:" + e.getMessage());
} finally {
try {
if (response != null) {
response.close();
}
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
if (httpPost != null) {
httpPost.releaseConnection();
}
}
}
/** /**
* 向指定URL发送POST请求 * 向指定URL发送POST请求
*
* @param url * @param url
* @param paramMap * @param paramMap
* @return 响应结果 * @return 响应结果
...@@ -235,7 +301,7 @@ public class HttpHelper { ...@@ -235,7 +301,7 @@ public class HttpHelper {
return responseContent; return responseContent;
} catch (Exception e) { } catch (Exception e) {
throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage()); throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
}finally { } finally {
try { try {
if (response != null) { if (response != null) {
response.close(); response.close();
...@@ -246,7 +312,7 @@ public class HttpHelper { ...@@ -246,7 +312,7 @@ public class HttpHelper {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (httpPost != null){ if (httpPost != null) {
httpPost.releaseConnection(); httpPost.releaseConnection();
} }
} }
...@@ -299,7 +365,7 @@ public class HttpHelper { ...@@ -299,7 +365,7 @@ public class HttpHelper {
return responseContent; return responseContent;
} catch (Exception e) { } catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage()); throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
}finally { } finally {
try { try {
if (response != null) { if (response != null) {
response.close(); response.close();
...@@ -353,7 +419,7 @@ public class HttpHelper { ...@@ -353,7 +419,7 @@ public class HttpHelper {
return result; return result;
} catch (Exception e) { } catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage()); throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
}finally { } finally {
try { try {
if (response != null) { if (response != null) {
response.close(); response.close();
...@@ -420,7 +486,7 @@ public class HttpHelper { ...@@ -420,7 +486,7 @@ public class HttpHelper {
return responseContent; return responseContent;
} catch (Exception e) { } catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage()); throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
}finally { } finally {
try { try {
if (response != null) { if (response != null) {
response.close(); response.close();
...@@ -435,7 +501,7 @@ public class HttpHelper { ...@@ -435,7 +501,7 @@ public class HttpHelper {
} }
public static String getJson(String url,Map<String,String> headerMap ,Object params) throws ApiException { public static String getJson(String url, Map<String, String> headerMap, Object params) throws ApiException {
// 设置请求参数 // 设置请求参数
if (params != null) { if (params != null) {
try { try {
...@@ -473,7 +539,7 @@ public class HttpHelper { ...@@ -473,7 +539,7 @@ public class HttpHelper {
return responseContent; return responseContent;
} catch (Exception e) { } catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage()); throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
}finally { } finally {
try { try {
if (response != null) { if (response != null) {
response.close(); response.close();
...@@ -488,7 +554,7 @@ public class HttpHelper { ...@@ -488,7 +554,7 @@ public class HttpHelper {
} }
public static String postParam(String url, Map<String, Object> paramMap, Map<String,String> headerMap) throws ApiException { public static String postParam(String url, Map<String, Object> paramMap, Map<String, String> headerMap) throws ApiException {
// 设置请求参数 // 设置请求参数
CloseableHttpClient httpClient = null; CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null; CloseableHttpResponse response = null;
...@@ -511,7 +577,46 @@ public class HttpHelper { ...@@ -511,7 +577,46 @@ public class HttpHelper {
return responseContent; return responseContent;
} catch (Exception e) { } catch (Exception e) {
throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage()); throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
}finally { } finally {
try {
if (response != null) {
response.close();
}
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static String getParam(String url, Map<String, String> headerMap, Map<String,Object> paramMap) throws ApiException {
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
try {
List<NameValuePair> params = toNameValuePair(paramMap);
URI uri = new URIBuilder(url).setParameters(params).build();
log.info("getParam请求,地址为:"+uri);
HttpGet httpGet = new HttpGet(uri);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECTION_TIMEOUT).build();
httpGet.setConfig(requestConfig);
if (headerMap != null && !headerMap.isEmpty()) {
for (Entry<String, String> entry : headerMap.entrySet()) {
httpGet.addHeader(entry.getKey(), entry.getValue());
}
}
httpClient = HttpClients.createDefault();
response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, CONTENT_CHARSET);
return responseContent;
} catch (Exception e) {
throw new ApiException("Request to [" + url + "] failed:" + e.getMessage());
} finally {
try { try {
if (response != null) { if (response != null) {
response.close(); response.close();
......
package com.neotel.smfcore.custom.fuji;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.fuji.config.FileDirectoryConfig;
import com.neotel.smfcore.custom.fuji.config.FujiUrlConfig;
import com.neotel.smfcore.custom.fuji.util.NotifyUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@Service
@Slf4j
public class FujiApi extends BaseSmfApiListener {
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("fuji");
}
@Override
public Barcode canPutInAfterResolve(String inCheckUrl, CodeValidateParam params, Barcode barcode) throws ValidateException {
String accessToken = getAccessToken();
//log.info(barcode.getBarcode()+"获取token的结果为:"+accessToken);
boolean hasDid = inventoryHasDid(barcode.getBarcode(),accessToken);
if (hasDid){
log.info(barcode.getBarcode()+"在Fuji中已经存在,直接返回");
return barcode;
} else {
boolean register = registerNewDid(barcode, accessToken);
if (register){
log.info(barcode.getBarcode()+"在Fuji中注册成功,直接返回");
return barcode;
} else {
throw new ValidateException("smfcore.registerdid.false",barcode.getBarcode()+"注册失败");
}
}
}
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if (task.isFinished()) {
NotifyUtil.createLoadEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
}
}
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if (task.isFinished()) {
NotifyUtil.createLoadEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
NotifyUtil.createProvideEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getSourceName(),task.getLine(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
NotifyUtil.createDeleteEtn(task.getBarcode(),task.getW(),task.getH(),task.getPartNumber(),FileDirectoryConfig.NOTIFY);
}
}
public boolean registerNewDid(Barcode barcode,String accessToken) {
Map<String, String> headerMap = new HashMap<>();
headerMap.put("fujiAccessToken", accessToken);
Map<String, Object> params = new HashMap<>();
params.put("did",barcode.getBarcode());
params.put("partBarcode",barcode.getFullCode());
params.put("quantity",barcode.getAmount());
params.put("packageType","paper"); //默认是paper,
params.put("partsoutWarning",0);
params.put("splicingWarning",0);
params.put("partNumber",barcode.getPartNumber());
params.put("vendorName",barcode.getProvider());
params.put("lotName",barcode.getBatch());
params.put("dateCode",barcode.getProduceDate());
params.put("location","");
params.put("memo","");
params.put("note1","");
params.put("note2","");
params.put("note3","");
params.put("note4","");
params.put("useSplicing",true);
params.put("useTrayPackage",true);
params.put("trayStackCount",1);
params.put("trayPickupPositionX",1);
params.put("trayPickupPositionY",1);
params.put("traySizeX",0);
params.put("traySizeY",0);
log.info("注册Fuji的did参数为:"+JSON.toJSONString(params));
try {
String result = HttpHelper.postJsonWithAuth(FujiUrlConfig.inventoryDids(), Arrays.asList(params), "", headerMap);
log.info("注册Fuji的did结果为:"+result);
JSONObject resultObj = JSONObject.parseObject(result);
Integer addedCount = resultObj.getInteger("addedCount");
if (addedCount != null && addedCount > 0){
return true;
} else {
String details = resultObj.getString("details");
throw new ValidateException("smfcore.registerdid.false",barcode.getBarcode()+"注册失败:"+details);
}
} catch (ApiException e) {
log.info("注册Fuji的did失败:",e);
}
return false;
}
public boolean inventoryHasDid(String barcode,String accessToken) {
Map<String, String> headerMap = new HashMap<>();
headerMap.put("fujiAccessToken", accessToken);
String search = "did == \""+barcode+"\"";
String orderBy = "did asc";
int pageToken = 0;
int pageSize = 200;
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("pageToken", pageToken);
paramMap.put("pageSize", pageSize);
paramMap.put("search", search);
paramMap.put("orderBy", orderBy);
try {
String result = HttpHelper.getParam(FujiUrlConfig.inventoryDids(), headerMap, paramMap);
log.info(barcode + "获取Fuji的inventory/dids结果为:" + result);
JSONObject resultObj = JSONObject.parseObject(result);
JSONArray dataArray = resultObj.getJSONArray("datas");
if (dataArray != null && !dataArray.isEmpty()){
for (int i = 0; i < dataArray.size(); i++) {
JSONObject data = dataArray.getJSONObject(i);
if (barcode.equals(data.getString("did"))){
return true;
}
}
}
} catch (ApiException e) {
log.info(barcode + "获取Fuji的inventory/dids失败:", e.getMessage());
}
return false;
}
/**
* 获取登录的token
* @return
*/
private String getAccessToken() {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("userName", FujiUrlConfig.userName);
paramMap.put("password", FujiUrlConfig.password);
log.info("获取Fuji的token参数为:" + JSON.toJSONString(paramMap));
String accessToken = "";
try {
String result = HttpHelper.postJson(FujiUrlConfig.getAuthLogin(), paramMap);
log.info("获取Fuji的token结果为:" + result);
JSONObject resultObj = JSONObject.parseObject(result);
accessToken = resultObj.getString("accessToken");
} catch (ApiException e) {
log.info("获取Fuji的token异常:", e);
accessToken = "";
}
if (StringUtils.isEmpty(accessToken)) {
throw new ValidateException("smfcore.accessToken.ng", "获取AccessToken失败");
}
return accessToken;
}
}
package com.neotel.smfcore.custom.nexim.bean; package com.neotel.smfcore.custom.fuji.bean;
import lombok.Data; import lombok.Data;
......
package com.neotel.smfcore.custom.nexim.bean; package com.neotel.smfcore.custom.fuji.bean;
import lombok.Data; import lombok.Data;
......
package com.neotel.smfcore.custom.nexim.bean; package com.neotel.smfcore.custom.fuji.bean;
import lombok.Data; import lombok.Data;
......
package com.neotel.smfcore.custom.fuji.config;
public class FileDirectoryConfig {
public static final String NOTIFY = "\\\\175.41.238.212\\remoteorder\\notify\\";
}
package com.neotel.smfcore.custom.fuji.config;
import lombok.Data;
@Data
public class FujiUrlConfig {
private static final String baseUrl = "http://175.41.238.212/fujiopenwebapi/api/v1";
public static final String userName = "Neotel";
public static final String password = "Neotel";
private static final String authLogin = "/auth/login";
private static final String inventoryDids = "/inventory/dids";
public static String getAuthLogin() {
return baseUrl + authLogin;
}
public static String inventoryDids() {
return baseUrl + inventoryDids;
}
}
package com.neotel.smfcore.custom.nexim.enums; package com.neotel.smfcore.custom.fuji.enums;
/** /**
* Action 类型 * Action 类型
......
package com.neotel.smfcore.custom.nexim.enums; package com.neotel.smfcore.custom.fuji.enums;
public class ErrorCode { public class ErrorCode {
public static final int ok = 0; public static final int ok = 0;
......
package com.neotel.smfcore.custom.nexim.enums; package com.neotel.smfcore.custom.fuji.enums;
public enum NexObject { public enum NexObject {
......
package com.neotel.smfcore.custom.nexim.enums; package com.neotel.smfcore.custom.fuji.enums;
public class OrderType { public class OrderType {
public static final String order = "[Order]"; public static final String order = "[Order]";
......
package com.neotel.smfcore.custom.nexim.order; package com.neotel.smfcore.custom.fuji.order;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.utils.*;
import com.neotel.smfcore.core.api.SmfApi; import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
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.device.util.DataCache;
import com.neotel.smfcore.core.order.LiteOrderCache; import com.neotel.smfcore.core.order.LiteOrderCache;
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.enums.CHECKOUT_TYPE; import com.neotel.smfcore.custom.fuji.util.NotifyUtil;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; import com.neotel.smfcore.custom.fuji.util.OrderUtil;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.nexim.NeximApi;
import com.neotel.smfcore.custom.nexim.bean.OrderReq;
import com.neotel.smfcore.custom.nexim.bean.OrderResp;
import com.neotel.smfcore.custom.nexim.enums.Action;
import com.neotel.smfcore.custom.nexim.enums.ErrorCode;
import com.neotel.smfcore.custom.nexim.enums.NexObject;
import com.neotel.smfcore.custom.nexim.enums.OrderType;
import com.neotel.smfcore.custom.nexim.util.NotifyUtil;
import com.neotel.smfcore.custom.nexim.util.OrderUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import jcifs.smb.SmbFile;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*; import java.util.*;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j @Slf4j
@Component @Component
public class OrderHandler { public class OrderHandler {
private static IStoragePosManager storagePosManager;
@Autowired
public void setStoragePosManager(IStoragePosManager manager) {
storagePosManager = manager;
}
private static IBarcodeManager barcodeManager;
@Autowired
public void setBarcodeManager(IBarcodeManager manager) {
barcodeManager = manager;
}
private static DataCache dataCache; private static DataCache dataCache;
@Autowired @Autowired
...@@ -82,13 +34,6 @@ public class OrderHandler { ...@@ -82,13 +34,6 @@ public class OrderHandler {
dataCache = cache; dataCache = cache;
} }
private static TaskService taskService;
@Autowired
public void setTaskService(TaskService service) {
taskService = service;
}
private static ILiteOrderManager liteOrderManager; private static ILiteOrderManager liteOrderManager;
@Autowired @Autowired
...@@ -103,12 +48,6 @@ public class OrderHandler { ...@@ -103,12 +48,6 @@ public class OrderHandler {
liteOrderCache = cache; liteOrderCache = cache;
} }
private static OrderCheckOutService checkOutService;
@Autowired
public void setOrderCheckOutService(OrderCheckOutService service) {
checkOutService = service;
}
public static SmfApi smfApi; public static SmfApi smfApi;
...@@ -122,16 +61,15 @@ public class OrderHandler { ...@@ -122,16 +61,15 @@ public class OrderHandler {
@PostConstruct @PostConstruct
public void init() { public void init() {
if ("nexim".equals(smfApi.getApiName())){
scheduledThreadPool.scheduleAtFixedRate(() -> { scheduledThreadPool.scheduleAtFixedRate(() -> {
try { try {
if ("nexim".equals(smfApi.getApiName())) {
handler(); handler();
} catch (Exception e) {
log.info("执行fuji工单失败:",e);
} }
} catch (IOException e) { },60, 10, TimeUnit.SECONDS);
e.printStackTrace();
log.error(e.getMessage());
} }
}, 60, 10, TimeUnit.SECONDS);
} }
public static void handler() throws IOException { public static void handler() throws IOException {
......
package com.neotel.smfcore.custom.nexim.util; package com.neotel.smfcore.custom.fuji.util;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.nexim.bean.Notify;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
......
package com.neotel.smfcore.custom.nexim.util; package com.neotel.smfcore.custom.fuji.util;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.SmbUtil; import com.neotel.smfcore.common.utils.SmbUtil;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.custom.nexim.bean.Notify; import com.neotel.smfcore.custom.fuji.bean.OrderResp;
import com.neotel.smfcore.custom.nexim.bean.OrderReq;
import com.neotel.smfcore.custom.nexim.bean.OrderResp;
import com.neotel.smfcore.custom.nexim.enums.OrderType;
import jcifs.smb.SmbFile; import jcifs.smb.SmbFile;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -20,7 +15,6 @@ import java.nio.charset.StandardCharsets; ...@@ -20,7 +15,6 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
......
...@@ -295,7 +295,7 @@ public class NeotelApi extends BaseSmfApiListener { ...@@ -295,7 +295,7 @@ public class NeotelApi extends BaseSmfApiListener {
barcode = barcodeManager.save(barcode); barcode = barcodeManager.save(barcode);
return barcode; return barcode;
} else { } else {
return null; throw new ValidateException("smfcore.mesApi.inCheck.error", "MES验证出错:" + apiResult.getMsg());
} }
} catch (Exception e) { } catch (Exception e) {
log.error("入库验证接口出错:" + e.getMessage()); log.error("入库验证接口出错:" + e.getMessage());
......
package com.neotel.smfcore.custom.nexim;
import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.SmbUtil;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.custom.nexim.bean.Notify;
import com.neotel.smfcore.custom.nexim.config.FileDirectoryConfig;
import com.neotel.smfcore.custom.nexim.enums.Action;
import com.neotel.smfcore.custom.nexim.enums.NexObject;
import com.neotel.smfcore.custom.nexim.util.NotifyUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.io.File;
@Service
@Slf4j
public class NeximApi extends BaseSmfApiListener {
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("nexim");
}
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if (task.isFinished()) {
NotifyUtil.createLoadEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
}
}
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if (task.isFinished()) {
NotifyUtil.createLoadEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
NotifyUtil.createProvideEtn(task.getBarcode(),task.getPosName(),task.getNum(),"",task.getW(),task.getH(),task.getPartNumber(),task.getSourceName(),task.getLine(),task.getStorageName(),FileDirectoryConfig.NOTIFY);
NotifyUtil.createDeleteEtn(task.getBarcode(),task.getW(),task.getH(),task.getPartNumber(),FileDirectoryConfig.NOTIFY);
}
}
}
package com.neotel.smfcore.custom.nexim.config;
public class FileDirectoryConfig {
//public static final String NOTIFY = "Remoteorder\\notify\\";
public static final String NOTIFY = "F:\\FUJI\\remoteorder\\notify\\";
//public static final String INPUT = "Remoteorder\\input\\";
public static final String INPUT = "F:\\FUJI\\remoteorder\\line\\";
public static final String OUTPUT = "Remoteorder\\output\\";
}
...@@ -2,11 +2,13 @@ server: ...@@ -2,11 +2,13 @@ server:
port: 8800 port: 8800
api: api:
name: SO21476 name:
inCheckUrl: D:\remain\ inCheckUrl:
outNotifyUrl: outNotifyUrl:
inNotifyUrl: inNotifyUrl:
hella: hella:
#host: 127.0.0.1 #host: 127.0.0.1
#port: 3333 #port: 3333
...@@ -50,5 +52,6 @@ menu: ...@@ -50,5 +52,6 @@ menu:
smd: smd:
filePath: filePath:
userName:
password:
\ No newline at end of file \ No newline at end of file
userName :
password :
url:
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!