master
2 years ago
parent 702649c670
commit 464524d845

@ -11,10 +11,10 @@
//},
"AllowedHosts": "*",
"ConnectionStrings": {
//"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=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=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",
"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"
},
"JwtSecurityOption": {
"SigningKey": "3c41f60c-1d12-11ec-890d-00163e1b8678",

@ -98,9 +98,9 @@ namespace Khd.Core.Application
wcscmd.sendFlag = 1;
wcscmd.cmdStatus = 3;
wcsTask.taskStatus = 3;
_dbContext.WcsCmd.Where(t => t.objid == wcscmd.objid).Update(a => new WcsCmd { cmdStatus = 3 });
_dbContext.WcsCmd.Update(wcscmd);
_dbContext.WcsCmdLog.Where(t => t.objid == wcscmd.objid).Update(a => new WcsCmdLog { cmdStatus = 3 });
_dbContext.WcsTask.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTask { taskStatus = 3 });
_dbContext.WcsTask.Update(wcsTask);
_dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 3 });
reponseagvCallbackDto.code = "0";
reponseagvCallbackDto.message = "成功";

@ -25,7 +25,7 @@ namespace Khd.Core.Domain.Models
[Column("material_type_id")]
public string MaterialTypeId { get; set; }
[Column("batch_flag")]
public int? BatchFlag { get; set; }
public string BatchFlag { get; set; }
[Column("batch_amount")]
public int? BatchAmount { get; set; }
[Column("material_unit_id")]
@ -41,7 +41,7 @@ namespace Khd.Core.Domain.Models
[Column("gross_weight")]
public decimal? GrossWeight { get; set; }
[Column("bind_flag")]
public decimal? BindFlag { get; set; }
public string BindFlag { get; set; }
[Column("factory_id")]
public string FactoryId { get; set; }
[Column("create_org_id")]
@ -59,11 +59,11 @@ namespace Khd.Core.Domain.Models
[Column("purchase_price_unit_id")]
public long? PurchasePriceUnitId { get; set; }
[Column("create_by")]
public long? CreateBy { get; set; }
public string CreateBy { get; set; }
[Column("create_time")]
public DateTime? CreateTime { get; set; }
[Column("update_by")]
public long? UpdateBy { get; set; }
public string UpdateBy { get; set; }
[Column("update_time")]
public DateTime? UpdateTime { get; set; }
[Column("approve_date")]

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Khd.Core.Domain.Models
{
[Table("wms_inventory_check")]
public class WmsInventoryCheck
{
[Key]
[Column("inventory_check_id")]
public long InventoryCheckId { get; set; }
[Column("inventory_check_code")]
public string InventoryCheckCode { get; set; }
[Column("warehouse_id")]
public long WarehouseId { get; set; }
[Column("check_status")]
public string CheckStatus { get; set; }
[Column("begin_time")]
public DateTime? BeginTime { get; set; }
[Column("end_time")]
public DateTime? EndTime { get; set; }
[Column("location_amount")]
public int LocationAmount { get; set; }
[Column("inventorying_amount")]
public int InventoryingAmount { get; set; }
[Column("inventoried_amount")]
public int InventoriedAmount { get; set; }
[Column("remark")]
public string Remark { get; set; }
[Column("create_by")]
public string CreateBy { get; set; }
[Column("create_date")]
public DateTime? CreateTime { get; set; }
[Column("update_by")]
public string UpdateBy { get; set; }
[Column("update_date")]
public DateTime? UpdateTime { get; set; }
}
}

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Khd.Core.Domain.Models
{
[Table("wms_inventory_check_detail")]
public class WmsInventoryCheckDetail
{
[Key]
[Column("inventory_check_detail_id")]
public long InventoryCheckDetailId { get; set; }
[Column("inventory_check_id")]
public long InventoryCheckId { get; set; }
[Column("material_id")]
public long? MaterialId { get; set; }
[Column("location_code")]
public string LocationCode { get; set; }
[Column("material_batch")]
public string MaterialBatch { get; set; }
[Column("stock_type")]
public string StockType { get; set; }
[Column("stock_id")]
public long? StockId { get; set; }
[Column("stock_amount")]
public decimal? StockAmount { get; set; }
[Column("real_amount")]
public decimal? RealAmount { get; set; }
[Column("check_status")]
public string CheckStatus { get; set; }
[Column("inventory_time")]
public int? InventoryCount { get; set; }
[Column("erp_status")]
public string? ErpStatus { get; set; }
[Column("erp_amount")]
public decimal? ErpAmount { get; set; }
[Column("create_by")]
public string CreateBy { get; set; }
[Column("create_date")]
public DateTime? CreateTime { get; set; }
[Column("update_by")]
public string UpdateBy { get; set; }
[Column("update_date")]
public DateTime? UpdateTime { get; set; }
[Column("check_type")]
public string CheckType { get; set; }
}
}

@ -82,23 +82,23 @@ namespace Khd.Core.Domain.Models
[Column("instock_amount")]
public decimal? instockAmount { get; set; }
/// <summary>
/// 申请原因
/// </summary>
[Column("apply_reason")]
public string applyReason { get; set; }
///// <summary>
///// 申请原因
///// </summary>
//[Column("apply_reason")]
//public string applyReason { get; set; }
/// <summary>
/// 审核原因
/// </summary>
[Column("audit_reason")]
public string auditReason { get; set; }
///// <summary>
///// 审核原因
///// </summary>
//[Column("audit_reason")]
//public string auditReason { get; set; }
/// <summary>
/// 审核状态(0待审核,1审核通过,2审核未通过)
/// </summary>
[Column("audit_status")]
public string auditStatus { get; set; }
///// <summary>
///// 审核状态(0待审核,1审核通过,2审核未通过)
///// </summary>
//[Column("audit_status")]
//public string auditStatus { get; set; }
/// <summary>
/// 执行状态(0待执行,1执行中,2执行完成)
@ -106,29 +106,29 @@ namespace Khd.Core.Domain.Models
[Column("execute_status")]
public string executeStatus { get; set; }
/// <summary>
/// 申请人
/// </summary>
[Column("apply_by")]
public string applyBy { get; set; }
///// <summary>
///// 申请人
///// </summary>
//[Column("apply_by")]
//public string applyBy { get; set; }
/// <summary>
/// 申请时间
/// </summary>
[Column("apply_date")]
public DateTime? applyDate { get; set; }
///// <summary>
///// 申请时间
///// </summary>
//[Column("apply_date")]
//public DateTime? applyDate { get; set; }
/// <summary>
/// 审核人
/// </summary>
[Column("audit_by")]
public string auditBy { get; set; }
///// <summary>
///// 审核人
///// </summary>
//[Column("audit_by")]
//public string auditBy { get; set; }
/// <summary>
/// 审核时间
/// </summary>
[Column("audit_date")]
public DateTime? auditDate { get; set; }
///// <summary>
///// 审核时间
///// </summary>
//[Column("audit_date")]
//public DateTime? auditDate { get; set; }
/// <summary>
/// 最后更新人

@ -14,7 +14,8 @@ namespace Khd.Core.EntityFramework
public DbSet<SysRole> SysRole { get; set; }
public DbSet<SysMenu> SysMenu { get; set; }
public DbSet<WcsAgvStatus> WcsAgvStatus { get; set; }
public DbSet<WmsInventoryCheck> WmsInventoryCheck { get; set; }
public DbSet<WmsInventoryCheckDetail> WmsInventoryCheckDetail { get; set; }
public DbSet<MesBaseMaterialInfo> MesBaseMaterialInfo { get; set; }
public DbSet<WmsRawReturn> WmsRawReturn { get; set; }
public DbSet<WcsTaskManual> WcsTaskManual { get; set; }

