Commit 08f5ce75 sunke

接口重构

研华版本
大陆科技料架功能修正
1 个父辈 2f44da71
正在显示 67 个修改的文件 包含 1071 行增加612 行删除
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.1</version>
<version>2.7.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.neotel</groupId>
......
package com.neotel.smfcore.common.exception;
import org.springframework.http.HttpStatus;
import java.text.MessageFormat;
/**
* Created by kangmor on 2015/11/12.
*/
......@@ -7,4 +11,22 @@ public class ApiException extends Exception {
public ApiException(String message){
super(message);
}
private String msgKey="";
private String[] msgParam;
private String defaultMsg="";
public ApiException(String msgKey, String defMsg){
super(defMsg);
this.msgKey=msgKey;
this.msgParam=null;
this.defaultMsg=defMsg;
}
public ApiException(String msgKey, String defMsg,String[] msgParam){
super( defMsg= MessageFormat.format(defMsg,msgParam));
this.msgKey=msgKey;
this.msgParam=msgParam;
this.defaultMsg= defMsg;
}
}
......@@ -2,13 +2,12 @@ package com.neotel.smfcore.common.init;
import com.neotel.smfcore.common.utils.PermissionInitUtil;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.inList.util.InListCache;
import com.neotel.smfcore.core.message.enums.MessageType;
import com.neotel.smfcore.core.message.service.manager.IMessageManager;
import com.neotel.smfcore.core.message.service.po.Message;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
import com.neotel.smfcore.core.order.util.OrderFileWatch;
import com.neotel.smfcore.security.rest.bean.vo.MenuVo;
import com.neotel.smfcore.security.service.manager.IMenuManager;
import com.neotel.smfcore.security.service.manager.IRoleManager;
import com.neotel.smfcore.security.service.manager.IUserManager;
......@@ -16,7 +15,6 @@ import com.neotel.smfcore.security.service.po.Menu;
import com.neotel.smfcore.security.service.po.Role;
import com.neotel.smfcore.security.service.po.User;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.mongodb.core.query.Criteria;
......@@ -48,7 +46,6 @@ public class DataInitManager {
@Autowired
MainTimer mainTimer;
@Autowired
PermissionInitUtil annotationUtil;
......@@ -115,60 +112,6 @@ public class DataInitManager {
}
private int sortValue=0;
private List<Menu> createMenus(Menu pMenu,Menu... subMenus) {
List<Menu> list = new ArrayList<Menu>();
try {
sortValue++;
pMenu.setSubCount(subMenus.length);
pMenu.setMenuSort(sortValue * 10);
if (pMenu.getPath().isEmpty()) {
pMenu.setPath("sys-" + sortValue * 10);
}
pMenu = menuManager.saveMenu(pMenu);
list.add(pMenu);
// list.addAll(createSubPerMenus(pMenu));
if (subMenus.length > 0) {
int i = 0;
for (Menu subm : subMenus
) {
List<Menu> childMenus = new ArrayList<>();
if (subm.getChildren() != null) {
childMenus = new ArrayList<>(subm.getChildren());
}
i++;
int subSort = sortValue * 10 + i;
subm.setMenuSort(subSort);
subm.setSubCount(childMenus.size());
subm.setPid(pMenu.getId());
subm.setChildren(new ArrayList<>());
subm = menuManager.saveMenu(subm);
list.add(subm);
// list.addAll(createSubPerMenus(subm));
for (Menu childMenu : childMenus) {
i++;
subSort = sortValue * 10 + i;
childMenu.setMenuSort(subSort);
childMenu.setSubCount(0);
childMenu.setPid(subm.getId());
childMenu.setChildren(new ArrayList<>());
childMenu = menuManager.saveMenu(childMenu);
list.add(childMenu);
}
}
}
} catch (Exception ex) {
log.error("创建菜单【" + pMenu.getTitle() + "】及其子菜单时出错:" + ex.toString());
}
return list;
}
/**
* 循环创建父级菜单
*/
......@@ -208,6 +151,7 @@ public class DataInitManager {
addNewFunctionMenu(out,"checkOut", "UID出库", "singleOuput", "neolight/singleOuput/index","export1",functionMenuMap);
addNewFunctionMenu(out,"tacticsOuput", "PN出库", "tacticsOuput", "neolight/tacticsOuput/index", "tacticsOuput",functionMenuMap);
addNewFunctionMenu(poutOut,"workOrder", "工单出库","workOrder", "neolight/workOrder/index","orderOut",functionMenuMap);
addNewFunctionMenu(poutOut,"posOutput", "库位出库", "posOutput", "system/posOutput/index", "swagger",functionMenuMap);
addNewFunctionMenu(poutOut, "labelOuput", "物料标签", "labelOuput", "neolight/labelOuput/index", "mgroup",functionMenuMap);
addNewFunctionMenu(poutOut, "materialBox", "料盒操作", "materialBox", "neolight/materialBox/index", "mIbox",functionMenuMap);
......@@ -304,6 +248,7 @@ public class DataInitManager {
"barcode",
"barcodeSetting",
"taskLog",
//"orderSetting",//工单设置
"inOutData", //报表->出入库
"inventory", //报表->库存
"bunker", //设备管理
......@@ -312,8 +257,6 @@ public class DataInitManager {
"peoples", //用户管理
"role" //角色管理
};
}
Map<String, Menu> allMenus = getAllMenuMap();
......
......@@ -3,20 +3,25 @@ package com.neotel.smfcore.common.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.neotel.smfcore.common.exception.ApiException;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.apache.logging.log4j.util.Strings;
import java.io.*;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
......@@ -25,12 +30,12 @@ import java.util.Map.Entry;
/**
* HTTP网络请求
*/
@Slf4j
public class HttpHelper {
// 编码方式
private static final String CONTENT_CHARSET = "UTF-8";
public static String postJson(String url, Map<String, Object> params) throws ApiException {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
// 设置请求参数
......@@ -38,14 +43,15 @@ public class HttpHelper {
ObjectMapper mapper = new ObjectMapper();
try {
String requestBody = mapper.writeValueAsString(params);
httpPost.setEntity(new StringEntity(requestBody));
httpPost.setEntity(new StringEntity(requestBody,CONTENT_CHARSET));
} catch (JsonProcessingException e) {
throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
} catch (UnsupportedEncodingException e) {
} catch (Exception e) {
throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
}
}
try{
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(httpPost);
//System.out.println(response.getStatusLine().getStatusCode() + "\n");
HttpEntity entity = response.getEntity();
......@@ -59,4 +65,49 @@ public class HttpHelper {
}
/**
* 向指定URL发送POST请求
* @param url
* @param paramMap
* @return 响应结果
*/
public static String postParam(String url, Map<String, Object> paramMap) throws ApiException {
// 设置请求参数
List<NameValuePair> params=new ArrayList<NameValuePair>();
if (paramMap != null && !paramMap.isEmpty()) {
//建立一个NameValuePair数组,用于存储欲传送的参数
for (Entry<String, Object> entry : paramMap.entrySet()) {
String value = "";
Object valueObj = entry.getValue();
if(valueObj != null){
if(valueObj instanceof Date){
value = DateUtil.toDateString((Date)valueObj,"yyyyMMdd");
}else{
value = valueObj.toString();
}
}
params.add(new BasicNameValuePair(entry.getKey(),value));
}
}
try {
URI uri = new URIBuilder(url).setParameters(params).build();
log.info("执行MES请求:"+uri.toString());
HttpPost httpPost = new HttpPost(uri);
httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
// httpPost.setEntity(new UrlEncodedFormEntity(params, CONTENT_CHARSET));
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse 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 params to [" + url + "] failed:" + e.getMessage());
}
}
}
......@@ -3,6 +3,8 @@ package com.neotel.smfcore.common.utils;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.api.bean.ApiResult;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
......@@ -129,17 +131,66 @@ public class JsonUtil {
// System.out.println(System.nanoTime());
// System.out.println(System.currentTimeMillis());
// System.out.println(System.currentTimeMillis());
jsonStr = "{\"state\":\"0\",\"msg\":\"鏂欏嵎浣嶆暟涓嶅尮閰??\",\"info\":{\"so\":\"\",\"facility\":\"12334\",\"company\":\"\",\"qty\":\"\",\"soseq\":\"\"}}";
jsonStr = "{\"data\":[{\"Serial\":\"58890\",\"VehicleID\":\"D15\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D44\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D83\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D90\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D98\",\"Status\":\"\"}]}";
Map<String, Object> map = JsonUtil.toMap(jsonStr);
Object data = map.get("data");
if(data != null){
List<Object> dataList = (List)data;
for (Object info : dataList) {
Map<String,String> infoMap = (Map)info;
System.out.println(infoMap.get("Serial"));
// jsonStr = "{\"state\":\"0\",\"msg\":\"鏂欏嵎浣嶆暟涓嶅尮閰??\",\"info\":{\"so\":\"\",\"facility\":\"12334\",\"company\":\"\",\"qty\":\"\",\"soseq\":\"\"}}";
// jsonStr = "{\"data\":[{\"Serial\":\"58890\",\"VehicleID\":\"D15\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D44\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D83\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D90\",\"Status\":\"\"},{\"Serial\":\"58890\",\"VehicleID\":\"D98\",\"Status\":\"\"}]}";
// Map<String, Object> map = JsonUtil.toMap(jsonStr);
// Object data = map.get("data");
// if(data != null){
// List<Object> dataList = (List)data;
// for (Object info : dataList) {
// Map<String,String> infoMap = (Map)info;
// System.out.println(infoMap.get("Serial"));
// }
// }
jsonStr = "{\n" +
" \"code\": 0,\n" +
" \"msg\": \"ok\",\n" +
" \"data\": {\n" +
" \"number\": \"N2020052851182\",\n" +
" \"items\": [\n" +
" {\n" +
" \"partNum\": \"6H.4R710.20M\",\n" +
" \"qty\": 100000\n" +
" },\n" +
" {\n" +
" \"partNum\": \"6S.53654.32D\",\n" +
" \"qty\": 130000\n" +
" }\n" +
" ]\n" +
" }\n" +
"}\n";
jsonStr = "{\"Result\":{\"Table1\":[{\"Reel\":\"2203B22579\",\"Result\":\"OK\"}]},\"Success\":true,\"Error\":null}";
Map<String, Object> resultMap = JsonUtil.toMap(jsonStr);
boolean success = Boolean.valueOf(resultMap.get("Success").toString());
System.out.println(success);
Map<String,Map<String,Object>> resultData = (Map<String, Map<String, Object>>) resultMap.get("Result");
List<Map<String,String>> reelResultList = (List<Map<String, String>>) resultData.get("Table1");
for (Map<String, String> reelMap : reelResultList) {
String reelId = reelMap.get("Reel");
if("2203B22579".equals(reelId)){
String reelResult = reelMap.get("Result").toString();
if("OK".equalsIgnoreCase(reelResult)){
System.out.println("2203B22579");
}else{
throw new ValidateException("smfcore.mesApi.inCheck.ng","MES验证失败:" + reelResult);
}
}
}
// Map<String,Map<String,Object>> resultData = (Map<String, Map<String, Object>>) map.get("Result");
// List<Map<String,String>> reelResultList = (List<Map<String, String>>) resultData.get("Table1");
// for (Map<String, String> reelMap : reelResultList) {
// String reelId = reelMap.get("Reel");
// if("2218B05424".equals(reelId)){
// String reelResult = reelMap.get("result").toString();
// System.out.println(reelResult);
// break;
// }
// }
// System.out.println(map.size());
}
}
package com.neotel.smfcore.core.api;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.api.listener.ISmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.system.service.po.DataLog;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.List;
@Service
@Slf4j
public class SmfApi {
@Autowired
protected DataCache dataCache;
/**
* 入库验证
*/
@Value("${api.inCheckUrl:}")
protected String inCheckUrl = "";
/**
* 入库通知
*/
@Value("${api.inNotifyUrl:}")
protected String inNotifyUrl = "";
/**
* 出库通知
*/
@Value("${api.outNotifyUrl:}")
protected String outNotifyUrl = "";
@Value("${api.orderNotifyUrl:}")
protected String orderNotifyUrl = "";
@Value("${api.fetchInListUrl:}")
protected String fetchInListUrl = "";
/**
* API名称
*/
@Value("${api.name:}")
protected String apiName = "";
@Value("${api.fetchOrderUrl:}")
protected String fetchOrderUrl = "";
@PostConstruct
public void init(){
apiName = dataCache.getConfigCache("api.name",apiName);
log.info("apiName:" + apiName);
inCheckUrl = dataCache.getConfigCache("api.inCheckUrl",inCheckUrl);
inNotifyUrl = dataCache.getConfigCache("api.inNotifyUrl",inNotifyUrl);
outNotifyUrl = dataCache.getConfigCache("api.outNotifyUrl",outNotifyUrl);
orderNotifyUrl = dataCache.getConfigCache("api.orderNotifyUrl",orderNotifyUrl);
fetchInListUrl = dataCache.getConfigCache("api.fetchInListUrl",fetchInListUrl);
fetchOrderUrl = dataCache.getConfigCache("api.fetchOrderUrl",fetchOrderUrl);
}
/**
* 权限验证API列表
*/
protected List<ISmfApiListener> apiListenerList = Lists.newArrayList();
public SmfApi(List<ISmfApiListener> apiList){
for (ISmfApiListener api : apiList) {
apiListenerList.add(api);
}
}
public void onTaskStatusChange(DataLog task) {
for (ISmfApiListener apiListener : apiListenerList) {
if(apiListener.isForThisApi(apiName)){
if(task.isPutInTask()){
if(isUrlExist(inNotifyUrl)){
apiListener.inTaskStatusChange(inNotifyUrl,task);
}
}else{
if(isUrlExist(outNotifyUrl)){
apiListener.outTaskStatusChange(outNotifyUrl,task);
}
}
}
}
}
public void onOrderStatusChange(LiteOrder liteOrder){
if(isUrlExist(orderNotifyUrl)){
for (ISmfApiListener apiListener : apiListenerList) {
if(apiListener.isForThisApi(apiName)){
apiListener.onOrderStatusChange(orderNotifyUrl,liteOrder);
}
}
}
}
public Barcode resolveBarcode(CodeValidateParam param) throws ValidateException{
for (ISmfApiListener apiListener : apiListenerList) {
Barcode responseBarcode = apiListener.resolveBarcode(inCheckUrl,param);
if(responseBarcode != null){
return responseBarcode;
}
}
return null;
}
/**
* 条码解析之前到API验证是否可以入库
* @param codeStr
* @return
* @throws ValidateException
*/
public Barcode canPutInBeforeResolve(String codeStr) throws ValidateException{
if(isUrlExist(inCheckUrl)){
for (ISmfApiListener apiListener : apiListenerList) {
if(apiListener.isForThisApi(apiName)){
Barcode responseBarcode = apiListener.canPutInBeforeResolve(inCheckUrl, codeStr);
if(responseBarcode != null){
return responseBarcode;
}
}
}
}
return null;
}
/**
* 条码解析之后到API验证是否可以入库
*/
public Barcode canPutInAfterResolve(Barcode barcode) throws ValidateException{
if(barcode == null){
return null;
}
if(isUrlExist(inCheckUrl)){
for (ISmfApiListener apiListener : apiListenerList) {
if(apiListener.isForThisApi(apiName)){
Barcode responseBarcode = apiListener.canPutIn(inCheckUrl, barcode);
if(responseBarcode != null){
return responseBarcode;
}
}
}
}
return null;
}
public LiteOrder fetchOrder(String orderNumber, String username){
if(orderNumber == null){
throw new ValidateException("smfcore.fetchOrder.orderNumber.empty","工单号不能为空");
}
if(isUrlExist(fetchOrderUrl)){
for (ISmfApiListener apiListener : apiListenerList) {
if(apiListener.isForThisApi(apiName)){
LiteOrder liteOrder = apiListener.fetchOrder(fetchOrderUrl,orderNumber,username);
if(liteOrder != null){
return liteOrder;
}
}
}
}
return null;
}
/**
* 判断URL是否存在,如果不存在不需要进行发送
* @param url
* @return
*/
protected boolean isUrlExist(String url){
if(Strings.isNotBlank(url)){
return !url.equalsIgnoreCase("none") && !url.equalsIgnoreCase("null");
}
return false;
}
}
package com.neotel.smfcore.core.api.bean;
import com.neotel.smfcore.common.utils.JsonUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApiResult {
/**
* 错误码,0表示正常
*/
private int code=-1;
private String msg="";
private Object data="";
public String getDataStr(){
return JsonUtil.toJsonStr(data);
}
public boolean isOk(){
return code == 0;
}
}
package com.neotel.smfcore.core.device.api;
package com.neotel.smfcore.core.api.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
......
package com.neotel.smfcore.core.api.listener;
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.HttpHelper;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.api.bean.ApiResult;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.inList.service.manager.IInListManager;
import com.neotel.smfcore.core.inList.service.po.InList;
import com.neotel.smfcore.core.inList.service.po.InListItem;
import com.neotel.smfcore.core.inList.util.InListCache;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.system.service.po.DataLog;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
@Slf4j
public abstract class BaseSmfApiListener implements ISmfApiListener {
@Autowired
protected LiteOrderCache liteOrderCache;
@Autowired
protected ILiteOrderManager liteOrderManager;
@Autowired
protected IBarcodeManager barcodeManager;
@Autowired
protected IInListManager inListManager;
@Autowired
protected InListCache inListCache;
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task){
}
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task){
}
@Override
public Barcode resolveBarcode(String url, CodeValidateParam param) throws ValidateException {
return null;
}
@Override
public Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException {
return null;
}
@Override
public void onOrderStatusChange(String orderNotifyUrl, LiteOrder liteOrder) {
}
@Override
public LiteOrder fetchOrder(String fetchOrderUrl, String orderNumber, String username){
return null;
}
@Override
public Barcode canPutInBeforeResolve(String inCheckUrl, String codeStr) throws ValidateException {
return null;
}
}
package com.neotel.smfcore.core.api.listener;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.system.service.po.DataLog;
public interface ISmfApiListener {
/**
* 是否是本API
*/
boolean isForThisApi(String apiName);
/**
* 任务状态改变时调用
*/
void inTaskStatusChange(String inNotifyUrl, DataLog task);
/**
* 出库任务状态改变时通知
* @param outNotifyUrl
* @param task
*/
void outTaskStatusChange(String outNotifyUrl, DataLog task);
/**
* 传入原始条码,API解析条码,注意条码中带有尺寸信息,此方法会在canPutIn方法之前调用,通常料架使用(其他设备会有尺寸信息且会有多个条码所以不适用此方法)
* @param param
* @return
* @throws ValidateException
*/
Barcode resolveBarcode(String inCheckUrl, CodeValidateParam param) throws ValidateException;
/**
* 是否可入库验证
*/
Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException;
/**
* 入库扫条码后在解析之前进行验证
* @param inCheckUrl
* @param codeStr
* @return
* @throws ValidateException
*/
Barcode canPutInBeforeResolve(String inCheckUrl, String codeStr)throws ValidateException;
/**
* 工单状态改变
*/
void onOrderStatusChange(String url, LiteOrder liteOrder);
/**
*
* @param orderNumber
* @param username
* @return
*/
LiteOrder fetchOrder(String url, String orderNumber, String username);
}
......@@ -2,12 +2,15 @@ package com.neotel.smfcore.core.barcode.bean;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
*
......@@ -663,6 +666,7 @@ public class BarcodeRule {
rule ="BATCH;PRODATEyyyy-MM-dd[1:10:-1]EXPD[-1:-4:-1];PN[1:12:-1]SP[13:5:-1]QTY[-1:-5:-1];RI";
codeStr = "L00002019090199951797;E2019-09-01 0365;B8C.R2003.V81506072019090103000;R506072019102200356";
//rule = "1;PN;BATCH;PRODATEyyyyMMdd;EXPDATEyyyyMMdd;QTY;RI";
//codeStr = ";RMK1608-K-B-10300;7B16081217B0;20200506;20250203;5000;000";
......@@ -707,6 +711,20 @@ public class BarcodeRule {
codeStr="=7x8=TJM210308001935&10446500253&10000&2021-01-01&Z573226594&&10446&&R05242021030201596";
rule="RI&PN&QTY&PRODATEyyyy-MM-dd&5&&6&&7";
codeStr = "2720332436";
rule = "PN[0_2:10:0]RI[0_2:10:0]";
//大陆科技
//条码截取规则:
//[)>@06@12S0002@PA2C7363430200@1P28.5823-0813.1@31P2858230813100@12VC11001844@10VCHN-KUNSHAN@2P@20P@6D20220208@14D20220916@30PY@ZN@K5100012719@16K0@V702043942@3SSX00010346575@Q30NAR000@20T2@1TPEax98-02@2T2204-002@1ZOrigin: CN215300@@
//截取补全后条码:00000A2C7363430200@0702043942@SX00010346575 (料号补全至18位,供应商代码补全至10位,Package 13位不变)
//PN:PA2C7363430200,SP:V702043942,RI:3SSX00010346575,QTY:Q30NAR000
//截取补全后条码:00000A2C7363430200@0702043942@SX00010346575 (料号补全至18位,供应商代码补全至10位,Package 13位不变)
codeStr = "[)>@06@12S0002@PA2C4000670322@1P700042761@31PCGA4F2X7R2A103KT5Y2A@12V700042761@10VJPN-AKITA@2P1@20P25gsm@6D20210826@14D20220314@30PN@ZN@K0@16K0@V000000000@3SS100000000068@Q1KGM000@20T1@1T1@2T@1Z1@@";
codeStr = "[)>@06@12S0002@PA2C7363430200@1P28.5823-0813.1@31P2858230813100@12VC11001844@10VCHN-KUNSHAN@2P@20P@6D20220208@14D20220916@30PY@ZN@K5100012719@16K0@V702043942@3SSX00010346575@Q30NAR000@20T2@1TPEax98-02@2T2204-002@1ZOrigin: CN215300@@";
codeStr = "[)>@06@12S0002@PA2C4000670322@1P700042761@31PCGA4F2X7R2A103KT5Y2A@12V700042761@10VJPN-AKITA@2P1@20P25gsm@6D20210826@14D20220314@30PN@ZN@K0@16K0@V000000000@3SS100000000068@Q1KGM000@20T1@1T1@2T@1Z1@@";
rule = "1@2@3@PPN@5@6@7@8@9@10@6DPRODATEyyyyMMdd@14DEXPDATEyyyyMMdd@13@14@15@16@VSP@3SRI@QQTYKGM000@20@1TBATCH@22@23@24@25";
BarcodeRule br = BarcodeRule.newRule(rule);
Barcode b = br.toCodeBean(codeStr).getBarcode();
if(b != null){
......@@ -723,6 +741,18 @@ public class BarcodeRule {
log.info("解析失败");
}
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("RI", "00000A2C4000670322@0000000000@S100000000093");
// params.put("LOC", "SO1069");
// params.put("PN", "A2C4000670322");
// params.put("QTY", 1);
// params.put("PRODATE", "");
// params.put("EXPDATE", "");
// params.put("SP", "000000000");
// params.put("BATCH", "");
// String result = HttpHelper.postParam("https://matlabel-tool.com:4434/SMD_BOXAPI/InBox", params);
// System.out.println(result);
// URI uri = new URI("smb://materialtower:Flextronics1@10.222.42.48/materialtower/re20190822161258_result.txt");
......
......@@ -65,6 +65,8 @@ public class BarcodeDto implements Serializable {
@ApiModelProperty("高度")
private int height=0;
@ApiModelProperty("供应商")
private String provider;
@ApiModelProperty("批次")
......
package com.neotel.smfcore.core.device.api;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
/**
* 出入库权限验证API
* Created by sunke on 2021/7/14.
*/
public interface IOpAuthApi {
/**
* 传入原始条码,API解析条码,注意条码中带有尺寸信息,此方法会在canPutIn方法之前调用,通常料架使用(其他设备会有尺寸信息且会有多个条码所以不适用此方法)
* @param param
* @return
* @throws ValidateException
*/
Barcode resolveBarcode(CodeValidateParam param) throws ValidateException;
/**
* 是否可入库验证
*/
Barcode canPutIn(Barcode barcode) throws ValidateException;
/**
* 是否要出库验证
*/
boolean canCheckout(Barcode barcode) throws ValidateException;
boolean isEnable();
}
......@@ -2,7 +2,6 @@ package com.neotel.smfcore.core.device.handler.impl;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.order.enums.ORDER_COLOR;
......@@ -19,10 +18,6 @@ import java.util.*;
@Slf4j
public class AccShelfHandler extends BaseDeviceHandler{
public AccShelfHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
@Override
public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) {
statusBean.setClientIp(request.getRemoteHost());
......
......@@ -5,6 +5,7 @@ import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.enums.SOLDER_STATUS;
......@@ -13,7 +14,6 @@ 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.Component;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.enums.BOX_STATUS;
import com.neotel.smfcore.core.device.enums.OP;
......@@ -38,8 +38,7 @@ import com.neotel.smfcore.core.system.service.po.Humiture;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.service.manager.IGroupManager;
import com.neotel.smfcore.siemens.SiemensApi;
import com.neotel.smfcore.siemens.bean.LotCheckInfo;
import com.neotel.smfcore.custom.siemens.bean.LotCheckInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -83,7 +82,9 @@ public class BaseDeviceHandler implements IDeviceHandler {
/**
* 权限验证API列表
*/
protected List<IOpAuthApi> opAuthApiList = Lists.newArrayList();
@Autowired
protected SmfApi smfApi;
@Autowired
protected LiteOrderCache liteOrderCache;
......@@ -95,12 +96,6 @@ public class BaseDeviceHandler implements IDeviceHandler {
*/
protected static Map<String, Exception> serverExceptions = new ConcurrentHashMap<>();
public BaseDeviceHandler(List<IOpAuthApi> apiList){
for (IOpAuthApi api : apiList) {
opAuthApiList.add(api);
}
}
/**
* 处理温湿度消息
*/
......@@ -228,66 +223,6 @@ public class BaseDeviceHandler implements IDeviceHandler {
}
}
protected Barcode siemensCheckCode(String codeStr,int type) {
try {
Collection<CodeBean> codeBeans = codeResolve.resolveCodeStr(codeStr, type);
// Collection<CodeBean> codeBeans = codeResolve.resolveCodeStr("=1+0x0-7x8=5YM05960654", COMPONENT_TYPE.COMPONENT);
boolean ok = false;
for (CodeBean codebean :
codeBeans) {
if (codebean.hasReelSizeInfo()) {
LotCheckInfo info = SiemensApi.lotCheckIn(codebean.getCodeStr());
if (info != null && info.isStatus() && ObjectUtil.isNotEmpty(info.getPartnum()) && ObjectUtil.isNotEmpty(info.getQuantity())) {
//查找元器件是否存在
Component component = componentManager.findOneByPN(info.getPartnum());
if (component == null) {
//新建元器件和条码
component = new Component();
component.setPartNumber(info.getPartnum());
component.setAmount(info.getQuantity());
component.setHeight(codebean.getReelHeight());
component.setPlateSize(codebean.getReelWidth());
component = componentManager.saveComponent(component);
log.info("siemensCheckCode 新增 元器件:[" + component.getPartNumber() + "][" + component.getAmount() + "][" + component.getPlateSize() + "]X[" + component.getHeight() + "]");
} else if (component.getAmount() != info.getQuantity()) {
component.setAmount(info.getQuantity());
component = componentManager.saveComponent(component);
log.info("siemensCheckCode 修改 元器件:[" + component.getPartNumber() + "]数量为[" + component.getAmount() + "] ");
}
//判断条码是否存在
Barcode barcode = barcodeManager.get(codebean.getCodeStr());
if (barcode == null) {
barcode = new Barcode();
barcode.setPlateSize(component.getPlateSize());
barcode.setHeight(component.getHeight());
barcode.setBarcode(codebean.getCodeStr());
barcode.setAmount(component.getAmount());
barcode.setFullCode(codebean.getCodeStr());
barcode.setPartNumber(component.getPartNumber());
barcode = barcodeManager.saveBarcode(barcode);
log.info("siemensCheckCode 新增 条码:[" + barcode.getBarcode() + "] ");
}else if(!barcode.getPartNumber().equals(component.getPartNumber())){
barcode.setPlateSize(component.getPlateSize());
barcode.setHeight(component.getHeight());
barcode.setBarcode(codebean.getCodeStr());
barcode.setAmount(component.getAmount());
barcode.setPartNumber(component.getPartNumber());
log.info("siemensCheckCode 修改 条码:[" + barcode.getBarcode() + "] pn为 ["+barcode.getPartNumber()+"] ");
}
return barcode;
}
}
}
} catch (Exception ex) {
log.info("siemensCheckCode 验证条码 [" + codeStr + "] 出错:", ex);
}
return null;
}
/**
* 流水线入库:优先查找空闲BOX中同尺寸的,如果找不到,再查找可入库 BOX(可用且不是出库状态) 同尺寸或比盘尺寸大的仓位
*/
......@@ -298,23 +233,17 @@ public class BaseDeviceHandler implements IDeviceHandler {
type=COMPONENT_TYPE.FIXTURE;
}
String codeStr = statusBean.getCode();
Barcode barcodeSave =null;
try{
barcodeSave = codeResolve.resolveOneValideBarcode(codeStr,type);
}catch (ValidateException validateException) {
barcodeSave = siemensCheckCode(codeStr,type);
if (barcodeSave == null) {
throw validateException;
}
Barcode barcodeSave = smfApi.canPutInBeforeResolve(codeStr);
if(barcodeSave == null){
barcodeSave = codeResolve.resolveOneValideBarcode(codeStr,type);
}
// Barcode barcodeSave = codeResolve.resolveOneValideBarcode(codeStr,type);
//本地难条码是否可以入库
verifyBarcodePutIn(Lists.<Storage>newArrayList(storage), barcodeSave);
//从API验证
barcodeSave = verifyPutInFromApi(barcodeSave);
Barcode barcodeFromApi = smfApi.canPutInAfterResolve(barcodeSave);
if (barcodeSave == null) {
barcodeSave = codeResolve.resolveOneValideBarcode(codeStr,type);
if (barcodeFromApi != null) {
barcodeSave = barcodeFromApi;
}
// //西门子接口验证
......@@ -388,19 +317,6 @@ public class BaseDeviceHandler implements IDeviceHandler {
}
/**
* 从API接口验证条码是否可以入库
*/
protected Barcode verifyPutInFromApi(Barcode barcode) throws ValidateException {
for (IOpAuthApi opAuthApi : opAuthApiList) {
Barcode responseBarcode = opAuthApi.canPutIn(barcode);
if(responseBarcode != null){
return responseBarcode;
}
}
return null;
}
/**
* 验证条码是否可以入库
*/
public Barcode verifyBarcodePutIn(List<Storage> storageList, Barcode barcodeSave) throws ValidateException {
......
package com.neotel.smfcore.core.device.handler.impl;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.storage.enums.DeviceType;
......@@ -13,9 +12,7 @@ import java.util.List;
@Service
@Slf4j
public class LineBoxHandler extends BaseDeviceHandler {
public LineBoxHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
@Override
public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) {
String cid = statusBean.getCid();
......
......@@ -5,7 +5,6 @@ import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.storage.bean.InventoryItem;
......@@ -14,12 +13,11 @@ import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.siemens.SiemensApi;
import com.neotel.smfcore.security.annotation.AnonymousPostMapping;
import com.neotel.smfcore.custom.siemens.SiemensApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
......@@ -34,9 +32,6 @@ import java.util.*;
@Slf4j
public class MimoBoxHandler extends BaseDeviceHandler {
public MimoBoxHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
@Override
public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) {
String cid = statusBean.getCid();
......@@ -76,8 +71,7 @@ public class MimoBoxHandler extends BaseDeviceHandler {
@ApiOperation("单盘出库获取库存的PN")
@PostMapping("/api/mimo/getInventory")
@PreAuthorize("@el.check('storagePos')")
@AnonymousPostMapping("/api/mimo/getInventory")
public List<String> getInventory(@RequestBody Map<String, String> mapValues, HttpServletRequest request) {
String storageId = mapValues.get("storageId");
......@@ -100,8 +94,7 @@ public class MimoBoxHandler extends BaseDeviceHandler {
}
@ApiOperation("根据PN单盘出库")
@PostMapping("/api/mimo/singleOut")
@PreAuthorize("@el.check('storagePos')")
@AnonymousPostMapping("/api/mimo/singleOut")
public ResultBean singleOut(@RequestBody Map<String, String> mapValues, HttpServletRequest request) {
String storageId = mapValues.get("storageId");
......
......@@ -8,7 +8,6 @@ import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.inList.util.InListCache;
......@@ -39,9 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
@RestController
@Slf4j
public class NLMShelfHandler extends BaseDeviceHandler {
public NLMShelfHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
@Autowired
private TokenProvider tokenProvider;
......
......@@ -6,12 +6,10 @@ import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.api.CodeValidateParam;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.inList.util.InListCache;
import com.neotel.smfcore.core.order.enums.ORDER_COLOR;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.storage.service.po.Storage;
......@@ -24,7 +22,6 @@ import com.neotel.smfcore.core.system.websocket.SocketMsg;
import com.neotel.smfcore.core.system.websocket.WebSocketServer;
import com.neotel.smfcore.security.TokenProvider;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.service.po.Group;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -45,9 +42,6 @@ import java.util.*;
public class NLPShelfHandler extends BaseDeviceHandler{
@Autowired
private TokenProvider tokenProvider;
public NLPShelfHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
/**
* 扫码
......@@ -108,14 +102,13 @@ public class NLPShelfHandler extends BaseDeviceHandler{
//从API验证
Barcode verResult = verifyPutInFromApi(barcodeSave);
if(verResult==null){
return testPutIn(loginUser,groupId,storageId, barcodeSave,token);
if(verResult !=null){
barcodeSave = verResult;
}
// resultBean = hellaServiceHandler.checkMaterial(loginUser, groupId, code);
return ResultBean.newOkResult("");
return putIn(loginUser,groupId,storageId, barcodeSave,token);
}
private ResultBean testPutIn(String loginUser, String groupId,String storageId,Barcode barcode,String token) {
private ResultBean putIn(String loginUser, String groupId,String storageId,Barcode barcode,String token) {
// CodeBean codeBean = codeResolve.resolveSingleCode(codeStr);
if (barcode == null || barcode.getBarcode() == null) {
......@@ -171,13 +164,7 @@ public class NLPShelfHandler extends BaseDeviceHandler{
* 从API接口解析条码,通常料架使用(其他设备会有尺寸信息且会有多个条码所以不适用此方法)
*/
protected Barcode resolveBarcodeFromApiForShelf(CodeValidateParam param) throws ValidateException{
for (IOpAuthApi opAuthApi : opAuthApiList) {
Barcode responseBarcode = opAuthApi.resolveBarcode(param);
if(responseBarcode != null){
return responseBarcode;
}
}
return null;
return smfApi.resolveBarcode(param);
}
......
......@@ -6,7 +6,6 @@ import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.NLShelfOperateBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
......@@ -40,9 +39,7 @@ import java.util.concurrent.ConcurrentHashMap;
@RestController
@Slf4j
public class NLShelfHandler extends BaseDeviceHandler {
public NLShelfHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
//上一次入库的库位,用于扫下一条码时灭灯
private static Map<String,NLShelfOperateBean> shelfPutInBeanMap = new ConcurrentHashMap<>();
......
package com.neotel.smfcore.core.device.handler.impl;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
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.Component;
import com.neotel.smfcore.core.device.api.CodeValidateParam;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.kanban.rest.bean.dto.ShelfPosErrorDto;
import com.neotel.smfcore.core.order.enums.ORDER_COLOR;
import com.neotel.smfcore.core.storage.enums.DeviceType;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.bean.OrderSetting;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.websocket.MsgType;
import com.neotel.smfcore.core.system.websocket.SocketMsg;
import com.neotel.smfcore.core.system.websocket.WebSocketServer;
import com.neotel.smfcore.hella.tcp.command.HellaReqCommand;
import com.neotel.smfcore.hella.tcp.command.HellaRespCommand;
import com.neotel.smfcore.security.TokenProvider;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.service.po.Group;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.*;
/**
* 感应料架
* Created by sunke on 2021/7/12.
......@@ -60,9 +17,6 @@ import java.util.*;
public class SensorShelfHandler extends BaseDeviceHandler {
@Autowired
private TokenProvider tokenProvider;
public SensorShelfHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
// /**
// * 扫码
......
package com.neotel.smfcore.core.device.handler.impl;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.storage.enums.DeviceType;
......@@ -15,9 +14,7 @@ import java.util.List;
@Service
@Slf4j
public class SisoBoxHandler extends BaseDeviceHandler {
public SisoBoxHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
@Override
public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) {
statusBean.setClientIp(request.getRemoteHost());
......
......@@ -10,7 +10,6 @@ import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
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.Component;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.BOX_STATUS;
......@@ -44,10 +43,6 @@ public class SpBoxHandler extends BaseDeviceHandler {
@Autowired
private IComponentManager componentManager;
public SpBoxHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
@Override
public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) {
statusBean.setClientIp(request.getRemoteHost());
......
......@@ -2,7 +2,6 @@ package com.neotel.smfcore.core.device.handler.impl;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.BOX_STATUS;
......@@ -34,10 +33,6 @@ public class VerticalBoxHandler extends BaseDeviceHandler {
*/
private Map<String,DataLog> operateTaskMap = new ConcurrentHashMap<>();
public VerticalBoxHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
@Override
public StatusBean handleClientRequest(StatusBean statusBean, HttpServletRequest request) {
statusBean.setClientIp(request.getRemoteHost());
......
......@@ -6,7 +6,6 @@ import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.NLShelfOperateBean;
import com.neotel.smfcore.core.device.bean.VirtualOperateBean;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
......@@ -49,10 +48,6 @@ public class VirtualBoxHandler extends BaseDeviceHandler{
@Autowired
private ILiteOrderManager liteOrderManager;
public VirtualBoxHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
/**
* 扫码
*/
......
......@@ -7,7 +7,6 @@ import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.NLShelfOperateBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
......@@ -46,10 +45,6 @@ import java.util.concurrent.ConcurrentHashMap;
@Api(tags = "BOX: XLC方仓")
@Slf4j
public class XLCBoxHandler extends BaseDeviceHandler {
public XLCBoxHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
@Autowired
private IStoragePosManager storagePosManager;
......
......@@ -2,7 +2,6 @@ package com.neotel.smfcore.core.device.handler.impl;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.BOX_STATUS;
......@@ -33,10 +32,6 @@ public class XlBoxHandler extends BaseDeviceHandler {
*/
private Map<String,DataLog> operateTaskMap = new ConcurrentHashMap<>();
public XlBoxHandler(List<IOpAuthApi> apiList) {
super(apiList);
}
/**
* 获取当前正在执行的任务
*/
......
......@@ -441,8 +441,7 @@ public class DeviceController {
if(posInfoList!=null&&posInfoList.size()>0){
int row = 1;
int newRowCount = 0;
for (PosInfo pos :
posInfoList) {
for (PosInfo pos : posInfoList) {
row++;
if (ObjectUtil.isEmpty(pos.getPos())) {
......
......@@ -154,24 +154,18 @@ public class DataCache {
log.info("updateCache ["+cacheKey+"]=["+value+"]");
}
public String GetConfigCache(String cacheKey ,String configKey,String configValue) {
if (StringUtils.isEmpty(configKey) || StringUtils.isEmpty(cacheKey)) {
/**
* 获取配置信息同时插入数据库,如果配置值为空,使用数据库配置的值
*/
public String getConfigCache(String configKey,String configValue) {
if(Strings.isNullOrEmpty(configValue)){
//没有配置,使用数据库的配置值
return getCache(configKey);
}else{
//有配置值,将配置值写入数据库
updateCache(configKey,configValue);
return configValue;
}
if (StringUtils.isEmpty(configValue)) {
String cacheValue = getCache(cacheKey);
if (cacheValue == null || StringUtils.isEmpty(cacheValue)) {
return configValue;
}
configValue = cacheValue;
Map<String, Object> updateMap = new HashMap<>();
updateMap.put(configKey, configValue);
YmlUpdateUtil.updateYamlFile(updateMap);
} else {
updateCache(cacheKey, configValue);
}
return configValue;
}
/**
......
......@@ -26,6 +26,7 @@ import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.service.po.Humiture;
import com.neotel.smfcore.core.system.util.DevicesStatusUtil;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousPutMapping;
import com.neotel.smfcore.security.service.manager.IGroupManager;
import com.neotel.smfcore.security.service.manager.impl.GroupManagerImpl;
import com.neotel.smfcore.security.service.manager.impl.UserManagerImpl;
......@@ -258,8 +259,7 @@ public class BoxKanbanController {
}
@ApiOperation("保存界面的一些操作")
@PutMapping("/saveOp")
@PreAuthorize("@el.check('storagePos:edit')")
@AnonymousPutMapping("/saveOp")
public ResultBean saveOp(@RequestBody Map<String,String> params) {
String cid = params.get("cid");
if(!Strings.isNullOrEmpty(cid)){
......
......@@ -7,12 +7,15 @@ import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.*;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.rest.bean.dto.BarcodeDto;
import com.neotel.smfcore.core.barcode.rest.bean.mapstruct.BarcodeMapper;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
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.order.LiteOrderCache;
import com.neotel.smfcore.core.order.enums.LITEORDER_STATUS;
import com.neotel.smfcore.core.order.rest.bean.dto.OrderDto;
......@@ -24,6 +27,8 @@ 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.LiteOrderItem;
import com.neotel.smfcore.core.order.util.OrderFileWatch;
import com.neotel.smfcore.core.system.bean.MSDAppendInfo;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.bean.FileProperties;
......@@ -101,6 +106,9 @@ public class OrderController {
@Autowired
TaskService taskService;
@Autowired
SmfApi smfApi;
// @ApiOperation("导出用户数据")
// @GetMapping(value = "/download")
// @PreAuthorize("@el.check('user:list')")
......@@ -223,12 +231,8 @@ public class OrderController {
if (orderNo == null) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"orderNo"});
}
String result = liteOrderCache.orderItemSupplementOut(orderNo, orderItemId);
if (ObjectUtil.isEmpty(result)) {
return ResultBean.newOkResult(result);
} else {
return ResultBean.newErrorResult(-1, result, result);
}
ResultBean result = liteOrderCache.orderItemSupplementOut(orderNo, orderItemId);
return result;
}
@ApiOperation("查询工单")
......@@ -431,7 +435,7 @@ public class OrderController {
throw new ValidateException("smfcore.error.virtualOut.noItem", "工单{0}中未找到对应的PN或物料编号", new String[]{liteOrder.getOrderNo() + ""});
} else {
//增加一条出库完成记录
taskService.addVirtualOutToFinished(liteOrder, barcode, num, SecurityUtils.getCurrentUsername());
addVirtualOutToFinished(liteOrder, barcode, num, SecurityUtils.getCurrentUsername());
findItem.setOutNum(findItem.getOutNum() + num);
findItem.setTotalOutNum(findItem.getTotalOutNum() + num);
findItem.setOutReelCount(findItem.getOutReelCount() + 1);
......@@ -460,6 +464,52 @@ public class OrderController {
return ResultBean.newOkResult("");
}
public void addVirtualOutToFinished( LiteOrder liteOrder, Barcode barcode,Integer num, String opUser) {
try {
DataLog dataLog = new DataLog();
dataLog.setPartNumber(barcode.getPartNumber());
dataLog.setBarcode(barcode.getBarcode());
dataLog.setNum(num);
dataLog.setMemo(barcode.getMemo());
dataLog.setPutInDate(barcode.getPutInDate());
MSDAppendInfo msdAppendInfo = new MSDAppendInfo();
msdAppendInfo.setMsl(barcode.getMsl());
msdAppendInfo.setOpenTime(barcode.getOpenTime());
msdAppendInfo.setThickness(barcode.getThickness());
dataLog.setMsdAppendInfo(msdAppendInfo);
dataLog.setCid("");
dataLog.setStorageId("");
dataLog.setStorageName("OutLine");
dataLog.setPosId("");
dataLog.setPosName("OutLine");
//操作人,工单信息
dataLog.setOperator(opUser);
dataLog.setSourceName(liteOrder.getOrderNo());
dataLog.setSourceId(liteOrder.getId());
log.info(opUser + "虚拟回仓: PN【"+barcode.getPartNumber()+"】条码【" + barcode.getBarcode() + "】 工单号【" + liteOrder.getOrderNo() + "】数量【" + num + "】");
dataLog.setType(OP.CHECKOUT);
barcode.setUsed(true);
barcode.setUsedDate(new Date());
//仓位状态
barcode.setCheckOutDate(new Date(), dataLog.getOperator());
barcode.setPosName("");
barcodeManager.save(barcode);
dataLog.setStatus(OP_STATUS.FINISHED.name());
taskService.updateFinishedTask(dataLog);
} catch (Exception e) {
log.error("addVirtualOutToFinished Error:", e);
}
}
private LiteOrderItem findVirtualItem(LiteOrder liteOrder, Barcode barcode, boolean checkNum) {
LiteOrderItem findItem = null;
for (LiteOrderItem item :
......@@ -481,4 +531,22 @@ public class OrderController {
return findItem;
}
@ApiOperation("根据工单号获取工单")
@PostMapping(value = "/fetchOrder")
@PreAuthorize("@el.check('workOrder')")
public ResultBean fetchOrder(@RequestBody Map<String, String> mapValues) {
String orderNo = mapValues.get("orderNo");
if (orderNo == null) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"orderNo"});
}
LiteOrder liteOrder = smfApi.fetchOrder(orderNo,SecurityUtils.getCurrentUsername());
if(liteOrder == null){
throw new ValidateException("smfcore.api.noUrl", "未配置API地址");
}
OrderDto dto = orderMapper.toDto(liteOrder);
return ResultBean.newOkResult(dto);
}
}
......@@ -17,10 +17,16 @@ public class OrderDto implements Serializable {
@ApiModelProperty(value = "ID")
private String id;
/**
* 单号
* 需求单号
*/
@ApiModelProperty("单号")
@ApiModelProperty("需求单号")
private String orderNo;
/**
* 工单号
*/
@ApiModelProperty("工单号")
private String so = "";
/**
* 当前任务盘数
*/
......
......@@ -35,6 +35,18 @@ public class OrderItemDto {
@ApiModelProperty("站位信息")
private String feederInfo = "";
/**
* 台车号
*/
@ApiModelProperty("台车号")
private String tableNo = "";
/**
* 面别
*/
@ApiModelProperty("面别")
private String side = "";
@ApiModelProperty("库存信息")
@Transient
private int inventoryNum = 0;
......
......@@ -6,5 +6,5 @@ import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import java.util.List;
public interface ILiteOrderItemManager extends IBaseManager<LiteOrderItem> {
List<LiteOrderItem> findOrderItems(String orderNo);
List<LiteOrderItem> findOrderItems(String orderId);
}
......@@ -22,8 +22,8 @@ public class LiteOrderItemManagerImpl implements ILiteOrderItemManager {
private ILiteOrderItemDao liteOrderItemDao;
@Override
public List<LiteOrderItem> findOrderItems(String orderNo) {
return liteOrderItemDao.findListByCondition(new String[]{"orderNo"}, new String[]{orderNo});
public List<LiteOrderItem> findOrderItems(String orderId) {
return liteOrderItemDao.findListByCondition(new String[]{"orderId"}, new String[]{orderId});
}
@Override
......
......@@ -36,7 +36,7 @@ public class LiteOrderManagerImpl implements ILiteOrderManager {
public LiteOrder findByOrderNo(String orderNo) {
LiteOrder order= liteOrderDao.findOneByCondition(new String[] {"orderNo"}, new String[] {orderNo});
if(order!=null&& order.getOrderItems()==null){
List<LiteOrderItem> items=liteOrderItemManager.findOrderItems(orderNo);
List<LiteOrderItem> items=liteOrderItemManager.findOrderItems(order.getId());
order.setOrderItems(items);
}
return order;
......@@ -46,7 +46,7 @@ public class LiteOrderManagerImpl implements ILiteOrderManager {
public LiteOrder get(String id) {
LiteOrder order= liteOrderDao.findOneById(id);
if(order!=null&& order.getOrderItems()==null){
List<LiteOrderItem> items=liteOrderItemManager.findOrderItems(order.getOrderNo());
List<LiteOrderItem> items=liteOrderItemManager.findOrderItems(order.getId());
order.setOrderItems(items);
}
return order;
......@@ -63,16 +63,16 @@ public class LiteOrderManagerImpl implements ILiteOrderManager {
}
@Override
public LiteOrder createWithItems(LiteOrder liteOrder) throws ValidateException {
liteOrder = save(liteOrder);
List<LiteOrderItem> items = Lists.newArrayList();
for (LiteOrderItem liteOrderItem : liteOrder.getOrderItems()) {
liteOrderItem.setOrderNo(liteOrder.getOrderNo());
liteOrderItem.setOrderId(liteOrder.getId());
liteOrderItem = liteOrderItemManager.save(liteOrderItem);
items.add(liteOrderItem);
}
if(liteOrder.getSDate()==null){
liteOrder.setSdate(new Date(System.currentTimeMillis()));
}
liteOrder = save(liteOrder);
liteOrder.setOrderItems(items);
return liteOrder;
}
......@@ -86,7 +86,7 @@ public class LiteOrderManagerImpl implements ILiteOrderManager {
for (LiteOrder order : orders
) {
if (order != null && order.getOrderItems() == null) {
List<LiteOrderItem> items = liteOrderItemManager.findOrderItems(order.getOrderNo());
List<LiteOrderItem> items = liteOrderItemManager.findOrderItems(order.getId());
order.setOrderItems(items);
}
}
......
......@@ -67,9 +67,6 @@ public class LiteOrder extends BasePo implements Serializable {
*/
private int status = LITEORDER_STATUS.NEW;
/**
* 出库状态, 2表示已完成
*/
private boolean closed = false;
......@@ -118,23 +115,6 @@ public class LiteOrder extends BasePo implements Serializable {
}
/**
* 结束当前的任务
*/
public void finishedTasks(){
if(isOutOne()){
// setStatus(LITEORDER_STATUS.ONE_FINISHED);
setClosed(true);
}else if(isOutBom()){
setStatus(LITEORDER_STATUS.BOM_FINISHED);
}else if(isOutTails()){
// setStatus(LITEORDER_STATUS.TAILS_FINISHED);
setClosed(true);
}
setTaskFinishedTime(System.currentTimeMillis());
}
/**
* 是否正在出首套料
* @return
*/
......
......@@ -53,14 +53,14 @@ public class LiteOrderItem extends BasePo implements Serializable ,Comparable<Li
/**
* 订单信息
*/
private String orderNo = "";
private String orderId = "";
/**
* 站位编号,料架工单出库时,亮灯指引功能排序
*/
private Integer slotNum=0;
/**
* 站位信息
* 站位
*/
private String feederInfo = "";
......@@ -70,7 +70,15 @@ public class LiteOrderItem extends BasePo implements Serializable ,Comparable<Li
@Transient
private int inventoryNum = 0;
/**
* 台车号
*/
private String tableNo = "";
/**
* 面别
*/
private String side = "";
/**
* 出库是否满足要求,已出库数量大于需求数量
......
......@@ -11,7 +11,6 @@ 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.LiteOrderItem;
import com.neotel.smfcore.core.system.bean.OrderSetting;
import com.neotel.smfcore.core.system.listener.ITaskListener;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
......
......@@ -4,7 +4,9 @@ import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.util.DataCache;
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.StoragePos;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
......@@ -33,6 +35,8 @@ public class MesApiController {
protected TaskService taskService;
@Autowired
IStoragePosManager storagePosManager;
@Autowired
protected DataCache dataCache;
//http://localhost/myproject/rest/api/v2/mes/inventory?LOC=1
@ApiOperation("查询有料仓位")
@RequestMapping(value = "/inventory")
......@@ -62,6 +66,15 @@ public class MesApiController {
item.put("PN",barcode.getPartNumber());
item.put("QTY",barcode.getAmount());
item.put("LOC", pos.getStorageId());
Storage storage = dataCache.getStorageById(pos.getStorageId());
String cid = "";
String name = "";
if(storage != null){
cid = storage.getCid();
name = storage.getName();
}
item.put("CID", cid);
item.put("CNAME", name);
ReelBarCodes.add(item);
}
return ReelBarCodes /*+ dataCache.getSettings().getNotifyApiUrl()*/;
......
......@@ -256,20 +256,11 @@ public class StorageController {
List<Storage> storages = storageDao.findByQuery(querySto);
String delStoName = "";
for (Storage storage : storages) {
//验证料仓是否有料
Query query = new Query(Criteria.where("storageId").is(storage.getId()));
List<StoragePos> posList = storagePosManager.findByQuery(query);
if(posList!=null) {
for (StoragePos pos : posList
) {
if (pos.getBarcode() == null || pos.getBarcode().equals("")) {
} else {
throw new ValidateException("smfcore.posIsused","料仓[{0}]的库位[{1}}]有料[{2}],删除失败",new String[]{ storage.getName() ,pos.getPosName(),pos.getBarcode().getBarcode()});
// throw new BadRequestException("料仓[" + storage.getName() + "]的库位[" + pos.getPosName() + "]有料[" + pos.getBarcode() + "],删除失败");
}
}
if(posList!=null && !posList.isEmpty()) {
throw new ValidateException("smfcore.storage.posNotEmpty","料仓[{0}]有关联库位,删除失败",new String[]{ storage.getName()});
}
delStoName += "[" + storage.getName() + "]";
}
......
......@@ -5,12 +5,9 @@ import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.rest.bean.dto.CodeDto;
import com.neotel.smfcore.core.barcode.rest.bean.mapstruct.CodeMapper;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
......@@ -29,7 +26,7 @@ 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.StoragePos;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.siemens.SiemensApi;
import com.neotel.smfcore.custom.siemens.SiemensApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
......@@ -48,7 +45,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.regex.Pattern;
@Slf4j
@RestController
......
......@@ -77,4 +77,6 @@ public class StoragePosDto implements Serializable {
@ApiModelProperty("组名称")
private String groupName = "";
}
package com.neotel.smfcore.core.system.listener;
import com.neotel.smfcore.core.system.service.po.DataLog;
import org.springframework.stereotype.Service;
/**
* Created by sunke on 2021/7/12.
*/
@Service
public class ApiListener implements ITaskListener {
@Override
public void onTaskStatusChange(DataLog task) {
}
}
package com.neotel.smfcore.core.system.listener;
import com.neotel.smfcore.core.system.service.po.DataLog;
/**
* Created by sunke on 2021/7/12.
*/
public interface ITaskListener {
void onTaskStatusChange(DataLog task);
}
......@@ -9,6 +9,8 @@ import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.system.rest.bean.dto.ClientSettingDto;
import com.neotel.smfcore.core.system.rest.bean.dto.SysSettingsDto;
import com.neotel.smfcore.core.system.service.po.Settings;
import com.neotel.smfcore.security.annotation.AnonymousGetMapping;
import com.neotel.smfcore.security.annotation.AnonymousPutMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
......@@ -29,8 +31,7 @@ public class ClientSettingsController {
DataCache dataCache;
@ApiOperation("获取界面设置")
@GetMapping()
@PreAuthorize("@el.check('sysSetting')")
@AnonymousGetMapping()
public ClientSettingDto getSettings(ClientSettingDto settingDto) {
if (settingDto == null || ObjectUtil.isEmpty(settingDto.getKey()) ) {
......@@ -53,8 +54,7 @@ public class ClientSettingsController {
}
@ApiOperation("修改界面设置")
@PutMapping()
@PreAuthorize("@el.check('sysSetting')")
@AnonymousPutMapping()
public ResultBean updateSettings(@RequestBody ClientSettingDto settingDto) {
if (settingDto == null || ObjectUtil.isEmpty(settingDto.getKey()) || ObjectUtil.isEmpty(settingDto.getValue())) {
......
......@@ -16,6 +16,8 @@ import com.neotel.smfcore.core.system.rest.bean.query.TaskQueryCondition;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousDeleteMapping;
import com.neotel.smfcore.security.annotation.AnonymousGetMapping;
import com.neotel.smfcore.security.service.manager.IUserManager;
import com.neotel.smfcore.security.service.po.User;
import io.swagger.annotations.Api;
......@@ -93,8 +95,7 @@ public class TaskController {
}
@ApiOperation("获取某个分组队列中的任务")
@GetMapping("/{groupId}")
@PreAuthorize("@el.check('taskLog')")
@AnonymousGetMapping("/{groupId}")
public List<TaskDto> groupTask(@PathVariable String groupId){
if(groupId!=null&&groupId.equals("-1")){
groupId="";
......@@ -107,8 +108,7 @@ public class TaskController {
}
@ApiOperation("获取队列中的任务")
@GetMapping
@PreAuthorize("@el.check('taskLog')")
@AnonymousGetMapping
public List<TaskDto> filterTask(TaskQueryCondition criteria,HttpServletRequest request){
String groupId = criteria.getGroupId();
String[] cids = criteria.getCids();
......@@ -157,9 +157,7 @@ public class TaskController {
}
@ApiOperation("取消任务")
@DeleteMapping
// @PreAuthorize("@el.check('task:cancel')")
@PreAuthorize("@el.check('taskLog')")
@AnonymousDeleteMapping
public ResponseEntity<Object> cancel(@RequestBody Set<String> ids){
for (String taskId : ids) {
DataLog task = dataLogManager.get(taskId);
......
......@@ -2,6 +2,7 @@ package com.neotel.smfcore.core.system.util;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Maps;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.message.enums.MessageType;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
......@@ -115,11 +116,13 @@ public class DevicesStatusUtil {
*存储料仓 出入库的一些操作,KEY=cid
*/
private static Map<String,Map<String, String>> storageOpMap = new ConcurrentHashMap<>();
/**
* 设备上一次的操作人,key为cid, value为用户名
*/
private static Map<String,String> lastOpUserMap = new ConcurrentHashMap<>();
/**
* 添加操作
* @param cid
* @param opKey
* @param opValue
*/
public static void addOp(String cid, String opKey, String opValue){
if(opValue == null){
......@@ -129,11 +132,20 @@ public class DevicesStatusUtil {
if(opMap == null){
opMap = new ConcurrentHashMap<>();
}
String operator = SecurityUtils.getLoginUsername();
lastOpUserMap.put(cid,operator);
opMap.put(opKey, opValue);
storageOpMap.put(cid, opMap);
}
/**
* 获取设备的上一个操作人
*/
public static String getLastOpUsername(String cid){
return lastOpUserMap.get(cid);
}
/**
* 追加操作
* @param cid
* @param opKey
......
......@@ -8,7 +8,7 @@ import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
......@@ -16,6 +16,7 @@ import com.neotel.smfcore.core.device.bean.StatusBean;
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.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.storage.enums.CHECKOUT_TYPE;
import com.neotel.smfcore.core.storage.rest.dto.TacticsOutDto;
......@@ -23,7 +24,6 @@ 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.StoragePos;
import com.neotel.smfcore.core.system.bean.MSDAppendInfo;
import com.neotel.smfcore.core.system.listener.ITaskListener;
import com.neotel.smfcore.core.system.service.dao.IDataLogDao;
import com.neotel.smfcore.core.system.service.po.DataLog;
import lombok.extern.slf4j.Slf4j;
......@@ -48,9 +48,11 @@ public class TaskService {
@Autowired
protected IStoragePosManager storagePosManager;
@Autowired
protected LiteOrderCache liteOrderCache;
@Autowired
private List<ITaskListener> taskListenerList = new ArrayList<>();
private SmfApi smfApi;
/**
* 任务队列,Key 为dataLog的ID,value 为本区域待执行的任务
......@@ -82,7 +84,10 @@ public class TaskService {
barcode.updateSluggishTime(dataCache.getPNsluggishDay(barcode.getPartNumber()));
barcodeManager.saveBarcode(barcode);
}
String loginUser = SecurityUtils.getLoginUsername();
String loginUser = DevicesStatusUtil.getLastOpUsername(storage.getCid());
if(Strings.isNullOrEmpty(loginUser)){
loginUser = SecurityUtils.getLoginUsername();
}
task.setOperator(loginUser);
task = updateQueueTask(task);
log.info("cid:[" + storage.getCid() + "] barcode:[" + barcode.getBarcode() + "] partNumber:[" + task.getPartNumber() + "]位置[" + storagePos.getPosName() + "]的入库操作成功加入队列");
......@@ -139,9 +144,8 @@ public class TaskService {
* @param task
*/
private void tiggerTaskChangeListener(DataLog task) {
for (ITaskListener taskListener : taskListenerList) {
taskListener.onTaskStatusChange(task);
}
liteOrderCache.onTaskStatusChange(task);
smfApi.onTaskStatusChange(task);
}
/**
......@@ -821,57 +825,6 @@ public class TaskService {
}
}
public void addVirtualOutToFinished( LiteOrder liteOrder, Barcode barcode,Integer num, String opUser) {
try {
Collection<DataLog> allTasks = taskMap.values();
DataLog dataLog = new DataLog();
dataLog.setPartNumber(barcode.getPartNumber());
dataLog.setBarcode(barcode.getBarcode());
dataLog.setNum(num);
dataLog.setMemo(barcode.getMemo());
dataLog.setPutInDate(barcode.getPutInDate());
MSDAppendInfo msdAppendInfo = new MSDAppendInfo();
msdAppendInfo.setMsl(barcode.getMsl());
msdAppendInfo.setOpenTime(barcode.getOpenTime());
msdAppendInfo.setThickness(barcode.getThickness());
dataLog.setMsdAppendInfo(msdAppendInfo);
dataLog.setCid("");
dataLog.setStorageId("");
dataLog.setStorageName("OutLine");
dataLog.setPosId("");
dataLog.setPosName("OutLine");
dataLog.setStatus(OP_STATUS.WAIT.name());
//操作人,工单信息
dataLog.setOperator(opUser);
dataLog.setSourceName(liteOrder.getOrderNo());
dataLog.setSourceId(liteOrder.getId());
log.info(opUser + "虚拟回仓: PN【"+barcode.getPartNumber()+"】条码【" + barcode.getBarcode() + "】 工单号【" + liteOrder.getOrderNo() + "】数量【" + num + "】");
dataLog.setType(OP.CHECKOUT);
barcode.setUsed(true);
barcode.setUsedDate(new Date());
//仓位状态
barcode.setCheckOutDate(new Date(), dataLog.getOperator());
barcode.setPosName("");
barcodeManager.save(barcode);
dataLog.setStatus(OP_STATUS.FINISHED.name());
dataLog = dataLogDao.save(dataLog);
theFinishedTaskMap.put(dataLog.getBarcode(), dataLog);
} catch (Exception e) {
log.error("addVirtualOutToFinished Error:", e);
}
}
/**
* 出库完成
*/
......
package com.neotel.smfcore.custom.dalu;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.core.api.listener.DefaultSmfApiListener;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.system.service.po.DataLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Service
@Slf4j
public class DaLuApi extends DefaultSmfApiListener {
@Autowired
private IComponentManager componentManager;
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("DaLu");
}
/**
* 1092感应料架对条码进行补全
* PN:PA2C7363430200,SP:V702043942,RI:3SSX00010346575,QTY:Q30NAR000
* 截取补全后条码:00000A2C7363430200@0702043942@SX00010346575 (料号补全至18位,供应商代码补全至10位,Package 13位不变)
* @param barcode
* @return
* @throws ValidateException
*/
@Override
public Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException {
String pn = barcode.getPartNumber();
String newPn = pn;
int pnLength = pn.length();
for (int i = 0; i < 18 - pnLength; i++) {
newPn = "0"+newPn;
}
String sp = barcode.getProvider();
String newSp = sp;
int spLength = sp.length();
for (int i = 0; i < 10 - spLength; i++) {
newSp = "0" + newSp;
}
String reelId = newPn + "@" + newSp + "@" + barcode.getBarcode();
log.info("开始对条码进行补全,料号由"+pn+"补全为"+newPn+", 供应商由"+sp+"补全为"+newSp +" 补全后唯一码为:" + reelId);
Barcode dbBarcode = barcodeManager.findByBarcode(reelId);
if(dbBarcode == null){
//修改原来的条码
log.info("修改原来条码信息为:" + reelId);
barcode.setBarcode(reelId);
barcode = barcodeManager.saveBarcode(barcode);
}else{
//使用数据库的,删除生成的
log.info("删除原来条码信息:" + barcode.getBarcode()+"["+barcode.getId()+"]");
barcodeManager.delete(barcode);
barcode = dbBarcode;
}
return barcode;
}
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if (!Strings.isNullOrEmpty(inNotifyUrl) && task.isFinished()) {
try {
log.info("向 MES(" + inNotifyUrl + ") 通知【" + task.getBarcode() + "】的入库信息");
Barcode barcode = barcodeManager.findByBarcode(task.getBarcode());
Map<String, Object> params = new HashMap<String, Object>();
params.put("RI", task.getBarcode());
params.put("LOC", task.getPosName());
//params.put("NAME", task.getStorageName());
if (barcode != null) {
params.put("PN", barcode.getPartNumber());
params.put("QTY", barcode.getAmount());
Date produceDate = barcode.getProduceDate();
params.put("PRODATE", produceDate);
params.put("EXPDATE", barcode.getExpireDate());
params.put("SP", barcode.getProvider());
params.put("BATCH", barcode.getAmount());
}
String result = HttpHelper.postParam(inNotifyUrl, params);
log.info("收到MES [" + inNotifyUrl + "] 的关于[" + barcode.getBarcode() + "]入库通知的反馈信息:" + result);
} catch (Exception e) {
log.error("向 MES [" + inNotifyUrl + "]入库通知【" + task.getBarcode() + "】的信息出错", e);
}
}
}
@Override
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if (!Strings.isNullOrEmpty(outNotifyUrl) && task.isFinished()) {
try {
log.info("向 MES 通知【" + task.getBarcode() + "】的出库信息");
Map<String, Object> params = new HashMap<String, Object>();
params.put("RI", task.getBarcode());
String result = HttpHelper.postParam(outNotifyUrl, params);
log.info("收到MES [" + outNotifyUrl + "]的关于[" + task.getBarcode() + "]出库通知的反馈信息:" + result);
} catch (Exception e) {
log.error("向 MES [" + outNotifyUrl + "]出库通知【" + task.getBarcode() + "】的信息出错", e);
}
}
}
}
package com.neotel.smfcore.hella.handler;
package com.neotel.smfcore.custom.hella.handler;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.api.CodeValidateParam;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.hella.tcp.HellaTcpClient;
import com.neotel.smfcore.hella.tcp.command.HellaReqCommand;
import com.neotel.smfcore.hella.tcp.command.HellaRespCommand;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.custom.hella.tcp.HellaTcpClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class HellaApiHandler implements IOpAuthApi {
public class HellaApiHandler extends BaseSmfApiListener {
@Autowired
private HellaServiceHandler hellaServiceHandler;
@Override
public Barcode resolveBarcode(CodeValidateParam param) throws ValidateException {
if (!isEnable()) {
@Override
public Barcode resolveBarcode(String url, CodeValidateParam param) throws ValidateException {
if (!HellaTcpClient.isEnable()) {
return null;
}
hellaServiceHandler.checkMaterial(param);
......@@ -33,23 +26,15 @@ public class HellaApiHandler implements IOpAuthApi {
}
@Override
public Barcode canPutIn(Barcode barcode) throws ValidateException {
if (!isEnable()) {
return null;
}
return barcode;
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("Hella");
}
@Override
public boolean canCheckout(Barcode barcode) throws ValidateException {
if(!isEnable()){
return false;
public Barcode canPutIn(String inCheckUrl, Barcode barcode) throws ValidateException {
if (!HellaTcpClient.isEnable()) {
return null;
}
return false;
}
@Override
public boolean isEnable() {
return HellaTcpClient.isEnable();
return barcode;
}
}
package com.neotel.smfcore.hella.handler;
package com.neotel.smfcore.custom.hella.handler;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
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.Component;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.api.CodeValidateParam;
import com.neotel.smfcore.core.api.bean.CodeValidateParam;
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;
......@@ -24,24 +25,23 @@ import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Label;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.listener.ITaskListener;
import com.neotel.smfcore.core.system.service.dao.IDataLogDao;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.core.system.websocket.MsgType;
import com.neotel.smfcore.core.system.websocket.SocketMsg;
import com.neotel.smfcore.core.system.websocket.WebSocketServer;
import com.neotel.smfcore.hella.tcp.HellaTcpClient;
import com.neotel.smfcore.hella.tcp.command.HellaReqCommand;
import com.neotel.smfcore.hella.tcp.command.HellaRespCommand;
import com.neotel.smfcore.custom.hella.tcp.HellaTcpClient;
import com.neotel.smfcore.custom.hella.tcp.command.HellaReqCommand;
import com.neotel.smfcore.custom.hella.tcp.command.HellaRespCommand;
import com.neotel.smfcore.security.service.manager.IGroupManager;
import com.neotel.smfcore.security.service.po.Group;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.Strings;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.service.IoHandler;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.FilterEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -53,7 +53,7 @@ import java.util.concurrent.atomic.AtomicLong;
* Created by sunke on 2021/5/26.
*/
@Service
public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListener {
public class HellaServiceHandler extends BaseSmfApiListener implements IoHandler {
@Autowired
private IComponentManager componentManager;
......@@ -62,9 +62,6 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen
private IBarcodeManager barcodeManager;
@Autowired
private IDataLogDao dataLogDao;
@Autowired
private TaskService taskService;
@Autowired
......@@ -156,13 +153,7 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen
}
@Override
public void messageSent(IoSession session, Object message) throws Exception {
super.messageSent(session, message);
}
@Override
public void sessionClosed(IoSession session) throws Exception {
super.sessionClosed(session);
log.info("与服务端" + session.getRemoteAddress() +" 的连接已断开");
}
......@@ -572,7 +563,7 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen
}
@Override
public void onTaskStatusChange(DataLog task) {
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if(task.isFinished()){
if(task.isPutInTask()){
String groupId = task.getGroupId();
......@@ -587,4 +578,38 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen
}
@Override
public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
log.error("连接发生异常:" + cause.getMessage());
}
@Override
public void messageSent(IoSession session, Object message) throws Exception {
}
@Override
public void inputClosed(IoSession session) throws Exception {
session.closeNow();
}
@Override
public void event(IoSession session, FilterEvent event) throws Exception {
}
@Override
public void sessionCreated(IoSession session) throws Exception {
}
@Override
public void sessionOpened(IoSession session) throws Exception {
}
@Override
public boolean isForThisApi(String apiName) {
return HellaTcpClient.isEnable();
}
}
package com.neotel.smfcore.hella.tcp;
package com.neotel.smfcore.custom.hella.tcp;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.system.service.po.Settings;
import com.neotel.smfcore.hella.handler.HellaServiceHandler;
import lombok.Data;
import com.neotel.smfcore.custom.hella.handler.HellaServiceHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.mina.core.filterchain.IoFilterAdapter;
import org.apache.mina.core.future.ConnectFuture;
import org.apache.mina.core.session.IdleStatus;
......@@ -38,7 +33,6 @@ public class HellaTcpClient {
private static NioSocketConnector connector;
private static String host = "";
private static int port = 9999;
......@@ -63,12 +57,12 @@ public class HellaTcpClient {
@PostConstruct
public void init(){
host=dataCache.GetConfigCache("hella.host","hella.host",host);
port=Integer.parseInt(dataCache.GetConfigCache("hella.port","hella.port",port+"")) ;
updateServerInfo(host, port);
host=dataCache.getConfigCache("hella.host",host);
port=Integer.parseInt(dataCache.getConfigCache("hella.port",port+"")) ;
if(ObjectUtil.isEmpty(host)||ObjectUtil.isEmpty(port)){
log.info("配置不完整,不需要连接");
}else{
updateServerInfo(host, port);
start();
}
}
......
package com.neotel.smfcore.hella.tcp.command;
package com.neotel.smfcore.custom.hella.tcp.command;
import java.util.Date;
......
package com.neotel.smfcore.hella.tcp.command;
package com.neotel.smfcore.custom.hella.tcp.command;
/**
* Created by sunke on 2021/5/26.
......
package com.neotel.smfcore.hella.tcp.command;
package com.neotel.smfcore.custom.hella.tcp.command;
/**
* Created by sunke on 2021/5/26.
......
package com.neotel.smfcore.panacim;//package com.neotel.smfcore.panacim;
package com.neotel.smfcore.custom.panacim;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Strings;
......@@ -7,16 +7,14 @@ import com.google.common.collect.Maps;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.api.CodeValidateParam;
import com.neotel.smfcore.core.device.api.IOpAuthApi;
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.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.listener.ITaskListener;
import com.neotel.smfcore.core.system.service.dao.IDataLogDao;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
......@@ -37,7 +35,7 @@ import java.util.concurrent.atomic.AtomicLong;
@Controller
@RequestMapping("/rest/api")
public class PanaApiController implements IOpAuthApi, ITaskListener{
public class PanaApiController extends BaseSmfApiListener {
@Autowired
protected TaskService taskService;
......@@ -376,12 +374,7 @@ public class PanaApiController implements IOpAuthApi, ITaskListener{
@Override
public Barcode resolveBarcode(CodeValidateParam param) throws ValidateException {
return null;
}
@Override
public Barcode canPutIn(Barcode barcode) throws ValidateException {
public Barcode canPutIn(String incheckUrl, Barcode barcode) throws ValidateException {
String requestReelUrl = getRequestReelUrl();
try {
if(!Strings.isNullOrEmpty(requestReelUrl)){
......@@ -434,17 +427,18 @@ public class PanaApiController implements IOpAuthApi, ITaskListener{
}
@Override
public boolean canCheckout(Barcode barcode) throws ValidateException {
return false;
}
@Override
public boolean isEnable() {
return false;
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if(task.isFinished()){
if(task.isPutInTask()){
checkInNotification(task);
}else{
deliverNotification(task);
}
}
}
@Override
public void onTaskStatusChange(DataLog task) {
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if(task.isFinished()){
if(task.isPutInTask()){
checkInNotification(task);
......@@ -454,6 +448,7 @@ public class PanaApiController implements IOpAuthApi, ITaskListener{
}
}
/**
* 入库完成通知
* @param task
......@@ -517,4 +512,9 @@ public class PanaApiController implements IOpAuthApi, ITaskListener{
log.error("出库通知PanaCIM["+outNotifyApi+"]料盘"+task.getBarcode()+" 出错",e);
}
}
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("PanaCIM");
}
}
package com.neotel.smfcore.panacim;
package com.neotel.smfcore.custom.panacim;
import com.fasterxml.jackson.annotation.JsonProperty;
......
package com.neotel.smfcore.siemens;
package com.neotel.smfcore.custom.siemens;
import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.HttpHelper;
import com.neotel.smfcore.common.utils.JsonUtil;
import com.neotel.smfcore.core.system.listener.ITaskListener;
import com.neotel.smfcore.core.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.siemens.bean.LotCheckInfo;
import com.neotel.smfcore.custom.siemens.bean.LotCheckInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/**
* Siemens
* #host: "140.231.193.101"
* port:
* #url: "http://cnctu04053:8014/api/JsonC"
* #url_checkIn: "http://cnctu04053:8014/api/JsonC"
* #url: "http://cnctu041p059:8014/api/JsonC"
* #url: "http://cnctu04053:8014/api/JsonC"
*
* action:
* GetMaterialLot: "http://siplace.com/facts/materiallot/2010/01/MaterialLot/GetMaterialLot"
* ProcessMaterialLot: "http://siplace.com/facts/materiallot/2010/01/MaterialLot/ProcessMaterialLot"
*/
@Slf4j
@Component
public class SiemensApi implements ITaskListener {
private static SiemensConfig config;
public class SiemensApi extends BaseSmfApiListener {
// private static SiemensConfig config;
//
// @Autowired
// public void setConfig(SiemensConfig config){
// SiemensApi.config=config;
// }
@Autowired
public void setConfig(SiemensConfig config){
SiemensApi.config=config;
protected IComponentManager componentManager;
@Autowired
protected CodeResolve codeResolve;
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if(task.isFinished()){
if(task.isPutInTask()){
lotInOut(inNotifyUrl, task.getBarcode(),1);
}
}
}
@Override
public void onTaskStatusChange(DataLog task) {
public void outTaskStatusChange(String outNotifyUrl, DataLog task) {
if(task.isFinished()){
if(task.isPutInTask()){
SiemensApi.lotInOut(task.getBarcode(),1);
}else{
SiemensApi.lotInOut(task.getBarcode(),2);
lotInOut(outNotifyUrl, task.getBarcode(),2);
}
}
}
public static boolean lotInOut(String lot,int inoutType) {
String url=config.url;
private static boolean lotInOut(String url, String lot,int inoutType) {
//String url=config.url;
if (ObjectUtil.isEmpty(url)) {
log.info("没有配置Siemens,无需通知");
return true;
......@@ -90,8 +127,67 @@ public class SiemensApi implements ITaskListener {
// }
}
@Override
public Barcode canPutInBeforeResolve(String inCheckUrl, String codeStr) throws ValidateException {
try {
Collection<CodeBean> codeBeans = codeResolve.resolveCodeStr(codeStr, COMPONENT_TYPE.COMPONENT);
boolean ok = false;
for (CodeBean codebean : codeBeans) {
if (codebean.hasReelSizeInfo()) {
LotCheckInfo info = lotCheckIn(codebean.getCodeStr());
if (info != null && info.isStatus() && ObjectUtil.isNotEmpty(info.getPartnum()) && ObjectUtil.isNotEmpty(info.getQuantity())) {
//查找元器件是否存在
com.neotel.smfcore.core.barcode.service.po.Component component = componentManager.findOneByPN(info.getPartnum());
if (component == null) {
//新建元器件和条码
component = new com.neotel.smfcore.core.barcode.service.po.Component();
component.setPartNumber(info.getPartnum());
component.setAmount(info.getQuantity());
component.setHeight(codebean.getReelHeight());
component.setPlateSize(codebean.getReelWidth());
component = componentManager.saveComponent(component);
log.info("siemensCheckCode 新增 元器件:[" + component.getPartNumber() + "][" + component.getAmount() + "][" + component.getPlateSize() + "]X[" + component.getHeight() + "]");
} else if (component.getAmount() != info.getQuantity()) {
component.setAmount(info.getQuantity());
component = componentManager.saveComponent(component);
log.info("siemensCheckCode 修改 元器件:[" + component.getPartNumber() + "]数量为[" + component.getAmount() + "] ");
}
//判断条码是否存在
Barcode barcode = barcodeManager.get(codebean.getCodeStr());
if (barcode == null) {
barcode = new Barcode();
barcode.setPlateSize(component.getPlateSize());
barcode.setHeight(component.getHeight());
barcode.setBarcode(codebean.getCodeStr());
barcode.setAmount(component.getAmount());
barcode.setFullCode(codebean.getCodeStr());
barcode.setPartNumber(component.getPartNumber());
barcode = barcodeManager.saveBarcode(barcode);
log.info("siemensCheckCode 新增 条码:[" + barcode.getBarcode() + "] ");
}else if(!barcode.getPartNumber().equals(component.getPartNumber())){
barcode.setPlateSize(component.getPlateSize());
barcode.setHeight(component.getHeight());
barcode.setBarcode(codebean.getCodeStr());
barcode.setAmount(component.getAmount());
barcode.setPartNumber(component.getPartNumber());
log.info("siemensCheckCode 修改 条码:[" + barcode.getBarcode() + "] pn为 ["+barcode.getPartNumber()+"] ");
}
return barcode;
}
}
}
} catch (Exception ex) {
log.info("siemensCheckCode 验证条码 [" + codeStr + "] 出错:", ex);
}
return null;
}
public static LotCheckInfo lotCheckIn(String lot) {
String url = config.url_checkIn;
//String url = config.url_checkIn;
String url = "";
if (ObjectUtil.isEmpty(url)) {
log.info("没有配置Siemens,无需验证");
return null;
......@@ -131,6 +227,11 @@ public class SiemensApi implements ITaskListener {
}
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("Siemens");
}
// private static boolean getMaterialLot(int inoutType,String storageId,String storageName,String materialLot){
//
......
package com.neotel.smfcore.siemens;
package com.neotel.smfcore.custom.siemens;
import com.neotel.smfcore.core.device.util.DataCache;
import lombok.extern.slf4j.Slf4j;
......
package com.neotel.smfcore.siemens.bean;
package com.neotel.smfcore.custom.siemens.bean;
import com.neotel.smfcore.common.utils.JsonUtil;
import lombok.AllArgsConstructor;
......
package com.neotel.smfcore.siemens.util;
package com.neotel.smfcore.custom.siemens.util;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.httpclient.HostConfiguration;
......
......@@ -119,12 +119,12 @@ public class UserController {
//判断用户名是否存在
userManager.userNameIsExist(resources.getUsername(),null);
if(resources.getEnabled()==null){
resources.setEnabled(false);
resources.setEnabled(true);
}
if(resources.getGroups()==null){
resources.setGroups(new HashSet<String>());
}
resources.setEnabled(false);
resources.setEnabled(true);
if(resources.getCheckCode()==null){
resources.setCheckCode("");
}
......
......@@ -81,21 +81,21 @@ public class UserDetailsServiceImpl implements UserDetailsService {
if (user == null) {
throw new ValidateException("smfcore.valueNotExist","{0}[{1}]不存在",new String[]{"username",username});
} else {
if(user.getEnabled()==null){
throw new ValidateException("smfcore.notActivated","账号未激活");
}
if (!user.getEnabled()) {
throw new ValidateException("smfcore.notActivated","账号未激活");
}
if(user.getUsername().equals(Constants.SUPER_USERNAME)){
}else {
//判断激活码是否正确
String code = Md5Utls.getMd5(user.getId(), user.getCreateDate());
if (!code.equals(user.getCheckCode())) {
throw new ValidateException("smfcore.notActivated","账号未激活");
}
}
// if(user.getEnabled()==null){
// throw new ValidateException("smfcore.notActivated","账号未激活");
// }
// if (!user.getEnabled()) {
// throw new ValidateException("smfcore.notActivated","账号未激活");
// }
// if(user.getUsername().equals(Constants.SUPER_USERNAME)){
//
// }else {
// //判断激活码是否正确
// String code = Md5Utls.getMd5(user.getId(), user.getCreateDate());
// if (!code.equals(user.getCheckCode())) {
// throw new ValidateException("smfcore.notActivated","账号未激活");
// }
// }
List<Long> dataScopes = new ArrayList<>();
jwtUserDto = new JwtUserDto(
user,
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!