拣货完成,回传库存信息到mes,数量为0

修改回库库存新增交易表bug
出库页面和功能整改
This commit is contained in:
zgf 2023-12-04 23:47:03 +08:00
parent 11ea24c544
commit aacf491051
4 changed files with 167 additions and 78 deletions

View File

@ -360,7 +360,8 @@ namespace HHWMS.Web
if(task.TaskType == TaskTypeEnum.盘料盒入库
|| task.TaskType == TaskTypeEnum.散料盒入库)
{
var invList = _unitwork.Find<Inventory>(x => x.ContainerCode == task.ContainerCode)
var invList = _unitwork.Find<Inventory>(x => x.ContainerCode == task.ContainerCode
&& x.TaskStatus == InventoryTaskStatus.任务中)
.ToList();
var listInvtran = new List<InventoryTransaction>();
foreach (var inv in invList)

View File

@ -229,7 +229,7 @@ namespace HHWMS.Web.Controllers
public ActionResult ReturnToMes(string id)
{
var inv = _unitwork.FindById<Inventory>(int.Parse(id));
if(inv.Status == "1")
if (inv.Status == "1")
{
return FFResult().Message($"物料{inv.UniqueCode}已回传MES").RefreshGrid();
}

View File

@ -2,8 +2,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
using HHWMS.Web.Models;
using MESTOWMSService;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using ServiceReference1;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
@ -34,16 +37,17 @@ public class ShipOutController : BaseController
/// 扫描散料箱/盘料周转箱 返回待出库明细
/// </summary>
/// <param name="code"></param>
/// <param name="type"></param>
/// <returns></returns>
[HttpPost]
public ActionResult ScanBox(string code)
public ActionResult ScanBox(string code, string type)
{
Location box = new Location();
if (code.Contains("C"))
if (type.Contains("slbox"))
{
box = _unitWork.FindSingle<Location>(x => x.Code.Equals(code) && x.Type == LocationTypeEnum.散料库站台);
}
else if (code.Contains("L"))
else if (type.Contains("lt"))
{
box = _unitWork.FindSingle<Location>(x => x.Code.Equals(code) && x.Type == LocationTypeEnum.料塔);
}
@ -87,79 +91,142 @@ public class ShipOutController : BaseController
var shipment = _unitWork.Find<ShipmentDetail>(x => x.UniqueCode.Equals(uniqueCode))
.Include(x => x.ShipmentHeader)
.FirstOrDefault();
if (shipment == null)
using (var tran = Wtm.DC.Database.BeginTransaction())
{
return JsonMore(null, 500, "未找到该出库单!");
}
shipment.Status = ShipStatusEnum.拣货完成;
shipment.UpdateTime = DateTime.Now;
shipment.UpdateBy = Wtm.LoginUserInfo.ITCode;
if (!shipment.ShipmentHeader.ShipmentDetails.Any(x => x.Status < ShipStatusEnum.拣货完成))
{
shipment.ShipmentHeader.FirstStatus = ShipStatusEnum.拣货完成;
}
else
{
shipment.ShipmentHeader.FirstStatus = ShipStatusEnum.拣货中;
}
shipment.UpdateBy = Wtm.LoginUserInfo.ITCode;
shipment.UpdateTime = DateTime.Now;
_unitWork.Update(shipment);
var inv = _unitWork.FindSingle<Inventory>(x => x.UniqueCode.Equals(uniqueCode) && x.LocationCode == station);
if (inv != null)
{
// 删除库存,扣账,记录库存交易 todo,根据站台查询是否还有未拣货的物料,如果没有就清空站台占用
var invTran = new InventoryTransaction
try
{
BillType = "out",
ZoneCode = inv.ZoneCode,
Type = inv.UniqueCode,
MaterialCode = inv.MaterialCode,
MaterialName = inv.MaterialName,
MaterialSpec = inv.MaterialSpec,
MaterialUnit = inv.MaterialUnit,
MaterialType = inv.MaterialType,
Batch = inv.Batch,
Lot = inv.Lot,
CompanyCode = inv.CompanyCode,
LocationCode = inv.LocationCode,
SupplierCode = inv.SupplierCode,
Qty = inv.Qty,
CreateTime = DateTime.Now
};
_unitWork.Add(invTran);
_unitWork.Delete(inv);
var Sation = _unitWork.Find<Location>(x => x.Code == station).FirstOrDefault();
if (Sation != null && Sation.Type == "T")
{
Sation.Height -= 1;
if (Sation.Height <= 0)
if (shipment == null)
{
Sation.Height = 0;
Sation.ContainerCode = "";
return JsonMore(null, 500, "未找到该出库单!");
}
_unitWork.Update(Sation);
}
List<Inventory> list = _unitWork.Find<Inventory>(x => x.LocationCode == station).ToList();
if (list.Count() == 0)
{
//var Sation = _unitWork.Find<Location>(x => x.Code == station).FirstOrDefault();
if (Sation != null && Sation.Type == "T")
shipment.Status = ShipStatusEnum.拣货完成;
shipment.UpdateTime = DateTime.Now;
shipment.UpdateBy = Wtm.LoginUserInfo.ITCode;
if (!shipment.ShipmentHeader.ShipmentDetails.Any(x => x.Status < ShipStatusEnum.拣货完成))
{
Sation.ContainerCode = "";
Sation.Height = 0;
_unitWork.Update(Sation);
shipment.ShipmentHeader.FirstStatus = ShipStatusEnum.拣货完成;
}
else
{
shipment.ShipmentHeader.FirstStatus = ShipStatusEnum.拣货中;
}
shipment.UpdateBy = Wtm.LoginUserInfo.ITCode;
shipment.UpdateTime = DateTime.Now;
_unitWork.Update(shipment);
var inv = _unitWork.FindSingle<Inventory>(x => x.UniqueCode.Equals(uniqueCode) && x.LocationCode == station);
if (inv != null)
{
//回传MES
var qr = _unitWork.FindSingle<MaterialQr>(x => x.UniqueCode.Equals(inv.UniqueCode))?.QRCode;
var bizData = new InStore
{
INWMS = new INWMS
{
INITEMS = new INITEMS
{
INITEM = new List<INITEMItem>()
{
new INITEMItem()
{
ERPSN = qr,
WMSSN = inv?.UniqueCode,
QTY = "0",
TYPE = "2",
FLAG = "1"
}
}
}
}
};
var str = JsonConvert.SerializeObject(bizData);
var request = new ServiceReference1.bizOperationV1Request
{
fromUnit = "8357S",
toUnit = "8357TEST",
fromSys = "WMSTEST",
toSys = "MES",
bizOperation = "InStore",
bizData = str
};
var client = new ServiceReference1.portTypeClient();
var result = client.bizOperationV1Async(request).Result;
//var result = new bizOperationV1Response();
//result.Status = "Y";
if (result.Status == "Y")
{
// 删除库存,扣账,记录库存交易 todo,根据站台查询是否还有未拣货的物料,如果没有就清空站台占用
var invTran = new InventoryTransaction
{
BillType = "out",
ZoneCode = inv.ZoneCode,
Type = inv.UniqueCode,
MaterialCode = inv.MaterialCode,
MaterialName = inv.MaterialName,
MaterialSpec = inv.MaterialSpec,
MaterialUnit = inv.MaterialUnit,
MaterialType = inv.MaterialType,
Batch = inv.Batch,
Lot = inv.Lot,
CompanyCode = inv.CompanyCode,
LocationCode = inv.LocationCode,
SupplierCode = inv.SupplierCode,
Qty = inv.Qty,
CreateTime = DateTime.Now
};
_unitWork.Add(invTran);
_unitWork.Delete(inv);
var Sation = _unitWork.Find<Location>(x => x.Code == station).FirstOrDefault();
if (Sation != null && Sation.Type == "T")
{
Sation.Height -= 1;
if (Sation.Height <= 0)
{
Sation.Height = 0;
Sation.ContainerCode = "";
}
_unitWork.Update(Sation);
}
List<Inventory> list = _unitWork.Find<Inventory>(x => x.LocationCode == station).ToList();
if (list.Count() == 0)
{
//var Sation = _unitWork.Find<Location>(x => x.Code == station).FirstOrDefault();
if (Sation != null && Sation.Type == "T")
{
Sation.ContainerCode = "";
Sation.Height = 0;
_unitWork.Update(Sation);
}
}
Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "success");
tran.Commit();
return JsonMore(null);
}
else
{
tran.Rollback();
Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "error");
return JsonMore(null, 500, $"回传MES失败,失败原因{result.Message}");
}
}
else
{
tran.Rollback();
return JsonMore(null, 500, $"站台{station}上的{uniqueCode}不存在!");
}
}
return JsonMore(inv);
catch (Exception ex)
{
tran.Rollback();
return JsonMore(null, 500, $"拣货失败,失败原因{ex.Message}");
}
}
return JsonMore(null, 500, $"站台{station}上的{uniqueCode}不存在!");
}
/// <summary>

