接口, 出库,任务下发
This commit is contained in:
1 parent
f5423e78fe
commit
5c13b2a85c
38 files changed
+22919
-115
No files matched your search
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using AutoMapper;
|
||||
using HHWMS.Web.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -72,13 +74,88 @@ namespace HHWMS.Web
|
||||
var taskfromlocatioin = _unitwork.FindSingle<Location>(x => x.Code.Equals(task.FromLocation));
|
||||
switch (task.TaskType)
|
||||
{
|
||||
case TaskTypeEnum.散料盒入库:
|
||||
// 更新库位
|
||||
// 起始库位为空
|
||||
// 目标库位为有货
|
||||
// 更新库存
|
||||
task.Status = TaskStatusEnum.完成;
|
||||
taskfromlocatioin.Status = LocationStatus.空仓位;
|
||||
_unitwork.Update(taskfromlocatioin);
|
||||
|
||||
tasktolocatioin.Status = tasktolocatioin.Length == 1 ? LocationStatus.满货 : LocationStatus.有货;
|
||||
if (!_unitwork.IsExit<Inventory>(x => x.ContainerCode == tasktolocatioin.ContainerCode))
|
||||
{
|
||||
tasktolocatioin.Status = LocationStatus.空容器;
|
||||
}
|
||||
_unitwork.Update(tasktolocatioin);
|
||||
|
||||
_unitwork.BatchUpdate<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode),
|
||||
x => new Inventory
|
||||
{
|
||||
LocationCode = tasktolocatioin.Code,
|
||||
TaskStatus = InventoryTaskStatus.无任务,
|
||||
UpdateTime = DateTime.Now,
|
||||
UpdateBy = "wcs"
|
||||
});
|
||||
break;
|
||||
case TaskTypeEnum.散料盒出库:
|
||||
// 更新库位
|
||||
// 起始库位为空
|
||||
// 目标库位为有货
|
||||
// 更新库存
|
||||
task.Status = TaskStatusEnum.完成;
|
||||
|
||||
taskfromlocatioin.Status = LocationStatus.空仓位;
|
||||
_unitwork.Update(taskfromlocatioin);
|
||||
|
||||
tasktolocatioin.Status = LocationStatus.有货;
|
||||
_unitwork.Update(tasktolocatioin);
|
||||
|
||||
_unitwork.BatchUpdate<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode),
|
||||
x => new Inventory
|
||||
{
|
||||
LocationCode = tasktolocatioin.Code,
|
||||
UpdateTime = DateTime.Now,
|
||||
UpdateBy = "wcs"
|
||||
});
|
||||
|
||||
break;
|
||||
case TaskTypeEnum.盘料盒入库:
|
||||
// 更新库位
|
||||
// 起始库位为空
|
||||
// 目标库位为有货
|
||||
// 更新库存
|
||||
task.Status = TaskStatusEnum.完成;
|
||||
|
||||
|
||||
taskfromlocatioin.ContainerCode = "";
|
||||
taskfromlocatioin.Status = LocationStatus.空仓位;
|
||||
_unitwork.Update(taskfromlocatioin);
|
||||
|
||||
var invCount = _unitwork.GetCount<Inventory>(x => x.ContainerCode == tasktolocatioin.ContainerCode);
|
||||
if (invCount == tasktolocatioin.Length)
|
||||
{
|
||||
tasktolocatioin.Status = LocationStatus.满货;
|
||||
}
|
||||
else if (invCount < tasktolocatioin.Length)
|
||||
{
|
||||
tasktolocatioin.Status = LocationStatus.有货;
|
||||
}
|
||||
else if (invCount == 0)
|
||||
{
|
||||
tasktolocatioin.Status = LocationStatus.空容器;
|
||||
}
|
||||
_unitwork.Update(tasktolocatioin);
|
||||
|
||||
_unitwork.BatchUpdate<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode),
|
||||
x => new Inventory
|
||||
{
|
||||
LocationCode = tasktolocatioin.Code,
|
||||
TaskStatus = InventoryTaskStatus.无任务,
|
||||
UpdateTime = DateTime.Now,
|
||||
UpdateBy = "wcs"
|
||||
});
|
||||
|
||||
break;
|
||||
case TaskTypeEnum.盘料盒出库:
|
||||
// 更新库位
|
||||
@@ -86,55 +163,68 @@ namespace HHWMS.Web
|
||||
// 目标库位为有货
|
||||
// 更新库存
|
||||
task.Status = TaskStatusEnum.完成;
|
||||
|
||||
tasktolocatioin.ContainerCode = task.ContainerCode;
|
||||
tasktolocatioin.Status = LocationStatus.任务锁;
|
||||
_unitwork.Update(tasktolocatioin);
|
||||
|
||||
// 料盒出库是为了入,还是为了出 1是出,2是入
|
||||
/*if (task.Station == "1")
|
||||
if (task.Station == "1")
|
||||
{
|
||||
|
||||
// 下发盘料出库
|
||||
var plcTask = _unitwork.FindSingle<TaskHeader>(x => x.TaskType.Equals(TaskTypeEnum.盘料出库)
|
||||
&& x.ContainerCode.Equals(task.ContainerCode));
|
||||
if (plcTask != null)
|
||||
{
|
||||
plcTask.Status = TaskStatusEnum.待下发;
|
||||
_unitwork.Update(plcTask);
|
||||
}
|
||||
}
|
||||
else if (task.Station == "2")
|
||||
{
|
||||
|
||||
}*/
|
||||
// 测试 创建盘料出库任务
|
||||
var locationList = _unitwork.Find<Location>(x => x.Row == tasktolocatioin.Row && "T,G2".Contains(x.Type)).ToList();
|
||||
newTask.ZoneCode = "L";
|
||||
newTask.TaskNo = _unitwork.GetSerialNumber("pout", 4);
|
||||
newTask.TaskType = TaskTypeEnum.盘料出库;
|
||||
newTask.ContainerCode = "L02";
|
||||
newTask.FromLocation = locationList.First(x => x.Type.Equals("G2")).Code;
|
||||
newTask.ToLocation = "L02";
|
||||
newTask.Status = TaskStatusEnum.待下发;
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
newTask.TaskDetails.Add(new TaskDetail
|
||||
// 下发盘料入库
|
||||
var plrTask = _unitwork.Find<TaskHeader>(x => x.TaskType.Equals(TaskTypeEnum.盘料入库)
|
||||
&& x.ContainerCode.Contains(task.ContainerCode))
|
||||
.Include(x => x.TaskDetails).FirstOrDefault();
|
||||
if (plrTask != null)
|
||||
{
|
||||
UniqueCode = $"{newTask.TaskNo}-{i}",
|
||||
FromLocation = i.ToString(),
|
||||
ToLocation = i.ToString(),
|
||||
Status = TaskStatusEnum.新建
|
||||
});
|
||||
plrTask.Status = TaskStatusEnum.待下发;
|
||||
|
||||
// 更新明细为待下发
|
||||
var details = task.TaskDetails.Where(x => x.ContainerCode.Equals(task.ContainerCode));
|
||||
|
||||
foreach(var item in details)
|
||||
{
|
||||
item.Status = TaskStatusEnum.待下发;
|
||||
item.UpdateTime = DateTime.Now;
|
||||
}
|
||||
_unitwork.Update(plrTask);
|
||||
}
|
||||
}
|
||||
_unitwork.Add(newTask);
|
||||
break;
|
||||
case TaskTypeEnum.盘料入库:
|
||||
var ll = response.TaskId.Split("-")[1];
|
||||
task.TaskDetails.First(x => x.FromLocation == ll).Status = TaskStatusEnum.完成;
|
||||
// 查询料塔 是否还有已下发,未完成的盘料入库任务 有不操作,没有 创建料盒入库任务
|
||||
if (!task.TaskDetails.Any(x => x.Status < TaskStatusEnum.完成))
|
||||
var containerCode = task.TaskDetails.First(x => x.FromLocation == ll).ContainerCode;
|
||||
// 查询料塔 是否还有 此料盒 已下发,未完成的盘料入库任务 有不操作,没有 创建料盒入库任务
|
||||
if (!task.TaskDetails.Any(x => x.Status < TaskStatusEnum.完成 && x.ContainerCode.Equals(containerCode)))
|
||||
{
|
||||
task.Status = TaskStatusEnum.完成;
|
||||
// 测试 创建料盒入库任务
|
||||
var fromL = _unitwork.FindSingle<Location>(x => x.Row.Equals(tasktolocatioin.Row) && x.Type == "G1");
|
||||
// 创建料盒入库任务
|
||||
// 查找回库的任务起点,
|
||||
var fromLocation = _unitwork.FindSingle<Location>(x => x.Code.Equals(task.FromLocation)).ContiguousCode;
|
||||
newTask.ZoneCode = "L";
|
||||
newTask.TaskNo = _unitwork.GetSerialNumber("in", 4);
|
||||
newTask.TaskType = TaskTypeEnum.盘料盒入库;
|
||||
newTask.ContainerCode = fromL.Code;
|
||||
newTask.FromLocation = fromL.Code;
|
||||
newTask.ToLocation = "L01-02-01-01";
|
||||
newTask.ContainerCode = containerCode;
|
||||
newTask.FromLocation = fromLocation;
|
||||
newTask.ToLocation = containerCode;
|
||||
newTask.Status = TaskStatusEnum.待下发;
|
||||
//newTask.Station = task.Station;
|
||||
_unitwork.Add(newTask);
|
||||
|
||||
}
|
||||
// 查询料塔 是否还有已下发,未完成的盘料入库任务
|
||||
if (!task.TaskDetails.Any(x => x.Status < TaskStatusEnum.完成))
|
||||
{
|
||||
task.Status = TaskStatusEnum.完成;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -145,25 +235,16 @@ namespace HHWMS.Web
|
||||
if (!task.TaskDetails.Any(x => x.Status < TaskStatusEnum.完成))
|
||||
{
|
||||
task.Status = TaskStatusEnum.完成;
|
||||
// 测试 创建盘料入库任务
|
||||
var locationList1 = _unitwork.Find<Location>(x => x.Row == tasktolocatioin.Row && "T,G2".Contains(x.Type)).ToList();
|
||||
// 查找回库的任务起点,
|
||||
var fromLocation = _unitwork.FindSingle<Location>(x => x.Code.Equals(task.FromLocation)).ContiguousCode;
|
||||
// 下发盘料盒回库任务,回原位
|
||||
newTask.ZoneCode = "L";
|
||||
newTask.TaskNo = _unitwork.GetSerialNumber("pin", 4);
|
||||
newTask.TaskType = TaskTypeEnum.盘料入库;
|
||||
newTask.ContainerCode = locationList1.First(x => x.Type.Equals("T")).Code;
|
||||
newTask.FromLocation = tasktolocatioin.Code;
|
||||
newTask.ToLocation = taskfromlocatioin.Code;
|
||||
newTask.TaskNo = _unitwork.GetSerialNumber("in", 4);
|
||||
newTask.TaskType = TaskTypeEnum.盘料盒入库;
|
||||
newTask.ContainerCode = task.ContainerCode;
|
||||
newTask.FromLocation = fromLocation;
|
||||
newTask.ToLocation = task.ContainerCode;
|
||||
newTask.Status = TaskStatusEnum.待下发;
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
newTask.TaskDetails.Add(new TaskDetail
|
||||
{
|
||||
UniqueCode = $"{newTask.TaskNo}-{i}",
|
||||
FromLocation = i.ToString(),
|
||||
ToLocation = i.ToString(),
|
||||
Status = TaskStatusEnum.新建
|
||||
});
|
||||
}
|
||||
_unitwork.Add(newTask);
|
||||
}
|
||||
break;
|
||||
@@ -189,7 +270,7 @@ namespace HHWMS.Web
|
||||
var taskno = response.TaskId.Split("-")[0];
|
||||
//wcs 任务反馈
|
||||
var task = _unitwork.Find<TaskHeader>(x => x.TaskNo.Equals(taskno) && x.Status != TaskStatusEnum.完成).Include(x => x.TaskDetails).FirstOrDefault();
|
||||
|
||||
|
||||
if (task != null)
|
||||
{
|
||||
if (task.Status != TaskStatusEnum.完成 && response.Result == (int)TaskStatusEnum.完成)
|
||||
@@ -273,9 +354,9 @@ namespace HHWMS.Web
|
||||
newTask.Status = TaskStatusEnum.待下发;
|
||||
//newTask.Station = task.Station;
|
||||
_unitwork.Add(newTask);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case TaskTypeEnum.盘料出库:
|
||||
var lll = response.TaskId.Split("-")[1];
|
||||
|
||||
@@ -10,8 +10,7 @@ using WalkingTec.Mvvm.Mvc;
|
||||
namespace HHWMS.Web.Controllers
|
||||
{
|
||||
[Area("configs")]
|
||||
//[ActionDescription("容器管理")]
|
||||
[ActionDescription("MenuKey.ActionLog")]
|
||||
[ActionDescription("容器管理")]
|
||||
public partial class ContainerController : BaseController
|
||||
{
|
||||
private readonly IUnitWork _unitwork;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HHWMS.Web.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
|
||||
namespace HHWMS.Web.Controllers
|
||||
{
|
||||
[Area("configs")]
|
||||
[ActionDescription("打印管理")]
|
||||
public partial class PrintController : BaseController
|
||||
{
|
||||
private readonly IUnitWork _unitwork;
|
||||
|
||||
public PrintController(IUnitWork unitwork)
|
||||
{
|
||||
_unitwork = unitwork;
|
||||
}
|
||||
|
||||
#region Search
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
var vm = Wtm.CreateVM<ContainerListVM>();
|
||||
return PartialView(vm);
|
||||
}
|
||||
#endregion Search
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<el-row id="print">
|
||||
<el-input v-model="code"
|
||||
placeholder="请扫描散料盒编码">
|
||||
</el-input>
|
||||
<el-button type="primary" @@click="print">打印</el-button>
|
||||
</el-row>
|
||||
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
let code1 = [{
|
||||
qrcode: '18279822586'
|
||||
}];
|
||||
let template1 = {
|
||||
"panels": [
|
||||
{
|
||||
"index": 0,
|
||||
"name": 1,
|
||||
"height": 25,
|
||||
"width": 35,
|
||||
"paperHeader": 49.5,
|
||||
"paperFooter": 65.65656565656563,
|
||||
"printElements": [
|
||||
{
|
||||
"options": {
|
||||
"left": 12.5,
|
||||
"top": 7.5,
|
||||
"height": 55,
|
||||
"width": 70,
|
||||
"title": "文本",
|
||||
"field": "qrcode",
|
||||
"right": 79.99609375,
|
||||
"bottom": 59.2421875,
|
||||
"vCenter": 44.99609375,
|
||||
"hCenter": 31.7421875,
|
||||
"coordinateSync": false,
|
||||
"widthHeightSync": false,
|
||||
"textType": "qrcode",
|
||||
"barcodeMode": "CODE39",
|
||||
"qrCodeLevel": 0
|
||||
},
|
||||
"printElementType": {
|
||||
"title": "这是更新后的元素",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
],
|
||||
"paperNumberLeft": 69,
|
||||
"paperNumberTop": 48,
|
||||
"paperNumberDisabled": true,
|
||||
"paperNumberContinue": true,
|
||||
"watermarkOptions": {
|
||||
"content": "vue-plugin-hiprint",
|
||||
"rotate": 25,
|
||||
"timestamp": true,
|
||||
"format": "YYYY-MM-DD HH:mm"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
let testhiprintTemplate = new hiprint.PrintTemplate({
|
||||
template: template1
|
||||
});
|
||||
console.log(testhiprintTemplate);
|
||||
let $html = testhiprintTemplate.getSimpleHtml(code1);
|
||||
console.log($html);
|
||||
});
|
||||
var app = new Vue({
|
||||
el: "#print",
|
||||
data() {
|
||||
return {
|
||||
code: '123',
|
||||
}
|
||||
},
|
||||
mettods: {
|
||||
print() {
|
||||
// this.$print(undefined, template, "123123", {})
|
||||
$html.jqprint({
|
||||
debug: false, //如果是true则可以显示iframe查看效果(iframe默认高和宽都很小,可以再源码中调大),默认是false
|
||||
importCSS: true, //true表示引进原来的页面的css,默认是true。(如果是true,先会找$("link[media=print]"),若没有会去找$("link")中的css文件)
|
||||
printContainer: true, //表示如果原来选择的对象必须被纳入打印(注意:设置为false可能会打破你的CSS规则)。
|
||||
operaSupport: false //表示如果插件也必须支持歌opera浏览器,在这种情况下,它提供了建立一个临时的打印选项卡。默认是true
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -239,7 +239,7 @@ namespace HHWMS.Web.Controllers
|
||||
/// <summary>
|
||||
/// 查所有新建的明细,已开始收货明细不允许点数
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public ActionResult SelectReceiptDetailsByCode(int id)
|
||||
{
|
||||
|
||||
@@ -150,8 +150,6 @@
|
||||
// 绑定
|
||||
onSubmit() {
|
||||
var _this = this;
|
||||
console.log("submit!");
|
||||
console.log(this.form);
|
||||
|
||||
// 提交已绑定数据
|
||||
$.ajax({
|
||||
|
||||
@@ -191,8 +191,6 @@
|
||||
// 绑定
|
||||
onSubmit() {
|
||||
var _this = this;
|
||||
console.log("submit!");
|
||||
console.log(this.form);
|
||||
|
||||
// 提交已绑定数据
|
||||
$.ajax({
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HHWMS.Web.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
using WalkingTec.Mvvm.Mvc;
|
||||
|
||||
namespace HHWMS.Web.Controllers;
|
||||
|
||||
[Area("shipment")]
|
||||
[ActionDescription("出库操作")]
|
||||
public class ShipOutController : BaseController
|
||||
{
|
||||
private readonly IUnitWork _unitWork;
|
||||
|
||||
public ShipOutController(IUnitWork unitWork)
|
||||
{
|
||||
_unitWork = unitWork;
|
||||
}
|
||||
|
||||
#region Search
|
||||
|
||||
[ActionDescription("Sys.Search")]
|
||||
public ActionResult Index()
|
||||
{
|
||||
return PartialView("Index");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 扫描散料箱/盘料周转箱 返回待出库明细
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ActionResult ScanBox(string code)
|
||||
{
|
||||
// 判断箱号是否合理
|
||||
var box = _unitWork.FindSingle<Location>(x => x.Code.Equals(code));
|
||||
if (box != null)
|
||||
{
|
||||
if (box.Type == LocationTypeEnum.散料库站台 || box.Type == LocationTypeEnum.料塔)
|
||||
{
|
||||
var inv = _unitWork.Find<Inventory>(x => x.LocationCode.Equals(code));
|
||||
return JsonMore(inv);
|
||||
}
|
||||
else
|
||||
{
|
||||
return JsonMore(null, 500, $"{code}不在站台!");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return JsonMore(null, 500, $"{code}不正确!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描唯一码,并验证
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ActionResult ScanUniqueCode(string code)
|
||||
{
|
||||
// 判断唯一码是否在 出库站台 料塔 或 抽屉
|
||||
var stationList = _unitWork.Find<Location>(x => x.Type.Equals(LocationTypeEnum.散料库站台)
|
||||
|| x.Type.Equals(LocationTypeEnum.料塔))
|
||||
.Select(x => x.Code).ToList();
|
||||
var inv = _unitWork.FindSingle<Inventory>(x => x.UniqueCode.Equals(code)
|
||||
&& stationList.Contains(x.LocationCode));
|
||||
if (inv != null)
|
||||
{
|
||||
return JsonMore(inv);
|
||||
}
|
||||
return JsonMore(null, 500, $"{code}不存在!");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Pick(string uniqueCode, decimal qty)
|
||||
{
|
||||
var inv = _unitWork.FindSingle<Inventory>(x => x.UniqueCode.Equals(uniqueCode));
|
||||
if (inv != null)
|
||||
{
|
||||
// 删除库存,扣账,记录库存交易 todo
|
||||
_unitWork.Delete(inv);
|
||||
|
||||
return JsonMore(inv);
|
||||
}
|
||||
return JsonMore(null, 500, $"{uniqueCode}不存在!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 散料箱回库,捡完回库
|
||||
/// </summary>
|
||||
/// <param name="boxCode"></param>
|
||||
/// <param name="isFull"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ActionResult BoxBack(string boxCode, bool isFull)
|
||||
{
|
||||
// 判断任务重复
|
||||
if(!_unitWork.IsExit<TaskHeader>(x => x.ZoneCode.Equals(ZoneCodeEnum.散料库) && x.ContainerCode.Equals(boxCode))){
|
||||
return JsonMore(null, 500, $"库内已存在{boxCode}的任务,请勿重复操作!");
|
||||
};
|
||||
// 判断箱号是否合理
|
||||
var box = _unitWork.FindSingle<Location>(x => x.ContainerCode.Equals(boxCode));
|
||||
if (box != null)
|
||||
{
|
||||
if(box.Type != LocationTypeEnum.散料库站台)
|
||||
{
|
||||
return JsonMore(null, 500, $"{boxCode}不在站台,无法入库!");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 查找目标库位
|
||||
var toLocation = _unitWork.FindSingle<Location>(x => x.Status.Equals(LocationStatus.空仓位)
|
||||
&& x.Type.Equals(LocationTypeEnum.散料库位)
|
||||
&& x.Row.Equals(box.Row));
|
||||
|
||||
if (toLocation != null)
|
||||
{
|
||||
// 创建任务
|
||||
var task = new TaskHeader
|
||||
{
|
||||
ZoneCode = ZoneCodeEnum.散料库,
|
||||
TaskNo = _unitWork.GetSerialNumber("CIn"),
|
||||
TaskType = TaskTypeEnum.散料盒入库,
|
||||
ContainerCode = boxCode,
|
||||
FromLocation = box.Code,
|
||||
ToLocation = toLocation.Code,
|
||||
Status = TaskStatusEnum.新建,
|
||||
CreateBy = Wtm.LoginUserInfo.ITCode,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
_unitWork.Add(task);
|
||||
|
||||
toLocation.Status = LocationStatus.任务锁;
|
||||
toLocation.Length = isFull ? 1 : 0; // 是否满盘
|
||||
_unitWork.Update(toLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
return JsonMore(null, 500, $"库内无可用仓位,无法入库!");
|
||||
}
|
||||
}
|
||||
return JsonMore(data: null);
|
||||
}
|
||||
else
|
||||
{
|
||||
return JsonMore(null, 500, $"{boxCode}不正确!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<el-row id="outapp">
|
||||
<el-card class="box-card" :span="16">
|
||||
<el-form ref="form" :model="form" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="4">
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-select v-model="type"
|
||||
placeholder="请选择类型"
|
||||
style="width: 100%"
|
||||
clearable>
|
||||
<el-option v-for="item in taskType"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="16">
|
||||
<el-input v-model="form.code"
|
||||
placeholder="请扫描"
|
||||
@@change="scanCode">
|
||||
</el-input>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row v-show="showTable">
|
||||
<el-divider></el-divider>
|
||||
<el-table :data="invTable" height="400" stripe border @@row-click="selectdata"
|
||||
style="width: 100%">
|
||||
<el-table-column label="唯一码" width="220" align="center" prop="UniqueCode"></el-table-column>
|
||||
<el-table-column label="编码" align="center" prop="MaterialCode"></el-table-column>
|
||||
<el-table-column label="规格型号" align="center" prop="MaterialSpec"></el-table-column>
|
||||
<el-table-column label="批次" align="center" prop="Batch"></el-table-column>
|
||||
<el-table-column label="数量" align="center" prop="Qty"></el-table-column>
|
||||
</el-table>
|
||||
</el-row>
|
||||
<el-divider></el-divider>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="唯一码" prop="uniqueCode">
|
||||
<el-input v-model="form.uniqueCode" ref="uniqueCode"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="物料码" prop="materialCode">
|
||||
<el-input v-model="form.materialCode" readonly></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="规格型号" prop="materialSpec">
|
||||
<el-input v-model="form.materialSpec" readonly></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="批次" prop="batch">
|
||||
<el-input v-model="form.batch" readonly></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="数量" prop="qty">
|
||||
<el-input v-model.number="form.qty" ref="qty" ></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-form-item style="float:right">
|
||||
<el-button type="primary" @@click="onSubmit">拣货</el-button>
|
||||
</el-form-item>
|
||||
</el-row>
|
||||
|
||||
<el-row v-show="form.type=='slbox'">
|
||||
<el-divider></el-divider>
|
||||
<el-form-item style="float: right">
|
||||
<el-button type="primary" @@click="back">回库</el-button>
|
||||
</el-form-item>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</el-row>
|
||||
|
||||
<script>
|
||||
var app = new Vue({
|
||||
el: "#outapp",
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
code: "",
|
||||
uniqueCode: "",
|
||||
materialCode: "",
|
||||
materialSpec: "",
|
||||
batch: "",
|
||||
qty: ""
|
||||
},
|
||||
type: "",
|
||||
taskType: [
|
||||
{ label: "散料箱", value: "slbox" },
|
||||
{ label: "料塔周转箱", value: "lt" },
|
||||
{ label: "唯一码", value: "uniqueCode" },
|
||||
],
|
||||
invTable:[],
|
||||
showTable: false
|
||||
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// 选中行
|
||||
selectdata(data) {
|
||||
this.form.uniqueCode = data.UniqueCode;
|
||||
this.form.materialCode = data.MaterialCode;
|
||||
this.form.materialSpec = data.MaterialSpec;
|
||||
this.form.batch = data.Batch;
|
||||
this.form.qty = data.Qty;
|
||||
},
|
||||
// 扫描
|
||||
scanCode(data) {
|
||||
var _this = this;
|
||||
if (_this.type == "") {
|
||||
_this.$message({
|
||||
message: "请先选择操作类型!",
|
||||
type: "warning",
|
||||
duration: "10000",
|
||||
});
|
||||
_this.form.code = "";
|
||||
return;
|
||||
}
|
||||
let url = "";
|
||||
if (_this.type == "uniqueCode") {
|
||||
url = "/shipment/ShipOut/ScanUniqueCode"
|
||||
}
|
||||
else{
|
||||
url = "/shipment/ShipOut/ScanBox"
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: { code: _this.form.code },
|
||||
url: url,
|
||||
success: function (json) {
|
||||
if (json.Code != 200) {
|
||||
_this.$message({
|
||||
message: "扫描失败!" + json.Msg,
|
||||
type: "warning",
|
||||
duration: "10000",
|
||||
});
|
||||
} else {
|
||||
if (_this.type == "uniqueCode") {
|
||||
_this.form.uniqueCode = json.Data.UniqueCode;
|
||||
_this.form.materialCode = json.Data.MaterialCode;
|
||||
_this.form.materialSpec = json.Data.MaterialSpec;
|
||||
_this.form.batch = json.Data.Batch;
|
||||
_this.form.qty = json.Data.Qty;
|
||||
} else {
|
||||
_this.showTable = true;
|
||||
_this.invTable = json.Data;
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (json) {
|
||||
_this.$message({
|
||||
message: "扫描失败!",
|
||||
type: "error",
|
||||
duration: "10000",
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
// 拣货
|
||||
onSubmit() {
|
||||
var _this = this;
|
||||
|
||||
// 提交已绑定数据
|
||||
$.ajax({
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: { uniqueCode: _this.form.uniqueCode, qty: _this.form.qty },
|
||||
url: "/shipment/ShipOut/Pick",
|
||||
success: function (json) {
|
||||
if (json.Code == 200) {
|
||||
_this.$message({
|
||||
message: "拣货成功!",
|
||||
});
|
||||
// 删除invTable 对应的 uniqueCode行
|
||||
_this.invTable.forEach(function (value, index, arr) {
|
||||
if (value.UniqueCode == _this.form.uniqueCode) {
|
||||
arr.splice(index, 1);
|
||||
}
|
||||
});
|
||||
_this.$refs['form'].resetFields();
|
||||
} else {
|
||||
_this.$message({
|
||||
message: "提交失败!",
|
||||
type: "warning",
|
||||
duration: "10000",
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (json) {
|
||||
_this.$message({
|
||||
message: "提交失败!",
|
||||
type: "error",
|
||||
duration: "10000",
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
// 回库
|
||||
back() {
|
||||
var _this = this;
|
||||
// 创建回库任务
|
||||
if (_this.code == "") {
|
||||
_this.$message({
|
||||
message: "箱号为空,不能创建回库任务!",
|
||||
type: "error",
|
||||
duration: "1000",
|
||||
});
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: { boxCode: _this.form.code, isFull: _this.form.isFull },
|
||||
url: "/shipment/ShipOut/BoxBack",
|
||||
success: function (json) {
|
||||
if (json.Code != 200) {
|
||||
_this.$message({
|
||||
message: "回库任务创建失败!" + json.Msg,
|
||||
type: "warning",
|
||||
duration: "10000",
|
||||
});
|
||||
} else {
|
||||
_this.$message({
|
||||
message: "回库任务创建成功!"
|
||||
});
|
||||
_this.resetForm('form');
|
||||
}
|
||||
},
|
||||
error: function (json) {
|
||||
_this.$message({
|
||||
message: "回库任务创建失败!",
|
||||
type: "error",
|
||||
duration: "10000",
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using HHWMS.Web.Models;
|
||||
@@ -22,31 +23,39 @@ namespace HHWMS.Web
|
||||
{
|
||||
var _unitwork = new UnitWork(Wtm);
|
||||
|
||||
var task = _unitwork.Find<TaskHeader>(x => x.Status == TaskStatusEnum.待下发)
|
||||
.Include(x => x.TaskDetails.Where(x => x.Status < TaskStatusEnum.已下发)).FirstDynamic();
|
||||
var taskList = CreateWCSTask(task, _unitwork);
|
||||
foreach (var item in taskList)
|
||||
{
|
||||
task.ErrorMsg += JsonConvert.SerializeObject(item);
|
||||
// 调用wcs任务下发接口
|
||||
try
|
||||
var task = _unitwork.Find<TaskHeader>(x =>x.Status > TaskStatusEnum.新建 && x.Status <= TaskStatusEnum.已下发)
|
||||
.Include(x => x.TaskDetails)
|
||||
.FirstOrDefault();
|
||||
if (task != null) {
|
||||
|
||||
if (task.TaskType == TaskTypeEnum.盘料入库)
|
||||
{
|
||||
var res = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, item).Result.Data;
|
||||
if (res.Success)
|
||||
GenTask(task, _unitwork);
|
||||
}
|
||||
var taskList = CreateWCSTask(task, _unitwork);
|
||||
foreach (var item in taskList)
|
||||
{
|
||||
task.ErrorMsg += JsonConvert.SerializeObject(item);
|
||||
// 调用wcs任务下发接口
|
||||
try
|
||||
{
|
||||
task.TaskDetails.Where(x => x.UniqueCode.Equals(item.ObjId)).First().Status = TaskStatusEnum.已下发;
|
||||
//var res = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, item).Result.Data;
|
||||
//if (res.Success)
|
||||
//{
|
||||
// task.TaskDetails.Where(x => x.UniqueCode.Equals(item.ObjId)).First().Status = TaskStatusEnum.已下发;
|
||||
//}
|
||||
Task.Delay(500);
|
||||
}
|
||||
Task.Delay(500);
|
||||
catch(Exception ex)
|
||||
{
|
||||
task.ErrorMsg += ex.Message;
|
||||
}
|
||||
if(task.TaskDetails.Count(x => x.Status == TaskStatusEnum.新建) == 0)
|
||||
{
|
||||
task.Status = TaskStatusEnum.已下发;
|
||||
}
|
||||
_unitwork.Update(task);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
task.ErrorMsg += ex.Message;
|
||||
}
|
||||
if(task.TaskDetails.Count(x => x.Status == TaskStatusEnum.新建) == 0)
|
||||
{
|
||||
task.Status = TaskStatusEnum.已下发;
|
||||
}
|
||||
_unitwork.Update(task);
|
||||
}
|
||||
|
||||
#region 更新时间
|
||||
@@ -62,13 +71,68 @@ namespace HHWMS.Web
|
||||
}
|
||||
_unitwork.Update<SysJob>(job);
|
||||
}
|
||||
|
||||
Wtm.DoLog("任务下发", ActionLogTypesEnum.Job, "SendWcsJob");
|
||||
#endregion 更新时间
|
||||
}
|
||||
catch { }
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
/// <summary>
|
||||
/// 生成任务
|
||||
/// </summary>
|
||||
public void GenTask(TaskHeader task, UnitWork _unitwork)
|
||||
{
|
||||
// 查找符合条件的料盒出库,创建料盒出库任务 length-width, 默认小盘料 找23格的料盒
|
||||
var details = task.TaskDetails.Where(x => x.Status == TaskStatusEnum.新建
|
||||
&& string.IsNullOrEmpty(x.ContainerCode));
|
||||
var count = details.Count();
|
||||
// 查找可用站台
|
||||
var station = _unitwork.FindSingle<Location>(x => x.Type.Equals(LocationTypeEnum.堆垛机工位)
|
||||
&& x.Status != LocationStatus.任务锁);
|
||||
if (station != null)
|
||||
{
|
||||
var container = _unitwork.Find<Location>(x => x.Row == station.Row
|
||||
&& x.Length == 23
|
||||
&& (x.Status == LocationStatus.有货 || x.Status == LocationStatus.空容器))
|
||||
.OrderByDescending(x => x.Length - x.Width).FirstOrDefault();
|
||||
if(container != null)
|
||||
{
|
||||
var newTask = new TaskHeader();
|
||||
newTask.ZoneCode = "L";
|
||||
newTask.TaskNo = _unitwork.GetSerialNumber("in", 4);
|
||||
newTask.TaskType = TaskTypeEnum.盘料盒出库;
|
||||
newTask.ContainerCode = container.Code;
|
||||
newTask.FromLocation = container.Code;
|
||||
newTask.ToLocation = station.Code;
|
||||
newTask.Status = TaskStatusEnum.待下发;
|
||||
_unitwork.Add(newTask);
|
||||
|
||||
// 更新库位
|
||||
container.Status = LocationStatus.任务锁;
|
||||
_unitwork.Update(container);
|
||||
|
||||
// 计算 容器可用格
|
||||
var used = _unitwork.Find<Inventory>(x => x.LocationCode.Equals(container.Code))
|
||||
.Select(x => int.Parse(x.Lot)).ToArray();
|
||||
var caseCount = Convert.ToInt32(container.Length);
|
||||
var caseList = Enumerable.Range(1, caseCount).ToArray();
|
||||
var canUse = caseList.Except(used).ToArray<int>();
|
||||
foreach(var item in canUse)
|
||||
{
|
||||
var detail = details.FirstOrDefault();
|
||||
if (detail != null)
|
||||
{
|
||||
details.First().Lot = $"{task.FromLocation}-{Convert.ToInt32(container.Length)}";
|
||||
details.First().ToLocation = item.ToString();
|
||||
details.First().ContainerCode = container.Code;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
_unitwork.Update(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建WCS任务
|
||||
/// </summary>
|
||||
@@ -85,18 +149,20 @@ namespace HHWMS.Web
|
||||
{
|
||||
case TaskTypeEnum.盘料盒入库:
|
||||
case TaskTypeEnum.盘料盒出库:
|
||||
case TaskTypeEnum.散料盒入库:
|
||||
case TaskTypeEnum.散料盒出库:
|
||||
var taskInfo = new TaskInfo();
|
||||
taskInfo.TaskType = (int)task.TaskType;
|
||||
taskInfo.TaskId = task.TaskNo;
|
||||
taskInfo.ObjId = task.ContainerCode;
|
||||
taskInfo.StartType = ConvertTypeLocation(begin.Length);
|
||||
taskInfo.StartType = ConvertTypeLocation(begin.Length.ToString());
|
||||
taskInfo.StartPos = new CoordPos
|
||||
{
|
||||
X = begin.Line,
|
||||
Y = begin.Row,
|
||||
Z = begin.Layer
|
||||
};
|
||||
taskInfo.EndType = ConvertTypeLocation(end.Length);
|
||||
taskInfo.EndType = ConvertTypeLocation(end.Length.ToString());
|
||||
taskInfo.EndPos = new CoordPos
|
||||
{
|
||||
X = end.Line,
|
||||
@@ -107,28 +173,33 @@ namespace HHWMS.Web
|
||||
break;
|
||||
|
||||
case TaskTypeEnum.盘料入库:
|
||||
foreach (var item in task.TaskDetails)
|
||||
var container = _unitwork.Find<Location>(x => x.Type == LocationTypeEnum.堆垛机工位)
|
||||
.Select(x => x.ContainerCode).ToList();
|
||||
foreach (var item in task.TaskDetails.Where(x => x.Status == TaskStatusEnum.待下发))
|
||||
{
|
||||
taskInfoList.Add(new TaskInfo
|
||||
if (container.Any(x => x == item.ContainerCode))
|
||||
{
|
||||
TaskId = $"{task.TaskNo}-{item.FromLocation}",
|
||||
TaskType = (int)task.TaskType,
|
||||
ObjId = item.UniqueCode,
|
||||
StartType = ConvertTypeLT(task.ContainerCode),
|
||||
StartPos = new CoordPos
|
||||
taskInfoList.Add(new TaskInfo
|
||||
{
|
||||
X = begin.Line,
|
||||
Y = 2,
|
||||
Z = int.Parse(item.FromLocation)
|
||||
},
|
||||
EndType = ConvertTypeLocation(end.Length),
|
||||
EndPos = new CoordPos
|
||||
{
|
||||
X = end.Line,
|
||||
Y = int.Parse(item.ToLocation),
|
||||
Z = 2
|
||||
}
|
||||
});
|
||||
TaskId = $"{task.TaskNo}-{item.FromLocation}",
|
||||
TaskType = (int)task.TaskType,
|
||||
ObjId = item.UniqueCode,
|
||||
StartType = ConvertTypeLT(item.Lot.Split('-')[0]),
|
||||
StartPos = new CoordPos
|
||||
{
|
||||
X = begin.Line,
|
||||
Y = 2,
|
||||
Z = int.Parse(item.FromLocation)
|
||||
},
|
||||
EndType = ConvertTypeLocation(item.Lot.Split('-')[1]),
|
||||
EndPos = new CoordPos
|
||||
{
|
||||
X = end.Line,
|
||||
Y = int.Parse(item.ToLocation),
|
||||
Z = 2
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -140,7 +211,7 @@ namespace HHWMS.Web
|
||||
TaskId = $"{task.TaskNo}-{item.FromLocation}",
|
||||
TaskType = (int)task.TaskType,
|
||||
ObjId = item.UniqueCode,
|
||||
StartType = ConvertTypeLocation(begin.Length),
|
||||
StartType = ConvertTypeLocation(item.Lot.Split('-')[0]),
|
||||
StartPos = new CoordPos
|
||||
{
|
||||
X = begin.Line,
|
||||
@@ -148,7 +219,7 @@ namespace HHWMS.Web
|
||||
Z = 2
|
||||
},
|
||||
|
||||
EndType = ConvertTypeLT(task.ContainerCode),
|
||||
EndType = ConvertTypeLT(item.Lot.Split('-')[1]),
|
||||
EndPos = new CoordPos
|
||||
{
|
||||
X = end.Line,
|
||||
@@ -166,28 +237,32 @@ namespace HHWMS.Web
|
||||
return taskInfoList;
|
||||
}
|
||||
|
||||
public int ConvertTypeLocation(decimal? length)
|
||||
public int ConvertTypeLocation(string length)
|
||||
{
|
||||
var type = 0;
|
||||
if (length.HasValue)
|
||||
if (!string.IsNullOrEmpty(length) )
|
||||
{
|
||||
switch ((int)length)
|
||||
switch (length)
|
||||
{
|
||||
case 23:
|
||||
case "23":
|
||||
type = (int)ContainerTypeEnum.格料盒23;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
case "13":
|
||||
type = (int)ContainerTypeEnum.格料盒13;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
case "16":
|
||||
type = (int)ContainerTypeEnum.格料盒16;
|
||||
break;
|
||||
|
||||
case 19:
|
||||
case "19":
|
||||
type = (int)ContainerTypeEnum.格料盒19;
|
||||
break;
|
||||
|
||||
default:
|
||||
type = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return type;
|
||||
|
||||
Reference in new issue
Block a user