| | |
| | | using System.Web.Http; |
| | | |
| | | using HH.WCS.Mobox3.AnGang.dispatch; |
| | | using HH.WCS.Mobox3.AnGang.wms; |
| | | using HH.WCS.Mobox3.AnGang.models; |
| | | using HH.WCS.Mobox3.AnGang.util; |
| | | using HH.WCS.Mobox3.AnGang.wms; |
| | | |
| | | using Newtonsoft.Json; |
| | | |
| | | using SqlSugar; |
| | | |
| | | using static HH.WCS.Mobox3.AnGang.api.ApiModel; |
| | | using HH.WCS.Mobox3.AnGang.util; |
| | | |
| | | namespace HH.WCS.Mobox3.AnGang.api { |
| | | /// <summary> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化数据库 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Route("CreateDatabase")] |
| | | public string CreateDatabase() { |
| | | try { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | var entityTypes = new Type[] { }; |
| | | |
| | | //db.CodeFirst.InitTables(entityTypes); |
| | | } |
| | | catch (Exception ex) { |
| | | LogHelper.Info($"发生了异常"); |
| | | return "初始化数据库错误" + ex.Message; |
| | | } |
| | | return "成功"; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// DEBUG:根据任务号设置物料重量 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | |
| | | return "找不到对应的任务号"; |
| | | } |
| | | |
| | | cgDetail.F_QTY = model.Weight; |
| | | cgDetail.F_WEIGHT = model.Weight; |
| | | task.F_WEIGHT = model.Weight; |
| | | |
| | | try { |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => it.F_QTY) |
| | | if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => it.F_WEIGHT) |
| | | .ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return "修改失败"; |
| | |
| | | return ex.Message; |
| | | } |
| | | } |
| | | |
| | | [HttpPost] |
| | | public string AddCntrData() { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try { |
| | | //var locCntrRelList = db.Queryable<TN_Loc_Container>(); |
| | | //var result = db.Queryable<TN_CG_Detail>() |
| | | // .GroupBy(d => d.S_CNTR_CODE) // 按 S_CNTR_CODE 分组 |
| | | // .Select(d => new CntrCodeCountResult { |
| | | // S_CNTR_CODE = d.S_CNTR_CODE, |
| | | // Count = SqlFunc.AggregateCount(d.S_ITEM_CODE) // 计算每组的条目数 |
| | | // }) |
| | | // .ToList(); |
| | | |
| | | //var cntrList = locCntrRelList.Select(c => c.S_CNTR_CODE); |
| | | |
| | | var result = db.Queryable<TN_CG_Detail>() |
| | | .LeftJoin<TN_Loc_Container>((detail, container) => detail.S_CNTR_CODE == container.S_CNTR_CODE) |
| | | .GroupBy(detail => detail.S_CNTR_CODE) |
| | | .Select((detail, container) => new CntrCodeCountResult { |
| | | S_CNTR_CODE = detail.S_CNTR_CODE, |
| | | Count = SqlFunc.AggregateCount(detail.S_ITEM_CODE) |
| | | }) |
| | | .ToList(); |
| | | |
| | | var cntrList = db.Queryable<TN_Container>().ToList(); |
| | | |
| | | var cntrListToUpdate = new List<TN_Container>(); |
| | | var cntrListToInsert = new List<TN_Container>(); |
| | | foreach (var cntr in result) { |
| | | var oldCntr = cntrList.Where(c => c.S_CODE == cntr.S_CNTR_CODE).First(); |
| | | if (oldCntr == null) { |
| | | cntrListToUpdate.Add(new TN_Container { S_CODE = cntr.S_CNTR_CODE, N_DETAIL_COUNT = cntr.Count }); |
| | | } |
| | | |
| | | if (oldCntr.N_DETAIL_COUNT != cntr.Count) { |
| | | cntrListToUpdate.Add(new TN_Container { S_CODE = cntr.S_CNTR_CODE, N_DETAIL_COUNT = cntr.Count }); |
| | | } |
| | | } |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (cntrListToUpdate.Count > 0 && db.Updateable(cntrListToUpdate).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return "更新失败"; |
| | | } |
| | | if (cntrListToInsert.Count > 0 && db.Insertable(cntrListToInsert).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return "插入失败"; |
| | | } |
| | | tran.CommitTran(); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | |
| | | return ex.Message; |
| | | } |
| | | |
| | | return "success"; |
| | | } |
| | | } |
| | | |
| | | public class CntrCodeCountResult { |
| | | public string S_CNTR_CODE { get; set; } // 容器代码 |
| | | public int Count { get; set; } // 该容器代码对应的条目数 |
| | | } |
| | | |
| | | public class ReturnResults { |
| | |
| | | |
| | | public class GzResults { |
| | | public List<GzResult> GzResultList { set; get; } |
| | | } |
| | | |
| | | public class LocCntrCg { |
| | | public string LocCode { get; set; } |
| | | public string LocArea { get; set; } |
| | | public string CntrCode { get; set; } |
| | | public string ItemCode { get; set; } |
| | | public string BatchNo { get; set; } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// AGV 下一个状态 |
| | | /// </summary> |
| | | public int NextState { set; get; } |
| | | } |
| | | |
| | | public class CoverInfo { |
| | | public bool IsCover { set; get; } = true; |
| | | } |
| | | |
| | | public class SetTaskWeightInfo { |