using HH.WCS.Mobox3.HD.core; using HH.WCS.Mobox3.HD.device; using HH.WCS.Mobox3.HD.dispatch; using HH.WCS.Mobox3.HD.models; using HH.WCS.Mobox3.HD.util; using HH.WCS.Mobox3.HD.wms; using Newtonsoft.Json; using S7.Net; using System; using System.Collections.Generic; using System.Linq; using System.Web.Http; using System.Web.UI.WebControls; using static HH.WCS.Mobox3.HD.core.Monitor; using static HH.WCS.Mobox3.HD.dispatch.ShopFloorControl; using static HH.WCS.Mobox3.HD.wms.WCSHelper; using static System.Runtime.CompilerServices.RuntimeHelpers; namespace HH.WCS.Mobox3.HD.api { /// /// 第三方调用的接口 /// [RoutePrefix("api")] public class WmsController : System.Web.Http.ApiController { /// /// 0.心跳监测 /// /// public ResponseResult heatbeat() { ResponseResult result = new ResponseResult() { success = true, result = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; return result; } /// /// 1.创建入库搬运任务 /// /// /// public ResponseResult createInOrder(InStockInfo model) { LogHelper.Info("创建入库搬运任务-createInOrder 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); ResponseResult result = new ResponseResult(); try { result = ApiHelper.createInOrder(model); } catch (BusinessException be) { result.success = false; result.message = be.Message; } catch (Exception ex) { result.success = false; result.message = "内部异常,请联系开发人员处理"; LogHelper.Info($"内部异常,错误信息:{ex.Message}", "车间控制器"); LogHelper.Info(ex.StackTrace, "车间控制器"); } LogHelper.Info("创建入库搬运任务-createInOrder 出参:" + JsonConvert.SerializeObject(result), "车间控制器"); return result; } public class BusinessException : Exception { public BusinessException(string message) : base(message) { } } /// /// 2、创建出库搬运任务 /// /// /// public ResponseResult createOutOrder(OutStockInfo model) { LogHelper.Info("创建出库搬运任务-createOutOrder 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); ResponseResult result = new ResponseResult(); try { result = ApiHelper.createOutOrder(model); } catch (BusinessException be) { result.success = false; result.message = be.Message; } catch (Exception ex) { result.success = false; result.message = "内部异常,请联系开发人员处理"; LogHelper.Info($"内部异常,错误信息:{ex.Message}", "车间控制器"); LogHelper.Info(ex.StackTrace, "车间控制器"); } LogHelper.Info("创建出库搬运任务-createOutOrder 出参:" + JsonConvert.SerializeObject(result), "车间控制器"); return result; } /// /// 3、校验模具信息接口 /// /// public ResponseResult verifyMouldInfo(MouldInfo model) { LogHelper.Info("校验模具信息接口-verifyMouldInfo 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); ResponseResult result = new ResponseResult(); MouldCntr mouldCntr = MouldHelper.GetMouldCntr(new MouldCntr() { S_MOULD_NO = model.mouldNo, S_CNTR_CODE = model.trayCode }); if (mouldCntr == null) { result.success = false; result.message = "模具与托盘不匹配"; } else { result.success = true; result.message = "模具与托盘匹配成功"; } LogHelper.Info("校验模具信息接口-verifyMouldInfo 出参:" + JsonConvert.SerializeObject(result), "车间控制器"); return result; } /// /// 5、灵动AGV任务状态上报 /// /// /// public ResponseResult lingDongAgvTaskStatus(LDAgvTaskInfo model) { LogHelper.Info("灵动AGV任务状态上报-lingDongAgvTaskStatus 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); ResponseResult result = new ResponseResult() { success = true, }; // 1、根据车间控制器任务ID查询WMS作业任务 WMSTask mst = WMSHelper.GetWmsTaskBySrc(model.originNo); if (mst != null) { // 2.查询当前进行中的任务,并判断该任务是否是灵动任务 WCSTask cst = WCSHelper.GetProceedTaskBySrcNo(mst.S_CODE); if (cst != null && cst.S_SCHEDULE_TYPE.Contains("LD")) { var endLoc = LocationHelper.GetLoc(cst.S_END_LOC); // 3、判断任务状态 离开 、完成 if (model.status.Equals("LEAVE")) { // 开始货位解绑物料信息、并解锁 LocationHelper.UnBindingLoc(cst.S_START_LOC, new List { mst.S_CNTR_CODE }); LocationHelper.UnLockLoc(cst.S_START_LOC); var line = WCSHelper.GetLinePlcInfo(cst.S_START_LOC); if (line != null) { S7Helper.WriteInt(line.deviceNo, 101, line.writeAddr + 14, 1); // AGV 取货完成 1 LogHelper.Info("灵动AGV取货完成,并向输送线下发AGV任务反馈", "车间控制器"); } } if (model.status.Equals("FINISH") || ( model.status.Equals("LEAVE") && endLoc==null ) ) { // 终点货位绑定物料信息、并解锁 if (mst.S_TYPE.Contains("入库")) { LocationHelper.BindingLoc(cst.S_END_LOC, new List { mst.S_CNTR_CODE }); } LocationHelper.UnLockLoc(cst.S_END_LOC); WCSHelper.End(cst); var line = WCSHelper.GetLinePlcInfo(cst.S_END_LOC); if (line != null) { S7Helper.WriteInt(line.deviceNo, 101, line.writeAddr + 14, 2); // AGV 放货完成 2 LogHelper.Info("灵动AGV放货完成,并向输送线下发AGV任务反馈", "车间控制器"); } // 4、判断当前任务是否为最后任务,是则结束任务,并记录物料信息 if (mst.S_END_LOC.Equals(cst.S_END_LOC)) { mst.N_B_STATE = 2; mst.T_END_TIME = DateTime.Now; WMSHelper.UpdateTaskState(mst); // 4.1更新出入库记录 var cntrItemRels = ItemHelper.GetCntrItemByCntrCode(mst.S_CNTR_CODE); if (cntrItemRels != null && cntrItemRels.Count > 0) { foreach (var cntrItemRel in cntrItemRels) { WMSHelper.AddStockRecord(mst, cntrItemRel); // 4.2 终点货位在系统中没有维护,则删除物料信息 if (endLoc == null || cntrItemRel.S_ITEM_TYPE.Equals("半成品")) { ContainerHelper.deleteCntrItem(mst.S_CNTR_CODE); } } } else { WMSHelper.AddStockRecord(mst, null); } } else { List areaCdoes = Settings.getStoreAreaCodes(2, 1); if (!areaCdoes.Contains(mst.S_END_AREA) && mst.S_TYPE == "半成品/成品入库" && mst.S_END_LOC =="虚拟货位") { // 横栋半成品称重,并回报车间控制器 float weight = WCSCore.getGjWeight(cst.S_END_LOC, mst.S_CNTR_CODE, mst.S_OP_DEF_CODE); ProductWeightInfo productWeightInfo = new ProductWeightInfo() { wmsId = mst.S_CODE, trayCode = mst.S_CNTR_CODE, weight = weight.ToString(), weightTime = DateTime.Now.ToString(), }; ShopFloorControl.reportSemilFinishedProductWeight(productWeightInfo); // 4.3如当前为一段任务,则需要创建二段任务 string itemCode = null; var cntrItems = ContainerHelper.GetCntrItemRel(mst.S_CNTR_CODE); if (cntrItems != null && cntrItems.Count > 0) { itemCode = cntrItems[0].S_ITEM_CODE; } Location twoEndLoc = WMSHelper.GetEndLocation(mst.S_END_AREA, itemCode, 1, 1); mst.S_END_LOC = twoEndLoc.S_CODE; WMSHelper.UpdateTask(mst); // 创建入库任务 WCSTask twoWcsTask = new WCSTask { S_OP_NAME = mst.S_OP_DEF_NAME, S_OP_CODE = mst.S_CODE, S_CODE = WCSHelper.GenerateTaskNo(), S_CNTR_CODE = mst.S_CNTR_CODE, S_TYPE = mst.S_TYPE + "-2", S_START_LOC = cst.S_END_LOC, S_START_AREA = cst.S_END_AREA, S_END_LOC = mst.S_END_LOC, S_END_AREA = mst.S_END_AREA, S_SCHEDULE_TYPE = "HL" }; if (WCSHelper.CreateTask(twoWcsTask)) { // 接驳位加出库锁,终点货位加入库锁 LocationHelper.LockLoc(twoWcsTask.S_START_LOC, 2); LocationHelper.LockLoc(twoWcsTask.S_END_LOC, 1); } } } } } } else { result.success = false; result.message = "任务已完成"; } LogHelper.Info("灵动AGV任务状态上报-lingDongAgvTaskStatus 出参:" + JsonConvert.SerializeObject(result), "车间控制器"); return result; } /// /// 6.AGV安全交互接口(输送线、拆盘机) /// /// public ResponseResult agvSafeRequest(SafeRequest model ) { LogHelper.Info("AGV安全交互接口-agvSafeRequest 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); ResponseResult responseResult = new ResponseResult() { success = false, }; Location loc = LocationHelper.GetLoc(model.bit); /* var accessAreas = Settings.storeAreaInfos.Where(a => a.areaType == 2 && a.cargoType == 1).Select(a => a.accessArea).ToList(); */ PipelineSignalInfo lineSignalInfo = null; LinePlcInfo linePlcInfo = WCSHelper.GetLinePlcInfo(model.bit); if (linePlcInfo != null) { lineSignalInfo = WCSHelper.readPipelineInfo(linePlcInfo); LogHelper.Info("线体信号: " + JsonConvert.SerializeObject(lineSignalInfo), "车间控制器"); } bool allow = false; if (loc != null ) { switch (model.reqState) { case "1": // 请求取货 LogHelper.Info("请求取货.... " , "车间控制器"); if (lineSignalInfo != null && lineSignalInfo.agvInfo == 2 && (lineSignalInfo.faultMessage == 0 || lineSignalInfo.faultMessage == 1)) { LogHelper.Info("向输送线下发AGV安全信号【9】 ", "车间控制器"); S7Helper.WriteInt(linePlcInfo.deviceNo, 101, linePlcInfo.writeAddr + 16, 9); allow = true; } break; case "2": // 请求放货 LogHelper.Info("请求放货.... ", "车间控制器"); if (lineSignalInfo != null && lineSignalInfo.agvInfo == 1 && (lineSignalInfo.faultMessage == 0 || lineSignalInfo.faultMessage == 1)) { LogHelper.Info("向输送线下发AGV安全信号【9】", "车间控制器"); S7Helper.WriteInt(linePlcInfo.deviceNo, 101, linePlcInfo.writeAddr + 16, 9); allow = true; } break; case "3": // 安全退出 LogHelper.Info("安全退出.... ", "车间控制器"); if (lineSignalInfo != null) { if (linePlcInfo.actType == "入库") { S7Helper.WriteInt(linePlcInfo.deviceNo, 101, linePlcInfo.writeAddr + 14, 2); // AGV 放货完成 2 LogHelper.Info("灵动AGV放货完成,并向输送线下发AGV任务反馈", "车间控制器"); } else if(linePlcInfo.actType == "出库") { S7Helper.WriteInt(linePlcInfo.deviceNo, 101, linePlcInfo.writeAddr + 14, 1); // AGV 取货完成 1 LogHelper.Info("灵动AGV取货完成,并向输送线下发AGV任务反馈", "车间控制器"); } LogHelper.Info("安全退出【0】 ", "车间控制器"); S7Helper.WriteInt(linePlcInfo.deviceNo, 101, linePlcInfo.writeAddr + 16, 0); allow = true; } break; } responseResult.success = allow; } LogHelper.Info("AGV安全交互接口-agvSafeRequest 出参:" + JsonConvert.SerializeObject(responseResult), "车间控制器"); return responseResult; } /// /// 7.查询分页接口(仅限半成品/成品) /// /// public ResponseResult queryItemInfo(QueryItemModel model) { LogHelper.Info("查询分页接口-queryItemInfo 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); PageInfo page = ContainerHelper.GetCntrItemPage(model); ResponseResult result = new ResponseResult() { success = true, result = page }; LogHelper.Info("查询分页接口-queryItemInfo 出参:" + JsonConvert.SerializeObject(result), "车间控制器"); return result; } /// /// 9.模具数量更新 /// /// public ResponseResult mouldNumUpdate(MouldUpdateInfo model) { LogHelper.Info("模具数量更新-mouldNumUpdate 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); ResponseResult responseResult = new ResponseResult(); bool usable = true; // 更新模具类型 和 状态 MouldCntr mouldCntr = MouldHelper.GetMouldCntr(model.mouldNo); if (mouldCntr != null) { mouldCntr.S_MOULD_TYPE = model.mouldType; // 更新子模具数据 var mouldDetails = MouldHelper.GetMouldDetails(model.mouldNo); foreach (var item in mouldDetails) { foreach (var md in model.itemInfoList) { if (item.S_NAME.Equals(md.itemName)) { int currentNum = item.N_QTY; if (model.actionType == "1") { currentNum = currentNum + md.num; } else if (model.actionType == "2") { currentNum = currentNum - md.num; } if (currentNum >= 0) { if (item.N_INIT_QTY > currentNum) { usable = false; } else if (item.N_INIT_QTY < currentNum) { responseResult.success = false; responseResult.message = md.itemName + "当前数量大于初始数量"; return responseResult; } } else { responseResult.success = false; responseResult.message = md.itemName + "当前数量小于0"; return responseResult; } item.N_QTY = currentNum; } } } MouldHelper.updateMouldNum(mouldDetails); /* mouldCntr.S_ABLE_FLAG = usable ? "是" : "否";*/ MouldHelper.updateMouldStatus(mouldCntr); } else { responseResult.success = false; responseResult.message = "未找到该模具,请检查模具号是否正确"; return responseResult; } responseResult.success = true; LogHelper.Info("模具数量更新-mouldNumUpdate 出参:" + JsonConvert.SerializeObject(responseResult), "车间控制器"); return responseResult; } /// /// 11.模具编号数据查询 /// /// public ResponseResult queryByMouldNo(MouldBase model) { LogHelper.Info("模具编号数据查询-queryByMouldNo 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); ResponseResult responseResult = new ResponseResult() { success = true, }; MouldCntr mouldCntr = MouldHelper.GetMouldCntr(new MouldCntr() { S_MOULD_NO = model.mouldNo }); List trayItemInfos = new List(); if (mouldCntr != null) { foreach (var item in mouldCntr.mouldDetails) { TrayMouldInfo trayItemInfo = new TrayMouldInfo() { trayCode = mouldCntr.S_CNTR_CODE, itemCode = mouldCntr.S_ITEM_CODE, itemName = item.S_NAME, mouldNo = mouldCntr.S_MOULD_NO, quantity = item.N_INIT_QTY, }; trayItemInfos.Add(trayItemInfo); } responseResult.result = trayItemInfos; } else { responseResult.success = false; responseResult.message = "没有此模具信息"; } LogHelper.Info("模具编号数据查询-queryByMouldNo 出参:" + JsonConvert.SerializeObject(responseResult), "车间控制器"); return responseResult; } /// /// 12.查询钢卷原始重量 /// /// public ResponseResult queryCoilInitWeight(CoilItemBase model) { LogHelper.Info("查询钢卷原始重量-queryCoilInitWeight 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); ResponseResult responseResult = new ResponseResult() { success = true}; CoilInitWeight coilWeightInfo = new CoilInitWeight(); var coilInfo = ItemHelper.GetCoilItemInfo(model.coilNo); if (coilInfo != null) { coilWeightInfo.initWeight = coilInfo.F_INIT_WEIGHT.ToString(); responseResult.result = coilWeightInfo; } else { responseResult.success = false; responseResult.message = "没有此钢卷信息"; } LogHelper.Info("查询钢卷原始重量-queryCoilInitWeight 出参:" + JsonConvert.SerializeObject(responseResult), "车间控制器"); return responseResult; } /// /// 13.查询窄钢卷最初入库重量 /// /// public ResponseResult queryNarrowCoil(CoilItemBase model) { LogHelper.Info("查询窄钢卷最初入库重量-queryNarrowCoil 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); ResponseResult responseResult = new ResponseResult(){success = true}; List coilInfos = new List(); var coilList = ItemHelper.GetNarrowCoilInfo(model.coilNo); if (coilList != null) { foreach (var item in coilList) { CoilInfo coilInfo = new CoilInfo() { coilNo = item.S_COIL_NO, initWeight = item.F_INIT_WEIGHT.ToString(), }; coilInfos.Add(coilInfo); } responseResult.result = coilInfos; } LogHelper.Info("查询窄钢卷最初入库重量-queryNarrowCoil 出参:" + JsonConvert.SerializeObject(responseResult), "车间控制器"); return responseResult; } /// /// 14.查询空托货位 /// /// public ResponseResult queryEmptyTrayLoc(StationBase station) { LogHelper.Info("查询空托货位-queryEmptyTrayLoc 入参:", "车间控制器"); ResponseResult responseResult = new ResponseResult() { success = true }; int readDB = 100; var devicePlcInfos = Settings.devicePlcInfos.Where(a => a.deviceType == 3).ToList(); if (station != null && station.bit != null) { LinePlcInfo linePlcInfo = WCSHelper.GetLinePlcInfo(station.bit); devicePlcInfos = devicePlcInfos.Where(a => a.deviceNo == linePlcInfo.deviceNo).ToList(); } try { foreach (var item in devicePlcInfos) { string deviceNo = item.deviceNo; short[] segment1 = S7Helper.ReadInt(deviceNo, readDB, 120, 2); short segment2 = S7Helper.ReadInt(deviceNo, readDB, 130); LogHelper.Info(item.deviceName+",编号:"+item.deviceNo+ ",查询拆盘机信号:" + JsonConvert.SerializeObject(segment1), "车间控制器"); if (segment1 != null && segment1[1] == 1 && segment2 == 0) { var sortAreaInfo = Settings.sortAreaInfos.Where(a => a.areaCode == item.area).FirstOrDefault(); if (sortAreaInfo != null) { string loc = sortAreaInfo.outLocCode; var location = LocationHelper.GetLoc(loc); if (location.N_LOCK_STATE == 0) { EmptyTrayLoc emptyTrayLoc = new EmptyTrayLoc() { locCode = location.S_CODE, areaCode = location.S_AREA_CODE, }; responseResult.result = emptyTrayLoc; } } } } } catch (Exception ex) { LogHelper.Info("查询空托货位错误,错误原因:" + ex.Message, "车间控制器"); } LogHelper.Info("查询空托货位-queryEmptyTrayLoc 出参:" + JsonConvert.SerializeObject(responseResult), "车间控制器"); return responseResult; } /// /// 15.取消任务 /// /// public ResponseResult cancelTask(TaskBase model) { LogHelper.Info("取消任务-cancelTask 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); ResponseResult responseResult = new ResponseResult() { success = true }; if (model.transferId == null) { responseResult.success = false; responseResult.message = "物流ID不能为空"; return responseResult; } WMSTask wmsTask = WMSHelper.GetWmsTaskBySrc(model.transferId); if (wmsTask != null && wmsTask.N_B_STATE < 2) { List wcsTasks = WCSHelper.GetTaskBySrcNo(wmsTask.S_CODE); if (wcsTasks.Count > 0) { foreach (var wcsTask in wcsTasks) { if (wcsTask.S_SCHEDULE_TYPE.Contains("RB")) { if (wcsTask.N_B_STATE == 2 && wcsTask.S_TYPE.Contains("出库")) { LocationHelper.UnBindingLoc(wcsTask.S_END_LOC, new List() { wcsTask.S_CNTR_CODE }); } if (wcsTask.N_B_STATE == 0 && wcsTask.S_TYPE.Contains("入库")) { LocationHelper.UnBindingLoc(wcsTask.S_START_LOC, new List() { wcsTask.S_CNTR_CODE }); } if (wcsTask.N_B_STATE > 0) { continue; } } if (wcsTask.S_SCHEDULE_TYPE.Contains("LD")) { if (wcsTask.S_TYPE.Contains("出库")) { var locCntrs = LocationHelper.GetLocCntrRel(wcsTask.S_START_LOC); if (locCntrs.Count > 0) { var cntrList = locCntrs.Select(a => a.S_CNTR_CODE).ToList(); if (cntrList.Contains(wcsTask.S_CNTR_CODE)) { var linePlcInfo = WCSHelper.GetLinePlcInfo(wcsTask.S_START_LOC); triggerAlarmCommand(linePlcInfo , 1); } } } LocationHelper.UnBindingLoc(wcsTask.S_START_LOC, new List() { wcsTask.S_CNTR_CODE }); LocationHelper.UnBindingLoc(wcsTask.S_END_LOC, new List() { wcsTask.S_CNTR_CODE }); var locCntrRels = LocationHelper.GetLocCntr(wcsTask.S_CNTR_CODE); if (locCntrRels.Count > 0) { LocationHelper.UnBindingLoc(locCntrRels[0].S_LOC_CODE, new List() { locCntrRels[0].S_CNTR_CODE }); } var cntrItemRels = ItemHelper.GetCntrItemByCntrCode(wmsTask.S_CNTR_CODE); if (cntrItemRels != null && cntrItemRels.Count > 0) { foreach (var cntrItemRel in cntrItemRels) { ContainerHelper.deleteCntrItem(wmsTask.S_CNTR_CODE); } } } WCSHelper.Fail(wcsTask); LocationHelper.UnLockLoc(wcsTask.S_START_LOC); LocationHelper.UnLockLoc(wcsTask.S_END_LOC); wmsTask.N_B_STATE = 3; wmsTask.T_END_TIME = DateTime.Now; WMSHelper.UpdateTaskState(wmsTask); } } else { wmsTask.N_B_STATE = 3; wmsTask.T_END_TIME = DateTime.Now; WMSHelper.UpdateTaskState(wmsTask); LocationHelper.UnLockLoc(wmsTask.S_START_LOC); LocationHelper.UnLockLoc(wmsTask.S_END_LOC); } } LogHelper.Info("取消任务-cancelTask 出参:" + JsonConvert.SerializeObject(responseResult), "车间控制器"); return responseResult; } /// /// 16.入库口补录任务 /// /// public ResponseResult supplTask(InStockInfo model) { ResponseResult responseResult = new ResponseResult(); LogHelper.Info("补录任务-supplTask 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); if (model.taskType.Equals("半成品/成品入库") && (model.trayItemInfoList == null || model.trayItemInfoList.Count == 0)) { responseResult.success = false; responseResult.message = "物料信息不能为空!"; return responseResult; } Location endLoc = LocationHelper.GetLoc(model.endBit); if (endLoc != null) { // 绑定容器物料信息 model.trayItemInfoList.ForEach(it => { CntrItemRel cntrItemRel = new CntrItemRel() { S_ITEM_CODE = it.itemCode, S_ITEM_NAME = it.itemName, S_WORK_NO = it.workNo, S_WORK_NAME = it.workName, S_DEPART_NO = it.dePartNo, S_PART_TASK_ID = it.partTaskId, S_PARTDRAW_NO = it.partDrawNo, S_PART_NAME = it.partName, S_OPER_NO = it.operNo, S_OPER_NAME = it.operName, F_QTY = float.Parse(it.quantity == null ? "0" : it.quantity), F_WEIGHT = float.Parse(it.weight == null ? "0" : it.weight), S_ITEM_SPEC = it.spec, S_ITEM_TYPE = it.isFinish }; ContainerHelper.BindCntrItemSingle(model.trayCode, cntrItemRel); }); string areaCode = Settings.getStoreAreaByAccessArea(model.endArea); var wmsTask = new WMSTask() { S_CNTR_CODE = model.trayCode, S_CODE = WMSHelper.GenerateTaskNo(), S_START_LOC = endLoc.S_CODE, S_START_AREA = endLoc.S_AREA_CODE, S_END_LOC = "虚拟货位", S_END_AREA = areaCode, S_TYPE = model.taskType, S_OP_DEF_CODE = model.taskNo, S_OP_DEF_NAME = "入库搬运任务(补)", N_PRIORITY = model.taskPri == null ? 1 : int.Parse(model.taskPri), T_START_TIME = DateTime.Now, }; if (WMSHelper.CreateWmsTask(wmsTask)) { LocCntrRel locCntrRel = ContainerHelper.getLocCntrByLoc(endLoc.S_CODE); if (locCntrRel != null) { LocationHelper.UnBindingLoc(endLoc.S_CODE, new List { locCntrRel.S_CNTR_CODE }); } LocationHelper.BindingLoc(endLoc.S_CODE, new List { model.trayCode }); } } else { responseResult.success = false; responseResult.message = "终点货位不存在"; } LogHelper.Info("补录任务-supplTask 出参:" + JsonConvert.SerializeObject(responseResult), "车间控制器"); return responseResult; } /// /// 17.查询托盘是否存在WMS任务 /// /// /// public ResponseResult findWmsTaskExist(TrayInfo model) { LogHelper.Info("查询WMS任务-findWmsTask 入参:" + JsonConvert.SerializeObject(model), "车间控制器"); ResponseResult responseResult = new ResponseResult(); WmsTaskExistResponse response = new WmsTaskExistResponse() { isExist = false }; var wmsTask = WMSHelper.GetWmsTaskByCntr(model.trayCode); if (wmsTask != null) { response.isExist = true; response.transferId = wmsTask.S_OP_DEF_CODE; } responseResult.result = response; LogHelper.Info("查询WMS任务-findWmsTask 出参:" + JsonConvert.SerializeObject(responseResult), "车间控制器"); return responseResult; } public class WmsTaskExistResponse { public bool isExist { get; set; } public string transferId { get; set; } } public class TaskBase { public string transferId { get; set; } } public class EmptyTrayLoc { public string locCode { get; set; } public string areaCode { get; set; } } public class SteelCoilInStockInfo { public string coilNo { get; set; } public string locCode { get; set; } } public class CoilItemBase { public string coilNo { get; set; } } public class CoilInitWeight { public string initWeight { get; set; } } public class CoilInfo { public string coilNo { get; set; } public string initWeight { get; set; } } public class SafeRequest { public string bit { get; set; } // 货位编码 public string reqState { get; set; } // 请求状态 1-请求取货 2-请求放货 3-安全退出 } public class LDAgvTaskInfo { public string robotCode { get; set; } // 机器人编号,只有任务下发到车上该字段才会传过去,否则不传 public string transportNo { get; set; } // 搬运单号(wms) public string stationName { get; set; } // 到达点位,离开点位的名称 public string originNo { get; set; } // 上级任务号 (车间控制器) public string status { get; set; } // 任务状态 } public class StationBase { public string bit { get; set; } // 货位编码 } public class MouldUpdateInfo { public string mouldNo { get; set; } // 模具序列号 public string actionType { get; set; } // 操作类型 1-入库 2-出库 传数字编号即可 public string mouldType { get; set; } // 模具类型 主片模具 、项片模具 、大项片模具 public List itemInfoList { get; set; } public class itemInfo { public string itemName { get; set; } public int num { get; set; } } } public class PageInfo { public int pageNum { get; set; } public int pageSize { get; set; } public int totalCount { get; set; } public object data { get; set; } } public class QueryItemModel { public string trayCode { get; set; } public string itemCode { get; set; } // 物料编码 public string workNo { get; set; } // 工作号 public string dePartNo { get; set; } // 部套号 public string partDrawNo { get; set; } // 零件图号 public string areaCode { get; set; } // 库区 public string startTime { get; set; } // 开始时间 public string endTime { get; set; } // 结束时间 public int pageNum { get; set; } // 当前页 public int pageSize { get; set; } // 每页数量 } public class MouldBase { public string mouldNo{ get; set; } } public class TrayInfo { public string trayCode { get; set; } } /// /// 入库请求信息 /// public class InStockInfo { public string taskNo { get; set; } // 车间控制器的任务号 public string taskType { get; set; } // 任务类型(1-钢卷入库、2-模具入库、3-半成品/成品入库 、4-空盘垛入库 传输中文) public string taskPri { get; set; } // 优先级 public string startBit { get; set; } // 起点货位编码 public string startArea { get; set; } // 起点库区编码 public string endBit { get; set; } // 终点货位编码 public string endArea { get; set; } // 终点库区编码 public string reqTime { get; set; } // 请求时间 public string trayCode { get; set; } // 托盘编码 钢卷入库:传输钢卷号 public List trayItemInfoList { get; set; } // 托盘物料信息 } public class TrayItemInfoReq { public string workNo { get; set; } //工作号 public string workName { get; set; } //工作号 public string dePartNo { get; set; } //部套号 public string partTaskId { get; set; } //零件任务号 public string partDrawNo { get; set; } //零件图号 public string partName { get; set; } //零件名称 public string operNo { get; set; } //工序编号 public string operName { get; set; } //工序名称 public string itemCode { get; set; } //物料编码 public string itemName { get; set; } //物料名称 public string quantity { get; set; } //数量-钢卷无数量 public string weight { get; set; } //重量-仅钢卷有重量 public string spec { get; set; } // 货品规格 public string isFinish { get; set; } //是否为成品物料 1-成品 2-半成品 } public class TrayItemInfoRes { public string trayCode { get; set; } //托盘码 public string workNo { get; set; } //工作号 public string workName { get; set; } //工作号 public string dePartNo { get; set; } //部套号 public string partTaskId { get; set; } //零件任务号 public string partDrawNo { get; set; } //零件图号 public string partName { get; set; } //零件名称 public string operNo { get; set; } //工序编号 public string operName { get; set; } //工序名称 public string itemCode { get; set; } //物料编码 public string itemName { get; set; } //物料名称 public string quantity { get; set; } //数量-钢卷无数量 public string weight { get; set; } //重量-仅钢卷有重量 public string spec { get; set; } // 货品规格 public string width { get; set; } // 钢卷宽度 public string isFinish { get; set; } //是否为成品物料 1-成品 2-半成品 public string fullTime { get; set; } //入库时间 public string areaCode { get; set; } //所在库区 } public class InStockRetureData { public string startStationCode { get; set; } //起点货位编码 public string startAreaCode { get; set; } //起点库区编码 public string endStationCode { get; set; } //起点库区编码 public string endAreaCode { get; set; } //起点库区编码 public string wmsId { get; set; } //WMS任务号 } public class OutStockInfo { public string taskNo { get; set; } // 车间控制器的任务号 public string taskType { get; set; } // 任务类型(1-钢卷出库、2-模具出库、3-半成品/成品出库 4-模具托盘出库 5-叫托盘出库 传输中文) public string taskPri { get; set; } // 优先级 public string startBit { get; set; } // 起点货位编码 public string startArea { get; set; } // 起点库区编码 public string endBit { get; set; } // 终点货位编码 public string endArea { get; set; } // 终点库区编码 public string reqTime { get; set; } // 请求时间 public string workNo { get; set; } // 工作号 public string width { get; set; } // 钢卷宽度 public string weight { get; set; } // 钢卷重量 public string coilNo { get; set; } // 钢卷号 // 物料编码 按照车间控制器传输的物料编码出库 模具出库-模具号或者模具编号 钢卷-(不是钢卷号) 成品/半成品-入库传的物料编码 public string itemCode { get; set; } public string partTaskId { get; set; } // 零件任务号(半成品/成品) public string trayCode { get; set; } // 托盘号 } public class OutStockReturnData { public string startStationCode { get; set; } //起点货位编码 public string startAreaCode { get; set; } //起点库区编码 public string endStationCode { get; set; } //起点库区编码 public string endAreaCode { get; set; } //起点库区编码 public string wmsId { get; set; } //WMS任务号 public List trayItemInfo { get; set; } //WMS任务号 } public class ResponseResult { public bool success { get; set; } = true; // 是否成功 public string message { get; set; } // 返回信息 public object result { get; set; } // 附加数据 public string e { get; set; } // 错误信息 } public class MouldInfo { public string trayCode { get; set; } // 托盘码 public string mouldNo { get; set; } // 模具序列号 } public class TrayMouldInfo { public string trayCode { get; set; } // 托盘码 public string itemCode { get; set; } // 物料编码(模具编码) public string itemName { get; set; } // 物料名称 public string mouldNo { get; set; } // 模具序列号( public int quantity { get; set; } // 数量 } public class TaskRequest { public int type { get; set; } // 1、入库 2、出库 public string area_code { get; set; } public string item_code { get; set; } public string cntr_code { get; set; } // 托盘编码 } public class CallbackInfo { public string requestId { get; set; } // 任务请求ID public int status { get; set; } // 状态 2、完成 3、取消 } public class TaskInfo { public int type { get; set; } // 1、入库 2、出库 public string loc { get; set; } // 货位 public string item { get; set; } // 物料编码 public string targetArea { get; set; } // 目标库区 } } }