入库操作修改

This commit is contained in:
zgf committed 2023-08-24 09:07:12 +08:00
1 parent 2097bffabb
commit 8de4bc26cd
8 files changed
+348 -25

No files matched your search

@@ -17,10 +17,10 @@ namespace HHWMS.Web.Controllers
[ActionDescription("盘料操作")]
public partial class ReceiptInController : BaseController
{
private readonly IUnitWork _unitwork;
private readonly IUnitWork _unitWork;
public ReceiptInController(IUnitWork unitwork)
{
_unitwork = unitwork;
_unitWork = unitwork;
}
#region Search
[ActionDescription("Sys.Search")]
@@ -32,7 +32,7 @@ namespace HHWMS.Web.Controllers
[HttpPost]
public ActionResult<dynamic> SelectReceiptCode()
{
var data = _unitwork.Find<ReceiptHeader>(x => x.FirstStatus < ReceiptStatusEnum.回传)
var data = _unitWork.Find<ReceiptHeader>(x => x.FirstStatus <= ReceiptStatusEnum.收完)
.Select(x => new { label = x.Code, value = x.Code });
return JsonMore(data);
}
@@ -40,10 +40,12 @@ namespace HHWMS.Web.Controllers
[HttpPost]
public ActionResult<dynamic> SelectReceipt(string Code)
{
var data = _unitwork.Find<ReceiptHeader>(x => x.Code == Code).Include(x => x.ReceiptDetails).FirstOrDefault();
var data = _unitWork.Find<ReceiptHeader>(x => x.Code == Code)
.Include(x => x.ReceiptDetails.Where(a => a.Status < ReceiptStatusEnum.收完))
.FirstOrDefault();
if(data != null)
{
var result = data.ReceiptDetails.Select(x => new { name = x.MaterialCode });
var result = data.ReceiptDetails.Select(x => new { name = x.UniqueCode });
return JsonMore(result);
}
else
@@ -57,10 +59,46 @@ namespace HHWMS.Web.Controllers
/// <param name="data"></param>
/// <returns></returns>
[HttpPost]
public dynamic BindingData(List<Binding> data)
public ActionResult BindingData(List<Binding> data)
{
// 查找明细,修改对应状态,并且 绑定物料周转箱
return new ApiJsonResult<object> { Success = true };
var receiptHeaderList = _unitWork.Find<ReceiptHeader>(x =>
data.Select(x => x.ReceiptCode).ToList().Contains(x.Code))
.Include(x => x.ReceiptDetails).ToList();
// 查找明细,修改对应状态,并且 绑定物料周转箱
foreach (Binding item in data)
{
// 更新入库单明细状态
var header = receiptHeaderList.First(x => x.Code.Equals(item.ReceiptCode));
var receipt = header.ReceiptDetails.First(x => x.UniqueCode.Equals(item.UniqueCode));
//var receipt = _unitWork.FindSingle<ReceiptDetail>(x => x.UniqueCode == 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.收完;
_unitWork.Update(header);
}
}
// 新建库存
var inventory = new Inventory
{
ZoneCode = ZoneCodeEnum.盘料库,
UniqueCode = item.UniqueCode,
Flag = item.Index,
Qty = receipt.Qty,
Lot = item.Size.ToString(),
ContainerCode = item.BoxCode,
TaskStatus = InventoryTaskStatus.任务中
};
_unitWork.Add(inventory);
}
return JsonMore(null);
}
#endregion
@@ -69,9 +107,11 @@ namespace HHWMS.Web.Controllers
public class Binding
{
public string ReceiptCode { get; set; }
public string UniqueCode { get; set; }
public string BoxCode { get; set; }
public int Index { get; set; }
public int Size { get; set; }
public int BindQty { get; set; }
}
}
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
@@ -69,6 +71,35 @@ public class ReceiptSLInController : BaseController
return JsonMore(null);
}
/// <summary>
/// 扫描散料箱
/// </summary>
/// <param name="boxCode"></param>
/// <returns></returns>
[HttpPost]
public ActionResult ScanBox(string boxCode)
{
// 判断任务重复
if (_unitWork.IsExit<TaskHeader>(x => x.ZoneCode.Equals(ZoneCodeEnum.散料库) && x.ContainerCode.Equals(boxCode)))
{
return JsonMore(null, 500, $"库内已存在{boxCode}的任务,请勿重复操作!");
};
// 判断箱号是否合理
var box = _unitWork.FindSingle<Location>(x => x.ContainerCode.Equals(boxCode));
if (box != null)
{
if (box.Type != LocationTypeEnum.散料库站台)
{
return JsonMore(null, 500, $"{boxCode}不在站台,无法入库!");
}
return JsonMore(null);
}
else
{
return JsonMore(null, 500, $"{boxCode}不正确!");
}
}
/// <summary>
/// 扫描唯一码,并验证,返回入库单明细
/// </summary>
@@ -82,10 +113,117 @@ public class ReceiptSLInController : BaseController
{
if (receiptDetail.Status == ReceiptStatusEnum.收完)
{
return JsonMore(null, 500, $"{uniqueCode}已绑定,无需重新绑定!");
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();
// 查找明细,修改对应状态,并且 绑定物料周转箱
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.收完;
}
}
// 新建库存
var inventory = new Inventory
{
ZoneCode = ZoneCodeEnum.散料库,
UniqueCode = item.UniqueCode,
Qty = item.BindQty,
Lot = item.Size.ToString(),
ContainerCode = item.BoxCode,
TaskStatus = InventoryTaskStatus.任务中
};
_unitWork.Add(inventory);
}
_unitWork.BatchUpdate(receiptHeaderList.ToArray());
return JsonMore(null);
}
/// <summary>
/// 散料箱回库
/// </summary>
/// <param name="boxCode"></param>
/// <param name="isFull"></param>
/// <returns></returns>
[HttpPost]
public ActionResult BoxBack(string boxCode, bool isFull)
{
// 判断任务重复
if(!_unitWork.IsExit<TaskHeader>(x => x.ZoneCode.Equals(ZoneCodeEnum.散料库) && x.ContainerCode.Equals(boxCode))){
return JsonMore(null, 500, $"库内已存在{boxCode}的任务,请勿重复操作!");
};
// 判断箱号是否合理
var box = _unitWork.FindSingle<Location>(x => x.ContainerCode.Equals(boxCode));
if (box != null)
{
if(box.Type != LocationTypeEnum.散料库站台)
{
return JsonMore(null, 500, $"{boxCode}不在站台,无法入库!");
}
else
{
// 查找目标库位
var toLocation = _unitWork.FindSingle<Location>(x => x.Status.Equals(LocationStatus.空仓位)
&& x.Type.Equals(LocationTypeEnum.散料库位)
&& x.Row.Equals(box.Row));
if (toLocation != null)
{
// 创建任务
var task = new TaskHeader
{
ZoneCode = ZoneCodeEnum.散料库,
TaskNo = _unitWork.GetSerialNumber("CIn"),
TaskType = TaskTypeEnum.散料盒入库,
ContainerCode = boxCode,
FromLocation = box.Code,
ToLocation = toLocation.Code,
Status = TaskStatusEnum.新建,
CreateBy = Wtm.LoginUserInfo.ITCode,
CreateTime = DateTime.Now
};
_unitWork.Add(task);
toLocation.Status = LocationStatus.任务锁;
toLocation.Length = isFull ? 1 : 0; // 是否满盘
_unitWork.Update(toLocation);
}
else
{
return JsonMore(null, 500, $"库内无可用仓位,无法入库!");
}
}
return JsonMore(data: null);
}
else
{
return JsonMore(null, 500, $"{boxCode}不正确!");
}
}
}
@@ -133,7 +133,7 @@
data: { data: _this.bindingData },
url: "/receipt/ReceiptIn/BindingData",
success: function (json) {
if (json.Success) {
if (json.Code == 200) {
_this.$message({
message: '绑定成功!'
});
@@ -5,7 +5,8 @@
<el-col :span="16">
<el-form-item label="散料盒编码">
<el-input v-model="form.code"
placeholder="请扫描散料盒编码">
placeholder="请扫描散料盒编码"
@@change="scanBox">
</el-input>
</el-form-item>
</el-col>
@@ -28,12 +29,19 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="唯一码" prop="uniqueCode">
<el-input v-model="form.uniqueCode"
@@change="scanUniqueCode"
ref="uniqueCode">
</el-input>
</el-form-item>
<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-col :span="6">
<el-form-item label="满盘">
<el-switch v-model="form.isFull"></el-switch>
</el-form-item>
</el-col>
<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">
@@ -72,6 +80,7 @@
<el-form-item style="float: right">
<el-button type="primary" @@click="onSubmit">绑定</el-button>
<el-button @@click="resetForm('form')">重置</el-button>
<el-button type="primary" @@click="back">回库</el-button>
</el-form-item>
</el-form>
</el-card>
@@ -86,6 +95,7 @@
code: "",
size: "",
uniqueCode: "",
isFull: false
},
boxSize: [
{ label: "8mm", value: "8" },
@@ -114,6 +124,7 @@
// });
},
methods: {
// 呼叫料箱
callBox() {
var _this = this;
$.ajax({
@@ -144,10 +155,40 @@
},
});
},
// 扫描散料箱
scanBox(data) {
var _this = this;
$.ajax({
type: "post",
dataType: "json",
data: { boxCode: _this.form.code },
url: "/receipt/ReceiptSLIn/ScanBox",
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "扫描失败!" + json.Msg,
type: "warning",
duration: "10000",
});
}
else {
_this.$refs.uniqueCode.focus();
}
},
error: function (json) {
_this.$message({
message: "扫描失败!",
type: "error",
duration: "10000",
});
},
});
},
sizeFormatter(row) {
var rr = this.boxSize.filter((item) => item.value == row.size)[0].label;
return rr;
},
// 绑定
onSubmit() {
var _this = this;
console.log("submit!");
@@ -158,13 +199,13 @@
type: "post",
dataType: "json",
data: { data: _this.bindingData },
url: "/receipt/ReceiptIn/BindingData",
url: "/receipt/ReceiptSLIn/BindingData",
success: function (json) {
if (json.Success) {
if (json.Code == 200) {
_this.$message({
message: "绑定成功!",
});
_this.resetForm("form");
_this.bindingData = [];
} else {
_this.$message({
message: "绑定失败!",
@@ -182,15 +223,12 @@
},
});
},
// 重置
resetForm(formName) {
this.$refs[formName].resetFields();
this.boxSize = [];
this.bindingData = [];
},
// 扫描散料箱
scanBox(data) {
this.$refs.uniqueCode.focus();
},
// 选择尺寸后
changeSize() {
this.$refs.uniqueCode.focus();
@@ -227,13 +265,14 @@
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "扫描失败!" + json.Msg,
message: json.Msg,
type: "warning",
duration: "10000",
});
} else {
// 3.已扫描增加
_this.bindingData.push({
receiptCode: json.Data.ReceiptHeaderId,
boxCode: _this.form.code,
uniqueCode: data,
qty: json.Data.Qty - json.Data.CompletedQty,
@@ -271,6 +310,46 @@
this.bindingData[index].bindQty = row.qty;
}
},
// 回库
back() {
var _this = this;
// 创建回库任务
if (_this.code == "") {
_this.$message({
message: "箱号为空,不能创建回库任务!",
type: "error",
duration: "1000",
});
return;
}
$.ajax({
type: "post",
dataType: "json",
data: { boxCode: _this.form.code, isFull: _this.form.isFull },
url: "/receipt/ReceiptSLIn/BoxBack",
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "回库任务创建失败!" + json.Msg,
type: "warning",
duration: "10000",
});
} else {
_this.$message({
message: "回库任务创建成功!"
});
_this.resetForm('form');
}
},
error: function (json) {
_this.$message({
message: "回库任务创建失败!",
type: "error",
duration: "10000",
});
},
});
}
},
});
</script>
+37
View File
@@ -291,6 +291,43 @@ namespace HHWMS.Web.Models
}
/// <summary>
/// 区域
/// </summary>
public static class LocationTypeEnum
{
/// <summary>
/// 盘料库位 = "L";
/// </summary>
public const string 盘料库位 = "L";
/// <summary>
/// 料塔 = "T";
/// </summary>
public const string 料塔 = "T";
/// <summary>
/// 机械臂工位 = "G2";
/// </summary>
public const string 机械臂工位 = "G2";
/// <summary>
/// 堆垛机工位 = "G1";
/// </summary>
public const string 堆垛机工位 = "G1";
/// <summary>
/// 散料库 = "C";
/// </summary>
public const string 散料库位 = "C";
/// <summary>
/// 散料库站台 = "C1";
/// </summary>
public const string 散料库站台 = "C1";
}
/// <summary>
/// 站台类型
/// </summary>
+7
View File
@@ -25,6 +25,10 @@ namespace HHWMS.Web.Models
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
public string LocationCode { get; set; }
[Display(Name = "Inventory.UniqueCode", Description = "唯一编码")]
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
public string UniqueCode { get; set; }
[Display(Name = "Inventory.MaterialCode", Description = "物料编码")]
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
public string MaterialCode { get; set; }
@@ -95,5 +99,8 @@ namespace HHWMS.Web.Models
[Display(Name = "Inventory.TaskStatus", Description = "任务状态")]
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
public string TaskStatus { get; set; }
[Display(Name = "Inventory.Flag", Description = "格数")]
public int Flag { get; set; }
}
}
+1
View File
@@ -33,6 +33,7 @@ namespace HHWMS.Web
int Update<T>(T entity) where T : class;
int BatchUpdate<T>(T[] entities) where T : class;
/// <summary>
/// 根据条件更新
/// </summary>
+21
View File
@@ -111,6 +111,27 @@ namespace HHWMS.Web
return _data.SaveChanges();
}
public int BatchUpdate<T>(T[] entities) where T : class
{
foreach (T entity in entities)
{
//自动设定添加日期和添加人
if (typeof(T).IsSubclassOf(typeof(BasePoco)))
{
if ((entity as BasePoco).CreateTime == null)
{
(entity as BasePoco).CreateTime = DateTime.Now;
}
if (string.IsNullOrEmpty((entity as BasePoco).CreateBy))
{
(entity as BasePoco).CreateBy = _info?.ITCode;
}
}
}
_data.Set<T>().UpdateRange(entities);
return _data.SaveChanges();
}
public int BatchUpdate<T>(Expression<Func<T, bool>> where, Expression<Func<T, T>> entity) where T : class
{
/*if (typeof(T).IsSubclassOf(typeof(BasePoco)))