@ -58,7 +58,7 @@ namespace Khd.Core.Wcs
plc = new Plc.S7.Plc(plcConfig.CpuType, plcConfig.IP, plcConfig.Port, plcConfig.Rack, plcConfig.Slot);
try
{
plc.Open();
//plc.Open();
Console.WriteLine(DateTime.Now + ":连接到PLC" + plcConfig.IP);
}
catch
@ -70,9 +70,9 @@ namespace Khd.Core.Wcs
}
//SystemTimer systemTimer = new SystemTimer(_host);
//systemTimer.Start();
////创建任务
//CreateTaskByRecord createTaskByRecord = new(_host);
//createTaskByRecord.StartPoint();
//创建任务
CreateTaskByRecord createTaskByRecord = new(_host);
createTaskByRecord.StartPoint();
////一楼提升机以及接驳位
//FirstFloor firstFloor = new(_host, StaticData.PlcDic[0]);
@ -100,7 +100,7 @@ namespace Khd.Core.Wcs
////三层AGV
//var ThirdFloorAgvEquip = StaticData.BaseEquip.Where(t => t.floorNo == 3 && t.equipType == 4).First();
//ThirdFloorAGV thirdFloorAGV = new(_host, StaticData.PlcDic[0], ThirdFloorAgvEquip.floorNo.Value);
//ThirdFloorAGV thirdFloorAGV = new(_host, StaticData.PlcDic[2], ThirdFloorAgvEquip.floorNo.Value);
//thirdFloorAGV.StartPoint();
////五层接驳位
@ -115,9 +115,10 @@ namespace Khd.Core.Wcs
////五层AGV
//var FifthFloorAgvEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 5).First();
//FiveFloorAGV fifthFloorAGV = new(_host, StaticData.PlcDic[2], FifthFloorAgvEquip.floorNo.Value);
//FiveFloorAGV fifthFloorAGV = new(_host, StaticData.PlcDic[0], FifthFloorAgvEquip.floorNo.Value);
//fifthFloorAGV.StartPoint();
////背负式Agv
//var FifthFloorBearAgvEquip = StaticData.BaseEquip.Where(t => t.objid == 28).First();
//FiveFloorBearAgv fiveFloorBearAgv = new(_host, StaticData.PlcDic[1], FifthFloorBearAgvEquip.floorNo.Value);
//fiveFloorBearAgv.StartPoint();

File diff suppressed because it is too large Load Diff

