| | |
| | | { |
| | | return DebugService.AgvSeriesReports(model); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 初始化数据库 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("BuildDB")] |
| | | public string BuildDB() |
| | | { |
| | | try |
| | | { |
| | | var db = DbHelper.GetDbClient(); |
| | | //db.CodeFirst.InitTables<WCSTask>(); //所有库都支持 |
| | | //db.CodeFirst.InitTables<Zone>(); |
| | | //db.CodeFirst.InitTables<Area>(); |
| | | |
| | | //db.CodeFirst.InitTables<Location>(); |
| | | //db.CodeFirst.InitTables<LocCntrRel>(); |
| | | //db.CodeFirst.InitTables<Container>(); |
| | | //db.CodeFirst.InitTables<SYSHelper.OI_SYS_MAXID>(); |
| | | |
| | | db.CodeFirst.InitTables<TN_CG_Detail>(); |
| | | db.CodeFirst.InitTables<TN_WorkOrder>(); |
| | | db.CodeFirst.InitTables<TN_CAR_IN>(); |
| | | |
| | | db.CodeFirst.InitTables<TN_Task_Action>(); |
| | | db.CodeFirst.InitTables<TN_Task>(); |
| | | db.CodeFirst.InitTables<TN_Location>(); |
| | | db.CodeFirst.InitTables<TN_Loc_Container>(); |
| | | |
| | | db.CodeFirst.InitTables<TN_Outbound_Order>(); |
| | | db.CodeFirst.InitTables<TN_Outbound_Detail>(); |
| | | db.CodeFirst.InitTables<TN_Outbound_Task>(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"发生了异常"); |
| | | return "初始化数据库错误" + ex.Message; |
| | | } |
| | | //return res ? "成功" : "失败"; |
| | | return "成功"; |
| | | } |
| | | |
| | | [HttpPost] |
| | | [Route("InsertLocation")] |
| | | public string InsertLocation(InsertLocationInfo model) { |
| | | try { |
| | | var db = DbHelper.GetDbClient(); |
| | | |
| | | var locList = new List<TN_Location>(); |
| | | locList.Add(new TN_Location { S_AREA_CODE = model.AreaCode, S_CODE = model.Code}); |
| | | |
| | | if (db.Insertable<TN_Location>(locList).ExecuteCommand() <= 0) { |
| | | return "失败"; |
| | | } |
| | | |
| | | } |
| | | catch (Exception ex) { |
| | | LogHelper.Info($"发生了异常"); |
| | | return "添加货位错误" + ex.Message; |
| | | } |
| | | //return res ? "成功" : "失败"; |
| | | return "成功"; |
| | | [Route("CreateDatabase")] |
| | | public string CreateDatabase(CoverInfo model) { |
| | | return DebugService.CreateDatabase(model.IsCover); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | public string InsertLocCntrCg() { |
| | | return DebugService.InsertLocCntrCg(); |
| | | } |
| | | |
| | | public string AddCgCntrLocRel(CgInfo model) { |
| | | var db = DbHelper.GetDbClient(); |
| | | |
| | | try { |
| | | using (var tran = db.Ado.UseTran()) { |
| | | var loc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.LocId); |
| | | if (loc == null) { |
| | | var newLoc = new TN_Location { S_CODE = model.LocId, N_CURRENT_NUM = 1 }; |
| | | if (db.Insertable<TN_Location>(newLoc).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return $"插入位置{model.LocId}失败"; |
| | | } |
| | | loc = db.Queryable<TN_Location>().First(a => a.S_CODE == model.LocId); |
| | | } |
| | | if (loc.N_CURRENT_NUM == 0) { |
| | | loc.N_CURRENT_NUM = 1; |
| | | if (db.Updateable<TN_Location>(loc).UpdateColumns( |
| | | it => new { it.N_CURRENT_NUM, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return $"修改位置{model.LocId}失败"; |
| | | } |
| | | } |
| | | |
| | | var locCntrRel = db.Queryable<TN_Loc_Container>().First(a => a.S_LOC_CODE == model.LocId && a.S_CNTR_CODE == model.CntId); |
| | | if (locCntrRel == null) { |
| | | var locList = new List<TN_Loc_Container>(); |
| | | locList.Add(new TN_Loc_Container { S_LOC_CODE = model.LocId, S_CNTR_CODE = model.CntId }); |
| | | if (db.Insertable<TN_Loc_Container>(locList).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return $"插入位置托盘关系{model.LocId}-{model.CntId}失败"; |
| | | } |
| | | } |
| | | |
| | | var cgDetail = db.Queryable<TN_CG_Detail>().First(a => a.S_CNTR_CODE == model.CntId && a.S_CG_ID == model.CgId); |
| | | if (cgDetail == null) { |
| | | var locList = new List<TN_CG_Detail>(); |
| | | locList.Add(new TN_CG_Detail { S_CNTR_CODE = model.CntId, S_CG_ID = model.CntId }); |
| | | if (db.Insertable<TN_CG_Detail>(locList).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return $"插入托盘物料关系{model.CntId}-{model.CgId}失败"; |
| | | } |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | return $"出错:{ex}"; |
| | | } |
| | | |
| | | return "success"; |
| | | } |
| | | } |
| | | |
| | | public class CgInfo { |
| | | public string CgId { get; set; } |
| | | public string CntId { get; set; } |
| | | public string LocId { get; set; } |
| | | } |
| | | |
| | | public class InsertLocationInfo { |
| | | public string Code { set; get; } |
| | | public string AreaCode { set; get; } |
| | | } |
| | | |
| | | public class UpdateTaskWeightInfo { |
| | | public string TaskID { set; get; } |
| | | public float Weight { set; get; } |
| | | } |
| | | } |