接口, 出库,任务下发

This commit is contained in:
zgf committed 2023-09-05 00:47:02 +08:00
1 parent f5423e78fe
commit 5c13b2a85c
38 files changed
+22919 -115

No files matched your search

@@ -0,0 +1,158 @@
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;
namespace HHWMS.Web.Controllers;
[Area("shipment")]
[ActionDescription("出库操作")]
public class ShipOutController : BaseController
{
private readonly IUnitWork _unitWork;
public ShipOutController(IUnitWork unitWork)
{
_unitWork = unitWork;
}
#region Search
[ActionDescription("Sys.Search")]
public ActionResult Index()
{
return PartialView("Index");
}
#endregion
/// <summary>
/// 扫描散料箱/盘料周转箱 返回待出库明细
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
[HttpPost]
public ActionResult ScanBox(string code)
{
// 判断箱号是否合理
var box = _unitWork.FindSingle<Location>(x => x.Code.Equals(code));
if (box != null)
{
if (box.Type == LocationTypeEnum.散料库站台 || box.Type == LocationTypeEnum.料塔)
{
var inv = _unitWork.Find<Inventory>(x => x.LocationCode.Equals(code));
return JsonMore(inv);
}
else
{
return JsonMore(null, 500, $"{code}不在站台!");
}
}
else
{
return JsonMore(null, 500, $"{code}不正确!");
}
}
/// <summary>
/// 扫描唯一码,并验证
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
[HttpPost]
public ActionResult ScanUniqueCode(string code)
{
// 判断唯一码是否在 出库站台 料塔 或 抽屉
var stationList = _unitWork.Find<Location>(x => x.Type.Equals(LocationTypeEnum.散料库站台)
|| x.Type.Equals(LocationTypeEnum.料塔))
.Select(x => x.Code).ToList();
var inv = _unitWork.FindSingle<Inventory>(x => x.UniqueCode.Equals(code)
&& stationList.Contains(x.LocationCode));
if (inv != null)
{
return JsonMore(inv);
}
return JsonMore(null, 500, $"{code}不存在!");
}
[HttpPost]
public ActionResult Pick(string uniqueCode, decimal qty)
{
var inv = _unitWork.FindSingle<Inventory>(x => x.UniqueCode.Equals(uniqueCode));
if (inv != null)
{
// 删除库存,扣账,记录库存交易 todo
_unitWork.Delete(inv);
return JsonMore(inv);
}
return JsonMore(null, 500, $"{uniqueCode}不存在!");
}
/// <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}不正确!");
}
}
}
@@ -0,0 +1,246 @@
<el-row id="outapp">
<el-card class="box-card" :span="16">
<el-form ref="form" :model="form" label-width="100px">
<el-row>
<el-col :span="4">
<el-form-item label="类型" prop="type">
<el-select v-model="type"
placeholder="请选择类型"
style="width: 100%"
clearable>
<el-option v-for="item in taskType"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="16">
<el-input v-model="form.code"
placeholder="请扫描"
@@change="scanCode">
</el-input>
</el-col>
</el-row>
<el-row v-show="showTable">
<el-divider></el-divider>
<el-table :data="invTable" height="400" stripe border @@row-click="selectdata"
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="MaterialSpec"></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>
<el-divider></el-divider>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="唯一码" prop="uniqueCode">
<el-input v-model="form.uniqueCode" ref="uniqueCode"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物料码" prop="materialCode">
<el-input v-model="form.materialCode" readonly></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="规格型号" prop="materialSpec">
<el-input v-model="form.materialSpec" readonly></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="批次" prop="batch">
<el-input v-model="form.batch" readonly></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="数量" prop="qty">
<el-input v-model.number="form.qty" ref="qty" ></el-input>
</el-form-item>
</el-col>
<el-form-item style="float:right">
<el-button type="primary" @@click="onSubmit">拣货</el-button>
</el-form-item>
</el-row>
<el-row v-show="form.type=='slbox'">
<el-divider></el-divider>
<el-form-item style="float: right">
<el-button type="primary" @@click="back">回库</el-button>
</el-form-item>
</el-row>
</el-form>
</el-card>
</el-row>
<script>
var app = new Vue({
el: "#outapp",
data() {
return {
form: {
code: "",
uniqueCode: "",
materialCode: "",
materialSpec: "",
batch: "",
qty: ""
},
type: "",
taskType: [
{ label: "散料箱", value: "slbox" },
{ label: "料塔周转箱", value: "lt" },
{ label: "唯一码", value: "uniqueCode" },
],
invTable:[],
showTable: false
};
},
methods: {
// 选中行
selectdata(data) {
this.form.uniqueCode = data.UniqueCode;
this.form.materialCode = data.MaterialCode;
this.form.materialSpec = data.MaterialSpec;
this.form.batch = data.Batch;
this.form.qty = data.Qty;
},
// 扫描
scanCode(data) {
var _this = this;
if (_this.type == "") {
_this.$message({
message: "请先选择操作类型!",
type: "warning",
duration: "10000",
});
_this.form.code = "";
return;
}
let url = "";
if (_this.type == "uniqueCode") {
url = "/shipment/ShipOut/ScanUniqueCode"
}
else{
url = "/shipment/ShipOut/ScanBox"
}
$.ajax({
type: "post",
dataType: "json",
data: { code: _this.form.code },
url: url,
success: function (json) {
if (json.Code != 200) {
_this.$message({
message: "扫描失败!" + json.Msg,
type: "warning",
duration: "10000",
});
} else {
if (_this.type == "uniqueCode") {
_this.form.uniqueCode = json.Data.UniqueCode;
_this.form.materialCode = json.Data.MaterialCode;
_this.form.materialSpec = json.Data.MaterialSpec;
_this.form.batch = json.Data.Batch;
_this.form.qty = json.Data.Qty;
} else {
_this.showTable = true;
_this.invTable = json.Data;
}
}
},
error: function (json) {
_this.$message({
message: "扫描失败!",
type: "error",
duration: "10000",
});
},
});
},
// 拣货
onSubmit() {
var _this = this;
// 提交已绑定数据
$.ajax({
type: "post",
dataType: "json",
data: { uniqueCode: _this.form.uniqueCode, qty: _this.form.qty },
url: "/shipment/ShipOut/Pick",
success: function (json) {
if (json.Code == 200) {
_this.$message({
message: "拣货成功!",
});
// 删除invTable 对应的 uniqueCode行
_this.invTable.forEach(function (value, index, arr) {
if (value.UniqueCode == _this.form.uniqueCode) {
arr.splice(index, 1);
}
});
_this.$refs['form'].resetFields();
} else {
_this.$message({
message: "提交失败!",
type: "warning",
duration: "10000",
});
}
},
error: function (json) {
_this.$message({
message: "提交失败!",
type: "error",
duration: "10000",
});
},
});
},
// 回库
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: "/shipment/ShipOut/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>