View File

@ -4,7 +4,7 @@
<el-row>
<el-col :span="4">
<el-form-item label="类型" prop="type">
<el-select v-model="type"
<el-select v-model="form.type"
placeholder="请选择类型"
style="width: 100%"
@@change="select"
@ -109,11 +109,17 @@
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.type == "") {
if (_this.form.type == "") {
_this.$message({
message: "请先选择操作类型!",
type: "warning",
@ -123,7 +129,7 @@
return;
}
let url = "";
if (_this.type == "uniqueCode") {
if (_this.form.type == "uniqueCode") {
url = "/shipment/ShipOut/ScanUniqueCode"
}
else{
@ -132,7 +138,7 @@
$.ajax({
type: "post",
dataType: "json",
data: { code: _this.form.code },
data: { code: _this.form.code, type: _this.form.type },
url: url,
success: function (json) {
if (json.Code != 200) {
@ -141,8 +147,9 @@
type: "warning",
duration: "10000",
});
_this.form.code = "";
} else {
if (_this.type == "uniqueCode") {
if (_this.form.type == "uniqueCode") {
_this.form.uniqueCode = json.Data.UniqueCode;
_this.form.materialCode = json.Data.MaterialCode;
_this.form.materialSpec = json.Data.MaterialSpec;
@ -151,6 +158,11 @@
} 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;
}
}
}
},
@ -166,7 +178,14 @@
// 拣货
onSubmit() {
var _this = this;
if (_this.form.uniqueCode == "") {
_this.$message({
message: "未选择出库明细!",
type: "warning",
duration: "10000",
});
return;
}
// 提交已绑定数据
$.ajax({
type: "post",
@ -184,7 +203,9 @@
arr.splice(index, 1);
}
});
if (_this.invTable.length == 0 && _this.form.type == "slbox") {
if (_this.invTable.length == 0
&& _this.form.type == "slbox"
&& _this.form.code.startsWith("C")) {
_this.showBack = true;
}
_this.$refs['form'].resetFields();
@ -209,7 +230,7 @@
back() {
var _this = this;
// 创建回库任务
if (_this.code == "") {
if (_this.form.code == "") {
_this.$message({
message: "箱号为空,不能创建回库任务!",
type: "error",