现场初始调试完成,

入库(有货/空容器)
出库,库存出库
AGV任务对接
This commit is contained in:
Mac mini git server 2024-04-24 10:51:58 +08:00
parent b4632cfc33
commit 70e6866e20
9 changed files with 243 additions and 100 deletions

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using HHWMS.Web.Controllers;
using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
@ -36,14 +37,14 @@ namespace HHWMS.Web
public IActionResult ReturnStatus(WcsRequest request)
{
// 返回状态 只接收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));
if(task == null)
if (task == null)
{
return ApiResultError(msg: $"任务不存在, 任务号 {request.TaskNo} , 请检查后重新请求!");
}
@ -67,17 +68,18 @@ namespace HHWMS.Web
IsLock = ContainerLockEnum.未锁,
LocationCode = task.ToLocation
});
var inventoryList = _unitWork.Find<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode))
.ToList();
// 3.更新库位
_unitWork.BatchUpdate<Location>(x => x.Code.Equals(task.ToLocation), x => new Location
{
UpdateTime = DateTime.Now,
UpdateBy = "WMS",
Status = LocationStatus.空容器,
Status = inventoryList.Count > 0 ? LocationStatus.有货 : LocationStatus.空容器,
ContainerCode = task.ContainerCode
});
// 4.插入库存交易
// 1.将任务容器的库存查出来
var inventoryList = _unitWork.Find<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode)).ToList();
if (inventoryList.Count > 0)
{
// 2.根据库存生成库存交易出库信息
@ -120,7 +122,8 @@ namespace HHWMS.Web
ContainerCode = ""
});
// 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)
{
// 2.根据库存生成库存交易出库信息
@ -144,8 +147,9 @@ namespace HHWMS.Web
// 3.批量插入库存交易
_unitWork.BatchAdd(inventoryTransactions2);
_unitWork.BatchDelete<Inventory>(x => x.ContainerCode.Equals(task.ContainerCode));
_unitWork.BatchDelete<Inventory>(inventoryList2);
}
// 下发AGV到出库口的任务
// 如果对接 执行下方任务,否则不执行
var interfaceAgv = _unitWork.FindSingle<SysCount>(x => x.Prefix == "interfaceAGV")?.Value;
@ -154,10 +158,10 @@ namespace HHWMS.Web
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)
// {
//
@ -166,7 +170,7 @@ namespace HHWMS.Web
break;
default:
return ApiResultError(msg:$"任务类型不正确!任务号{request.TaskNo}");
return ApiResultError(msg: $"任务类型不正确!任务号{request.TaskNo}");
}
task.Status = TaskStatusEnum.完成;
@ -203,7 +207,7 @@ namespace HHWMS.Web
}
var location = _unitWork.FindSingle<Location>(x => x.Status == LocationStatus.空仓位);
if(location == null)
if (location == null)
{
return ApiResultError(msg: "没有空仓位");
}
@ -228,7 +232,7 @@ namespace HHWMS.Web
public IActionResult EmptyOut(WcsRequest request)
{
var task = _unitWork.FindSingle<TaskHeader>(x => x.TaskNo.Equals(request.TaskNo));
if(task == null)
if (task == null)
{
return ApiResultError(msg: $"任务不存在, 任务号 {request.TaskNo} , 请检查后重新请求!");
}

View File

@ -225,5 +225,74 @@ namespace HHWMS.Web.Controllers
}
#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("任务创建成功!");
}
}
}

View File

@ -24,7 +24,7 @@ namespace HHWMS.Web
return new List<GridAction>
{
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.Delete, Localizer["Sys.Delete"], "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);
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.MaterialCode),
this.MakeGridHeader(x => x.MaterialType),
// this.MakeGridHeader(x => x.MaterialType),
this.MakeGridHeader(x => x.MaterialName),
this.MakeGridHeader(x => x.MaterialSpec),
this.MakeGridHeader(x => x.MaterialUnit),
this.MakeGridHeader(x => x.Batch),
this.MakeGridHeader(x => x.Lot),
// this.MakeGridHeader(x => x.MaterialSpec),
// this.MakeGridHeader(x => x.MaterialUnit),
// this.MakeGridHeader(x => x.Batch),
// this.MakeGridHeader(x => x.Lot),
//this.MakeGridHeader(x => x.ManufactureDate),
//this.MakeGridHeader(x => x.ExpirationDate),
//this.MakeGridHeader(x => x.CompanyCode),

View File

