拣货完成,回传库存信息到mes,数量为0
修改回库库存新增交易表bug 出库页面和功能整改
This commit is contained in:
1 parent
11ea24c544
commit
aacf491051
4 files changed
+167
-78
No files matched your search
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user