| | |
| | | /// <param name="locCode"></param> |
| | | /// <param name="trayType"></param> |
| | | /// <param name="inWay">入库方式 1.自动入库 2.人工入库</param> |
| | | /// <param name="itemCode">物料编码</param> |
| | | /// <returns></returns> |
| | | public static Location GetInstockEndLoc(int trayType , string locCode = null , int inWay = 1 ,string itemCode = null) |
| | | { |
| | |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | if (itemBarcodeInfos.Count > 0) |
| | | { |
| | | itemBarcodeInfos.ForEach(item => { |
| | | var itemBarcodeInfo = db.Queryable<ItemBarcodeInfo>().Where(a => a.S_BC_ENTRIED == item.S_BC_ENTRIED).First(); |
| | | if (itemBarcodeInfo == null) |
| | | { |
| | | var bo = db.Insertable<ItemBarcodeInfo>(item).ExecuteCommand() > 0; |
| | | if (!bo) |
| | | var bo = db.Insertable<ItemBarcodeInfo>(item).ExecuteCommand() == 0; |
| | | if (bo) |
| | | { |
| | | result = false; |
| | | LogHelper.Info($"添加物料条码信息失败,物料条码信息:{JsonConvert.SerializeObject(item)}", "GT"); |
| | | } |
| | | } |
| | | }); |
| | | if (result) |
| | | { |
| | | } |
| | | db.CommitTran(); |
| | | } |
| | | else |
| | | { |
| | | db.RollbackTran(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"添加物料条码信息错误,错误信息:{ex.Message}", "GT"); |
| | | db.RollbackTran(); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 同步条码状态表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static bool synBarcodeStatus(List<iWMS_semi_bld_BCstatus> model) |
| | | { |
| | | bool result = true; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | if (model.Count > 0) |
| | | { |
| | | model.ForEach(update => { |
| | | db.Insertable(update).ExecuteCommand(); |
| | | }); |
| | | } |
| | | db.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"同步条码状态表错误,错误信息:{ex.Message}", "GT"); |
| | | db.RollbackTran(); |
| | | result = false; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 同步抽检状态表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static bool synSamplingStatus(List<iWMS_semi_bld_BCsample> model) |
| | | { |
| | | bool result = true; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | if (model.Count > 0) |
| | | { |
| | | model.ForEach(update => { |
| | | db.Insertable(update).ExecuteCommand(); |
| | | }); |
| | | } |
| | | db.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"同步抽检状态表错误,错误信息:{ex.Message}", "GT"); |
| | | db.RollbackTran(); |
| | | result = false; |
| | | } |
| | | return result; |
| | | } |
| | |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | if (updateMatlStatuses.Count > 0) |
| | | { |
| | | updateMatlStatuses.ForEach(update => { |
| | | var itemBarcodeInfo = db.Queryable<ItemBarcodeInfo>().Where(a => a.S_BC_ENTRIED == update.bc_entried).First(); |
| | | if (itemBarcodeInfo != null) |
| | |
| | | var cntrItemRel = db.Queryable<CntrItemRel>().Where(a => a.S_CG_ID == update.bc_entried).First(); |
| | | if (cntrItemRel != null) |
| | | { |
| | | // 将MES的物料状态转化成WMS可识别的物料状态 |
| | | if (update.jdge == "" || update.jdge == null) |
| | | { |
| | | update.jdge = "OK"; |
| | | } |
| | | else if (update.jdge != "OK") |
| | | { |
| | | update.jdge = "HOLD"; |
| | | } |
| | | db.Updateable<CntrItemRel>().SetColumns(a => new CntrItemRel() { S_ITEM_STATE = update.jdge }).Where(a => a.S_CG_ID == update.bc_entried).ExecuteCommand(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | db.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | result = false; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 批量更新物料状态 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static bool batchUpdateMatlTimeConfig(List<Overage> overages) |
| | | { |
| | | bool result = true; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | foreach (Overage overage in overages) |
| | | { |
| | | var overage1 = db.Queryable<Overage>().Where(a => a.RECID == overage.RECID).First(); |
| | | if (overage1 != null) |
| | | { |
| | | overage1.MCNGRP = overage.MCNGRP; |
| | | overage1.ITEMPATT = overage.ITEMPATT; |
| | | overage1.OVERAGE = overage.OVERAGE; |
| | | overage1.MINHOUR = overage.MINHOUR; |
| | | overage1.FLAG_STS = overage.FLAG_STS; |
| | | db.Updateable(overage1).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | db.Insertable(overage).ExecuteCommand(); |
| | | } |
| | | } |
| | | db.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"批量更新物料存放时间配置信息错误,错误信息:{ex.Message}", "GT"); |
| | | db.RollbackTran(); |
| | | result = false; |
| | | } |
| | | return result; |
| | | } |
| | | /// <summary> |
| | | /// 查询物料存放时间配置信息 |
| | | /// </summary> |
| | | /// <param name="bc_entried"></param> |
| | | /// <returns></returns> |
| | | public static Overage getOverage(string bc_entried) |
| | | { |
| | | |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | // 直接执行 SQL(参数化查询) |
| | | var sql = "SELECT get_ovg_bar(@barcode, @mcngrp) AS overage_value"; |
| | | var sql1 = "SELECT get_minhour_bar(@barcode, @mcngrp) AS overage_value"; |
| | | |
| | | // 使用匿名对象传递参数 |
| | | var ovg_bar = db.Ado.SqlQuery<int>(sql, new { barcode = bc_entried, mcngrp = "1"}).First(); |
| | | var minhour_bar = db.Ado.SqlQuery<float>(sql1, new { barcode = bc_entried, mcngrp = "1"}).First(); |
| | | Overage overage = new Overage() |
| | | { |
| | | MINHOUR = minhour_bar, |
| | | OVERAGE = ovg_bar |
| | | }; |
| | | return overage; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <summary> |
| | | /// 查询上一次的同步时间 |
| | | /// </summary> |
| | | /// <param name="recordTable"></param> |
| | | /// <param name="tableType"></param> |
| | | /// <returns></returns> |
| | | public static SynDataTimeRecord getLastDataSynTime(string recordTable) |
| | | public static string getDataLastSynTime(int tableType) |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | return db.Queryable<SynDataTimeRecord>().Where(a => a.RECORD_TABLE == recordTable).OrderByDescending(a => a.T_CREATE).First(); |
| | | string lastTime = null; |
| | | if (tableType == 1) |
| | | { |
| | | lastTime = db.Queryable<ItemBarcodeInfo>().OrderByDescending(a => a.LAST_MODIFY_TIME).Select(a => a.LAST_MODIFY_TIME).First(); |
| | | } |
| | | else if (tableType == 2) |
| | | { |
| | | |
| | | } |
| | | else if (tableType == 3) |
| | | { |
| | | |
| | | } |
| | | return lastTime; |
| | | } |
| | | } |
| | | } |