| | |
| | | using System.Reflection; |
| | | using System.Text.RegularExpressions; |
| | | using System.Threading; |
| | | using Ubiety.Dns.Core; |
| | | using static HH.WCS.Mobox3.YNJT_PT.api.ApiModel; |
| | | using static HH.WCS.Mobox3.YNJT_PT.api.OtherModel; |
| | | using static HH.WCS.Mobox3.YNJT_PT.api.WmsController; |
| | | using static HH.WCS.Mobox3.YNJT_PT.dispatch.WCSDispatch; |
| | | using static HH.WCS.Mobox3.YNJT_PT.util.Settings; |
| | | using static HH.WCS.Mobox3.YNJT_PT.wms.WMSHelper; |
| | | using static System.Net.Mime.MediaTypeNames; |
| | |
| | | /// 成型机下线记录 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | public static ResponseResult cxjOffLineRecord(OffLineModel model) |
| | | public static ResponseResult cxjOffLineRecord(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult response = new ResponseResult(); |
| | | var container = ContainerHelper.GetCntr(model.rfid); |
| | | var container = ContainerHelper.GetCntr(model.cntrNo); |
| | | if (container == null) |
| | | { |
| | | ContainerHelper.AddCntr(model.rfid); |
| | | ContainerHelper.AddCntr(model.cntrNo); |
| | | } |
| | | |
| | | try |
| | | { |
| | | OffLineModel extData1 = JsonConvert.DeserializeObject<OffLineModel>(model.extData.ToString()); |
| | | OffLineRecord record = new OffLineRecord() |
| | | { |
| | | S_RFID = model.rfid, |
| | | S_RFID = model.cntrNo, |
| | | S_DEVICE_NO = model.deviceNo, |
| | | N_IS_URGENT = model.isUrgent, |
| | | N_IS_URGENT = extData1.isUrgent, |
| | | T_OFF_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
| | | N_IS_FULL = model.isFull, |
| | | N_IS_FULL = extData1.isFull, |
| | | N_NEED_PAIR = extData1.needPair, |
| | | S_LOC = model.loc |
| | | }; |
| | | WMSHelper.addOffLineRecord(record); |
| | |
| | | var startLoc = LocationHelper.GetLoc(model.loc); |
| | | if (startLoc != null) |
| | | { |
| | | List<BarcodeModel> extData = model.extData; |
| | | List<BarcodeModel> extData = JsonConvert.DeserializeObject<List<BarcodeModel>>(model.extData.ToString()); |
| | | int dataCount = extData.Count; |
| | | if (dataCount > 0) |
| | | { |
| | |
| | | } |
| | | else if (wcsTask.S_TYPE == "胚胎叫料出库任务") |
| | | { |
| | | if (model.cntrNo != wcsTask.S_CNTR_CODE) |
| | | var cntrItemRels = ContainerHelper.GetCntrItemRel(wcsTask.S_CNTR_CODE); |
| | | if (model.cntrNo != wcsTask.S_CNTR_CODE || cntrItemRels.Count == 0 || cntrItemRels.Count > 0 && cntrItemRels[0].S_ITEM_STATE != "OK") |
| | | { |
| | | // 计算排出口 |
| | | endLoc = WMSHelper.getCallOutLoc(endLoc.N_ROW); |
| | |
| | | readCodeFeedbackResponse.verifyResult = false; |
| | | readCodeFeedbackResponse.endLoc = endLoc.S_CODE; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var cntrItemRels = ContainerHelper.GetCntrItemRel(wcsTask.S_CNTR_CODE); |
| | | if (cntrItemRels.Count > 0) |
| | | { |
| | | if (cntrItemRels[0].S_ITEM_STATE != "OK") |
| | | { |
| | | endLoc = WMSHelper.getMinTaskMiddleLoc(1,endLoc.N_ROADWAY); ; |
| | | response.code = 1; |
| | | response.msg = $"任务号:{model.taskNo},未查询到执行中的任务"; |
| | | } |
| | | response.data = readCodeFeedbackResponse; |
| | | return response; |
| | | } |
| | | |
| | | wcsTask.S_END_LOC = endLoc.S_CODE; |
| | | wcsTask.S_END_AREA = endLoc.S_AREA_CODE; |
| | | /// <summary> |
| | | /// 异常申请(取消任务) |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public static ResponseResult anomalyRequest(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult response = new ResponseResult(); |
| | | readCodeFeedbackResponse readCodeFeedbackResponse = new readCodeFeedbackResponse() |
| | | { |
| | | verifyResult = true |
| | | }; |
| | | var wcsTask = WCSHelper.GetTask(model.taskNo); |
| | | var wmsTask = WMSHelper.GetWmsTask(wcsTask.S_OP_CODE); |
| | | if (wcsTask != null && wmsTask != null) |
| | | { |
| | | Location endLoc = LocationHelper.GetLoc(wmsTask.S_END_LOC); // 原终点 |
| | | if (wcsTask.S_TYPE == "满料下线入库任务") |
| | | { |
| | | // 查询排出口 |
| | | var middleLoc = WMSHelper.getMinTaskMiddleLoc(1, 0, endLoc.N_ROADWAY); |
| | | wcsTask.S_END_LOC = middleLoc.S_CODE; |
| | | wcsTask.S_END_AREA = middleLoc.S_AREA_CODE; |
| | | WCSHelper.updateTaskEnd(wcsTask); |
| | | readCodeFeedbackResponse.verifyResult = false; |
| | | readCodeFeedbackResponse.endLoc = middleLoc.S_CODE; |
| | | |
| | | wmsTask.S_END_LOC = endLoc.S_CODE; |
| | | wmsTask.S_END_AREA = endLoc.S_AREA_CODE; |
| | | WMSHelper.UpdateTaskEnd(wmsTask); |
| | | |
| | | // 查询新终点 |
| | | endLoc = WMSHelper.getOnlneLoc(2); |
| | | } |
| | | else if (wcsTask.S_TYPE == "胚胎叫料出库任务") |
| | | { |
| | | endLoc = WMSHelper.getCallOutLoc(endLoc.N_ROW); |
| | | readCodeFeedbackResponse.verifyResult = false; |
| | | readCodeFeedbackResponse.endLoc = endLoc.S_CODE; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | wmsTask.S_END_LOC = endLoc.S_CODE; |
| | | wmsTask.S_END_AREA = endLoc.S_AREA_CODE; |
| | | WMSHelper.UpdateTaskEnd(wmsTask); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 硫化机呼叫胚胎出库 |
| | | /// 4.硫化机呼叫胚胎出库 |
| | | /// 逻辑: |
| | | /// 1.根据机台号查询【硫化机工单表】、【胚胎已完成的条码中间表】筛选当前班次的生产计划数量是否满足,当预计生产数量 = 实际数+在途数量 ,则停止叫料 |
| | | /// 2.查询机台号在【硫化机工单表】对应的物料编码, |
| | | /// 开始计算(1.巷道不报警、2.物料状态OK、3.小于失效时间 大于等于生效时间 4.加急料先出、5.先入先出(生产时间))出库物料,生成任务 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | public static ResponseResult callItemOutStock(CallItemModel model) |
| | | public static ResponseResult callItemOutStock(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult response = new ResponseResult(); |
| | | |
| | | int locNum = model.locCodes.Count; |
| | | var locCodes = model.loc.Split(',').ToList(); |
| | | |
| | | int locNum = locCodes.Count; |
| | | if (locNum > 0) |
| | | { |
| | | Location prevLoc = null; |
| | | Dictionary<string,Location> outLocDic = new Dictionary<string,Location>(); |
| | | foreach (var mcn in model.locCodes) |
| | | foreach (var mcn in locCodes) |
| | | { |
| | | // 1.一个硫化机工位只能同时存在一个正在执行中的任务 |
| | | var existTask = WCSHelper.GetTaskByEnd(mcn); |
| | |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public static ResponseResult emptyTrayInStock(EmptyTrayInStockModel model) |
| | | public static ResponseResult emptyTrayInStock(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult response = new ResponseResult(); |
| | | Location startLoc = LocationHelper.GetLoc(model.startLoc); |
| | | var endLocGroup = WMSHelper.getInStockEndLoc(1,null); |
| | | if (endLocGroup.endLocList.Count == 1) |
| | | Location startLoc = LocationHelper.GetLoc(model.loc); |
| | | |
| | | var cntrCodeList = model.loc.Split(',').ToList(); |
| | | if (cntrCodeList.Count > 0) |
| | | { |
| | | Location endLoc = endLocGroup.endLocList[0]; |
| | | var endLocGroup = WMSHelper.getInStockEndLoc(cntrCodeList.Count, null); |
| | | if (endLocGroup.endLocList.Count > 0) |
| | | { |
| | | foreach (var endLoc in endLocGroup.endLocList) |
| | | { |
| | | var wmsTask = new WMSTask() |
| | | { |
| | | S_CNTR_CODE = model.trayCode, |
| | | S_CNTR_CODE = model.cntrNo, |
| | | S_CODE = WMSHelper.GenerateTaskNo(), |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | |
| | | S_OP_DEF_NAME = "空托盘回库任务", |
| | | N_PRIORITY = 1, |
| | | T_START_TIME = DateTime.Now, |
| | | S_GROUP_NO = endLocGroup.groupNo, |
| | | }; |
| | | if (WMSHelper.CreateWmsTask(wmsTask)) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | response.code = 1; |
| | | response.msg = "库区没有可入的空货位"; |
| | | } |
| | | } |
| | | |
| | | return response; |
| | | } |
| | | |
| | |
| | | /// 呼叫空托出库 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponseResult callEmptyTrayOutStock(CallEmptyTrayOutStockModel model) |
| | | public static ResponseResult callEmptyTrayOutStock(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | Location startLoc = WMSHelper.getOutStockStartLoc(null); |
| | | int executeNum = 0; |
| | | string startLocCode = null; |
| | | for (int i = 1; i <= 2; i++) |
| | | { |
| | | Location startLoc = WMSHelper.getOutStockStartLoc(startLocCode); |
| | | if (startLoc != null) |
| | | { |
| | | Location endLoc = LocationHelper.GetLoc(model.endLoc); |
| | | startLocCode = startLoc.S_CODE; |
| | | Location endLoc = WMSHelper.getMinTaskMiddleLoc(1, 0, startLoc.N_ROADWAY); |
| | | if (endLoc != null) |
| | | { |
| | | var locCntrRels = LocationHelper.GetLocCntr(startLoc.S_CODE); |
| | |
| | | // 更新作业任务状态 |
| | | wmsTask.N_B_STATE = 1; |
| | | WMSHelper.UpdateTaskState(wmsTask); |
| | | |
| | | executeNum += 1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | } |
| | | } |
| | | |
| | | if (executeNum < 1) |
| | | { |
| | | responseResult.code = 1; |
| | | responseResult.msg = $"终点货位:{model.endLoc}在WMS系统中不存在"; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | responseResult.code = 1; |
| | | responseResult.msg = "库内空托不足"; |
| | | responseResult.msg = "立库内空托盘数量不足"; |
| | | } |
| | | return responseResult; |
| | | } |
| | |
| | | /// 胚胎抽检出库 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static ResponseResult embryoCheckOutStock(EmbryoCheckOutStockModel model) |
| | | public static SimpleResult embryoCheckOutStock(EmbryoCheckOutStockModel model) |
| | | { |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | SimpleResult result = new SimpleResult(); |
| | | var locCntrs = LocationHelper.GetLocCntrRelByCntr(model.trayCode); |
| | | if (locCntrs.Count == 1) |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | return responseResult; |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | public static ResponseResult anomalyTrayInStock(AnomalyTrayInStockModel model) |
| | | public static ResponseResult anomalyTrayInStock(NotifyDeviceSignalModel model) |
| | | { |
| | | ResponseResult responseResult = new ResponseResult(); |
| | | LocationHelper.UnBindingLoc(model.startLoc, new List<string>() { model.trayCode }); |
| | | ContainerHelper.deleteCntrItemRelByCntr(model.trayCode); |
| | | LocationHelper.UnBindingLoc(model.loc, new List<string>() { model.cntrNo }); |
| | | ContainerHelper.deleteCntrItemRelByCntr(model.cntrNo); |
| | | return responseResult; |
| | | } |
| | | |
| | |
| | | |
| | | public class OffLineModel |
| | | { |
| | | public string loc { get; set; } // 下线位 |
| | | public string rfid { get; set; } // 托盘号 |
| | | public string deviceNo { get; set; } // 机台号 |
| | | public int isUrgent { get; set; } // N_IS_URGENT 是否加急(0.否 1.是) |
| | | public int isFull { get; set; } // 是否满拖 0.否 1.是 |
| | | public int needPair { get; set; } // 0.否 1.是(当前空托盘为配对托盘) |
| | | } |
| | | public class AddTaskModel { |
| | | public string From { get; set; } |