master
2 years ago
parent 1c71df8c8a
commit 531c9bbd59

@ -18,7 +18,7 @@ namespace Khd.Core.Domain.Models
public class BaseEquip public class BaseEquip
{ {
[Column("empty_count")] [Column("empty_count")]
public int? emptyCount; public int? emptyCount { get; set; }
[Column("agv_position_code")] [Column("agv_position_code")]
public string agvPositionCode { get; set; } public string agvPositionCode { get; set; }

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Khd.Core.Domain.Models namespace Khd.Core.Domain.Models
{ {
[Table("base_plcpoint")] [Table("wcs_plcpoint")]
public class BasePlc public class BasePlc
{ {
[Column("id")] [Column("id")]

@ -186,21 +186,30 @@ namespace Khd.Core.Domain.Models
/// <summary> /// <summary>
/// 备用字段1 /// 备用字段1
/// </summary> /// </summary>
[Column("ud1")] [Column("ctu_execute")]
public string ud1 { get; set; } public string CTUExecute { get; set; }
/// <summary> /// <summary>
/// 备用字段2 /// 备用字段2
/// </summary> /// </summary>
[Column("ud2")] [Column("is_empty")]
public string ud2 { get; set; } public string isEmpty { get; set; }
/// <summary> /// <summary>
/// 备用字段3 /// 备用字段3
/// </summary> /// </summary>
[Column("ud3")] [Column("ud3")]
public string ud3 { get; set; } public string ud3 { get; set; }
/// <summary>
/// 备用字段3
/// </summary>
[Column("ud1")]
public string ud1 { get; set; }
/// <summary>
/// 备用字段3
/// </summary>
[Column("ud2")]
public string ud2 { get; set; }
/// <summary> /// <summary>
/// 备注 /// 备注
/// </summary> /// </summary>

@ -186,21 +186,30 @@ namespace Khd.Core.Domain.Models
/// <summary> /// <summary>
/// 备用字段1 /// 备用字段1
/// </summary> /// </summary>
[Column("ud1")] [Column("ctu_execute")]
public string ud1 { get; set; } public string CTUExecute { get; set; }
/// <summary> /// <summary>
/// 备用字段2 /// 备用字段2
/// </summary> /// </summary>
[Column("ud2")] [Column("is_empty")]
public string ud2 { get; set; } public string isEmpty { get; set; }
/// <summary> /// <summary>
/// 备用字段3 /// 备用字段3
/// </summary> /// </summary>
[Column("ud3")] [Column("ud3")]
public string ud3 { get; set; } public string ud3 { get; set; }
/// <summary>
/// 备用字段3
/// </summary>
[Column("ud1")]
public string ud1 { get; set; }
/// <summary>
/// 备用字段3
/// </summary>
[Column("ud2")]
public string ud2 { get; set; }
/// <summary> /// <summary>
/// 备注 /// 备注
/// </summary> /// </summary>

@ -56,7 +56,7 @@ namespace Khd.Core.Domain.Models
/// 物料ID /// 物料ID
/// </summary> /// </summary>
[Column("material_id")] [Column("material_id")]
public long materialId { get; set; } public long? materialId { get; set; }
/// <summary> /// <summary>
/// 批次;扫描条码时,从打印条码记录表中获取 /// 批次;扫描条码时,从打印条码记录表中获取

@ -47,8 +47,6 @@ namespace Khd.Core.Wcs
WcsChuLiWanCheng = StaticPlcHelper.GetValue("2", "1"); WcsChuLiWanCheng = StaticPlcHelper.GetValue("2", "1");
//设置默认去向=>1为 Int16位 //设置默认去向=>1为 Int16位
WcsMoRenQuXiang = StaticPlcHelper.GetValue("2", "1"); WcsMoRenQuXiang = StaticPlcHelper.GetValue("2", "1");
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
StaticData.BasePlcpointList = dbContext.BasePlcpoint.Where(t => t.isDelete == 0).ToList(); StaticData.BasePlcpointList = dbContext.BasePlcpoint.Where(t => t.isDelete == 0).ToList();
StaticData.BaseEquip = dbContext.BaseEquip.ToList(); StaticData.BaseEquip = dbContext.BaseEquip.ToList();
StaticData.basePlcs = dbContext.BasePlc.ToList(); StaticData.basePlcs = dbContext.BasePlc.ToList();

@ -70,8 +70,8 @@ namespace Khd.Core.Wcs.Wcs
var createRawInWareTaskThread = new Thread(CreateRawInWareTaskLogic); var createRawInWareTaskThread = new Thread(CreateRawInWareTaskLogic);
createRawInWareTaskThread.Start(); createRawInWareTaskThread.Start();
var createProductTaskThread = new Thread(CreateProductTaskLogic); var createFiveProductTaskThread = new Thread(CreateFiveProductTaskLogic);
createProductTaskThread.Start(); createFiveProductTaskThread.Start();
var createRawTaskThread = new Thread(CreateRawTaskLogic); var createRawTaskThread = new Thread(CreateRawTaskLogic);
createRawTaskThread.Start(); createRawTaskThread.Start();
@ -129,7 +129,7 @@ namespace Khd.Core.Wcs.Wcs
WmsBaseLocation? wmsBaseLocation = null; WmsBaseLocation? wmsBaseLocation = null;
bill = bill.OrderBy(t => t.b.instockDate); bill = bill.OrderBy(t => t.b.instockDate);
var fistbill = bill.FirstOrDefault(); var fistbill = bill.FirstOrDefault();
if(fistbill != null) if (fistbill != null)
{ {
int? locRow = 0; int? locRow = 0;
if (fistbill.a.locRow % 2 == 1) if (fistbill.a.locRow % 2 == 1)
@ -148,10 +148,10 @@ namespace Khd.Core.Wcs.Wcs
.FirstOrDefault(); .FirstOrDefault();
if (lastbill != null) if (lastbill != null)
{ {
if (lastbill.b.instockDate != null&&fistbill.b.instockDate != null) if (lastbill.b.instockDate != null && fistbill.b.instockDate != null)
{ {
wmsBaseLocation = fistbill.a; wmsBaseLocation = fistbill.a;
if(lastbill.b.instockDate.Value.Date == fistbill.b.instockDate.Value.Date) if (lastbill.b.instockDate.Value.Date == fistbill.b.instockDate.Value.Date)
{ {
wmsBaseLocation = lastbill.a; wmsBaseLocation = lastbill.a;
} }
@ -162,11 +162,11 @@ namespace Khd.Core.Wcs.Wcs
List<string> list = wmsRawStocks.Select(t => t.locationCode).ToList(); List<string> list = wmsRawStocks.Select(t => t.locationCode).ToList();
var deepLocation = wmsBaseLocations var deepLocation = wmsBaseLocations
.Where(t => t.locDeep == 1) .Where(t => t.locDeep == 1)
.Where(t=>!list.Contains(t.locationCode)) .Where(t => !list.Contains(t.locationCode))
.ToList(); .ToList();
if(deepLocation.Count > 0) if (deepLocation.Count > 0)
{ {
var toWmsBaseLocation= deepLocation.First(); var toWmsBaseLocation = deepLocation.First();
var EKWcsTask = new WcsTask() var EKWcsTask = new WcsTask()
{ {
objid = StaticData.SnowId.NextId(), objid = StaticData.SnowId.NextId(),
@ -337,7 +337,7 @@ namespace Khd.Core.Wcs.Wcs
/// <summary> /// <summary>
/// 成品出库 /// 成品出库
/// </summary> /// </summary>
private void CreateProductTaskLogic() private void CreateFiveProductTaskLogic()
{ {
using var scope = _host.Services.CreateScope(); using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>(); using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
@ -346,10 +346,14 @@ namespace Khd.Core.Wcs.Wcs
try try
{ {
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload()); dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var proStock = dbContext.WmsProductStock.Where(t => t.activeFlag == "0").ToList(); var proStock = dbContext.WmsProductStock
.Where(t => t.warehouseId == 531)
.Where(t => t.activeFlag == "0").ToList();
var proOutStock = dbContext.WmsProductOutstock var proOutStock = dbContext.WmsProductOutstock
.Where(t => t.outstockQty < t.applyQty) .Where(t => t.outstockQty < t.applyQty)
.Where(t => t.auditStatus == "1") .Where(t => t.auditStatus == "1")
.Where(t => t.warehouseId == 531)
.Where(t => t.productType == "3")
.Where(t => t.executeStatus == "0" || t.executeStatus == "1").ToList(); .Where(t => t.executeStatus == "0" || t.executeStatus == "1").ToList();
//获取最早入库时间 //获取最早入库时间
foreach (var item in proOutStock) foreach (var item in proOutStock)
@ -444,15 +448,36 @@ namespace Khd.Core.Wcs.Wcs
location.locationStatus = "6"; location.locationStatus = "6";
location.updateBy = "WCS"; location.updateBy = "WCS";
location.updateTime = DateTime.Now; location.updateTime = DateTime.Now;
dbContext.Update(location); MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.barcodeInfo == stock.productBatch).FirstOrDefault();
dbContext.Add(wcsTask); if(mesBaseBarcodeInfo != null)
dbContext.Update(stock);
dbContext.SaveChanges();
if (qty >= needNumber)
{ {
break; WmsProductOutstockDetail wmsProductOutstockDetail = new WmsProductOutstockDetail()
{
productOutstockDetailId = StaticData.SnowId.NextId(),
productOutstockId = item.productOutstockId,
productId = item.productId,
beginTime = DateTime.Now,
confirmAmount = 0,
executeStatus = "1",
locationCode = location.locationCode,
outstockAmount = qty,
planAmount = item.applyQty,
warehouseId = item.warehouseId,
productBatch = mesBaseBarcodeInfo.batchCode,
productBarcode=mesBaseBarcodeInfo.barcodeInfo
};
dbContext.Add(wmsProductOutstockDetail);
dbContext.Update(location);
dbContext.Add(wcsTask);
dbContext.Update(stock);
dbContext.SaveChanges();
if (qty >= needNumber)
{
break;
}
} }
} }
if (item.beginTime == null) if (item.beginTime == null)
{ {
item.beginTime = DateTime.Now; item.beginTime = DateTime.Now;
@ -583,18 +608,39 @@ namespace Khd.Core.Wcs.Wcs
useFlag = 1, useFlag = 1,
qty = outNumber qty = outNumber
}; };
location.outstockFlag = "1"; MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.barcodeInfo == stock.instockBatch).FirstOrDefault();
location.locationStatus = "6"; if (mesBaseBarcodeInfo != null)
location.updateBy = "WCS";
location.updateTime = DateTime.Now;
wcsOutstockLock.boxStatus = 1;
dbContext.Update(location);
dbContext.Add(wcsTask);
dbContext.Update(stock);
dbContext.SaveChanges();
if (qty >= needNumber)
{ {
break; WmsRawOutstockDetail wmsProductOutstockDetail = new WmsRawOutstockDetail()
{
rawOutstockDetailId = StaticData.SnowId.NextId(),
rawOutstockId = item.rawOutstockId,
materialId = item.materialId,
createDate = DateTime.Now,
createBy = "WCS",
taskCode = wcsTask.objid.ToString(),
executeStatus = "1",
locationCode = location.locationCode,
outstockAmount = qty,
planAmount = item.outstockAmount,
warehouseId = item.warehouseId,
materialBarcode= mesBaseBarcodeInfo.barcodeInfo,
instockBatch=mesBaseBarcodeInfo.batchCode
};
dbContext.Add(wmsProductOutstockDetail);
location.outstockFlag = "1";
location.locationStatus = "6";
location.updateBy = "WCS";
location.updateTime = DateTime.Now;
wcsOutstockLock.boxStatus = 1;
dbContext.Update(location);
dbContext.Add(wcsTask);
dbContext.Update(stock);
dbContext.SaveChanges();
if (qty >= needNumber)
{
break;
}
} }
} }
if (item.beginTime == null) if (item.beginTime == null)

@ -571,6 +571,12 @@ namespace Khd.Core.Wcs.Wcs
} }
else if (item.taskType == 38)//出库 else if (item.taskType == 38)//出库
{ {
var wmsProductOutstockDetail = dbContext.WmsProductOutstockDetail.FirstOrDefault(t => t.productOutstockId == item.orderId);
if(wmsProductOutstockDetail != null)
{
wmsProductOutstockDetail.executeStatus = "2";
dbContext.Update(wmsProductOutstockDetail);
}
BaseEquip lineEquip = StaticData.BaseEquip.First(t=>t.objid==5); BaseEquip lineEquip = StaticData.BaseEquip.First(t=>t.objid==5);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation
.First(t => t.locationId == item.endPointId && t.warehouseFloor == 5); .First(t => t.locationId == item.endPointId && t.warehouseFloor == 5);

@ -133,7 +133,7 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
} }
catch(Exception ex) catch (Exception ex)
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
@ -208,16 +208,16 @@ namespace Khd.Core.Wcs.Wcs
try try
{ {
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload()); dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var taskList = dbContext.WcsTask.Where(t => t.nextPointId == CTUID).OrderBy(t=>t.createTime).ToList(); var taskList = dbContext.WcsTask.Where(t => t.nextPointId == CTUID).OrderBy(t => t.createTime).ToList();
if (taskList.Count == 0) if (taskList.Count == 0)
{ {
LogManager.Info(FloorNo + "楼CTU无任务"); LogManager.Info(FloorNo + "楼CTU无任务");
} }
foreach (var item in taskList) foreach (var item in taskList)
{ {
if (!taskList.Where(t => t.taskType == 29 && t.ud1 == "2").Any()) if (!taskList.Where(t => t.taskType == 29 && t.CTUExecute == "2").Any())
{ {
if (item.ud1 == "1") if (item.CTUExecute == "1")
{ {
ExecuteInTask(baseEquip); ExecuteInTask(baseEquip);
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First(); WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
@ -225,7 +225,7 @@ namespace Khd.Core.Wcs.Wcs
wcsOutstockLock.boxStatus = 0; wcsOutstockLock.boxStatus = 0;
dbContext.Update(wcsOutstockLock); dbContext.Update(wcsOutstockLock);
isWait = false; isWait = false;
item.ud1 = "2"; item.CTUExecute = "2";
dbContext.Update(item); dbContext.Update(item);
} }
} }
@ -373,7 +373,6 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (wcsCmd.cmdStatus == 3) if (wcsCmd.cmdStatus == 3)
{ {
if (item.taskType == 30) if (item.taskType == 30)
{ {
var canOut = this._plc.Read(isput.plcpointAddress); var canOut = this._plc.Read(isput.plcpointAddress);
@ -429,23 +428,21 @@ namespace Khd.Core.Wcs.Wcs
} }
else if (wcsCmd.cmdStatus == 5) else if (wcsCmd.cmdStatus == 5)
{ {
//任务完成 if (item.taskType == 30)//出库任务
//如果是出库任务,更新库存信息,并删除任务
if (item.taskType == 30)
{ {
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation
.First(t => t.locationId == item.startPointId && t.warehouseFloor == 5); .First(t => t.locationId == item.startPointId && t.warehouseFloor == 5);
wmsBaseLocation.outstockFlag = "0"; wmsBaseLocation.outstockFlag = "0";
wmsBaseLocation.locationStatus = "1"; wmsBaseLocation.locationStatus = "1";
dbContext.Update(wmsBaseLocation); dbContext.Update(wmsBaseLocation);
dbContext.WmsRawOutstockDetail.Where(t => t.locationCode == wmsBaseLocation.locationCode).Update(t => new WmsRawOutstockDetail { executeStatus = "2" });
dbContext.WcsCmd.Where(t => t.objid == wcsCmd.objid).Delete(); dbContext.WcsCmd.Where(t => t.objid == wcsCmd.objid).Delete();
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog() { cmdStatus = 6 }); dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog() { cmdStatus = 6 });
dbContext.WcsTask.Where(t => t.objid == item.objid).Delete(); dbContext.WcsTask.Where(t => t.objid == item.objid).Delete();
dbContext.WcsTaskLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsTaskLog() { taskStatus = 6 }); dbContext.WcsTaskLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsTaskLog() { taskStatus = 6 });
dbContext.SaveChanges(); dbContext.SaveChanges();
} }
else//如果是入库任务,更新库存信息,下一个任务为提升机 else if (item.taskType == 29)//入库任务
{ {
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation
.First(t => t.locationId == item.endPointId && t.warehouseFloor == 5); .First(t => t.locationId == item.endPointId && t.warehouseFloor == 5);
@ -499,48 +496,12 @@ namespace Khd.Core.Wcs.Wcs
else else
{ {
LogManager.Info("下发CTU执行入库任务失败"); LogManager.Info("下发CTU执行入库任务失败");
Console.WriteLine($"{DateTime.Now}:下发CTU执行入库任务失败" + executeReponse?.message);
ExecuteInTask(baseEquip);
Thread.Sleep(1000);
} }
} }
} }
/// <summary>
/// 下发任务
/// </summary>
/// <param name="task"></param>
public void SendTask(long? orderId)
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var taskList = dbContext.WcsTask.Where(t => t.orderId == orderId).ToList();
//获取
if (taskList.Count == 0)
return;
//首先判断是否已下发指令
var cmd = dbContext.WcsCmd.Where(t => taskList.Select(t => t.objid).ToList().Contains(t.taskId.GetValueOrDefault())).FirstOrDefault();
//指令表存在说明已下发
if (cmd != null) return;
//获取下发agv指令
string ip = ""; int port = 0; string url = "";
RequestAGVTaskDto agvtask = new RequestAGVTaskDto();
agvtask.reqCode = orderId.ToString();
var json = JsonConvert.SerializeObject(agvtask);
HttpHelper.SendPostMessage(ip, port, url, json);
foreach (var item in taskList)
{
//未下发给agv下发指令
WcsCmd taskCmd = new WcsCmd()
{
taskId = item.objid,
cmdType = item.taskType,
serialNo = item.serialNo,
equipmentNo = item.equipmentNo,
cmdStatus = 1,
createBy = FloorNo + "楼CTU",
createTime = DateTime.Now,
};
dbContext.Add(taskCmd);
dbContext.SaveChanges();
}
}
} }
} }

@ -192,7 +192,7 @@ namespace Khd.Core.Wcs.Wcs
var wmsRawOutstock = dbContext.WmsRawOutstock.FirstOrDefault(t => t.orderId == wcsTask.orderId); var wmsRawOutstock = dbContext.WmsRawOutstock.FirstOrDefault(t => t.orderId == wcsTask.orderId);
if (wmsRawOutstock != null) if (wmsRawOutstock != null)
{ {
BaseEquip endEquip = StaticData.BaseEquip.FirstOrDefault(t => t.equipNo == wmsRawOutstock.endStationCode); var endEquip = StaticData.BaseEquip.FirstOrDefault(t => t.equipNo == wmsRawOutstock.endStationCode);
if (endEquip != null) if (endEquip != null)
{ {
floor = endEquip.floorNo; floor = endEquip.floorNo;
@ -245,119 +245,5 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
} }
public WcsTask? GetTask(string containerNo, int floorNo, string equipNo)
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var wcsTask = new WcsTask();
var wareHouseList = StaticData.WmsBaseWarehouse.ToList();
try
{
//获取条码号,如果该条码任务存在就继续任务,如果条码不存在,创建入库任务并调度agv
var task = StaticData.WcsTask.Where(t => t.containerNo == containerNo).FirstOrDefault();
if (task == null)
{
var palletInfo = StaticData.MesBasePalletInfo.Where(t => t.palletInfoCode == containerNo).FirstOrDefault();
//查询该条码绑定的物料信息
var material = StaticData.WmsWarehouseMaterial.Where(t => t.storageId == palletInfo.materialId).FirstOrDefault();
var wareHouse = wareHouseList.Where(t => t.warehouseId == material.warehouseId).FirstOrDefault();
var dic = StaticData.BaseDictionary.Where(t => t.dicKey == "TaskType" && t.agvType == "I" && t.dicField == wareHouse.warehouseInstockType).FirstOrDefault();
var equip = StaticData.BaseEquip.ToList();
var startEquip = equip.Where(t => t.equipNo == equipNo).FirstOrDefault();
var endPoint = wareHouseList.Where(t => t.warehouseFloor == floorNo).FirstOrDefault();
if (palletInfo != null && startEquip != null && material != null && dic != null && endPoint != null)
{
//自动获取id
var objid = StaticData.SnowId.NextId();
WcsTask newTask = new()
{
objid = objid,
taskType = Convert.ToInt32(dic.dicValue),
containerNo = containerNo,
taskStatus = 0,
materialId = material.storageId,
qty = Convert.ToInt32(palletInfo.bindAmount),
startPointId = startEquip.objid,
startPointNo = equipNo,
currPointId = startEquip.objid,
currPointNo = equipNo,
endPointId = endPoint.warehouseId,
endPointNo = endPoint.warehouseCode,
};
dbContext.Add(newTask);
dbContext.SaveChanges();
wcsTask = newTask;
}
else
{
LogManager.Info(floorNo + "楼接驳位,托盘" + containerNo + "未绑定!");
}
}
else
{
wcsTask = StaticData.WcsTask.Where(t => t.currPointNo == equipNo).FirstOrDefault();
}
}
catch (Exception ex)
{
LogManager.Info(floorNo + "楼接驳位异常" + ex.Message);
throw;
}
return wcsTask;
}
/// <summary>
/// 下发任务
/// </summary>
/// <param name="task"></param>
public void SendTask(WcsTask task)
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
//入库类型
List<int> taskInType = new List<int> { 1, 3, 5, 7 };
List<int> taskOutType = new List<int> { 2, 4, 6, 8 };
try
{
//获取
if (task == null) return;
if (taskInType.Contains(task.taskType.GetValueOrDefault()))
{
//首先判断是否已下发指令
var cmd = StaticData.WcsCmd.Where(t => t.taskId == task.objid).FirstOrDefault();
//指令表存在说明已下发
if (cmd != null) return;
//获取下发agv指令
string ip = ""; int port = 0; string url = "";
RequestAGVTaskDto agvtask = new RequestAGVTaskDto();
agvtask.reqCode = task.serialNo.ToString();
var json = JsonConvert.SerializeObject(agvtask);
HttpHelper.SendPostMessage(ip, port, url, json);
//未下发给agv下发指令
WcsCmd taskCmd = new WcsCmd()
{
taskId = task.objid,
cmdType = task.taskType,
serialNo = task.serialNo,
equipmentNo = task.equipmentNo,
cmdStatus = 1,
createBy = "",
createTime = DateTime.Now,
};
dbContext.Add(taskCmd);
dbContext.SaveChanges();
}
else
{
}
}
catch (Exception)
{
throw;
}
}
} }
} }

@ -75,6 +75,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload()); dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
//获取条码号,如果该条码任务存在就继续任务,如果条码不存在,创建入库任务并调度agv //获取条码号,如果该条码任务存在就继续任务,如果条码不存在,创建入库任务并调度agv
var taskList = dbContext.WcsTask.Where(t => t.nextPointId == EquipID).ToList(); var taskList = dbContext.WcsTask.Where(t => t.nextPointId == EquipID).ToList();
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -85,78 +85,102 @@ namespace Khd.Core.Wcs.Wcs
{ {
BaseEquip baseEquip = StaticData.BaseEquip.First(t => t.floorNo == 3 && t.equipType == 1); BaseEquip baseEquip = StaticData.BaseEquip.First(t => t.floorNo == 3 && t.equipType == 1);
var wcsTask = dbContext.WcsTask.FirstOrDefault(t => t.containerNo == rfid && t.nextPointId == baseEquip.objid); var wcsTask = dbContext.WcsTask.FirstOrDefault(t => t.containerNo == rfid && t.nextPointId == baseEquip.objid);
var AgvEquip = StaticData.BaseEquip.First(t => t.floorNo == 3 && t.equipType == 4);//背负Agv
if (wcsTask != null)//如果不是null if (wcsTask != null)//如果不是null
{ {
if (wcsTask.taskStatus == 5)//提升机任务是完成状态 if (wcsTask.taskStatus == 5)//提升机任务是完成状态
{ {
var wmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseFloor == FloorNo) if (wcsTask.isEmpty == "1")
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.instockFlag == "0")
.Where(t => t.outstockFlag == "0")
.ToList();
List<string> containerCodes = wmsBaseLocations.Where(t => t.locDeep == 1).Select(t => t.containerCode).ToList();//深库位的托盘
List<MesBasePalletInfo> mesBasePalletInfos = dbContext.MesBasePalletInfo
.Where(t => t.materialId == wcsTask.materialId)
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料
var bill = from a in mesBasePalletInfos
join b in wmsBaseLocations.Where(t => t.locDeep == 1) on a.palletInfoCode equals b.containerCode
select new { b };//等于当前任务的物料的托盘的库位信息
var outBill = from a in bill
from b in wmsBaseLocations
where a.b.layerNum == b.layerNum
&& b.locDeep == 2
&& a.b.locRow == b.locRow
&& a.b.locColumn == b.locColumn
&& b.locationStatus == "1"
&& b.outstockFlag == "0"
&& b.instockFlag == "0"
&& string.IsNullOrEmpty(b.containerCode)
select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
WmsBaseLocation? wmsBaseLocation = null;
wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 2);//找不到再找深库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
//深浅库位问题?库位入库优先级等
var AgvEquip = StaticData.BaseEquip.First(t => t.floorNo == 3 && t.equipType == 4);//背负Agv
if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null)
{ {
wcsTask.taskStatus = 0;//创建状态 var emptyEquip = StaticData.BaseEquip.FirstOrDefault(t => t.equipType == 15 && t.emptyCount == 0);
wcsTask.updateTime = DateTime.Now; if(emptyEquip != null)
wcsTask.currPointId = baseEquip.objid;
wcsTask.currPointNo = baseEquip.equipNo;
wcsTask.nextPointId = AgvEquip.objid;
wcsTask.nextPointNo = AgvEquip.equipNo;
wcsTask.endPointId = wmsBaseLocation.locationId;
wcsTask.endPointNo = wmsBaseLocation.locationCode;
if (wmsBaseLocation.warehouseId == 311)
{ {
wcsTask.taskType = 39; wcsTask.taskStatus = 0;//创建状态
wcsTask.updateTime = DateTime.Now;
wcsTask.currPointId = baseEquip.objid;
wcsTask.currPointNo = baseEquip.equipNo;
wcsTask.nextPointId = AgvEquip.objid;
wcsTask.nextPointNo = AgvEquip.equipNo;
wcsTask.endPointId = emptyEquip.objid;
wcsTask.endPointNo = emptyEquip.equipNo;
wcsTask.useFlag = 1;
dbContext.Update(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
} }
else
{
Console.WriteLine("查找入库库位失败");
Thread.Sleep(1000);
continue;
}
wcsTask.useFlag = 1;
wmsBaseLocation.instockFlag = "1";
wmsBaseLocation.locationStatus = "2";
dbContext.Update(wmsBaseLocation);
dbContext.Update(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
} }
else else
{ {
Console.WriteLine(DateTime.Now + ":三楼楼接驳位调度入库任务,未找到库位"); var wmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseFloor == FloorNo)
LogManager.Info("三楼接驳位调度入库任务,未找到库位"); .Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.instockFlag == "0")
.Where(t => t.outstockFlag == "0")
.ToList();
List<string> containerCodes = wmsBaseLocations.Where(t => t.locDeep == 1).Select(t => t.containerCode).ToList();//深库位的托盘
List<MesBasePalletInfo> mesBasePalletInfos = dbContext.MesBasePalletInfo
.Where(t => t.materialId == wcsTask.materialId)
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料
var bill = from a in mesBasePalletInfos
join b in wmsBaseLocations.Where(t => t.locDeep == 1) on a.palletInfoCode equals b.containerCode
select new { b };//等于当前任务的物料的托盘的库位信息
var outBill = from a in bill
from b in wmsBaseLocations
where a.b.layerNum == b.layerNum
&& b.locDeep == 2
&& a.b.locRow == b.locRow
&& a.b.locColumn == b.locColumn
&& b.locationStatus == "1"
&& b.outstockFlag == "0"
&& b.instockFlag == "0"
&& string.IsNullOrEmpty(b.containerCode)
select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
WmsBaseLocation? wmsBaseLocation = null;
wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 2);//找不到再找深库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
//深浅库位问题?库位入库优先级等
if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null)
{
wcsTask.taskStatus = 0;//创建状态
wcsTask.updateTime = DateTime.Now;
wcsTask.currPointId = baseEquip.objid;
wcsTask.currPointNo = baseEquip.equipNo;
wcsTask.nextPointId = AgvEquip.objid;
wcsTask.nextPointNo = AgvEquip.equipNo;
wcsTask.endPointId = wmsBaseLocation.locationId;
wcsTask.endPointNo = wmsBaseLocation.locationCode;
if (wmsBaseLocation.warehouseId == 311)
{
wcsTask.taskType = 39;
}
else
{
Console.WriteLine("查找入库库位失败");
Thread.Sleep(1000);
continue;
}
wcsTask.useFlag = 1;
wmsBaseLocation.instockFlag = "1";
wmsBaseLocation.locationStatus = "2";
dbContext.Update(wmsBaseLocation);
dbContext.Update(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
}
else
{
Console.WriteLine(DateTime.Now + ":三楼楼接驳位调度入库任务,未找到库位");
LogManager.Info("三楼接驳位调度入库任务,未找到库位");
}
} }
} }
else if (wcsTask.taskStatus == 6)//小车任务是完成状态,说明是出库 else if (wcsTask.taskStatus == 6)//小车任务是完成状态,说明是出库

@ -1,6 +1,7 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
//"DefaultConnection": "server=106.12.13.113;port=3336;database=khd_jyhb;uid=khd;pwd=khd@123;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True", //"DefaultConnection": "server=106.12.13.113;port=3336;database=khd_jyhb;uid=khd;pwd=khd@123;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True",
//"DefaultConnection": "server=172.16.12.100;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khdrkjy2024...;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
"DefaultConnection": "server=localhost;port=3306;database=jyhb;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True" "DefaultConnection": "server=localhost;port=3306;database=jyhb;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
//"DefaultConnection": "server=175.27.215.92;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khd2024;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True" //"DefaultConnection": "server=175.27.215.92;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khd2024;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
}, },
@ -13,22 +14,22 @@
"Slot": 1, "Slot": 1,
"Code": 0 "Code": 0
}, },
//{ {
// "IP": "192.168.2.31", "IP": "192.168.2.31",
// "Port": 102, //102 "Port": 102, //102
// "CpuType": 40, "CpuType": 40,
// "Rack": 0, "Rack": 0,
// "Slot": 1, "Slot": 1,
// "Code": 1 "Code": 1
//}, },
//{ {
// "IP": "192.168.2.220", "IP": "192.168.2.220",
// "Port": 102, //102 "Port": 102, //102
// "CpuType": 40, "CpuType": 40,
// "Rack": 0, "Rack": 0,
// "Slot": 1, "Slot": 1,
// "Code": 2 "Code": 2
//} }
], ],
"PLCSetting": { "PLCSetting": {
"Mode": "0", "Mode": "0",

@ -4,6 +4,11 @@
xmlns:local="clr-namespace:Khd.Core.Wpf" xmlns:local="clr-namespace:Khd.Core.Wpf"
StartupUri="LoginPage.xaml"> StartupUri="LoginPage.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources> </Application.Resources>
</Application> </Application>

@ -4,14 +4,15 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Khd.Core.Wpf.myConverter" xmlns:local="clr-namespace:Khd.Core.Wpf.myConverter"
mc:Ignorable="d" WindowStyle="None" mc:Ignorable="d"
WindowStyle="None"
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
xmlns:hc="https://handyorg.github.io/handycontrol"
WindowState="Maximized" WindowState="Maximized"
Title="FormBoardT" Title="FormBoardT"
Loaded="FormBoard_Loaded" Loaded="FormBoard_Loaded"
Width="1920" Width="1920"
Height="1080" Height="1080"
> >
<Window.Resources> <Window.Resources>
<ResourceDictionary> <ResourceDictionary>
@ -97,7 +98,7 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
<Style TargetType="TabItem"> <Style TargetType="TabItem" x:Key="DefaultItem">
<Setter Property="Background" Value="#213269"/> <Setter Property="Background" Value="#213269"/>
<!--设置背景色--> <!--设置背景色-->
<Setter Property="Template"> <Setter Property="Template">
@ -387,7 +388,7 @@
<Canvas Width="1880" Height="1080" > <Canvas Width="1880" Height="1080" >
<Grid Width="1880" Height="1080"> <Grid Width="1880" Height="1080">
<TabControl Background="Transparent" BorderThickness="0" HorizontalAlignment="Center" VerticalContentAlignment="Center" SelectionChanged="TabControl_SelectionChanged" TabStripPlacement="Left" Width="1890" Margin="-10,0,0,0"> <TabControl Background="Transparent" BorderThickness="0" HorizontalAlignment="Center" VerticalContentAlignment="Center" SelectionChanged="TabControl_SelectionChanged" TabStripPlacement="Left" Width="1890" Margin="-10,0,0,0">
<TabItem Header="任务管理" Foreground="White" FontSize="25" Width="160" Height="125" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5" > <TabItem Header="任务管理" Style="{StaticResource DefaultItem}" Background="#213269" Foreground="White" FontSize="25" Width="160" Height="125" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5" >
<StackPanel <StackPanel
x:Name="essentialData" x:Name="essentialData"
Canvas.Left="174" Canvas.Left="174"
@ -395,11 +396,11 @@
Width="1714" Width="1714"
Height="1060" Height="1060"
Background="#213269" Margin="0,-15,0,0"> Background="#213269" Margin="0,-15,0,0">
<Label <TextBlock
Width="125" Width="125"
Height="70" Height="70"
Margin="-1500,20,0,-100" Margin="-1500,20,0,-100"
Content="设备编号 :" Text="设备编号 :"
FontSize="25" FontSize="25"
Foreground="White" Foreground="White"
/> />
@ -407,11 +408,11 @@
></Border> ></Border>
<TextBox x:Name="lba_ThrifTtitle1" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true" <TextBox x:Name="lba_ThrifTtitle1" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="-1150,-8,0,-100"></TextBox> Width="180" Height="50" Margin="-1150,-8,0,-100"></TextBox>
<Label <TextBlock
Width="125" Width="125"
Height="70" Height="70"
Margin="-800,20,0,-100" Margin="-800,20,0,-100"
Content="容器号 :" Text="容器号 :"
FontSize="25" FontSize="25"
Foreground="White" Foreground="White"
/> />
@ -419,7 +420,7 @@
></Border> ></Border>
<TextBox x:Name="lba_ThrifTtitle2" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true" <TextBox x:Name="lba_ThrifTtitle2" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="-500,-8,0,-100"></TextBox> Width="180" Height="50" Margin="-500,-8,0,-100"></TextBox>
<Button Content="搜索" Margin="-100,-8,0,-100" Foreground="White" Height="50" Width="132" Click="btnGetTask_Click"> <Button Content="搜索" Margin="-100,-8,0,-100" Foreground="White" Height="50" FontSize="25" Width="132" Click="btnGetTask_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -430,7 +431,7 @@
</Button.Template> </Button.Template>
</Button> </Button>
<Button Content="创建任务" Margin="200,-8,0,-100" Foreground="White" Height="50" Width="132" Click="AddTaskButton_Click"> <Button Content="创建任务" Margin="200,-8,0,-100" FontSize="25" Foreground="White" Height="50" Width="132" Click="AddTaskButton_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -440,7 +441,7 @@
</ControlTemplate> </ControlTemplate>
</Button.Template> </Button.Template>
</Button> </Button>
<Button Content="删除任务" Margin="500,-8,0,-100" Foreground="White" Height="50" Width="132" Click="btnDelTask_Click"> <Button Content="删除任务" Margin="500,-8,0,-100" FontSize="25" Foreground="White" Height="50" Width="132" Click="btnDelTask_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -450,7 +451,7 @@
</ControlTemplate> </ControlTemplate>
</Button.Template> </Button.Template>
</Button> </Button>
<Button Content="开始任务" Margin="800,-8,0,-100" Foreground="White" Height="50" Width="132" Click="btnEditTask_Click"> <Button Content="开始任务" Margin="800,-8,0,-100" FontSize="25" Foreground="White" Height="50" Width="132" Click="btnEditTask_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -794,7 +795,7 @@
</DataGrid> </DataGrid>
</Grid> </Grid>
</TabItem>--> </TabItem>-->
<TabItem Header="设备管理" Foreground="White" FontSize="25" Width="160" Height="125" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5" > <TabItem Header="设备管理" Background="#213269" Style="{StaticResource DefaultItem}" Foreground="White" FontSize="25" Width="160" Height="125" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5" >
<StackPanel <StackPanel
x:Name="materialBom" x:Name="materialBom"
Canvas.Left="174" Canvas.Left="174"
@ -802,11 +803,11 @@
Width="1714" Width="1714"
Height="1060" Height="1060"
Background="#213269" Margin="0,-15,0,0"> Background="#213269" Margin="0,-15,0,0">
<Label <TextBlock
Width="125" Width="125"
Height="70" Height="70"
Margin="-1500,20,0,-100" Margin="-1500,20,0,-100"
Content="设备编号 :" Text="设备编号 :"
FontSize="25" FontSize="25"
Foreground="White" Foreground="White"
/> />
@ -814,7 +815,7 @@
></Border> ></Border>
<TextBox x:Name="lba_ThrifTtitle3" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true" <TextBox x:Name="lba_ThrifTtitle3" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="-1150,-8,0,-100"></TextBox> Width="180" Height="50" Margin="-1150,-8,0,-100"></TextBox>
<Button Content="搜索" Margin="-700,-8,0,-100" Foreground="White" Height="50" Width="132" Click="btnGetEquip_Click"> <Button Content="搜索" FontSize="25" Margin="-700,-8,0,-100" Foreground="White" Height="50" Width="132" Click="btnGetEquip_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -957,7 +958,7 @@
<Label Content="Label"/> <Label Content="Label"/>
</StackPanel> </StackPanel>
</TabItem> </TabItem>
<TabItem Header="库存信息" Foreground="White" FontSize="25" Width="160" Height="125" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5" > <TabItem Header="库存信息" Background="#213269" Style="{StaticResource DefaultItem}" Foreground="White" FontSize="25" Width="160" Height="125" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5" >
<StackPanel <StackPanel
x:Name="orderControl" x:Name="orderControl"
Canvas.Left="174" Canvas.Left="174"
@ -965,11 +966,11 @@
Width="1714" Width="1714"
Height="1060" Height="1060"
Background="#213269" Margin="0,-15,0,0" > Background="#213269" Margin="0,-15,0,0" >
<Label <TextBlock
Width="125" Width="125"
Height="70" Height="70"
Margin="-1500,20,0,-100" Margin="-1500,20,0,-100"
Content="物料编码 :" Text="物料编码 :"
FontSize="25" FontSize="25"
Foreground="White" Foreground="White"
/> />
@ -977,21 +978,21 @@
></Border> ></Border>
<TextBox x:Name="lba_ThrifTtitle5" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true" <TextBox x:Name="lba_ThrifTtitle5" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="-1150,-8,0,-100"></TextBox> Width="180" Height="50" Margin="-1150,-8,0,-100"></TextBox>
<Label <TextBlock
Width="125" Width="125"
Height="70" Height="70"
Margin="-800,20,0,-100" Margin="-800,20,0,-100"
Content="库位 :" Text="库位 :"
FontSize="25" FontSize="25"
Foreground="White" Foreground="White"
/> />
<Border></Border> <Border></Border>
<TextBox x:Name="lba_ThrifTtitle6" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true" <TextBox x:Name="lba_ThrifTtitle6" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="-550,-8,0,-100"></TextBox> Width="180" Height="50" Margin="-550,-8,0,-100"></TextBox>
<Label Width="125" Height="70" Margin="-100,20,0,-100" Content="仓库 :" FontSize="25" Foreground="White"/> <TextBlock Width="125" Height="70" Margin="-100,20,0,-100" Text="仓库 :" FontSize="25" Foreground="White"/>
<Border></Border> <Border></Border>
<ComboBox x:Name="WarehourseId" DisplayMemberPath="warehouseName" Height="50" Margin="140,0,0,-100" Width="200" FontSize="25" /> <ComboBox x:Name="WarehourseId" DisplayMemberPath="warehouseName" Height="50" Margin="140,0,0,-100" Width="200" FontSize="25" />
<Button Content="搜索" Margin="600,-8,0,-100" Foreground="White" Height="50" Width="132" Click="btnGetStocK_Click"> <Button Content="搜索" FontSize="25" Margin="600,-8,0,-100" Foreground="White" Height="50" Width="132" Click="btnGetStocK_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -1005,11 +1006,10 @@
<Grid Width="1711" Height="1070" HorizontalAlignment="Left"> <Grid Width="1711" Height="1070" HorizontalAlignment="Left">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="10*"/> <RowDefinition Height="10*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="88*"/> <RowDefinition Height="88*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Background="#172557" Grid.Row="1"></Grid> <Grid Grid.Row="1">
<Grid Grid.Row="2">
<DataGrid <DataGrid
x:Name="LoadMaterial1" x:Name="LoadMaterial1"
AlternationCount="2" AlternationCount="2"
@ -1072,14 +1072,14 @@
IsReadOnly="True" /> IsReadOnly="True" />
<DataGridTextColumn <DataGridTextColumn
Width="150*" Width="300*"
Binding="{Binding locationCode}" Binding="{Binding locationCode}"
CanUserSort="False" CanUserSort="False"
ElementStyle="{StaticResource dgCell}" ElementStyle="{StaticResource dgCell}"
FontSize="20" FontSize="20"
Header="库位" Header="库位"
IsReadOnly="True" /> IsReadOnly="True" />
<DataGridTextColumn <DataGridTextColumn
Width="180*" Width="180*"
Binding="{Binding floorNo}" Binding="{Binding floorNo}"
CanUserSort="False" CanUserSort="False"
@ -1154,6 +1154,9 @@
</DataGrid.ColumnHeaderStyle> </DataGrid.ColumnHeaderStyle>
</DataGrid> </DataGrid>
</Grid> </Grid>
<Grid Grid.Row="2" HorizontalAlignment="Center">
<hc:Pagination x:Name="Pagination1" MaxWidth="1500" MaxPageCount="1" Margin="0,0,0,15" PageUpdated="Pagination_PageUpdated" IsJumpEnabled="True" HorizontalAlignment="Center" Width="339" />
</Grid>
</Grid> </Grid>
</StackPanel> </StackPanel>
</TabItem> </TabItem>
@ -1405,18 +1408,18 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</TabItem>--> </TabItem>-->
<TabItem Header="物料扫描" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="125" Margin="5"> <TabItem Header="物料扫描" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="125" Margin="5">
<StackPanel x:Name="splMaterialCode" Height="1060" Width="1703" Background="#213269" Canvas.Left="175" Canvas.Top="110" Orientation="Horizontal"> <StackPanel x:Name="splMaterialCode" Height="1060" Width="1703" Background="#213269" Canvas.Left="175" Canvas.Top="110" Orientation="Horizontal">
<StackPanel Orientation="Horizontal" Width="1750"> <StackPanel Orientation="Horizontal" Width="1750">
<StackPanel Orientation="Vertical" Margin="20,5,0,0"> <StackPanel Orientation="Vertical" Margin="20,5,0,0">
<StackPanel Orientation="Horizontal" Margin="0" HorizontalAlignment="Left"> <!--<StackPanel Orientation="Horizontal" Margin="0" HorizontalAlignment="Left">
<Image <Image
x:Name="img_plcmesssage1" x:Name="img_plcmesssage1"
Width="40" Width="40"
Height="35" Height="35"
Margin="60,0,0,0" Margin="60,0,0,0"
Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/> Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/>
<Label Content="人工叫料" Foreground="White" FontSize="20" Width="150" Height="40" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> <Label Content="人工叫料" Foreground="White" FontSize="20" Width="150" Height="40" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
</StackPanel> </StackPanel>
<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Margin="0,5,0,0"> <Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Margin="0,5,0,0">
@ -1453,7 +1456,7 @@
</Button> </Button>
</StackPanel> </StackPanel>
</Border> </Border>-->
<StackPanel Orientation="Horizontal" Margin="0"> <StackPanel Orientation="Horizontal" Margin="0">
<Image <Image
x:Name="img_plcmesssage2" x:Name="img_plcmesssage2"
@ -1461,42 +1464,42 @@
Height="35" Height="35"
Margin="60,0,0,0" Margin="60,0,0,0"
Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/> Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/>
<Label Content="物料扫描" Foreground="White" FontSize="20" Width="150" Height="40" Margin="10,10,80,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> <TextBlock Text="物料扫描" Foreground="White" FontSize="20" Width="150" Height="40" Margin="10,10,80,0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel> </StackPanel>
<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Height="500" Margin="0,5,0,0"> <Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Height="500" Margin="0,5,0,0">
<StackPanel Margin="0,10,10,10"> <StackPanel Margin="0,10,10,10">
<Label <TextBlock
Width="152" Width="152"
Height="73" Height="37"
Content="业务类型 :" Text="业务类型 :"
FontSize="25" Margin="0,0,750,-60" FontSize="25" Margin="0,20,750,-60"
Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"
/> />
<ComboBox x:Name="cbxType" Margin="0,0,400,0" Width="180" Height="50" > <ComboBox x:Name="cbxType" Margin="0,10,400,0" Width="180" Height="50" >
<ComboBoxItem Content="入库" IsSelected="True"/> <ComboBoxItem Content="入库" IsSelected="True"/>
<ComboBoxItem Content="出库" /> <ComboBoxItem Content="出库" />
<ComboBoxItem Content="回库" /> <ComboBoxItem Content="回库" />
</ComboBox> </ComboBox>
<Label <TextBlock
Width="152" Width="152"
Height="73" Height="36"
Content="料箱 :" Text="料箱 :"
FontSize="25" Margin="0,0,750,-60" FontSize="25" Margin="0,30,750,-60"
Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"
/> />
<TextBox x:Name="txtBox" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true" <TextBox x:Name="txtBox" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="0,0,400,0" KeyDown="txtBox_KeyDown"/> Width="180" Height="50" Margin="0,15,400,0" KeyDown="txtBox_KeyDown"/>
<Label <TextBlock
Width="152" Width="152"
Height="73" Height="39"
Content="条码:" Text="条码:"
FontSize="25" Margin="0,0,750,-60" FontSize="25" Margin="0,20,750,-60"
Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"
/> />
<TextBox x:Name="txtBarCode" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true" <TextBox x:Name="txtBarCode" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="0,0,400,0" TextChanged="txtBarCode_KeyDown"/> Width="180" Height="50" Margin="0,20,400,0" TextChanged="txtBarCode_KeyDown"/>
<Button Content="清除料箱条码" Margin="400,-180,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="170" Click="clearRFID_Click"> <Button Content="清除料箱条码" FontSize="25" Margin="400,-180,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="170" Click="clearRFID_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -1506,7 +1509,7 @@
</ControlTemplate> </ControlTemplate>
</Button.Template> </Button.Template>
</Button> </Button>
<Button Content="清除条码" Margin="400,-50,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="170" Click="clearBarCode_Click"> <Button Content="清除条码" FontSize="25" Margin="400,-50,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="170" Click="clearBarCode_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -1516,17 +1519,17 @@
</ControlTemplate> </ControlTemplate>
</Button.Template> </Button.Template>
</Button> </Button>
<Label <TextBlock
Width="152" Width="152"
Height="73" Height="42"
Content="已扫描数量:" Text="已扫描数量:"
FontSize="25" Margin="0,0,750,-60" FontSize="25" Margin="0,20,750,-60"
Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White"
/> />
<TextBox x:Name="txtScan" Style="{StaticResource XingHaoBianMaYangShi}" IsReadOnly="True" <TextBox x:Name="txtScan" Style="{StaticResource XingHaoBianMaYangShi}" IsReadOnly="True"
Width="180" Height="50" Margin="0,0,400,0" IsEnabled="False" /> Width="180" Height="50" Margin="0,10,400,0" IsEnabled="False" />
<Button Content="确认" Margin="150,30,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="132" Click="btnConfirmBox_Click"> <Button Content="确认" FontSize="25" Margin="150,30,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="132" Click="btnConfirmBox_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -1537,7 +1540,18 @@
</Button.Template> </Button.Template>
</Button> </Button>
<Button Content="背负式小车捡料完成" Margin="50,50,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="300" Click="btnBearConfirmBox_Click"> <Button Content="背负式小车捡料完成" FontSize="25" Margin="50,50,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="300" Click="btnBearConfirmBox_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
<Button Content="执行小车入库任务" FontSize="25" Margin="500,-50,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="300" Click="btnCtuInConfirmBox_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -1553,7 +1567,7 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</TabItem> </TabItem>
<TabItem Header="PLC信息" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="125" Margin="5"> <TabItem Header="PLC信息" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="#213269" Foreground="White" Width="160" Height="125" Margin="5">
<StackPanel x:Name="splPlcMessage" Height="1060" Width="1729" Background="#213269" Canvas.Left="175" Canvas.Top="110" Orientation="Horizontal"> <StackPanel x:Name="splPlcMessage" Height="1060" Width="1729" Background="#213269" Canvas.Left="175" Canvas.Top="110" Orientation="Horizontal">
<StackPanel Orientation="Horizontal" Width="1750"> <StackPanel Orientation="Horizontal" Width="1750">
<StackPanel Orientation="Vertical" Margin="20,5,0,0"> <StackPanel Orientation="Vertical" Margin="20,5,0,0">
@ -1564,8 +1578,8 @@
Height="35" Height="35"
Margin="60,0,0,0" Margin="60,0,0,0"
Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/> Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/>
<Label Content="PLC交互信息" Foreground="White" FontSize="20" Width="150" Height="40" Margin="10,0,80,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> <TextBlock Text="PLC交互信息" Foreground="White" FontSize="20" Width="150" Height="40" Margin="10,10,80,0"/>
<Button Content="刷新" Foreground="White" Height="50" Width="132" Click="btnRefreshPlc_Click"> <Button Content="刷新" FontSize="25" Foreground="White" Height="50" Width="132" Click="btnRefreshPlc_Click">
<Button.Template > <Button.Template >
<ControlTemplate TargetType="{x:Type Button}" > <ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4"> <Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -1580,7 +1594,7 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1.5*"/> <ColumnDefinition Width="1.5*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
@ -1628,7 +1642,7 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -1685,25 +1699,25 @@
Height="40" Height="40"
Margin="240,0,0,0" Margin="240,0,0,0"
Source="..\Resources\riqi.png" /> Source="..\Resources\riqi.png" />
<Label <TextBlock
x:Name="LabDate" x:Name="LabDate"
Height="55" Height="55"
Margin="25,0,0,0" Margin="25,0,0,0"
FontSize="30" FontSize="30"
Width="255" Width="255"
Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Image <Image
Width="40" Width="40"
Height="40" Height="40"
Margin="20,0,0,0" Margin="20,0,0,0"
Source="..\Resources\shijian.png" /> Source="..\Resources\shijian.png" />
<Label <TextBlock
x:Name="LabTime" x:Name="LabTime"
Height="55" Height="55"
Margin="20,0,0,0" Margin="20,0,0,0"
FontSize="30" FontSize="30"
Width="170" Width="170"
Foreground="White" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/> Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Grid> </Grid>

@ -53,7 +53,7 @@ namespace Khd.Core.Wpf.Form
Dictionary<long, bool> SelectedItem = new Dictionary<long, bool>(); Dictionary<long, bool> SelectedItem = new Dictionary<long, bool>();
Dictionary<long, bool> InSelectedItem = new Dictionary<long, bool>(); Dictionary<long, bool> InSelectedItem = new Dictionary<long, bool>();
public List<MesBaseBarcodeInfo> barcodeLsit = new List<MesBaseBarcodeInfo>(); public List<MesBaseBarcodeInfo> barcodeLsit = new List<MesBaseBarcodeInfo>();
private int pageCount = 15;
private void ScanMessage() private void ScanMessage()
@ -156,7 +156,7 @@ namespace Khd.Core.Wpf.Form
{ {
plc.Open(); plc.Open();
} }
catch(Exception ex) catch (Exception ex)
{ {
LogManager.Error(ex); LogManager.Error(ex);
} }
@ -396,11 +396,17 @@ namespace Khd.Core.Wpf.Form
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void btnGetStocK_Click(object sender, RoutedEventArgs e) private void btnGetStocK_Click(object sender, RoutedEventArgs e)
{
Pagination1.PageIndex = 1;
GetBaseLocations();
}
private void GetBaseLocations()
{ {
if (WarehourseId.SelectedItem is WmsBaseWarehouse warehouse) if (WarehourseId.SelectedItem is WmsBaseWarehouse warehouse)
{ {
using var scope = _host.Services.CreateScope(); var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>(); var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var locationCode = lba_ThrifTtitle6.Text; var locationCode = lba_ThrifTtitle6.Text;
long materialId = 0; long materialId = 0;
try try
@ -411,10 +417,18 @@ namespace Khd.Core.Wpf.Form
{ {
} }
int sum = dbContext.WmsRawStock
.WhereIf(!string.IsNullOrEmpty(lba_ThrifTtitle6.Text), t => t.locationCode.Contains(locationCode))
.WhereIf(!string.IsNullOrEmpty(lba_ThrifTtitle5.Text), t => t.materialId == materialId)
.Where(t => t.warehouseId == warehouse.warehouseId)
.Count();
Pagination1.MaxPageCount = (sum / pageCount) + (sum % pageCount == 0 ? 0 : 1);
var data = dbContext.WmsRawStock var data = dbContext.WmsRawStock
.WhereIf(!string.IsNullOrEmpty(lba_ThrifTtitle6.Text), t => t.locationCode.Contains(locationCode)) .WhereIf(!string.IsNullOrEmpty(lba_ThrifTtitle6.Text), t => t.locationCode.Contains(locationCode))
.WhereIf(!string.IsNullOrEmpty(lba_ThrifTtitle5.Text), t => t.materialId == materialId) .WhereIf(!string.IsNullOrEmpty(lba_ThrifTtitle5.Text), t => t.materialId == materialId)
.Where(t => t.warehouseId == warehouse.warehouseId) .Where(t => t.warehouseId == warehouse.warehouseId)
.Skip((Pagination1.PageIndex - 1) * pageCount)
.Take(pageCount)
.ToList(); .ToList();
this.LoadMaterial1.ItemsSource = null; this.LoadMaterial1.ItemsSource = null;
this.LoadMaterial1.ItemsSource = data; this.LoadMaterial1.ItemsSource = data;
@ -423,15 +437,14 @@ namespace Khd.Core.Wpf.Form
{ {
MessageBox.Show("未查询到数据"); MessageBox.Show("未查询到数据");
} }
} }
else else
{ {
MessageBox.Show("请选择仓库!"); MessageBox.Show("请选择仓库!");
return; return;
} }
} }
///// <summary> ///// <summary>
///// 查询指令信息 ///// 查询指令信息
///// </summary> ///// </summary>
@ -500,51 +513,51 @@ namespace Khd.Core.Wpf.Form
// GetWcsCmd(); // GetWcsCmd();
// } // }
//} //}
/// <summary> ///// <summary>
/// 呼叫料箱 ///// 呼叫料箱
/// </summary> ///// </summary>
/// <param name="sender"></param> ///// <param name="sender"></param>
/// <param name="e"></param> ///// <param name="e"></param>
private void btnCallBox_Click(object sender, RoutedEventArgs e) //private void btnCallBox_Click(object sender, RoutedEventArgs e)
{ //{
try // try
{ // {
if (!string.IsNullOrEmpty(callMaterialId.Text)) // if (!string.IsNullOrEmpty(callMaterialId.Text))
{ // {
using var scope = _host.Services.CreateScope(); // using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>(); // using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
if (int.TryParse(txtNum.Text, out int num)) // if (int.TryParse(txtNum.Text, out int num))
{ // {
WmsRawOutstock wmsRawOutstock = new WmsRawOutstock() // WmsRawOutstock wmsRawOutstock = new WmsRawOutstock()
{ // {
rawOutstockId = _jcSnowId.NextId(), // rawOutstockId = _jcSnowId.NextId(),
taskCode = "task", // taskCode = "task",
warehouseId = 512, // warehouseId = 512,
materialId = Convert.ToInt32(callMaterialId.Text), // materialId = Convert.ToInt32(callMaterialId.Text),
outstockAmount = Convert.ToInt32(txtNum.Text), // outstockAmount = Convert.ToInt32(txtNum.Text),
realOutstockAmount = 0, // realOutstockAmount = 0,
endStationCode = "FL052", // endStationCode = "FL052",
auditStatus = "0", // auditStatus = "0",
operationType = "1", // operationType = "1",
taskType = "1", // taskType = "1",
executeStatus = "0" // executeStatus = "0"
}; // };
dbContext.Add(wmsRawOutstock); // dbContext.Add(wmsRawOutstock);
dbContext.SaveChanges(); // dbContext.SaveChanges();
MessageBox.Show("料箱呼叫任务添加成功!"); // MessageBox.Show("料箱呼叫任务添加成功!");
} // }
else // else
{ // {
MessageBox.Show("请输入有效的数字"); // MessageBox.Show("请输入有效的数字");
} // }
} // }
} // }
catch // catch
{ // {
} // }
} //}
/// <summary> /// <summary>
/// 料箱扫描 /// 料箱扫描
/// </summary> /// </summary>
@ -752,6 +765,9 @@ namespace Khd.Core.Wpf.Form
dbContext.SaveChanges(); dbContext.SaveChanges();
MessageBox.Show("回库成功!"); MessageBox.Show("回库成功!");
} }
barcodeLsit.Clear();
txtScan.Text = string.Empty;
txtBarCode.Text = string.Empty;
} }
catch catch
{ {
@ -897,37 +913,37 @@ namespace Khd.Core.Wpf.Form
barcodeLsit.Clear(); barcodeLsit.Clear();
txtBarCode.Text = string.Empty; txtBarCode.Text = string.Empty;
} }
/// <summary> ///// <summary>
/// 人工叫料失去焦点 ///// 人工叫料失去焦点
/// </summary> ///// </summary>
/// <param name="sender"></param> ///// <param name="sender"></param>
/// <param name="e"></param> ///// <param name="e"></param>
private void callMaterialId_LostFocus(object sender, RoutedEventArgs e) //private void callMaterialId_LostFocus(object sender, RoutedEventArgs e)
{ //{
try // try
{ // {
if (!string.IsNullOrEmpty(callMaterialId.Text)) // if (!string.IsNullOrEmpty(callMaterialId.Text))
{ // {
using var scope = _host.Services.CreateScope(); // using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>(); // using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var material = dbContext.WmsRawStock.Where(t => t.instockBatch == callMaterialId.Text).FirstOrDefault(); // var material = dbContext.WmsRawStock.Where(t => t.instockBatch == callMaterialId.Text).FirstOrDefault();
if (material == null) // if (material == null)
{ // {
MessageBox.Show("批次号不存在!"); // MessageBox.Show("批次号不存在!");
callMaterialId.Text = string.Empty; // callMaterialId.Text = string.Empty;
} // }
else // else
{ // {
} // }
} // }
} // }
catch // catch
{ // {
} // }
} //}
/// <summary> /// <summary>
/// 开始任务 /// 开始任务
/// </summary> /// </summary>
@ -1076,7 +1092,7 @@ namespace Khd.Core.Wpf.Form
CtuTextBlock.Text = SystemData.PlcDic[1].Read(isput.plcpointAddress)?.ToString(); CtuTextBlock.Text = SystemData.PlcDic[1].Read(isput.plcpointAddress)?.ToString();
} }
} }
catch(Exception ex) catch (Exception ex)
{ {
try try
{ {
@ -1101,5 +1117,35 @@ namespace Khd.Core.Wpf.Form
} }
} }
private void btnCtuInConfirmBox_Click(object sender, RoutedEventArgs e)
{
try
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
WcsTask? wcsTask = dbContext.WcsTask.FirstOrDefault(t => t.nextPointId == 11 && t.taskType == 29);
if (wcsTask == null)
{
MessageBox.Show("未查询到当前有CTU入库任务!");
}
else
{
wcsTask.CTUExecute = "1";
dbContext.WcsTask.Update(wcsTask);
dbContext.SaveChanges();
MessageBox.Show("CTU入库任务确认完成成功!");
}
}
catch
{
}
}
private void Pagination_PageUpdated(object sender, HandyControl.Data.FunctionEventArgs<int> e)
{
GetBaseLocations();
}
} }
} }

@ -134,8 +134,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="EPPlus" Version="7.0.2" /> <PackageReference Include="EPPlus" Version="7.0.2" />
<PackageReference Include="HandyControl" Version="3.0.0" /> <PackageReference Include="HandyControl" Version="3.5.0" />
<PackageReference Include="HandyControls" Version="3.3.4" /> <PackageReference Include="HandyControls" Version="3.5.0" />
<PackageReference Include="Masuit.Tools.Core" Version="2.6.7.5" /> <PackageReference Include="Masuit.Tools.Core" Version="2.6.7.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.32.3" /> <PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.32.3" />

Loading…
Cancel
Save