92 lines
3.4 KiB
C#
92 lines
3.4 KiB
C#
using System;
|
|
using System.Linq;
|
|
using HHWMS.Web.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using WalkingTec.Mvvm.Core;
|
|
using WalkingTec.Mvvm.Mvc;
|
|
|
|
namespace HHWMS.Web.Controllers;
|
|
|
|
[Area("receipt")]
|
|
[ActionDescription("散料操作")]
|
|
public class ReceiptSLInController : BaseController
|
|
{
|
|
private readonly IUnitWork _unitWork;
|
|
|
|
public ReceiptSLInController(IUnitWork unitWork)
|
|
{
|
|
_unitWork = unitWork;
|
|
}
|
|
|
|
#region Search
|
|
|
|
[ActionDescription("Sys.Search")]
|
|
public ActionResult Index()
|
|
{
|
|
return PartialView("Index");
|
|
}
|
|
#endregion
|
|
|
|
[HttpPost]
|
|
public ActionResult CallBox()
|
|
{
|
|
// 查询站台占用
|
|
var stations = _unitWork.Find<Location>(x => (x.Code == StationCode.散料库左抽屉
|
|
|| x.Code == StationCode.散料库右抽屉)
|
|
&& x.Status != LocationStatus.任务锁).ToList();
|
|
if (stations.Count == 0) return JsonMore(null, 500, "无可用站台!");
|
|
|
|
// 查找没任务的仓位,分两边查,那边站台能用 查哪边
|
|
var box = _unitWork.Find<Location>(x => (x.ZoneCode == ZoneCodeEnum.散料库)
|
|
& (x.Status != LocationStatus.任务锁)
|
|
&& x.Status != LocationStatus.满货
|
|
&& x.Status != LocationStatus.空仓位
|
|
&& x.Row == stations.First().Row).FirstOrDefault();
|
|
if (box == null && stations.Count == 2)
|
|
box = _unitWork.Find<Location>(x => (x.ZoneCode == ZoneCodeEnum.散料库)
|
|
& (x.Status != LocationStatus.任务锁)
|
|
&& x.Status != LocationStatus.满货
|
|
&& x.Status != LocationStatus.空仓位
|
|
&& x.Row == stations.Last().Row).FirstOrDefault();
|
|
|
|
if (box == null) return JsonMore(null, 500, "库内没有可用散料箱!");
|
|
|
|
var toLocation = box.Row == 1 ? StationCode.散料库右抽屉 : StationCode.散料库左抽屉;
|
|
// 创建任务
|
|
var task = new TaskHeader
|
|
{
|
|
ZoneCode = ZoneCodeEnum.散料库,
|
|
TaskNo = _unitWork.GetSerialNumber("SOut"),
|
|
TaskType = TaskTypeEnum.散料盒出库,
|
|
ContainerCode = box.ContainerCode,
|
|
FromLocation = box.Code,
|
|
ToLocation = toLocation,
|
|
Status = TaskStatusEnum.新建,
|
|
CreateTime = DateTime.Now,
|
|
CreateBy = Wtm.LoginUserInfo.ITCode
|
|
};
|
|
_unitWork.Add(task);
|
|
return JsonMore(null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 扫描唯一码,并验证,返回入库单明细
|
|
/// </summary>
|
|
/// <param name="uniqueCode"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public ActionResult ScanUniqueCode(string uniqueCode)
|
|
{
|
|
var receiptDetail = _unitWork.FindSingle<ReceiptDetail>(x => x.UniqueCode.Equals(uniqueCode));
|
|
if (receiptDetail != null)
|
|
{
|
|
if (receiptDetail.Status == ReceiptStatusEnum.收完)
|
|
{
|
|
return JsonMore(null, 500, $"{uniqueCode}已绑定,无需重新绑定!");
|
|
}
|
|
return JsonMore(receiptDetail);
|
|
}
|
|
return JsonMore(null, 500, $"{uniqueCode}不存在!");
|
|
}
|
|
}
|