现场初始调试完成,

入库(有货/空容器)
出库,库存出库
AGV任务对接
This commit is contained in:
zhougf committed 2024-04-24 10:51:58 +08:00
1 parent b4632cfc33
commit 70e6866e20
9 files changed
+215 -72

No files matched your search

+16 -12
View File
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using AutoMapper; using AutoMapper;
using HHWMS.Web.Controllers;
using HHWMS.Web.Models; using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -36,14 +37,14 @@ namespace HHWMS.Web
public IActionResult ReturnStatus(WcsRequest request) public IActionResult ReturnStatus(WcsRequest request)
{ {
// 返回状态 只接收100 // 返回状态 只接收100
if(request.State != 100) if (request.State != 100)
{ {
return ApiResultError(msg:"State 不为100, 请检查后重新请求!"); return ApiResultError(msg: "State 不为100, 请检查后重新请求!");
} }
// 判断任务是否合理 // 判断任务是否合理
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) if (task == null)
{ {
return ApiResultError(msg: $"任务不存在, 任务号 {request.TaskNo} , 请检查后重新请求!"); return ApiResultError(msg: $"任务不存在, 任务号 {request.TaskNo} , 请检查后重新请求!");
} }
@@ -67,17 +68,18 @@ namespace HHWMS.Web
IsLock = ContainerLockEnum.未锁, IsLock = ContainerLockEnum.未锁,
LocationCode = task.ToLocation LocationCode = task.ToLocation
}); });
var inventoryList = _unitWork.Find<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode))
.ToList();
// 3.更新库位 // 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, UpdateTime = DateTime.Now,
UpdateBy = "WMS", UpdateBy = "WMS",
Status = LocationStatus.空容器, Status = inventoryList.Count > 0 ? LocationStatus.有货 : LocationStatus.空容器,
ContainerCode = task.ContainerCode ContainerCode = task.ContainerCode
}); });
// 4.插入库存交易 // 4.插入库存交易
// 1.将任务容器的库存查出来 // 1.将任务容器的库存查出来
var inventoryList = _unitWork.Find<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode)).ToList();
if (inventoryList.Count > 0) if (inventoryList.Count > 0)
{ {
// 2.根据库存生成库存交易出库信息 // 2.根据库存生成库存交易出库信息
@@ -120,7 +122,8 @@ namespace HHWMS.Web
ContainerCode = "" ContainerCode = ""
}); });
// 1.将任务容器的库存查出来 // 1.将任务容器的库存查出来
var inventoryList2 = _unitWork.Find<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode)).ToList(); var inventoryList2 = _unitWork.Find<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode))
.ToList();
if (inventoryList2.Count > 0) if (inventoryList2.Count > 0)
{ {
// 2.根据库存生成库存交易出库信息 // 2.根据库存生成库存交易出库信息
@@ -144,8 +147,9 @@ namespace HHWMS.Web
// 3.批量插入库存交易 // 3.批量插入库存交易
_unitWork.BatchAdd(inventoryTransactions2); _unitWork.BatchAdd(inventoryTransactions2);
_unitWork.BatchDelete<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode)); _unitWork.BatchDelete<Inventory>(inventoryList2);
} }
// 下发AGV到出库口的任务 // 下发AGV到出库口的任务
// 如果对接 执行下方任务,否则不执行 // 如果对接 执行下方任务,否则不执行
var interfaceAgv = _unitWork.FindSingle<SysCount>(x => x.Prefix == "interfaceAGV")?.Value; var interfaceAgv = _unitWork.FindSingle<SysCount>(x => x.Prefix == "interfaceAGV")?.Value;
@@ -154,10 +158,10 @@ namespace HHWMS.Web
var postAgv = new var postAgv = new
{ {
task_id = "123456" task_id = "6970907a6b82e7fb"
}; };
var res = Wtm.CallAPI<dynamic>("ACS", "task_mould_do", HttpMethodEnum.POST, postAgv); var res = Wtm.CallAPI<ShipOutController.agvResult>("ACS", "task_mould_do", HttpMethodEnum.POST, postAgv);
// if (res.Result.Data.ack == 0) // if (res.Result.Data.ack == 0)
// { // {
// //
@@ -166,7 +170,7 @@ namespace HHWMS.Web
break; break;
default: default:
return ApiResultError(msg:$"任务类型不正确!任务号{request.TaskNo}"); return ApiResultError(msg: $"任务类型不正确!任务号{request.TaskNo}");
} }
task.Status = TaskStatusEnum.完成; task.Status = TaskStatusEnum.完成;
@@ -203,7 +207,7 @@ namespace HHWMS.Web
} }
var location = _unitWork.FindSingle<Location>(x => x.Status == LocationStatus.空仓位); var location = _unitWork.FindSingle<Location>(x => x.Status == LocationStatus.空仓位);
if(location == null) if (location == null)
{ {
return ApiResultError(msg: "没有空仓位"); return ApiResultError(msg: "没有空仓位");
} }
@@ -228,7 +232,7 @@ namespace HHWMS.Web
public IActionResult EmptyOut(WcsRequest request) public IActionResult EmptyOut(WcsRequest request)
{ {
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) if (task == null)
{ {
return ApiResultError(msg: $"任务不存在, 任务号 {request.TaskNo} , 请检查后重新请求!"); return ApiResultError(msg: $"任务不存在, 任务号 {request.TaskNo} , 请检查后重新请求!");
} }
@@ -225,5 +225,74 @@ namespace HHWMS.Web.Controllers
} }
#endregion #endregion
public IActionResult Out(int id)
{
var inv = _unitwork.FindById<Inventory>(id);
if (inv == null)
{
return FFResult().RefreshGrid().Alert("选定库存不存在!请检查后再执行出库任务!");
}
if (_unitwork.IsExit<TaskHeader>(x => x.ContainerCode.Equals(inv.ContainerCode)))
{
return FFResult().RefreshGrid().Alert("选定库存已存在任务!请检查后再执行出库任务!");
}
var location = _unitwork.FindSingle<Location>(x => x.Code == inv.LocationCode);
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 res = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData)
.Result.Data;
if (res.Success)
{
task.Status = TaskStatusEnum.已下发;
}
else
{
task.ErrorMsg = res.Msg;
}
task.UpdateTime = DateTime.Now;
task.UpdateBy = "WMS";
_unitwork.Update(task);
}
return FFResult().RefreshGrid().Message("任务创建成功!");
}
} }
} }
@@ -24,7 +24,7 @@ namespace HHWMS.Web
return new List<GridAction> return new List<GridAction>
{ {
this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"inventory", dialogWidth: 800), this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"inventory", dialogWidth: 800),
this.MakeAction("Inventory","ReturnToMes",Localizer["Inventory.ReturnToMes"],Localizer["Inventory.ReturnToMes"],GridActionParameterTypesEnum.SingleId,"inventory"), this.MakeAction("Inventory","Out",Localizer["Inventory.Out"],Localizer["Inventory.Out"],GridActionParameterTypesEnum.SingleId,"inventory"),
this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "inventory", dialogWidth: 800), this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "inventory", dialogWidth: 800),
this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "inventory", dialogWidth: 800), this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "inventory", dialogWidth: 800),
this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "inventory", dialogWidth: 800), this.MakeStandardAction("Inventory", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "inventory", dialogWidth: 800),
@@ -55,15 +55,15 @@ namespace HHWMS.Web
var data = ZoneCodes.FirstOrDefault(x => x.Value.ToString() == a.ZoneCode); var data = ZoneCodes.FirstOrDefault(x => x.Value.ToString() == a.ZoneCode);
return data?.Text ?? a.ZoneCode; return data?.Text ?? a.ZoneCode;
}), }),
this.MakeGridHeader(x => x.ContainerCode).SetHide(), this.MakeGridHeader(x => x.ContainerCode),
this.MakeGridHeader(x => x.LocationCode), this.MakeGridHeader(x => x.LocationCode),
this.MakeGridHeader(x => x.MaterialCode), this.MakeGridHeader(x => x.MaterialCode),
this.MakeGridHeader(x => x.MaterialType), // this.MakeGridHeader(x => x.MaterialType),
this.MakeGridHeader(x => x.MaterialName), this.MakeGridHeader(x => x.MaterialName),
this.MakeGridHeader(x => x.MaterialSpec), // this.MakeGridHeader(x => x.MaterialSpec),
this.MakeGridHeader(x => x.MaterialUnit), // this.MakeGridHeader(x => x.MaterialUnit),
this.MakeGridHeader(x => x.Batch), // this.MakeGridHeader(x => x.Batch),
this.MakeGridHeader(x => x.Lot), // this.MakeGridHeader(x => x.Lot),
//this.MakeGridHeader(x => x.ManufactureDate), //this.MakeGridHeader(x => x.ManufactureDate),
//this.MakeGridHeader(x => x.ExpirationDate), //this.MakeGridHeader(x => x.ExpirationDate),
//this.MakeGridHeader(x => x.CompanyCode), //this.MakeGridHeader(x => x.CompanyCode),
@@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
using HHWMS.Web.Models; using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using WalkingTec.Mvvm.Core; using WalkingTec.Mvvm.Core;
@@ -28,7 +29,7 @@ namespace HHWMS.Web.Controllers
#endregion Index #endregion Index
[HttpPost] [HttpPost]
public ActionResult TaskIn(string containerCode) public ActionResult TaskIn(string containerCode, bool inv)
{ {
// 判断containerCode是否为空 // 判断containerCode是否为空
if (string.IsNullOrEmpty(containerCode)) if (string.IsNullOrEmpty(containerCode))
@@ -41,14 +42,24 @@ namespace HHWMS.Web.Controllers
{ {
return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!"); return JsonMore(null, 500, $"库内没有编码为 {containerCode} 的容器!");
} }
// 如果 container的库位不为空,或者islock为true,则返回错误信息
if (!string.IsNullOrEmpty(container.LocationCode) || container.IsLock == ContainerLockEnum.任务锁)
{
return JsonMore(null, 500, $"容器 {containerCode} 已被占用!");
}
container.IsLock = ContainerLockEnum.任务锁; container.IsLock = ContainerLockEnum.任务锁;
container.UpdateTime = DateTime.Now; container.UpdateTime = DateTime.Now;
container.UpdateBy = Wtm.LoginUserInfo?.ITCode??"WMS"; container.UpdateBy = Wtm.LoginUserInfo?.ITCode??"WMS";
_unitWork.Update(container); // _unitWork.Update(container);
//查找仓位
var location = _unitWork.Find<Location>(u => u.Status == LocationStatus.空仓位)
.OrderBy(x => x.Layer)
.ThenBy(x => x.Line)
.FirstOrDefault();
//查询location表的一个空库位 更新仓位状态为锁定
var location = _unitWork.FindSingle<Location>(u => u.Status == LocationStatus.空仓位);
// 判断location是否为空 // 判断location是否为空
if (location == null) if (location == null)
{ {
@@ -59,6 +70,21 @@ namespace HHWMS.Web.Controllers
location.UpdateBy = Wtm.LoginUserInfo?.ITCode??"WMS"; location.UpdateBy = Wtm.LoginUserInfo?.ITCode??"WMS";
_unitWork.Update(location); _unitWork.Update(location);
if (inv) //有货
{
_unitWork.Add<Inventory>(new Inventory()
{
ZoneCode = ZoneCodeEnum.立库,
ContainerCode = containerCode,
LocationCode = location.Code,
MaterialCode = "123456",
MaterialName = "矿泉水",
Qty = 1,
TaskStatus = InventoryTaskStatus.任务中,
CreateTime = DateTime.Now
});
}
_unitWork.Update(container);
//创建容器编码为containercode的任务 //创建容器编码为containercode的任务
var task = new TaskHeader var task = new TaskHeader
{ {
@@ -82,8 +108,9 @@ namespace HHWMS.Web.Controllers
FromLocation = task.FromLocation, FromLocation = task.FromLocation,
ToLocation = task.ToLocation ToLocation = task.ToLocation
}; };
var res1 = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData); var res = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData)
var res = res1.Result.Data; .Result.Data;
if (res.Success) if (res.Success)
{ {
task.Status = TaskStatusEnum.已下发; task.Status = TaskStatusEnum.已下发;
@@ -1,11 +1,27 @@
<div id="receiptin"> <div id="receiptin">
<a-space direction="vertical" fill> <a-space direction="vertical" fill>
<a-input :style="{width:'320px'}" placeholder="扫描箱号" v-model="ContainerCode" allow-clear/> <a-space>
<a-button @@click="handleClick" <template #split>
:loading="loading1" <a-divider direction="vertical"/>
type="primary"> </template>
入库 <a-input :style="{width:'150px'}" placeholder="扫描箱号" v-model="ContainerCode" allow-clear/>
</a-button> <a-switch v-model="inv">
<template #checked>
载货
</template>
<template #unchecked>
空箱
</template>
</a-switch>
</a-space>
<a-space>
<a-button @@click="handleClick"
:loading="loading1"
type="primary" size="large">
入库
</a-button>
</a-space>
</a-space> </a-space>
</div> </div>
<script> <script>
@@ -16,10 +32,12 @@
return { return {
ContainerCode: '', ContainerCode: '',
loading1:false, loading1:false,
inv:false,
data: reactive([]) data: reactive([])
} }
}, },
methods: { methods: {
handleClick() { handleClick() {
var _this = this; var _this = this;
if (_this.ContainerCode == ""){ if (_this.ContainerCode == ""){
@@ -31,6 +49,7 @@
let postData = new URLSearchParams(); let postData = new URLSearchParams();
postData.append('containerCode', _this.ContainerCode); postData.append('containerCode', _this.ContainerCode);
postData.append('inv', _this.inv);
axios.post("/receipt/ReceiptIn/TaskIn", postData) axios.post("/receipt/ReceiptIn/TaskIn", postData)
.then(function (json) { .then(function (json) {
@@ -68,8 +68,8 @@ public class ShipOutController : BaseController
FromLocation = task.FromLocation, FromLocation = task.FromLocation,
ToLocation = task.ToLocation ToLocation = task.ToLocation
}; };
var res1 = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData); var res = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData)
var res = res1.Result.Data; .Result.Data;
if (res.Success) if (res.Success)
{ {
task.Status = TaskStatusEnum.已下发; task.Status = TaskStatusEnum.已下发;
@@ -92,30 +92,38 @@ public class ShipOutController : BaseController
public IActionResult AgvTask(string type) public IActionResult AgvTask(string type)
{ {
var task_id = "123"; try
switch (type)
{ {
case "In": var task_id = type switch
task_id = "1"; {
break; "In" => "ee66a5dc570cecd0",
case "Out": "Out" => "6970907a6b82e7fb",
task_id = "2"; "Charge" => "a7a93155ff7f23a7",
break; _ => throw new Exception("参数错误!")
case "Charge": };
task_id = "3";
break; var res = Wtm.CallAPI<agvResult>("ACS", "task_mould_do", HttpMethodEnum.POST, new
default: {
return JsonMore(null,500,"参数错误!"); task_id = task_id
});
if (res.Result.Data.ack != 0)
{
return JsonMore(null, 500, res.Result.Data.msg);
}
return JsonMore(null);
} }
var res = Wtm.CallAPI<dynamic>("ACS", "task_mould_do", HttpMethodEnum.POST, new catch (Exception ex)
{ {
task_id = task_id return JsonMore(null, 500, ex.Message);
});
if (res.Result.Data.ack != 0)
{
return JsonMore(null,500,res.Result.Data.msg);
} }
return JsonMore(null); }
public class agvResult
{
public int ack { get; set; }
public string msg { get; set; }
public dynamic data { get; set; }
} }
} }
@@ -1,31 +1,41 @@
<div id="shipout"> <div id="shipout">
<a-space direction="vertical" fill> <a-space direction="vertical" fill :size="large">
@* <a-input :style="{width:'320px'}" placeholder="扫描箱号" v-model="ContainerCode" allow-clear/> *@ @* <a-input :style="{width:'320px'}" placeholder="扫描箱号" v-model="ContainerCode" allow-clear/> *@
<a-button @@click="handleClick" <a-button @@click="handleClick"
:loading="loading1" :loading="loading1"
type="primary"> type="primary"
size="large">
呼叫出库 呼叫出库
</a-button> </a-button>
<a-button @@click='handleAGVTask("In")' <a-divider />
:loading="loading2" <a-space>
type="primary" <template #split>
status="warning"> <a-divider direction="vertical" />
到入库点 </template>
</a-button> <a-button @@click='handleAGVTask("In")'
:loading="loading2"
type="primary"
status="warning"
size="large">
到入库点
</a-button>
<a-button @@click='handleAGVTask("Charge")' <a-button @@click='handleAGVTask("Charge")'
:loading="loading2" :loading="loading2"
type="primary" type="primary"
status="success"> status="success"
充电任务 size="large">
</a-button> 充电任务
</a-button>
<a-button @@click='handleAGVTask("Out")' <a-button @@click='handleAGVTask("Out")'
:loading="loading2" :loading="loading2"
type="outline"> type="outline"
到出库点 size="large">
</a-button> 到出库点
</a-button>
</a-space>
</a-space> </a-space>
</div> </div>
<script> <script>
+3
View File
@@ -924,4 +924,7 @@
<data name="_Admin.ZipCode" xml:space="preserve"> <data name="_Admin.ZipCode" xml:space="preserve">
<value>Zip</value> <value>Zip</value>
</data> </data>
<data name="Inventory.Out" xml:space="preserve">
<value />
</data>
</root> </root>
+3
View File
@@ -1407,4 +1407,7 @@
<data name="MenuKey.InterfaceLog" xml:space="preserve"> <data name="MenuKey.InterfaceLog" xml:space="preserve">
<value>接口日志</value> <value>接口日志</value>
</data> </data>
<data name="Inventory.Out" xml:space="preserve">
<value>出库</value>
</data>
</root> </root>