using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Web.Http;
|
using HH.WCS.Mobox3.DSZSH.models;
|
using HH.WCS.Mobox3.DSZSH.util;
|
using HH.WCS.Mobox3.DSZSH.wms;
|
|
using static HH.WCS.Mobox3.DSZSH.api.ApiModel;
|
using static HH.WCS.Mobox3.DSZSH.util.Config;
|
|
namespace HH.WCS.Mobox3.DSZSH.api {
|
/// <summary>
|
/// 应急/特殊情况的强制操作流程
|
/// </summary>
|
[RoutePrefix("force")]
|
public class ForceController : ApiController {
|
/// <summary>
|
/// 强制创建任务并下发
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("ForceInbound")]
|
public SimpleResult ForceCreateTask(ForceModel.ForceCreateTaskInfo model) {
|
return ForceService.ForceCreateTask(model);
|
}
|
|
public SimpleResult ForceAddCgDetail() {
|
return NewSimpleResult(0, "");
|
}
|
}
|
|
public class ForceService {
|
public static SimpleResult ForceCreateTask(ForceModel.ForceCreateTaskInfo model) {
|
var db = new SqlHelper<object>().GetInstance();
|
var (ok, msg) = (false, string.Empty);
|
var taskInfo = ETask.M满箱下线入库.Info();
|
const string preLog = "DEBUG:强制创建任务:";
|
|
try {
|
var startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLocUnbind(model.StartLoc, taskInfo.StartAreas)).First();
|
if (startLoc == null) {
|
return NewSimpleResult(2, preLog + LogMsg.StartLocUnbindNotFound(model.StartLoc, taskInfo.StartAreas));
|
}
|
|
var endLoc = db.Queryable<TN_Location>().Where(DbExpr.EndLoc(areas: taskInfo.EndAreas))
|
.OrderBy(l => new { l.N_LAYER }).First();
|
if (endLoc == null) {
|
return NewSimpleResult(3, preLog + LogMsg.EndLocNotFound(areas: taskInfo.EndAreas));
|
}
|
|
var task = WCSHelper.BuildTaskWithLocLock(startLoc, endLoc, model.CntId, taskInfo.TaskName);
|
|
(ok, msg) = DbTran.CreateTask(new CreateTaskObj {
|
StartLocToUpdate = startLoc,
|
EndLocToUpdate = endLoc,
|
TaskToInsert = task,
|
});
|
return NewSimpleResult(ok ? 0 : 500, preLog + msg);
|
}
|
catch (Exception ex) {
|
return NewSimpleResult(ex, preLog);
|
}
|
}
|
}
|
|
public class ForceModel {
|
public class ForceCreateTaskInfo {
|
public string StartLoc { get; set; }
|
public string EndLoc { get; set; }
|
public string CntId { get; set; } // 可为空
|
}
|
}
|
}
|