| | |
| | | return gzResults; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化数据库 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("CreateDatabase")] |
| | | public string CreateDatabase(CoverInfo model) { |
| | | try { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var cover = model.IsCover; |
| | | ///// <summary> |
| | | ///// 初始化数据库 |
| | | ///// </summary> |
| | | ///// <returns></returns> |
| | | //[HttpPost] |
| | | //[Route("CreateDatabase")] |
| | | //public string CreateDatabase(CoverInfo model) { |
| | | // try { |
| | | // var db = new SqlHelper<object>().GetInstance(); |
| | | // var cover = model.IsCover; |
| | | |
| | | 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), |
| | | // 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), |
| | | |
| | | }; |
| | | // typeof(TN_Count_Plan), |
| | | // typeof(TN_Count_Order), |
| | | // typeof(TN_Count_CG_Detail), |
| | | // typeof(TN_Count_Diff), |
| | | // }; |
| | | |
| | | 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); |
| | | } |
| | | // 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.InitTables(entityTypes); |
| | | |
| | | //db.CodeFirst.BackupTable().InitTables(entityTypes); |
| | | } |
| | | else { |
| | | db.CodeFirst.InitTables(entityTypes); |
| | | } |
| | | // //db.CodeFirst.BackupTable().InitTables(entityTypes); |
| | | // } |
| | | // else { |
| | | // db.CodeFirst.InitTables(entityTypes); |
| | | // } |
| | | |
| | | tran.CommitTran(); |
| | | } |
| | | // tran.CommitTran(); |
| | | // } |
| | | |
| | | } |
| | | catch (Exception ex) { |
| | | LogHelper.Info($"发生了异常"); |
| | | return "初始化数据库错误" + ex.Message; |
| | | } |
| | | // } |
| | | // catch (Exception ex) { |
| | | // LogHelper.Info($"发生了异常"); |
| | | // return "初始化数据库错误" + ex.Message; |
| | | // } |
| | | |
| | | return "成功"; |
| | | } |
| | | // return "成功"; |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// DEBUG:插入货位、容器、货品信息 |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// DEBUG:根据任务号设置物料重量 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("SetTaskWeight")] |
| | | public string SetTaskWeight(SetTaskWeightInfo model) { |
| | |
| | | return "找不到对应的物料信息"; |
| | | } |
| | | |
| | | var task = db.Queryable<TN_Task>() |
| | | .Where(t => t.S_CODE == model.TaskNo).First(); |
| | | |
| | | if (cgDetail == null) { |
| | | return "找不到对应的任务号"; |
| | | } |
| | | |
| | | cgDetail.F_QTY = model.Weight; |
| | | task.F_WEIGHT = model.Weight; |
| | | |
| | | try { |
| | | if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => it.F_QTY) |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => it.F_QTY) |
| | | .ExecuteCommand() <= 0) { |
| | | return "修改失败"; |
| | | } |
| | | return "修改成功"; |
| | | tran.RollbackTran(); |
| | | return "修改失败"; |
| | | } |
| | | |
| | | if (db.Updateable<TN_Task>(task).UpdateColumns(it => it.F_WEIGHT).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return "修改失败"; |
| | | } |
| | | tran.CommitTran(); |
| | | } |
| | | LogHelper.Info($"模拟AGV传递物料重量:修改任务号{task.S_CODE}重量为{model.Weight}", "HosttoagvTask"); |
| | | return "修改成功"; |
| | | } |
| | | |
| | | catch (Exception ex) { |
| | | |
| | | return ex.Message; |