@ -499,9 +499,28 @@ namespace Khd.Core.Wcs.Wcs
WcsCmd? wcsCmd = dbContext.WcsCmd.FirstOrDefault(t => t.taskId == item.objid);
if (wcsCmd != null)
{
if (wcsCmd.cmdStatus == 3)
{
if (item.currPointId == 5)
{
var lineSignalValue = this._plc.Read(LineSignal.plcpointAddress);
if (lineSignalValue == null || Convert.ToInt32(lineSignalValue) == 0)
{
Console.WriteLine(DateTime.Now + ":五楼Agv接驳位为空无法取货");
LogManager.Info("五楼Agv接驳位为空无法取货");
continue;
}
}
else if (item.endPointId == 5)
{
var lineSignalValue = this._plc.Read(LineSignal.plcpointAddress);
if (lineSignalValue == null || Convert.ToInt32(lineSignalValue) == 1)
{
Console.WriteLine(DateTime.Now + ":五楼Agv接驳位有货无法送货");
LogManager.Info("五楼Agv接驳位有货无法送货");
continue;
}
}
var agvTask = new RequestAGVTaskDto
{
reqCode = StaticData.SnowId.NextId().ToString(),
@ -526,7 +545,7 @@ namespace Khd.Core.Wcs.Wcs
LogManager.Info("五楼叉车线程完成任务" + wcsCmd.objid);
Console.WriteLine(DateTime.Now + ":五楼背负式AGV线程完成任务" + wcsCmd.currPointNo + "," + wcsCmd.nextPointNo);
LogManager.Info("五楼Agv完成任务成功" + wcsCmd.ToJsonString());
if (item.taskType == 66)
if (item.taskType == 66)//移库
{
WmsBaseLocation fromBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
WmsBaseLocation toBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
@ -608,19 +627,31 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == 33)//原材料到背板安装
{
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.outstockFlag = "0";
wmsBaseLocation.containerCode = "";
wmsBaseLocation.updateTime = DateTime.Now;
wmsBaseLocation.updateBy = "WCS";
dbContext.Update(wmsBaseLocation);
dbContext.WmsRawStock.Where(t => t.locationCode == wmsBaseLocation.locationCode).Delete();
dbContext.WcsCmd.Remove(wcsCmd);
dbContext.WcsTask.Remove(item);
dbContext.SaveChanges();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog { cmdStatus = 6 });
WmsRawOutstock? wmsRawOutstock = dbContext.WmsRawOutstock.Where(t => t.rawOutstockId == item.orderId).FirstOrDefault();
if (wmsRawOutstock != null)
{
WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.Where(t => t.rawOutstockId == wmsRawOutstock.rawOutstockId && t.executeStatus == "1").FirstOrDefault();
if (wmsRawOutstockDetail != null)
{
wmsRawOutstockDetail.executeStatus = "2";
wmsRawOutstock.executeStatus = "2";
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.outstockFlag = "0";
wmsBaseLocation.containerCode = "";
wmsBaseLocation.updateTime = DateTime.Now;
wmsBaseLocation.updateBy = "WCS";
dbContext.Update(wmsRawOutstock);
dbContext.Update(wmsRawOutstockDetail);
dbContext.Update(wmsBaseLocation);
dbContext.WmsRawStock.Where(t => t.locationCode == wmsBaseLocation.locationCode).Delete();
dbContext.WcsCmd.Remove(wcsCmd);
dbContext.WcsTask.Remove(item);
dbContext.SaveChanges();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog { cmdStatus = 6 });
}
}
}
else if (item.taskType == 34)//半成品入库
{
@ -640,6 +671,8 @@ namespace Khd.Core.Wcs.Wcs
WmsProductInstockDetail? wmsProductInstockDetail = dbContext.WmsProductInstockDetail.Where(t => t.productInstockId == wmsProductInstock.productInstockId).FirstOrDefault();
if (wmsProductInstockDetail != null)
{
wmsProductInstock.executeStatus = "2";
dbContext.Update(wmsProductInstock);
WmsProductStock wmsProductStock = new WmsProductStock()
{
productId = wmsProductInstock.productId,
@ -683,64 +716,74 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == 46)//该任务结束后立刻生成一个新的返库任务但是是否使用标志未0等待mes通知
{
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
wmsBaseLocation.outstockFlag = "0";
wmsBaseLocation.instockFlag = "1";
wmsBaseLocation.locationStatus = "2";
wmsBaseLocation.containerCode = null;
wmsBaseLocation.updateTime = DateTime.Now;
wmsBaseLocation.updateBy = "WCS";
WmsRawStock? wmsRawStock = dbContext.WmsRawStock.Where(t => t.locationCode == wmsBaseLocation.locationCode).FirstOrDefault();
if (wmsRawStock != null)
var wmsRawOutStock = dbContext.WmsRawOutstock.Where(t => t.rawOutstockId == item.orderId).FirstOrDefault();
WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.Where(t => t.rawOutstockId == item.orderId).FirstOrDefault();
if (wmsRawOutStock != null && wmsRawOutstockDetail != null)
{
wmsRawStock.completeFlag = "0";
wmsRawStock.updateDate = DateTime.Now;
wmsRawStock.updateBy = "WCS";
dbContext.Update(wmsRawStock);
dbContext.Update(wmsBaseLocation);
if (wmsBaseLocation.locDeep == 1)
wmsRawOutstockDetail.executeStatus = "2";
wmsRawOutStock.executeStatus = "2";
dbContext.Update(wmsRawOutStock);
dbContext.Update(wmsRawOutstockDetail);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
wmsBaseLocation.outstockFlag = "0";
wmsBaseLocation.instockFlag = "1";
wmsBaseLocation.locationStatus = "2";
wmsBaseLocation.containerCode = null;
wmsBaseLocation.updateTime = DateTime.Now;
wmsBaseLocation.updateBy = "WCS";
WmsRawStock? wmsRawStock = dbContext.WmsRawStock.Where(t => t.locationCode == wmsBaseLocation.locationCode).FirstOrDefault();
if (wmsRawStock != null)
{
int? locRow = 0;
if (wmsBaseLocation.locRow % 2 == 1)
wmsRawStock.completeFlag = "0";
wmsRawStock.updateDate = DateTime.Now;
wmsRawStock.updateBy = "WCS";
dbContext.Update(wmsRawStock);
dbContext.Update(wmsBaseLocation);
if (wmsBaseLocation.locDeep == 1)
{
locRow = wmsBaseLocation.locRow + 1;
}
else
{
locRow = wmsBaseLocation.locRow - 1;
}
WmsBaseLocation? deepWmsLocation = dbContext.WmsBaseLocation.Where(t => t.locRow == locRow)
.Where(t => t.locColumn == wmsBaseLocation.locColumn)
.Where(t => t.warehouseId == wmsBaseLocation.warehouseId)
.FirstOrDefault();
if (deepWmsLocation != null)
{
deepWmsLocation.instockFlag = "1";
deepWmsLocation.locationStatus = "2";
dbContext.Update(deepWmsLocation);
int? locRow = 0;
if (wmsBaseLocation.locRow % 2 == 1)
{
locRow = wmsBaseLocation.locRow + 1;
}
else
{
locRow = wmsBaseLocation.locRow - 1;
}
WmsBaseLocation? deepWmsLocation = dbContext.WmsBaseLocation.Where(t => t.locRow == locRow)
.Where(t => t.locColumn == wmsBaseLocation.locColumn)
.Where(t => t.warehouseId == wmsBaseLocation.warehouseId)
.FirstOrDefault();
if (deepWmsLocation != null)
{
deepWmsLocation.instockFlag = "1";
deepWmsLocation.locationStatus = "2";
dbContext.Update(deepWmsLocation);
}
}
WcsTask newTask = CoreMapper.Map<WcsTask>(item);
newTask.objid = StaticData.SnowId.NextId();
var currPointId = item.currPointId;
var currPointNo = item.currPointNo;
newTask.currPointId = item.endPointId;
newTask.currPointNo = item.endPointNo;
newTask.endPointId = item.currPointId;
newTask.endPointNo = item.currPointNo;
newTask.createTime = DateTime.Now;
newTask.taskType = 28;
newTask.taskStatus = 0;
newTask.useFlag = 0;
dbContext.Remove(item);
dbContext.Remove(wcsCmd);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(newTask);
dbContext.Add(newTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog { cmdStatus = 6 });
}
WcsTask newTask = CoreMapper.Map<WcsTask>(item);
newTask.objid = StaticData.SnowId.NextId();
var currPointId = item.currPointId;
var currPointNo = item.currPointNo;
newTask.currPointId = item.endPointId;
newTask.currPointNo = item.endPointNo;
newTask.endPointId = item.currPointId;
newTask.endPointNo = item.currPointNo;
newTask.createTime = DateTime.Now;
newTask.taskType = 28;
newTask.taskStatus = 0;
newTask.useFlag = 0;
dbContext.Remove(item);
dbContext.Remove(wcsCmd);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(newTask);
dbContext.Add(newTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog { cmdStatus = 6 });
}
}
else if (item.taskType == 28)//柜体拆分到原材料

@ -39,7 +39,7 @@ namespace Khd.Core.Wcs.Wcs
this.isput = StaticData.BasePlcpointList.First(t => t.plcpointNo == "isput");
this.canReceive = StaticData.BasePlcpointList.First(t => t.plcpointNo == "canReceive");
this.ReceiveMaterial = StaticData.BasePlcpointList.First(t => t.plcpointNo == "ReceiveMaterial");
this.CtuLineWaring = StaticData.BasePlcpointList.First(t => t.plcpointNo == "CtuLineWaring");
this.CtuLineWaring = StaticData.BasePlcpointList.First(t => t.plcpointNo == "CTULineWaring");
}
/// <summary>
@ -153,6 +153,45 @@ namespace Khd.Core.Wcs.Wcs
else
{
if (task.taskType == 30)
{
dbContext.WcsTask.Where(t => t.objid == task.objid).Delete();
//根据rfid找到库位
//生成入库任务
var wmsBaseLocation = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == rfid);
if (wmsBaseLocation != null)
{
BaseEquip baseEquip = StaticData.BaseEquip.First(t => t.equipNo == "FL051");
BaseEquip ctuEquip = StaticData.BaseEquip.First(t => t.objid == 11);
if (wmsBaseLocation != null)
{
var wcsTask = new WcsTask()
{
objid = StaticData.SnowId.NextId(),
currPointId = baseEquip.objid,
currPointNo = baseEquip.agvPositionCode,
nextPointId = ctuEquip.objid,
useFlag = 1,
endPointId = wmsBaseLocation.locationId,
endPointNo = wmsBaseLocation.agvPositionCode,
taskType = 29,
taskStatus = 0,
floorNo = 5,
containerNo = rfid.ToString(),
equipmentNo = baseEquip.equipNo,
createBy = FloorNo + "楼CTU",
createTime = DateTime.Now,
};
wmsBaseLocation.instockFlag = "1";
wmsBaseLocation.locationStatus = "2";
wmsBaseLocation.updateTime = DateTime.Now;
dbContext.Update(wmsBaseLocation);
dbContext.Add(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
}
}
}else if (task.taskType == 100)
{
dbContext.WcsTask.Where(t => t.objid == task.objid).Delete();
//根据rfid找到库位
@ -203,28 +242,27 @@ namespace Khd.Core.Wcs.Wcs
}
else if (receiveMaterial != null && Convert.ToInt32(receiveMaterial) == 1)
{
Task.Run(() =>
{
var receiveMaterial2 = this._plc.Read(ReceiveMaterial.plcpointAddress);
while (receiveMaterial2 != null && Convert.ToInt32(receiveMaterial2) == 1)
{
receiveMaterial2 = this._plc.Read(ReceiveMaterial.plcpointAddress);
lock (SystemData.outStockLock)
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
bool haveTask = dbContext.WcsTask.Where(t => t.nextPointId == 11).Any();
if (!haveTask && wcsOutstockLock.boxStatus == 1)
{
wcsOutstockLock.boxStatus = 0;
wcsOutstockLock.qty = 0;
dbContext.Update(wcsOutstockLock);
dbContext.SaveChanges();
}
}
Thread.Sleep(3000);
}
});
//Task.Run(() =>
//{
// var receiveMaterial2 = this._plc.Read(ReceiveMaterial.plcpointAddress);
// while (receiveMaterial2 != null && Convert.ToInt32(receiveMaterial2) == 1)
// {
// receiveMaterial2 = this._plc.Read(ReceiveMaterial.plcpointAddress);
// lock (SystemData.outStockLock)
// {
// WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
// bool haveTask = dbContext.WcsTask.Where(t => t.nextPointId == 11).Any();
// if (!haveTask && wcsOutstockLock.boxStatus == 1)
// {
// wcsOutstockLock.boxStatus = 0;
// wcsOutstockLock.qty = 0;
// dbContext.Update(wcsOutstockLock);
// dbContext.SaveChanges();
// }
// }
// Thread.Sleep(3000);
// }
//});
}
}
catch (Exception ex)
@ -480,6 +518,65 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
else if (item.taskType == 100)//盘库
{
BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == item.endPointId);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
var wcsCmd = new WcsCmd()
{
objid = StaticData.SnowId.NextId(),
cmdStatus = 0,
taskId = item.objid,
useFlag = 1,
cmdType = item.taskType,
containerNo = item.containerNo,
createTime = DateTime.Now,
createBy = FloorNo + "楼CTU",
currPointId = wmsBaseLocation.locationId,
currPointNo = wmsBaseLocation.agvPositionCode,
nextPointId = endEquip.objid,
nextPointNo = endEquip.agvPositionCode,
taskCode = null
};
var agvTask = new RequestAGVTaskDto
{
reqCode = StaticData.SnowId.NextId().ToString(),
positionCodePath = new List<Position>
{
new()
{
positionCode = wcsCmd.currPointNo,
type = "05"
},
new()
{
positionCode = wcsCmd.nextPointNo,
type = "00"
},
},
ctnrTyp = "1",
taskTyp = "F504"
};
string message = JsonConvert.SerializeObject(agvTask);
string result = HttpHelper.SendPostMessage(baseEquip.serverIp, baseEquip.serverPort.Value, "rcms/services/rest/hikRpcService/genAgvSchedulingTask", message);
var reponseMessage = JsonConvert.DeserializeObject<ReponseMessage>(result);
if (reponseMessage != null && reponseMessage.code == "0")
{
wcsCmd.taskCode = reponseMessage.data;
wcsCmd.cmdStatus = 1;
item.taskStatus = 1;
dbContext.Update(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 1 });
WcsCmdLog wcsCmdLog = CoreMapper.Map<WcsCmdLog>(wcsCmd);
dbContext.Add(wcsCmdLog);
dbContext.WcsCmd.Add(wcsCmd);
dbContext.SaveChanges();
}
else
{
LogManager.Info("CTU下发出库任务失败" + reponseMessage?.message);
}
}
}
else
{
@ -488,7 +585,7 @@ namespace Khd.Core.Wcs.Wcs
{
if (wcsCmd.cmdStatus == 3)
{
if (item.taskType == 30)
if (item.taskType == 30 || item.taskType == 100)
{
var canOut = this._plc.Read(isput.plcpointAddress);
if (canOut != null && Convert.ToInt64(canOut) == 0)
@ -604,6 +701,25 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
else if (item.taskType == 100)//出库任务
{
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation
.First(t => t.locationId == item.currPointId && t.warehouseFloor == 5);
wmsBaseLocation.outstockFlag = "0";
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.locationStatus = "2";
dbContext.Update(wmsBaseLocation);
dbContext.Remove(wcsCmd);
dbContext.WcsTask.Where(t => t.objid == item.objid).Update(t => new WcsTask() { taskStatus = 6 });
dbContext.SaveChanges();
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog() { cmdStatus = 6 });
dbContext.WcsTaskLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsTaskLog() { taskStatus = 6 });
int wcsTaskCount = dbContext.WcsTask.Where(t => (t.taskType == 30 || t.taskType == 100) && t.taskStatus != 6).Count();
if (wcsTaskCount == 0)
{
this._plc.WriteToPoint(this.canReceive.plcpointAddress, "1", this.canReceive.plcpointLength?.ToString());
}
}
}
}
}

