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

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

No files matched your search

+2 -1
View File
@@ -360,7 +360,8 @@ namespace HHWMS.Web
if(task.TaskType == TaskTypeEnum.盘料盒入库 if(task.TaskType == TaskTypeEnum.盘料盒入库
|| 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(); .ToList();
var listInvtran = new List<InventoryTransaction>(); var listInvtran = new List<InventoryTransaction>();
foreach (var inv in invList) foreach (var inv in invList)
@@ -229,7 +229,7 @@ namespace HHWMS.Web.Controllers
public ActionResult ReturnToMes(string id) public ActionResult ReturnToMes(string id)
{ {
var inv = _unitwork.FindById<Inventory>(int.Parse(id)); var inv = _unitwork.FindById<Inventory>(int.Parse(id));
if(inv.Status == "1") if (inv.Status == "1")
{ {
return FFResult().Message($"物料{inv.UniqueCode}已回传MES").RefreshGrid(); return FFResult().Message($"物料{inv.UniqueCode}已回传MES").RefreshGrid();
} }
@@ -2,8 +2,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using HHWMS.Web.Models; using HHWMS.Web.Models;
using MESTOWMSService;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using ServiceReference1;
using WalkingTec.Mvvm.Core; using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc; using WalkingTec.Mvvm.Mvc;
@@ -34,16 +37,17 @@ public class ShipOutController : BaseController
/// 扫描散料箱/盘料周转箱 返回待出库明细 /// 扫描散料箱/盘料周转箱 返回待出库明细
/// </summary> /// </summary>
/// <param name="code"></param> /// <param name="code"></param>
/// <param name="type"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public ActionResult ScanBox(string code) public ActionResult ScanBox(string code, string type)
{ {
Location box = new Location(); Location box = new Location();
if (code.Contains("C")) if (type.Contains("slbox"))
{ {
box = _unitWork.FindSingle<Location>(x => x.Code.Equals(code) && x.Type == LocationTypeEnum.散料库站台); 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.料塔); 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)) var shipment = _unitWork.Find<ShipmentDetail>(x => x.UniqueCode.Equals(uniqueCode))
.Include(x => x.ShipmentHeader) .Include(x => x.ShipmentHeader)
.FirstOrDefault(); .FirstOrDefault();
if (shipment == null) using (var tran = Wtm.DC.Database.BeginTransaction())
{ {
return JsonMore(null, 500, "未找到该出库单!"); try
}
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
{ {
BillType = "out", if (shipment == null)
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; return JsonMore(null, 500, "未找到该出库单!");
Sation.ContainerCode = "";
} }
_unitWork.Update(Sation); shipment.Status = ShipStatusEnum.拣货完成;
} shipment.UpdateTime = DateTime.Now;
List<Inventory> list = _unitWork.Find<Inventory>(x => x.LocationCode == station).ToList(); shipment.UpdateBy = Wtm.LoginUserInfo.ITCode;
if (list.Count() == 0)
{
//var Sation = _unitWork.Find<Location>(x => x.Code == station).FirstOrDefault(); if (!shipment.ShipmentHeader.ShipmentDetails.Any(x => x.Status < ShipStatusEnum.拣货完成))
if (Sation != null && Sation.Type == "T")
{ {
Sation.ContainerCode = ""; shipment.ShipmentHeader.FirstStatus = ShipStatusEnum.拣货完成;
Sation.Height = 0; }
_unitWork.Update(Sation); 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}不存在!");
} }
} }
catch (Exception ex)
return JsonMore(inv); {
tran.Rollback();
return JsonMore(null, 500, $"拣货失败,失败原因{ex.Message}");
}
} }
return JsonMore(null, 500, $"站台{station}上的{uniqueCode}不存在!");
} }
/// <summary> /// <summary>
@@ -4,7 +4,7 @@
<el-row> <el-row>
<el-col :span="4"> <el-col :span="4">
<el-form-item label="类型" prop="type"> <el-form-item label="类型" prop="type">
<el-select v-model="type" <el-select v-model="form.type"
placeholder="请选择类型" placeholder="请选择类型"
style="width: 100%" style="width: 100%"
@@change="select" @@change="select"
@@ -109,11 +109,17 @@
select(data) { select(data) {
this.form.code = ""; this.form.code = "";
this.form.type = data; 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) { scanCode(data) {
var _this = this; var _this = this;
if (_this.type == "") { if (_this.form.type == "") {
_this.$message({ _this.$message({
message: "请先选择操作类型!", message: "请先选择操作类型!",
type: "warning", type: "warning",
@@ -123,7 +129,7 @@
return; return;
} }
let url = ""; let url = "";
if (_this.type == "uniqueCode") { if (_this.form.type == "uniqueCode") {
url = "/shipment/ShipOut/ScanUniqueCode" url = "/shipment/ShipOut/ScanUniqueCode"
} }
else{ else{
@@ -132,7 +138,7 @@
$.ajax({ $.ajax({
type: "post", type: "post",
dataType: "json", dataType: "json",
data: { code: _this.form.code }, data: { code: _this.form.code, type: _this.form.type },
url: url, url: url,
success: function (json) { success: function (json) {
if (json.Code != 200) { if (json.Code != 200) {
@@ -141,8 +147,9 @@
type: "warning", type: "warning",
duration: "10000", duration: "10000",
}); });
_this.form.code = "";
} else { } else {
if (_this.type == "uniqueCode") { if (_this.form.type == "uniqueCode") {
_this.form.uniqueCode = json.Data.UniqueCode; _this.form.uniqueCode = json.Data.UniqueCode;
_this.form.materialCode = json.Data.MaterialCode; _this.form.materialCode = json.Data.MaterialCode;
_this.form.materialSpec = json.Data.MaterialSpec; _this.form.materialSpec = json.Data.MaterialSpec;
@@ -151,6 +158,11 @@
} else { } else {
_this.showTable = true; _this.showTable = true;
_this.invTable = json.Data; _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() { onSubmit() {
var _this = this; var _this = this;
if (_this.form.uniqueCode == "") {
_this.$message({
message: "未选择出库明细!",
type: "warning",
duration: "10000",
});
return;
}
// 提交已绑定数据 // 提交已绑定数据
$.ajax({ $.ajax({
type: "post", type: "post",
@@ -184,7 +203,9 @@
arr.splice(index, 1); 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.showBack = true;
} }
_this.$refs['form'].resetFields(); _this.$refs['form'].resetFields();
@@ -209,7 +230,7 @@
back() { back() {
var _this = this; var _this = this;
// 创建回库任务 // 创建回库任务
if (_this.code == "") { if (_this.form.code == "") {
_this.$message({ _this.$message({
message: "箱号为空,不能创建回库任务!", message: "箱号为空,不能创建回库任务!",
type: "error", type: "error",