Author SHA1 Message Date
zhougf 8606f7abcb 重写了 出库任务生成盒下发流程
修改了部分页面的查询条件
2024-05-16 02:38:16 +08:00
44 changed files with 319 additions and 472 deletions

No files matched your search

-2
View File
@@ -1,6 +1,4 @@
# wtm custom
.DS_Store
Desktop.ini
demo/WalkingTec.Mvvm.Demo/wwwroot/layuiadminsrc
.Publish/
+5 -8
View File
@@ -202,7 +202,7 @@ namespace HHWMS.Web
{
// 下发盘料出库
var plcTaskList = _unitwork.Find<TaskHeader>(x => x.TaskType.Equals(TaskTypeEnum.盘料出库)
&& x.ContainerCode.Contains(task.ContainerCode))
&& x.ContainerCode.Contains(task.ContainerCode))
.Include(x => x.TaskDetails)
.ToList();
if (plcTaskList.Any())
@@ -236,7 +236,7 @@ namespace HHWMS.Web
// 更新目的仓位
var to = _unitwork.FindSingle<Location>(x => x.ContiguousCode == task.ToLocation
&& x.Type.Equals(LocationTypeEnum.机械臂工位))?.Code;
plrTask.ToLocation += $" {to}";
plrTask.ToLocation = to;
// 更新明细为待下发
var details = plrTask.TaskDetails.Where(x => !string.IsNullOrEmpty(x.ContainerCode) && x.ContainerCode.Contains(task.ContainerCode));
@@ -270,11 +270,8 @@ namespace HHWMS.Web
{
var station = _unitwork.Find<Location>(x => x.Code == task.FromLocation).FirstOrDefault();
// 创建料盒入库任务
// 根据子任务容器编码,查找回库的任务起点,(主任务会有多个容器编码)
var fromLocation = _unitwork.FindSingle<Location>(x =>
x.ContainerCode.Equals(containerCode)
&& x.Type == LocationTypeEnum.堆垛机工位
).Code;
// 查找回库的任务起点,
var fromLocation = _unitwork.FindSingle<Location>(x => x.Code.Equals(task.ToLocation)).ContiguousCode;
newTask.ZoneCode = ZoneCodeEnum.盘料库;
if (task.TaskNo.Contains("PLoop"))
{
@@ -320,7 +317,7 @@ namespace HHWMS.Web
&& n.TaskStatus == InventoryTaskStatus.任务中).FirstOrDefault();
if (inv != null)
{
inv.ContainerCode = tolocation?.ContainerCode;
inv.ContainerCode = tolocation.ContainerCode;
inv.LocationCode = task.ToLocation;
inv.Lot = taskde.ToLocation;
_unitwork.Update(inv);
@@ -50,13 +50,13 @@ namespace HHWMS.Web
return data?.Text ?? a.ZoneCode;
}),
this.MakeGridHeader(x => x.Code, 120),
this.MakeGridHeader(x => x.Type,120)
this.MakeGridHeader(x => x.Type)
.SetFormat((a, b) =>
{
var data = Types.FirstOrDefault(x => x.Value.ToString() == a.Type);
return data?.Text ?? a.Type;
}),
this.MakeGridHeader(x => x.Status,120)
this.MakeGridHeader(x => x.Status)
.SetFormat((a, b) =>
{
var data = LocationStatus.FirstOrDefault(x => x.Value.ToString() == a.Status);
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
@@ -11,7 +10,7 @@ namespace HHWMS.Web
public String Code { get; set; }
[Display(Name = "Location.Type")]
public List<string> Type { get; set; }
public String Type { get; set; }
[Display(Name = "Location.Status")]
public String Status { get; set; }
@@ -19,7 +19,7 @@
<wt:display field="Entity.ContiguousCode" /> *@
</wt:row>
<wt:grid vm="@Model.Inventorys" height="300" hidden-checkbox="true" use-local-data="true" hidden-panel="true"/>
<wt:grid vm="@Model.Inventorys" height="300" hidden-checkbox="true" hidden-grid-index="true" use-local-data="true" hidden-panel="true"/>
<wt:row align="AlignEnum.Right">
<wt:closebutton />
@@ -5,7 +5,7 @@
<wt:row items-per-row="ItemsPerRowEnum.Three">
<wt:combobox field="Searcher.ZoneCode" items="ZoneCodes" />
<wt:textbox field="Searcher.Code" />
<wt:combobox field="Searcher.Type" items="Types" multi-select="true"/>
<wt:combobox field="Searcher.Type" items="Types" />
@*
<wt:combobox field="Searcher.Status" items="LocationStatus" />
<wt:textbox field="Searcher.Row" />
@@ -26,28 +26,27 @@ namespace HHWMS.Web
protected override IEnumerable<IGridColumn<InventoryTransaction_View>> InitGridHeader()
{
return new List<GridColumn<InventoryTransaction_View>>{
this.MakeGridHeader(x => x.ZoneCode,120),
this.MakeGridHeader(x => x.BillType,120),
this.MakeGridHeader(x => x.Type,230),
this.MakeGridHeader(x => x.ContainerCode).SetHide(),
this.MakeGridHeader(x => x.LocationCode,150),
this.MakeGridHeader(x => x.MaterialCode,120),
this.MakeGridHeader(x => x.MaterialType,120),
this.MakeGridHeader(x => x.MaterialName,120),
this.MakeGridHeader(x => x.MaterialSpec,120),
this.MakeGridHeader(x => x.MaterialUnit,120),
this.MakeGridHeader(x => x.Batch,120),
this.MakeGridHeader(x => x.ZoneCode),
this.MakeGridHeader(x => x.Type),
this.MakeGridHeader(x => x.ContainerCode),
this.MakeGridHeader(x => x.LocationCode),
this.MakeGridHeader(x => x.MaterialCode),
this.MakeGridHeader(x => x.MaterialType),
this.MakeGridHeader(x => x.MaterialName),
this.MakeGridHeader(x => x.MaterialSpec),
this.MakeGridHeader(x => x.MaterialUnit),
this.MakeGridHeader(x => x.Batch),
this.MakeGridHeader(x => x.Lot),
this.MakeGridHeader(x => x.ManufactureDate).SetHide(),
this.MakeGridHeader(x => x.ExpirationDate).SetHide(),
this.MakeGridHeader(x => x.CompanyCode).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.Qty),
this.MakeGridHeader(x => x.BillType),
this.MakeGridHeader(x => x.SourceCode),
this.MakeGridHeader(x => x.BillCode),
this.MakeGridHeader(x => x.BillDetailId),
this.MakeGridHeader(x => x.Status).SetHide(),
this.MakeGridHeader(x => x.CreateTime,200),
this.MakeGridHeader(x => x.Status),
this.MakeGridHeaderAction(width: 200)
};
}
@@ -94,7 +93,6 @@ namespace HHWMS.Web
BillCode = x.BillCode,
BillDetailId = x.BillDetailId,
Status = x.Status,
CreateTime = x.CreateTime
})
.OrderBy(x => x.ID);
return query;
@@ -14,7 +14,7 @@ namespace HHWMS.Web
{
[Display(Name = "Task.ZoneCode")]
public String ZoneCode { get; set; }
[Display(Name = "Inventory.UniqueCode")]
[Display(Name = "InventoryTransaction.Type")]
public String Type { get; set; }
[Display(Name = "Task.ContainerCode")]
public String ContainerCode { get; set; }
@@ -57,31 +57,30 @@ namespace HHWMS.Web
}),
this.MakeGridHeader(x => x.UniqueCode).SetWidth(230),
this.MakeGridHeader(x => x.ContainerCode).SetHide(),
this.MakeGridHeader(x => x.LocationCode,150),
this.MakeGridHeader(x => x.MaterialCode,120),
this.MakeGridHeader(x => x.MaterialType,120),
this.MakeGridHeader(x => x.MaterialName,120),
this.MakeGridHeader(x => x.MaterialSpec,120),
this.MakeGridHeader(x => x.LocationCode),
this.MakeGridHeader(x => x.MaterialCode),
this.MakeGridHeader(x => x.MaterialType),
this.MakeGridHeader(x => x.MaterialName),
this.MakeGridHeader(x => x.MaterialSpec),
this.MakeGridHeader(x => x.MaterialUnit),
this.MakeGridHeader(x => x.Batch,120),
this.MakeGridHeader(x => x.Lot,80),
this.MakeGridHeader(x => x.Batch),
this.MakeGridHeader(x => x.Lot),
//this.MakeGridHeader(x => x.ManufactureDate),
//this.MakeGridHeader(x => x.ExpirationDate),
//this.MakeGridHeader(x => x.CompanyCode),
//this.MakeGridHeader(x => x.SupplierCode),
this.MakeGridHeader(x => x.TaskQty).SetHide(),
this.MakeGridHeader(x => x.Qty,80),
this.MakeGridHeader(x => x.Qty),
//this.MakeGridHeader(x => x.SourceCode),
//this.MakeGridHeader(x => x.ReceiptCode),
//this.MakeGridHeader(x => x.ReceiptDetailId),
//this.MakeGridHeader(x => x.Status),
this.MakeGridHeader(x => x.TaskStatus,120)
this.MakeGridHeader(x => x.TaskStatus)
.SetFormat((a, b) =>
{
var data = InventoryTaskStatus.FirstOrDefault(x => x.Value.ToString() == a.TaskStatus);
return data?.Text ?? a.TaskStatus;
}),
this.MakeGridHeader(x => x.CreateTime,220),
this.MakeGridHeaderAction(width: 200)
};
}
@@ -123,7 +122,7 @@ namespace HHWMS.Web
.CheckContain(Searcher.Lot, x => x.Lot)
.CheckContain(Searcher.SourceCode, x => x.SourceCode)
.CheckContain(Searcher.ReceiptCode, x => x.ReceiptCode)
.CheckContain(Searcher.TaskStatus, x => x.Status)
.CheckContain(Searcher.TaskStatus, x => x.TaskStatus)
.Select(x => new Inventory_View
{
ID = x.ID,
@@ -149,7 +148,6 @@ namespace HHWMS.Web
ReceiptDetailId = x.ReceiptDetailId,
Status = x.Status,
TaskStatus = x.TaskStatus,
CreateTime = x.CreateTime,
})
.OrderBy(x => x.ID);
return query;
@@ -6,7 +6,6 @@ using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using HHWMS.Web;
using HHWMS.Web.Models;
namespace HHWMS.Web
@@ -15,10 +14,13 @@ namespace HHWMS.Web
{
[Display(Name = "Task.ZoneCode")]
public String ZoneCode { get; set; }
[Display(Name = "Container.LocationCode")]
public String LocationCode { get; set; }
[Display(Name = "Inventory.TaskStatus", Description = "任务状态")]
public string TaskStatus { get; set; }
[Display(Name = "Inventory.UniqueCode")]
public String UniqueCode { get; set; }
[Display(Name = "Inventory.MaterialCode")]
@@ -17,7 +17,7 @@
<wt:textbox field="Searcher.Lot" />
<wt:textbox field="Searcher.SourceCode" />
<wt:textbox field="Searcher.ReceiptCode" />
<wt:textbox field="Searcher.Status" /> *@
*@
</wt:row>
</wt:searchpanel>
<wt:grid vm="@Model" url="/inventory/Inventory/Search"/>
@@ -267,8 +267,7 @@ namespace HHWMS.Web.Controllers
{
return JsonMore(null, 500, $"数量必须大于0!");
}
var receiptDetail = _unitwork.FindSingle<ReceiptDetail>(x => x.UniqueCode.Equals(uniqueCode)
&& x.ReceiptHeaderId.ToString() == code);
var receiptDetail = _unitwork.FindSingle<ReceiptDetail>(x => x.UniqueCode.Equals(uniqueCode));
if (receiptDetail != null)
{
receiptDetail.Qty = qty;
@@ -142,27 +142,6 @@ namespace HHWMS.Web.Controllers
{
try
{
// 先捡货,后入库
if (_unitWork.IsExit<Inventory>(x => !string.IsNullOrEmpty(x.SourceCode)
&& x.LocationCode == data.First().BoxCode))
{
return JsonMore(null, 500, "周转箱存在未捡货任务,请捡货完成后再执行入库操作!");
}
/*
//单据明细验证
var errDetails = _unitWork.Find<ReceiptDetail>(x => data.Select(x => x.UniqueCode).ToList()
.Contains(x.UniqueCode)
&& x.Status != ReceiptStatusEnum.新建).ToList();
if (errDetails.Any())
{
var msg = "以下明细不是新建状态:\n";
foreach (var errDetail in errDetails)
{
msg += $"{errDetail.UniqueCode}\n";
}
return JsonMore(null, 500, msg);
}*/
var receiptHeaderList = _unitWork.Find<ReceiptHeader>(x =>
data.Select(x => x.ReceiptCode).ToList().Contains(x.Code))
.Include(x => x.ReceiptDetails).ToList();
@@ -214,11 +193,8 @@ namespace HHWMS.Web.Controllers
}
var boxcode = data.First().BoxCode;
//根据提交的uniquecode,创建入库任务
var invList = _unitWork.Find<Inventory>(x =>
data.Select(y => y.UniqueCode).ToList().Contains(x.UniqueCode)
&& x.TaskStatus == InventoryTaskStatus.任务中
&& x.ContainerCode.Equals(boxcode))
//创建入库任务
var invList = _unitWork.Find<Inventory>(x => x.ContainerCode.Equals(boxcode))
.ToList();
if (invList.Count == 0)
{
@@ -159,28 +159,12 @@ public class ReceiptSLInController : BaseController
{
try
{
/*
var errDetails = _unitWork.Find<ReceiptDetail>(x => data.Select(x => x.UniqueCode).ToList()
.Contains(x.UniqueCode)
&& x.Status != ReceiptStatusEnum.新建).ToList();
if (errDetails.Any())
{
var msg = "以下明细不是新建状态:\n";
foreach (var errDetail in errDetails)
{
msg += $"{errDetail.UniqueCode}\n";
}
return JsonMore(null, 500, msg);
}
*/
// 查找明细,修改对应状态,并且 绑定物料周转箱
foreach (Binding item in data.OrderBy(x => x.ReceiptCode))
{
// 更新入库单明细状态
var header = receiptHeaderList.Find(x => x.ID.ToString().Equals(item.ReceiptCode));
var receipt = header.ReceiptDetails.FirstOrDefault(x => x.UniqueCode.Equals(item.UniqueCode)
&& x.Status == ReceiptStatusEnum.新建);
var receipt = header.ReceiptDetails.FirstOrDefault(x => x.UniqueCode.Equals(item.UniqueCode));
if (receipt != null)
{
if (receipt.Status == ReceiptStatusEnum.收完) continue;
@@ -2,8 +2,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Threading;
using System.Threading.Tasks;
using HHWMS.Web.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
@@ -73,27 +71,12 @@ public class ReceiptShelfInController : BaseController
{
try
{
var errDetails = _unitWork.Find<ReceiptDetail>(x =>
data.Select(y => y.ID).ToList().Contains(x.ID)
&& x.Status != ReceiptStatusEnum.新建).ToList();
if (errDetails.Any())
{
var msg = "以下明细不是新建状态:\n";
foreach (var errDetail in errDetails)
{
msg += $"{errDetail.UniqueCode}\n";
}
return JsonMore(null, 500, msg);
}
// 查找明细,修改对应状态,并且 绑定物料周转箱
foreach (Binding item in data.OrderBy(x => x.ReceiptCode))
{
// 更新入库单明细状态
var header = receiptHeaderList.Find(x => x.ID.ToString().Equals(item.ReceiptCode));
var receipt = header.ReceiptDetails.FirstOrDefault(x => x.UniqueCode.Equals(item.UniqueCode)
&& x.Status == ReceiptStatusEnum.新建
);
var receipt = header.ReceiptDetails.FirstOrDefault(x => x.UniqueCode.Equals(item.UniqueCode));
if (receipt != null)
{
receipt.Status = ReceiptStatusEnum.收完;
@@ -105,7 +88,7 @@ public class ReceiptShelfInController : BaseController
}
else
{
throw new Exception($"入库单{item.ReceiptCode}不存在{item.UniqueCode}的新建状态明细!");
throw new Exception($"入库单{item.ReceiptCode}不存在{item.UniqueCode}的明细!");
}
// 新建库存
@@ -127,28 +110,29 @@ public class ReceiptShelfInController : BaseController
TaskStatus = InventoryTaskStatus.无任务,
CreateBy = Wtm.LoginUserInfo.ITCode,
CreateTime = DateTime.Now
});
}
foreach (var inv in invList)
{
listInvtran.Add(new InventoryTransaction
}); ;
foreach (var inv in invList)
{
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
});
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());
@@ -66,7 +66,7 @@
<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" :disabled="disabledButton">绑定入库</el-button>
<el-button type="primary" @@click="onSubmit">绑定入库</el-button>
<el-button @@click="resetForm('form')">重置</el-button>
@* <el-button type="primary" @@click="inOperation">启动入库</el-button> *@
</el-form-item>
@@ -107,8 +107,7 @@
boxCode: [
{ validator: validatePass, trigger: 'blur' }
]
},
disabledButton : false
}
}
},
mounted: function () {
@@ -133,16 +132,7 @@
//绑定单据
onSubmit() {
var _this = this;
if (_this.bindingData.length == 0){
_this.$message({
message: "待入库清单为空!",
type: "warning",
duration: "10000",
});
return false;
}
var loadIndex = layer.load(1);
_this.disabledButton = true;
// 提交已绑定数据
$.ajax({
type: "post",
@@ -150,8 +140,6 @@
data: { data: _this.bindingData },
url: "/receipt/ReceiptIn/BindingData",
success: function (json) {
layer.close(loadIndex);
_this.disabledButton = false;
if (json.Code == 200) {
_this.$message({
message: '入库成功!',
@@ -161,14 +149,12 @@
}
else {
_this.$message({
message: '入库失败!'+json.Msg,
message: '入库失败!',
type: 'warning'
});
}
},
error: function (json) {
layer.close(loadIndex);
_this.disabledButton = false;
_this.$message({
message: '入库失败!',
type: 'error'
@@ -83,7 +83,7 @@
</el-table-column>
</el-table>
<el-form-item style="float: right">
<el-button type="primary" @@click="onSubmit" :disabled="disabledButton">绑定</el-button>
<el-button type="primary" @@click="onSubmit">绑定</el-button>
<el-button @@click="resetForm('form')">重置</el-button>
<el-button type="success" @@click="back" :disabled="disabledbackbutton">回库</el-button>
</el-form-item>
@@ -102,7 +102,6 @@
uniqueCode: "",
isFull: false
},
disabledButton : false,
disabledbackbutton: true,// true不可回库,false可回库
boxSize: [
{ label: "8mm", value: "8" },
@@ -224,16 +223,7 @@
// 绑定
onSubmit() {
var _this = this;
if (_this.bindingData.length == 0){
_this.$message({
message: "待入库清单为空!",
type: "warning",
duration: "10000",
});
return false;
}
var loadIndex = layer.load(1);
_this.disabledButton = true;
// 提交已绑定数据
$.ajax({
type: "post",
@@ -241,8 +231,6 @@
data: { data: _this.bindingData },
url: "/receipt/ReceiptSLIn/BindingData",
success: function (json) {
layer.close(loadIndex);
_this.disabledButton = false;
if (json.Code == 200) {
_this.$message({
message: "绑定成功!",
@@ -261,8 +249,6 @@
}
},
error: function (json) {
layer.close(loadIndex);
_this.disabledButton = false;
_this.$message({
message: "绑定失败!",
type: "error",
@@ -58,7 +58,7 @@
</el-table-column>
</el-table>
<el-form-item style="float: right">
<el-button type="primary" @@click="onSubmit" :disabled="disabledButton">入库</el-button>
<el-button type="primary" @@click="onSubmit">入库</el-button>
<el-button @@click="resetForm('form')">重置</el-button>
</el-form-item>
</el-form>
@@ -74,8 +74,7 @@
uniqueCode: "",
locationCode: ""
},
bindingData: [],
disabledButton : false
bindingData: []
};
},
mounted: function () {
@@ -98,16 +97,7 @@
// 绑定
onSubmit() {
var _this = this;
if (_this.bindingData.length == 0){
_this.$message({
message: "待入库清单为空!",
type: "warning",
duration: "10000",
});
return false;
}
var loadIndex = layer.load(1);
_this.disabledButton = true;
// 提交已绑定数据
$.ajax({
type: "post",
@@ -115,8 +105,6 @@
data: { data: _this.bindingData },
url: "/receipt/ReceiptShelfIn/BindingData",
success: function (json) {
layer.close(loadIndex);
_this.disabledButton = false;
if (json.Code == 200) {
_this.$message({
message: "入库成功!",
@@ -124,15 +112,13 @@
_this.bindingData = [];
} else {
_this.$message({
message: "入库失败!"+json.Msg,
message: "入库失败!",
type: "warning",
duration: "10000",
});
}
},
error: function (json) {
layer.close(loadIndex);
_this.disabledButton = false;
_this.$message({
message: "入库失败!",
type: "error",
@@ -149,14 +135,7 @@
// 扫描唯一码
scanUniqueCode(data) {
var _this = this;
if (_this.form.locationCode == ""){
_this.$message({
message: "位置不能为空!",
type: "warning",
duration: "1000",
});
return false;
}
//1. 判断唯一码是否合理,调用后台,并返回唯一码对应的数量
var isExit = this.bindingData.findIndex(function (value) {
return value.uniqueCode == data;
@@ -185,7 +164,6 @@
} else {
// 3.已扫描增加
_this.bindingData.push({
id:json.Data.ID,
receiptCode: json.Data.ReceiptHeaderId,
uniqueCode: json.Data.UniqueCode,
materialCode: json.Data.MaterialCode,
@@ -89,7 +89,6 @@ namespace HHWMS.Web
var query = DC.Set<ShipmentDetailHistory>()
.CheckEqual(Searcher.ShipmentHeaderHistoryId, x=>x.ShipmentHeaderHistoryId)
.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)
@@ -66,17 +66,16 @@ namespace HHWMS.Web
if (count > 0)
{
var taskList = CreateWCSTask(task, _unitwork);
foreach (var item in taskList)
{
task.ErrorMsg += JsonConvert.SerializeObject(item);
// 调用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));
var end = locationList.FirstOrDefault(x => x.Code.Equals(task.ToLocation));
@@ -108,12 +107,12 @@ namespace HHWMS.Web
_unitwork.Update(begin);
_unitwork.Update(end);
}
else
{
task.ErrorMsg += $",任务下发失败,失败原因:{res.Msg}";
_unitwork.Update(task);
continue;
}
// else
// {
// task.ErrorMsg += $",任务下发失败,失败原因:{res.Msg}";
// _unitwork.Update(task);
// continue;
// }
//Task.Delay(500);
}
catch (Exception ex)
@@ -148,9 +147,7 @@ namespace HHWMS.Web
Wtm.DoLog("任务下发", ActionLogTypesEnum.Job, "SendWcsJob");
#endregion 更新时间
}
catch(Exception ex) {
Wtm.DoLog(ex.Message, ActionLogTypesEnum.Job, "SendWcsJob");
}
catch { }
return Task.CompletedTask;
}
/// <summary>
@@ -243,7 +240,7 @@ namespace HHWMS.Web
newTask.Station = "2";
_unitwork.Add(newTask);
task.ContainerCode += $" {container.ContainerCode}";
task.ContainerCode += container.ContainerCode;
// 更新库位
container.Status = LocationStatus.任务锁;
_unitwork.Update(container);
@@ -383,10 +380,7 @@ namespace HHWMS.Web
if (task != null)
{
var locationList = _unitwork.Find<Location>(x => task.FromLocation.Equals(x.Code)
|| task.ToLocation.Equals(x.Code)
|| "G1,G2,T".Contains(x.Type)).ToList();
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));
var end = locationList.FirstOrDefault(x => x.Code.Equals(task.ToLocation));
// 根据不同任务类型 创建任务
@@ -424,11 +418,6 @@ namespace HHWMS.Web
{
if (container.Any(x => x == item.ContainerCode))
{
var g1 = locationList.First(x => x.ContainerCode.Equals(item.ContainerCode)
&& x.Type.Equals(LocationTypeEnum.堆垛机工位));
end = locationList.First(x => x.Code.Equals(g1.ContiguousCode));
taskInfoList.Add(new TaskInfo
{
TaskId = $"{task.TaskNo}-{item.FromLocation}",
@@ -39,12 +39,14 @@ namespace HHWMS.Web
{
foreach (var shipment in Shipments)
{
var shipmentDetails = shipment.ShipmentDetails.Where(x => x.Status.Equals(ShipStatusEnum.新建)).ToList();
var shipmentDetails = shipment.ShipmentDetails
.Where(x => x.Status.Equals(ShipStatusEnum.新建)).ToList();
foreach (var shipmentDetail in shipmentDetails)
{
var inventorys = _unitwork.Find<Inventory>(x => x.UniqueCode == shipmentDetail.UniqueCode
&& x.TaskStatus == InventoryTaskStatus.无任务
&& x.ZoneCode != ZoneCodeEnum.货架库).ToList();
var inventorys = _unitwork.Find<Inventory>(x =>
x.UniqueCode == shipmentDetail.UniqueCode
&& x.TaskStatus == InventoryTaskStatus.无任务
&& x.ZoneCode != ZoneCodeEnum.货架库).ToList();
if (inventorys.Count <= 0)
{
continue;
@@ -62,6 +64,7 @@ namespace HHWMS.Web
shipmentDetail.Status = ShipStatusEnum.分配完成;
}
shipmentDetail.UpdateTime = DateTime.Now;
shipmentDetail.UpdateBy = "wmsjob";
}
@@ -81,18 +84,18 @@ namespace HHWMS.Web
}
var inTaskContainerList = _unitwork.Find<TaskHeader>(x => x.TaskType == TaskTypeEnum.盘料盒入库
|| x.TaskType == TaskTypeEnum.盘料入库
|| x.TaskType == TaskTypeEnum.散料盒入库)
|| x.TaskType == TaskTypeEnum.盘料入库
|| x.TaskType == TaskTypeEnum.散料盒入库)
.Select(x => x.ContainerCode)
.ToList();
//出库库存通过托盘号分组
var lockInvs = _unitwork.Find<Inventory>(x => x.TaskStatus == InventoryTaskStatus.任务中
&& !"L01,L02".Contains(x.LocationCode)
&& !inTaskContainerList.Contains(x.LocationCode))
.ToList();
&& !"L01,L02".Contains(x.LocationCode)
&& !inTaskContainerList.Contains(x.LocationCode))
.ToList();
shiInventorys.AddRange(lockInvs);
//已生成任务的库存不再生成任务
var taskUniques = _unitwork.Find<TaskDetail>(x => x.Status > TaskStatusEnum.新建)
var taskUniques = _unitwork.Find<TaskDetail>(x => x.Status >= TaskStatusEnum.新建)
.Select(x => x.UniqueCode).ToList();
var taskInvs = _unitwork.Find<Inventory>(x => taskUniques.Contains(x.UniqueCode)).ToList();
var newList = shiInventorys.Except(taskInvs).ToList();
@@ -100,19 +103,29 @@ namespace HHWMS.Web
var inventoryList = newList.GroupBy(x => x.ContainerCode)
.ToList();
// 堆垛机工位点
var gLocDict = new Dictionary<int, dynamic>();
gLocDict.Add(1, new { Row = 1, GLoc = "L01-01-34-02", TLoc = "L01-02" });
gLocDict.Add(2, new { Row = 3, GLoc = "L01-02-34-02", TLoc = "L01-01" });
//散料库
if (inventoryList.Any(x => x.Key.Contains("C")))
{
foreach (var item in inventoryList.Where(x => x.Key.Contains("C")))
{
//出库托盘
Location location = _unitwork.Find<Location>(x => x.Code == item.Key && x.Status != LocationStatus.任务锁).FirstOrDefault();
Location location = _unitwork
.Find<Location>(x => x.Code == item.Key && x.Status != LocationStatus.任务锁)
.FirstOrDefault();
if (location == null)
{
continue;
}
// 查询目的地站台是否可用
var station = _unitwork.Find<Location>(x => x.Row == location.Row && x.Type == LocationTypeEnum.散料库站台 && string.IsNullOrEmpty(x.ContainerCode)).FirstOrDefault();
var station = _unitwork.Find<Location>(x =>
x.Row == location.Row && x.Type == LocationTypeEnum.散料库站台 &&
string.IsNullOrWhiteSpace(x.ContainerCode)).FirstOrDefault();
if (station == null)
{
continue;
@@ -121,7 +134,8 @@ namespace HHWMS.Web
{
//判断是否已经有目的站台的出库任务
TaskHeader taskHeader = _unitwork.Find<TaskHeader>(x =>
x.ToLocation == station.Code && x.TaskType == TaskTypeEnum.散料盒出库).FirstOrDefault();
x.ToLocation == station.Code && x.TaskType == TaskTypeEnum.散料盒出库)
.FirstOrDefault();
if (taskHeader != null)
{
continue;
@@ -148,11 +162,157 @@ namespace HHWMS.Web
}
}
}
//盘料库
if (inventoryList.Any(x => x.Key.Contains("L")))
{
foreach (var item in inventoryList.Where(x => x.Key.Contains("L")))
{
#region new task flow
//判断是否存在此托盘入库任务
// 存在 跳过
if (_unitwork.IsExit<TaskHeader>(x =>
x.ContainerCode.Equals(item.Key)
&& (x.TaskType == TaskTypeEnum.盘料入库
|| x.TaskType == TaskTypeEnum.盘料盒入库)))
{
continue;
}
// 不用判断是否存在出库任务,可创建多个相同容器的盘料出库任务,存在盘料盒出库也无所谓
// 根据库存的库位信息,查找盘料出库的起点站台 堆垛机工位
var invLoc = _unitwork.FindSingle<Location>(x => x.Code == item.Key);
var taskHeader = new TaskHeader();
taskHeader.TaskDetails = new List<TaskDetail>();
taskHeader.ZoneCode = ZoneCodeEnum.盘料库;
taskHeader.TaskNo = _unitwork.GetSerialNumber("pout", 4);
taskHeader.TaskType = TaskTypeEnum.盘料出库;
taskHeader.Status = TaskStatusEnum.新建;
taskHeader.ContainerCode = item.Key;
taskHeader.Priority = 100;
taskHeader.FromLocation = gLocDict.First(x => x.Value.Row == invLoc.Row).Value.TLoc;
taskHeader.ToLocation = item.First().Flag == 8 ? "L01" : "L02";
taskHeader.CreateTime = DateTime.Now;
taskHeader.CreateBy = "wmsjob";
// 创建任务明细
foreach (var inventory in item)
{
if (!taskHeader.TaskDetails.Any(x => x.UniqueCode.Equals(inventory.UniqueCode)))
taskHeader.TaskDetails.Add(new TaskDetail
{
UniqueCode = inventory.UniqueCode,
Lot = $"{Convert.ToInt32(invLoc.Length)}-{taskHeader.ToLocation}",
FromLocation = inventory.Lot,
ToLocation = "",
Status = TaskStatusEnum.新建,
ContainerCode = inventory.ContainerCode,
CreateTime = DateTime.Now
});
}
_unitwork.Add(taskHeader);
#endregion
}
}
// 根据盘料出库,生成盘料盒出库任务,并更新盘料出库明细的 出库库位
var plcTaskList = _unitwork.Find<TaskHeader>(x =>
x.TaskType == TaskTypeEnum.盘料出库
&& x.Status == TaskStatusEnum.新建)
.Include(x => x.TaskDetails)
.ToList();
// 查询当前工位的状态
var workLocList = _unitwork.Find<Location>(x =>
"L01,L02,L01-01-34-02,L01-02-34-02".Contains(x.Code)
).ToList();
foreach (var plcTask in plcTaskList)
{
var lLoc = workLocList.First(x => x.Code.Equals(plcTask.ToLocation));
var container = _unitwork.FindSingle<Location>(x => x.Code.Equals(plcTask.ContainerCode));
// 判断是否已存在盘料盒出库任务,或者盘料盒已在堆垛机工位 L01-34-02/L02-34-02
var isOut = workLocList.Any(x => x.ContainerCode.Equals(plcTask.ContainerCode));
string toLocCode = gLocDict.First(x => x.Value.Row == container.Row).Value.GLoc;
// 存在去相同工位点的 盘料盒出库任务 跳过(保持一个工位只有一条盘料盒出库任务)
// 工位有货 也跳过
var c1 = _unitwork.IsExit<TaskHeader>(x =>
x.TaskType == TaskTypeEnum.盘料盒出库
&& x.ContainerCode != plcTask.ContainerCode
&& x.ToLocation == toLocCode);
var c2 = workLocList.Any(x => x.Code == toLocCode
&& !string.IsNullOrWhiteSpace(x.ContainerCode)
&& !x.ContainerCode.Equals(plcTask.ContainerCode));
if(c1 || c2)
continue;
if (!plcTask.TaskDetails.Any(x =>
x.Status == TaskStatusEnum.新建 && string.IsNullOrWhiteSpace(x.ToLocation))) continue;
if (_unitwork.IsExit<TaskHeader>(x =>
x.ContainerCode.Equals(plcTask.ContainerCode)
&& x.TaskType == TaskTypeEnum.盘料盒出库)
||
isOut
)
{
// 更新任务明细的 location ,status一般在盘料盒出库完成后更新为 待下发
// 1. 计算周转箱可用层数
var canUse = CalCanUse(Convert.ToInt32(lLoc.Length), plcTask.ToLocation, _unitwork);
foreach (var detail in plcTask.TaskDetails.Where(x => x.Status == TaskStatusEnum.新建
&& string.IsNullOrWhiteSpace(x.ToLocation)))
{
if (canUse.Length > 0)
{
// 2.更新目标库位
detail.ToLocation = canUse.First().ToString();
detail.UpdateTime = DateTime.Now;
canUse = canUse.Where(x => x != canUse.First()).ToArray();
}
else
{
break;
}
}
_unitwork.Update(plcTask);
}
else if (!isOut && !_unitwork.IsExit<TaskHeader>(x =>
x.ToLocation.Equals(toLocCode)))
{
// 不存在盘料盒出库任务,创建盘料盒出库任务
// 判断堆垛机工位是否有货,并且没有其他去该工位的盘料盒出库
var pTask = new TaskHeader
{
ZoneCode = ZoneCodeEnum.盘料库,
TaskNo = _unitwork.GetSerialNumber("Out"),
TaskType = TaskTypeEnum.盘料盒出库,
ContainerCode = plcTask.ContainerCode,
FromLocation = plcTask.ContainerCode,
ToLocation = toLocCode,
Station = "1",
Status = TaskStatusEnum.待下发,
Priority = 0,
CreateTime = DateTime.Now,
CreateBy = "wmsjob"
};
_unitwork.Add(pTask);
}
}
/*
var task = new TaskHeader();
task.TaskDetails = new List<TaskDetail>();
var inv = item.FirstOrDefault();
@@ -364,6 +524,7 @@ namespace HHWMS.Web
}
}
}
*/
tran.Commit();
}
catch
@@ -377,19 +538,26 @@ namespace HHWMS.Web
var job = _unitwork.FindSingle<SysJob>(x => x.JobName == context.JobDetail.Key.Name);
if (job != null)
{
job.LastFireTime = TimeZoneInfo.ConvertTimeFromUtc(context.FireTimeUtc.DateTime, TimeZoneInfo.Local);
job.LastFireTime =
TimeZoneInfo.ConvertTimeFromUtc(context.FireTimeUtc.DateTime, TimeZoneInfo.Local);
// 只执行一次 没有下次执行时间
if (context.NextFireTimeUtc != null)
{
job.NextFireTime = TimeZoneInfo.ConvertTimeFromUtc(context.NextFireTimeUtc.Value.DateTime, TimeZoneInfo.Local);
job.NextFireTime = TimeZoneInfo.ConvertTimeFromUtc(context.NextFireTimeUtc.Value.DateTime,
TimeZoneInfo.Local);
}
_unitwork.Update<SysJob>(job);
}
Wtm.DoLog("出库分解", ActionLogTypesEnum.Job, "SendWmsJob");
#endregion 更新时间
}
catch { }
catch(Exception ex)
{
Wtm.DoLog("出库分解", ActionLogTypesEnum.Job, "SendWmsJob", result:ex.Message);
}
return Task.CompletedTask;
}
@@ -573,7 +741,8 @@ namespace HHWMS.Web
{
var used1 = _unitwork.Find<Inventory>(x => x.LocationCode.Equals(code))
.Select(x => int.Parse(x.Lot)).ToArray();
var used2 = _unitwork.Find<TaskDetail>(x => x.Lot.Contains(code))
var used2 = _unitwork.Find<TaskDetail>(x => x.Lot.Contains(code)
&& !string.IsNullOrWhiteSpace(x.ToLocation))
.Select(x => int.Parse(x.ToLocation)).ToArray();
var used = used1.Union(used2);
var caseList = Enumerable.Range(1, length).ToArray();
@@ -12,9 +12,7 @@ namespace HHWMS.Web
{
public partial class TaskDetailHistorySearcher : BaseSearcher
{
[Display(Name = "Task.TaskNo")]
public List<ComboSelectListItem> AllTaskHeaders { get; set; }
[Display(Name = "Task.TaskNo")]
public int? TaskHeaderId { get; set; }
[Display(Name = "Inventory.UniqueCode")]
public String UniqueCode { get; set; }
@@ -55,7 +55,6 @@ namespace HHWMS.Web
public override IOrderedQueryable<TaskDetail_View> GetSearchQuery()
{
var query = DC.Set<TaskDetail>()
.CheckEqual(Searcher.TaskHeaderId,x => x.TaskHeaderId)
.CheckContain(Searcher.UniqueCode, x=>x.UniqueCode)
.CheckContain(Searcher.MaterialCode, x=>x.MaterialCode)
.CheckContain(Searcher.FromLocation, x=>x.FromLocation)
@@ -12,8 +12,6 @@ namespace HHWMS.Web
{
public partial class TaskDetailSearcher : BaseSearcher
{
[Display(Name = "Task.TaskNo")]
public List<ComboSelectListItem> AllTaskHeaders { get; set; }
[Display(Name = "Inventory.UniqueCode")]
public String UniqueCode { get; set; }
@@ -26,10 +24,10 @@ namespace HHWMS.Web
public String FromLocation { get; set; }
[Display(Name = "Task.ToLocation")]
public String ToLocation { get; set; }
protected override void InitVM()
{
AllTaskHeaders = DC.Set<TaskHeader>().GetSelectListItems(Wtm, y => y.TaskNo);
}
}
}
@@ -33,17 +33,16 @@ namespace HHWMS.Web
{
return new List<GridColumn<TaskHeaderHistory_View>>{
this.MakeGridHeader(x => x.ZoneCode),
this.MakeGridHeader(x => x.TaskNo).SetWidth(220),
this.MakeGridHeader(x => x.TaskType,150),
this.MakeGridHeader(x => x.FromLocation,150),
this.MakeGridHeader(x => x.ToLocation,150),
this.MakeGridHeader(x => x.TaskNo),
this.MakeGridHeader(x => x.TaskType),
this.MakeGridHeader(x => x.FromLocation),
this.MakeGridHeader(x => x.ToLocation),
this.MakeGridHeader(x => x.Station),
this.MakeGridHeader(x => x.ContainerCode,150),
this.MakeGridHeader(x => x.ContainerCode),
this.MakeGridHeader(x => x.RoadWay).SetHide(),
this.MakeGridHeader(x => x.Priority).SetHide(),
this.MakeGridHeader(x => x.Status,150),
this.MakeGridHeader(x => x.Status),
this.MakeGridHeader(x => x.ErrorMsg),
this.MakeGridHeader(x => x.CreateTime,220),
this.MakeGridHeaderAction(width: 200)
};
}
@@ -73,7 +72,6 @@ namespace HHWMS.Web
Priority = x.Priority,
Status = x.Status,
ErrorMsg = x.ErrorMsg,
CreateTime = x.CreateTime
})
.OrderBy(x => x.ID);
return query;
@@ -68,7 +68,6 @@ namespace HHWMS.Web
this.MakeGridHeader(x => x.Status, 150),
this.MakeGridHeader(x => x.CreateTime, 150).SetHide(),
this.MakeGridHeader(x => x.ErrorMsg, 150).SetHide(),
this.MakeGridHeader(x => x.CreateTime,220),
this.MakeGridHeaderAction(width: 200)
};
}
@@ -98,7 +97,6 @@ namespace HHWMS.Web
Priority = x.Priority,
Status = x.Status,
ErrorMsg = x.ErrorMsg,
CreateTime = x.CreateTime
})
.OrderByDescending(x => x.ID);
return query;
@@ -2,13 +2,11 @@
@inject IStringLocalizer<Program> Localizer;
<wt:searchpanel vm="@Model" reset-btn="true">
<wt:row items-per-row="ItemsPerRowEnum.Three">
<wt:combobox field="Searcher.TaskHeaderId" items="Searcher.AllTaskHeaders" empty-text="@Localizer["Sys.All"]" />
<wt:textbox field="Searcher.UniqueCode"/>
<wt:textbox field="Searcher.MaterialCode"/>
<wt:textbox field="Searcher.FromLocation"/>
<wt:textbox field="Searcher.ToLocation"/>
</wt:row>
<wt:row items-per-row="ItemsPerRowEnum.Three">
<wt:textbox field="Searcher.UniqueCode" />
<wt:textbox field="Searcher.MaterialCode" />
<wt:textbox field="Searcher.FromLocation" />
<wt:textbox field="Searcher.ToLocation" />
</wt:row>
</wt:searchpanel>
<wt:grid vm="@Model" url="/taskManage/TaskDetail/Search"/>
@@ -3,7 +3,7 @@
<wt:searchpanel vm="@Model" reset-btn="true">
<wt:row items-per-row="ItemsPerRowEnum.Three">
<wt:combobox field="Searcher.TaskHeaderId" items="Searcher.AllTaskHeaders" empty-text="@Localizer["Sys.All"]" />
@* <wt:combobox field="Searcher.TaskHeaderId" items="Searcher.AllTaskHeaders" empty-text="@Localizer["Sys.All"]" /> *@
<wt:textbox field="Searcher.UniqueCode" />
<wt:textbox field="Searcher.ContainerCode" />
<wt:textbox field="Searcher.FromLocation" />
-16
View File
@@ -3,15 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using HHWMS.Web.Support;
using HHWMS.Web.ViewModels.HomeVMs;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
@@ -157,18 +153,6 @@ namespace HHWMS.Web.Controllers
return JsonMore("No Data");
}
[Public]
public IActionResult CheckLogin()
{
return Ok();
}
[Public]
public IActionResult BeforeLogin(LoginVM vm)
{
return JsonMore(UserSessionManager.AllSignined().ToList());
}
//[AllowAnonymous]
//public github GetGithubInfo()
//{
+2 -27
View File
@@ -14,11 +14,6 @@ using WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkUserVms;
using HHWMS.Web.ViewModels.HomeVMs;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HHWMS.Web.Support;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Caching.Distributed;
using WalkingTec.Mvvm.Core.Support.Quartz;
namespace HHWMS.Web.Controllers
{
@@ -38,7 +33,7 @@ namespace HHWMS.Web.Controllers
}
return View(vm);
}
[Public]
[HttpPost]
public async Task<ActionResult> Login(LoginVM vm)
@@ -52,9 +47,7 @@ namespace HHWMS.Web.Controllers
return View(vm);
}
}*/
var user = Wtm.DoLogin(vm.ITCode, vm.Password, vm.Tenant);
if (user == null)
{
vm.MSD.AddModelError("", Localizer["Sys.LoginFailed"]);
@@ -62,13 +55,6 @@ namespace HHWMS.Web.Controllers
}
else
{
var bb = UserSessionManager.IsUserSignined(user.Name);
if (bb)
{
// 踢人下线
await KickUser(user.Name);
}
//其他属性可以通过user.Attributes["aaa"] = "bbb"方式赋值
Wtm.LoginUserInfo = user;
string url = string.Empty;
@@ -91,9 +77,7 @@ namespace HHWMS.Web.Controllers
};
}
var principal = user.CreatePrincipal();
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, properties);
UserSessionManager.AddUserSession(user.Name,principal.Claims.First(c => c.Type == "SessionId").Value);
return Redirect(HttpUtility.UrlDecode(url));
}
}
@@ -136,7 +120,6 @@ namespace HHWMS.Web.Controllers
[ActionDescription("Logout")]
public async Task Logout()
{
UserSessionManager.RemoveUserSession(Wtm.LoginUserInfo.Name);
HttpContext.Session.Clear();
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
if (ConfigInfo.HasMainHost == false || Wtm.LoginUserInfo?.CurrentTenant != null)
@@ -149,15 +132,7 @@ namespace HHWMS.Web.Controllers
HttpContext.Response.Redirect(ConfigInfo.MainHost);
}
}
[AllRights]
public async Task<IActionResult> KickUser(string ITcode)
{
UserSessionManager.KickUser(ITcode);
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return Ok();
}
[AllRights]
[ActionDescription("ChangePassword")]
public ActionResult ChangePassword()
+1 -1
View File
@@ -95,7 +95,7 @@ namespace HHWMS.Web
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// ef生成表 添加字段注释,只有本项目的表才添加,需要在DisplayAttribute,添加Description
var ddd = modelBuilder.Model.GetEntityTypes();
ddd = ddd.Where(x => x.ClrType.FullName.Contains("HHWMS.Web")).ToList();
+4 -5
View File
@@ -55,7 +55,7 @@ namespace MESTOWMSService
}
catch(Exception ex)
{
_wtm.DoLog(ex.Message, ActionLogTypesEnum.Normal, "mes", request: materails, result: "error");
_wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: materails, result: "error");
return new Result { Status = "N", Message = ex.Message};
}
}
@@ -64,6 +64,7 @@ namespace MESTOWMSService
{
try
{
_wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: outOrder);
var data = JsonConvert.DeserializeObject<MesOut>(outOrder);
// 生成出库单和明细
var shipment = new ShipmentHeader
@@ -101,20 +102,18 @@ namespace MESTOWMSService
}
else
{
_wtm.DoLog($"{item.SN}物料不存在库内!", ActionLogTypesEnum.Normal, "mes", request: outOrder, result: "error");
return new Result { Status = "N", Message = $"{item.SN}物料不存在库内!" };
return new Result { Status = "N", Message = $"物料不存在库内!" };
}
}
if(shipment.ShipmentDetails.Count > 0)
{
_unitwork.Add(shipment);
}
_wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: outOrder);
return new Result();
}
catch (Exception ex)
{
_wtm.DoLog(ex.Message, ActionLogTypesEnum.Normal, "mes", request: outOrder, result: "error");
_wtm.DoLog("", ActionLogTypesEnum.Normal, "mes", request: outOrder, result: "error");
return new Result { Status = "N", Message = ex.Message };
}
}
+1 -2
View File
@@ -1,7 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using WalkingTec.Mvvm.Core;
@@ -25,7 +24,7 @@ namespace HHWMS.Web.Models
[Display(Name = "Container.LocationCode", Description = "库位编码")]
[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; }
@@ -17,7 +17,7 @@ namespace HHWMS.Web.Models
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
public string ZoneCode { get; set; }
[Display(Name = "Inventory.UniqueCode")]
[Display(Name = "InventoryTransaction.Type", Description = "交易类型")]
[StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
public string Type { get; set; }
-1
View File
@@ -76,7 +76,6 @@ app.UseSession();
app.UseWtmSwagger(false);
app.UseSwaggerExt();
app.UseWtm();
app.UseMiddleware<SessionValidationMiddleware>();
app.AddQuartzJobs();
app.UseEndpoints(endpoints => {
+1 -1
View File
@@ -18,7 +18,7 @@
},
"HHWMS.Web": {
"commandName": "Project",
"launchBrowser": false,
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
@@ -1,38 +0,0 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Http;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Support.Quartz;
namespace HHWMS.Web.Support;
public class SessionValidationMiddleware
{
private readonly RequestDelegate _next;
public SessionValidationMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
if (context.User.Identity.IsAuthenticated)
{
var userId = context.User.Identity.Name;
var sessionId = context.User.Claims.FirstOrDefault(c => c.Type == "SessionId")?.Value;
if (!UserSessionManager.IsUserSessionValid(userId, sessionId))
{
// UserSessionManager.RemoveUserSession(userId);
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
context.Response.Redirect(new Configs().CookieOptions.LogoutPath);
return;
}
}
await _next(context);
}
}
-42
View File
@@ -1,42 +0,0 @@
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using WalkingTec.Mvvm.Core;
namespace HHWMS.Web.Support;
using System.Collections.Concurrent;
public class UserSessionManager
{
private static ConcurrentDictionary<string, string> userSessions = new ConcurrentDictionary<string, string>();
public static void AddUserSession(string userId, string sessionId)
{
userSessions[userId.ToLower()] = sessionId;
}
public static void RemoveUserSession(string userId)
{
userSessions.TryRemove(userId, out _);
}
public static bool IsUserSessionValid(string userId, string sessionId)
{
return userSessions.TryGetValue(userId.ToLower(), out var storedSessionId) && storedSessionId == sessionId;
}
public static bool IsUserSignined(string userId)
{
return userSessions.ContainsKey(userId);
}
public static void KickUser(string userId)
{
userSessions.TryRemove(userId, out _);
}
public static ConcurrentDictionary<string, string> AllSignined()
{
return userSessions;
}
}
-27
View File
@@ -1,28 +1 @@
<script>layui.use('index')</script>
<script>
// 检查Token是否过期的函数
function isTokenExpired() {
$.ajax({
url: 'Home/CheckLogin/',
statusCode: {
// 处理200 OK状态码
200: function(data) {
if (data.indexOf('Login') !== -1) {
clearInterval(timerId);
alert("您的账号已在其他地方登陆,若继续使用,请重新登录!");
location.reload();
}
},
},
});
}
// 存储定时器ID
var timerId = setInterval(function() {
// 你的代码逻辑
isTokenExpired();
}, 10000); // 每10000毫秒执行一次
</script>
+1 -30
View File
@@ -36,7 +36,7 @@
<div class="login-form">
<h1>WMS</h1>
<br />
<form id="login" action="/Login/Login" method="post">
<form action="/Login/Login" method="post">
<input type="hidden" name="Redirect" value="@Model.Redirect">
<ul class="loginForm">
<li>
@@ -75,36 +75,7 @@
margin-bottom: 1%;
">© 2022 华恒工程技术中心有限公司</p>*@
</div>
<script>
var loginData = [];
$.post('/Home/BeforeLogin/',{},function (data){
loginData = data.Data;
});
// 给表单添加 onsubmit 事件处理器
document.getElementById('login').onsubmit = function() {
var usernameValue = $('input[name="ITCode"]').val();
var issigned;
// 从loginData查找 itcode
loginData.forEach(function(item) {
if (item.Key === usernameValue) {
var isConfirmed = confirm("您的账号已在其他地方登陆,确定在此设备重新登录吗?\n(此设备登陆后,其他设备的账号将自动退出!)");
// 如果用户点击“取消”,返回 false 以阻断表单提交
if (!isConfirmed) {
issigned = false;
}
else{
issigned = true;
}
}
})
return issigned;
}
</script>
</body>
+10 -10
View File
@@ -22,17 +22,17 @@
},
"Connections": [
//{
// "Key": "default",
// "Value": "Server=127.0.0.1;Port=3306;Database=8357wms;Uid=root;Password=abc123*;Character Set=utf8mb4;",
// "DBType": "mysql"
//}
{
"Key": "default",
"Value": "Server=127.0.0.1;Port=3306;Database=8wms;Uid=root;Password=abc123*;Character Set=utf8mb4;",
"DBType": "mysql"
"Value": "Data Source=.;Initial Catalog=8357wms;User=sa;Password=abc123*;Persist Security Info=True",
"DbContext": "DataContext",
"DBType": "sqlserver" //DataBase, you can choose mysql,sqlserver,pgsql,sqlite,oracle
}
// {
// "Key": "default",
// "Value": "Data Source=.;Initial Catalog=8wms;User=sa;Password=abc123*;Persist Security Info=True",
// "DbContext": "DataContext",
// "DBType": "sqlserver" //DataBase, you can choose mysql,sqlserver,pgsql,sqlite,oracle
// }
//{
// "Key": "default",
// "Value": "Data Source=10.18.106.4;Initial Catalog=8357wms;User=wms;Password=abc123*;Persist Security Info=True",
@@ -41,9 +41,9 @@
//}
],
"CookiePre": "HHWMS", //cookie前缀
"IsQuickDebug": false, //是否启用debug模式
"IsQuickDebug": true, //是否启用debug模式
"EnableTenant": false, //是否启动多租户
"SyncDb": false, //是否自动同步数据库
"SyncDb": true, //是否自动同步数据库
"EncryptKey": "", //加密密钥
"PageMode": "Tab", //页面显示模式,Single或者Tab
"TabMode": "Simple", //Tab页显示方式,Default或者Simple
@@ -15,11 +15,7 @@ namespace WalkingTec.Mvvm.Core.Extensions
public static ClaimsPrincipal CreatePrincipal(this LoginUserInfo self)
{
if (string.IsNullOrEmpty(self.ITCode)) throw new ArgumentException("Id is mandatory", nameof(self.ITCode));
var claims = new List<Claim>
{
new Claim(AuthConstants.JwtClaimTypes.Subject, self.ITCode) ,
new Claim("SessionId", Guid.NewGuid().ToString())
};
var claims = new List<Claim> { new Claim(AuthConstants.JwtClaimTypes.Subject, self.ITCode) };
if (!string.IsNullOrEmpty(self.Name))
{
@@ -12,11 +12,11 @@ namespace $namespace$
[ActionDescription("$des$")]
public partial class $modelname$Controller : BaseController
{
private readonly IUnitWork _unitWork;
private readonly IUnitWork _unitwork;
public $modelname$Controller(IUnitWork unitWork)
public $modelname$Controller(IUnitWork unitwork)
{
_unitWork = unitWork;
_unitwork = unitwork;
}
#region Search
+1 -1
View File
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>6.4.0</VersionPrefix>
<VersionPrefix>6.3.7</VersionPrefix>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">