@ -45,6 +45,7 @@ namespace Khd.Core.Wcs.Wcs
public void MonitorInLocatorPoint()
{
List<string> BigContainerCodes = new() { "JYHB01020001", "JYHB01020002", "JYHB01020003", "JYHB01020004" };
List<int?> ITypes = new() { 1, 3, 5, 7 };
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
@ -58,6 +59,11 @@ namespace Khd.Core.Wcs.Wcs
var isSignal = this._plc.Read(LineSignal.plcpointAddress);
if (rfid != null && isSignal != null)
{
if (BigContainerCodes.Contains(rfid))
{
Thread.Sleep(1000);
continue;
}
//正常读到输送线信息 有到位信号,并且有托盘,获取条码信息
if (Convert.ToInt32(isSignal) == 1)
{

@ -193,22 +193,21 @@ namespace Khd.Core.Wcs.Wcs
/// <param name="obj"></param>
private void MessageSynchronousLogic(object? obj)
{
while (true)
{
try
{
using var scope = host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
HositerLogic();
//CtuLineLogic();
ThirdAgvLogic(dbContext);
FiveAgvLogic(dbContext);
FiveBearAgvLogic(dbContext);
CtuCmdLogic(dbContext);
SecondAgvLogic(dbContext);
SendTrayMessage(dbContext);
UpdatePlcPointValue(dbContext);
ThirdAgvLogic();
FiveAgvLogic();
FiveBearAgvLogic();
CtuCmdLogic();
SecondAgvLogic();
//SendTrayMessage();
UpdatePlcPointValue();
}
catch (Exception ex)
{
@ -235,8 +234,10 @@ namespace Khd.Core.Wcs.Wcs
}
}
private void SendTrayMessage(DefaultDbContext dbContext)
private void SendTrayMessage()
{
using var scope = host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 40);
BasePlcpoint oneInPoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "oneIn");
BasePlcpoint oneOutPoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "oneOut");
@ -265,10 +266,12 @@ namespace Khd.Core.Wcs.Wcs
StaticData.PlcDic[2].WriteToPoint(basePlc2.Address, baseEquip.emptyCount.ToString(), basePlc2.type);
}
private void UpdatePlcPointValue(DefaultDbContext dbContext)
private void UpdatePlcPointValue()
{
try
{
using var scope = host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
foreach (var item in StaticData.basePlcs)
{
item.Value = StaticData.PlcDic[2].Read(item.Address)?.ToString();
@ -286,8 +289,10 @@ namespace Khd.Core.Wcs.Wcs
/// 定时更新三楼AGV信息
/// </summary>
/// <param name="dbContext"></param>
private void ThirdAgvLogic(DefaultDbContext dbContext)
private void ThirdAgvLogic()
{
using var scope = host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 9);
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var basePlcs = StaticData.basePlcs.Where(t => t.Station == "3楼AGV").ToList();
@ -317,8 +322,10 @@ namespace Khd.Core.Wcs.Wcs
/// 定时更新二楼AGV信息
/// </summary>
/// <param name="dbContext"></param>
private void SecondAgvLogic(DefaultDbContext dbContext)
private void SecondAgvLogic()
{
using var scope = host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 8);
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var basePlcs = StaticData.basePlcs.Where(t => t.Station == "2楼AGV").ToList();
@ -348,8 +355,10 @@ namespace Khd.Core.Wcs.Wcs
/// 定时更新五楼AGV信息
/// </summary>
/// <param name="dbContext"></param>
private void FiveAgvLogic(DefaultDbContext dbContext)
private void FiveAgvLogic()
{
using var scope = host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 10);
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var basePlcs = StaticData.basePlcs.Where(t => t.Station == "5楼AGV").ToList();
@ -425,8 +434,10 @@ namespace Khd.Core.Wcs.Wcs
/// 定时更新五楼背负式AGV信息
/// </summary>
/// <param name="dbContext"></param>
private void FiveBearAgvLogic(DefaultDbContext dbContext)
private void FiveBearAgvLogic()
{
using var scope = host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 10);
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var basePlcs = StaticData.basePlcs.Where(t => t.Station == "5楼背负式").ToList();
@ -457,8 +468,10 @@ namespace Khd.Core.Wcs.Wcs
/// 定时更新五楼CTU信息
/// </summary>
/// <param name="dbContext"></param>
private void CtuCmdLogic(DefaultDbContext dbContext)
private void CtuCmdLogic()
{
using var scope = host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 11);
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var basePlcs = StaticData.basePlcs.Where(t => t.Station == "5楼CTU").ToList();

@ -19,13 +19,16 @@ namespace Khd.Core.Wcs.Wcs
private readonly IHost _host;
private readonly Plc.S7.Plc _plc;
int FloorNo { get; set; }
private readonly BasePlcpoint putTrayPoint;
private readonly BasePlcpoint getTrayPoint;
public ThirdFloorAGV(IHost host, Plc.S7.Plc plc, int floor)
{
this._host = host;
this._plc = plc;
FloorNo = floor;
//var IsPallet = this._plc.Read(LineIsPallet.plcpointAddress);
this.putTrayPoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "putTray");
this.getTrayPoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "getTray");
}
/// <summary>
/// 启动上件扫描监听
@ -35,10 +38,66 @@ namespace Khd.Core.Wcs.Wcs
Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
FlowPointThread.Start();
Thread FZJThread = new Thread(MonitorInFZJPoint);
FZJThread.Start();
Console.WriteLine(DateTime.Now + ":三楼AGV 启动上件扫描监听");
LogManager.Info("三楼AGV 启动上件扫描监听");
}
private void MonitorInFZJPoint(object? obj)
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
while (true)
{
try
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var getTrayValue = this._plc.Read(getTrayPoint.plcpointAddress);
if (getTrayValue != null && Convert.ToInt32(getTrayValue) == 1)
{
bool hasTask = dbContext.WcsTask.Where(t => t.taskType == 41 || t.taskType == 42).Any();
if (!hasTask)
{
BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == 35);
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == 31);
BaseEquip agvEquip = StaticData.BaseEquip.First(t => t.objid == 9);
WcsTask wcsTask = new()
{
objid = StaticData.SnowId.NextId(),
taskType = 42,
taskStatus = 0,
useFlag = 1,
createBy = FloorNo + "楼AGV",
nextPointId=agvEquip.objid,
nextPointNo=agvEquip.agvPositionCode,
currPointId = startEquip.objid,
currPointNo = startEquip.agvPositionCode,
endPointId = endEquip.objid,
endPointNo = endEquip.agvPositionCode,
containerNo="",
createTime = DateTime.Now,
isEmpty="1",
qty=1,
};
dbContext.Add(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
LogManager.Info("三楼AGV 生成空托盘入收集架任务:" + wcsTask.objid);
}
}
}
catch (Exception ex)
{
LogManager.Error(ex);
}
Thread.Sleep(5000);
}
}
public void MonitorInLocatorPoint()
{
using var scope = _host.Services.CreateScope();

@ -1,8 +1,8 @@
{
"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=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=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=175.27.215.92;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khd2024;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
},
"PlcConfigs": [
@ -14,14 +14,14 @@
"Slot": 1,
"Code": 0
},
//{
// "IP": "192.168.2.31",
// "Port": 102, //102
// "CpuType": 40,
// "Rack": 0,
// "Slot": 1,
// "Code": 1
//},
{
"IP": "192.168.2.31",
"Port": 102, //102
"CpuType": 40,
"Rack": 0,
"Slot": 1,
"Code": 1
},
{
"IP": "192.168.2.220",
"Port": 102, //102

@ -1744,38 +1744,167 @@
<hc:Pagination x:Name="Pagination2" Grid.Row="2" MaxWidth="1500" MaxPageCount="1" Margin="0,0,0,15" PageUpdated="Pagination2_PageUpdated" IsJumpEnabled="True" HorizontalAlignment="Center" Width="339" />
</Grid>
</TabItem>
<TabItem x:Name="InventoryManager" Header="盘库任务" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">
<Grid Height="1100" Width="1700">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Content="搜索" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="100" Margin="20,0,0,0" Click="SelectInventoryButton_Click"/>
<Button Content="库存盘点" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="150" Margin="20,0,0,0" Click="InventoryTaskButton_Click"/>
</StackPanel>
<DataGrid
Style="{StaticResource DataGridStyle}"
Grid.Row="1" AlternationCount="2"
AutoGenerateColumns="False"
MinRowHeight="50"
Background="#172557"
CanUserAddRows="False"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
GridLinesVisibility="None"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
Focusable="False"
Height="auto"
HeadersVisibility="Column"
IsReadOnly="True"
LoadingRow="dgData_LoadingRow"
RowHeaderWidth="0"
SelectionMode="Single" FontSize="16"
Visibility="Visible"
x:Name="InventoryMaterial">
<DataGrid.Columns>
<DataGridTemplateColumn
Width="100"
MinWidth="10"
Header=" 序号"
IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Focusable="False"
FontSize="20"
Text="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}, Mode=FindAncestor}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Width="180*"
Binding="{Binding LocationAmount}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="库位数"
IsReadOnly="True" />
<DataGridTextColumn
Width="180*"
Binding="{Binding InventoryingAmount}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="正在盘库数量"
IsReadOnly="True" />
<DataGridTextColumn
Width="180*"
Binding="{Binding InventoriedAmount}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="已盘库数量"
IsReadOnly="True" />
<DataGridTextColumn
Width="180*"
Binding="{Binding CheckStatus}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="盘点状态"
IsReadOnly="True" />
<DataGridTextColumn
Width="220*"
Binding="{Binding CreateTime,StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="创建时间"
IsReadOnly="True" />
<DataGridTextColumn
Width="220*"
Binding="{Binding BeginTime,StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="开始时间"
IsReadOnly="True" />
<DataGridTextColumn
Width="220*"
Binding="{Binding EndTime,StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="结束时间"
IsReadOnly="True" />
<DataGridTemplateColumn
Width="300"
MinWidth="10"
Header=" 操作"
IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Content="开始盘点" Style="{StaticResource ButtonPrimary}" FontSize="25" Width="125" Height="75" Click="StartInventory"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="#213269" />
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="#213269" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="60"/>
</Style>
</DataGrid.RowStyle>
<DataGrid.RowHeaderStyle>
<Style TargetType="{x:Type DataGridRowHeader}">
<Setter Property="Background" Value="#213269" />
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
</DataGrid.RowHeaderStyle>
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="#172560" />
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="BorderThickness" Value="5" />
<Setter Property="BorderBrush" Value="#172540" />
<Setter Property="FontSize" Value="30" />
</Style>
</DataGrid.ColumnHeaderStyle>
</DataGrid>
<hc:Pagination x:Name="Pagination3" Grid.Row="2" MaxWidth="1500" MaxPageCount="1" Margin="0,0,0,15" PageUpdated="Pagination3_PageUpdated" IsJumpEnabled="True" HorizontalAlignment="Center" Width="339" />
</Grid>
</TabItem>
<TabItem x:Name="ScanInManager" Header="扫描入库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">
<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="Vertical" Margin="20,5,0,0">
<!--<StackPanel Orientation="Horizontal" Margin="0" HorizontalAlignment="Left">
<Image
x:Name="img_plcmesssage1"
Width="40"
Height="35"
Margin="60,0,0,0"
Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/>
<TextBlock Text="人工叫料" Foreground="White" FontSize="20" Width="150" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Margin="0,5,0,0">
<Grid Height="300">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<TextBlock Text="请选择物料名称:" Grid.Row="0" Grid.Column="0"/>
<TextBlock Text="物料规格:" Grid.Row="1" Grid.Column="0"/>
<ComboBox x:Name="MaterialName" DisplayMemberPath="MaterialName" SelectionChanged="MaterialName_SelectionChanged" Grid.Column="1" IsEditable="True" Grid.Row="0" Width="170" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<ComboBox x:Name="MaterialSpec" DisplayMemberPath="MaterialSpec" Grid.Column="1" Grid.Row="1" Width="170" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</Grid>
</Border>-->
<Grid Width="1650" Height="1000">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>

@ -364,7 +364,7 @@ namespace Khd.Core.Wpf.Form
ud3 = t.ud3 == "0" ? "空" : t.ud3 == "1" ? "托盘" : t.ud3 == "2" ? "废料" : "未知",
equipNo = t.equipNo,
floorNo = t.floorNo,
containerNo=t.containerNo
containerNo = t.containerNo
}
).OrderBy(t => t.equipNo);
this.EmptyEquip.Items.Refresh();
@ -1415,7 +1415,7 @@ namespace Khd.Core.Wpf.Form
frozenAmount = 0,
instockDate = System.DateTime.Now,
rawStockId = Global.SnowId.NextId(),
saleOrderId = material.saleOrderId,
saleOrderId = material.saleOrderId == null ? 0 : material.saleOrderId,
warehouseFloor = 5,
warehouseId = 512,
createBy = "扫描入库",
@ -1439,6 +1439,7 @@ namespace Khd.Core.Wpf.Form
LogManager.Error(ex);
MessageBox.Show("入库失败");
}
//20240717102819RB045
}
/// <summary>
/// 入库容器改变
@ -1507,7 +1508,7 @@ namespace Khd.Core.Wpf.Form
else
{
txtInScan.Text = (material.batchFlag == "1" ? material.amount : 1).ToString();
if (mesBaseMaterialInfo.BatchFlag == 0)
if (mesBaseMaterialInfo.BatchFlag == "0")
{
txtInScan.IsReadOnly = true;
}
@ -1653,7 +1654,7 @@ namespace Khd.Core.Wpf.Form
}
else
{
WmsRawOutstock? wmsRawOutstock = dbContext.WmsRawOutstock.FirstOrDefault(t => t.rawOutstockId == wcsTask.orderId);
WmsRawOutstock? wmsRawOutstock = dbContext.WmsRawOutstock.FirstOrDefault(t => t.materialId == wcsTask.materialId && t.realOutstockAmount < t.outstockAmount);
if (wmsRawOutstock != null)
{
wmsRawOutstock.realOutstockAmount += outScan;
@ -1661,27 +1662,57 @@ namespace Khd.Core.Wpf.Form
{
wmsRawOutstock.executeStatus = "2";
}
wmsRawStock.totalAmount -= outScan;
if (wmsRawStock.totalAmount == 0)
else if (wmsRawOutstock.realOutstockAmount > wmsRawOutstock.outstockAmount)
{
dbContext.WmsRawStock.Where(t => t.rawStockId == wmsRawStock.rawStockId).Delete();
MessageBox.Show("出库数量不能大于申请单数量,当前出库数量为:" + (wmsRawOutstock.realOutstockAmount - outScan) + ",申请单数量为:" + wmsRawOutstock.outstockAmount + "!");
return;
}
wmsRawStock.totalAmount -= outScan;
if (wmsRawStock.totalAmount <= 0)
{
dbContext.Remove(wmsRawStock);
dbContext.Update(wmsRawOutstock);
dbContext.SaveChanges();
}
else
{
dbContext.WmsRawStock.Update(wmsRawStock);
dbContext.Update(wmsRawStock);
dbContext.Update(wmsRawOutstock);
dbContext.SaveChanges();
}
var mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == txtOutBarCode.Text);
if (mesBaseBarcodeInfo != null)
{
WmsRawOutstockDetail wmsProductOutstockDetail = new WmsRawOutstockDetail()
{
rawOutstockDetailId = Global.SnowId.NextId(),
rawOutstockId = wmsRawOutstock.rawOutstockId,
materialId = mesBaseBarcodeInfo.materialId,
createDate = DateTime.Now,
createBy = "WCS",
taskCode = wcsTask.objid.ToString(),
executeStatus = "2",
locationCode = wcsTask.currPointNo,
outstockAmount = outScan,
planAmount = outScan,
warehouseId = 512,
materialBarcode = mesBaseBarcodeInfo.barcodeInfo,
instockBatch = mesBaseBarcodeInfo.batchCode,
stackAmount = outScan,
outstockPerson = "WCS",
outstockTime = DateTime.Now,
outstockWay = "2",
materialProductionDate = mesBaseBarcodeInfo.productionDate
};
dbContext.WmsRawOutstockDetail.Add(wmsProductOutstockDetail);
}
dbContext.SaveChanges();
}
else
{
wmsRawStock.totalAmount -= outScan;
if (wmsRawStock.totalAmount == 0)
{
dbContext.WmsRawStock.Where(t => t.rawStockId == wmsRawStock.rawStockId).Delete();
dbContext.WmsRawStock.Remove(wmsRawStock);
dbContext.SaveChanges();
}
else
{
@ -1813,6 +1844,174 @@ namespace Khd.Core.Wpf.Form
{
GetPersonCallMaterialData();
}
/// <summary>
/// 页码改变时
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Pagination3_PageUpdated(object sender, HandyControl.Data.FunctionEventArgs<int> e)
{
GetInvertoryData();
}
private void StartInventory(object sender, RoutedEventArgs e)
{
dynamic wmsInventoryCheck = this.InventoryMaterial.SelectedItem;
long inventoryCheckId = wmsInventoryCheck.InventoryCheckId;
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var InventoryCheck = dbContext.WmsInventoryCheck.Where(t => t.InventoryCheckId == inventoryCheckId).FirstOrDefault();
BaseEquip agvEquip = SystemData.BaseEquip.First(t => t.objid == 11);
BaseEquip lineEquip = SystemData.BaseEquip.First(t => t.objid == 20);
if (InventoryCheck != null)
{
if (InventoryCheck.InventoryingAmount == 0)
{
bool hasTask = dbContext.WcsTask.Where(t => t.taskType == 100).Any();
if (!hasTask)
{
hasTask = dbContext.WcsTaskManual.Where(t => t.taskType == 100).Any();
if (!hasTask)
{
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.ContainerStatus == "1")
.Where(t => t.locationStatus == "1")
.Where(t => t.instockFlag == "0")
.Where(t => t.outstockFlag == "0")
.Where(t => t.activeFlag == "1")
.OrderBy(t => t.locRow)
.ThenBy(t => t.locColumn)
.ToList();
var wmsInventoryCheckDetails = dbContext.WmsInventoryCheckDetail
.Where(t => t.InventoryCheckId == InventoryCheck.InventoryCheckId).ToList();
List<string> locationCodes = wmsInventoryCheckDetails.Select(t => t.LocationCode).Distinct().ToList();
wmsBaseLocations.RemoveAll(t => locationCodes.Contains(t.locationCode));
if (wmsBaseLocations.Count > 0)
{
List<string> locations = wmsBaseLocations.Select(t => t.locationCode).ToList();
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => t.warehouseId == 512).ToList();
var wmsRawStock = wmsRawStocks
.Where(t => locations.Contains(t.locationCode)).ToList();
List<string> codes = wmsRawStock.Select(t => t.locationCode).Distinct().ToList();
var bill = from a in wmsBaseLocations
from b in codes
where a.locationCode == b
select new { a };
var outLocation = bill.OrderBy(t => t.a.locRow).ThenBy(t => t.a.locColumn).Take(6);
List<WcsTaskManual> addList = new List<WcsTaskManual>();
foreach (var item in outLocation)
{
WmsBaseLocation startBaseLocation = item.a;
startBaseLocation.outstockFlag = "1";
startBaseLocation.locationStatus = "6";
startBaseLocation.ContainerStatus = "2";
addList.Add(new WcsTaskManual()
{
objid = Global.SnowId.NextId(),
taskType = 100,
containerNo = startBaseLocation.containerCode,
currPointId = startBaseLocation.locationId,
currPointNo = startBaseLocation.locationCode,
nextPointId = agvEquip.objid,
nextPointNo = agvEquip.equipNo,
endPointId = lineEquip.objid,
endPointNo = lineEquip.equipNo,
createTime = DateTime.Now,
ud1 = startBaseLocation.locColumn,
taskStatus = 0,
remark = "CTU盘点任务",
floorNo = 5,
fromFloorNo = 5,
useFlag = 1
});
dbContext.Update(startBaseLocation);
}
for (int i = addList.Count + 1; i <= 6; i++)
{
List<long?> list = addList.Select(t => t.currPointId).ToList();
WmsBaseLocation? startBaseLocation = wmsBaseLocations.Where(t => !list.Contains(t.locationId)).FirstOrDefault();
if (startBaseLocation != null)
{
startBaseLocation.outstockFlag = "1";
startBaseLocation.locationStatus = "6";
startBaseLocation.ContainerStatus = "2";
addList.Add(new WcsTaskManual()
{
objid = Global.SnowId.NextId(),
taskType = 100,
orderId = InventoryCheck.InventoryCheckId,
containerNo = startBaseLocation.containerCode,
currPointId = startBaseLocation.locationId,
currPointNo = startBaseLocation.locationCode,
nextPointId = agvEquip.objid,
nextPointNo = agvEquip.equipNo,
endPointId = lineEquip.objid,
endPointNo = lineEquip.equipNo,
createTime = DateTime.Now,
ud1 = startBaseLocation.locColumn,
taskStatus = 0,
remark = "CTU盘点任务",
floorNo = 5,
fromFloorNo = 5,
useFlag = 1,
});
dbContext.Update(startBaseLocation);
}
}
List<WmsInventoryCheckDetail> addCheckDetail = new List<WmsInventoryCheckDetail>();
foreach (var item in addList)
{
List<WmsRawStock> itemList = wmsRawStocks.Where(t => t.locationCode == item.currPointNo).ToList();
foreach (var rawItem in itemList)
{
addCheckDetail.Add(new WmsInventoryCheckDetail
{
InventoryCheckDetailId = Global.SnowId.NextId(),
InventoryCheckId = inventoryCheckId,
CheckStatus = "1",
CreateBy = "WCS",
CreateTime = DateTime.Now,
StockAmount = rawItem.totalAmount,
RealAmount = rawItem.totalAmount,
InventoryCount = 0,
LocationCode = rawItem.locationCode,
StockId = 1,
StockType = "1",
MaterialId = rawItem.materialId,
ErpStatus = "0",
ErpAmount = 0,
});
}
}
InventoryCheck.InventoryingAmount += addList.Count;
if (InventoryCheck.BeginTime == null)
{
InventoryCheck.BeginTime = DateTime.Now;
InventoryCheck.CheckStatus = "1";
}
dbContext.AddRange(addCheckDetail);
dbContext.AddRange(addList);
dbContext.SaveChanges();
MessageBox.Show("任务创建成功!");
}
else
{
MessageBox.Show("无可盘点库位!");
}
}
else
{
MessageBox.Show("当前有盘点任务正在出库");
}
}
else
{
MessageBox.Show("当前有盘点任务正在出库");
}
}
}
}
/// <summary>
/// 叫空料箱
/// </summary>
@ -1893,6 +2092,7 @@ namespace Khd.Core.Wpf.Form
}
}
/// <summary>
/// 叫托盘
/// </summary>
@ -1969,6 +2169,7 @@ namespace Khd.Core.Wpf.Form
}
}
/// <summary>
/// 执行CTU任务
/// </summary>
@ -2606,5 +2807,56 @@ namespace Khd.Core.Wpf.Form
}
}
private void SelectInventoryButton_Click(object sender, RoutedEventArgs e)
{
GetInvertoryData();
}
private void GetInvertoryData()
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
try
{
var list = dbContext.WmsInventoryCheck
.Where(t => t.WarehouseId == 512)
.OrderByDescending(t => t.CreateTime).Skip((this.Pagination3.PageIndex - 1) * this.pageCount).Take(this.pageCount).ToList();
this.InventoryMaterial.ItemsSource = list.Select(t =>
new
{
InventoryCheckId = t.InventoryCheckId,
InventoriedAmount = t.InventoriedAmount,
BeginTime = t.BeginTime,
CheckStatus = t.CheckStatus == "0" ? "未开始" : t.CheckStatus == "1" ? "盘点中" : t.CheckStatus == "2" ? "已完成" : "",
CreateBy = t.CreateBy,
CreateTime = t.CreateTime,
EndTime = t.EndTime,
InventoryCheckCode = t.InventoryCheckCode,
InventoryingAmount = t.InventoryingAmount,
LocationAmount = t.LocationAmount,
Remark = t.Remark,
UpdateBy = t.UpdateBy,
UpdateTime = t.UpdateTime,
WarehouseId = t.WarehouseId,
});
this.InventoryMaterial.Items.Refresh();
if (list.Count == 0)
{
MessageBox.Show("没有数据!");
}
}
catch
{
}
}
private void InventoryTaskButton_Click(object sender, RoutedEventArgs e)
{
InventoryTaskForm inventoryTaskForm = new InventoryTaskForm(this._host);
inventoryTaskForm.ShowDialog();
}
}
}

