新增货架出入库 和打印操作

This commit is contained in:
zgf 2023-11-28 02:51:20 +08:00
parent c27a357771
commit 6a1329d74e
17 changed files with 620 additions and 9 deletions

View File

@ -357,6 +357,35 @@ namespace HHWMS.Web
break;
}
if(task.TaskType == TaskTypeEnum.盘料盒入库
|| task.TaskType == TaskTypeEnum.散料盒入库)
{
var invList = _unitwork.Find<Inventory>(x => x.ContainerCode == task.ContainerCode)
.ToList();
var listInvtran = new List<InventoryTransaction>();
foreach (var inv in invList)
{
listInvtran.Add(new InventoryTransaction
{
BillType = "in",
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.BatchAdd(listInvtran.ToArray());
}
_unitwork.Update(task);
if (task.Status == TaskStatusEnum.完成)
{

View File

@ -64,7 +64,7 @@ namespace HHWMS.Web
this.MakeGridHeader(x => x.MaterialSpec),
this.MakeGridHeader(x => x.MaterialUnit),
this.MakeGridHeader(x => x.Batch),
//this.MakeGridHeader(x => x.Lot),
this.MakeGridHeader(x => x.Lot),
//this.MakeGridHeader(x => x.ManufactureDate),
//this.MakeGridHeader(x => x.ExpirationDate),
//this.MakeGridHeader(x => x.CompanyCode),

View File

@ -5,8 +5,9 @@
<wt:row items-per-row="ItemsPerRowEnum.Three">
<wt:combobox field="Searcher.ZoneCode" items="ZoneCodes" />
<wt:textbox field="Searcher.UniqueCode" />
@*<wt:textbox field="Searcher.MaterialCode" />
<wt:textbox field="Searcher.MaterialType" />
<wt:textbox field="Searcher.MaterialCode" />
<wt:textbox field="Searcher.Batch" />
@*<wt:textbox field="Searcher.MaterialType" />
<wt:textbox field="Searcher.MaterialName" />
<wt:textbox field="Searcher.MaterialSpec" />
<wt:textbox field="Searcher.MaterialUnit" />

View File

@ -217,6 +217,7 @@ namespace HHWMS.Web.Controllers
public class Binding
{
public int ID { get; set; }
public string ReceiptCode { get; set; }
public string UniqueCode { get; set; }
public string BoxCode { get; set; }

View File

@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using NPOI.SS.Formula.Functions;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
namespace HHWMS.Web.Controllers;
[Area("receipt")]
[ActionDescription("货架入库")]
public class ReceiptShelfInController : BaseController
{
private readonly IUnitWork _unitWork;
public ReceiptShelfInController(IUnitWork unitWork)
{
_unitWork = unitWork;
}
#region Search
[ActionDescription("Sys.Search")]
public ActionResult Index()
{
return PartialView("Index");
}
#endregion
/// <summary>
/// 扫描唯一码,并验证,返回入库单明细
/// </summary>
/// <param name="uniqueCode"></param>
/// <returns></returns>
[HttpPost]
public ActionResult ScanUniqueCode(string uniqueCode)
{
var receiptDetail = _unitWork.FindSingle<ReceiptDetail>(x => x.UniqueCode.Equals(uniqueCode));
if (receiptDetail != null)
{
if (receiptDetail.Status == ReceiptStatusEnum.收完)
{
return JsonMore(null, 500, $"{uniqueCode}已全部收完,无需重新绑定!");
}
return JsonMore(receiptDetail);
}
return JsonMore(null, 500, $"{uniqueCode}不存在!");
}
/// <summary>
/// 绑定
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
[HttpPost]
public ActionResult BindingData(List<Binding> data)
{
var receiptHeaderList = _unitWork.Find<ReceiptHeader>(x =>
data.Select(x => x.ReceiptCode).ToList().Contains(x.ID.ToString()))
.Include(x => x.ReceiptDetails).ToList();
var invList = new List<Inventory>();
var listInvtran = new List<InventoryTransaction>();
// 查找明细,修改对应状态,并且 绑定物料周转箱
foreach (Binding item in data.OrderBy(x => x.ReceiptCode))
{
// 更新入库单明细状态
var header = receiptHeaderList.Find(x => x.ID.ToString().Equals(item.ReceiptCode));
var receipt = header.ReceiptDetails.First(x => x.UniqueCode.Equals(item.UniqueCode));
if (receipt != null)
{
if (receipt.Status == ReceiptStatusEnum.收完) continue;
receipt.CompletedQty += item.BindQty;
}
if(receipt.CompletedQty == receipt.Qty)
{
receipt.Status = ReceiptStatusEnum.收完;
if (!header.ReceiptDetails.Any(x => x.Status < ReceiptStatusEnum.收完))
{
header.FirstStatus = ReceiptStatusEnum.收完;
}
receipt.UpdateTime = DateTime.Now;
}
// 新建库存
invList.Add(new Inventory
{
ZoneCode = ZoneCodeEnum.货架库,
UniqueCode = item.UniqueCode,
MaterialCode = receipt.MaterialCode,
MaterialType = receipt.MaterialType,
MaterialName = receipt.MaterialName,
MaterialSpec = receipt.MaterialSpec,
Batch = receipt.Batch,
MaterialUnit = receipt.MaterialUnit,
SupplierCode = receipt.SupplierCode,
Qty = item.BindQty,
Status = "0",
TaskStatus = InventoryTaskStatus.无任务,
CreateBy = Wtm.LoginUserInfo.ITCode,
CreateTime = DateTime.Now
}); ;
foreach (var inv in invList)
{
listInvtran.Add(new InventoryTransaction
{
BillType = "in",
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.BatchAdd(invList.ToArray());
_unitWork.BatchAdd(listInvtran.ToArray());
_unitWork.BatchUpdate(receiptHeaderList.ToArray());
return JsonMore(null);
}
}

View File

@ -86,7 +86,7 @@ namespace HHWMS.Web
AppointmentTime = x.AppointmentTime,
Remark = x.Remark,
})
.OrderBy(x => x.ID);
.OrderByDescending(x => x.ID);
return query;
}
}

View File

@ -0,0 +1,173 @@
<el-row id="slapp">
<el-card class="box-card" :span="16">
<el-form ref="form" :model="form" label-width="100px">
<el-row>
<el-col :span="16">
<el-form-item label="唯一码" prop="uniqueCode">
<el-input v-model="form.uniqueCode"
@@change="scanUniqueCode"
ref="uniqueCode">
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-table :data="bindingData" stripe max-height="450" border style="width: 100%">
<el-table-column fixed="left" label="操作" width="120" align="center">
<template slot-scope="scope">
<el-button @@click.native.prevent="deleteRow(scope.$index, bindingData)"
type="text"
size="small">
移除
</el-button>
</template>
</el-table-column>
<el-table-column label="唯一码"
align="center"
prop="uniqueCode">
</el-table-column>
<el-table-column label="物料码"
align="center"
prop="materialCode">
</el-table-column>
<el-table-column label="名称"
align="center"
prop="materialName">
</el-table-column>
<el-table-column label="数量"
align="center"
prop="bindQty">
</el-table-column>
</el-table>
<el-form-item style="float: right">
<el-button type="primary" @@click="onSubmit">入库</el-button>
<el-button @@click="resetForm('form')">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</el-row>
<script>
var app = new Vue({
el: "#slapp",
data() {
return {
form: {
uniqueCode: "",
},
bindingData: []
};
},
mounted: function () {
// 获取所有单据编码
// $.ajax({
// type: "post",
// dataType: "json",
// data:{},
// url: "/receipt/ReceiptIn/SelectReceiptCode",
// success: function (json) {
// app.options = json.Data;
// },
// error: function (json) {
// alert("加载失败");
// }
// });
},
methods: {
// 绑定
onSubmit() {
var _this = this;
// 提交已绑定数据
$.ajax({
type: "post",
dataType: "json",
data: { data: _this.bindingData },
url: "/receipt/ReceiptShelfIn/BindingData",
success: function (json) {
if (json.Code == 200) {
_this.$message({
message: "入库成功!",
});
_this.bindingData = [];
} else {
_this.$message({
message: "入库失败!",
type: "warning",
duration: "10000",
});
}
},
error: function (json) {
_this.$message({
message: "入库失败!",
type: "error",
duration: "10000",
});
},
});
},
// 重置
resetForm(formName) {
this.$refs[formName].resetFields();
this.bindingData = [];
},
// 扫描唯一码
scanUniqueCode(data) {
var _this = this;
//1. 判断唯一码是否合理,调用后台,并返回唯一码对应的数量
var isExit = this.bindingData.findIndex(function (value) {
return value.uniqueCode == data;
})
if (isExit != -1) {
this.$message({
message: '唯一码' + data + '已绑定!',
type: 'warning'
});
this.form.uniqueCode = '';
return;
}
$.ajax({
type: "post",
dataType: "json",
data: { uniqueCode: _this.form.uniqueCode },
url: "/receipt/ReceiptShelfIn/ScanUniqueCode",
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: json.Msg,
type: "warning",
duration: "10000",
});
} else {
// 3.已扫描增加
_this.bindingData.push({
receiptCode: json.Data.ReceiptHeaderId,
uniqueCode: json.Data.UniqueCode,
materialCode: json.Data.MaterialCode,
materialName: json.Data.MaterialName,
batch: json.Data.Batch,
bindQty: json.Data.Qty,
});
}
},
error: function (json) {
_this.$message({
message: "扫描失败!",
type: "error",
duration: "10000",
});
},
});
this.form.uniqueCode = "";
},
// 删除已绑定行
deleteRow(index, rows) {
rows.splice(index, 1);
},
},
});
</script>

View File

@ -88,6 +88,27 @@ public class ShipOutController : BaseController
if (inv != null)
{
// 删除库存,扣账,记录库存交易 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);
List<Inventory> list = _unitWork.Find<Inventory>(x => x.LocationCode == station).ToList();
if (list.Count() == 0)

View File

@ -4,6 +4,8 @@ using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using WalkingTec.Mvvm.Mvc;
using HHWMS.Web;
using HHWMS.Web.Models;
using System.Linq;
namespace HHWMS.Web.Controllers
{

View File

@ -9,6 +9,8 @@ using System.Reflection;
using HHWMS.Web.Models;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using NPOI.SS.Formula.Functions;
using System.Collections.Generic;
namespace HHWMS.Web.Controllers
{
@ -250,7 +252,7 @@ namespace HHWMS.Web.Controllers
{
var data = _unitwork.Find<ShipmentHeader>(x => x.ID == id)
.Include(x => x.ShipmentDetails).ToList();
var details = data.FirstOrDefault().ShipmentDetails.Where(x => x.Status < ShipStatusEnum.拣货完成);
var details = data.FirstOrDefault().ShipmentDetails.Where(x => x.Status < ShipStatusEnum.分配完成);
foreach (var item in details)
{
var invQty = _unitwork.Find<Inventory>(x => x.UniqueCode.Equals(item.UniqueCode))
@ -260,6 +262,99 @@ namespace HHWMS.Web.Controllers
return JsonMore(details);
}
[ActionDescription("ShipmentHeader.ShelfInv")]
public ActionResult ShelfInv(string id)
{
var vm = Wtm.CreateVM<ShipmentHeaderVM>(id);
return PartialView(vm);
}
/// <summary>
/// 货架库存
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[ActionDescription("ShipmentHeader.ShelfInv")]
public ActionResult ShelfInvData(int id)
{
var data = _unitwork.Find<ShipmentHeader>(x => x.ID == id)
.Include(x => x.ShipmentDetails)
.FirstOrDefault();
var details = data.ShipmentDetails.Where(x => x.Status < ShipStatusEnum.分配完成)
.Select(x => x.UniqueCode)
.ToList();
var invList = _unitwork.Find<Inventory>(x => x.ZoneCode.Equals(ZoneCodeEnum.货架库)
&& x.TaskStatus.Equals(InventoryTaskStatus.无任务)
&& details.Contains(x.UniqueCode))
.ToList();
//var details = data.ShipmentDetails.Where(x => invList.Contains(x.UniqueCode));
return JsonMore(invList);
}
[ActionDescription("ShipmentHeader.Pick")]
[HttpPost]
public ActionResult Pick(List<Binding> data, int shipId)
{
var shipment = _unitwork.Find<ShipmentHeader>(x => x.ID.Equals(shipId))
.Include(x => x.ShipmentDetails)
.FirstOrDefault();
if(shipment == null)
{
return JsonMore(null, 500, "未找到该出库单!");
}
foreach(var detail in shipment.ShipmentDetails
.Where(x => data.Select(x => x.UniqueCode).Contains(x.UniqueCode)))
{
detail.Status = ShipStatusEnum.拣货完成;
}
if (!shipment.ShipmentDetails.Any(x => x.Status < ShipStatusEnum.拣货完成))
{
shipment.FirstStatus = ShipStatusEnum.拣货完成;
}
else
{
shipment.FirstStatus = ShipStatusEnum.拣货中;
}
shipment.UpdateBy = Wtm.LoginUserInfo.ITCode;
shipment.UpdateTime = DateTime.Now;
var ids = data.Select(x => x.ID).ToList();
var invList = _unitwork.Find<Inventory>(x => ids.Contains(x.ID))
.ToList();
// 加入交易表
var listInvtran = new List<InventoryTransaction>();
foreach (var inv in invList)
{
listInvtran.Add(new InventoryTransaction
{
BillType = "out",
ZoneCode = inv.ZoneCode,
BillCode = shipment.Code,
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.BatchAdd(listInvtran.ToArray());
// 删除库存
_unitwork.BatchDelete<Inventory>(x => data.Select(u => u.ID).Contains(x.ID));
return JsonMore(null);
}
/// <summary>
/// 获取库存数据
/// </summary>

View File

@ -111,6 +111,7 @@ namespace HHWMS.Web
var query = DC.Set<ShipmentDetail>()
.CheckEqual(Searcher.ShipmentHeaderId, x => x.ShipmentHeaderId)
.CheckContain(Searcher.ZoneCode, x => x.ZoneCode)
.CheckContain(Searcher.UniqueCode, x => x.UniqueCode)
.CheckContain(Searcher.MaterialCode, x => x.MaterialCode)
.CheckContain(Searcher.MaterialType, x => x.MaterialType)
.CheckContain(Searcher.MaterialName, x => x.MaterialName)

View File

@ -17,6 +17,9 @@ namespace HHWMS.Web
[Display(Name = "Task.ZoneCode")]
public String ZoneCode { get; set; }
[Display(Name = "Inventory.UniqueCode")]
public String UniqueCode { get; set; }
[Display(Name = "Inventory.MaterialCode")]
public String MaterialCode { get; set; }

View File

@ -9,7 +9,6 @@ namespace HHWMS.Web
public partial class ShipmentHeaderListVM : BasePagedListVM<ShipmentHeader_View, ShipmentHeaderSearcher>
{
public List<ComboSelectListItem> ShipTypes { get; set; }
protected override void InitVM()
{
var vm = Wtm.CreateVM<ShipmentHeaderVM>();
@ -22,6 +21,9 @@ namespace HHWMS.Web
this.MakeAction("ShipmentHeader","StartOut",Localizer["ShipmentHeader.StartOut"],"",GridActionParameterTypesEnum.SingleId,"shipment"),
this.MakeAction("ShipmentHeader","Analyse",Localizer["ShipmentHeader.Analyse"],Localizer["ShipmentHeader.Analyse"],GridActionParameterTypesEnum.SingleId,"shipment")
.SetShowInRow().SetHideOnToolBar().SetButtonClass("layui-btn-Warm").SetSize(1200,800),
this.MakeAction("ShipmentHeader","ShelfInv",Localizer["ShipmentHeader.ShelfInv"],Localizer["ShipmentHeader.ShelfInv"],GridActionParameterTypesEnum.SingleId,"shipment")
.SetShowInRow().SetHideOnToolBar().SetButtonClass("layui-btn-Warm").SetSize(1200,800),
this.MakeStandardAction("ShipmentHeader", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"shipment", dialogWidth: 800),
this.MakeStandardAction("ShipmentHeader", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "shipment", dialogWidth: 800),
this.MakeStandardAction("ShipmentHeader", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "shipment", dialogWidth: 800),
@ -77,7 +79,7 @@ namespace HHWMS.Web
LastStatus = x.LastStatus,
Remark = x.Remark,
})
.OrderBy(x => x.ID);
.OrderByDescending(x => x.ID);
return query;
}
}

View File

@ -1,4 +1,4 @@
@model HHWMS.Web.ShipmentDetailListVM
@model HHWMS.Web.ShipmentDetailListVM
@inject IStringLocalizer<Program> Localizer;
<wt:searchpanel vm="@Model" reset-btn="true">

View File

@ -0,0 +1,142 @@
@model HHWMS.Web.ShipmentHeaderVM
<el-row id="shelfinv" :gutter="20">
<el-card class="box-card">
<el-table :data="tableData" max-height="600" border
style="width: 100%"
>
<el-table-column label="唯一码" width="220" align="center" prop="UniqueCode"></el-table-column>
<el-table-column label="编码" align="center" prop="MaterialCode"></el-table-column>
<el-table-column label="批次" align="center" prop="Batch"></el-table-column>
<el-table-column label="数量" align="center" prop="Qty"></el-table-column>
</el-table>
<el-row style="float:right">
<el-button type="primary" @@click="print">打印</el-button>
<el-button type="success" @@click="pick">全部拣货</el-button>
</el-row>
</el-card>
</el-row>
<script>
var str = "";
@{
<text>str = @Model.Entity.ID; </text>
}
var app = new Vue({
el: "#shelfinv",
data() {
return {
tableData: []
};
},
mounted: function () {
// 获取所有单据明细
$.ajax({
type: "post",
dataType: "json",
data: { id: str },
url: "/shipment/ShipmentHeader/ShelfInvData",
success: function (json) {
app.tableData = json.Data;
},
error: function (json) {
console.log("加载失败");
}
});
},
methods: {
pick() {
var _this = this;
console.log(_this.tableData)
layer.confirm('确定执行一键拣货操作?', { icon: 3, title: '提示' },
function (index) {
$.ajax({
type: "post",
dataType: "json",
data: { data: _this.tableData, shipId: str },
url: "/shipment/ShipmentHeader/Pick",
success: function (json) {
if (json.Code == 200) {
_this.$message({
message: "拣货成功!"
});
layer.closeAll();
}
else {
_this.$message({
message: "回库任务创建失败!" + json.Msg,
type: "warning",
duration: "10000",
});
}
},
error: function (json) {
_this.$message({
type: 'info',
message: '拣货失败'
});
}
});
layer.close(index);
}, function (index) {
_this.$message({
type: 'info',
message: '已取消'
});
});
},
print() {
var _this = this;
let printdata = {
table : _this.tableData
}
hiprint.init();
var hiprintTemplate = new hiprint.PrintTemplate();
var panel = hiprintTemplate.addPrintPanel({ width: 210, height: 297, paperHeader: 45, paperFooter: 780, paperType: 'A4' });
panel.addPrintTable({
options: {
"left": 16.5,
"top": 57,
"height": 38,
"width": 562.5,
"textAlign": "center",
"field": "table",
"columns": [[{
"title": "唯一码",
"field": "UniqueCode",
"width": 180,
"colspan": 1,
"rowspan": 1
}, {
"title": "物料码",
"field": "MaterialCode",
"width": 80,
"colspan": 1,
"rowspan": 1
},
{
"title": "名称",
"field": "MaterialName",
"width": 110,
"colspan": 1,
"rowspan": 1
}, {
"title": "批次",
"field": "Batch",
"width": 80,
"colspan": 1,
"rowspan": 1
}]]
}
});
hiprintTemplate.print([printdata]);
}
}
});
</script>

View File

@ -289,6 +289,10 @@ namespace HHWMS.Web.Models
/// </summary>
public const string 散料库 = "C";
/// <summary>
/// 货架库 = "P";
/// </summary>
public const string 货架库 = "P";
}
/// <summary>

View File

@ -1225,7 +1225,7 @@
<value>批次</value>
</data>
<data name="Inventory.Lot" xml:space="preserve">
<value>料号</value>
<value>格</value>
</data>
<data name="Inventory.ManufactureDate" xml:space="preserve">
<value>生产日期</value>