Commit 7e26e143 zshaohui

功能提交

1 个父辈 add365d1
......@@ -295,6 +295,9 @@ public class Barcode extends BasePo implements Serializable {
*/
private boolean isInventory = false;
//判断是否请求过入库
private boolean askPutIn = false;
/**
* 添加相关联条码
*
......
......@@ -10,6 +10,7 @@ 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.ReelLockPosUtil;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.core.api.listener.ISmfApiListener;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
......@@ -187,6 +188,15 @@ public class DeviceController {
throw new ValidateException("smfcore.error.barcode.expired", "物料已过期,无法入库.");
}
}
//判断库别是否为空
/*Barcode barcode1F = lizhenApi.getBarcode(barcode.getBarcode());
if (barcode1F == null || StringUtils.isEmpty(barcode1F.getWarehouseCode())){
throw new ValidateException("", barcode.getBarcode()+"未找到对应的库别信息");
}
String warhouseCode = barcode1F.getWarehouseCode();*/
String warhouseCode = "";
//判断虚拟仓有没有存在,如果有,把虚拟仓库位置空
StoragePos storagePos = storagePosManager.getByBarcode(barcode.getBarcode());
if (storagePos != null) {
......@@ -242,6 +252,7 @@ public class DeviceController {
barcode = barcodeApi;
}
for (DataLog dataLog : taskService.getAllTasks()) {
// if(!dataLog.isPackageReel()){
//已经在任务当中,返回对应的信息
......@@ -308,6 +319,12 @@ public class DeviceController {
Storage theStorage = dataCache.getStorageById(pos.getStorageId());
//lizhenApi.backToWarehouse(warhouseCode,theStorage.getName(),barcode.getBarcode());
barcode.setWarehouseCode(warhouseCode);
barcode.setAskPutIn(true);
barcode = barcodeManager.save(barcode);
resultMap.put("result", "0");
resultMap.put("msg", "");
......
......@@ -31,6 +31,21 @@ public class Message extends BasePo implements Serializable {
Message message=new Message(deviceName,deviceId,module, type,msgCode,msg,msgParams,null,null,"",errorCode);
return message;
}
public boolean sameMas(Message msg){
if(deviceName.equals(msg.getDeviceName())
&&deviceId.equals(msg.getDeviceId())
&&module.equals(msg.getModule())
&&type.equals(msg.getType())
&&getMsg().equals(msg.getMsg())
&&errorCode.equals(msg.getErrorCode())
){
return true;
}
return false;
}
/**
* 设备名称
*/
......
......@@ -18,6 +18,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.aggregation.ComparisonOperators;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
@Component
public class DeviceMessageUtil {
......@@ -73,6 +77,37 @@ public class DeviceMessageUtil {
return null;
}
private static List<Message> messageList=new ArrayList<>();
private synchronized static boolean msgNeedSave(Message message) {
int TimeOutMs = 20000;
boolean needSave = true;
if (messageList == null) {
messageList = new ArrayList<>();
}
List<Message> oldMsg = new ArrayList<>();
oldMsg.addAll(messageList);
messageList = new ArrayList<>();
message.setCreateDate(new Date());
for (Message msg :
oldMsg) {
long ms = (new Date()).getTime() - msg.getCreateDate().getTime();
if (ms < TimeOutMs) {
if (msg.sameMas(message)) {
needSave = false;
messageList.add(message);
} else {
messageList.add(msg);
}
}
}
if(needSave){
messageList.add(message);
}
return needSave;
}
public static void addDeviceMessage(String cid,String msgType, String moudle, String msgCode, String msg, String[] msgParam,String errorCode) {
DeviceInfo deviceInfo=getDeviceName(cid);
......@@ -84,9 +119,12 @@ public class DeviceMessageUtil {
}
}
Message message=Message.newMsg(msgType ,deviceInfo.getName(), deviceInfo.getId(), moudle, code,msg,msgParam,errorCode);
boolean result=msgNeedSave(message);
if(result){
messageManager.save(message);
}
}
}
public static void addOnlineMessage(String cid, String moudle,String ip) {
DeviceInfo deviceInfo=getDeviceName(cid);
......
......@@ -86,7 +86,7 @@ public class DefaultOrderFileListener implements IOrderFileListener {
}
}
liteOrder.setLine(lineStr);
liteOrder.setSource(LITEORDER_SOURCE.OUTTER.name());
//liteOrder.setSource(LITEORDER_SOURCE.OUTTER.name());
liteOrder = liteOrderManager.createWithItems(liteOrder);
liteOrderCache.addOrderToMap(liteOrder);
return true;
......
......@@ -65,6 +65,13 @@ public class LizhenApi extends DefaultSmfApiListener {
@Value("${api.checkReelMeasure}")
private String checkReelMeasureUrl = "";
@Value("${api.getBarcode}")
private String getBarcodeUrl = "";
@Value("${api.inNotifyUrl}")
private String inNotifyUrl = "";
@PostConstruct
public void init(){
fetchGRUrl = dataCache.getConfigCache("fetchGRUrl",fetchGRUrl);
......@@ -74,6 +81,8 @@ public class LizhenApi extends DefaultSmfApiListener {
werks = dataCache.getConfigCache("werks",werks);
outNotifyUrlPK = dataCache.getConfigCache("api.outNotifyUrlPK",outNotifyUrlPK);
batchCheckUrl = dataCache.getConfigCache("api.batchCheckUrl",batchCheckUrl);
getBarcodeUrl = dataCache.getConfigCache("api.getBarcodeUrl",getBarcodeUrl);
inNotifyUrl = dataCache.getConfigCache("api.getBarcodeUrl",inNotifyUrl);
}
/**
......@@ -260,22 +269,7 @@ public class LizhenApi extends DefaultSmfApiListener {
*/
@Override
public void inTaskStatusChange(String inNotifyUrl, DataLog task) {
if (task.isFinished()){
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("PLANT_CODE", CommonUtil.plantCode);
paramMap.put("RETURN_TYPE", "return_tower"); //退回大库: return 退回料塔: return_tower
paramMap.put("BIN_CODE", task.getPosName());
paramMap.put("REEL_LIST", Arrays.asList(task.getBarcode()));
log.info(task.getBarcode()+"入库通知,调用电子料入退库,请求参数为:"+JSON.toJSONString(paramMap));
try {
String resultStr = HttpHelper.postJson(inNotifyUrl, paramMap);
log.info(task.getBarcode()+"入库通知,调用电子料入退库,结果为:"+resultStr);
} catch (ApiException e) {
e.printStackTrace();
log.info(task.getBarcode()+"入库通知,调用电子料入退库,异常为:"+e.getMessage());
}
}
}
/**
......@@ -439,8 +433,107 @@ public class LizhenApi extends DefaultSmfApiListener {
}
public Barcode getBarcode(String codeStr) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("codeStr",codeStr);
try {
String resultStr = HttpHelper.postJson(getBarcodeUrl, paramMap);
return JsonUtil.toObj(resultStr,Barcode.class);
} catch (ApiException e) {
e.printStackTrace();
log.error(codeStr+"getBarcode报错:"+e.getMessage());
}
return null;
}
public void backToWarehouse(String warhouseCode, String machineName, String barcode) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("PLANT_CODE", CommonUtil.plantCode);
paramMap.put("RETURN_TYPE", "return_tower"); //退回大库: return 退回料塔: return_tower
paramMap.put("BIN_CODE", machineName + warhouseCode);
paramMap.put("REEL_LIST", Arrays.asList(barcode));
log.info(barcode + "入库通知,调用电子料入退库,请求参数为:" + JSON.toJSONString(paramMap));
try {
String resultStr = HttpHelper.postJson(inNotifyUrl, paramMap);
log.info(barcode + "入库通知,调用电子料入退库,结果为:" + resultStr);
JSONObject jsonObject = JSONObject.parseObject(resultStr);
String msgty = jsonObject.getString("MSGTY");
if (!"S".equalsIgnoreCase(msgty)){
throw new ValidateException("",barcode+"调用电子料入退库失败:"+resultStr);
}
} catch (ApiException e) {
e.printStackTrace();
log.info(barcode + "入库通知,调用电子料入退库,异常为:" + e.getMessage());
}
}
@Override
public boolean isForThisApi(String apiName) {
return apiName != null && apiName.equalsIgnoreCase("Lizhen");
}
public static void main(String[] args) {
String resultStr = "{\n" +
" \"MSGTY\": \"S\",\n" +
" \"MSGTX\": \"退回成功\",\n" +
" \"DATA\": {\n" +
" \"inventory_id\": \"21380985746190001\",\n" +
" \"plant_code\": \"W339\",\n" +
" \"material_type\": \"ROH\",\n" +
" \"material_code\": \"118S00258\",\n" +
" \"warehouse_code\": \"W10B\",\n" +
" \"bin_code\": \"Tower2-LW10B\",\n" +
" \"keeper_code\": \"BR013\",\n" +
" \"label_id\": \"L2024051700000039\",\n" +
" \"group_id\": null,\n" +
" \"label_qty\": 20000.0,\n" +
" \"vendor_code\": \"0000797001\",\n" +
" \"vendor_name\": null,\n" +
" \"fl_code\": null,\n" +
" \"allocate_qty\": 0.0,\n" +
" \"ticket_type\": null,\n" +
" \"fifo_priority\": 0,\n" +
" \"extend_days\": 0,\n" +
" \"extend_times\": 0,\n" +
" \"rohs\": null,\n" +
" \"order_no\": null,\n" +
" \"version\": null,\n" +
" \"os_version\": null,\n" +
" \"date_code\": null,\n" +
" \"week_code\": null,\n" +
" \"lot_code\": null,\n" +
" \"remark\": null,\n" +
" \"batch_code\": \"1000000030\",\n" +
" \"expire_date\": null,\n" +
" \"gr_date\": \"2023-08-18 13:21:22\",\n" +
" \"tran_date\": \"2024-05-17 08:42:54\",\n" +
" \"status\": 0,\n" +
" \"reel_qty\": 1.0,\n" +
" \"pack_type\": null,\n" +
" \"brand\": \"CYNTEC\",\n" +
" \"mpn\": null,\n" +
" \"unit\": \"PC\",\n" +
" \"coo\": null,\n" +
" \"region\": null,\n" +
" \"cavity\": null,\n" +
" \"group_code\": null,\n" +
" \"create_at\": \"2024-05-17 08:42:54\",\n" +
" \"create_by\": \"MLB_API\",\n" +
" \"update_at\": null,\n" +
" \"update_by\": null\n" +
" }\n" +
"}";
JSONObject jsonObject = JSONObject.parseObject(resultStr);
String msgty = jsonObject.getString("MSGTY");
String msgty1 = jsonObject.getString("msgty");
System.out.println(msgty);
System.out.println(msgty1);
if (!"S".equalsIgnoreCase(jsonObject.getString("MSGTY")) && !"S".equalsIgnoreCase(jsonObject.getString("msgty"))){
throw new ValidateException("","调用电子料入退库失败:"+resultStr);
}
}
}
......@@ -38,7 +38,7 @@ public class ExpireDateUtil {
}
public static Date getExpireDate(String dateStr, String vendor) {
try {
/*try {
vendor = vendor.toUpperCase(Locale.ROOT);
switch (vendor) {
case "UMT":
......@@ -168,7 +168,7 @@ public class ExpireDateUtil {
log.error(vendor + "---" + dateStr + "生产日期解析出错:" + e.getMessage());
return null;
}
log.error(vendor + "---" + dateStr + "解析失返回为null");
log.error(vendor + "---" + dateStr + "解析失返回为null");*/
return null;
}
......
......@@ -4,3 +4,4 @@ api:
inCheckUrl: http://10.68.21.21:8001/Npm/WmsCheckReelfob #禁用料接口
outNotifyUrl: http://10.68.30.22:8082/api/mlb/TowerIssue
inNotifyUrl: http://10.68.30.22:8082/api/mlb/BackToWarehouse
getBarcode: http://10.68.27.83/smf-core/thirdBarcode/getBarcode
\ No newline at end of file
......@@ -4,3 +4,4 @@ api:
inCheckUrl: http://10.68.21.21:8001/Npm/WmsCheckReelfob #禁用料接口
outNotifyUrl: http://10.42.220.171:8082/api/mlb/TowerIssue
inNotifyUrl: http://10.42.220.171:8082/api/mlb/BackToWarehouse
getBarcode: http://10.68.27.83/smf-core/thirdBarcode/getBarcode
\ No newline at end of file
......@@ -103,5 +103,5 @@ app:
type: ""
menu:
show: #innerMaterial
show: workOrder
hide:
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!