@ -0,0 +1,81 @@
<Window x:Class="Khd.Core.Wpf.TaskForm.Inventory.InventoryTaskEditForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Khd.Core.Wpf.TaskForm.Inventory"
mc:Ignorable="d"
Background="#333333"
Closed="Window_Closed"
xmlns:hc="https://handyorg.github.io/handycontrol"
WindowStyle="None"
Loaded="Window_Loaded"
WindowStartupLocation="CenterScreen"
Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="7*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text="料箱号:" FontSize="30" Foreground="White" />
<TextBlock x:Name="ContainerNo" FontSize="30" Foreground="White" Margin="5,0,0,0"/>
</StackPanel>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border BorderBrush="White" BorderThickness="2" CornerRadius="5" Padding="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="5*" />
</Grid.RowDefinitions>
<TextBlock Text="该物料原库存信息" FontSize="24" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock x:Name="MaterialSpec" Grid.Row="1" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" MaxWidth="400"/>
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="6*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="条码" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock Text="数量" FontSize="16" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Column="2"/>
<TextBlock x:Name="BarCode" Grid.Row="1" FontSize="16" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Center" TextWrapping="Wrap"/>
<TextBlock x:Name="Count" Grid.Column="2" Grid.Row="1" FontSize="16" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Center" TextWrapping="Wrap"/>
</Grid>
</Grid>
</Border>
<Border BorderBrush="White" Grid.Column="1" BorderThickness="2" CornerRadius="5" Padding="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="6*" />
</Grid.RowDefinitions>
<TextBlock Text="该物料新库存信息" FontSize="24" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1">
<TextBox x:Name="NewBarCode" Width="250" FontSize="20" hc:InfoElement.Placeholder="请扫描条码" Style="{StaticResource TextBoxExtend}" />
<RepeatButton x:Name="ScanButton" Content="添加" Style="{StaticResource RepeatButtonPrimary}" Width="100" Margin="20,0,0,0" Click="ScanButton_Click" />
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Row="2" Margin="0,20,0,0">
<GroupBox Height="200" Header="条码" Padding="10">
<Border Background="{DynamicResource RegionBrush}" CornerRadius="4">
<TextBlock x:Name="BarCodeList" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</GroupBox>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,20,0,0">
<Button x:Name="SaveButton" Content="保存" Style="{StaticResource ButtonPrimary}" Width="100" Click="SaveButton_Click" />
<Button x:Name="CancelButton" Content="取消" Style="{StaticResource ButtonPrimary}" Width="100" Margin="20,0,0,0" Click="CancelButton_Click" />
</StackPanel>
</StackPanel>
</Grid>
</Border>
</Grid>
</Grid>
</Window>

