kazelee
2025-06-30 f978872b6de4e7e20d992a2ee7cda902c11347b9
api/ApiHelper.cs
@@ -34,8 +34,6 @@
            var startAreas = taskInfo.StartAreas;
            var endAreas = taskInfo.EndAreas;
            var log = $"API:{taskName}:";
            try {
                if (model.Num <= 0) {
                    info = $"物料数量'{model.Num}'不合法:物料数量应该大于0";
@@ -51,7 +49,12 @@
                    return NewSimpleResult(1, info);
                }
                var startLoc = LocationHelper.GetLocQuery(db, 0, startAreas, model.StartLoc).First();
                var startLoc = db.Queryable<TN_Location>()
                    .Where(l => l.S_CODE == model.StartLoc)
                    .Where(l => startAreas.Contains(l.S_AREA_CODE))
                    .Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y")
                    .Where(l => l.N_CURRENT_NUM == 0)
                    .First();
                if (startLoc == null) {
                    info = $":没有找到起点货位'{model.StartLoc}'!要求:未上锁、数量=0、货区属于[{string.Join(", ", startAreas)}]";
@@ -67,7 +70,11 @@
                    S_CNTR_TYPE = "好运箱",
                };
                var endLoc = LocationHelper.GetLocQuery(db, 0, endAreas).OrderBy(l => new { l.N_LAYER }).First();
                var endLoc = db.Queryable<TN_Location>()
                    .Where(l => startAreas.Contains(l.S_AREA_CODE))
                    .Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y")
                    .Where(l => l.N_CURRENT_NUM == 0)
                    .OrderBy(l => new { l.N_LAYER }).First();
                
                if (endLoc == null) {
                    info = $"没有找到合适的终点货位,需要满足:未上锁、当前容器数量=0";
@@ -729,11 +736,14 @@
                TN_Location endLoc = null;
                if (locCntrRel.S_CNTR_TYPE == "托盘") {
                    endAreas = taskInfo.EndAreas_Pallet;
                    endLoc = LocationHelper.GetLocQuery(db, 0, endAreas).First();
                    endLoc = db.Queryable<TN_Location>()
                    .Where(l => startAreas.Contains(l.S_AREA_CODE))
                    .Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y")
                    .Where(l => l.N_CURRENT_NUM == 0).First();
                }
                else if (locCntrRel.S_CNTR_TYPE == "好运箱") {
                    endAreas = taskInfo.EndAreas_Goodpack;
                    endLoc = LocationHelper.GetLocQuery(db, 0, endAreas).First();
                    endLoc = db.Queryable<TN_Location>().Where(l => startAreas.Contains(l.S_AREA_CODE)).Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y").Where(l => l.N_CURRENT_NUM == 0).First();
                }
                else {
                    return NewSimpleResult(-1, $"托盘类型{locCntrRel.S_CNTR_TYPE}不合法:托盘号{locCntrRel.S_CNTR_CODE}");