@ -1,4 +1,5 @@
using System;
using System.Linq;
using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc;
using WalkingTec.Mvvm.Core;
@ -28,7 +29,7 @@ namespace HHWMS.Web.Controllers
#endregion Index
[HttpPost]
public ActionResult TaskIn(string containerCode)
public ActionResult TaskIn(string containerCode, bool inv)
{
// 判断containerCode是否为空
if (string.IsNullOrEmpty(containerCode))
@ -41,14 +42,24 @@ namespace HHWMS.Web.Controllers
{
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.UpdateTime = DateTime.Now;
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是否为空
if (location == null)
{
@ -59,6 +70,21 @@ namespace HHWMS.Web.Controllers
location.UpdateBy = Wtm.LoginUserInfo?.ITCode??"WMS";
_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的任务
var task = new TaskHeader
{
@ -82,8 +108,9 @@ namespace HHWMS.Web.Controllers
FromLocation = task.FromLocation,
ToLocation = task.ToLocation
};
var res1 = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData);
var res = res1.Result.Data;
var res = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData)
.Result.Data;
if (res.Success)
{
task.Status = TaskStatusEnum.已下发;

View File

@ -1,11 +1,27 @@
<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>
<template #split>
<a-divider direction="vertical"/>
</template>
<a-input :style="{width:'150px'}" placeholder="扫描箱号" v-model="ContainerCode" allow-clear/>
<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>
</div>
<script>
@ -16,10 +32,12 @@
return {
ContainerCode: '',
loading1:false,
inv:false,
data: reactive([])
}
},
methods: {
handleClick() {
var _this = this;
if (_this.ContainerCode == ""){
@ -31,6 +49,7 @@
let postData = new URLSearchParams();
postData.append('containerCode', _this.ContainerCode);
postData.append('inv', _this.inv);
axios.post("/receipt/ReceiptIn/TaskIn", postData)
.then(function (json) {

View File

@ -68,8 +68,8 @@ public class ShipOutController : BaseController
FromLocation = task.FromLocation,
ToLocation = task.ToLocation
};
var res1 = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData);
var res = res1.Result.Data;
var res = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, postData)
.Result.Data;
if (res.Success)
{
task.Status = TaskStatusEnum.已下发;
@ -92,30 +92,38 @@ public class ShipOutController : BaseController
public IActionResult AgvTask(string type)
{
var task_id = "123";
switch (type)
try
{
case "In":
task_id = "1";
break;
case "Out":
task_id = "2";
break;
case "Charge":
task_id = "3";
break;
default:
return JsonMore(null,500,"参数错误!");
var task_id = type switch
{
"In" => "ee66a5dc570cecd0",
"Out" => "6970907a6b82e7fb",
"Charge" => "a7a93155ff7f23a7",
_ => throw new Exception("参数错误!")
};
var res = Wtm.CallAPI<agvResult>("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);
}
var res = Wtm.CallAPI<dynamic>("ACS", "task_mould_do", HttpMethodEnum.POST, new
catch (Exception ex)
{
task_id = task_id
});
if (res.Result.Data.ack != 0)
{
return JsonMore(null,500,res.Result.Data.msg);
return JsonMore(null, 500, ex.Message);
}
return JsonMore(null);
}
public class agvResult
{
public int ack { get; set; }
public string msg { get; set; }
public dynamic data { get; set; }
}
}

View File

@ -1,31 +1,41 @@
<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-button @@click="handleClick"
:loading="loading1"
type="primary">
type="primary"
size="large">
呼叫出库
</a-button>
<a-button @@click='handleAGVTask("In")'
:loading="loading2"
type="primary"
status="warning">
到入库点
</a-button>
<a-divider />
<a-space>
<template #split>
<a-divider direction="vertical" />
</template>
<a-button @@click='handleAGVTask("In")'
:loading="loading2"
type="primary"
status="warning"
size="large">
到入库点
</a-button>
<a-button @@click='handleAGVTask("Charge")'
:loading="loading2"
type="primary"
status="success">
充电任务
</a-button>
<a-button @@click='handleAGVTask("Charge")'
:loading="loading2"
type="primary"
status="success"
size="large">
充电任务
</a-button>
<a-button @@click='handleAGVTask("Out")'
:loading="loading2"
type="outline">
到出库点
</a-button>
<a-button @@click='handleAGVTask("Out")'
:loading="loading2"
type="outline"
size="large">
到出库点
</a-button>
</a-space>
</a-space>
</div>
<script>

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
@ -924,4 +924,7 @@
<data name="_Admin.ZipCode" xml:space="preserve">
<value>Zip</value>
</data>
</root>
<data name="Inventory.Out" xml:space="preserve">
<value />
</data>
</root>

View File

@ -1407,4 +1407,7 @@
<data name="MenuKey.InterfaceLog" xml:space="preserve">
<value>接口日志</value>
</data>
<data name="Inventory.Out" xml:space="preserve">
<value>出库</value>
</data>
</root>