@ -0,0 +1,221 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Khd.Core.Wpf.TaskForm.Inventory
{
/// <summary>
/// InventoryTaskEditForm.xaml 的交互逻辑
/// </summary>
public partial class InventoryTaskEditForm : Window
{
private readonly Microsoft.Extensions.Hosting.IHost _host;
private readonly long _materialId;
private readonly string _containerNo;
private readonly string _materialName;
private readonly InventoryTaskForm _inventoryTaskForm;
private readonly string _locationCode;
public InventoryTaskEditForm(Microsoft.Extensions.Hosting.IHost _host, long materialId, string containerNo, string materialName,string locationCode, InventoryTaskForm inventoryTaskForm)
{
InitializeComponent();
this._host = _host;
this._materialId = materialId;
this._containerNo = containerNo;
this._materialName = materialName;
this._inventoryTaskForm = inventoryTaskForm;
this._locationCode = locationCode;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
try
{
this.ContainerNo.Text = _containerNo;
this.MaterialSpec.Text = _materialName;
using var scope= this._host.Services.CreateScope();
using var dbContext= scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var wmsRawStocks = dbContext.WmsRawStock.Where(t => t.palletInfoCode == _containerNo && t.materialId == _materialId).ToList();
if (wmsRawStocks.Count == 0)
{
this.BarCode.Text = "空";
}
else
{
//这里把条码号用换行符分开
this.BarCode.Text = string.Join("\n", wmsRawStocks.Select(t => t.instockBatch));
this.Count.Text = string.Join("\n", wmsRawStocks.Select(t => t.totalAmount.ToString()));
}
}
catch
{
MessageBox.Show("加载数据失败,请重试");
this.Close();
}
}
private void Window_Closed(object sender, EventArgs e)
{
_inventoryTaskForm.ShowDialog();
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void ScanButton_Click(object sender, RoutedEventArgs e)
{
try
{
using var scope = this._host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == this.NewBarCode.Text);
if (mesBaseBarcodeInfo != null)
{
this.BarCodeList.Text += mesBaseBarcodeInfo.barcodeInfo + "\n";
this.NewBarCode.Text = "";
}
else
{
MessageBox.Show("条码不存在,请重新扫码");
this.NewBarCode.Text = "";
}
}
catch
{
}
}
private void SaveButton_Click(object sender, RoutedEventArgs e)
{
List<string> newList = this.BarCodeList.Text.Split('\n').Distinct().ToList();
List<string> list = this.BarCode.Text.Split('\n').ToList();
StringBuilder addStr = new StringBuilder();
List<string> addList = newList.Where(t => !list.Contains(t)).ToList();
if(addList.Count > 0)
{
addStr.AppendLine("新增条码:");
addStr.AppendLine(string.Join(",", addList));
}
StringBuilder removeStr = new();
List<string> removeList = list.Where(t => !newList.Contains(t)).ToList();
if (removeList.Count > 0)
{
removeStr.AppendLine("删除条码:");
removeStr.AppendLine(string.Join(",", removeList));
}
if(addStr.Length > 0 || removeStr.Length > 0)
{
MessageBoxResult messageBoxResult = MessageBox.Show(addStr.ToString() + "\n" + removeStr.ToString(), "提示", MessageBoxButton.OK, MessageBoxImage.Information);
if (messageBoxResult == MessageBoxResult.OK)
{
using var scope = this._host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
if(addList.Count > 0)
{
var wmsRawStocks = dbContext.WmsRawStock.Where(t => addList.Contains(t.instockBatch)).ToList();
List<string> rawList = wmsRawStocks.Select(t => t.instockBatch).ToList();
addList.RemoveAll(t=>rawList.Contains(t));
if (wmsRawStocks.Count > 0)
{
string waring = string.Join(",\n", wmsRawStocks.Select(t => new
{
message=t.locationCode+":"+t.instockBatch
}));
MessageBoxResult result = MessageBox.Show("条码已经在其他料箱中" + waring + "确认移动到当前料箱吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.OK)
{
foreach(var wmsRawStock in wmsRawStocks)
{
wmsRawStock.palletInfoCode = _containerNo;
wmsRawStock.locationCode= _locationCode;
wmsRawStock.updateBy = "WCS";
wmsRawStock.updateDate = DateTime.Now;
}
dbContext.UpdateRange(wmsRawStocks);
}
else
{
return;
}
}
if (addList.Count > 0)
{
List<WmsRawStock> newWmsRawStocks = new List<WmsRawStock>();
var mesBaseBarcodeInfos = dbContext.MesBaseBarcodeInfo.Where(t => addList.Contains(t.barcodeInfo)).ToList();
foreach (var barcode in addList)
{
var mesBaseBarcodeInfo = mesBaseBarcodeInfos.FirstOrDefault(t => t.barcodeInfo == barcode);
if (mesBaseBarcodeInfo != null)
{
newWmsRawStocks.Add(new WmsRawStock
{
palletInfoCode = _containerNo,
materialId = _materialId,
instockBatch = barcode,
safeFlag = "0",
stockType="1",
activeFlag="1",
supplierId=mesBaseBarcodeInfo.manufacturerId,
completeFlag="1",
frozenAmount=0,
instockDate=DateTime.Now,
qualityStatus="0",
rawStockId=Global.SnowId.NextId(),
occupyAmount=0,
totalAmount=mesBaseBarcodeInfo.batchFlag=="1"?mesBaseBarcodeInfo.amount:1,
warehouseFloor=5,
warehouseId=512,
saleOrderId=mesBaseBarcodeInfo.saleOrderId,
locationCode = _locationCode,
createBy = "WCS",
createDate = DateTime.Now,
updateBy = "WCS",
updateDate = DateTime.Now
});
}
else
{
MessageBox.Show($"{barcode}条码信息不存在,无法入库");
return;
}
}
if(newWmsRawStocks.Count > 0)
{
dbContext.AddRange(newWmsRawStocks);
}
}
}
if (removeList.Count > 0)
{
}
MessageBox.Show("保存成功");
}
else
{
return;
}
}
else
{
MessageBox.Show("条码未变动");
}
this.Close();
}
}
}

@ -0,0 +1,120 @@
<Window x:Class="Khd.Core.Wpf.TaskForm.InventoryTaskForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Khd.Core.Wpf.TaskForm"
mc:Ignorable="d"
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="#333333"
Loaded="Window_Loaded"
WindowStartupLocation="CenterScreen"
Height="900" Width="1500">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--<hc:ThemeResources/>
<hc:Theme/>-->
<ResourceDictionary Source="/CSS/SearchBtnClass.xaml" />
<ResourceDictionary Source="/CSS/SearchTextClass.xaml" />
<ResourceDictionary Source="/CSS/DataGridClass.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="dgCell" TargetType="TextBlock" BasedOn="{x:Null}">
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="请选择容器编号:" FontSize="30" Foreground="White" VerticalAlignment="Center"/>
<ComboBox x:Name="ContainerCodeBox" IsEditable="True" Style="{StaticResource ComboBoxExtend}" Width="300" hc:InfoElement.Placeholder="容器编码" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Necessary="True" FontSize="30" />
<Button x:Name="SearchBtn" Content="搜索" FontSize="30" Height="50" Foreground="White" Width="100" Background="#2196F3" Margin="10,0,0,0" Click="SearchBtn_Click"/>
</StackPanel>
<DataGrid
Style="{StaticResource DataGridStyle}"
Grid.Row="1"
x:Name="InventoryDataGrid"
AlternationCount="2"
AutoGenerateColumns="False"
MinRowHeight="50"
Background="Transparent"
CanUserAddRows="False"
GridLinesVisibility="None"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
Focusable="False"
HeadersVisibility="Column"
IsReadOnly="True"
VerticalAlignment="Stretch"
RowHeaderWidth="0"
SelectionMode="Single" FontSize="16"
Visibility="Visible"
>
<DataGrid.Columns>
<DataGridTextColumn Header="库位号" Binding="{Binding LocationCode}" ElementStyle="{StaticResource dgCell}" Width="200*"/>
<DataGridTextColumn Header="料箱号" Binding="{Binding ContainerNo}" ElementStyle="{StaticResource dgCell}" Width="200*"/>
<DataGridTextColumn Header="物料编码" Binding="{Binding MaterialId}" ElementStyle="{StaticResource dgCell}" Width="120*"/>
<DataGridTemplateColumn
Width="350*"
CanUserSort="False"
Header="物料描述"
IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding MaterialName}" ToolTip="{Binding MaterialName}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="库存数量" Binding="{Binding StockAmount}" ElementStyle="{StaticResource dgCell}" Width="120*"/>
<DataGridTextColumn Header="实际数量" Binding="{Binding RealAmount}" ElementStyle="{StaticResource dgCell}" Width="120*"/>
<DataGridTemplateColumn Header="操作">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="编辑" Foreground="White" Width="75" Background="#2196F3" Click="EditBtn_Click"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Background" Value="#333333" />
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#333333" />
</Style>
</DataGrid.RowStyle>
<DataGrid.RowHeaderStyle>
<Style TargetType="{x:Type DataGridRowHeader}">
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Background" Value="#333333" />
</Style>
</DataGrid.RowHeaderStyle>
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Background" Value="#333333" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="BorderThickness" Value="5" />
<Setter Property="BorderBrush" Value="#333333" />
<Setter Property="FontSize" Value="20" />
</Style>
</DataGrid.ColumnHeaderStyle>
</DataGrid>
</Grid>
</Window>

