| | |
| | | } |
| | | string Start = ""; //取货点 |
| | | string End = ""; |
| | | string areacode = ""; |
| | | string note = ""; //立库下发任务需要通知mes接口物料到位,用备注自动进行区分 |
| | | //根据物料获取对应库区 |
| | | #region 根据物料确认出库来源 |
| | | var iteminfo = db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE.Trim() == ItemCode).First(); |
| | | if (iteminfo != null) |
| | | { |
| | | //LogHelper.Info($"Createtask==>物料数据:{JsonConvert.SerializeObject(iteminfo)}"); |
| | | areacode = iteminfo.S_WH_CODE; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(areacode)) |
| | | { |
| | | LogHelper.Info($"Createtask==>根据物料编码:{ItemCode}未能找到物料来源,需同步物料数据"); |
| | | result.code = "1"; |
| | | result.msg = $"根据物料编码:{ItemCode}未能找到物料来源,需同步物料数据"; |
| | | AddErrorInfo("寻找出库区失败", result.msg); |
| | | return result; |
| | | } |
| | | //var task = db.Queryable<WCSTask>().Where(a => a.S_EQ_NO.Trim() == taskData.taskNum).First(); |
| | | //if (task != null) |
| | | #region 根据任务来源字段判断库区来源来源 |
| | | //var iteminfo = db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE.Trim() == ItemCode).First(); |
| | | //if (iteminfo != null) |
| | | //{ |
| | | // LogHelper.Info($"Createtask==> 任务号{taskData.taskNum},该任务已经存在,不允许创建任务"); |
| | | // //LogHelper.Info($"Createtask==>物料数据:{JsonConvert.SerializeObject(iteminfo)}"); |
| | | // areacode = iteminfo.S_WH_CODE; |
| | | //} |
| | | |
| | | //if (string.IsNullOrEmpty(areacode)) |
| | | //{ |
| | | // LogHelper.Info($"Createtask==>根据物料编码:{ItemCode}未能找到物料来源,需同步物料数据"); |
| | | // result.code = "1"; |
| | | // result.msg = $"任务号{taskData.taskNum},该任务已经存在,不允许创建任务"; |
| | | // result.msg = $"根据物料编码:{ItemCode}未能找到物料来源,需同步物料数据"; |
| | | // AddErrorInfo("寻找出库区失败", result.msg); |
| | | // return result; |
| | | //} |
| | | int n_type = 0; //任务来源 1.钢丝立库 2.胶片库 3.预备库 ,4.原材料库,通过物料确认任务来源 |
| | | |
| | | int n_type = 0; //任务来源 1.密炼立库 3.预备库 ,4.原材料库 |
| | | string Source = ""; |
| | | switch (areacode) |
| | | switch (taskData.source) |
| | | { |
| | | case "ML": |
| | | n_type = 1; |
| | | Source = "密炼"; |
| | | break; |
| | | case "JP": |
| | | n_type = 2; |
| | | Source = "井松"; |
| | | break; |
| | | case "YBK": |
| | | n_type = 3; |
| | | Source = "预备库"; |
| | | break; |
| | | case "wmwhse1": |
| | | case "YCL": |
| | | n_type = 4; |
| | | Source = "原材料"; |
| | | break; |
| | | } |
| | | LogHelper.Info($"Createtask==>任务类型:{n_type}"); |
| | | Console.WriteLine($"Createtask==>任务来源:{n_type}"); |
| | | if (n_type == 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"物料库区:{areacode}属于未定义库区,请检查物料表重新定义物料库区"; |
| | | AddErrorInfo("物料库区未定义", result.msg); |
| | | result.msg = $"任务来源:{taskData.source}属于未定义库区,请检查物料来源是否属于约定字段"; |
| | | AddErrorInfo("任务来源未定义", result.msg); |
| | | return result; |
| | | } |
| | | |
| | |
| | | { |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | Start = taskData.pickStation; |
| | | if (CreateCntrIteminfo(Start, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade)) |
| | | if (CreateCntrIteminfo(partData, taskData)) |
| | | { |
| | | endloc = Computeloc(CntrCode, taskData.dropStation, taskData.carrierType); |
| | | if (endloc != null) |
| | |
| | | else if (taskData.taskType == 5)//移库流程,直接使用起点货位和终点货位生成任务,并绑定托盘 |
| | | { |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | if (CreateCntrIteminfo(taskData.pickStation, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade)) |
| | | if (CreateCntrIteminfo(partData, taskData)) |
| | | { |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | |
| | | { |
| | | note = "异常库区入库"; |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | if (CreateCntrIteminfo(taskData.pickStation, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade)) |
| | | if (CreateCntrIteminfo(partData, taskData)) |
| | | { |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 预备库任务状态下发 |
| | |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "参数为null"; |
| | | AddErrorInfo("参数为空", result.msg,Source); |
| | | AddErrorInfo("参数为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | try |
| | |
| | | if (db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE == model.PartNumber).Count() > 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "物料主数据已存在"; |
| | | AddErrorInfo("物料主数据已存在", result.msg,Source); |
| | | result.msg = $"物料编码:{model.PartNumber}的物料主数据已存在"; |
| | | // AddErrorInfo("物料主数据已存在", result.msg, Source); |
| | | LogHelper.Info($"add:{result.msg}"); |
| | | return result; |
| | | } |
| | | TN_Material itemInfo = new TN_Material(); |
| | | itemInfo.S_ITEM_CODE = model.PartNumber; |
| | | itemInfo.ITEM_TYPE = model.PartClass; |
| | | itemInfo.S_ITEM_NAME = model.PartDesc; |
| | | itemInfo.REMARK1 = model.StewingTime.ToString("yyyy-MM-dd"); |
| | | itemInfo.REMARK2 = model.OverdueTime.ToString("yyyy-MM-dd"); |
| | | itemInfo.REMARK1 = model.StewingTime; |
| | | itemInfo.REMARK2 = model.OverdueTime; |
| | | itemInfo.S_MP_TYPE = model.Unit; |
| | | |
| | | db.Insertable<TN_Material>(itemInfo).ExecuteCommand(); |
| | | if (db.Insertable<TN_Material>(itemInfo).ExecuteCommand()>0) |
| | | { |
| | | LogHelper.Info($"add:物料编码:{model.PartNumber}的物料主数据已同步"); |
| | | } ; |
| | | return result; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"物料主数据创建失败 错误信息:{ex}"; |
| | | LogHelper.Error("add Error:" + ex.ToString(), ex); |
| | |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "参数为null"; |
| | | AddErrorInfo("参数为空", result.msg,Source); |
| | | AddErrorInfo("参数为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,起点{startloc.S_CODE}有锁"; |
| | | AddErrorInfo("货位有锁", result.msg,Source); |
| | | AddErrorInfo("货位有锁", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == startloc.S_CODE).First(); |
| | | if (cntr == null) |
| | | { |
| | | |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"起点{model.Data.start_loc_code}未查询绑定托盘"; |
| | | LogHelper.Info($"callfixture:创建空工装呼叫任务==>{result.msg}"); |
| | |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,根据货位编码:{dtcode}未找到电梯货位"; |
| | | AddErrorInfo("查找货位失败", result.msg,Source); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 货位信息上传 |
| | |
| | | |
| | | #endregion |
| | | var loc = LocationHelper.GetLocByItemCode(areacode, itemcode, level); |
| | | LogHelper.Info($"airlift=>根据库区编码:{areacode},物料编码:{itemcode},物料等级计算出有托盘货位{JsonConvert.SerializeObject(loc)}"); |
| | | result = FindStartcolByLoclist(loc); |
| | | LogHelper.Info($"airlift=>可用货位为:{JsonConvert.SerializeObject(result)}"); |
| | | return result; |
| | | } |
| | | |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 创建托盘物料绑定关系 |
| | | /// 立库任务下发创建托盘物料绑定关系 |
| | | /// </summary> |
| | | /// <param name="loc">货位编码</param> |
| | | /// <param name="cntr">托盘编码</param> |
| | | /// <param name="partNumber">物料编码</param> |
| | | /// <param name="partDesc">物料描述</param> |
| | | /// <param name="partType">物料类型</param> |
| | | /// <param name="cntrtype">托盘类型</param> |
| | | /// <param name="unit">物料单位</param> |
| | | /// <param name="weight">物料重量</param> |
| | | internal static bool CreateCntrIteminfo(string loc, string cntr, string partNumber, string partDesc, string partType, string batch, string unit, string weight, string cntrtype = "1", string level = "") |
| | | internal static bool CreateCntrIteminfo(partData partData, taskData taskData) |
| | | { |
| | | return ContainerHelper.CreateCntrItem(loc, cntr, partNumber, partDesc, partType, cntrtype, batch, weight, unit, level); |
| | | if (partData == null && taskData == null) |
| | | { |
| | | LogHelper.Info($"CreateCntrIteminfo==> 立库任务下发参数有空,创建物料托盘绑定关系失败"); |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | return ContainerHelper.CreateCntrItem(taskData.pickStation, partData.rfid, partData.partNumber, partData.partDesc, partData.partType, taskData.carrierType, partData.lotNumber, taskData.wmsLot, partData.weight, partData.unit, |
| | | taskData.tyreType, taskData.supplier, taskData.receiveLot, taskData.subpool, partData.productionTime, partData.maturityTime, taskData.level); |
| | | } |
| | | |
| | | } |
| | | private static object _lockLocation = new object(); |
| | | /// <summary> |
| | | /// 根据托盘编码,机台编码,工装类型计算机台线边区域 |
| | | /// </summary> |
| | | /// <param name="cntrcode">托盘编码</param> |
| | | /// <param name="jtcode">机台编码</param> |
| | | /// <param name="cntrType">托盘类型</param> |
| | | /// <returns></returns> |
| | | internal static Location Computeloc(string cntrcode, string jtcode, string cntrType) |
| | | { |
| | |
| | | |
| | | // var location = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == cntrcode).First(); |
| | | |
| | | |
| | | var loc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).First(); |
| | | if (loc != null) |
| | | lock (_lockLocation) |
| | | { |
| | | End = loc; |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"Computeloc==》根据机台分组:{jtcode},工装类型:{cntrType} 未找到空货位数据,请检查货位表"); |
| | | } |
| | | var loc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).First(); |
| | | if (loc != null) |
| | | { |
| | | End = loc; |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"Computeloc==》根据机台分组:{jtcode},工装类型:{cntrType} 未找到空货位数据,请检查货位表"); |
| | | } |
| | | |
| | | } |
| | | return End; |
| | | } |
| | | |