力阔现场出入库流程

agv任务下发
修改部分实体类错误和页面字段等
layout 添加条码库
添加容器逻辑修改
This commit is contained in:
zhougf committed 2024-04-21 22:03:15 +08:00
1 parent 345b5a3d5b
commit b4632cfc33
29 files changed
+618 -849

No files matched your search

+3 -3
View File
@@ -8,12 +8,12 @@ namespace HHWMS.Web
{
protected JsonResult ApiResult(object data = null, string msg = "success")
{
return new JsonResult(new ApiJsonResult<object> { Data = data, Success = true, Status = true, Msg = msg });
return new JsonResult(new ApiJsonResult<object> { Data = data, Success = true, Msg = msg });
}
protected JsonResult ApiResultError(object data = null, string msg = "faield")
protected JsonResult ApiResultError(object data = null, string msg = "failed")
{
return new JsonResult(new ApiJsonResult<object> { Data = data, Success = false, Status = false, Msg = msg });
return new JsonResult(new ApiJsonResult<object> { Data = data, Success = false, Msg = msg });
}
}
}
+154 -62
View File
@@ -10,7 +10,7 @@ using WalkingTec.Mvvm.Core;
namespace HHWMS.Web
{
/// <summary>
/// WCS接口
/// 提供WCS调用接口
/// 调用方向 WCS --> WMS
/// </summary>
[Public]
@@ -19,65 +19,15 @@ namespace HHWMS.Web
[Route("api/[controller]/[action]"), ApiExplorerSettings(GroupName = "User")]
public class IWCSController : ApiController
{
private readonly IUnitWork _unitwork;
private readonly IUnitWork _unitWork;
private readonly IMapper _mapper;
public IWCSController(IUnitWork unitwork, IMapper mapper)
public IWCSController(IUnitWork unitWork, IMapper mapper)
{
_unitwork = unitwork;
_unitWork = unitWork;
_mapper = mapper;
}
/// <summary>
/// 请求入库
/// </summary>
/// <returns></returns>
[HttpPost]
public IActionResult RequestIn(WcsRequest request)
{
//var inv = new List<Inventory>();
//for (int i = 0; i < 10; i++)
// inv.Add(new Inventory
// {
// ContainerCode = "test" + i
// });
//_unitwork.BatchAdd<Inventory>(inv);
//_unitwork.DeleteById<Inventory>(1441);
//_unitwork.BatchUpdate<Inventory>(x => x.ID > 1030, x=>new Inventory { Batch = "test"});
// 测试 删除数据 保存到历史表 主子表数据
/*var receipt = _unitwork.Find<ReceiptHeader>(x => x.ID == 3)
.FirstOrDefault();
var details = _unitwork.Find<ReceiptDetail>(x => x.HeaderId == 3)
.ToArray();
var his = _mapper.Map<ReceiptHeaderHistory>(receipt);
var his2 = _mapper.Map<ReceiptDetail[], IEnumerable<ReceiptDetailHistory>>(details);
_unitwork.Add(his);
_unitwork.BatchAdd(his2);*/
/*var receipt = _unitwork.Find<ShipmentHeader>(x => x.ID == 3)
.FirstOrDefault();
var details = _unitwork.Find<ShipmentDetail>(x => x.HeaderId == 3)
.ToArray();
var his = _mapper.Map<ShipmentHeaderHistory>(receipt);
var his2 = _mapper.Map<ShipmentDetail[], IEnumerable<ShipmentDetailHistory>>(details);
_unitwork.Add(his);
_unitwork.BatchAdd(his2);*/
var receipt = _unitwork.Find<TaskHeader>(x => 1==1)
.FirstOrDefault();
var details = _unitwork.Find<TaskDetail>(x => x.HeaderId == receipt.ID)
.ToArray();
var his = _mapper.Map<TaskHeaderHistory>(receipt);
var his2 = _mapper.Map<TaskDetail[], IEnumerable<TaskDetailHistory>>(details);
_unitwork.Add(his);
_unitwork.BatchAdd(his2);
return ApiResult();
}
/// <summary>
/// 状态返回
/// </summary>
@@ -92,7 +42,7 @@ namespace HHWMS.Web
}
// 判断任务是否合理
var task = _unitwork.FindSingle<TaskHeader>(x => x.TaskNo.Equals(request.TaskNo));
var task = _unitWork.FindSingle<TaskHeader>(x => x.TaskNo.Equals(request.TaskNo));
if(task == null)
{
return ApiResultError(msg: $"任务不存在, 任务号 {request.TaskNo} , 请检查后重新请求!");
@@ -103,37 +53,139 @@ namespace HHWMS.Web
{
case TaskTypeEnum.立库入库:
// 1.更新库存
_unitwork.BatchUpdate<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode), x => new Inventory
_unitWork.BatchUpdate<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode), x => new Inventory
{
UpdateTime = DateTime.Now,
UpdateBy = "WMS",
TaskStatus = InventoryTaskStatus.无任务
});
// 2.更新容器
_unitwork.BatchUpdate<Container>(x => x.Code.Equals(task.ContainerCode), x => new Container
_unitWork.BatchUpdate<Container>(x => x.Code.Equals(task.ContainerCode), x => new Container
{
UpdateTime = DateTime.Now,
UpdateBy = "WMS",
Status = ContainerStatus.有,
IsLock = ContainerLockEnum.未锁,
LocationCode = task.ToLocation
});
// 3.更新库位
_unitwork.BatchUpdate<Location>(x => x.Code.Equals(task.ToLocation), x => new Location
_unitWork.BatchUpdate<Location>(x => x.Code.Equals(task.ToLocation), x => new Location
{
UpdateTime = DateTime.Now,
UpdateBy = "WMS",
Status = LocationStatus.有货,
Status = LocationStatus.空容器,
ContainerCode = task.ContainerCode
});
// 4.插入库存交易
// 1.将任务容器的库存查出来
var inventoryList = _unitWork.Find<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode)).ToList();
if (inventoryList.Count > 0)
{
// 2.根据库存生成库存交易出库信息
var inventoryTransactions = inventoryList.Select(inventory => new InventoryTransaction
{
BillType = InventoryTranType.入库,
MaterialCode = inventory.MaterialCode,
MaterialName = inventory.MaterialName,
MaterialUnit = inventory.MaterialUnit,
Batch = inventory.Batch,
Lot = inventory.Lot,
LocationCode = inventory.LocationCode,
ContainerCode = inventory.ContainerCode,
Qty = inventory.Qty,
CreateTime = DateTime.Now,
CreateBy = "WMS",
UpdateTime = DateTime.Now,
UpdateBy = "WMS"
}).ToList();
// 3.批量插入库存交易
_unitWork.BatchAdd(inventoryTransactions);
}
break;
case TaskTypeEnum.立库出库:
_unitWork.BatchUpdate<Container>(x => x.Code.Equals(task.ContainerCode), x => new Container
{
UpdateTime = DateTime.Now,
UpdateBy = "WMS",
IsLock = ContainerLockEnum.未锁,
LocationCode = ""
});
_unitWork.BatchUpdate<Location>(x => x.Code.Equals(task.FromLocation), x => new Location
{
UpdateTime = DateTime.Now,
UpdateBy = "WMS",
Status = LocationStatus.空仓位,
ContainerCode = ""
});
// 1.将任务容器的库存查出来
var inventoryList2 = _unitWork.Find<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode)).ToList();
if (inventoryList2.Count > 0)
{
// 2.根据库存生成库存交易出库信息
var inventoryTransactions2 = inventoryList2.Select(inventory => new InventoryTransaction
{
BillType = InventoryTranType.出库,
MaterialCode = inventory.MaterialCode,
MaterialName = inventory.MaterialName,
MaterialUnit = inventory.MaterialUnit,
Batch = inventory.Batch,
Lot = inventory.Lot,
LocationCode = inventory.LocationCode,
ContainerCode = inventory.ContainerCode,
Qty = inventory.Qty,
CreateTime = DateTime.Now,
CreateBy = "WMS",
UpdateTime = DateTime.Now,
UpdateBy = "WMS"
}).ToList();
// 3.批量插入库存交易
_unitWork.BatchAdd(inventoryTransactions2);
_unitWork.BatchDelete<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode));
}
// 下发AGV到出库口的任务
// 如果对接 执行下方任务,否则不执行
var interfaceAgv = _unitWork.FindSingle<SysCount>(x => x.Prefix == "interfaceAGV")?.Value;
if (interfaceAgv == 1)
{
var postAgv = new
{
task_id = "123456"
};
var res = Wtm.CallAPI<dynamic>("ACS", "task_mould_do", HttpMethodEnum.POST, postAgv);
// if (res.Result.Data.ack == 0)
// {
//
// }
}
break;
default:
return ApiResultError(msg:$"任务类型不正确!任务号{request.TaskNo}");
}
task.Status = TaskStatusEnum.完成;
// 插到历史表,或者接下来流程
_unitWork.Add(new TaskHeaderHistory
{
TaskNo = task.TaskNo,
TaskType = task.TaskType,
FromLocation = task.FromLocation,
ToLocation = task.ToLocation,
ContainerCode = task.ContainerCode,
Status = task.Status,
CreateTime = DateTime.Now,
CreateBy = "WMS"
});
_unitWork.Delete(task);
return ApiResult();
}
@@ -144,9 +196,29 @@ namespace HHWMS.Web
[HttpPost]
public IActionResult FullIn(WcsRequest request)
{
return ApiResult();
}
var task = _unitWork.FindSingle<TaskHeader>(x => x.TaskNo.Equals(request.TaskNo));
if (task == null)
{
return ApiResultError(msg: $"任务不存在, 任务号 {request.TaskNo} , 请检查后重新请求!");
}
var location = _unitWork.FindSingle<Location>(x => x.Status == LocationStatus.空仓位);
if(location == null)
{
return ApiResultError(msg: "没有空仓位");
}
task.ToLocation = location.Code;
_unitWork.Update(task);
location.Status = LocationStatus.任务锁;
_unitWork.Update(location);
return ApiResult(new
{
locationCode = location.Code
});
}
/// <summary>
/// 空出
@@ -155,7 +227,27 @@ namespace HHWMS.Web
[HttpPost]
public IActionResult EmptyOut(WcsRequest request)
{
var task = _unitWork.FindSingle<TaskHeader>(x => x.TaskNo.Equals(request.TaskNo));
if(task == null)
{
return ApiResultError(msg: $"任务不存在, 任务号 {request.TaskNo} , 请检查后重新请求!");
}
_unitWork.Add(new TaskHeaderHistory
{
TaskNo = task.TaskNo,
TaskType = task.TaskType,
FromLocation = task.FromLocation,
ToLocation = task.ToLocation,
ContainerCode = task.ContainerCode,
Status = task.Status,
CreateTime = DateTime.Now,
CreateBy = "WMS"
});
_unitWork.Delete(task);
return ApiResult();
}
}
}
@@ -265,8 +265,10 @@ namespace HHWMS.Web.Controllers
vm.MSD.AddModelError(vm.Entity.BatchError, "数量和类型必填,且数量要大于0!");
return PartialView(vm);
}
var maxContainer = _unitwork.Find<Container>(x => x.Type == vm.Entity.Type).ToList().MaxBy(x => x.Code);
int maxNum = 1;
var maxContainer = _unitwork.Find<Container>(x => x.Type == vm.Entity.Type)
.ToList()
.MaxBy(x => x.Code);
int maxNum = 0;
if (maxContainer != null)
int.TryParse(maxContainer?.Code.Substring(1, 4), out maxNum);
// 查询已有的最大托盘值 在此基础上累加
@@ -31,6 +31,8 @@ namespace HHWMS.Web
this.MakeStandardAction("Container", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "configs", dialogWidth: 800),
this.MakeStandardAction("Container", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "configs"),
this.MakeAction("Container","AddContainer",Localizer["Container.AddContainer"],Localizer["Container.AddContainer"],GridActionParameterTypesEnum.NoId,"configs"),
this.MakeAction("Location","Print",Localizer["Sys.Print"],Localizer["Sys.Print"],GridActionParameterTypesEnum.MultiIds,"configs")
.SetShowDialog(false).SetOnClickScript("print"),
};
}
@@ -12,12 +12,6 @@ namespace HHWMS.Web
{
public partial class MaterialTemplateVM : BaseTemplateVM
{
[Display(Name = "Inventory.UniqueCode")]
public ExcelPropety UniqueCode_Excel = ExcelPropety.CreateProperty<Material>(x => x.UniqueCode);
[Display(Name = "Inventory.QRCode")]
public ExcelPropety QRCode_Excel = ExcelPropety.CreateProperty<Material>(x => x.QRCode);
[Display(Name = "Inventory.SourceCode")]
public ExcelPropety SourceCode_Excel = ExcelPropety.CreateProperty<Material>(x => x.SourceCode);
[Display(Name = "Inventory.MaterialCode")]
public ExcelPropety MaterialCode_Excel = ExcelPropety.CreateProperty<Material>(x => x.MaterialCode);
[Display(Name = "Inventory.MaterialType")]
@@ -32,9 +32,6 @@ namespace HHWMS.Web
protected override IEnumerable<IGridColumn<Material_View>> InitGridHeader()
{
return new List<GridColumn<Material_View>>{
this.MakeGridHeader(x => x.UniqueCode).SetHide(),
this.MakeGridHeader(x => x.QRCode),
this.MakeGridHeader(x => x.SourceCode).SetHide(),
this.MakeGridHeader(x => x.MaterialCode),
this.MakeGridHeader(x => x.MaterialType),
this.MakeGridHeader(x => x.MaterialName),
@@ -52,15 +49,10 @@ namespace HHWMS.Web
public override IOrderedQueryable<Material_View> GetSearchQuery()
{
var query = DC.Set<Material>()
.CheckContain(Searcher.UniqueCode, x=>x.UniqueCode)
.CheckContain(Searcher.QRCode, x=>x.QRCode)
.CheckContain(Searcher.MaterialCode, x=>x.MaterialCode)
.Select(x => new Material_View
{
ID = x.ID,
UniqueCode = x.UniqueCode,
QRCode = x.QRCode,
SourceCode = x.SourceCode,
MaterialCode = x.MaterialCode,
MaterialType = x.MaterialType,
MaterialName = x.MaterialName,
@@ -12,10 +12,6 @@ namespace HHWMS.Web
{
public partial class MaterialSearcher : BaseSearcher
{
[Display(Name = "Inventory.UniqueCode")]
public String UniqueCode { get; set; }
[Display(Name = "Inventory.QRCode")]
public String QRCode { get; set; }
[Display(Name = "Inventory.MaterialCode")]
public String MaterialCode { get; set; }
@@ -3,7 +3,7 @@
<wt:form vm="@Model">
<wt:row items-per-row="ItemsPerRowEnum.Two">
<wt:textbox field="Entity.Type" />
<wt:combobox field="Entity.Type" items="ContainerType"/>
<wt:textbox field="Num" />
<wt:textbox field="Entity.Length" />
<wt:textbox field="Entity.Width" />
@@ -14,3 +14,20 @@
</wt:row>
</wt:searchpanel>
<wt:grid vm="@Model" url="/configs/Container/Search"/>
<script>
let template = {"panels":[{"index":0,"height":60,"width":80,"paperHeader":43.5,"paperFooter":170.07874015748033,"printElements":[{"options":{"left":13.5,"top":22.5,"height":100.5,"width":198,"title":"12345678","field":"code","testData":"12345678","textType":"barcode","barcodeMode":"CODE128A","fontFamily":"Microsoft YaHei","fontSize":20.25,"textAlign":"center","lineHeight":30},"printElementType":{"type":"text"}}],"paperNumberLeft":196,"paperNumberTop":148,"paperNumberDisabled":true}]};
let printData = [];
function print(ids, datas) {
datas.forEach(function (value, index, arr) {
printData.push({ code: value.Code })
});
hiprint.init();
var hiprintTemplate = new hiprint.PrintTemplate({
template: template
});
hiprintTemplate.print(printData);
printData = [];
}
</script>
@@ -3,9 +3,6 @@
<wt:form vm="@Model">
<wt:row items-per-row="ItemsPerRowEnum.Two">
<wt:textbox field="Entity.UniqueCode" />
<wt:textbox field="Entity.QRCode" />
<wt:textbox field="Entity.SourceCode" />
<wt:textbox field="Entity.MaterialCode" />
<wt:textbox field="Entity.MaterialType" />
<wt:textbox field="Entity.MaterialName" />
@@ -4,9 +4,6 @@
<wt:form vm="@Model">
<wt:quote>@Localizer["Sys.DeleteConfirm"]</wt:quote>
<wt:row items-per-row="ItemsPerRowEnum.Two">
<wt:display field="Entity.UniqueCode" />
<wt:display field="Entity.QRCode" />
<wt:display field="Entity.SourceCode" />
<wt:display field="Entity.MaterialCode" />
<wt:display field="Entity.MaterialType" />
<wt:display field="Entity.MaterialName" />
@@ -3,9 +3,6 @@
<wt:form vm="@Model">
<wt:row items-per-row="ItemsPerRowEnum.Two">
<wt:display field="Entity.UniqueCode" />
<wt:display field="Entity.QRCode" />
<wt:display field="Entity.SourceCode" />
<wt:display field="Entity.MaterialCode" />
<wt:display field="Entity.MaterialType" />
<wt:display field="Entity.MaterialName" />
@@ -3,9 +3,6 @@
<wt:form vm="@Model">
<wt:row items-per-row="ItemsPerRowEnum.Two">
<wt:textbox field="Entity.UniqueCode" />
<wt:textbox field="Entity.QRCode" />
<wt:textbox field="Entity.SourceCode" />
<wt:textbox field="Entity.MaterialCode" />
<wt:textbox field="Entity.MaterialType" />
<wt:textbox field="Entity.MaterialName" />
@@ -3,8 +3,6 @@
<wt:searchpanel vm="@Model" reset-btn="true">
<wt:row items-per-row="ItemsPerRowEnum.Three">
<wt:textbox field="Searcher.UniqueCode" />
<wt:textbox field="Searcher.QRCode" />
<wt:textbox field="Searcher.MaterialCode" />
</wt:row>
</wt:searchpanel>
@@ -1,3 +1,5 @@
using System;
using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
@@ -5,14 +7,14 @@ using WalkingTec.Mvvm.Mvc;
namespace HHWMS.Web.Controllers
{
[Area("receipt")]
[ActionDescription("盘料操作")]
[ActionDescription("入库操作")]
public partial class ReceiptInController : BaseController
{
private readonly IUnitWork _unitWork;
public ReceiptInController(IUnitWork unitwork)
public ReceiptInController(IUnitWork unitWork)
{
_unitWork = unitwork;
_unitWork = unitWork;
}
#region Index
@@ -24,5 +26,77 @@ namespace HHWMS.Web.Controllers
}
#endregion Index
[HttpPost]
public ActionResult TaskIn(string containerCode)
{
// 判断containerCode是否为空
if (string.IsNullOrEmpty(containerCode))
{
return JsonMore(null, 500, "容器编码为空!请检查后重新提交!");
}
// 查询container表code为containercode的值
var container = _unitWork.FindSingle<Container>(u => u.Code == containerCode);
if (container == null)
{
return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!");
}
container.IsLock = ContainerLockEnum.任务锁;
container.UpdateTime = DateTime.Now;
container.UpdateBy = Wtm.LoginUserInfo?.ITCode??"WMS";
_unitWork.Update(container);
//查询location表的一个空库位 更新仓位状态为锁定
var location = _unitWork.FindSingle<Location>(u => u.Status == LocationStatus.空仓位);
// 判断location是否为空
if (location == null)
{
return JsonMore(null, 500, "库内没有空闲仓位!");
}
location.Status = LocationStatus.任务锁;
location.UpdateTime = DateTime.Now;
location.UpdateBy = Wtm.LoginUserInfo?.ITCode??"WMS";
_unitWork.Update(location);
//创建容器编码为containercode的任务
var task = new TaskHeader
{
ZoneCode = ZoneCodeEnum.立库,
TaskNo = _unitWork.GetSerialNumber("In"),
TaskType = TaskTypeEnum.立库入库,
ContainerCode = containerCode,
FromLocation = "",
ToLocation = location.Code,
Status = TaskStatusEnum.待下发,
CreateBy = Wtm.LoginUserInfo?.ITCode??"WMS",
CreateTime = DateTime.Now
};
_unitWork.Add(task);
// 下发任务到wcs
var postData = new
{
TaskNo = task.TaskNo,
PalletNo = task.ContainerCode,
FromLocation = task.FromLocation,
ToLocation = task.ToLocation
};
var res1 = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData);
var res = res1.Result.Data;
if (res.Success)
{
task.Status = TaskStatusEnum.已下发;
}
else
{
task.ErrorMsg = res.Msg;
}
task.UpdateTime = DateTime.Now;
task.UpdateBy = "WMS";
_unitWork.Update(task);
return JsonMore(null);
}
}
}
@@ -1,342 +1,56 @@
<el-row id="plapp" :gutter="20">
<el-col :span="6">
<el-card class="box-card" :span="8">
<el-select v-model="value" clearable filterable placeholder="请选择单据" size="big" style="width:100%"
@@change="changeselect" @@clear="clearReceipt">
<el-option v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-table :data="tableData" height="700" border
style="width: 100%">
<el-table-column prop="name"
label="唯一码"
align="center">
</el-table-column>
</el-table>
</el-card>
</el-col>
<el-col :span="18">
<el-card class="box-card" :span="16">
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="单据名称">
<el-input v-model="form.code" readonly></el-input>
</el-form-item>
<el-form-item label="周转箱编码" prop="boxCode">
<el-input v-model="form.boxCode" @@change="scanBox" ref="boxCode"></el-input>
</el-form-item>
<el-form-item label="料盘尺寸" prop="size">
<el-select v-model="form.size" placeholder="请选择料盘尺寸" style="width:100%" @@change="changeSize" clearable>
<el-option v-for="item in form.boxSize"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="唯一码" prop="uniqueCode">
<el-input v-model="form.uniqueCode" @@change="scanUniqueCode" ref="uniqueCode"></el-input>
</el-form-item>
<el-table :data="bindingData"
ref="tableData"
height="450" border
style="width: 100%">
<el-table-column fixed="left"
label="操作"
width="120"
align="center">
<template slot-scope="scope">
<el-button @@click.native.prevent="deleteRow(scope.$index, bindingData)"
type="text"
size="small">
移除
</el-button>
</template>
</el-table-column>
<el-table-column label="入库单编码" align="center" prop="receiptCode" v-if="false"></el-table-column>
<el-table-column label="周转箱" align="center" prop="boxCode"></el-table-column>
<el-table-column label="索引" align="center" prop="index"></el-table-column>
<el-table-column label="唯一码" align="center" prop="uniqueCode"></el-table-column>
<el-table-column label="料盘尺寸" align="center" prop="size" :formatter="sizeFormatter"></el-table-column>
</el-table>
<el-form-item style="float:right">
<el-button type="primary" @@click="onSubmit">绑定入库</el-button>
<el-button @@click="resetForm('form')">重置</el-button>
@* <el-button type="primary" @@click="inOperation">启动入库</el-button> *@
</el-form-item>
</el-form>
</el-card>
</el-col>
</el-row>
<div id="receiptin">
<a-space direction="vertical" fill>
<a-input :style="{width:'320px'}" placeholder="扫描箱号" v-model="ContainerCode" allow-clear/>
<a-button @@click="handleClick"
:loading="loading1"
type="primary">
入库
</a-button>
</a-space>
</div>
<script>
var app = new Vue({
el: '#plapp',
data() {
var validatePass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入工位编码'));
}
else if (value == 'L01' || value == 'L02') {
callback();
} else {
callback(new Error('请输入正确工位编码'));
}
};
const { createApp, reactive, ref } = Vue
return {
form: {
code: '',
boxCode: '',
boxSize: [],
size: '',
uniqueCode: ''
},
options: [],
value: '',
tableData: [],
bindingData: [],
dataIndex: [],
rules: {
boxCode: [
{ validator: validatePass, trigger: 'blur' }
]
}
}
},
mounted: function () {
// 获取所有单据编码
$.ajax({
type: "post",
dataType: "json",
data: {},
url: "/receipt/ReceiptIn/SelectReceiptCode",
success: function (json) {
app.options = json.Data;
},
error: function (json) {
alert("加载失败");
}
});
},
methods: {
sizeFormatter(row) {
return row.size + 'mm';
},
//绑定单据
onSubmit() {
var _this = this;
// 提交已绑定数据
$.ajax({
type: "post",
dataType: "json",
data: { data: _this.bindingData },
url: "/receipt/ReceiptIn/BindingData",
success: function (json) {
if (json.Code == 200) {
_this.$message({
message: '入库成功!',
type: 'success'
});
_this.resetForm('form');
}
else {
_this.$message({
message: '入库失败!',
type: 'warning'
});
}
},
error: function (json) {
_this.$message({
message: '入库失败!',
type: 'error'
});
}
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
this.form.boxSize = [];
this.bindingData = [];
},
clearReceipt() {
this.tableData = [];
},
// 选择单据后,查询明细
changeselect(data) {
var _this = this;
_this.form.code = data;
// 调用后台方法,查询单据明细数据
if (data != "") {
$.ajax({
type: "post",
dataType: "json",
data: { Code: data },
url: "/receipt/ReceiptIn/SelectReceipt",
success: function (json) {
_this.tableData = json.Data;
// 对比待绑定列表,删除在其表内的明细
_this.bindingData.forEach(function (item) {
_this.tableData.forEach(function (value, index, arr) {
if (value.name == item.uniqueCode) {
arr.splice(index, 1);
}
});
})
},
error: function (json) {
_this.$message({
message: '加载单据明细失败!',
type: 'error'
});
}
});
}
},
// 扫描周转箱
scanBox(Box) {
var _this = this;
_this.form.size = '';
_this.form.boxSize = [];
if (this.form.code == '') {
this.$message({
message: '请先选择单据!',
type: 'warning'
});
return;
}
$.ajax({
type: "post",
dataType: "json",
data: { boxCode: Box },
url: "/receipt/ReceiptIn/ScanBox",
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "扫描失败!" + json.Msg,
type: "warning",
duration: "10000",
});
_this.form.boxCode = "";
return false;
}
else {
_this.$message({
message: "扫描成功!",
type: "success",
duration: "10000",
});
_this.$refs.uniqueCode.focus();
if (Box == "L02") {
_this.form.boxSize = [{ label: "24mm", value: "24" }, { label: "16mm", value: "16" }, { label: "10mm", value: "10" }]
_this.dataIndex = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
}
else if (Box == "L01") {
_this.form.boxSize = [{ label: "8mm", value: "8" }];
_this.form.size = _this.form.boxSize[0].value;
_this.dataIndex = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
}
else {
_this.$message({
message: '输入周转箱编码不正确!',
type: 'warning'
});
return;
}
}
},
error: function (json) {
_this.$message({
message: "扫描失败!",
type: "error",
duration: "10000",
});
return;
},
});
// 重新扫描箱号后,待绑定列表清空
_this.bindingData = [];
_this.changeselect(_this.value);
// _this.$refs.uniqueCode.focus();
},
// 选择尺寸后
changeSize() {
this.$refs.uniqueCode.focus();
},
// 扫描唯一码
scanUniqueCode(data) {
if (this.form.code == '') {
this.$message({
message: '请先选择单据!',
type: 'warning'
});
return;
}
if (this.dataIndex.length == 0) {
this.$message({
message: '该周转箱已放满!',
type: 'warning'
});
this.form.uniqueCode = '';
return;
}
if (this.form.boxCode == '' || this.form.size == '') {
this.$message({
message: '请先输入周转箱编码并选择料盘尺寸!',
type: 'warning'
});
this.form.uniqueCode = '';
return;
}
var isExit = this.tableData.findIndex(function (value, index, arr) {
return value.name == data;
})
if (isExit == -1) {
this.$message({
message: '唯一码' + data + '不正确!',
type: 'warning'
});
this.form.uniqueCode = '';
return;
}
// 1.明细减少
this.tableData.forEach(function (item, index, arr) {
if (item.name == data) {
arr.splice(index, 1);
}
});
// 2.已扫描增加
this.bindingData.push({
receiptCode: this.form.code,
boxCode: this.form.boxCode,
index: this.dataIndex.shift(),
uniqueCode: data,
size: this.form.size
})
this.form.uniqueCode = '';
this.$nextTick(() => {
this.$refs.tableData.bodyWrapper.scrollTop = this.$refs.tableData.bodyWrapper.scrollHeight
})
},
// 删除已绑定行
deleteRow(index, rows) {
if (this.form.code == rows[index].receiptCode) {
this.tableData.push({ name: rows[index].uniqueCode });
}
this.dataIndex.unshift(rows[index].index);
rows.splice(index, 1);
}
const app = createApp({
data() {
return {
ContainerCode: '',
loading1:false,
data: reactive([])
}
},
methods: {
handleClick() {
var _this = this;
if (_this.ContainerCode == ""){
_this.$message.error("请扫描箱号!");
return;
}
});
_this.loading1 = !_this.loading1
let postData = new URLSearchParams();
postData.append('containerCode', _this.ContainerCode);
axios.post("/receipt/ReceiptIn/TaskIn", postData)
.then(function (json) {
_this.loading1 = !_this.loading1;
if (json.data.Code == 200){
_this.ContainerCode = '';
_this.$message.success("入库任务创建成功!");
}
else{
_this.$message.error(json.data.Msg);
}
})
.catch(function (error) {
_this.$message.error(error);
});
}
}
});
app.use(ArcoVue)
.use(ArcoVueIcon)
.mount('#receiptin');
</script>
@@ -1,3 +1,5 @@
using System;
using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
@@ -24,4 +26,96 @@ public class ShipOutController : BaseController
}
#endregion
[HttpPost]
public IActionResult CallBox()
{
// 查找库位状态为空容器的库位
var location = _unitWork.FindSingle<Location>(x => x.Status == LocationStatus.空容器);
if (location != null)
{
location.Status = LocationStatus.任务锁;
location.UpdateTime = DateTime.Now;
location.UpdateBy = Wtm.LoginUserInfo?.ITCode ?? "WMS";
_unitWork.Update(location);
// 查找container,并更新状态
var container = _unitWork.FindSingle<Container>(x => x.Code == location.ContainerCode);
container.IsLock = ContainerLockEnum.任务锁;
container.UpdateTime = DateTime.Now;
container.UpdateBy = Wtm.LoginUserInfo?.ITCode ?? "WMS";
_unitWork.Update(container);
//创建出库任务
var task = new TaskHeader
{
ZoneCode = ZoneCodeEnum.立库,
TaskNo = _unitWork.GetSerialNumber("Out"),
TaskType = TaskTypeEnum.立库出库,
ContainerCode = location.ContainerCode,
FromLocation = location.Code,
ToLocation = "",
Status = TaskStatusEnum.待下发,
CreateBy = Wtm.LoginUserInfo?.ITCode??"WMS",
CreateTime = DateTime.Now
};
_unitWork.Add(task);
// 下发任务到wcs
var postData = new
{
TaskNo = task.TaskNo,
PalletNo = task.ContainerCode,
FromLocation = task.FromLocation,
ToLocation = task.ToLocation
};
var res1 = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData);
var res = res1.Result.Data;
if (res.Success)
{
task.Status = TaskStatusEnum.已下发;
}
else
{
task.ErrorMsg = res.Msg;
}
task.UpdateTime = DateTime.Now;
task.UpdateBy = "WMS";
_unitWork.Update(task);
return JsonMore(null);
}
else
{
return JsonMore(null, 500, "库内无可用容器!");
}
}
public IActionResult AgvTask(string type)
{
var task_id = "123";
switch (type)
{
case "In":
task_id = "1";
break;
case "Out":
task_id = "2";
break;
case "Charge":
task_id = "3";
break;
default:
return JsonMore(null,500,"参数错误!");
}
var res = Wtm.CallAPI<dynamic>("ACS", "task_mould_do", HttpMethodEnum.POST, new
{
task_id = task_id
});
if (res.Result.Data.ack != 0)
{
return JsonMore(null,500,res.Result.Data.msg);
}
return JsonMore(null);
}
}
@@ -1,299 +1,91 @@
<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="form.type"
placeholder="请选择类型"
style="width: 100%"
@@change="select"
>
<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="200" 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" readonly></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>
<div id="shipout">
<a-space direction="vertical" fill>
@* <a-input :style="{width:'320px'}" placeholder="扫描箱号" v-model="ContainerCode" allow-clear/> *@
<a-button @@click="handleClick"
:loading="loading1"
type="primary">
呼叫出库
</a-button>
<el-form-item style="float:right">
<el-button type="primary" @@click="onSubmit">拣货</el-button>
<el-button v-show="showBack" type="success" @@click="back">回库</el-button>
</el-form-item>
</el-row>
</el-form>
</el-card>
</el-row>
<a-button @@click='handleAGVTask("In")'
:loading="loading2"
type="primary"
status="warning">
到入库点
</a-button>
<a-button @@click='handleAGVTask("Charge")'
:loading="loading2"
type="primary"
status="success">
充电任务
</a-button>
<a-button @@click='handleAGVTask("Out")'
:loading="loading2"
type="outline">
到出库点
</a-button>
</a-space>
</div>
<script>
var app = new Vue({
el: "#outapp",
data() {
return {
form: {
type:"",
code: "",
uniqueCode: "",
materialCode: "",
materialSpec: "",
batch: "",
qty: ""
},
type: "",
taskType: [
{ label: "散料站台", value: "slbox" },
{ label: "料塔周转箱", value: "lt" },
{ label: "唯一码", value: "uniqueCode" },
],
invTable:[],
showTable: false,
showBack: 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;
},
select(data) {
this.form.code = "";
this.form.type = data;
this.invTable = [];
if (this.invTable.length == 0
&& this.form.type == "slbox"
&& this.form.code.startsWith("C")) {
this.showBack = true;
}
},
// 扫描料塔站台号
scanCode(data) {
var _this = this;
if (_this.form.type == "") {
_this.$message({
message: "请先选择操作类型!",
type: "warning",
duration: "10000",
});
_this.form.code = "";
return;
}
let url = "";
if (_this.form.type == "uniqueCode") {
url = "/shipment/ShipOut/ScanUniqueCode"
}
else{
url = "/shipment/ShipOut/ScanBox"
}
$.ajax({
type: "post",
dataType: "json",
data: { code: _this.form.code, type: _this.form.type },
url: url,
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "扫描失败!" + json.Msg,
type: "warning",
duration: "10000",
});
_this.form.code = "";
} else {
if (_this.form.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;
if (_this.invTable.length == 0
&& _this.form.type == "slbox"
&& _this.form.code.startsWith("C")) {
_this.showBack = true;
}
}
}
},
error: function (json) {
_this.$message({
message: "扫描失败!",
type: "error",
duration: "10000",
});
},
});
},
// 拣货
onSubmit() {
var _this = this;
if (_this.form.uniqueCode == "") {
_this.$message({
message: "未选择出库明细!",
type: "warning",
duration: "10000",
});
return;
}
// 提交已绑定数据
$.ajax({
type: "post",
dataType: "json",
data: { uniqueCode: _this.form.uniqueCode, qty: _this.form.qty, station: _this.form.code },
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);
}
});
if (_this.invTable.length == 0
&& _this.form.type == "slbox"
&& _this.form.code.startsWith("C")) {
_this.showBack = true;
}
if (_this.form.code == "uniqueCode") {
_this.form.code = "";
}
// 清空下面表单 不清空code
_this.form.uniqueCode = "";
_this.form.materialCode = "";
_this.form.materialSpec = "";
_this.form.batch = "";
_this.form.qty = "";
// _this.$refs['form'].resetFields();
} else {
_this.$message({
message: "提交失败!"+json.Msg,
type: "warning",
duration: "10000",
});
}
},
error: function (json) {
_this.$message({
message: "提交失败!",
type: "error",
duration: "10000",
});
},
});
},
// 回库
back() {
var _this = this;
// 创建回库任务
if (_this.form.code == "") {
_this.$message({
message: "箱号为空,不能创建回库任务!",
type: "error",
duration: "1000",
});
return;
}
if (_this.invTable.length > 0) {
_this.$message({
message: "存在未拣货库存,不能创建回库任务!",
type: "error",
duration: "1000",
});
return;
}
this.$confirm('确定执行回库动作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
$.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",
});
},
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
const { createApp, reactive, ref } = Vue
const app = createApp({
data() {
return {
ContainerCode: '',
loading1:false,
loading2:false,
data: reactive([])
}
},
methods: {
handleClick() {
var _this = this;
_this.loading1 = !_this.loading1
axios.post("/shipment/Shipout/CallBox", {})
.then(function (json) {
_this.loading1 = !_this.loading1;
if (json.data.Code == 200){
_this.$message.success("呼叫料盒任务创建成功!");
}
},
});
else{
_this.$message.error(json.data.Msg);
}
})
.catch(function (error) {
_this.$message.error(error);
});
},
handleAGVTask(val) {
var _this = this;
_this.loading2 = !_this.loading2
let postData = new URLSearchParams();
postData.append('type', val);
axios.post("/shipment/Shipout/AgvTask", postData)
.then(function (json) {
_this.loading2 = !_this.loading2;
if (json.data.Code == 200){
_this.$message.success("任务创建成功!");
}
else{
_this.$message.error(json.data.Msg);
}
})
.catch(function (error) {
_this.$message.error(error);
});
}
}
});
app.use(ArcoVue)
.use(ArcoVueIcon)
.mount('#shipout');
</script>
@@ -144,7 +144,7 @@ namespace HHWMS.Web.Controllers
}
else
{
return FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID);
return FFResult().CloseDialog().RefreshGrid(index:1);
}
}
}
@@ -172,7 +172,7 @@ namespace HHWMS.Web.Controllers
}
else
{
return FFResult().CloseDialog().RefreshGrid();
return FFResult().CloseDialog().RefreshGrid(index:1);
}
}
@@ -0,0 +1,76 @@
using System;
using System.Threading.Tasks;
using HHWMS.Web.Models;
using Quartz;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Support.Quartz;
namespace HHWMS.Web
{
//[QuartzRepeat(10,10, true, 30)]
[PersistJobDataAfterExecution]
[DisallowConcurrentExecution]
public class SendWcsJob : WtmJob
{
public override Task Execute(IJobExecutionContext context)
{
try
{
var _unitWork = new UnitWork(Wtm);
var task = _unitWork.FindSingle<TaskHeader>(x => x.Status == TaskStatusEnum.待下发);
if (task != null)
{
// 下发任务到wcs
var postData = new
{
TaskNo = task.TaskNo,
PalletNo = task.ContainerCode,
FromLocation = task.FromLocation,
ToLocation = task.ToLocation
};
var res1 = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData);
var res = res1.Result.Data;
if (res.Success)
{
task.Status = TaskStatusEnum.已下发;
}
else
{
task.ErrorMsg = res.Msg;
}
task.UpdateTime = DateTime.Now;
task.UpdateBy = "WMS";
_unitWork.Update(task);
}
Wtm.DoLog("下发WCS任务", ActionLogTypesEnum.Job, "SendWcsJob");
#region 更新时间
var job = _unitWork.FindSingle<SysJob>(x =>
x.JobName == context.JobDetail.Key.Name
);
if (job != null)
{
job.LastFireTime = TimeZoneInfo.ConvertTimeFromUtc(
context.FireTimeUtc.DateTime,
TimeZoneInfo.Local
);
// 只执行一次 没有下次执行时间
if (context.NextFireTimeUtc != null)
{
job.NextFireTime = TimeZoneInfo.ConvertTimeFromUtc(
context.NextFireTimeUtc.Value.DateTime,
TimeZoneInfo.Local
);
}
_unitWork.Update<SysJob>(job);
}
#endregion
}
catch(Exception ex) {
Wtm.DoLog("下发WCS任务", ActionLogTypesEnum.Job, "SendWcsJob", request:"error", result:ex.Message);
}
return Task.CompletedTask;
}
}
}
@@ -57,15 +57,15 @@ namespace HHWMS.Web
{
string rv = UIService.MakeScriptButton(ButtonTypesEnum.Link,a.TaskNo,$"details('{a.ID}')");
return rv;
}).SetWidth(220),
}).SetWidth(180),
this.MakeGridHeader(x => x.TaskType,150),
this.MakeGridHeader(x => x.ContainerCode, 150),
this.MakeGridHeader(x => x.FromLocation,150),
this.MakeGridHeader(x => x.ToLocation, 150),
this.MakeGridHeader(x => x.Station,150),
this.MakeGridHeader(x => x.ContainerCode, 150),
this.MakeGridHeader(x => x.Status, 150),
this.MakeGridHeader(x => x.Station,150).SetHide(),
this.MakeGridHeader(x => x.RoadWay, 150).SetHide(),
this.MakeGridHeader(x => x.Priority, 150).SetHide(),
this.MakeGridHeader(x => x.Status, 150),
this.MakeGridHeader(x => x.CreateTime, 150).SetHide(),
this.MakeGridHeader(x => x.ErrorMsg, 150).SetHide(),
this.MakeGridHeaderAction(width: 200)
@@ -14,7 +14,7 @@
</wt:row>
</wt:searchpanel>
<wt:grid vm="@Model" id="TaskHeader" url="/taskManage/TaskHeader/Search" limit="7" />
<wt:grid vm="@Model.TaskDetails" id="TaskDetail" url="/taskManage/TaskDetail/Search2" height="400" />
@* <wt:grid vm="@Model.TaskDetails" id="TaskDetail" url="/taskManage/TaskDetail/Search2" height="400" /> *@
<script>
var headerId = 0;