库存回传
入库扫描逻辑
添加物料二维码和唯一码对应表
This commit is contained in:
zgf committed 2023-11-09 17:17:05 +08:00
1 parent f9bf7be066
commit da78422528
19 files changed
+1684 -115

No files matched your search

+22
View File
@@ -6,6 +6,7 @@ using AutoMapper;
using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using WalkingTec.Mvvm.Core;
namespace HHWMS.Web
@@ -36,6 +37,27 @@ namespace HHWMS.Web
[HttpPost]
public IActionResult RequestIn(WcsRequest request)
{
var inv = _unitwork.Find<Inventory>(x => x.ID > 0).FirstOrDefault();
var bizData = new InStore
{
INWMS = new INWMS
{
INITEMS = new INITEMS
{
INITEM = new List<INITEMItem>()
{
new INITEMItem()
{
ERPSN = inv.MaterialCode,
WMSSN = inv.UniqueCode,
QTY = ((int?)inv.Qty).ToString(),
TYPE = "2"
}
}
}
}
};
var str = JsonConvert.SerializeObject(bizData);
// 参数判断
if (request.RoadWay == null || request.Size == null)
{
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using HHWMS.Web.Models;
@@ -45,7 +46,7 @@ namespace HHWMS.Web.Controllers
}
[HttpPost]
public ActionResult GenCode(string code)
public ActionResult GenCode(string code, int num = 1)
{
var material = _unitwork.FindSingle<Material>(x => x.QRCode.Equals(code));
if (material == null)
@@ -54,20 +55,23 @@ namespace HHWMS.Web.Controllers
}
else
{
if (string.IsNullOrEmpty(material.UniqueCode))
var materialQrList = new List<MaterialQr>();
for (int i = 0; i < num; i++)
{
var prefix = code.Split("@")[1].Substring(2);
var unique = _unitwork.GetSerialNumber(prefix, 8);
var uniqueCode = prefix + unique;
var uniqueCode = _unitwork.GetSerialNumber(prefix, length: 8);
//var uniqueCode = prefix + unique;
material.UniqueCode = uniqueCode;
_unitwork.Update(material);
return JsonMore(uniqueCode);
}
else
{
return JsonMore(material.UniqueCode);
materialQrList.Add(new MaterialQr
{
QRCode = code,
UniqueCode = uniqueCode,
CreateTime = DateTime.Now,
CreateBy = Wtm.LoginUserInfo.ITCode
});
}
_unitwork.BatchAdd(materialQrList.ToArray());
return JsonMore(materialQrList);
}
}
}
@@ -32,7 +32,7 @@ namespace HHWMS.Web
protected override IEnumerable<IGridColumn<Material_View>> InitGridHeader()
{
return new List<GridColumn<Material_View>>{
this.MakeGridHeader(x => x.UniqueCode).SetWidth(220),
this.MakeGridHeader(x => x.UniqueCode).SetHide(),
this.MakeGridHeader(x => x.QRCode),
this.MakeGridHeader(x => x.SourceCode).SetHide(),
this.MakeGridHeader(x => x.MaterialCode),
@@ -1,12 +1,17 @@
<el-row id="print">
<el-row>
<el-col :span="16">
<el-col :span="12">
<el-input v-model="qrcode"
placeholder="请扫描二维码"
@@change="scanCode" ref="QrCode">
</el-input>
</el-col>
<el-col :span="8">
<el-input v-model.number="num"
placeholder="请输入数量">
</el-input>
</el-col>
<el-col :span="4">
<el-button type="primary" @@click="genCode">生成</el-button>
</el-col>
</el-row>
@@ -28,6 +33,7 @@
printData:[],
gendCode: '',
qrcode: '',
num: 1,
template: {
"panels": [
{
@@ -80,38 +86,6 @@
duration: "10000",
});
}
else{
$.ajax({
type: "post",
dataType: "json",
data: { code: _this.qrcode },
url: "/configs/Print/GenCode",
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "生成失败!" + json.Msg,
type: "warning",
duration: "10000",
});
return;
}
else {
_this.gendCode += json.Data + '\n';
_this.printData.push({ uniqueCode: json.Data });
//清空
_this.qrcode = '';
}
},
error: function (json) {
_this.$message({
message: "生成失败!",
type: "error",
duration: "10000",
});
},
});
}
},
error: function (json) {
_this.$message({
@@ -124,11 +98,27 @@
},
genCode() {
var _this = this;
if (_this.qrcode == "") {
_this.$message({
message: "请扫描二维码后再操作!",
type: "warning",
duration: "500",
});
return;
}
if (_this.num == "") {
_this.$message({
message: "请输入数量后再操作!",
type: "warning",
duration: "500",
});
return;
}
// 调用后台方法,生成唯一码,(流水号)
$.ajax({
type: "post",
dataType: "json",
data: { code: _this.qrcode },
data: { code: _this.qrcode, num: _this.num },
url: "/configs/Print/GenCode",
success: function (json) {
if (json.Code != 200) {
@@ -140,8 +130,12 @@
return;
}
else{
_this.gendCode += json.Data + '\n';
_this.printData.push({ uniqueCode: json.Data });
console.log(json);
json.Data.forEach(function (item) {
_this.gendCode += item.UniqueCode + '\n';
_this.printData.push({ uniqueCode: item.UniqueCode });
});
}
},
error: function (json) {
@@ -152,8 +146,7 @@
});
},
});
//清空
_this.qrcode = '';
_this.unm = 1;
},
print() {
var _this = this;
@@ -164,6 +157,9 @@
})
hiprintTemplate.print(this.printData);
_this.printData = [];
//清空
_this.qrcode = '';
_this.unm = 1;
}
}
});
@@ -5,6 +5,9 @@ using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
using WalkingTec.Mvvm.Core.Extensions;
using HHWMS.Web;
using HHWMS.Web.Models;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace HHWMS.Web.Controllers
{
@@ -222,5 +225,52 @@ namespace HHWMS.Web.Controllers
}
#endregion
[ActionDescription("Inventory.ReturnToMes")]
public ActionResult ReturnToMes(string id)
{
var inv = _unitwork.FindById<Inventory>(int.Parse(id));
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 = ((int?)inv?.Qty).ToString(),
TYPE = "2"
}
}
}
}
};
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;
if (result.Status == "Y")
{
Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "success");
return FFResult().Message("库存回传成功").RefreshGrid();
}
else
{
Wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: JsonConvert.SerializeObject(request), result: "error");
return FFResult().Message($"{result.Message}").RefreshGrid();
}
}
}
}
@@ -24,6 +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.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),
@@ -5,6 +5,7 @@ using WalkingTec.Mvvm.Mvc;
using WalkingTec.Mvvm.Core.Extensions;
using HHWMS.Web.Models;
using System.Collections.Generic;
using System;
namespace HHWMS.Web.Controllers
{
@@ -141,7 +142,7 @@ namespace HHWMS.Web.Controllers
{
UniqueCode = item,
Status = 0,
MaterialType = "PL",
ZoneCode = ZoneCodeEnum.盘料库,
ReceiptHeaderId = vm.Entity.ReceiptHeaderId
});
}
@@ -154,12 +155,29 @@ namespace HHWMS.Web.Controllers
detailList.Add(new ReceiptDetail
{
UniqueCode = item,
MaterialType = "SL",
ZoneCode = ZoneCodeEnum.散料库,
Status = 0,
ReceiptHeaderId = vm.Entity.ReceiptHeaderId
});
}
}
// 补充物料明细
foreach(var item in detailList)
{
var materialqr = _unitwork.FindSingle<MaterialQr>(x => x.UniqueCode.Equals(item.UniqueCode));
var material = _unitwork.FindSingle<Material>(x => x.QRCode.Equals(materialqr.QRCode));
item.MaterialCode = material.MaterialCode;
item.MaterialName = material.MaterialName;
item.MaterialSpec = material.MaterialSpec;
item.MaterialType = material.MaterialType;
item.MaterialUnit = material.MaterialUnit;
item.Batch = material.Batch;
item.Qty = material.Qty;
item.SupplierCode = material.SupplierCode;
item.CreateBy = Wtm.LoginUserInfo.ITCode;
item.CreateTime = DateTime.Now;
}
_unitwork.BatchAdd(detailList.ToArray());
return FFResult().CloseDialog().RefreshGrid(index: 1);
}
@@ -35,15 +35,15 @@ namespace HHWMS.Web
this.MakeGridHeader(x => x.UniqueCode).SetWidth(230),
this.MakeGridHeader(x => x.MaterialCode),
//this.MakeGridHeader(x => x.MaterialType),
//this.MakeGridHeader(x => x.MaterialName),
this.MakeGridHeader(x => x.MaterialName),
//this.MakeGridHeader(x => x.MaterialSpec),
//this.MakeGridHeader(x => x.MaterialUnit),
this.MakeGridHeader(x => x.MaterialUnit),
this.MakeGridHeader(x => x.Batch),
//this.MakeGridHeader(x => x.Lot).SetHide(),
//this.MakeGridHeader(x => x.ManufactureDate),
//this.MakeGridHeader(x => x.ExpirationDate),
//this.MakeGridHeader(x => x.CompanyCode),
//this.MakeGridHeader(x => x.SupplierCode),
this.MakeGridHeader(x => x.SupplierCode),
this.MakeGridHeader(x => x.CompletedQty),
this.MakeGridHeader(x => x.Qty),
//this.MakeGridHeader(x => x.InventoryStatus),
@@ -201,36 +201,29 @@
var _this = this;
_this.form.size = '';
_this.form.boxSize = [];
if (Box == "L02") {
_this.form.boxSize = [{ label: "24mm", value: "24" }, { label: "16mm", value: "16" }, { label: "10mm", value: "10" }]
_this.dataIndex = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
}
else if (Box == "L01") {
_this.form.boxSize = [{ label: "8mm", value: "8" }];
_this.form.size = _this.form.boxSize[0].value;
_this.dataIndex = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
}
else {
_this.$message({
message: '输入周转箱编码不正确!',
if (this.form.code == '') {
this.$message({
message: '请先选择单据!',
type: 'warning'
});
return;
}
console.log(Box);
$.ajax({
type: "post",
dataType: "json",
data: { boxCode: Box },
url: "/receipt/ReceiptIn/ScanBox",
success: function (json) {
console.log(json);
if (json.Code != 200) {
_this.$message({
message: "扫描失败!" + json.Msg,
type: "warning",
duration: "10000",
});
_this.form.boxCode = "";
return false;
}
else {
_this.$message({
@@ -239,6 +232,23 @@
duration: "10000",
});
_this.$refs.uniqueCode.focus();
if (Box == "L02") {
_this.form.boxSize = [{ label: "24mm", value: "24" }, { label: "16mm", value: "16" }, { label: "10mm", value: "10" }]
_this.dataIndex = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
}
else if (Box == "L01") {
_this.form.boxSize = [{ label: "8mm", value: "8" }];
_this.form.size = _this.form.boxSize[0].value;
_this.dataIndex = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
}
else {
_this.$message({
message: '输入周转箱编码不正确!',
type: 'warning'
});
return;
}
}
},
error: function (json) {
@@ -250,6 +260,8 @@
return;
},
});
// 重新扫描箱号后,待绑定列表清空
_this.bindingData = [];
_this.changeselect(_this.value);
@@ -262,6 +274,13 @@
},
// 扫描唯一码
scanUniqueCode(data) {
if (this.form.code == '') {
this.$message({
message: '请先选择单据!',
type: 'warning'
});
return;
}
if (this.dataIndex.length == 0) {
this.$message({
message: '该周转箱已放满!',
@@ -55,50 +55,23 @@
},
methods: {
handleSelectionChange(val) {
console.log(22);
val.forEach(row => {
if (row.station == '') {
this.$refs.multipleTable.toggleRowSelection(row);
this.$message({
message: "此周转箱没有选择站台!",
type: "warning",
duration: "5000",
});
}
});
this.selectData = val;
let names = this.selectData.map(item => item["station"]);
let nameSet = new Set(names);
if (nameSet.size != names.length) {
this.$message({
message: "站台不能重复!",
type: "warning",
duration: "5000",
});
this.$refs.multipleTable.clearSelection();
this.selectData = [];
}
console.log(this.selectData);
},
// 启动入库
inOperation() {
console.log(this.tableData)
var _this = this;
for (var i = 0; i < _this.tableData.length; i++) {
if (_this.tableData[i].station == null || _this.tableData[i].station == "") {
this.$message({
message: "必须全部选择!",
type: "warning",
duration: "5000",
});
return;
}
if (_this.selectData.length < 1) {
this.$message({
message: "至少选择一个站台!",
type: "warning",
duration: "5000",
});
return;
}
$.ajax({
type: "post",
dataType: "json",
data: { data: _this.tableData },
data: { data: _this.selectData },
url: "/receipt/ReceiptInOperation/InOperation",
success: function (json) {
if (json.Code == 200) {
@@ -107,6 +80,13 @@
type: "success",
});
}
else {
_this.$message({
message: json.Msg,
type: "warning",
duration: "1000",
});
}
},
error: function (json) {
alert("加载失败");
@@ -67,9 +67,9 @@ namespace HHWMS.Web
// 调用wcs任务下发接口
try
{
//var res = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, item).Result.Data;
if (true)
//if (res.Success)
var res = Wtm.CallAPI<ApiJsonResult<dynamic>>("WCS", "TaskAssign", HttpMethodEnum.POST, item).Result.Data;
//if (true)
if (res.Success)
{
var locationList = _unitwork.Find<Location>(x => task.FromLocation.Equals(x.Code) || task.ToLocation.Equals(x.Code)).ToList();
var begin = locationList.FirstOrDefault(x => x.Code.Equals(task.FromLocation));