散料入库

This commit is contained in:
zgf committed 2023-08-23 04:10:59 +08:00
1 parent 630e33a27a
commit 2097bffabb
6 files changed
+388 -247

No files matched your search

+4 -4
View File
@@ -154,7 +154,7 @@ namespace HHWMS.Web
var taskfromlocatioin = _unitwork.FindSingle<Location>(x => x.Code.Equals(task.FromLocation));
switch (task.TaskType)
{
case TaskTypeEnum.料盒入库:
case TaskTypeEnum.盘料盒入库:
// 更新库位
// 起始库位为空
// 目标库位为有货
@@ -163,7 +163,7 @@ namespace HHWMS.Web
// 测试 创建料盒出库任务
newTask.ZoneCode = "L";
newTask.TaskNo = _unitwork.GetSerialNumber("out", 4);
newTask.TaskType = TaskTypeEnum.料盒出库;
newTask.TaskType = TaskTypeEnum.盘料盒出库;
newTask.ContainerCode = task.FromLocation;
newTask.FromLocation = task.ToLocation;
newTask.ToLocation = task.FromLocation;
@@ -171,7 +171,7 @@ namespace HHWMS.Web
//newTask.Station = task.Station;
_unitwork.Add(newTask);
break;
case TaskTypeEnum.料盒出库:
case TaskTypeEnum.盘料盒出库:
// 更新库位
// 起始库位为空
// 目标库位为有货
@@ -218,7 +218,7 @@ namespace HHWMS.Web
var fromL = _unitwork.FindSingle<Location>(x => x.Row.Equals(tasktolocatioin.Row) && x.Type == "G1");
newTask.ZoneCode = "L";
newTask.TaskNo = _unitwork.GetSerialNumber("in", 4);
newTask.TaskType = TaskTypeEnum.料盒入库;
newTask.TaskType = TaskTypeEnum.盘料盒入库;
newTask.ContainerCode = fromL.Code;
newTask.FromLocation = fromL.Code;
newTask.ToLocation = "L01-01-19-01";
@@ -1,35 +1,91 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Linq;
using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Mvc;
using WalkingTec.Mvvm.Core.Extensions;
using HHWMS.Web;
using HHWMS.Web.Models;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using Newtonsoft.Json;
using System.Collections.Generic;
namespace HHWMS.Web.Controllers
namespace HHWMS.Web.Controllers;
[Area("receipt")]
[ActionDescription("散料操作")]
public class ReceiptSLInController : BaseController
{
[Area("receipt")]
[ActionDescription("散料操作")]
public partial class ReceiptSLInController : BaseController
private readonly IUnitWork _unitWork;
public ReceiptSLInController(IUnitWork unitWork)
{
private readonly IUnitWork _unitwork;
public ReceiptSLInController(IUnitWork unitwork)
{
_unitwork = unitwork;
}
#region Search
[ActionDescription("Sys.Search")]
public ActionResult Index()
{
return PartialView("Index");
}
_unitWork = unitWork;
}
#endregion
#region Search
[ActionDescription("Sys.Search")]
public ActionResult Index()
{
return PartialView("Index");
}
#endregion
[HttpPost]
public ActionResult CallBox()
{
// 查询站台占用
var stations = _unitWork.Find<Location>(x => (x.Code == StationCode.散料库左抽屉
|| x.Code == StationCode.散料库右抽屉)
&& x.Status != LocationStatus.任务锁).ToList();
if (stations.Count == 0) return JsonMore(null, 500, "无可用站台!");
// 查找没任务的仓位,分两边查,那边站台能用 查哪边
var box = _unitWork.Find<Location>(x => (x.ZoneCode == ZoneCodeEnum.散料库)
& (x.Status != LocationStatus.任务锁)
&& x.Status != LocationStatus.满货
&& x.Status != LocationStatus.空仓位
&& x.Row == stations.First().Row).FirstOrDefault();
if (box == null && stations.Count == 2)
box = _unitWork.Find<Location>(x => (x.ZoneCode == ZoneCodeEnum.散料库)
& (x.Status != LocationStatus.任务锁)
&& x.Status != LocationStatus.满货
&& x.Status != LocationStatus.空仓位
&& x.Row == stations.Last().Row).FirstOrDefault();
if (box == null) return JsonMore(null, 500, "库内没有可用散料箱!");
var toLocation = box.Row == 1 ? StationCode.散料库右抽屉 : StationCode.散料库左抽屉;
// 创建任务
var task = new TaskHeader
{
ZoneCode = ZoneCodeEnum.散料库,
TaskNo = _unitWork.GetSerialNumber("SOut"),
TaskType = TaskTypeEnum.散料盒出库,
ContainerCode = box.ContainerCode,
FromLocation = box.Code,
ToLocation = toLocation,
Status = TaskStatusEnum.新建,
CreateTime = DateTime.Now,
CreateBy = Wtm.LoginUserInfo.ITCode
};
_unitWork.Add(task);
return JsonMore(null);
}
/// <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}不存在!");
}
}
@@ -1,133 +1,158 @@
<el-row id="slapp" :gutter="20">
<el-col :span="6">
<el-card class="box-card" :span="8">
<el-select v-model="value" clearable filterable placeholder="请选择单据" size="big" style="width:100%"
@@change="changeselect" @@clear="clearReceipt">
<el-option v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-table :data="tableData" height="700" border
style="width: 100%">
<el-table-column prop="name"
label="唯一码"
align="center">
<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="散料盒编码">
<el-input v-model="form.code"
placeholder="请扫描散料盒编码">
</el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item style="float: left">
<el-button type="primary" @@click="callBox">呼叫料盒</el-button>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="尺寸" prop="size">
<el-select v-model="form.size"
placeholder="请选择料盘尺寸"
style="width: 100%"
@@change="changeSize"
clearable>
<el-option v-for="item in boxSize"
:key="item.value"
:label="item.label"
:value="item.value">
</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-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="boxCode">
</el-table-column>
<el-table-column label="唯一码"
align="center"
prop="uniqueCode">
</el-table-column>
<el-table-column label="数量"
align="center"
prop="qty" v-if="false">
</el-table-column>
<el-table-column label="数量"
align="center"
prop="bindQty">
<template slot-scope="scope">
<el-input size="small" v-model="scope.row.bindQty" @@change="handleEdit(scope.$index, scope.row)"></el-input>
</template>
</el-table-column>
<el-table-column label="尺寸"
align="center"
prop="size"
:formatter="sizeFormatter">
</el-table-column>
</el-table>
</el-card>
</el-col>
<el-col :span="18">
<el-card class="box-card" :span="16">
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="单据名称">
<el-input v-model="form.code" readonly></el-input>
</el-form-item>
<el-form-item label="周转箱编码" prop="boxCode">
<el-input v-model="form.boxCode" @@change="scanBox"></el-input>
</el-form-item>
<el-form-item label="料盘尺寸" prop="size">
<el-select v-model="form.size" placeholder="请选择料盘尺寸" style="width:100%" @@change="changeSize" clearable>
<el-option v-for="item in form.boxSize"
:key="item.value"
:label="item.label"
:value="item.value">
</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-table :data="bindingData" 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="receiptCode" v-if="false"></el-table-column>
<el-table-column label="周转箱" align="center" prop="boxCode"></el-table-column>
<el-table-column label="索引" align="center" prop="index"></el-table-column>
<el-table-column label="唯一码" align="center" prop="uniqueCode"></el-table-column>
<el-table-column label="料盘尺寸" align="center" prop="size" :formatter="sizeFormatter"></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-col>
<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',
el: "#slapp",
data() {
var validatePass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入周转箱编码'));
}
else if (value == 'M00000001' || value == 'M00000002' || value == 'E00000001' || value == 'E00000002') {
callback();
} else {
callback(new Error('请输入正确周转箱编码'));
}
};
return {
form: {
code: '',
boxCode: '',
boxSize: [],
size: '',
uniqueCode: ''
code: "",
size: "",
uniqueCode: "",
},
options: [],
value: '',
tableData: [],
boxSize: [
{ label: "8mm", value: "8" },
{ label: "10mm", value: "10" },
{ label: "16mm", value: "16" },
{ label: "24mm", value: "24" },
{ label: "散料", value: "1" },
],
bindingData: [],
dataIndex:[],
rules: {
boxCode: [
{ validator: validatePass, trigger: 'blur' }
]
}
}
qty: ''
};
},
mounted: function() {
mounted: function () {
// 获取所有单据编码
$.ajax({
type: "post",
dataType: "json",
data:{},
url: "/receipt/ReceiptIn/SelectReceiptCode",
success: function (json) {
app.options = json.Data;
},
error: function (json) {
alert("加载失败");
}
});
// $.ajax({
// type: "post",
// dataType: "json",
// data:{},
// url: "/receipt/ReceiptIn/SelectReceiptCode",
// success: function (json) {
// app.options = json.Data;
// },
// error: function (json) {
// alert("加载失败");
// }
// });
},
methods: {
callBox() {
var _this = this;
$.ajax({
type: "post",
dataType: "json",
data: {},
url: "/receipt/ReceiptSLIn/CallBox",
success: function (json) {
if (json.Code == 200) {
_this.$message({
message: "呼叫成功!",
});
// _this.resetForm('form');
} else {
_this.$message({
message: "呼叫失败!" + json.Msg,
type: "warning",
duration: "10000",
});
}
},
error: function (json) {
_this.$message({
message: "呼叫失败!",
type: "error",
duration: "10000",
});
},
});
},
sizeFormatter(row) {
return row.size + 'mm';
var rr = this.boxSize.filter((item) => item.value == row.size)[0].label;
return rr;
},
onSubmit() {
var _this = this;
console.log('submit!');
console.log("submit!");
console.log(this.form);
// 提交已绑定数据
$.ajax({
type: "post",
@@ -137,85 +162,33 @@
success: function (json) {
if (json.Success) {
_this.$message({
message: '绑定成功!'
message: "绑定成功!",
});
_this.resetForm('form');
}
else{
_this.resetForm("form");
} else {
_this.$message({
message: '绑定失败!',
type: 'warning'
message: "绑定失败!",
type: "warning",
duration: "10000",
});
}
},
error: function (json) {
_this.$message({
message: '绑定失败!',
type: 'error'
message: "绑定失败!",
type: "error",
duration: "10000",
});
}
},
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
this.form.boxSize = [];
this.boxSize = [];
this.bindingData = [];
},
clearReceipt() {
this.tableData = [];
},
// 选择单据后,查询明细
changeselect(data) {
var _this = this;
_this.form.code = data;
// 调用后台方法,查询单据明细数据
if (data != "") {
$.ajax({
type: "post",
dataType: "json",
data: { Code: data },
url: "/receipt/ReceiptIn/SelectReceipt",
success: function (json) {
_this.tableData = json.Data;
// 对比待绑定列表,删除在其表内的明细
_this.bindingData.forEach(function (item) {
_this.tableData.forEach(function (value, index, arr) {
if (value.name == item.uniqueCode) {
arr.splice(index, 1);
}
});
})
console.log(json.Data);
},
error: function (json) {
_this.$message({
message: '加载单据明细失败!',
type: 'error'
});
}
});
}
},
// 扫描周转箱
scanBox(data){
this.form.size = '';
this.form.boxSize = [];
if (data == "M00000001" || data == "M00000002") {
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];
}
else if (data == "E00000001" || data == "E00000002") {
this.form.boxSize = [{ label: "10mm", value: "10" }, { label: "16mm", value: "16" }, { label: "24mm", value: "24" }];
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;
}
// 扫描散料箱
scanBox(data) {
this.$refs.uniqueCode.focus();
},
// 选择尺寸后
@@ -224,57 +197,80 @@
},
// 扫描唯一码
scanUniqueCode(data) {
if (this.dataIndex.length == 0) {
var _this = this;
// 1. 判断条件
if (this.form.code == "" || this.form.size == "") {
this.$message({
message: '该周转箱已放满!',
type: 'warning'
message: "请先扫描料箱箱编码并选择物料尺寸!",
type: "warning",
});
this.form.uniqueCode = '';
this.form.uniqueCode = "";
return;
}
if (this.form.boxCode == '' || this.form.size == '') {
this.$message({
message: '请先输入周转箱编码并选择料盘尺寸!',
type: 'warning'
});
this.form.uniqueCode = '';
return;
}
var isExit = this.tableData.findIndex(function (value, index, arr) {
return value.name == data;
//2. 判断唯一码是否合理,调用后台,并返回唯一码对应的数量
var isExit = this.bindingData.findIndex(function (value) {
return value.uniqueCode == data;
})
if (isExit == -1) {
if (isExit != -1) {
this.$message({
message: '唯一码'+ data + '不正确!',
message: '唯一码' + data + '已绑定!',
type: 'warning'
});
this.form.uniqueCode = '';
return;
}
// 1.明细减少
this.tableData.forEach(function (item, index, arr) {
if (item.name == data) {
arr.splice(index, 1);
}
$.ajax({
type: "post",
dataType: "json",
data: { uniqueCode: _this.form.uniqueCode },
url: "/receipt/ReceiptSLIn/ScanUniqueCode",
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "扫描失败!" + json.Msg,
type: "warning",
duration: "10000",
});
} else {
// 3.已扫描增加
_this.bindingData.push({
boxCode: _this.form.code,
uniqueCode: data,
qty: json.Data.Qty - json.Data.CompletedQty,
bindQty: json.Data.Qty - json.Data.CompletedQty,
size: _this.form.size,
});
}
},
error: function (json) {
_this.$message({
message: "扫描失败!",
type: "error",
duration: "10000",
});
},
});
// 2.已扫描增加
this.bindingData.push({
receiptCode: this.form.code,
boxCode: this.form.boxCode,
index: this.dataIndex.shift(),
uniqueCode : data,
size: this.form.size
})
this.form.uniqueCode = '';
this.form.uniqueCode = "";
},
// 删除已绑定行
deleteRow(index, rows) {
if (this.form.code == rows[index].receiptCode) {
this.tableData.push({ name: rows[index].uniqueCode });
}
this.dataIndex.unshift(rows[index].index);
rows.splice(index, 1);
}
}
},
handleEdit(index, row) {
console.log(index, row, this.bindingData);
if (row.qty < row.bindQty) {
this.$message({
message: "数量不能大于剩余绑定数量!" + row.qty,
type: "warning",
duration: "1000",
});
this.bindingData[index].bindQty = row.qty;
}
else if (row.bindQty <= 0) {
this.bindingData[index].bindQty = row.qty;
}
},
},
});
</script>
@@ -42,6 +42,10 @@ namespace HHWMS.Web
{
task.ErrorMsg += ex.Message;
}
if(task.TaskDetails.Count(x => x.Status == TaskStatusEnum.新建) == 0)
{
task.Status = TaskStatusEnum.已下发;
}
_unitwork.Update(task);
}
@@ -79,8 +83,8 @@ namespace HHWMS.Web
// 根据不同任务类型 创建任务
switch (task.TaskType)
{
case TaskTypeEnum.料盒入库:
case TaskTypeEnum.料盒出库:
case TaskTypeEnum.盘料盒入库:
case TaskTypeEnum.盘料盒出库:
var taskInfo = new TaskInfo();
taskInfo.TaskType = (int)task.TaskType;
taskInfo.TaskId = task.TaskNo;
+84 -3
View File
@@ -29,13 +29,13 @@ namespace HHWMS.Web.Models
/// 入库任务
/// </summary>
[Display(Name = "TaskType.In")]
料盒入库 = 1,
盘料盒入库 = 1,
/// <summary>
/// 出库任务
/// </summary>
[Display(Name = "TaskType.Out")]
料盒出库 = 2,
盘料盒出库 = 2,
/// <summary>
/// 盘料入库
@@ -47,7 +47,19 @@ namespace HHWMS.Web.Models
/// 盘料出库
/// </summary>
[Display(Name = "TaskType.POut")]
盘料出库 = 4
盘料出库 = 4,
/// <summary>
/// 散料入库
/// </summary>
[Display(Name = "TaskType.SIn")]
散料盒入库 = 5,
/// <summary>
/// 散料出库
/// </summary>
[Display(Name = "TaskType.SOut")]
散料盒出库 = 6
}
/// <summary>
@@ -145,6 +157,11 @@ namespace HHWMS.Web.Models
/// </summary>
public const string 有货 = "some";
/// <summary>
/// 满货 = "full";
/// </summary>
public const string 满货 = "full";
/// <summary>
/// 空容器 = "emptyContainer"
/// </summary>
@@ -257,6 +274,70 @@ namespace HHWMS.Web.Models
}
/// <summary>
/// 区域
/// </summary>
public static class ZoneCodeEnum
{
/// <summary>
/// 盘料库 = "L";
/// </summary>
public const string 盘料库 = "L";
/// <summary>
/// 散料库 = "C";
/// </summary>
public const string 散料库 = "C";
}
/// <summary>
/// 站台类型
/// </summary>
public static class StationCode
{
/// <summary>
/// 散料库左抽屉 = "C02-02-18-02";
/// </summary>
public const string 散料库左抽屉 = "C02-02-18-02";
/// <summary>
/// 散料库右抽屉 = "C02-01-18-02";
/// </summary>
public const string 散料库右抽屉 = "C02-01-18-02";
/// <summary>
/// 盘料库左工位 = "L01-02-34-02";
/// </summary>
public const string 盘料库左工位 = "L01-02-34-02";
/// <summary>
/// 盘料库右工位 = "L01-01-34-02";
/// </summary>
public const string 盘料库右工位 = "L01-01-34-02";
/// <summary>
/// 左料塔 = "L01";
/// </summary>
public const string 左料塔 = "L01";
/// <summary>
/// 右料塔 = "L02";
/// </summary>
public const string 右料塔 = "L02";
/// <summary>
/// 左料塔工位 = "L01-01";
/// </summary>
public const string 左料塔工位 = "L01-01";
/// <summary>
/// 右料塔工位 = "L01-02";
/// </summary>
public const string 右料塔工位 = "L01-02";
}
/// <summary>
/// 料塔类型
/// </summary>
+6 -2
View File
@@ -26,6 +26,10 @@ namespace HHWMS.Web.Models
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
public string MaterialCode { get; set; }
[Display(Name = "Inventory.UniqueCode", Description = "唯一编码")]
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
public string UniqueCode { get; set; }
[Display(Name = "Inventory.MaterialType", Description = "物料类型")]
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
public string MaterialType { get; set; }
@@ -65,11 +69,11 @@ namespace HHWMS.Web.Models
[Display(Name = "Receipt.CompletedQty", Description = "完成数量")]
[Column(TypeName = "decimal(12,4)")]
public decimal? CompletedQty { get; set; }
public decimal? CompletedQty { get; set; } = Decimal.Zero;
[Display(Name = "Inventory.Qty", Description = "数量")]
[Column(TypeName = "decimal(12,4)")]
public decimal? Qty { get; set; }
public decimal? Qty { get; set; } = Decimal.Zero;
[Display(Name = "Inventory.Status", Description = "物料状态")]
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]