Commit f90a593e 孙克
2 个父辈 902d68b5 4b1661ef
正在显示 42 个修改的文件 包含 1027 行增加197 行删除
...@@ -113,6 +113,8 @@ public class MenuInit { ...@@ -113,6 +113,8 @@ public class MenuInit {
//AGV看板 //AGV看板
//addDefaultFunctionMenu(1,null,"AGV看板","agvkanban", "agv/agvkanban/index","agv"); //addDefaultFunctionMenu(1,null,"AGV看板","agvkanban", "agv/agvkanban/index","agv");
addDefaultFunctionMenu(-1,null,"Neo Ai","neoai","neoai/index","neoai");
//Mimo临时看板 //Mimo临时看板
addDefaultFunctionMenu(0,null,"SMD BOX MIMO","SMDBOXMIMO", "smdBoxMimo/index","smdMimo"); addDefaultFunctionMenu(0,null,"SMD BOX MIMO","SMDBOXMIMO", "smdBoxMimo/index","smdMimo");
......
...@@ -168,4 +168,9 @@ public class Constants { ...@@ -168,4 +168,9 @@ public class Constants {
*/ */
public static final String CACHE_spSettings="spSettings"; public static final String CACHE_spSettings="spSettings";
/**
* 缺料不自动关闭工单
*/
public static final String CACHE_closeWorkOrder = "CACHE_closeWorkOrder";
} }
...@@ -355,8 +355,12 @@ public class FileUtil extends cn.hutool.core.io.FileUtil { ...@@ -355,8 +355,12 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
if (CollectionUtils.isNotEmpty(dataList)) { if (CollectionUtils.isNotEmpty(dataList)) {
for (Map<String, Object> data : dataList) { for (Map<String, Object> data : dataList) {
for (String key : titles) { for (String key : titles) {
if(data.get(key).toString().contains(CSV_COLUMN_SEPARATOR)){
buf.append("\""+data.get(key)+"\"").append(CSV_COLUMN_SEPARATOR);
}else{
buf.append(data.get(key)).append(CSV_COLUMN_SEPARATOR); buf.append(data.get(key)).append(CSV_COLUMN_SEPARATOR);
} }
}
buf.append(CSV_ROW_SEPARATOR); buf.append(CSV_ROW_SEPARATOR);
} }
} }
......
...@@ -476,6 +476,44 @@ public class HttpHelper { ...@@ -476,6 +476,44 @@ public class HttpHelper {
} }
} }
public static String postParam(String url, Map<String, Object> paramMap, Map<String,String> headerMap) throws ApiException {
// 设置请求参数
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
try {
List<NameValuePair> params = toNameValuePair(paramMap);
URI uri = new URIBuilder(url).setParameters(params).build();
log.info("执行请求:" + uri.toString());
HttpPost httpPost = new HttpPost(uri);
for (Entry<String, String> entry : headerMap.entrySet()) {
httpPost.addHeader(entry.getKey(), entry.getValue());
}
// httpPost.setEntity(new UrlEncodedFormEntity(params, CONTENT_CHARSET));
httpClient = HttpClients.createDefault();
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
String responseContent = EntityUtils.toString(entity, CONTENT_CHARSET);
//response.close();
//httpClient.close();
return responseContent;
} catch (Exception e) {
throw new ApiException("Request params to [" + url + "] failed:" + e.getMessage());
}finally {
try {
if (response != null) {
response.close();
}
if (httpClient != null) {
httpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
private static String appendString(String url, String paramStr) { private static String appendString(String url, String paramStr) {
StringBuffer stringBuffer = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(url); stringBuffer.append(url);
......
...@@ -2,12 +2,14 @@ package com.neotel.smfcore.core.api; ...@@ -2,12 +2,14 @@ package com.neotel.smfcore.core.api;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.init.MenuInit; import com.neotel.smfcore.common.init.MenuInit;
import com.neotel.smfcore.core.api.listener.ISmfApiListener; import com.neotel.smfcore.core.api.listener.ISmfApiListener;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.api.bean.CodeValidateParam; import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inList.service.po.InList;
import com.neotel.smfcore.core.order.service.po.LiteOrder; import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -262,6 +264,20 @@ public class SmfApi { ...@@ -262,6 +264,20 @@ public class SmfApi {
return false; return false;
} }
public InList fetchInList(String number) {
if (isUrlExist(fetchInListUrl)) {
for (ISmfApiListener apiListener : apiListenerList) {
if (apiListener.isForThisApi(apiName)) {
InList inList = apiListener.fetchInList(fetchInListUrl,number);
if (inList != null) {
return inList;
}
}
}
}
return null;
}
public String getApiName(){ public String getApiName(){
return apiName; return apiName;
} }
......
...@@ -118,6 +118,11 @@ public abstract class BaseSmfApiListener implements ISmfApiListener { ...@@ -118,6 +118,11 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
public boolean canLogin(String loginCheckUrl, String userName, String pwd) throws ValidateException { public boolean canLogin(String loginCheckUrl, String userName, String pwd) throws ValidateException {
return true; return true;
} }
@Override
public InList fetchInList(String fetchInListUrl, String number){
return null;
}
protected String getData(Map<String, Object> dataMap, String dataKey) { protected String getData(Map<String, Object> dataMap, String dataKey) {
Object data = dataMap.get(dataKey); Object data = dataMap.get(dataKey);
if (data == null) { if (data == null) {
......
...@@ -197,31 +197,31 @@ public class DefaultSmfApiListener extends BaseSmfApiListener { ...@@ -197,31 +197,31 @@ public class DefaultSmfApiListener extends BaseSmfApiListener {
} }
} }
public InList fetchInList(String fetchInListUrl, String number) throws ApiException { public InList fetchInList(String fetchInListUrl, String number) {
Map<String,Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("number",number); paramMap.put("number", number);
try { try {
log.info("调用获取入库单接口,参数" + JsonUtil.toJsonStr(paramMap)); log.info("调用获取入库单接口,参数" + JsonUtil.toJsonStr(paramMap));
String result = HttpHelper.postJson(fetchInListUrl, paramMap); String result = HttpHelper.postJson(fetchInListUrl, paramMap);
log.info(number + "获取入库单接口返回" + result); log.info(number + "获取入库单接口返回" + result);
ApiResult apiResult = JsonUtil.toObj(result,ApiResult.class); ApiResult apiResult = JsonUtil.toObj(result, ApiResult.class);
if(apiResult.isOk()){ if (apiResult.isOk()) {
Map<String,Object> dataMap = (Map<String, Object>) apiResult.getData(); Map<String, Object> dataMap = (Map<String, Object>) apiResult.getData();
String returnNumber = dataMap.get("number").toString(); String returnNumber = dataMap.get("number").toString();
InList inList = new InList(); InList inList = new InList();
inList.setName(returnNumber); inList.setName(returnNumber);
List<InListItem> items = new ArrayList<>(); List<InListItem> items = new ArrayList<>();
List<Map<String,Object>> itemList = (List<Map<String, Object>>) dataMap.get("items"); List<Map<String, Object>> itemList = (List<Map<String, Object>>) dataMap.get("items");
for (Map<String, Object> itemMap : itemList) { for (Map<String, Object> itemMap : itemList) {
String partNum = itemMap.get("partNum").toString(); String partNum = itemMap.get("partNum").toString();
Object qtyStr = itemMap.get("qty"); Object qtyStr = itemMap.get("qty");
Object reelCountStr = itemMap.get("reelCount"); Object reelCountStr = itemMap.get("reelCount");
InListItem item = new InListItem(); InListItem item = new InListItem();
item.setPN(partNum); item.setPN(partNum);
if(qtyStr != null && !qtyStr.toString().isEmpty()){ if (qtyStr != null && !qtyStr.toString().isEmpty()) {
item.setNum(Integer.valueOf(qtyStr.toString())); item.setNum(Integer.valueOf(qtyStr.toString()));
} }
if(reelCountStr != null && !qtyStr.toString().isEmpty()){ if (reelCountStr != null && !qtyStr.toString().isEmpty()) {
item.setInReelCount(Integer.valueOf(reelCountStr.toString())); item.setInReelCount(Integer.valueOf(reelCountStr.toString()));
} }
items.add(item); items.add(item);
...@@ -231,12 +231,12 @@ public class DefaultSmfApiListener extends BaseSmfApiListener { ...@@ -231,12 +231,12 @@ public class DefaultSmfApiListener extends BaseSmfApiListener {
inList = inListManager.createWithItems(inList); inList = inListManager.createWithItems(inList);
inListCache.addInListToMap(inList); inListCache.addInListToMap(inList);
return inList; return inList;
}else{ } else {
throw new ApiException("smfcore.fetchInList.ng","获取入库单MES返回NG:" + apiResult.getMsg()); throw new ApiException("smfcore.fetchInList.ng", "获取入库单MES返回NG:" + apiResult.getMsg());
} }
} catch (Exception e) { } catch (Exception e) {
log.error(number + "获取入库单接口出错:" + e.getMessage()); log.error(number + "获取入库单接口出错:" + e.getMessage());
throw new ApiException("smfcore.fetchInList.error","获取入库单出错:" + e.getMessage()); return null;
} }
} }
......
package com.neotel.smfcore.core.api.listener; 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.exception.ValidateException;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.api.bean.CodeValidateParam; import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.inList.service.po.InList;
import com.neotel.smfcore.core.order.service.po.LiteOrder; import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
...@@ -67,4 +69,7 @@ public interface ISmfApiListener { ...@@ -67,4 +69,7 @@ public interface ISmfApiListener {
* 是否可以登陆 * 是否可以登陆
*/ */
boolean canLogin(String loginCheckUrl, String userName,String pwd) throws ValidateException; boolean canLogin(String loginCheckUrl, String userName,String pwd) throws ValidateException;
InList fetchInList(String fetchInListUrl, String number);
} }
...@@ -841,6 +841,8 @@ public class BarcodeRule { ...@@ -841,6 +841,8 @@ public class BarcodeRule {
rule="EXPDATEyyMMdd[12:0:-1]|BATCH[2:0:-1]|QTY[2:0:-1]|RI[2:0:-1]|PN[1:0:-1]|MPN[-1:0:2]"; rule="EXPDATEyyMMdd[12:0:-1]|BATCH[2:0:-1]|QTY[2:0:-1]|RI[2:0:-1]|PN[1:0:-1]|MPN[-1:0:2]";
// rule="PN[1:0:-1]|BATCH[2:0:-1]|LOT[2:0:-1]|QTY[2_7Q:0:-1]|RI[1:0:-1]|SP[3:0:-1]|PRODATEyyyyMMdd[2:0:-1]|xxx"; // rule="PN[1:0:-1]|BATCH[2:0:-1]|LOT[2:0:-1]|QTY[2_7Q:0:-1]|RI[1:0:-1]|SP[3:0:-1]|PRODATEyyyyMMdd[2:0:-1]|xxx";
codeStr = "41000100883,2329,38M0540150,4341,1,710032329883000188";
rule = "RI,PRODATEyyWW,PN,QTY,MSL,BATCH";
BarcodeRule br = BarcodeRule.newRule(rule); BarcodeRule br = BarcodeRule.newRule(rule);
Barcode b = br.toCodeBean(codeStr).getBarcode(); Barcode b = br.toCodeBean(codeStr).getBarcode();
if(b != null){ if(b != null){
...@@ -881,7 +883,7 @@ public class BarcodeRule { ...@@ -881,7 +883,7 @@ public class BarcodeRule {
} }
private static String toCodeRule(String codeStr, Map<String,String> fieldValueMap){ public static String toCodeRule(String codeStr, Map<String,String> fieldValueMap){
String separator = findSeparator(codeStr); String separator = findSeparator(codeStr);
String[] codeArr = new String[]{codeStr}; String[] codeArr = new String[]{codeStr};
if(!Strings.isNullOrEmpty(separator)){ if(!Strings.isNullOrEmpty(separator)){
......
...@@ -8,15 +8,18 @@ import com.neotel.smfcore.common.exception.ValidateException; ...@@ -8,15 +8,18 @@ import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.FileUtil; import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.QueryHelp; import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.core.barcode.bean.BarcodeRule; import com.neotel.smfcore.core.barcode.bean.BarcodeRule;
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.dto.BarcodeDto;
import com.neotel.smfcore.core.barcode.rest.bean.dto.BarcodeRuleDto; import com.neotel.smfcore.core.barcode.rest.bean.dto.BarcodeRuleDto;
import com.neotel.smfcore.core.barcode.rest.bean.mapstruct.BarcodeMapper; import com.neotel.smfcore.core.barcode.rest.bean.mapstruct.BarcodeMapper;
import com.neotel.smfcore.core.barcode.rest.bean.query.BarcodeQueryCriteria; import com.neotel.smfcore.core.barcode.rest.bean.query.BarcodeQueryCriteria;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager; import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.barcode.utils.QrcodeUtils; import com.neotel.smfcore.core.barcode.utils.QrcodeUtils;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.system.service.po.Settings; import com.neotel.smfcore.core.system.service.po.Settings;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import com.neotel.smfcore.security.bean.FileProperties; import com.neotel.smfcore.security.bean.FileProperties;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -58,6 +61,9 @@ public class BarcodeController { ...@@ -58,6 +61,9 @@ public class BarcodeController {
@Autowired @Autowired
private final FileProperties properties; private final FileProperties properties;
@Autowired
private CodeResolve codeResolve;
@ApiOperation("导出条码数据") @ApiOperation("导出条码数据")
@GetMapping(value = "/download") @GetMapping(value = "/download")
public void download(HttpServletResponse response, BarcodeQueryCriteria criteria) throws Exception { public void download(HttpServletResponse response, BarcodeQueryCriteria criteria) throws Exception {
...@@ -181,12 +187,36 @@ public class BarcodeController { ...@@ -181,12 +187,36 @@ public class BarcodeController {
} }
/*@ApiOperation("根据条码信息获取条码规则") @ApiOperation("根据条码信息获取条码规则")
@PostMapping(value = "getBarcodeRule") @PostMapping(value = "getBarcodeRule")
@AnonymousAccess
public ResultBean getBarcodeRule(@RequestBody Map<String, String> paramMap) { public ResultBean getBarcodeRule(@RequestBody Map<String, String> paramMap) {
String ruleStr = BarcodeRule.toCodeRule(paramMap.get("codeStr"), paramMap); String codeStr = paramMap.get("codeStr");
paramMap.remove("codeStr");
String ruleStr = BarcodeRule.toCodeRule(codeStr, paramMap);
return ResultBean.newOkResult(ruleStr); return ResultBean.newOkResult(ruleStr);
}*/ }
@ApiOperation("获取条码内容")
@PostMapping("/getBarCodeInfo")
@AnonymousAccess
public ResultBean getBarCodeInfo(@RequestBody Map<String, String> paramMap) {
//获取条码内容
String codeStr = paramMap.get("code");
List<BarcodeRule> barcodeRuleList = codeResolve.getBarcodeRuleList();
if (barcodeRuleList != null && !barcodeRuleList.isEmpty()) {
for (BarcodeRule barcodeRule : barcodeRuleList) {
CodeBean codeBean = barcodeRule.toCodeBean(codeStr);
if (codeBean.getBarcode() != null) {
return ResultBean.newOkResult(codeBean.getBarcode());
}
}
} else {
return ResultBean.newErrorResult(1, "smfcore.error.barcode.noRules", "解析规则未定义");
}
return ResultBean.newErrorResult(1, "smfcore.error.barcode.invalid", "未找到有效条码");
}
protected String handleBarcode(String fileURL) throws Exception { protected String handleBarcode(String fileURL) throws Exception {
......
...@@ -47,6 +47,11 @@ public class CodeResolve { ...@@ -47,6 +47,11 @@ public class CodeResolve {
} }
} }
} }
public List<BarcodeRule> getBarcodeRuleList(){
return barcodeRuleList;
}
public void updateExpiresDay(Integer expiresDay){ public void updateExpiresDay(Integer expiresDay){
defaultExpiresDay=expiresDay; defaultExpiresDay=expiresDay;
} }
...@@ -202,6 +207,13 @@ public class CodeResolve { ...@@ -202,6 +207,13 @@ public class CodeResolve {
} }
} }
} }
if (produceDate != null){
barcode.setProduceDate(produceDate);
log.info("重新设置"+codeBeanFromRule.getCodeStr()+"的过生产日期");
needUpdate = true;
}
if(barcodeFromRule.getExpireDate()!=null /*&&barcode.getExpireDate()==null*/){ if(barcodeFromRule.getExpireDate()!=null /*&&barcode.getExpireDate()==null*/){
barcode.setExpireDate(barcodeFromRule.getExpireDate()); barcode.setExpireDate(barcodeFromRule.getExpireDate());
log.info("重新设置"+codeBeanFromRule.getCodeStr()+"的过期日期"); log.info("重新设置"+codeBeanFromRule.getCodeStr()+"的过期日期");
......
package com.neotel.smfcore.mimo.controller; package com.neotel.smfcore.core.dashboard.mimo;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
......
package com.neotel.smfcore.core.device.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MsgInfo implements Serializable {
public MsgInfo(String msg,String type){
this.msg=msg;
this.type=type;
}
/**
* 提示消息
*/
private String msg = "";
/**
* 消息类型,INFO,WARNING,ERROR,DATA
*/
private String type;
/**
* 英文提示消息
*/
private String msgEn = "";
private String msgJp="";
/**
* 翻译key
*/
private String msgKey="";
/**
* 翻译参数
*/
private String[] msgParam ;
/**
* 报警类型
*/
private String alarmType="";
/**
*报警错误码
*/
private String alarmCode="";
}
...@@ -22,6 +22,19 @@ public class NLShelfOperateBean { ...@@ -22,6 +22,19 @@ public class NLShelfOperateBean {
*/ */
private String nextPosId; private String nextPosId;
/**
* 上一个库位的Id,用于自动推荐库位
*/
private String lastPosId;
public String getLastPosId() {
return lastPosId;
}
public void setLastPosId(String lastPosId) {
updateOpTime();
this.lastPosId = lastPosId;
}
public StoragePos getOpPos() { public StoragePos getOpPos() {
return opPos; return opPos;
......
...@@ -79,6 +79,9 @@ public class StatusBean { ...@@ -79,6 +79,9 @@ public class StatusBean {
public String msgJp=""; public String msgJp="";
/**
* 翻译key
*/
public String msgCode=""; public String msgCode="";
public String[] msgParam ; public String[] msgParam ;
...@@ -108,6 +111,14 @@ public class StatusBean { ...@@ -108,6 +111,14 @@ public class StatusBean {
private List<PosInfo> posList=null; private List<PosInfo> posList=null;
/** /**
* 语言,zh-CN,zh-TW,en-US,ja-JP,默认中文
*/
public String language="";
/**
* 消息集合
*/
public List<MsgInfo> msgList;
/**
* 料仓类型 * 料仓类型
*/ */
private String deviceType = DeviceType.AUTO.name(); private String deviceType = DeviceType.AUTO.name();
...@@ -532,75 +543,174 @@ public class StatusBean { ...@@ -532,75 +543,174 @@ public class StatusBean {
} }
return doorReelSignal; return doorReelSignal;
} }
//
// public String getShowMsg(Locale locale) {
// if(ObjectUtil.isEmpty(this.msg)){
// return "";
// }
// //从收到数据中查找
// String lan = locale.toLanguageTag();
// if (lan.equals(MessageUtils.JA_JP) && ObjectUtil.isNotEmpty(getMsgJp())) {
// String resultMsg= getMsgJp().replace("A=","").replace("I=","").replace("W=","");
// return resultMsg;
// } else if (lan.equals(MessageUtils.EN_US) && ObjectUtil.isNotEmpty(getMsgEn())) {
// String resultMsg= getMsgEn().replace("A=","").replace("I=","").replace("W=","");
// return resultMsg;
// }
// //提示信息国际化
// if (ObjectUtil.isEmpty(getMsgCode())) {
// return this.msg.replace("A=","").replace("I=","").replace("W=","");
// } else {
// String code = this.msgCode;
// if (!code.startsWith(MessageUtils.smfcore)) {
// code = MessageUtils.smfcore + "." + this.msgCode;
// }
// String newMsg=this.msg.replace("A=","").replace("I=","").replace("W=","");
// newMsg = MessageUtils.getText(code, getMsgParam(), locale, newMsg);
// return newMsg;
// }
// }
//
// public String getErrorMsg(Locale locale) {
// if(ObjectUtil.isEmpty(this.msg)){
// return "";
// }
//
// //判断是否有换行
// String[] msgArray=this.msg.split("\r\n");
// if(msgArray.length>0) {
// for (String msg :
// msgArray) {
// String msgType = MessageType.ERROR.name();
// if (msg.startsWith("A=")) {
// msgType = MessageType.ERROR.name();
// msg = msg.substring(2);
// } else if (msg.startsWith("I=")) {
// msgType = MessageType.INFO.name();
// msg = msg.substring(2);
// } else if (msg.startsWith("W=")) {
// msgType = MessageType.WARNING.name();
// msg = msg.substring(2);
// }
// if(msgType.equals(MessageType.ERROR.name())){
// return msg;
// }
// }
// }
// return "";
// }
//
// public Map<String,String> getMsgMap() {
// Map<String,String> resultMap=new HashMap<>();
// if(ObjectUtil.isEmpty(this.msg)){
// return resultMap;
// }
//
// //判断是否有换行
// String[] msgArray=this.msg.split("\r\n");
// if(msgArray.length>0) {
// for (String msg :
// msgArray) {
// if(ObjectUtil.isEmpty(msg)){
// continue;
// }
// String msgType = MessageType.ERROR.name();
// if (msg.startsWith("A=")) {
// msgType = MessageType.ERROR.name();
// msg = msg.substring(2);
// } else if (msg.startsWith("I=")) {
// msgType = MessageType.INFO.name();
// msg = msg.substring(2);
// } else if (msg.startsWith("W=")) {
// msgType = MessageType.WARNING.name();
// msg = msg.substring(2);
// }
// resultMap.put(msg,msgType);
// }
// }
// return resultMap;
// }
public String getShowMsg(Locale locale) { private String GetMsgStr(MsgInfo msg,Locale locale){
if(ObjectUtil.isEmpty(this.msg)){ String mMsg = "";
return "";
}
//从收到数据中查找 //从收到数据中查找
String lan = locale.toLanguageTag(); String lan = locale.toLanguageTag();
if (lan.equals(MessageUtils.JA_JP) && ObjectUtil.isNotEmpty(getMsgJp())) { if (lan.equals(MessageUtils.JA_JP) && ObjectUtil.isNotEmpty(msg.getMsgJp())) {
String resultMsg= getMsgJp().replace("A=","").replace("I=","").replace("W=",""); mMsg = msg.getMsgJp();
return resultMsg; } else if (lan.equals(MessageUtils.EN_US) && ObjectUtil.isNotEmpty(msg.getMsgEn())) {
} else if (lan.equals(MessageUtils.EN_US) && ObjectUtil.isNotEmpty(getMsgEn())) { mMsg = msg.getMsgEn();
String resultMsg= getMsgEn().replace("A=","").replace("I=","").replace("W=","");
return resultMsg;
} }
//提示信息国际化 //提示信息国际化
if (ObjectUtil.isEmpty(getMsgCode())) { else if (ObjectUtil.isEmpty(msg.getMsgKey())) {
return this.msg.replace("A=","").replace("I=","").replace("W=",""); mMsg = msg.getMsg();
} else { } else {
String code = this.msgCode; String code = msg.getMsgKey();
if (!code.startsWith(MessageUtils.smfcore)) { if (!code.startsWith(MessageUtils.smfcore)) {
code = MessageUtils.smfcore + "." + this.msgCode; code = MessageUtils.smfcore + "." + msg.getMsgKey();
} }
String newMsg=this.msg.replace("A=","").replace("I=","").replace("W=",""); String newMsg = msg.getMsg().replace("A=", "").replace("I=", "").replace("W=", "");
newMsg = MessageUtils.getText(code, getMsgParam(), locale, newMsg); mMsg = MessageUtils.getText(code, msg.getMsgParam(), locale, newMsg);
return newMsg;
} }
return mMsg;
} }
public String getErrorMsg(Locale locale) { public String getShowMsg(Locale locale) {
if(ObjectUtil.isEmpty(this.msg)){ if (ObjectUtil.isEmpty(this.msgList)) {
return ""; return "";
} }
String returnMsg = "";
//判断是否有换行 for (MsgInfo msg :
String[] msgArray=this.msg.split("\r\n"); msgList) {
if(msgArray.length>0) { String mMsg = GetMsgStr(msg,locale);
for (String msg : if (ObjectUtil.isEmpty(returnMsg)) {
msgArray) { returnMsg = mMsg;
String msgType = MessageType.ERROR.name(); } else {
if (msg.startsWith("A=")) { returnMsg += "\r\n" + mMsg;
msgType = MessageType.ERROR.name();
msg = msg.substring(2);
} else if (msg.startsWith("I=")) {
msgType = MessageType.INFO.name();
msg = msg.substring(2);
} else if (msg.startsWith("W=")) {
msgType = MessageType.WARNING.name();
msg = msg.substring(2);
} }
if(msgType.equals(MessageType.ERROR.name())){
return msg;
} }
return returnMsg;
}
public String getErrorMsg(Locale locale) {
if (ObjectUtil.isEmpty(this.msgList)) {
return "";
}
for (MsgInfo msg :
msgList) {
if (msg.getType().toUpperCase().equals(MessageType.ERROR.name())) {
return msg.getMsg();
} }
} }
return ""; return "";
} }
public Map<String,String> getMsgMap() { public Map<String,String> getMsgMap(Locale locale) {
Map<String,String> resultMap=new HashMap<>(); Map<String, String> resultMap = new HashMap<>();
if(ObjectUtil.isEmpty(this.msg)){ if (ObjectUtil.isEmpty(msgList)) {
return resultMap;
}
//判断是否有换行
for (MsgInfo msg : msgList) {
resultMap.put(GetMsgStr(msg,locale) , msg.getType());
}
return resultMap; return resultMap;
} }
public void MsgDataProcess() {
//消息格式处理
if( getMsgList()==null&& ObjectUtil.isNotEmpty(msg)){
msgList=new ArrayList<>();
//判断是否有换行 //判断是否有换行
String[] msgArray=this.msg.split("\r\n"); String[] msgArray=this.msg.split("\r\n");
if(msgArray.length>0) { if(msgArray.length>0) {
for (String msg : for (String msg :
msgArray) { msgArray) {
if(ObjectUtil.isEmpty(msg)){ if (ObjectUtil.isEmpty(msg)) {
continue; continue;
} }
String msgType = MessageType.ERROR.name(); String msgType = MessageType.ERROR.name();
...@@ -614,9 +724,41 @@ public class StatusBean { ...@@ -614,9 +724,41 @@ public class StatusBean {
msgType = MessageType.WARNING.name(); msgType = MessageType.WARNING.name();
msg = msg.substring(2); msg = msg.substring(2);
} }
resultMap.put(msg,msgType);
if (msgArray.length == 1) {
msgList.add(new MsgInfo(msg, msgType,msgEn,msgJp,msgCode,msgParam,"",""));
} else {
msgList.add(new MsgInfo(msg, msgType));
}
} }
} }
return resultMap; }
}
public void setRMsg(String msgKey, String[] msgParam, String message) {
String msgEn = MessageUtils.getText(msgKey, msgParam, new Locale("en","US"), message);
String msgJp = MessageUtils.getText(msgKey, msgParam, new Locale("ja","JP"), message);
setMsg(message);
setMsgCode(msgKey);
setMsgEn(msgEn);
setMsgJp(msgJp);
if(ObjectUtil.isNotEmpty(language)){
String[] array = language.split("-");
Locale locale = null;
if (array.length == 2) {
locale = new Locale(array[0], array[1]);
} else {
locale = new Locale(language);
}
String lanMsg=MessageUtils.getText(msgKey, msgParam, locale, message);
setMsg(lanMsg);
}else{
String lanMsg=MessageUtils.getText(msgKey, msgParam, MessageUtils.getDefaultLocal(), message);
setMsg(lanMsg);
}
} }
} }
...@@ -324,13 +324,15 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -324,13 +324,15 @@ public class BaseDeviceHandler implements IDeviceHandler {
serverExceptions.remove(storage.getCid()); serverExceptions.remove(storage.getCid());
} catch (ValidateException e) { } catch (ValidateException e) {
String msgEn = MessageUtils.getText(e.getMsgKey(), e.getMsgParam(), new Locale("en","US"), e.getMessage()); // String msgEn = MessageUtils.getText(e.getMsgKey(), e.getMsgParam(), new Locale("en","US"), e.getMessage());
String msgJp = MessageUtils.getText(e.getMsgKey(), e.getMsgParam(), new Locale("ja","JP"), e.getMessage()); // String msgJp = MessageUtils.getText(e.getMsgKey(), e.getMsgParam(), new Locale("ja","JP"), e.getMessage());
log.warn(statusBean.getCode() + "入库到" + storage.getCid() + "失败:" + e.getMessage()+","+msgEn+","+msgJp); // log.warn(statusBean.getCode() + "入库到" + storage.getCid() + "失败:" + e.getMessage()+","+msgEn+","+msgJp);
statusBean.setMsg(e.getMessage()); // statusBean.setMsg(e.getMessage());
statusBean.setMsgCode(e.getMsgKey()); // statusBean.setMsgCode(e.getMsgKey());
statusBean.setMsgEn(msgEn); // statusBean.setMsgEn(msgEn);
statusBean.setMsgJp(msgJp); // statusBean.setMsgJp(msgJp);
statusBean.setRMsg(e.getMsgKey(),e.getMsgParam(),e.getMessage());
log.warn(statusBean.getCode() + "入库到" + storage.getCid() + "失败:" + e.getMessage()+","+statusBean.getMsg()+","+statusBean.getMsgEn()+","+statusBean.getMsgJp());
serverExceptions.put(storage.getCid(), e); serverExceptions.put(storage.getCid(), e);
}catch (Exception e) { }catch (Exception e) {
log.error(statusBean.getCode() + "入库到" + storage.getCid() + "失败", e); log.error(statusBean.getCode() + "入库到" + storage.getCid() + "失败", e);
...@@ -841,25 +843,39 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -841,25 +843,39 @@ public class BaseDeviceHandler implements IDeviceHandler {
protected void handleMsg(StatusBean statusBean) { protected void handleMsg(StatusBean statusBean) {
try { try {
//转换为新格式
statusBean.MsgDataProcess();
//判断是否刚刚上线 //判断是否刚刚上线
StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid()); StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid());
if (bean == null || bean.getBoxStatus() == null) { if (bean == null || bean.getBoxStatus() == null) {
DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp()); DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp());
DevicesStatusUtil.updateClientMsg(statusBean.getCid(), "", "", "","", null); DevicesStatusUtil.updateClientMsg(statusBean.getCid(),new ArrayList<>());
} else if (bean.timeOut() && (bean.getOfflineTime() > -1)) { } else if (bean.timeOut() && (bean.getOfflineTime() > -1)) {
DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp()); DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp());
DevicesStatusUtil.updateClientMsg(statusBean.getCid(), "", "", "","", null); DevicesStatusUtil.updateClientMsg(statusBean.getCid(), new ArrayList<>());
} }
if(ObjectUtil.isNotEmpty(statusBean.msgList)&& statusBean.msgList.size()>0) {
//展示到界面 DevicesStatusUtil.updateClientMsg(statusBean.getCid(), statusBean.msgList);
String msg = statusBean.getMsg(); }
String msgEn = statusBean.getMsgEn(); // //判断是否刚刚上线
String msgCode = statusBean.getMsgCode(); // StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid());
String msgJp=statusBean.getMsgJp(); // if (bean == null || bean.getBoxStatus() == null) {
// DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp());
if(ObjectUtil.isNotEmpty(msg)||ObjectUtil.isNotEmpty(msgCode)) { // DevicesStatusUtil.updateClientMsg(statusBean.getCid(), "", "", "","", null);
DevicesStatusUtil.updateClientMsg(statusBean.getCid(), msgCode, msg, msgEn, msgJp,statusBean.getMsgParam()); // } else if (bean.timeOut() && (bean.getOfflineTime() > -1)) {
} // DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp());
// DevicesStatusUtil.updateClientMsg(statusBean.getCid(), "", "", "","", null);
// }
//
// //展示到界面
// String msg = statusBean.getMsg();
// String msgEn = statusBean.getMsgEn();
// String msgCode = statusBean.getMsgCode();
// String msgJp=statusBean.getMsgJp();
//
// if(ObjectUtil.isNotEmpty(msg)||ObjectUtil.isNotEmpty(msgCode)) {
// DevicesStatusUtil.updateClientMsg(statusBean.getCid(), msgCode, msg, msgEn, msgJp,statusBean.getMsgParam());
// }
} catch (Exception e) { } catch (Exception e) {
log.error("客户端故障消息处理出错", e); log.error("客户端故障消息处理出错", e);
} }
...@@ -946,7 +962,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -946,7 +962,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
boolean isFind = false; boolean isFind = false;
for (DataLog dataLog : dataLogList) { for (DataLog dataLog : dataLogList) {
if (dataLog.getStatus().equals(OP_STATUS.EXECUTING)) { if (dataLog.getStatus().equals(OP_STATUS.EXECUTING.name())) {
dataLogs.add(dataLog); dataLogs.add(dataLog);
isFind = true; isFind = true;
break; break;
...@@ -963,7 +979,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -963,7 +979,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
} }
for (LiteOrderItem item : order.getOrderItems()) { for (LiteOrderItem item : order.getOrderItems()) {
for (DataLog dataLog : dataLogList) { for (DataLog dataLog : dataLogList) {
if (dataLog.getStatus().equals(OP_STATUS.WAIT)) { if (dataLog.getStatus().equals(OP_STATUS.WAIT.name())) {
if ((ObjectUtil.isNotEmpty(item.getPn()) && item.getPn().equals(dataLog.getPartNumber())) || if ((ObjectUtil.isNotEmpty(item.getPn()) && item.getPn().equals(dataLog.getPartNumber())) ||
(ObjectUtil.isNotEmpty(item.getRi()) && item.getRi().equals(dataLog.getBarcode())) (ObjectUtil.isNotEmpty(item.getRi()) && item.getRi().equals(dataLog.getBarcode()))
) { ) {
...@@ -977,11 +993,11 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -977,11 +993,11 @@ public class BaseDeviceHandler implements IDeviceHandler {
break; break;
} }
} }
}
if (isFind) { if (isFind) {
break; break;
} }
} }
}
return dataLogs; return dataLogs;
} }
......
...@@ -5,6 +5,7 @@ import com.google.common.base.Strings; ...@@ -5,6 +5,7 @@ import com.google.common.base.Strings;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils; import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.bean.CodeValidateParam; import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.device.bean.NLShelfOperateBean; import com.neotel.smfcore.core.device.bean.NLShelfOperateBean;
...@@ -86,34 +87,42 @@ public class NLShelfHandler extends BaseDeviceHandler { ...@@ -86,34 +87,42 @@ public class NLShelfHandler extends BaseDeviceHandler {
//亮灯 //亮灯
Collection<DataLog> queueTasks = taskService.getQueueTasks(statusBean.getCid()); Collection<DataLog> queueTasks = taskService.getQueueTasks(statusBean.getCid());
for (DataLog queueTask : queueTasks) { for (DataLog queueTask : queueTasks) {
if (!openZhiYin || StringUtils.isBlank(queueTask.getSourceId())) {
if (queueTask.isWait()) { if (queueTask.isWait()) {
queueTask.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(queueTask);
String rgb = queueTask.getLightColor(); String rgb = queueTask.getLightColor();
ORDER_COLOR color = ORDER_COLOR.fromRgb(rgb); ORDER_COLOR color = ORDER_COLOR.fromRgb(rgb);
if (color == null) { if (color == null) {
if (queueTask.isPutInTask()) { if (queueTask.isPutInTask()) {
color = ORDER_COLOR.DARKGREEN; color = ORDER_COLOR.DARKGREEN;
} else if (openZhiYin && ObjectUtil.isNotEmpty(queueTask.getSourceId())) { } else {
color = ORDER_COLOR.BLUE;
}
}
queueTask.setStatus(OP_STATUS.EXECUTING.name());
taskService.updateQueueTask(queueTask);
statusBean.addData("open", queueTask.getPosName() + "=" + color.name());
log.info("库位[" + queueTask.getPosName() + "][" + queueTask.getType() + "]+亮灯:" + color.name());
}
} else {
if (queueTask.isWait() || queueTask.isExecuting()) {
List<DataLog> dataLogList = outMap.get(queueTask.getSourceId()); List<DataLog> dataLogList = outMap.get(queueTask.getSourceId());
if (dataLogList == null) { if (dataLogList == null) {
dataLogList = new ArrayList<>(); dataLogList = new ArrayList<>();
} }
dataLogList.add(queueTask); dataLogList.add(queueTask);
outMap.put(queueTask.getSourceId(), dataLogList); outMap.put(queueTask.getSourceId(), dataLogList);
} else {
color = ORDER_COLOR.BLUE;
}
} }
statusBean.addData("open",queueTask.getPosName()+"="+color.name());
log.info("库位[" + queueTask.getPosName() + "]["+queueTask.getType()+"]+亮灯:" + color.name());
} }
} }
List<DataLog> dataLogs = getLightGuideTask(outMap); List<DataLog> dataLogs = getLightGuideTask(outMap);
for (DataLog task : dataLogs) { for (DataLog task : dataLogs) {
statusBean.addData("open", task.getPosName() + "=" + ORDER_COLOR.fromRgb(task.getLightColor()).name()); String colorName = ORDER_COLOR.fromRgb(task.getLightColor()).name();
statusBean.addData("open", task.getPosName() + "=" + colorName);
log.info("库位[" + task.getPosName() + "][" + task.getType() + "]+亮灯:" + colorName);
} }
return statusBean; return statusBean;
} }
...@@ -314,6 +323,7 @@ public class NLShelfHandler extends BaseDeviceHandler { ...@@ -314,6 +323,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
NLShelfOperateBean operateBean = getOperateBean(token); NLShelfOperateBean operateBean = getOperateBean(token);
operateBean.setOpPos(pos); operateBean.setOpPos(pos);
operateBean.setPosToClose(pos); operateBean.setPosToClose(pos);
operateBean.setLastPosId(pos.getId());
shelfPutInBeanMap.put(token, operateBean); shelfPutInBeanMap.put(token, operateBean);
log.info(ptoken + ":库位[" + pos.getPosName() + "]操作成功,请扫描要放入的物料"); log.info(ptoken + ":库位[" + pos.getPosName() + "]操作成功,请扫描要放入的物料");
return ResultBean.newOkResult("smfcore.shelf.msg.tipScanReel", "库位[" + pos.getPosName() + "]操作成功,请扫描要放入的物料", new String[]{pos.getPosName()},pos.getPosName()); return ResultBean.newOkResult("smfcore.shelf.msg.tipScanReel", "库位[" + pos.getPosName() + "]操作成功,请扫描要放入的物料", new String[]{pos.getPosName()},pos.getPosName());
...@@ -412,10 +422,40 @@ public class NLShelfHandler extends BaseDeviceHandler { ...@@ -412,10 +422,40 @@ public class NLShelfHandler extends BaseDeviceHandler {
NLShelfOperateBean operateBean = getOperateBean(token); NLShelfOperateBean operateBean = getOperateBean(token);
StoragePos opPos = operateBean.getOpPos(); StoragePos opPos = operateBean.getOpPos();
if (opPos == null) { if (opPos == null) {
String lastPosId = operateBean.getLastPosId();
if (StringUtils.isBlank(lastPosId)){
//未扫描库位 //未扫描库位
log.info(ptoken + ":条码[" +code+ "],请先扫描库位码"); log.info(ptoken + ":条码[" +code+ "],请先扫描库位码");
return ResultBean.newErrorResult(1, "smfcore.shelf.msg.scanPos", "请先扫描库位码"); return ResultBean.newErrorResult(1, "smfcore.shelf.msg.scanPos", "请先扫描库位码");
} else { } else {
long updateTime = operateBean.getUpdateTime();
if (System.currentTimeMillis() - updateTime > 1000 * 60 * 5){
log.info("上一次操作超过10分钟,重新扫描库位码");
return ResultBean.newErrorResult(1, "smfcore.shelf.msg.scanPos", "请先扫描库位码");
}
}
Long nextPosId = Long.valueOf(lastPosId) + 1;
StoragePos nextPos = storagePosManager.get(String.valueOf(nextPosId));
if(nextPos != null){
Collection<String> excludePosIds = taskService.excludePosIds();
if(excludePosIds.contains(nextPos.getId())){
return ResultBean.newErrorResult(1, "smfcore.shelf.nextPos.hasTask", "库位[{0}]已有任务,请重新扫描库位码",new String[]{nextPos.getPosName()});
}
//先关闭上一个库位
StoragePos posToClose = operateBean.getPosToClose();
if (posToClose != null){
opPosLight("close", posToClose, "");
}
opPos = nextPos;
openAndCloseLights(token, opPos,putInColor,delayCloseTime);
operateBean.setOpPos(opPos);
operateBean.setPosToClose(opPos);
operateBean.setLastPosId(opPos.getId());
shelfPutInBeanMap.put(token, operateBean);
}
}
if (opPos != null){
Storage currentStorage=dataCache.getStorageById(opPos.getStorageId()); Storage currentStorage=dataCache.getStorageById(opPos.getStorageId());
//入库单验证 //入库单验证
ResultBean resultBean= inListCache.inListValidate(currentStorage.getInListName(),barcode.getPartNumber() ); ResultBean resultBean= inListCache.inListValidate(currentStorage.getInListName(),barcode.getPartNumber() );
...@@ -438,6 +478,7 @@ public class NLShelfHandler extends BaseDeviceHandler { ...@@ -438,6 +478,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
log.error("Error:" + e.getMessage()); log.error("Error:" + e.getMessage());
return ResultBean.newErrorResult(1, e.getMessage(), e.getMessage(), e.getMsgParam()); return ResultBean.newErrorResult(1, e.getMessage(), e.getMessage(), e.getMsgParam());
} }
return ResultBean.newErrorResult(1, "smfcore.shelf.msg.scanPos", "请先扫描库位码");
} }
/** /**
......
package com.neotel.smfcore.core.device.rest; package com.neotel.smfcore.core.device.rest;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
...@@ -11,9 +12,13 @@ import com.neotel.smfcore.common.exception.ValidateException; ...@@ -11,9 +12,13 @@ import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants; import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.ReelLockPosUtil; import com.neotel.smfcore.common.utils.ReelLockPosUtil;
import com.neotel.smfcore.common.utils.SecurityUtils; import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi; import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.api.bean.CodeValidateParam; import com.neotel.smfcore.core.api.bean.CodeValidateParam;
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.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.core.barcode.utils.CodeResolve; import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.bean.PosInfo; import com.neotel.smfcore.core.device.bean.PosInfo;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
...@@ -63,6 +68,12 @@ public class DeviceController { ...@@ -63,6 +68,12 @@ public class DeviceController {
@Autowired @Autowired
private IStoragePosManager storagePosManager; private IStoragePosManager storagePosManager;
@Autowired
private IComponentManager componentManager;
@Autowired
private IBarcodeManager barcodeManager;
/** /**
* 权限验证API列表 * 权限验证API列表
*/ */
...@@ -629,4 +640,167 @@ public class DeviceController { ...@@ -629,4 +640,167 @@ public class DeviceController {
data.put("plateH", pos.getBarcode().getHeight() + ""); data.put("plateH", pos.getBarcode().getHeight() + "");
return ResultBean.newOkResult(data); return ResultBean.newOkResult(data);
} }
@ApiOperation("根据条码返回尺寸信息")
@RequestMapping("/service/store/getHeightandWidthByCode")
@ResponseBody
@AnonymousAccess
public ResultBean getHeightandWidthByCode(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("code");
if (StringUtils.isNotBlank(code)) {
Barcode barcode = codeResolve.resolveCode(code);
if (barcode != null) {
String partNumber = barcode.getPartNumber();
Component component = componentManager.findOneByPN(partNumber);
if (component != null) {
Map<String,Object> resultMap = new HashMap<>();
resultMap.put("partNumber",partNumber);
resultMap.put("plateSize",component.getPlateSize());
resultMap.put("height",component.getHeight());
return ResultBean.newOkResult(resultMap);
}
}
}
return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"commpont", code});
}
@ApiOperation("获取需要移动的库位是否有料")
@RequestMapping("/service/store/needMovePosHasReel")
@ResponseBody
@AnonymousAccess
public ResultBean needMovePosHasReel(@RequestBody Map<String, String> paramMap) {
String checkOutPosName = paramMap.get("checkOutPosName");
String needMovePosName = paramMap.get("needMovePosName");
log.info("出库的库位为:"+checkOutPosName+",需要移动的库位为:"+needMovePosName);
StoragePos checkOutPos = storagePosManager.getByPosName(checkOutPosName);
if (checkOutPos == null) {
return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"posName", checkOutPosName});
}
StoragePos needMovePos = storagePosManager.getByPosName(needMovePosName);
if (needMovePos == null) {
return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"posName", needMovePosName});
}
//如果barcode不为空,则提前锁定目标库位
boolean hasReel = true;
Barcode barcode = needMovePos.getBarcode();
if (barcode != null) {
Storage storage = dataCache.getStorageById(checkOutPos.getStorageId());
ReelLockPosInfo reelLocInfo = new ReelLockPosInfo();
reelLocInfo.setBarcode(barcode.getBarcode());
reelLocInfo.setCid(storage.getCid());
reelLocInfo.setLockPosName(checkOutPos.getPosName());
reelLocInfo.setLockPosId(checkOutPos.getId());
ReelLockPosUtil.addReelLockPosInfo(reelLocInfo, Arrays.asList(storage.getCid()));
log.info("提前锁定库位:" + checkOutPos.getPosName() + ",barcode为:" + barcode.getBarcode());
} else {
hasReel = false;
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("hasReel", hasReel);
if (hasReel){
resultMap.put("barcode", barcode.getBarcode());
resultMap.put("partNumber",barcode.getPartNumber());
}
return ResultBean.newOkResult(resultMap);
}
@ApiOperation("移动物料到另外一个库位")
@RequestMapping("/service/store/moveToOtherPos")
@ResponseBody
@AnonymousAccess
public ResultBean moveToOtherPos(@RequestBody Map<String, String> paramMap) {
String needMovePosName = paramMap.get("needMovePosName"); //需要移动的库位
String targetPosName = paramMap.get("targetPosName"); //目标库位
log.info("需要移动的库位为:" + needMovePosName + ",目标库位为:" + targetPosName);
//判断有没有物料
StoragePos needMovePos = storagePosManager.getByPosName(needMovePosName);
Barcode barcode = needMovePos.getBarcode();
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{needMovePosName, "barcode"});
}
//生成一条出库任务
taskService.addTaskToFinished(needMovePos, barcode, "admin-move");
//判断目标库位是否存在
StoragePos targetPos = storagePosManager.getByPosName(targetPosName);
if (targetPos == null) {
return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"posName", targetPosName});
}
taskService.addTaskToFinished(targetPos, barcode, "admin-move");
ReelLockPosUtil.removeReelLockPosInfo(barcode.getBarcode());
return ResultBean.newOkResult("");
}
@ApiOperation("取消任务,禁用库位")
@RequestMapping(value = "/service/store/cancelAndDisable")
@ResponseBody
@AnonymousAccess
public ResultBean cancelAndDisable(HttpServletRequest request) {
String posName = request.getParameter("posName");
if (StringUtils.isNotBlank(posName)) {
DataLog task = null;
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (posName.equals(dataLog.getPosName()) && dataLog.isCheckOutTask() && !dataLog.isFinished()) {
task = dataLog;
break;
}
}
if (task != null) {
boolean result = taskService.cancelTask(task.getId());
if (result) {
StoragePos pos = storagePosManager.getByPosName(posName);
if (pos != null) {
pos.setEnabled(false);
storagePosManager.save(pos);
dataCache.updateDisablePos(pos);
log.info("任务[" + task.getId() + "] posName[" + task.getPosName() + "] Reel Id[" + task.getBarcode() + "]取消成功,禁用库位[" + task.getPosName() + "]");
DeviceMessageUtil.addEnabledPosMessage(pos, SecurityUtils.getCurrentUsername());
Storage storage = dataCache.getStorageById(pos.getStorageId());
if (storage != null) {
dataCache.reloadStorage(storage, "");
}
}
return ResultBean.newOkResult("");
}
} else {
return ResultBean.newErrorResult(1, "smfcore.task.notExist", "Task does not exist");
}
}
return ResultBean.newErrorResult(1, "smfcore.cancelOutTask.fail", "客户端取消入库任务[{0}]失败:{1}", new String[]{posName, ""});
}
@ApiOperation("修改barcode数量")
@RequestMapping("/service/store/updateAmount")
@ResponseBody
@AnonymousAccess
public ResultBean updateAmount(HttpServletRequest request) {
String barcodeStr = request.getParameter("barcode");
String amountStr = request.getParameter("amount");
log.info(barcodeStr + "修改数量为:" + amountStr);
//1.判断物料是否存在
Barcode barcode = barcodeManager.findByBarcode(barcodeStr);
if (barcode == null) {
return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"barcode", barcodeStr});
}
int amount = NumberUtil.parseInt(amountStr);
log.info(barcodeStr + "当前数量为:" + barcode.getAmount() + ",新的数量为:" + amount);
barcode.setAmount(amount);
barcodeManager.save(barcode);
return ResultBean.newOkResult(barcode);
}
} }
...@@ -129,8 +129,11 @@ public class DataCache { ...@@ -129,8 +129,11 @@ public class DataCache {
cacheMap = Maps.newConcurrentMap(); cacheMap = Maps.newConcurrentMap();
List<CacheItem> all = cacheItemDao.findAll(); List<CacheItem> all = cacheItemDao.findAll();
for (CacheItem cacheItem : all) { for (CacheItem cacheItem : all) {
Object cacheValue = cacheItem.getCacheValue();
if(cacheValue != null) {
cacheMap.put(cacheItem.getCacheKey(), cacheItem.getCacheValue()); cacheMap.put(cacheItem.getCacheKey(), cacheItem.getCacheValue());
} }
}
if (cacheMap.get(Constants.CACHE_StopOut) == null) { if (cacheMap.get(Constants.CACHE_StopOut) == null) {
updateCache(Constants.CACHE_StopOut, false); updateCache(Constants.CACHE_StopOut, false);
} }
...@@ -176,7 +179,9 @@ public class DataCache { ...@@ -176,7 +179,9 @@ public class DataCache {
*/ */
public void updateCache(String cacheKey, Object value) { public void updateCache(String cacheKey, Object value) {
cacheItemDao.updateCacheItem(cacheKey, value); cacheItemDao.updateCacheItem(cacheKey, value);
if (value != null){
cacheMap.put(cacheKey, value); cacheMap.put(cacheKey, value);
}
if (cacheKey.equals(Constants.CACHE_CodeRule)) { if (cacheKey.equals(Constants.CACHE_CodeRule)) {
List<String> ruleList = (List<String>) value; List<String> ruleList = (List<String>) value;
codeResolve.updateBarcodeRuleList(ruleList); codeResolve.updateBarcodeRuleList(ruleList);
......
...@@ -9,6 +9,7 @@ import com.neotel.smfcore.common.csv.CsvReader; ...@@ -9,6 +9,7 @@ import com.neotel.smfcore.common.csv.CsvReader;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.FileUtil; import com.neotel.smfcore.common.utils.FileUtil;
import com.neotel.smfcore.common.utils.QueryHelp; import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inList.enums.INLIST_STATUS; import com.neotel.smfcore.core.inList.enums.INLIST_STATUS;
import com.neotel.smfcore.core.inList.rest.bean.dto.InListDto; import com.neotel.smfcore.core.inList.rest.bean.dto.InListDto;
...@@ -73,6 +74,9 @@ public class InListController { ...@@ -73,6 +74,9 @@ public class InListController {
@Autowired @Autowired
private IStorageManager storageManager; private IStorageManager storageManager;
@Autowired
private SmfApi smfApi;
@ApiOperation("上传入库单") @ApiOperation("上传入库单")
@PostMapping(value = "/upload") @PostMapping(value = "/upload")
@AnonymousAccess @AnonymousAccess
...@@ -187,14 +191,18 @@ public class InListController { ...@@ -187,14 +191,18 @@ public class InListController {
String inListName = params.get("inListName"); String inListName = params.get("inListName");
String storageId = params.get("storageId"); String storageId = params.get("storageId");
String groupId = params.get("groupId"); String groupId = params.get("groupId");
if(ObjectUtil.isEmpty(inListName)){ InList inList = null;
if (ObjectUtil.isEmpty(inListName)) {
} } else {
else { inList = inListCache.getInList(inListName);
InList inList = inListCache.getInList(inListName); if (inList == null) {
//如果入库单为空的话,调用api获取
inList = smfApi.fetchInList(inListName);
if (inList == null) { if (inList == null) {
return ResultBean.newErrorResult(1, "smfcore.inlist.notFound", "未找到入库单[{0}]", new String[]{inListName}); return ResultBean.newErrorResult(1, "smfcore.inlist.notFound", "未找到入库单[{0}]", new String[]{inListName});
} }
}
if (inList.getStatus() == INLIST_STATUS.OK) { if (inList.getStatus() == INLIST_STATUS.OK) {
return ResultBean.newErrorResult(1, "smfcore.inlist.listOk", "入库单[{0}]已完成", new String[]{inListName}); return ResultBean.newErrorResult(1, "smfcore.inlist.listOk", "入库单[{0}]已完成", new String[]{inListName});
} }
...@@ -206,11 +214,11 @@ public class InListController { ...@@ -206,11 +214,11 @@ public class InListController {
for (String cid : cidList) { for (String cid : cidList) {
Storage storage = dataCache.getStorage(cid); Storage storage = dataCache.getStorage(cid);
if (storage != null) { if (storage != null) {
if (storage.isType(new DeviceType[]{DeviceType.NLP,DeviceType.NL,DeviceType.NLS})) { if (storage.isType(new DeviceType[]{DeviceType.NLP, DeviceType.NL, DeviceType.NLS})) {
storage.setInListName(inListName); storage.setInListName(inListName);
log.info("设置组[" + groupId + "]料架[" + storage.getName() + "]的入库单为:[" + inListName + "]"); log.info("设置组[" + groupId + "]料架[" + storage.getName() + "]的入库单为:[" + inListName + "]");
storageManager.save(storage); storageManager.save(storage);
dataCache.reloadStorage(storage,""); dataCache.reloadStorage(storage, "");
} }
} }
...@@ -218,15 +226,15 @@ public class InListController { ...@@ -218,15 +226,15 @@ public class InListController {
} else { } else {
Storage storage = dataCache.getStorageById(storageId); Storage storage = dataCache.getStorageById(storageId);
if (storage != null) { if (storage != null) {
if (storage.isType(new DeviceType[]{DeviceType.NLP,DeviceType.NL,DeviceType.NLS})) { if (storage.isType(new DeviceType[]{DeviceType.NLP, DeviceType.NL, DeviceType.NLS})) {
storage.setInListName(inListName); storage.setInListName(inListName);
log.info("设置料架[" + storage.getName() + "]的入库单为:[" + inListName + "]"); log.info("设置料架[" + storage.getName() + "]的入库单为:[" + inListName + "]");
storageManager.save(storage); storageManager.save(storage);
dataCache.reloadStorage(storage,""); dataCache.reloadStorage(storage, "");
} }
} }
} }
return ResultBean.newOkResult("smfcore.inlist.setOk", "设置成功"); return ResultBean.newOkResult(inListMapper.toDto(inList));
} }
@ApiOperation("下载入库单模板") @ApiOperation("下载入库单模板")
......
...@@ -9,6 +9,7 @@ import lombok.NoArgsConstructor; ...@@ -9,6 +9,7 @@ import lombok.NoArgsConstructor;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Data @Data
@Document @Document
...@@ -58,12 +59,14 @@ public class InListItem extends BasePo implements Serializable { ...@@ -58,12 +59,14 @@ public class InListItem extends BasePo implements Serializable {
private List<ItemReelInfo> reelLists; private List<ItemReelInfo> reelLists;
public void addReelInfo(ItemReelInfo reelInfo){ public void addReelInfo(ItemReelInfo reelInfo){
if(ObjectUtil.isEmpty(ri)){ if(ObjectUtil.isEmpty(ri)){
inNum+=reelInfo.getInNum(); inNum+=reelInfo.getInNum();
}else{ }else{
inNum=num; inNum=num;
} }
if (reelLists == null){
reelLists = new ArrayList<>();
}
reelLists.add(reelInfo); reelLists.add(reelInfo);
inReelCount+=1; inReelCount+=1;
......
...@@ -129,7 +129,7 @@ public class InListCache { ...@@ -129,7 +129,7 @@ public class InListCache {
for (InListItem item : inList.getInListItems() for (InListItem item : inList.getInListItems()
) { ) {
if (item.getNum() != item.getInNum()) { if (item.getNum() > item.getInNum()) {
listOk = false; listOk = false;
break; break;
} }
...@@ -137,7 +137,7 @@ public class InListCache { ...@@ -137,7 +137,7 @@ public class InListCache {
if (listOk) { if (listOk) {
inList.setStatus(INLIST_STATUS.OK); inList.setStatus(INLIST_STATUS.OK);
log.info("UpdateInList 入库单[" + inListName + "]更改状态为:OK"); log.info("UpdateInList 入库单[" + inListName + "]更改状态为:OK");
} else if (updateOk) { } else if (!listOk && updateOk) {
inList.setStatus(INLIST_STATUS.ABNORMAL); inList.setStatus(INLIST_STATUS.ABNORMAL);
log.info("UpdateInList 入库单[" + inListName + "]更改状态为:ABNORMAL"); log.info("UpdateInList 入库单[" + inListName + "]更改状态为:ABNORMAL");
} }
......
...@@ -63,13 +63,23 @@ public class MessageUtils { ...@@ -63,13 +63,23 @@ public class MessageUtils {
private static Map<String,Map<String, LanguageMsg>> msgMap = new HashMap<>(); private static Map<String,Map<String, LanguageMsg>> msgMap = new HashMap<>();
private static ILanguageMsgManager languageMsgManager;
private static DataCache dataCache;
private static LanguageMsgService messageService;
@Autowired @Autowired
ILanguageMsgManager languageMsgManager; void setLanguageMsgManager(ILanguageMsgManager languageMsgManager) {
@Autowired MessageUtils.languageMsgManager = languageMsgManager;
DataCache dataCache; }
@Autowired @Autowired
LanguageMsgService messageService; void SetDataCache(DataCache dataCache) {
MessageUtils.dataCache = dataCache;
}
@Autowired
void SetMessageService(LanguageMsgService messageService) {
MessageUtils.messageService = messageService;
}
public static final String ZH_CN = "zh-CN"; public static final String ZH_CN = "zh-CN";
public static final String ZH_TW = "zh-TW"; public static final String ZH_TW = "zh-TW";
...@@ -157,6 +167,7 @@ public class MessageUtils { ...@@ -157,6 +167,7 @@ public class MessageUtils {
return msg.getMsg(); return msg.getMsg();
} }
log.info("获取资源[" + msgKey + "][" + defaultMsg + "][" + lanType + "]失败:未找到code[" + msgKey + "]"); log.info("获取资源[" + msgKey + "][" + defaultMsg + "][" + lanType + "]失败:未找到code[" + msgKey + "]");
// autoAddMsg(msgKey,defaultMsg,"");
} }
return defaultMsg; return defaultMsg;
} }
...@@ -224,6 +235,23 @@ public class MessageUtils { ...@@ -224,6 +235,23 @@ public class MessageUtils {
return lanList; return lanList;
} }
private static void autoAddMsg(String msgKey, String defaultMsg,String type ) {
try {
if (ObjectUtil.isEmpty(type)) {
type = smfcore;
}
LanguageMsg languageMsg = new LanguageMsg(msgKey, defaultMsg, type);
List<LanguageInfo> list=dataCache.getLanguageList();
for (LanguageInfo lan:list
) {
languageMsg.setContent(lan.getLanCode(),defaultMsg);
}
languageMsg = languageMsgManager.save(languageMsg);
updateMsg(languageMsg);
log.info("autoAddMsg: key=" + msgKey + ",msg=" + defaultMsg + ",type=" + type + ",defLocal=" + getDefaultLocal().toLanguageTag() + "");
} catch (Exception ex) {
log.error("autoAddMsg: key=" + msgKey + ",msg=" + defaultMsg + ",type=" + type + ",defLocal=" + getDefaultLocal().toLanguageTag() + "出错:" + ex.toString());
}
}
} }
...@@ -22,13 +22,20 @@ import java.util.Locale; ...@@ -22,13 +22,20 @@ import java.util.Locale;
@AllArgsConstructor @AllArgsConstructor
public class Message extends BasePo implements Serializable { public class Message extends BasePo implements Serializable {
public static Message newMsg(MessageType type,String deviceName,String deviceId,String module,String msgCode,String msg,String[] msgParams){ public static Message newMsg(MessageType type,String deviceName,String deviceId,String module,String msgCode,String msg,String[] msgParams){
Message message=new Message(deviceName,deviceId,module, type.name(),msgCode,msg,msgParams,null,null,""); Message message=new Message(deviceName,deviceId,module, type.name(),msgCode,msg,msgParams,null,null,"",msgCode,"");
return message; return message;
} }
public static Message newMsg(String type,String deviceName,String deviceId,String module,String msgCode,String msg,String[] msgParams){ public static Message newMsg(String type,String deviceName,String deviceId,String module,String msgCode,String msg,String[] msgParams){
Message message=new Message(deviceName,deviceId,module, type,msgCode,msg,msgParams,null,null,""); Message message=new Message(deviceName,deviceId,module, type,msgCode,msg,msgParams,null,null,"",msgCode,"");
return message;
}
public static Message newMsg(MessageType type,String deviceName,String deviceId,String module,String msgCode,String msg,String[] msgParams,String alarmType,String alarmCode){
Message message=new Message(deviceName,deviceId,module, type.name(),msgCode,msg,msgParams,null,null,"",alarmType,alarmCode);
return message;
}
public static Message newMsg(String type,String deviceName,String deviceId,String module,String msgCode,String msg,String[] msgParams,String alarmType,String alarmCode){
Message message=new Message(deviceName,deviceId,module, type,msgCode,msg,msgParams,null,null,"",alarmType,alarmCode);
return message; return message;
} }
/** /**
...@@ -75,6 +82,14 @@ public class Message extends BasePo implements Serializable { ...@@ -75,6 +82,14 @@ public class Message extends BasePo implements Serializable {
*/ */
private String operator; private String operator;
/**
* 报警类型
*/
public String alarmType="";
/**
*报警错误码
*/
public String alarmCode="";
public void addData(String key,String value){ public void addData(String key,String value){
if(dataList==null){ if(dataList==null){
dataList=new ArrayList<>(); dataList=new ArrayList<>();
......
...@@ -96,6 +96,20 @@ public class DeviceMessageUtil { ...@@ -96,6 +96,20 @@ public class DeviceMessageUtil {
messageManager.save(message); messageManager.save(message);
} }
} }
public static void addDeviceMessage(String cid,String msgType, String moudle, String msgCode, String msg, String[] msgParam,String almType,String almCode) {
DeviceInfo deviceInfo=getDeviceName(cid);
if (deviceInfo!=null) {
String code=msgCode;
if(ObjectUtil.isNotEmpty(msgCode)){
if(!msgCode.startsWith(MessageUtils.smfcore)){
code=MessageUtils.smfcore+"."+msgCode;
}
}
Message message=Message.newMsg(msgType ,deviceInfo.getName(), deviceInfo.getId(), moudle, code,msg,msgParam,almType,almCode);
messageManager.save(message);
}
}
public static void addOnlineMessage(String cid, String moudle,String ip) { public static void addOnlineMessage(String cid, String moudle,String ip) {
DeviceInfo deviceInfo=getDeviceName(cid); DeviceInfo deviceInfo=getDeviceName(cid);
......
...@@ -215,16 +215,26 @@ public class LiteOrderCache { ...@@ -215,16 +215,26 @@ public class LiteOrderCache {
* 结束当前的任务 * 结束当前的任务
*/ */
public void finishedOrderTasks(LiteOrder liteOrder){ public void finishedOrderTasks(LiteOrder liteOrder){
boolean noCloseWorkOrder = false;
Object cache = dataCache.getCache(Constants.CACHE_closeWorkOrder);
if (cache != null){
noCloseWorkOrder = Boolean.valueOf(cache.toString());
}
if(liteOrder.isOutOne()){ if(liteOrder.isOutOne()){
// setStatus(LITEORDER_STATUS.ONE_FINISHED); if (noCloseWorkOrder){
liteOrder.setStatus(LITEORDER_STATUS.ONE_FINISHED);
} else {
liteOrder.setClosed(true); liteOrder.setClosed(true);
}
}else if(liteOrder.isOutBom()){ }else if(liteOrder.isOutBom()){
liteOrder.setStatus(LITEORDER_STATUS.BOM_FINISHED); liteOrder.setStatus(LITEORDER_STATUS.BOM_FINISHED);
}else if(liteOrder.isOutTails()){ }else if(liteOrder.isOutTails()){
// setStatus(LITEORDER_STATUS.TAILS_FINISHED); if (noCloseWorkOrder){
liteOrder.setStatus(LITEORDER_STATUS.TAILS_FINISHED);
} else {
liteOrder.setClosed(true); liteOrder.setClosed(true);
} }
}
liteOrder.setTaskFinishedTime(System.currentTimeMillis()); liteOrder.setTaskFinishedTime(System.currentTimeMillis());
smfApi.onOrderStatusChange(liteOrder); smfApi.onOrderStatusChange(liteOrder);
} }
...@@ -699,7 +709,7 @@ public class LiteOrderCache { ...@@ -699,7 +709,7 @@ public class LiteOrderCache {
} }
public LiteOrder getOrderSortItems(String sourceId) { public LiteOrder getOrderSortItems(String sourceId) {
LiteOrder order = liteOrderManager.findByOrderNo(sourceId); LiteOrder order = liteOrderManager.get(sourceId);
if (order != null && order.getOrderItems().size() > 0) { if (order != null && order.getOrderItems().size() > 0) {
List<LiteOrderItem> list = order.getOrderItems(); List<LiteOrderItem> list = order.getOrderItems();
//根据站位号排序 //根据站位号排序
......
...@@ -244,13 +244,16 @@ public class SpBoxHandler extends BaseDeviceHandler { ...@@ -244,13 +244,16 @@ public class SpBoxHandler extends BaseDeviceHandler {
serverExceptions.remove(storage.getCid()); serverExceptions.remove(storage.getCid());
} catch (ValidateException e) { } catch (ValidateException e) {
log.warn(statusBean.getCode() + "入库到" + storage.getCid() + "失败:" + e.getMessage()); // log.warn(statusBean.getCode() + "入库到" + storage.getCid() + "失败:" + e.getMessage());
statusBean.setMsg(e.getMessage()); // statusBean.setMsg(e.getMessage());
statusBean.setMsgCode(e.getMsgKey()); // statusBean.setMsgCode(e.getMsgKey());
String msgEn = MessageUtils.getText(e.getMsgKey(), e.getMsgParam(), new Locale("en","US"), e.getMessage()); // String msgEn = MessageUtils.getText(e.getMsgKey(), e.getMsgParam(), new Locale("en","US"), e.getMessage());
String msgJp = MessageUtils.getText(e.getMsgKey(), e.getMsgParam(), new Locale("ja","JP"), e.getMessage()); // String msgJp = MessageUtils.getText(e.getMsgKey(), e.getMsgParam(), new Locale("ja","JP"), e.getMessage());
statusBean.setMsgEn(msgEn); // statusBean.setMsgEn(msgEn);
statusBean.setMsgJp(msgJp); // statusBean.setMsgJp(msgJp);
statusBean.setRMsg(e.getMsgKey(),e.getMsgParam(),e.getMessage());
log.warn(statusBean.getCode() + "入库到" + storage.getCid() + "失败:" + e.getMessage()+","+statusBean.getMsg()+","+statusBean.getMsgEn()+","+statusBean.getMsgJp());
serverExceptions.put(storage.getCid(), e); serverExceptions.put(storage.getCid(), e);
} catch (Exception e) { } catch (Exception e) {
log.error(statusBean.getCode() + "入库到" + storage.getCid() + "失败", e); log.error(statusBean.getCode() + "入库到" + storage.getCid() + "失败", e);
......
...@@ -81,6 +81,7 @@ public class SettingsController { ...@@ -81,6 +81,7 @@ public class SettingsController {
Integer expiresDay=dataCache.getCache(Constants.CACHE_ExpiresDay); Integer expiresDay=dataCache.getCache(Constants.CACHE_ExpiresDay);
Integer caWarn=dataCache.getCache(Constants.CACHE_CapacityWarn); Integer caWarn=dataCache.getCache(Constants.CACHE_CapacityWarn);
Integer backUpMonth = dataCache.getCache(Constants.BACKUP_MONTH_KEY); Integer backUpMonth = dataCache.getCache(Constants.BACKUP_MONTH_KEY);
boolean closeWorkOrder = dataCache.getCache(Constants.CACHE_closeWorkOrder);
SysSettingsDto dto = new SysSettingsDto(); SysSettingsDto dto = new SysSettingsDto();
dto.setStartJob(startJob); dto.setStartJob(startJob);
dto.setStopOut(stopOut); dto.setStopOut(stopOut);
...@@ -88,6 +89,7 @@ public class SettingsController { ...@@ -88,6 +89,7 @@ public class SettingsController {
dto.setExpiresDay(expiresDay); dto.setExpiresDay(expiresDay);
dto.setCapacityWarn(caWarn); dto.setCapacityWarn(caWarn);
dto.setBackUpMonth(backUpMonth); dto.setBackUpMonth(backUpMonth);
dto.setCloseWorkOrder(closeWorkOrder);
return dto; return dto;
} }
...@@ -101,8 +103,10 @@ public class SettingsController { ...@@ -101,8 +103,10 @@ public class SettingsController {
dataCache.updateCache(Constants.CACHE_ExpiresDay,sysSettingsDto.getExpiresDay()); dataCache.updateCache(Constants.CACHE_ExpiresDay,sysSettingsDto.getExpiresDay());
dataCache.updateCache(Constants.CACHE_CapacityWarn,sysSettingsDto.getCapacityWarn()); dataCache.updateCache(Constants.CACHE_CapacityWarn,sysSettingsDto.getCapacityWarn());
dataCache.updateCache(Constants.BACKUP_MONTH_KEY,sysSettingsDto.getBackUpMonth()); dataCache.updateCache(Constants.BACKUP_MONTH_KEY,sysSettingsDto.getBackUpMonth());
dataCache.updateCache(Constants.CACHE_closeWorkOrder,sysSettingsDto.isCloseWorkOrder());
log.info("更改系统设置:stopout=" + sysSettingsDto.isStopOut() + ",stopjob=" + sysSettingsDto.isStartJob()+",sluggishDay="+sysSettingsDto.getSluggishDay() log.info("更改系统设置:stopout=" + sysSettingsDto.isStopOut() + ",stopjob=" + sysSettingsDto.isStartJob()+",sluggishDay="+sysSettingsDto.getSluggishDay()
+",expiresDay="+sysSettingsDto.getExpiresDay()+",capacityWarn="+sysSettingsDto.getCapacityWarn()+",backUpMonth="+sysSettingsDto.getBackUpMonth()); +",expiresDay="+sysSettingsDto.getExpiresDay()+",capacityWarn="+sysSettingsDto.getCapacityWarn()+",backUpMonth="+sysSettingsDto.getBackUpMonth()
+",缺料不自动关闭工单="+sysSettingsDto.isCloseWorkOrder());
return ResultBean.newOkResult("保存成功"); return ResultBean.newOkResult("保存成功");
} }
......
...@@ -27,4 +27,7 @@ public class SysSettingsDto implements Serializable { ...@@ -27,4 +27,7 @@ public class SysSettingsDto implements Serializable {
@ApiModelProperty("备份时间") @ApiModelProperty("备份时间")
private Integer backUpMonth=0; private Integer backUpMonth=0;
@ApiModelProperty("缺料不自动关闭工单")
private boolean closeWorkOrder = false;
} }
...@@ -3,6 +3,7 @@ package com.neotel.smfcore.core.system.util; ...@@ -3,6 +3,7 @@ package com.neotel.smfcore.core.system.util;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.neotel.smfcore.common.utils.SecurityUtils; import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.device.bean.MsgInfo;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.message.enums.MessageType; import com.neotel.smfcore.core.message.enums.MessageType;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil; import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
...@@ -44,6 +45,7 @@ public class DevicesStatusUtil { ...@@ -44,6 +45,7 @@ public class DevicesStatusUtil {
statusBean.setMsgCode(msgBean.getMsgCode()); statusBean.setMsgCode(msgBean.getMsgCode());
statusBean.setMsgParam(msgBean.getMsgParam()); statusBean.setMsgParam(msgBean.getMsgParam());
statusBean.setMsgJp(msgBean.getMsgJp()); statusBean.setMsgJp(msgBean.getMsgJp());
statusBean.setMsgList(msgBean.getMsgList());
} }
} }
return statusBean; return statusBean;
...@@ -55,75 +57,111 @@ public class DevicesStatusUtil { ...@@ -55,75 +57,111 @@ public class DevicesStatusUtil {
public static void updateStatusBean(StatusBean statusBean) { public static void updateStatusBean(StatusBean statusBean) {
statusMap.put(statusBean.getCid(), statusBean); statusMap.put(statusBean.getCid(), statusBean);
} }
//
// /**
// * 更新客户端发上来的消息(设备故障等消息)
// */
// public static StatusBean updateClientMsg(String cid,String msgCode, String clientMsg, String clientMsgEn,String clientMsgJp,String[] msgParam) {
// if (clientMsg == null) {
// clientMsg = "";
// clientMsgEn = "";
// clientMsgJp="";
// }
// if(msgCode==null){
// msgCode="";
// }
// if(clientMsg==null){
// clientMsg="";
// }
// //判断消息是否有内容
// if(ObjectUtil.isNotEmpty(msgCode)||ObjectUtil.isNotEmpty(clientMsg)){
// boolean newMsg=true;
// //和上个消息是否一样
// StatusBean msgBean=clientMsgs.get(cid);
// if(msgBean!=null) {
//// if (msgBean.msgTimeOut()) {
//// newMsg = true;
//// } else
// if (msgBean.getMsgCode().equals(msgCode) && msgBean.getMsg().equals(clientMsg)) {
// newMsg = false;
// }
// }
// if(newMsg){
//
// //判断是否有换行
// String[] msgArray=clientMsg.split("\r\n");
// if(msgArray!=null&& msgArray.length>0) {
// for (String msg :
// msgArray) {
// String msgType = MessageType.ERROR.name();
// if (msg.startsWith("A=")) {
// msgType = MessageType.ERROR.name();
// msg = msg.substring(2);
// } else if (msg.startsWith("I=")) {
// msgType = MessageType.INFO.name();
// msg = msg.substring(2);
// } else if (msg.startsWith("W=")) {
// msgType = MessageType.WARNING.name();
// msg = msg.substring(2);
// }
// DeviceMessageUtil.addDeviceMessage(cid, msgType, "", msgCode, msg, msgParam);
// }
// }
// else {
// DeviceMessageUtil.addDeviceMessage(cid, MessageType.ERROR.name(), "", msgCode, clientMsg, msgParam);
// }
// }
// }
//
// StatusBean statusBean = new StatusBean();
// statusBean.setCid(cid);
// statusBean.setTime(System.currentTimeMillis());
// statusBean.setMsg(clientMsg);
// statusBean.setMsgEn(clientMsgEn);
// statusBean.setMsgCode(msgCode);
// statusBean.setMsgParam(msgParam);
// statusBean.setMsgJp(clientMsgJp);
// clientMsgs.put(cid, statusBean);
// return statusBean;
// }
/** /**
* 更新客户端发上来的消息(设备故障等消息) * 更新客户端发上来的消息(设备故障等消息)
*/ */
public static StatusBean updateClientMsg(String cid,String msgCode, String clientMsg, String clientMsgEn,String clientMsgJp,String[] msgParam) { public static StatusBean updateClientMsg(String cid, List<MsgInfo> msgs) {
if (clientMsg == null) {
clientMsg = "";
clientMsgEn = "";
clientMsgJp="";
}
if(msgCode==null){
msgCode="";
}
if(clientMsg==null){
clientMsg="";
}
//判断消息是否有内容 //判断消息是否有内容
if(ObjectUtil.isNotEmpty(msgCode)||ObjectUtil.isNotEmpty(clientMsg)){ if (msgs != null && msgs.size() > 0) {
boolean newMsg=true;
//和上个消息是否一样
StatusBean msgBean=clientMsgs.get(cid);
if(msgBean!=null) {
// if (msgBean.msgTimeOut()) {
// newMsg = true;
// } else
if (msgBean.getMsgCode().equals(msgCode) && msgBean.getMsg().equals(clientMsg)) {
newMsg = false;
}
}
if(newMsg){
//判断是否有换行 StatusBean msgBean = clientMsgs.get(cid);
String[] msgArray=clientMsg.split("\r\n"); List<MsgInfo> oldMsgs = msgBean.getMsgList();
if(msgArray!=null&& msgArray.length>0) { for (MsgInfo msg :
for (String msg : msgs) {
msgArray) { boolean newMsg = true;
String msgType = MessageType.ERROR.name();
if (msg.startsWith("A=")) { if (oldMsgs != null) {
msgType = MessageType.ERROR.name(); for (MsgInfo old :
msg = msg.substring(2); oldMsgs) {
} else if (msg.startsWith("I=")) { if (old.getMsgKey().equals(msg.getMsgKey()) && old.getMsg().equals(msg.getMsg())) {
msgType = MessageType.INFO.name(); newMsg = false;
msg = msg.substring(2); break;
} else if (msg.startsWith("W=")) {
msgType = MessageType.WARNING.name();
msg = msg.substring(2);
} }
DeviceMessageUtil.addDeviceMessage(cid, msgType, "", msgCode, msg, msgParam);
} }
} }
else { if (newMsg) {
DeviceMessageUtil.addDeviceMessage(cid, MessageType.ERROR.name(), "", msgCode, clientMsg, msgParam); DeviceMessageUtil.addDeviceMessage(cid, MessageType.ERROR.name(), "", msg.getMsgKey(), msg.getMsg(), msg.getMsgParam(),msg.getAlarmType(),msg.getAlarmCode());
} }
} }
} }
StatusBean statusBean = new StatusBean(); StatusBean statusBean = new StatusBean();
statusBean.setCid(cid); statusBean.setCid(cid);
statusBean.setTime(System.currentTimeMillis()); statusBean.setTime(System.currentTimeMillis());
statusBean.setMsg(clientMsg); statusBean.setMsgList(msgs);
statusBean.setMsgEn(clientMsgEn);
statusBean.setMsgCode(msgCode);
statusBean.setMsgParam(msgParam);
statusBean.setMsgJp(clientMsgJp);
clientMsgs.put(cid, statusBean); clientMsgs.put(cid, statusBean);
return statusBean; return statusBean;
} }
/** /**
* 主要用来存储感应料架库位报警信息 * 主要用来存储感应料架库位报警信息
*/ */
......
...@@ -941,6 +941,12 @@ public class TaskService { ...@@ -941,6 +941,12 @@ public class TaskService {
task.setBarcode(barcode.getBarcode()); task.setBarcode(barcode.getBarcode());
task.setNum(barcode.getAmount()); task.setNum(barcode.getAmount());
//如果入库单不为空,设置入库单
Storage storage = dataCache.getStorageById(pos.getStorageId());
if (storage != null && StringUtils.isNotBlank(storage.getInListName())){
task.setSourceName(storage.getInListName());
}
dataCache.updateInventory(pos, barcode); dataCache.updateInventory(pos, barcode);
//dataCache.updateStorage(task.getCid()); //dataCache.updateStorage(task.getCid());
......
...@@ -67,6 +67,7 @@ public class IriichiApi extends BaseSmfApiListener { ...@@ -67,6 +67,7 @@ public class IriichiApi extends BaseSmfApiListener {
"?customloadmethod=IR_GetJobMaterialPickListSp" + "?customloadmethod=IR_GetJobMaterialPickListSp" +
"&readonly=true" + "&readonly=true" +
"&loadtype=NEXT" + "&loadtype=NEXT" +
"&RowCap=0" +
"&customloadmethodparms=" + orderNumber, headerMap, null); "&customloadmethodparms=" + orderNumber, headerMap, null);
log.info(orderNumber+"fetchOrder结果为:"+result); log.info(orderNumber+"fetchOrder结果为:"+result);
return getOrderByResult(orderNumber, result); return getOrderByResult(orderNumber, result);
...@@ -121,7 +122,9 @@ public class IriichiApi extends BaseSmfApiListener { ...@@ -121,7 +122,9 @@ public class IriichiApi extends BaseSmfApiListener {
headerMap.put("Accept", IriichiConfig.accept); headerMap.put("Accept", IriichiConfig.accept);
try { try {
log.info("获取token参数为:"+ JSON.toJSONString(headerMap));
String result = HttpHelper.getJson(IriichiConfig.token_url, headerMap, null); String result = HttpHelper.getJson(IriichiConfig.token_url, headerMap, null);
log.info("获取token出参为:"+ result);
JSONObject jsonObject = JSONObject.parseObject(result); JSONObject jsonObject = JSONObject.parseObject(result);
if ("Success".equals(jsonObject.getString("Message"))) { if ("Success".equals(jsonObject.getString("Message"))) {
return jsonObject.getString("Token"); return jsonObject.getString("Token");
......
...@@ -2,12 +2,10 @@ package com.neotel.smfcore.custom.iriichi1081.config; ...@@ -2,12 +2,10 @@ package com.neotel.smfcore.custom.iriichi1081.config;
public class IriichiConfig { public class IriichiConfig {
//config name // token url 测试环境
public static final String iriichi_config_name = "app_neotel"; //public static final String token_url = "http://192.168.60.249/IDORequestService/MGRestService.svc/json/token/IRIICHI_CRP";
public static final String iriichi_crp_config_name = "Neotel@478*";
// token url public static final String token_url = "http://192.168.60.249/IDORequestService/MGRestService.svc/json/token/IRIICHI";
public static final String token_url = "http://192.168.60.249/IDORequestService/MGRestService.svc/json/token/IRIICHI_CRP";
// Job Material Picklist url 在配置文件中,配置fetchOrderUrl 地址 // Job Material Picklist url 在配置文件中,配置fetchOrderUrl 地址
//public static final String picklist_url = "http://192.168.60.249/IDORequestService/MGRestService.svc/json/IR_SLAPIs/pick_list,job,job_suffix,job_item,job_item_desc,item_code,Rating,workcenter,vendnum,vendor_name,qty_to_pick/adv"; //public static final String picklist_url = "http://192.168.60.249/IDORequestService/MGRestService.svc/json/IR_SLAPIs/pick_list,job,job_suffix,job_item,job_item_desc,item_code,Rating,workcenter,vendnum,vendor_name,qty_to_pick/adv";
......
...@@ -8,6 +8,7 @@ import com.neotel.smfcore.core.device.bean.BoxStatusBean; ...@@ -8,6 +8,7 @@ import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean; import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.message.enums.MessageType; import com.neotel.smfcore.core.message.enums.MessageType;
import com.neotel.smfcore.core.report.bean.ChartItem; import com.neotel.smfcore.core.report.bean.ChartItem;
import com.neotel.smfcore.core.storage.bean.UsageItem; import com.neotel.smfcore.core.storage.bean.UsageItem;
...@@ -109,10 +110,18 @@ public class MicronStatusController { ...@@ -109,10 +110,18 @@ public class MicronStatusController {
} }
//料仓状态 //料仓状态
List<String> boxList = new ArrayList<>(); List<String> boxList = new ArrayList<>();
for (int i = 1; i <= 8; i++ // for (int i = 1; i <= 8; i++
) { // ) {
boxList.add("M" + i); // boxList.add("M" + i);
} // }
boxList.add("KTS-R001A");
boxList.add("KTS-R001B");
boxList.add("KTS-R001C");
boxList.add("KTS-R001D");
boxList.add("KTS-R002A");
boxList.add("KTS-R002B");
boxList.add("KTS-R002C");
boxList.add("KTS-R002D");
// SBDH1, SBDH2, SBDH3, SBSH1, SBSH2 // SBDH1, SBDH2, SBDH3, SBSH1, SBSH2
boxList.add("SBDH1-1"); boxList.add("SBDH1-1");
boxList.add("SBDH1-2"); boxList.add("SBDH1-2");
...@@ -156,7 +165,6 @@ public class MicronStatusController { ...@@ -156,7 +165,6 @@ public class MicronStatusController {
dto.getMsgList().add(dtoMsg); dto.getMsgList().add(dtoMsg);
// } // }
} }
return dto; return dto;
} }
...@@ -165,9 +173,9 @@ public class MicronStatusController { ...@@ -165,9 +173,9 @@ public class MicronStatusController {
Map<String, Storage> allStorages = dataCache.getAllStorage(); Map<String, Storage> allStorages = dataCache.getAllStorage();
for (Storage storage : for (Storage storage :
allStorages.values()) { allStorages.values()) {
if (storage.getCid().contains(boxName)) { if (storage.getCid().contains(boxName.trim())) {
cids.add(storage.getCid()); cids.add(storage.getCid());
}else if(storage.getName().equals(boxName)){ }else if(storage.getName().trim().equals(boxName.trim())){
cids.add(storage.getCid()); cids.add(storage.getCid());
} }
} }
...@@ -213,12 +221,17 @@ public class MicronStatusController { ...@@ -213,12 +221,17 @@ public class MicronStatusController {
else if(dto.getStatus()==0) { else if(dto.getStatus()==0) {
dto.setStatus(1); dto.setStatus(1);
} }
Map<String,String> msgMap=s.getMsgMap(); Map<String,String> msgMap=s.getMsgMap(locale);
if(msgMap!=null&&msgMap.size()>0) { if(msgMap!=null&&msgMap.size()>0) {
String name=cid;
Storage storage=dataCache.getStorage(cid);
if(storage!=null){
name=storage.getName();
}
for (String msg : for (String msg :
msgMap.keySet()) { msgMap.keySet()) {
String type= msgMap.getOrDefault(msg, ""); String type= msgMap.getOrDefault(msg, "");
dto.getMsgList().add(new EquipMsg(cid, s.getStatus(), msg, new Date(s.getTime()), type.toUpperCase(), "", "", new String[]{})); dto.getMsgList().add(new EquipMsg(name, s.getStatus(), msg, new Date(s.getTime()), type.toUpperCase(), "", "", new String[]{}));
} }
} }
// String msg=s.getErrorMsg(locale); // String msg=s.getErrorMsg(locale);
...@@ -245,6 +258,7 @@ public class MicronStatusController { ...@@ -245,6 +258,7 @@ public class MicronStatusController {
for (String cid : for (String cid :
cids) { cids) {
Storage storage = dataCache.getStorage(cid); Storage storage = dataCache.getStorage(cid);
String name=storage.getName();
for (UsageItem item : storage.getUsageMap().values() for (UsageItem item : storage.getUsageMap().values()
) { ) {
useCount += item.getUsedCount(); useCount += item.getUsedCount();
...@@ -259,21 +273,21 @@ public class MicronStatusController { ...@@ -259,21 +273,21 @@ public class MicronStatusController {
dto.setHumidity(humidity); dto.setHumidity(humidity);
dto.setTemperature(temperature); dto.setTemperature(temperature);
} }
dto.getStatuMap().put(cid, boxStatus.getStatus()); dto.getStatuMap().put(name, boxStatus.getStatus());
dto.getMsgMap().put(cid, statusBean.getErrorMsg(servletRequest.getLocale())); dto.getMsgMap().put(name, statusBean.getErrorMsg(servletRequest.getLocale()));
} }
}else{ }else{
dto.getStatuMap().put(cid,0); dto.getStatuMap().put(name,0);
dto.getMsgMap().put(cid,""); dto.getMsgMap().put(name,"");
} }
//出入库报表 默认过去一周到现在的 //出入库报表 默认过去一周到现在的
Calendar time = Calendar.getInstance(); Calendar time = Calendar.getInstance();
time.setTime(new Date()); time.setTime(new Date());
time.add(Calendar.DAY_OF_YEAR, -6); time.add(Calendar.DAY_OF_YEAR, -6);
String today = DateUtil.toDateTimeString(new Date()); String today = DateUtil.toDateString(new Date(),"MM/dd/yyyy");
List<ChartItem> chartItems = storageManager.getRunStatusData(time.getTime(), new Date(), "",cids); List<ChartItem> chartItems = storageManager.getRunStatusData(time.getTime(), new Date(), "",cids);
for (ChartItem chartItem : for (ChartItem chartItem :
...@@ -313,10 +327,12 @@ public class MicronStatusController { ...@@ -313,10 +327,12 @@ public class MicronStatusController {
String[] nameList = new String[]{}; String[] nameList = new String[]{};
String robotName = "R1"; String robotName = "R1";
if (boxName.equals("MI1")) { if (boxName.equals("MI1")) {
nameList = new String[]{"M3", "M4", "M7", "M8"}; // nameList = new String[]{"M3", "M4", "M7", "M8"};
nameList = new String[]{"KTS-R001A", "KTS-R001B", "KTS-R001C", "KTS-R001D"};
robotName = "R1"; robotName = "R1";
} else if (boxName.equals("MI2")) { } else if (boxName.equals("MI2")) {
nameList = new String[]{"M1", "M2", "M5", "M6"}; // nameList = new String[]{"M1", "M2", "M5", "M6"};
nameList = new String[]{ "KTS-R002A", "KTS-R002B","KTS-R002C", "KTS-R002D"};
robotName = "R2"; robotName = "R2";
} }
...@@ -430,7 +446,7 @@ public class MicronStatusController { ...@@ -430,7 +446,7 @@ public class MicronStatusController {
// if (ObjectUtil.isNotEmpty(msg)) { // if (ObjectUtil.isNotEmpty(msg)) {
// count += 1; // count += 1;
// } // }
Map<String, String> msgMap = statusBean.getMsgMap(); Map<String, String> msgMap = statusBean.getMsgMap(MessageUtils.getDefaultLocal());
if (msgMap != null && msgMap.size() > 0) { if (msgMap != null && msgMap.size() > 0) {
for (String msg : for (String msg :
msgMap.keySet()) { msgMap.keySet()) {
......
package com.neotel.smfcore.custom.nanrui;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.exception.ApiException;
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.api.listener.BaseSmfApiListener;
import com.neotel.smfcore.core.inList.service.po.InList;
import com.neotel.smfcore.core.inList.service.po.InListItem;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
public class NanRuiApi extends BaseSmfApiListener {
@Override
public boolean isForThisApi(String apiName) {
return "nanrui".equals(apiName);
}
@Override
public InList fetchInList(String fetchInListUrl, String number) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("api", NanRuiConfig.api);
paramMap.put("format", NanRuiConfig.format);
Map<String, String> dataParamMap = new HashMap<>();
dataParamMap.put("number", number);
String dataStr = JSON.toJSONString(dataParamMap);
//dataStr = URLEncoder.encode(dataStr);
paramMap.put("data", dataStr);
Map<String, String> headerMap = new HashMap<>();
headerMap.put("X-DB", NanRuiConfig.X_DB_PROD);
headerMap.put("Content-Type", NanRuiConfig.contentType);
try {
log.info("调用获取入库单接口,参数" + JsonUtil.toJsonStr(paramMap));
String result = HttpHelper.postParam(fetchInListUrl, paramMap, headerMap);
log.info(number + "获取入库单接口返回" + result);
ApiResult apiResult = JsonUtil.toObj(result, ApiResult.class);
if (apiResult.isOk()) {
Map<String, Object> dataMap = (Map<String, Object>) apiResult.getData();
String returnNumber = dataMap.get("number").toString();
InList inList = new InList();
inList.setName(returnNumber);
List<InListItem> items = new ArrayList<>();
List<Map<String, Object>> itemList = (List<Map<String, Object>>) dataMap.get("items");
for (Map<String, Object> itemMap : itemList) {
String partNum = itemMap.get("partNum").toString();
Object qtyStr = itemMap.get("qty");
Object reelCountStr = itemMap.get("reelCount");
InListItem item = new InListItem();
item.setPN(partNum);
if (qtyStr != null && !qtyStr.toString().isEmpty()) {
item.setNum(Integer.valueOf(qtyStr.toString()));
}
if (reelCountStr != null && !qtyStr.toString().isEmpty()) {
item.setInReelCount(Integer.valueOf(reelCountStr.toString()));
}
//判断list里边有没有数据
boolean hasSample = false;
for (int i = 0; i < items.size(); i++) {
InListItem listItem = items.get(i);
if (listItem.getPN().equals(item.getPN())){
hasSample = true;
log.info(partNum+"存在相同的partNumber,上一条数量为:"+listItem.getNum()+",当前数量为:"+item.getNum());
listItem.setNum(listItem.getNum() + item.getNum());
//listItem.setInReelCount();
items.set(i,listItem);
log.info(partNum+"合并后的数量为:"+listItem.getNum());
}
}
if (!hasSample) {
items.add(item);
}
}
inList.setInListItems(items);
log.info("获取到入库单:" + inList.getName() + ",共" + items.size() + "条工单详情");
inList = inListManager.createWithItems(inList);
inListCache.addInListToMap(inList);
return inList;
} else {
throw new ApiException("smfcore.fetchInList.ng", "获取入库单MES返回NG:" + apiResult.getMsg());
}
} catch (Exception e) {
log.error(number + "获取入库单接口出错:" + e.getMessage());
return null;
}
}
}
package com.neotel.smfcore.custom.nanrui;
public class NanRuiConfig {
public static final String X_DB_TEST ="nari-wms-test";
public static final String X_DB_PROD ="nari-wms-prod";
public static final String contentType ="application/x-www-form-urlencoded";
public static final String api = "wms.task.replenishment";
public static final String format = "json";
}
...@@ -27,7 +27,7 @@ public class LotCheckInfo implements Serializable { ...@@ -27,7 +27,7 @@ public class LotCheckInfo implements Serializable {
public static LotCheckInfo toObj(String lotId,String result) { public static LotCheckInfo toObj(String lotId,String result) {
try { try {
Map<String, Object> map = JsonUtil.toMap(result); Map<String, Object> map = JsonUtil.toMap(result);
Object statusStr = map.containsKey("Status"); Object statusStr = map.get("Status");
if (statusStr != null) { if (statusStr != null) {
boolean s = Boolean.parseBoolean(statusStr.toString()); boolean s = Boolean.parseBoolean(statusStr.toString());
LotCheckInfo lotCheckInfo = new LotCheckInfo(); LotCheckInfo lotCheckInfo = new LotCheckInfo();
......
...@@ -380,3 +380,4 @@ smfcore.agv.dispatch=\u8D27\u7269\u5DF2\u7ECF\u53D1\u9001\u5230\u5B58\u50A8\u7CF ...@@ -380,3 +380,4 @@ smfcore.agv.dispatch=\u8D27\u7269\u5DF2\u7ECF\u53D1\u9001\u5230\u5B58\u50A8\u7CF
smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A
smfcore.agv.operation=AGV\u5728\u8FD0\u884C\u4E2D smfcore.agv.operation=AGV\u5728\u8FD0\u884C\u4E2D
smfcore.boxmimokanban=\u4E91\u6599\u4ED3\u770B\u677F smfcore.boxmimokanban=\u4E91\u6599\u4ED3\u770B\u677F
smfcore.neoai=Neo Ai
\ No newline at end of file \ No newline at end of file
...@@ -371,3 +371,4 @@ smfcore.agv.dispatch=Goods dispatched to storage system ...@@ -371,3 +371,4 @@ smfcore.agv.dispatch=Goods dispatched to storage system
smfcore.agv.awaitingInstruction=Awaiting instruction smfcore.agv.awaitingInstruction=Awaiting instruction
smfcore.agv.operation=AGV is in operation smfcore.agv.operation=AGV is in operation
smfcore.boxmimokanban=SMD BOX KANBAN smfcore.boxmimokanban=SMD BOX KANBAN
smfcore.neoai=Neo Ai
\ No newline at end of file \ No newline at end of file
...@@ -367,3 +367,4 @@ smfcore.agv.awaitingInstruction=\u6307\u793A\u5F85\u3061 ...@@ -367,3 +367,4 @@ smfcore.agv.awaitingInstruction=\u6307\u793A\u5F85\u3061
smfcore.agv.operation=AGV\u52D5\u4F5C\u4E2D\u3067\u3059 smfcore.agv.operation=AGV\u52D5\u4F5C\u4E2D\u3067\u3059
smfcore.boxmimokanban=\u30AF\u30E9\u30A6\u30C9\u5009\u5EAB\u30AB\u30F3\u30D0\u30F3 smfcore.boxmimokanban=\u30AF\u30E9\u30A6\u30C9\u5009\u5EAB\u30AB\u30F3\u30D0\u30F3
smfcore.neoai=Neo Ai
\ No newline at end of file \ No newline at end of file
...@@ -367,3 +367,4 @@ smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A ...@@ -367,3 +367,4 @@ smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A
smfcore.agv.operation=AGV\u5728\u8FD0\u884C\u4E2D smfcore.agv.operation=AGV\u5728\u8FD0\u884C\u4E2D
smfcore.boxmimokanban=\u4E91\u6599\u4ED3\u770B\u677F smfcore.boxmimokanban=\u4E91\u6599\u4ED3\u770B\u677F
smfcore.neoai=Neo Ai
\ No newline at end of file \ No newline at end of file
...@@ -367,3 +367,4 @@ smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A ...@@ -367,3 +367,4 @@ smfcore.agv.awaitingInstruction=\u7B49\u5F85\u6307\u793A
smfcore.agv.operation=AGV\u6B63\u5728\u904B\u884C smfcore.agv.operation=AGV\u6B63\u5728\u904B\u884C
smfcore.boxmimokanban=\u96F2\u6599\u5009\u770B\u677F smfcore.boxmimokanban=\u96F2\u6599\u5009\u770B\u677F
smfcore.neoai=Neo Ai
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!