打印
定时器修改
This commit is contained in:
parent
ba8fd9e53b
commit
26d46cad00
@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HHWMS.Web.Models;
|
||||
using ICSharpCode.SharpZipLib.Core;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
@ -26,6 +27,9 @@ namespace HHWMS.Web.Controllers
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
var inv = _unitwork.Find<Inventory>(x => x.TaskStatus != InventoryTaskStatus.任务中)
|
||||
.ToList()
|
||||
.GroupBy(x => x.ContainerCode);
|
||||
var vm = Wtm.CreateVM<ContainerListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
@ -56,6 +60,7 @@ namespace HHWMS.Web.Controllers
|
||||
else
|
||||
{
|
||||
var materialQrList = new List<MaterialQr>();
|
||||
var printList = new List<dynamic>();
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
var prefix = code.Split("@")[1].Substring(2);
|
||||
@ -69,9 +74,14 @@ namespace HHWMS.Web.Controllers
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = Wtm.LoginUserInfo.ITCode
|
||||
});
|
||||
printList.Add(new
|
||||
{
|
||||
UniqueCode = uniqueCode,
|
||||
Batch = material.Batch
|
||||
});
|
||||
}
|
||||
_unitwork.BatchAdd(materialQrList.ToArray());
|
||||
return JsonMore(materialQrList);
|
||||
return JsonMore(printList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-input v-model.number="num"
|
||||
placeholder="请输入数量">
|
||||
placeholder="请输入数量" readonly>
|
||||
</el-input>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
@ -78,7 +78,7 @@
|
||||
data: { code: _this.qrcode },
|
||||
url: "/configs/Print/ScanCode",
|
||||
success: function (json) {
|
||||
console.log(json);
|
||||
// console.log(json);
|
||||
if (json.Code != 200) {
|
||||
_this.$message({
|
||||
message: "扫描失败!" + json.Msg,
|
||||
@ -86,6 +86,7 @@
|
||||
duration: "10000",
|
||||
});
|
||||
}
|
||||
_this.printData = [];
|
||||
},
|
||||
error: function (json) {
|
||||
_this.$message({
|
||||
@ -130,12 +131,14 @@
|
||||
return;
|
||||
}
|
||||
else{
|
||||
console.log(json);
|
||||
// console.log(json);
|
||||
json.Data.forEach(function (item) {
|
||||
_this.gendCode += item.UniqueCode + '\n';
|
||||
_this.gendCode += item.Batch + '\n';
|
||||
_this.printData.push({ uniqueCode: item.UniqueCode });
|
||||
_this.printData.push({ uniqueCode: item.Batch });
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
error: function (json) {
|
||||
@ -156,7 +159,7 @@
|
||||
template: this.template
|
||||
})
|
||||
hiprintTemplate.print(this.printData);
|
||||
_this.printData = [];
|
||||
// _this.printData = [];
|
||||
//清空
|
||||
_this.qrcode = '';
|
||||
_this.unm = 1;
|
||||
|
||||
@ -107,6 +107,7 @@ public class ShipOutController : BaseController
|
||||
if (Sation != null)
|
||||
{
|
||||
Sation.ContainerCode = "";
|
||||
Sation.Height = 0;
|
||||
_unitWork.Update(Sation);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,26 +26,23 @@ namespace HHWMS.Web
|
||||
|
||||
var tasks = _unitwork.Find<TaskHeader>(x =>x.Status > TaskStatusEnum.新建 && x.Status < TaskStatusEnum.已下发)
|
||||
.Include(x => x.TaskDetails)
|
||||
.OrderBy(x => x.Priority)
|
||||
.ToList();
|
||||
foreach (var task in tasks)
|
||||
{
|
||||
if (task != null)
|
||||
{
|
||||
var count = 0;
|
||||
var Count = 0;
|
||||
if (task.TaskType == TaskTypeEnum.盘料入库)
|
||||
{
|
||||
GenTask(task, _unitwork);
|
||||
//子任务为新建的盘料入库任务不需要下发给WCS
|
||||
count = task.TaskDetails.Where(x => x.Status == TaskStatusEnum.新建).Count();
|
||||
//子任务部分完成,需要下发部分子任务
|
||||
Count = task.TaskDetails.Where(x => x.Status == TaskStatusEnum.待下发).Count();
|
||||
|
||||
count = task.TaskDetails.Where(x => x.Status <= TaskStatusEnum.待下发).Count();
|
||||
}
|
||||
else if (task.TaskType == TaskTypeEnum.盘料出库)
|
||||
{
|
||||
OutGenTask(task, _unitwork);
|
||||
//子任务为新建的盘料入库任务不需要下发给WCS
|
||||
count = task.TaskDetails.Where(x => x.Status == TaskStatusEnum.新建).Count();
|
||||
//if(OutGenTask(task, _unitwork))
|
||||
count = task.TaskDetails.Where(x => x.Status <= TaskStatusEnum.待下发).Count();
|
||||
}
|
||||
else if (task.TaskType == TaskTypeEnum.散料盒出库)
|
||||
{
|
||||
@ -57,8 +54,16 @@ namespace HHWMS.Web
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
if (count == 0 || Count > 0)
|
||||
else
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
if (count > 0)
|
||||
{
|
||||
var taskList = CreateWCSTask(task, _unitwork);
|
||||
foreach (var item in taskList)
|
||||
@ -251,14 +256,49 @@ namespace HHWMS.Web
|
||||
/// <summary>
|
||||
/// 根据盘料出库生成盘料盒出库任务
|
||||
/// </summary>
|
||||
public void OutGenTask(TaskHeader task, UnitWork _unitwork)
|
||||
public bool OutGenTask(TaskHeader task, UnitWork _unitwork)
|
||||
{
|
||||
//查找料塔工位
|
||||
var details = task.TaskDetails.Where(x => x.Status == TaskStatusEnum.新建
|
||||
&& string.IsNullOrEmpty(x.ToLocation));
|
||||
if(!details.Any())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
var container = _unitwork.Find<Location>(n => n.ContainerCode == task.ContainerCode).FirstOrDefault();
|
||||
|
||||
var tLoc = _unitwork.FindSingle<Location>(x => x.Code == task.ToLocation);
|
||||
|
||||
var outTask = _unitwork.Find<TaskHeader>(x => x.ContainerCode == task.ContainerCode
|
||||
&& x.TaskType == TaskTypeEnum.盘料盒出库).FirstOrDefault();
|
||||
if(outTask != null && tLoc.Height < tLoc.Length)
|
||||
{
|
||||
foreach (var detail in details)
|
||||
{
|
||||
if (tLoc.Height >= tLoc.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
detail.ToLocation = (Convert.ToInt32(tLoc.Height) + 1).ToString();
|
||||
detail.Lot = $"{Convert.ToInt32(container.Length)}-{task.ToLocation}";
|
||||
tLoc.Height += 1;
|
||||
if (tLoc.Height == tLoc.Length)
|
||||
{
|
||||
tLoc.Height = tLoc.Length;
|
||||
_unitwork.Update(tLoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
_unitwork.Update(tLoc);
|
||||
_unitwork.Update(task);
|
||||
return true;
|
||||
}
|
||||
if (string.IsNullOrEmpty(task.FromLocation))
|
||||
{
|
||||
var details = task.TaskDetails.Where(x => x.Status == TaskStatusEnum.新建);
|
||||
//var details = task.TaskDetails.Where(x => x.Status == TaskStatusEnum.新建);
|
||||
//根据盘料出库的托盘创建盘料盒出库任务
|
||||
var container = _unitwork.Find<Location>(n => n.ContainerCode == task.ContainerCode).FirstOrDefault();
|
||||
//var container = _unitwork.Find<Location>(n => n.ContainerCode == task.ContainerCode).FirstOrDefault();
|
||||
var station = _unitwork.FindSingle<Location>(x => x.Type.Equals(LocationTypeEnum.堆垛机工位) && x.Row == container.Row);
|
||||
if (container != null)
|
||||
{
|
||||
@ -277,13 +317,26 @@ namespace HHWMS.Web
|
||||
&& x.Type.Equals(LocationTypeEnum.机械臂工位))?.Code;
|
||||
task.FromLocation = from;
|
||||
//更新任务明细对应在料塔的位置
|
||||
var Invcount = 0;
|
||||
|
||||
foreach (var detail in details)
|
||||
{
|
||||
detail.ToLocation = (Invcount + 1).ToString();
|
||||
Invcount = Invcount + 1;
|
||||
detail.Lot = $"{Convert.ToInt32(container.Length)}-{task.ToLocation}";
|
||||
if (tLoc.Height >= tLoc.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
detail.ToLocation = (Convert.ToInt32(tLoc.Height) + 1).ToString();
|
||||
detail.Lot = $"{Convert.ToInt32(container.Length)}-{task.ToLocation}";
|
||||
tLoc.Height += 1;
|
||||
if (tLoc.Height == tLoc.Length)
|
||||
{
|
||||
tLoc.Height = tLoc.Length;
|
||||
_unitwork.Update(tLoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
_unitwork.Update(tLoc);
|
||||
var fromstation = _unitwork.Find<Location>(n => n.ContiguousCode == station.Code && n.Type.Equals(LocationTypeEnum.机械臂工位)).FirstOrDefault();
|
||||
if (fromstation != null)
|
||||
{
|
||||
@ -292,9 +345,9 @@ namespace HHWMS.Web
|
||||
_unitwork.Update(task);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建WCS任务
|
||||
|
||||
@ -26,198 +26,278 @@ namespace HHWMS.Web
|
||||
{
|
||||
var _unitwork = new UnitWork(Wtm);
|
||||
|
||||
var Shipments = _unitwork.Find<ShipmentHeader>(x =>x.FirstStatus == ShipStatusEnum.分配中)
|
||||
var Shipments = _unitwork.Find<ShipmentHeader>(x => x.FirstStatus == ShipStatusEnum.分配中)
|
||||
.Include(x => x.ShipmentDetails)
|
||||
.Take(5)
|
||||
.ToList();
|
||||
var shipments = Shipments.Take(1).ToList();
|
||||
|
||||
foreach (var shipment in shipments)
|
||||
|
||||
List<Inventory> shiInventorys = new List<Inventory>();
|
||||
using (var tran = Wtm.DC.Database.BeginTransaction())
|
||||
{
|
||||
List<Inventory> ShiInventorys = new List<Inventory>();
|
||||
var ShipmentDetails = shipment.ShipmentDetails.Where(x => x.Status.Equals(ShipStatusEnum.新建)).ToList();
|
||||
foreach (var ShipmentDetail in ShipmentDetails)
|
||||
try
|
||||
{
|
||||
var inventory = _unitwork.Find<Inventory>(x => x.UniqueCode == ShipmentDetail.UniqueCode
|
||||
&& x.TaskStatus == InventoryTaskStatus.无任务).FirstOrDefault();
|
||||
if (inventory == null)
|
||||
foreach (var shipment in Shipments)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
inventory.SourceCode = ShipmentDetail.ID.ToString();
|
||||
_unitwork.Update(inventory);
|
||||
//更新单据子表状态
|
||||
ShiInventorys.Add(inventory);
|
||||
}
|
||||
//出库库存通过托盘号分组
|
||||
var Inventorys = ShiInventorys.GroupBy(x => x.ContainerCode).ToList();
|
||||
//散料库
|
||||
if (Inventorys.First().Key.Contains("C"))
|
||||
{
|
||||
foreach (var item in Inventorys)
|
||||
{
|
||||
var inventory = item.FirstOrDefault();
|
||||
//出库托盘
|
||||
Location location = _unitwork.Find<Location>(x => x.Code == inventory.ContainerCode && x.Status != LocationStatus.任务锁).FirstOrDefault();
|
||||
if (location == null)
|
||||
var shipmentDetails = shipment.ShipmentDetails.Where(x => x.Status.Equals(ShipStatusEnum.新建)).ToList();
|
||||
foreach (var shipmentDetail in shipmentDetails)
|
||||
{
|
||||
continue;
|
||||
var inventorys = _unitwork.Find<Inventory>(x => x.UniqueCode == shipmentDetail.UniqueCode
|
||||
&& x.TaskStatus == InventoryTaskStatus.无任务).ToList();
|
||||
if (inventorys.Count <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var inventory in inventorys)
|
||||
{
|
||||
inventory.SourceCode = shipmentDetail.ShipmentHeader.Code;
|
||||
inventory.TaskStatus = InventoryTaskStatus.任务中;
|
||||
inventory.UpdateBy = "wmsjob";
|
||||
inventory.UpdateTime = DateTime.Now;
|
||||
|
||||
_unitwork.Update(inventory);
|
||||
shiInventorys.Add(inventory);
|
||||
|
||||
shipmentDetail.DividedQty += inventory.Qty;
|
||||
if (shipmentDetail.DividedQty >= shipmentDetail.Qty)
|
||||
{
|
||||
shipmentDetail.Status = ShipStatusEnum.分配完成;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
shipmentDetail.Status = ShipStatusEnum.分配中;
|
||||
}
|
||||
}
|
||||
shipmentDetail.UpdateTime = DateTime.Now;
|
||||
shipmentDetail.UpdateBy = "wmsjob";
|
||||
}
|
||||
// 查询目的地站台是否可用
|
||||
var stations = _unitwork.Find<Location>(x => x.Row == location.Row && x.Type == LocationTypeEnum.散料库站台 && string.IsNullOrEmpty(x.ContainerCode)).FirstOrDefault();
|
||||
if (stations == null)
|
||||
|
||||
if (!shipment.ShipmentDetails.Any(x => x.Status < ShipStatusEnum.分配完成))
|
||||
{
|
||||
continue;
|
||||
shipment.FirstStatus = ShipStatusEnum.分配完成;
|
||||
}
|
||||
else
|
||||
{
|
||||
//判断是否已经有目的站台的出库任务
|
||||
TaskHeader taskHeader = _unitwork.Find<TaskHeader>(x => x.ToLocation == stations.Code && x.TaskType == TaskTypeEnum.散料盒出库).FirstOrDefault();
|
||||
if (taskHeader != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// 创建任务
|
||||
var task = new TaskHeader
|
||||
{
|
||||
ZoneCode = ZoneCodeEnum.散料库,
|
||||
TaskNo = _unitwork.GetSerialNumber("SOut"),
|
||||
TaskType = TaskTypeEnum.散料盒出库,
|
||||
ContainerCode = inventory.ContainerCode,
|
||||
FromLocation = location.ContainerCode,
|
||||
ToLocation = stations.Code,
|
||||
Status = TaskStatusEnum.待下发,
|
||||
CreateTime = DateTime.Now,
|
||||
};
|
||||
_unitwork.Add(task);
|
||||
//更新库位状态
|
||||
location.Status = LocationStatus.任务锁;
|
||||
_unitwork.Update(location);
|
||||
|
||||
//更新库存状态
|
||||
var invs = _unitwork.Find<Inventory>(x => x.ContainerCode == inventory.ContainerCode).ToList();
|
||||
if (invs.Count() > 0)
|
||||
{
|
||||
foreach (var inv in invs)
|
||||
{
|
||||
inv.TaskStatus = InventoryTaskStatus.任务中;
|
||||
_unitwork.Update(inv);
|
||||
}
|
||||
}
|
||||
//更新单据主表状态
|
||||
foreach (var Inventory in item)
|
||||
{
|
||||
var shipmentdetail = shipment.ShipmentDetails.Where(x => x.ID == int.Parse(Inventory.SourceCode)).FirstOrDefault();
|
||||
if (shipmentdetail != null)
|
||||
{
|
||||
shipmentdetail.Status = ShipStatusEnum.分配完成;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shipment.ShipmentDetails.Any(x => x.Status < ShipStatusEnum.分配完成))
|
||||
{
|
||||
shipment.FirstStatus = ShipStatusEnum.分配完成;
|
||||
_unitwork.Update(shipment);
|
||||
}
|
||||
shipment.FirstStatus = ShipStatusEnum.分配中;
|
||||
}
|
||||
|
||||
shipment.UpdateBy = "wmsjob";
|
||||
shipment.UpdateTime = DateTime.Now;
|
||||
_unitwork.Update(shipment);
|
||||
}
|
||||
}
|
||||
//盘料库
|
||||
else if(Inventorys.First().Key.Contains("L"))
|
||||
{
|
||||
foreach (var item in Inventorys)
|
||||
|
||||
//出库库存通过托盘号分组
|
||||
var lockInvs = _unitwork.Find<Inventory>(x => x.TaskStatus == InventoryTaskStatus.任务中).ToList();
|
||||
shiInventorys.AddRange(lockInvs);
|
||||
shiInventorys.DistinctBy(x => x.UniqueCode);
|
||||
var inventoryList = shiInventorys.GroupBy(x => x.ContainerCode)
|
||||
.ToList();
|
||||
|
||||
//散料库
|
||||
if (inventoryList.Any(x => x.Key.Contains("C")))
|
||||
{
|
||||
var task = new TaskHeader();
|
||||
task.TaskDetails = new List<TaskDetail>();
|
||||
var Inventory = item.FirstOrDefault();
|
||||
var location = _unitwork.Find<Location>(x => x.ContainerCode == Inventory.ContainerCode
|
||||
&& x.Status != LocationStatus.空仓位
|
||||
&& x.Status != LocationStatus.空容器).FirstOrDefault();
|
||||
//查询仓位表是否符合
|
||||
if (location != null)
|
||||
foreach (var item in inventoryList.Where(x => x.Key.Contains("C")))
|
||||
{
|
||||
var row = 1;
|
||||
if (Inventory.Flag == 8)
|
||||
{
|
||||
row = 3;
|
||||
}
|
||||
else if(Inventory.Flag == 24 || Inventory.Flag == 16 || Inventory.Flag == 10)
|
||||
{
|
||||
row = 1;
|
||||
}
|
||||
//查找料塔工位
|
||||
var to = _unitwork.Find<Location>(x => string.IsNullOrEmpty(x.ContainerCode)
|
||||
&& x.Row == row
|
||||
&& x.Type.Equals(LocationTypeEnum.料塔)).FirstOrDefault();
|
||||
|
||||
//查询料塔是否为空
|
||||
if (to == null)
|
||||
//出库托盘
|
||||
Location location = _unitwork.Find<Location>(x => x.Code == item.Key && x.Status != LocationStatus.任务锁).FirstOrDefault();
|
||||
if (location == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
task.TaskNo = _unitwork.GetSerialNumber("pout", 4);
|
||||
task.TaskType = TaskTypeEnum.盘料出库;
|
||||
task.Status = TaskStatusEnum.待下发;
|
||||
task.ContainerCode = Inventory.ContainerCode;
|
||||
task.ToLocation = to.Code;
|
||||
task.ZoneCode = ZoneCodeEnum.盘料库;
|
||||
foreach (var inventory in item)
|
||||
// 查询目的地站台是否可用
|
||||
var station = _unitwork.Find<Location>(x => x.Row == location.Row && x.Type == LocationTypeEnum.散料库站台 && string.IsNullOrEmpty(x.ContainerCode)).FirstOrDefault();
|
||||
if (station == null)
|
||||
{
|
||||
var detail = new TaskDetail
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
//判断是否已经有目的站台的出库任务
|
||||
TaskHeader taskHeader = _unitwork.Find<TaskHeader>(x =>
|
||||
x.ToLocation == station.Code && x.TaskType == TaskTypeEnum.散料盒出库).FirstOrDefault();
|
||||
if (taskHeader != null)
|
||||
{
|
||||
UniqueCode = inventory.UniqueCode,
|
||||
FromLocation = inventory.Lot,
|
||||
Status = TaskStatusEnum.新建,
|
||||
ContainerCode = inventory.ContainerCode,
|
||||
CreateTime = DateTime.Now
|
||||
continue;
|
||||
}
|
||||
|
||||
// 创建任务
|
||||
var task = new TaskHeader
|
||||
{
|
||||
ZoneCode = ZoneCodeEnum.散料库,
|
||||
TaskNo = _unitwork.GetSerialNumber("SOut"),
|
||||
TaskType = TaskTypeEnum.散料盒出库,
|
||||
ContainerCode = item.Key,
|
||||
FromLocation = location.ContainerCode,
|
||||
ToLocation = station.Code,
|
||||
Status = TaskStatusEnum.待下发,
|
||||
Priority = 0,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = "wmsjob"
|
||||
};
|
||||
task.TaskDetails.Add(detail);
|
||||
_unitwork.Add(task);
|
||||
//更新库位状态
|
||||
location.Status = LocationStatus.任务锁;
|
||||
_unitwork.Update(location);
|
||||
}
|
||||
_unitwork.Add(task);
|
||||
//更新库位状态
|
||||
var container = _unitwork.Find<Location>(x => x.ContainerCode == Inventory.ContainerCode).FirstOrDefault();
|
||||
if (container != null)
|
||||
{
|
||||
container.Status = LocationStatus.任务锁;
|
||||
_unitwork.Update(container);
|
||||
}
|
||||
|
||||
to.ContainerCode = to.Code;
|
||||
_unitwork.Update(to);
|
||||
//更新库存状态
|
||||
var invs = _unitwork.Find<Inventory>(x => x.ContainerCode == Inventory.ContainerCode).ToList();
|
||||
if (invs.Count() > 0)
|
||||
{
|
||||
foreach (var inv in invs)
|
||||
{
|
||||
inv.TaskStatus = InventoryTaskStatus.任务中;
|
||||
_unitwork.Update(inv);
|
||||
}
|
||||
}
|
||||
//更新单据主表状态
|
||||
foreach (var inventory in item)
|
||||
{
|
||||
var shipmentdetail = shipment.ShipmentDetails.Where(x => x.ID == int.Parse(inventory.SourceCode)).FirstOrDefault();
|
||||
if (shipmentdetail != null)
|
||||
{
|
||||
shipmentdetail.Status = ShipStatusEnum.分配完成;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shipment.ShipmentDetails.Any(x => x.Status < ShipStatusEnum.分配完成))
|
||||
{
|
||||
shipment.FirstStatus = ShipStatusEnum.分配完成;
|
||||
_unitwork.Update(shipment);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//盘料库
|
||||
if (inventoryList.Any(x => x.Key.Contains("L")))
|
||||
{
|
||||
foreach (var item in inventoryList.Where(x => x.Key.Contains("L")))
|
||||
{
|
||||
var task = new TaskHeader();
|
||||
task.TaskDetails = new List<TaskDetail>();
|
||||
var inv = item.FirstOrDefault();
|
||||
var location = _unitwork.Find<Location>(x => x.ContainerCode == item.Key
|
||||
&& x.Status != LocationStatus.空仓位
|
||||
&& x.Status != LocationStatus.空容器).FirstOrDefault();
|
||||
//查询仓位表是否符合
|
||||
if (location != null)
|
||||
{
|
||||
var row = 1;
|
||||
if (inv.Flag == 8)
|
||||
{
|
||||
row = 3;
|
||||
}
|
||||
else if (inv.Flag == 24 || inv.Flag == 16 || inv.Flag == 10)
|
||||
{
|
||||
row = 1;
|
||||
}
|
||||
// 查找工位 G1
|
||||
var gLoc = _unitwork.Find<Location>(x => string.IsNullOrEmpty(x.ContainerCode)
|
||||
&& x.Row == location.Row
|
||||
&& x.Type.Equals(LocationTypeEnum.堆垛机工位)).FirstOrDefault();
|
||||
// 新建盘料盒出库任务
|
||||
if (gLoc != null)
|
||||
{
|
||||
var pTask = new TaskHeader
|
||||
{
|
||||
ZoneCode = ZoneCodeEnum.盘料库,
|
||||
TaskNo = _unitwork.GetSerialNumber("Out"),
|
||||
TaskType = TaskTypeEnum.盘料盒出库,
|
||||
ContainerCode = item.Key,
|
||||
FromLocation = location.ContainerCode,
|
||||
ToLocation = gLoc.Code,
|
||||
Status = TaskStatusEnum.待下发,
|
||||
Priority = 0,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateBy = "wmsjob"
|
||||
};
|
||||
//_unitwork.Add(pTask);
|
||||
//查找料塔工位 T
|
||||
var tLoc = _unitwork.Find<Location>(x => string.IsNullOrEmpty(x.ContainerCode)
|
||||
&& x.Row == row
|
||||
&& x.Type.Equals(LocationTypeEnum.料塔))
|
||||
.FirstOrDefault();
|
||||
|
||||
//查询料塔是否为空
|
||||
//if (tLoc == null)
|
||||
//{
|
||||
// //判断是否存在此托盘的出库任务
|
||||
// var containerTask = _unitwork.Find<TaskHeader>(x => x.Status < TaskStatusEnum.已下发
|
||||
// && x.ContainerCode == item.Key
|
||||
// && x.TaskType == TaskTypeEnum.盘料出库)
|
||||
// .Include(x => x.TaskDetails).FirstOrDefault();
|
||||
// if (containerTask != null)
|
||||
// {
|
||||
// foreach (var inventory in item)
|
||||
// {
|
||||
// if (tLoc.Height < tLoc.Length)
|
||||
// {
|
||||
// var detail = new TaskDetail
|
||||
// {
|
||||
// UniqueCode = inventory.UniqueCode,
|
||||
// Lot = $"{Convert.ToInt32(location.Length)}-{tLoc.Code}",
|
||||
// FromLocation = inventory.Lot,
|
||||
// ToLocation = (Convert.ToInt32(tLoc.Height) + 1).ToString(),
|
||||
// Status = TaskStatusEnum.新建,
|
||||
// ContainerCode = inventory.ContainerCode,
|
||||
// CreateTime = DateTime.Now
|
||||
// };
|
||||
// tLoc.Height += 1;
|
||||
// containerTask.Status = TaskStatusEnum.待下发;
|
||||
// containerTask.TaskDetails.Add(detail);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// _unitwork.Update(tLoc);
|
||||
// _unitwork.Update(containerTask);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
if (tLoc != null)
|
||||
{
|
||||
task.ZoneCode = ZoneCodeEnum.盘料库;
|
||||
task.TaskNo = _unitwork.GetSerialNumber("pout", 4);
|
||||
task.TaskType = TaskTypeEnum.盘料出库;
|
||||
task.Status = TaskStatusEnum.新建;
|
||||
task.ContainerCode = item.Key;
|
||||
task.Priority = 100;
|
||||
task.FromLocation = _unitwork
|
||||
.FindSingle<Location>(x => x.ContiguousCode == pTask.ToLocation)?.Code;
|
||||
task.ToLocation = tLoc.Code;
|
||||
task.CreateTime = DateTime.Now;
|
||||
task.CreateBy = "wmsjob";
|
||||
foreach (var inventory in item)
|
||||
{
|
||||
if (tLoc.Height < tLoc.Length)
|
||||
{
|
||||
var detail = new TaskDetail
|
||||
{
|
||||
UniqueCode = inventory.UniqueCode,
|
||||
Lot = $"{Convert.ToInt32(location.Length)}-{tLoc.Code}",
|
||||
FromLocation = inventory.Lot,
|
||||
ToLocation = (Convert.ToInt32(tLoc.Height) + 1).ToString(),
|
||||
Status = TaskStatusEnum.新建,
|
||||
ContainerCode = inventory.ContainerCode,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
task.TaskDetails.Add(detail);
|
||||
tLoc.Height += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
_unitwork.Add(pTask);
|
||||
_unitwork.Add(task);
|
||||
//更新库位状态
|
||||
var container = _unitwork.Find<Location>(x => x.ContainerCode == item.Key)
|
||||
.FirstOrDefault();
|
||||
if (container != null)
|
||||
{
|
||||
container.Status = LocationStatus.任务锁;
|
||||
container.UpdateTime = DateTime.Now;
|
||||
container.UpdateBy = "wmsjob";
|
||||
_unitwork.Update(container);
|
||||
}
|
||||
|
||||
tLoc.ContainerCode = tLoc.Code;
|
||||
tLoc.UpdateBy = "wmsjob";
|
||||
tLoc.UpdateTime = DateTime.Now;
|
||||
_unitwork.Update(tLoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tran.Commit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
tran.Rollback();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region 更新时间
|
||||
|
||||
@ -233,6 +313,7 @@ namespace HHWMS.Web
|
||||
_unitwork.Update<SysJob>(job);
|
||||
}
|
||||
Wtm.DoLog("出库分解", ActionLogTypesEnum.Job, "SendWmsJob");
|
||||
|
||||
#endregion 更新时间
|
||||
}
|
||||
catch { }
|
||||
|
||||
@ -27,18 +27,18 @@
|
||||
// "Value": "Server=127.0.0.1;Port=3306;Database=8357wms;Uid=root;Password=abc123*;Character Set=utf8mb4;",
|
||||
// "DBType": "mysql"
|
||||
//}
|
||||
{
|
||||
"Key": "default",
|
||||
"Value": "Data Source=.;Initial Catalog=8357wms;User=sa;Password=abc123*;Persist Security Info=True",
|
||||
"DbContext": "DataContext",
|
||||
"DBType": "sqlserver" //DataBase, you can choose mysql,sqlserver,pgsql,sqlite,oracle
|
||||
}
|
||||
//{
|
||||
// "Key": "default",
|
||||
// "Value": "Data Source=10.18.106.4;Initial Catalog=8357wms;User=wms;Password=abc123*;Persist Security Info=True",
|
||||
// "Value": "Data Source=.;Initial Catalog=8357wms;User=sa;Password=abc123*;Persist Security Info=True",
|
||||
// "DbContext": "DataContext",
|
||||
// "DBType": "sqlserver" //DataBase, you can choose mysql,sqlserver,pgsql,sqlite,oracle
|
||||
//}
|
||||
{
|
||||
"Key": "default",
|
||||
"Value": "Data Source=10.18.106.4;Initial Catalog=8357wms;User=wms;Password=abc123*;Persist Security Info=True",
|
||||
"DbContext": "DataContext",
|
||||
"DBType": "sqlserver" //DataBase, you can choose mysql,sqlserver,pgsql,sqlite,oracle
|
||||
}
|
||||
],
|
||||
"CookiePre": "HHWMS", //cookie前缀
|
||||
"IsQuickDebug": true, //是否启用debug模式
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user