@ -0,0 +1,120 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Khd.Core.Wpf.TaskForm.Inventory;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Khd.Core.Wpf.TaskForm
{
/// <summary>
/// InventoryTaskForm.xaml 的交互逻辑
/// </summary>
public partial class InventoryTaskForm : Window
{
private readonly IHost _host;
public InventoryTaskForm(IHost host)
{
InitializeComponent();
_host = host;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
try
{
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var wcsTasks = dbContext.WcsTask.Where(t => t.taskType == 100 && t.taskStatus == 6).ToList();
if (wcsTasks.Count > 0)
{
this.ContainerCodeBox.ItemsSource = wcsTasks.Select(t => t.containerNo).Distinct();
}
else
{
MessageBox.Show("未找到盘库已完成的小车任务!");
this.Close();
}
}
catch
{
}
}
private void GetData()
{
if (this.ContainerCodeBox.SelectedItem != null)
{
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var wcsTask = dbContext.WcsTask
.Where(t => t.taskType == 100)
.Where(t => t.containerNo == this.ContainerCodeBox.Text).FirstOrDefault();
if (wcsTask != null)
{
var wmsInventoryCheckDetails = dbContext.WmsInventoryCheckDetail
.Where(t => t.InventoryCheckId == wcsTask.orderId)
.Where(t => t.LocationCode == wcsTask.currPointNo)
.Where(t => t.CheckStatus == "1")
.ToList();
List<long?> list = wmsInventoryCheckDetails.Select(t => t.MaterialId).Distinct().ToList();
List<MesBaseMaterialInfo> mesBaseMaterialInfos = dbContext.MesBaseMaterialInfo.Where(t => list.Contains(t.MaterialId)).ToList();
this.InventoryDataGrid.ItemsSource = wmsInventoryCheckDetails.GroupBy(t => t.MaterialId).Select(t =>
new
{
ContainerNo = wcsTask.containerNo,
MaterialName = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.Key)?.MaterialSpec,
StockAmount = t.Sum(n => n.StockAmount),
LocationCode = wcsTask.currPointNo,
MaterialId = t.Key,
RealAmount = t.Sum(n => n.RealAmount),
});
this.InventoryDataGrid.Items.Refresh();
if (wmsInventoryCheckDetails.Count == 0)
{
MessageBox.Show("该料箱为空料箱");
}
}
}
else
{
MessageBox.Show("请先选择料箱号!");
}
}
private void SearchBtn_Click(object sender, RoutedEventArgs e)
{
GetData();
}
private void EditBtn_Click(object sender, RoutedEventArgs e)
{
dynamic item = this.InventoryDataGrid.SelectedItem;
long materialId = item.MaterialId;
string containerNo = item.ContainerNo;
string materialName = item.MaterialName;
string locationCode = item.LocationCode;
InventoryTaskEditForm editForm = new InventoryTaskEditForm(_host, materialId, containerNo, materialName, locationCode, this);
this.Hide();
editForm.ShowDialog();
GetData();
}
}
}

@ -3,9 +3,9 @@
//mysql
//"DefaultConnection": "server=106.12.13.113;port=3306;database=khd_jyhb;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True"
//khd
//"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=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=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=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"
},
"PlcConfigs": [
{

Loading…
Cancel
Save