Commit 967875a1 zshaohui

1.迈征对接功能提交

1 个父辈 f18b2cc3
正在显示 18 个修改的文件 包含 175 行增加107 行删除
......@@ -20,6 +20,7 @@ import com.neotel.smfcore.core.order.enums.LITEORDER_STATUS;
import com.neotel.smfcore.core.order.enums.ORDER_COLOR;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderItemManager;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.ItemOutDetail;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.storage.bean.InventoryItem;
......@@ -168,6 +169,12 @@ public class LiteOrderCache {
for (LiteOrder order :
liteOrders) {
//迈征工单不自动出库,其他接口通知出库
if (order.isMaiZheng()){
continue;
}
if (order.isNew() || order.isTaskFinished()) {
if (order.isTaskFinished() && order.isMaiZheng()){
......@@ -344,6 +351,15 @@ public class LiteOrderCache {
liteOrderItem.setTotalOutNum(liteOrderItem.getTotalOutNum() + task.getNum());
liteOrderItem.setTotalOutReelCount(liteOrderItem.getTotalOutReelCount() + 1);
liteOrderItem.setOutReelList(task.getBarcode());
//同时设置详情
ItemOutDetail detail = new ItemOutDetail();
detail.setReelNew(task.getBarcode());
detail.setReelNewLong(task.getFullCode());
detail.setX(task.getX());
detail.setY(task.getY());
liteOrderItem.setOutDetailList(detail);
liteOrderItem.setPositionList(task.getPosName());
liteOrderItem = liteOrderItemManager.save(liteOrderItem);
}
......
package com.neotel.smfcore.core.order.service.po;
import lombok.Data;
@Data
public class ItemOutDetail {
private String reelNew;
private String reelNewLong;
private String x;
private String y;
}
......@@ -166,15 +166,11 @@ public class LiteOrder extends BasePo implements Serializable {
//迈征额外参数
private String guid;
private String processType;
private String cacheIndex;
private String cacheSlot;
private String recvIndex;
private String repoOrder;
private String cacheID;
private String reelBoxID;
private String count;
private String dia;
private String startTime;
private String reelBoxId;
......
......@@ -231,6 +231,7 @@ public class LiteOrderItem extends BasePo implements Serializable ,Comparable<Li
*/
private List<String> outReelList;
private List<ItemOutDetail> outDetailList;
private String width;
......@@ -256,6 +257,13 @@ public class LiteOrderItem extends BasePo implements Serializable ,Comparable<Li
outReelList.add(reel);
}
public void setOutDetailList(ItemOutDetail detail) {
if (outDetailList == null){
outDetailList = new ArrayList<>();
}
outDetailList.add(detail);
}
public void setPositionList(String position) {
if (positionList == null){
positionList = new ArrayList<>();
......
......@@ -362,6 +362,12 @@ public class DataLog extends BasePo implements Serializable {
*/
private int height = 0;
//迈征的 弹夹 x,y坐标
private String x;
private String y;
//完整条码
private String fullCode;
/**
* 出口位置
......
......@@ -99,7 +99,9 @@ public class InnerBoxRestController {
String hSerial = request.getParameter("hSerial"); //工单序号
String outlet = request.getParameter("outlet"); //出口位置
String boxSide = request.getParameter("boxSide"); //料箱隔口
log.info("IA 出库更新任务状态--barcode:{},status:{},loc:{},hSerial:{},outlet:{},boxSide:{},cid:{},outlet:{}", code, status, loc, hSerial, outlet, boxSide,cid,outlet);
String x = request.getParameter("x");
String y = request.getParameter("y");
log.info("IA 出库更新任务状态--barcode:{},status:{},loc:{},hSerial:{},outlet:{},boxSide:{},cid:{},outlet:{},x:{},y:{}", code, status, loc, hSerial, outlet, boxSide,cid,outlet,x,y);
CodeBean codeBean = codeResolve.resolveSingleCode(code);
Barcode barcode = codeBean.getBarcode();
......@@ -134,6 +136,14 @@ public class InnerBoxRestController {
outFromPos(opTask);
}
opTask.setStatus(status);
if (StringUtils.isNotEmpty(x)){
opTask.setX(x);
}
if (StringUtils.isNotEmpty(y)){
opTask.setY(y);
}
opTask.setFullCode(barcode.getFullCode());
taskService.moveTaskToFinished(opTask);
//清理锁定库位
ReelLockPosUtil.removeReelLockPosInfo(code);
......
......@@ -62,7 +62,7 @@ public class StorageExportUtil {
//出料口名称
private final static List<String> exportStrArr = Arrays.asList("UM_2", "UM_3", "UM_4", "UM_5");
private final static List<String> exportStrArr = Arrays.asList("UM_1","UM_2", "UM_3", "UM_4", "UM_5");
//料仓前缀
public static final String EXPORT_PREFIX = "Storage_Export";
......
......@@ -71,6 +71,8 @@ public class KafkaService {
//故障
boolean fault = false;
String ip = "";
List<Map<String, String>> msgList = new ArrayList<>();
for (Storage storage : storages) {
if (machineId.equals(storage.getMachineId())) {
......@@ -85,6 +87,7 @@ public class KafkaService {
fault = true;
}
}
ip = statusBean.getClientIp();
String msg = statusBean.getMsg();
String errorCode = statusBean.getErrorCode();
if (StringUtils.isNotBlank(msg) && StringUtils.isNotBlank(errorCode)) {
......@@ -124,7 +127,7 @@ public class KafkaService {
status.setMachineID(machineId);
status.setTopicType(KafkaConfig.MACHINESTATUS_TOPIC);
status.setCurrentStatus(currentStatus);
status.setClientIP("");
status.setClientIP(ip);
if (msgList != null && !msgList.isEmpty()) {
for (Map<String, String> map : msgList) {
......@@ -336,7 +339,7 @@ public class KafkaService {
machineStatus.setCurrentStatus(currentStatus);
machineStatus.setErrorCode(equipMsg.getErrorCode());
machineStatus.setErrorMsg(equipMsg.getMsg());
machineStatus.setClientIP("");
machineStatus.setClientIP(statusBean.getClientIp());
String statusStr = JSON.toJSONString(machineStatus);
log.info("出料口主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.MACHINESTATUS_TOPIC, statusStr);
......@@ -351,7 +354,7 @@ public class KafkaService {
machineStatus.setCurrentStatus(currentStatus);
machineStatus.setErrorCode("");
machineStatus.setErrorMsg("");
machineStatus.setClientIP("");
machineStatus.setClientIP(statusBean.getClientIp());
String statusStr = JSON.toJSONString(machineStatus);
log.info("出料口主题为:" + KafkaConfig.MACHINESTATUS_TOPIC + "内容为:" + statusStr);
ListenableFuture future = kafkaTemplate.send(KafkaConfig.MACHINESTATUS_TOPIC, statusStr);
......
......@@ -57,7 +57,7 @@ public class MaiZhengApi {
public String transReelBox(LiteOrder liteOrder) {
Map<String, Object> paramMap = new HashMap<>();
/*Map<String, Object> paramMap = new HashMap<>();
paramMap.put("GUID", liteOrder.getGuid());
paramMap.put("CacheIndex", liteOrder.getCacheIndex());
paramMap.put("CacheSlot", liteOrder.getCacheSlot());
......@@ -96,14 +96,18 @@ public class MaiZhengApi {
} catch (Exception e) {
log.error("智能仓储备料完成后请求发料报错:" + e.getMessage());
return e.getMessage();
}
}*/
return "";
}
public void prepareReelBox(String guid, String result) {
public void prepareReelBox(String repoOrder, String result,String startTime) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("GUID", guid);
paramMap.put("Result", result);
paramMap.put("RepoOrder", repoOrder);
paramMap.put("StartTime", startTime);
if ("OK".equals(result)) {
paramMap.put("Result", true);
}
log.info("仓储回复可以开始备料入参为:" + JSON.toJSONString(paramMap));
try {
......@@ -116,7 +120,8 @@ public class MaiZhengApi {
public void workIdCancelApi(String guid) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("GUID", guid);
paramMap.put("RepoOrder", guid);
paramMap.put("Reason", "工单异常,手动取消");
log.info("仓储请求取消工单入参为:" + JSON.toJSONString(paramMap));
try {
String resultStr = HttpHelper.postJson(workIdCancleApi, paramMap);
......
......@@ -6,13 +6,10 @@ import java.util.List;
@Data
public class AskReelBox {
private String GUID;
private String ProcessType;
private String CacheIndex;
private String CacheSlot;
private String RecvIndex;
private String RepoOrder;
private String CacheID;
private String ReelBoxID;
private String Count;
private String Dia;
private String StartTime;
private List<AskReelBoxList> List;
}
......@@ -26,8 +26,4 @@ public class AskReelBoxList {
private String VENDOR;
private String Pitch;
private String Num;
private String Width;
private String Dia;
private String REQ_REEL;
private String REQ_QTY;
}
......@@ -9,7 +9,7 @@ import java.util.List;
@Data
public class AskReelIDStateRequest {
private String Guid;
private String SessionID;
private String Count;
......
......@@ -10,8 +10,8 @@ import java.util.List;
@Data
public class AskReelIDStateResponse {
@JSONField(name = "Guid")
private String Guid;
@JSONField(name = "SessionID")
private String SessionID;
@JSONField(name = "Count")
private String Count;
......
......@@ -15,6 +15,6 @@ public class AskReelIDStateResponseList {
private String State;
@JSONField(name = "WorkID")
private String WorkID;
private String RepoOrder;
}
......@@ -94,9 +94,9 @@ public class MaiZhengController {
public Map<String, String> askReelBox(@RequestBody AskReelBox askReelBox) {
log.info("收到迈征请求数据为:" + JSON.toJSONString(askReelBox));
String result = "OK";
askReelBoxMap.put(askReelBox.getGUID(), askReelBox);
askReelBoxMap.put(askReelBox.getRepoOrder(), askReelBox);
Map<String, String> resultMap = new HashMap<>();
resultMap.put("GUID", askReelBox.getGUID());
resultMap.put("RepoOrder", askReelBox.getRepoOrder());
resultMap.put("Result", result);
return resultMap;
}
......@@ -111,8 +111,9 @@ public class MaiZhengController {
if (askReelBoxMap != null && !askReelBoxMap.isEmpty()) {
for (Map.Entry<String, AskReelBox> entry : askReelBoxMap.entrySet()) {
log.info("开始处理:" + entry.getKey() + "的数据");
String result = createMaiZhengOrder(entry.getKey(), entry.getValue());
maiZhengApi.prepareReelBox(entry.getKey(), result);
AskReelBox askReelBox = entry.getValue();
String result = createMaiZhengOrder(entry.getKey(),askReelBox);
maiZhengApi.prepareReelBox(entry.getKey(), result,askReelBox.getStartTime());
log.info("处理结束:" + entry.getKey() + "的数据,结果为:" + result);
}
askReelBoxMap.clear();
......@@ -142,14 +143,11 @@ public class MaiZhengController {
if (liteOrder == null) {
liteOrder = new LiteOrder();
}
liteOrder.setOrderNo(askReelBox.getGUID());
liteOrder.setGuid(askReelBox.getGUID());
liteOrder.setCacheIndex(askReelBox.getCacheIndex());
liteOrder.setCacheSlot(askReelBox.getCacheSlot());
liteOrder.setRecvIndex(askReelBox.getRecvIndex());
liteOrder.setOrderNo(askReelBox.getRepoOrder());
liteOrder.setCacheID(askReelBox.getCacheID());
liteOrder.setRepoOrder(askReelBox.getRepoOrder());
liteOrder.setReelBoxID(askReelBox.getReelBoxID());
liteOrder.setCount(askReelBox.getCount());
liteOrder.setReelBoxId(StorageExportUtil.getMaizhengExport());
liteOrder.setDia(askReelBox.getDia());
liteOrder.setStartTime(askReelBox.getStartTime());
liteOrder.setMaiZheng(true);
......@@ -173,8 +171,6 @@ public class MaiZhengController {
item.setSubSlot(box.getSUBSLOT());
item.setPn(box.getPARTNUMBER());
item.setReel(box.getREEL());
item.setWidth(box.getWidth());
item.setDia(box.getDia());
item.setOrderId(liteOrder.getId());
item.setOrderNo(liteOrder.getOrderNo());
......@@ -200,7 +196,7 @@ public class MaiZhengController {
log.info("收到迈征请求指定Reel的位置:" + JSON.toJSONString(request));
String guid = request.getGuid();
String sessionID = request.getSessionID();
String count = request.getCount();
List<AskReelIDStateResponseList> responseList = new ArrayList<>();
......@@ -210,7 +206,7 @@ public class MaiZhengController {
AskReelIDStateResponseList reelIDResponse = new AskReelIDStateResponseList();
reelIDResponse.setState("0");
reelIDResponse.setReelID(reelId);
reelIDResponse.setWorkID("");
reelIDResponse.setRepoOrder("");
//判断是否在库存中
StoragePos storagePos = storagePosManager.getByBarcode(reelId);
if (storagePos != null) {
......@@ -223,7 +219,7 @@ public class MaiZhengController {
if (!dataLog.isCancel() && StringUtils.isNotBlank(dataLog.getSourceId()) && dataLog.isCheckOutTask()) {
log.info(reelId + ":已经绑定工单发出,工单号为:" + dataLog.getSourceName());
reelIDResponse.setState("2");
reelIDResponse.setWorkID(dataLog.getSourceName());
reelIDResponse.setRepoOrder(dataLog.getSourceName());
}
}
}
......@@ -231,7 +227,7 @@ public class MaiZhengController {
}
AskReelIDStateResponse response = new AskReelIDStateResponse();
response.setGuid(guid);
response.setSessionID(sessionID);
response.setCount(count);
response.setList(responseList);
log.info(JSON.toJSONString(response));
......
......@@ -3,9 +3,12 @@ package com.neotel.smfcore.custom.lizhen.third.maicheng.controller;
import com.alibaba.fastjson.JSON;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.order.LiteOrderCache;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.ItemOutDetail;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.lizhen.innerBox.bean.StorageExport;
import com.neotel.smfcore.custom.lizhen.innerBox.util.StorageExportUtil;
......@@ -18,10 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@RestController
......@@ -38,6 +39,9 @@ public class MaiZhengDeviceController {
@Autowired
private MaiZhengApi maiZhengApi;
@Autowired
private LiteOrderCache liteOrderCache;
@ApiOperation("请求迈征是否可以运送")
@RequestMapping("/transReelBox")
@AnonymousAccess
......@@ -73,7 +77,7 @@ public class MaiZhengDeviceController {
String material = export.getMaterial();
if (StringUtils.isNotBlank(material)){
liteOrder.setReelBoxId(material);
//liteOrder.setReelBoxId(material);
}
//请求迈征的接口,是否可以放入
......@@ -91,54 +95,87 @@ public class MaiZhengDeviceController {
@ApiOperation("获取迈征请求数据")
@RequestMapping("/getTransReelBoxData")
@AnonymousAccess
public ResultBean getTransReelBoxData(String exportStr) {
StorageExport export = StorageExportUtil.getExport(exportStr + StorageExportUtil.OUT_STATION);
log.info(exportStr + "获取到出料口信息为:" + JSON.toJSONString(export));
String hSerial = export.getHSerial();
if (StringUtils.isBlank(hSerial)) {
return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{exportStr, "hSerial"});
}
public ResultBean getTransReelBoxData(String orderNo) {
LiteOrder liteOrder = liteOrderManager.findByOrderNo(hSerial);
if (liteOrder == null) {
return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"orderNo", hSerial});
if (StringUtils.isEmpty(orderNo)){
return ResultBean.newErrorResult(-1,"","工单号不能为空");
}
String material = export.getMaterial();
if (StringUtils.isNotBlank(material)) {
liteOrder.setReelBoxId(material);
LiteOrder liteOrder = liteOrderManager.findByOrderNo(orderNo);
if (liteOrder == null) {
return ResultBean.newErrorResult(-1, "smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"orderNo", orderNo});
}
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("GUID", liteOrder.getGuid());
paramMap.put("CacheIndex", liteOrder.getCacheIndex());
paramMap.put("CacheSlot", liteOrder.getCacheSlot());
paramMap.put("RecvIndex", liteOrder.getRecvIndex());
paramMap.put("Count", liteOrder.getCount());
paramMap.put("ReelBoxID", liteOrder.getReelBoxId());
paramMap.put("Dia", liteOrder.getDia());
paramMap.put("StartTime", liteOrder.getStartTime());
paramMap.put("RepoOrder",liteOrder.getOrderNo());
paramMap.put("Count",liteOrder.getCount());
paramMap.put("CacheID",liteOrder.getCacheID());
paramMap.put("ReelBoxID",liteOrder.getReelBoxID());
paramMap.put("StartTime",liteOrder.getStartTime());
List<Map<String, Object>> list = new ArrayList<>();
List<LiteOrderItem> orderItemList = liteOrder.getOrderItems();
for (LiteOrderItem orderItem : orderItemList) {
List<String> outReelList = orderItem.getOutReelList();
if (outReelList != null && !outReelList.isEmpty()) {
for (int i = 0; i < outReelList.size(); i++) {
Map<String, Object> itemMap = new HashMap<>();
itemMap.put("Position", orderItem.getPositionList().get(i));
itemMap.put("PARTNUMBER", orderItem.getPn());
itemMap.put("REEL", orderItem.getReel());
itemMap.put("REELNew", outReelList.get(i));
itemMap.put("Width", orderItem.getWidth());
itemMap.put("Dia", orderItem.getDia());
list.add(itemMap);
List<ItemOutDetail> outDetailList = orderItem.getOutDetailList();
if (outDetailList != null && !outDetailList.isEmpty()){
for (ItemOutDetail detail : outDetailList) {
Map<String, Object> map = new HashMap<>();
map.put("PARTNUMBER",orderItem.getPn());
map.put("ReelNewLong",detail.getReelNewLong());
map.put("ReelNew",detail.getReelNew());
map.put("ReelOld",orderItem.getReel());
map.put("X",detail.getX());
map.put("Y",detail.getY());
list.add(map);
}
}
}
paramMap.put("List", list);
return ResultBean.newOkResult(paramMap);
}
@ApiOperation("流水线通知服务器出库")
@RequestMapping("/mBoxReady")
@AnonymousAccess
public ResultBean mBoxReady(String boxBarcode) {
//获取迈征出料口信息
StorageExport export = StorageExportUtil.getExport(StorageExportUtil.getMaizhengExport());
log.info("流水线通知服务器出库:"+StorageExportUtil.getMaizhengExport()+"获取到的出料口信息为:"+JSON.toJSONString(export)+"料串为:"+boxBarcode);
int remainCount = 0;
String orderNo = export.getHSerial();
if (StringUtils.isNotEmpty(orderNo)) {
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog dataLog : allTasks) {
if (orderNo.equals(dataLog.getSourceName())){
if (!dataLog.isCancel() && !dataLog.isFinished()){
remainCount ++;
}
}
}
}
if (remainCount > 0){
return ResultBean.newErrorResult(-1,"",orderNo+"正在执行,剩余数量为:"+remainCount);
}
//获取是迈征的,新建的工单
List<LiteOrder> maiZhengOrderList = new ArrayList<>();
for (LiteOrder order : liteOrderCache.getAllLiteOrder()) {
if (order.isMaiZheng() && order.isNew()){
maiZhengOrderList.add(order);
}
}
if (maiZhengOrderList == null || maiZhengOrderList.isEmpty()){
return ResultBean.newErrorResult(-1,"","没有需要执行的迈征工单");
}
//按时间进行排序,获取到第一个
maiZhengOrderList = maiZhengOrderList.stream().sorted(Comparator.comparing(LiteOrder :: getCreateDate)).collect(Collectors.toList());
LiteOrder liteOrder = maiZhengOrderList.get(0);
liteOrderCache.checkOutLiteOrder(liteOrder.getOrderNo(),false,StorageExportUtil.getMaizhengExport());
return ResultBean.newOkResult("");
}
}
......@@ -49,24 +49,7 @@ public class MaiZhengUtil {
}
}
//判断是否一盘没出
boolean hasOut = false;
List<LiteOrderItem> orderItems = liteOrder.getOrderItems();
for (LiteOrderItem orderItem : orderItems) {
if (orderItem.getTotalOutReelCount() > 0){
hasOut = true;
break;
}
}
if (!hasOut){
maiZhengApi.workIdCancelApi(orderNo);
} else {
if (liteOrder.isTransReelBox()){
maiZhengApi.workIdCancelApi(orderNo);
} else {
throw new ValidateException("", "工单:"+orderNo+"当前料串未拉走,不允许关闭");
}
}
}
}
}
......@@ -77,8 +77,8 @@ file:
#迈征配置
maizheng:
stationStatusApi: #http://10.190.196.124:8300/API/MZSM
export: #MU3_1
export: UM_1
transReelBoxApi: #http://10.190.196.124:52232/API/TransReelBoxAuto
prepareReelBoxApi: #http://10.190.196.124:52232/API/PrepareReelBoxAuto
workIdCancleApi: #http://10.190.196.124:52232/API/workIDCancle
prepareReelBoxApi: http://10.68.16.52:52231/API/Repo/PrepareReelBox
workIdCancleApi: http://10.68.16.52:52231/API/Repo/RepoOrderCancle
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!