| | |
| | | using CsvHelper; |
| | | using CsvHelper.Configuration; |
| | | |
| | | using HH.WCS.Mobox3.DSZSH.Helper; |
| | | using HH.WCS.Mobox3.DSZSH.Helpers; |
| | | using HH.WCS.Mobox3.DSZSH.Models; |
| | | |
| | |
| | | } |
| | | |
| | | var agvTaskState = new AgvTaskState() { |
| | | TaskNo = model.TaskID, |
| | | ForkliftNo = model.ForkliftNo, |
| | | task_no = model.TaskID, |
| | | forklift_no = model.ForkliftNo, |
| | | }; |
| | | |
| | | var result = new ReturnResult(); |
| | | |
| | | // 当前状态没有达到最终状态时,循环加入返回列表 |
| | | while (agvCurrentState != model.NextState) { |
| | | agvTaskState.State = agvCurrentState; |
| | | agvTaskState.state = agvCurrentState; |
| | | result = AgvService.OperateAgvTaskStatus(agvTaskState); |
| | | returnResults.ResultList.Add(result); |
| | | agvCurrentState = AgvHelper.GetNextState(agvCurrentState); |
| | | } |
| | | |
| | | // 将循环没有到达的最终状态,也加入返回列表 |
| | | agvTaskState.State = model.NextState; |
| | | agvTaskState.state = model.NextState; |
| | | result = AgvService.OperateAgvTaskStatus(agvTaskState); |
| | | returnResults.ResultList.Add(result); |
| | | |
| | |
| | | /// 初始数据库建立 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static string CreateDatabase() { |
| | | public static string CreateDatabase(bool cover = true) { |
| | | try { |
| | | var db = DbHelper.GetDbClient(); |
| | | |
| | | //db.CodeFirst.InitTables<TN_CG_Detail>(); |
| | | //db.CodeFirst.InitTables<TN_WorkOrder>(); |
| | | //db.CodeFirst.InitTables<TN_CAR_IN>(); |
| | | ////db.CodeFirst.InitTables<SYSHelper.OI_SYS_MAXID>(); |
| | | //db.CodeFirst.InitTables<TN_Task_Action>(); |
| | | //db.CodeFirst.InitTables<TN_Task>(); |
| | | //db.CodeFirst.InitTables<TN_Location>(); |
| | | //db.CodeFirst.InitTables<TN_Loc_Container>(); |
| | | var entityTypes = new Type[] { |
| | | typeof(TN_CAR_IN), |
| | | typeof(TN_CG_Detail), |
| | | typeof(TN_Container), |
| | | typeof(TN_Loc_Container), |
| | | typeof(TN_Location), |
| | | typeof(TN_Task), |
| | | typeof(TN_Task_Action), |
| | | typeof(SysHelper.OI_SYS_MAXID), |
| | | |
| | | //db.CodeFirst.InitTables<TN_Outbound_Order>(); |
| | | //db.CodeFirst.InitTables<TN_Outbound_Detail>(); |
| | | //db.CodeFirst.InitTables<TN_Check_Order>(); |
| | | db.CodeFirst.InitTables<TN_Check_Detail>(); |
| | | typeof(TN_Inbound_Order), |
| | | typeof(TN_Check_Detail), |
| | | typeof(TN_Check_Order), |
| | | typeof(TN_CNTR_ITEM), |
| | | typeof(TN_Outbound_Detail), |
| | | typeof(TN_Outbound_Order), |
| | | }; |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (cover) { |
| | | // 删除所有表(按依赖关系倒序) |
| | | var tables = db.DbMaintenance.GetTableInfoList(); |
| | | foreach (var table in tables.OrderByDescending(t => t.Name)) { |
| | | db.DbMaintenance.DropTable(table.Name); |
| | | } |
| | | |
| | | // 创建新表 |
| | | db.CodeFirst.InitTables(entityTypes); |
| | | |
| | | //db.CodeFirst.BackupTable().InitTables(entityTypes); |
| | | } |
| | | else { |
| | | db.CodeFirst.InitTables(entityTypes); |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) { |
| | |
| | | } |
| | | |
| | | var cgDetail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == locCntrCg.CntrCode |
| | | && a.S_CG_ID == locCntrCg.CgId); |
| | | && a.S_ITEM_CODE == locCntrCg.CgId); |
| | | if (cgDetail == null) { |
| | | var locList = new List<TN_CG_Detail>(); |
| | | locList.Add(new TN_CG_Detail { S_CNTR_CODE = locCntrCg.CntrCode, S_CG_ID = locCntrCg.CgId, S_BATCH_NO = locCntrCg.BatchNo ?? "" }); |
| | | locList.Add(new TN_CG_Detail { S_CNTR_CODE = locCntrCg.CntrCode, S_ITEM_CODE = locCntrCg.CgId, S_BATCH_NO = locCntrCg.BatchNo ?? "" }); |
| | | if (db.Insertable<TN_CG_Detail>(locList).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | LogHelper.Info($"插入托盘物料关系{locCntrCg.CntrCode}-{locCntrCg}失败"); |