2 years ago
commit e67ecafc30

@ -54,7 +54,7 @@ namespace Khd.Core.Api.Controllers
[HttpPost("agvComplete")]
public AgvCompeletedResponse MesToAgvComplete(AgvCompeleted agvCompeletedRequest)
{
LogManager.Info($"RecieveRcsController接口信息:{agvCompeletedRequest.ToJsonString()}");
LogManager.Info($"agvComplete接口信息:{agvCompeletedRequest.ToJsonString()}");
return _application.MesToAgvComplete(agvCompeletedRequest);
}

@ -166,10 +166,11 @@ namespace Khd.Core.Application
{
var wcsTask = _dbContext.WcsTask
.Where(t => (t.taskType == 32 || t.taskType == 48) && (t.endPointId == baseEquip.objid || t.currPointId == baseEquip.objid))
.OrderByDescending(t => t.createTime)
.OrderBy(t => t.createTime)
.FirstOrDefault();
if (wcsTask != null)
{
LogManager.Info($"agvComplete接口找到任务{wcsTask.ToJsonString()}");
if (wcsTask.taskType != 48 && wcsTask.taskStatus != 0)
{
wcsTask.taskStatus = 7;
@ -178,6 +179,7 @@ namespace Khd.Core.Application
_dbContext.SaveChanges();
agvCompeletedResponse.code = "0";
agvCompeletedResponse.message = "成功";
LogManager.Info($"agvComplete更新任务状态7{wcsTask.ToJsonString()}");
}
else if (wcsTask.taskStatus != 0)
{

@ -0,0 +1,136 @@
//-----------------------------------------------------------------------
//<copyright>
// * Copyright (C) 2021 KEHAIDASOFT All Rights Reserved
// * version : 4.0.30319.42000
// * author : khd by t4-2
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Khd.Core.Domain.Models
{
[Table("mes_product_plan_detail")]
public class MesProductPlanDetail
{
[Key]
[Column("plan_detail_id")]
public long PlanDetailId { get; set; }
/// <summary>
/// 明细编号
/// </summary>
[Column("plan_detail_code")]
[Required]
[StringLength(64)]
public string PlanDetailCode { get; set; }
/// <summary>
/// 生产计划ID
/// </summary>
[Column("plan_id")]
[Required]
public long PlanId { get; set; }
/// <summary>
/// 计划编号, 关联mes_product_plan_info的plan_code
/// </summary>
[Column("plan_code")]
[Required]
[StringLength(64)]
public string PlanCode { get; set; }
/// <summary>
/// 操作人员ID关联sys_user的user_id
/// </summary>
[Column("user_id")]
public long? UserId { get; set; }
/// <summary>
/// 操作人员名称关联sys_user的user_name
/// </summary>
[Column("user_name")]
[StringLength(64)]
public string UserName { get; set; }
/// <summary>
/// 开始时间
/// </summary>
[Column("real_begin_time")]
public DateTime? RealBeginTime { get; set; }
/// <summary>
/// 完成时间
/// </summary>
[Column("real_end_time")]
public DateTime? RealEndTime { get; set; }
/// <summary>
/// 文件ID关联附件信息主键
/// </summary>
[Column("attach_id")]
public int? AttachId { get; set; }
/// <summary>
/// 明细状态1-未开始2-已开始3-已完成9-异常完成(校验物料信息不完整)
/// </summary>
[Column("plan_detail_status")]
[Required]
[StringLength(1)]
public string PlanDetailStatus { get; set; } = "1";
/// <summary>
/// 是否标识1-是0-否
/// </summary>
[Column("is_flag")]
[Required]
[StringLength(1)]
public string IsFlag { get; set; } = "1";
/// <summary>
/// 备注
/// </summary>
[Column("remark")]
[StringLength(500)]
public string Remark { get; set; }
/// <summary>
/// 创建人
/// </summary>
[Column("create_by")]
[StringLength(64)]
public string CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Column("create_time")]
public DateTime? CreateTime { get; set; }
/// <summary>
/// 更新人
/// </summary>
[Column("update_by")]
[StringLength(64)]
public string UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[Column("update_time")]
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 物料条码
/// </summary>
[Column("material_barcode")]
[StringLength(64)]
public string MaterialBarcode { get; set; }
}
}

@ -0,0 +1,41 @@
//-----------------------------------------------------------------------
//<copyright>
// * Copyright (C) 2021 KEHAIDASOFT All Rights Reserved
// * version : 4.0.30319.42000
// * author : khd by t4-2
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Khd.Core.Domain.Models
{
[Table("mes_sale_order_relate")]
public class MesSaleOrderRelate
{
[Key]
[Column("sale_order_relate_id")]
public long SaleOrderRelateId { get; set; }
[Column("sale_order_id")]
public long SaleOrderId { get; set; }
[Column("relate_sale_order_id")]
public long RelateSaleOrderId { get; set; }
[Column("purchase_order_id")]
public long PurchaseOrderId { get; set; }
[Column("relate_sale_order_amout")]
public decimal RelateSaleOrderAmount { get; set; }
[Column("material_id")]
public long MaterialId { get; set; }
}
}

@ -36,5 +36,11 @@ namespace Khd.Core.Domain.Models
public string UpdateBy { get; set; }
[Column("update_date")]
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 物料类型id,如果为null盘所有库不为null盘该物料的库
/// </summary>
[Column("material_id")]
public string? MaterialId { get; set; }
}
}

@ -0,0 +1,120 @@
//-----------------------------------------------------------------------
//<copyright>
// * Copyright (C) 2021 KEHAIDASOFT All Rights Reserved
// * version : 4.0.30319.42000
// * author : khd by t4-2
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Khd.Core.Domain.Models
{
[Table("wms_move")]
public class WmsMove
{
[Key]
[Column("move_id")]
public long MoveId { get; set; }
[Required]
[Column("task_code")]
[MaxLength(128)]
public string TaskCode { get; set; }
[Required]
[Column("warehouse_id")]
public long WarehouseId { get; set; }
[Required]
[Column("ori_location_code")]
[MaxLength(64)]
public string OriLocationCode { get; set; }
[Required]
[Column("target_location_code")]
[MaxLength(64)]
public string TargetLocationCode { get; set; }
[Column("instock_batch")]
[MaxLength(64)]
public string InstockBatch { get; set; }
[Column("material_id")]
public long? MaterialId { get; set; }
[Column("plan_amount")]
public decimal? PlanAmount { get; set; }
[Column("real_outstock_amount")]
public decimal RealOutstockAmount { get; set; } = 0.000000m;
[Column("real_instock_amount")]
public decimal RealInstockAmount { get; set; } = 0.000000m;
[Required]
[Column("operation_type")]
[MaxLength(1)]
public string OperationType { get; set; }
[Required]
[Column("move_way")]
[MaxLength(1)]
public string MoveWay { get; set; }
[Required]
[Column("move_type")]
[MaxLength(1)]
public string MoveType { get; set; }
[Column("apply_reason")]
[MaxLength(500)]
public string ApplyReason { get; set; }
[Column("audit_reason")]
[MaxLength(500)]
public string AuditReason { get; set; }
[Required]
[Column("audit_status")]
[MaxLength(1)]
public string AuditStatus { get; set; }
[Required]
[Column("execute_status")]
[MaxLength(1)]
public string ExecuteStatus { get; set; }
[Column("apply_by")]
[MaxLength(64)]
public string ApplyBy { get; set; }
[Column("apply_date")]
public DateTime? ApplyDate { get; set; }
[Column("audit_by")]
[MaxLength(64)]
public string AuditBy { get; set; }
[Column("audit_date")]
public DateTime? AuditDate { get; set; }
[Column("update_by")]
[MaxLength(64)]
public string UpdateBy { get; set; }
[Column("update_date")]
public DateTime? UpdateDate { get; set; }
[Column("begin_time")]
public DateTime? BeginTime { get; set; }
[Column("end_time")]
public DateTime? EndTime { get; set; }
}
}

@ -0,0 +1,92 @@
//-----------------------------------------------------------------------
//<copyright>
// * Copyright (C) 2021 KEHAIDASOFT All Rights Reserved
// * version : 4.0.30319.42000
// * author : khd by t4-2
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Khd.Core.Domain.Models
{
[Table("wms_move_detail")]
public class WmsMoveDetail
{
[Key]
[Column("move_detail_id")]
public long MoveDetailId { get; set; }
[Required]
[Column("move_id")]
public long MoveId { get; set; }
[Column("material_barcode")]
[MaxLength(64)]
public string? MaterialBarcode { get; set; }
[Column("instock_batch")]
[MaxLength(64)]
public string? InstockBatch { get; set; }
[Required]
[Column("material_id")]
public long MaterialId { get; set; }
[Column("location_code")]
[MaxLength(64)]
public string? LocationCode { get; set; }
[Required]
[Column("plan_amount")]
public decimal PlanAmount { get; set; }
[Column("real_amount")]
public decimal? RealAmount { get; set; }
[Column("real_instock_amount")]
public decimal? RealInstockAmount { get; set; }
[Required]
[Column("execute_status")]
[MaxLength(1)]
public string ExecuteStatus { get; set; }
[Column("execute_person")]
[MaxLength(64)]
public string? ExecutePerson { get; set; }
[Column("execute_time")]
public DateTime? ExecuteTime { get; set; }
[Column("execute_end_time")]
public DateTime? ExecuteEndTime { get; set; }
[Column("machine_name")]
[MaxLength(64)]
public string? MachineName { get; set; }
[Column("create_by")]
[MaxLength(64)]
public string? CreateBy { get; set; }
[Column("create_date")]
public DateTime? CreateDate { get; set; }
[Column("update_by")]
[MaxLength(64)]
public string? UpdateBy { get; set; }
[Column("update_date")]
public DateTime? UpdateDate { get; set; }
[Column("active_flag")]
[MaxLength(1)]
public string? ActiveFlag { get; set; }
}
}

@ -64,6 +64,12 @@ namespace Khd.Core.Domain.Models
[Column("material_id")]
public long? materialId { get; set; }
/// <summary>
/// 物料条码信息
/// </summary>
[Column("material_barcode")]
public string materialBarCode { get; set; }
/// <summary>
/// 物料批次信息
/// </summary>
@ -106,17 +112,17 @@ 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>
///// 审核人
@ -159,6 +165,12 @@ namespace Khd.Core.Domain.Models
/// </summary>
[Column("return_flag")]
public string? returnFlag { get; set; }
/// <summary>
/// 请求返回标识(1是)execute_status改为2时此return_flag改为null
/// </summary>
[Column("purchase_order_id")]
public long? purchaseOrderId { get; set; }
}
}

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Khd.Core.Domain.Models
{
[Table("wms_raw_preferred_out")]
public class WmsRawPreferredOut
{
[Key]
[Column("raw_preferred_out_id")]
public long RawPreferredOutId { get; set; } // 优先出库ID
[Column("warehouse_id")]
public long WarehouseId { get; set; } // 仓库ID
[Column("warehouse_floor")]
public int? WarehouseFloor { get; set; } // 仓库楼层
[Column("location_code")]
[Required]
[MaxLength(64)]
public string LocationCode { get; set; } // 库位编码
[Column("stock_type")]
[Required]
[MaxLength(1)]
public string StockType { get; set; } // 库存类型1原材料2成品
[Column("material_id")]
public long MaterialId { get; set; } // 物料ID
[Column("create_by")]
[MaxLength(64)]
public string CreateBy { get; set; } // 创建人
[Column("create_date")]
public DateTime? CreateDate { get; set; } // 创建时间
[Column("update_by")]
[MaxLength(64)]
public string UpdateBy { get; set; } // 最后更新人
[Column("update_date")]
public DateTime? UpdateDate { get; set; } // 最后更新时间
[Column("use_flag")]
[Required]
[MaxLength(1)]
public string UseFlag { get; set; } = "1"; // 有效标记
}
}

@ -0,0 +1,104 @@
//-----------------------------------------------------------------------
//<copyright>
// * Copyright (C) 2021 KEHAIDASOFT All Rights Reserved
// * version : 4.0.30319.42000
// * author : khd by t4-2
// </copyright>
//-----------------------------------------------------------------------
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Khd.Core.Domain.Models
{
[Table("wms_raw_return_detail")]
public class WmsRawReturnDetail
{
[Key]
[Column("raw_return_detail_id")]
public long RawReturnDetailId { get; set; }
[Column("raw_return_id")]
public long RawReturnId { get; set; }
[Column("location_code")]
[StringLength(64)]
public string LocationCode { get; set; }
[Column("material_barcode")]
[StringLength(64)]
public string MaterialBarcode { get; set; }
[Column("material_id")]
public long MaterialId { get; set; }
[Column("instock_batch")]
[StringLength(64)]
public string InstockBatch { get; set; }
[Column("material_production_date")]
public DateTime? MaterialProductionDate { get; set; }
[Column("plan_amount")]
[Precision(16, 2)]
public decimal PlanAmount { get; set; }
[Column("return_amount")]
[Precision(16, 2)]
public decimal? ReturnAmount { get; set; }
[Column("execute_status")]
[StringLength(1)]
public string ExecuteStatus { get; set; }
[Column("erp_status")]
[StringLength(1)]
public string ErpStatus { get; set; }
[Column("erp_amount")]
[Precision(16, 2)]
public decimal? ErpAmount { get; set; }
[Column("return_person")]
[StringLength(64)]
public string ReturnPerson { get; set; }
[Column("return_time")]
public DateTime? ReturnTime { get; set; }
[Column("return_way")]
[StringLength(1)]
public string ReturnWay { get; set; }
[Column("machine_name")]
[StringLength(64)]
public string MachineName { get; set; }
[Column("quality_status")]
[StringLength(1)]
public string QualityStatus { get; set; }
[Column("create_by")]
[StringLength(64)]
public string CreateBy { get; set; }
[Column("create_date")]
public DateTime? CreateDate { get; set; }
[Column("update_by")]
[StringLength(64)]
public string UpdateBy { get; set; }
[Column("update_date")]
public DateTime? UpdateDate { get; set; }
[Column("stack_amount")]
[Precision(16, 2)]
public decimal? StackAmount { get; set; }
}
}

@ -19,6 +19,10 @@ namespace Khd.Core.EntityFramework
public DbSet<WmsInventoryCheckDetail> WmsInventoryCheckDetail { get; set; }
public DbSet<MesBaseMaterialInfo> MesBaseMaterialInfo { get; set; }
public DbSet<WmsRawReturn> WmsRawReturn { get; set; }
public DbSet<WmsRawPreferredOut> WmsRawPreferredOut { get; set; }
public DbSet<WmsMove> WmsMove { get; set; }
public DbSet<WmsMoveDetail> WmsMoveDetail { get; set; }
public DbSet<WmsRawReturnDetail> WmsRawReturnDetail { get; set; }
public DbSet<WcsTaskManual> WcsTaskManual { get; set; }
public DbSet<BaseDictionary> BaseDictionary { get; set; }
@ -27,9 +31,13 @@ namespace Khd.Core.EntityFramework
public DbSet<BasePlcpoint> BasePlcpoint { get; set; }
public DbSet<BasePlc> BasePlc { get; set; }
public DbSet<MesBasePalletInfo> MesBasePalletInfo { get; set; }
public DbSet<MesSaleOrderRelate> MesSaleOrderRelate { get; set; }
public DbSet<MesProductPlanDetail> MesProductPlanDetail { get; set; }
public DbSet<WcsCmd> WcsCmd { get; set; }
public DbSet<WcsCmdLog> WcsCmdLog { get; set; }

@ -27,6 +27,38 @@ namespace Khd.Core.Plc
plc.Write(address, GetValue(len, valueString));
}
/// <summary>
/// 写入RFID
/// </summary>
/// <param name="plc"> plc </param>
/// <param name="address"> 读取地址 </param>
/// <param name="len"> 长度 </param>
/// <returns> 读取到的RFID </returns>
public static void WriteRFID(this Plc.S7.Plc plc, string address, string value,int len = 15)
{
string[] adds = address.Split(".");
int db = int.Parse(adds[0].Replace("DB", ""));
int startByteAdr = int.Parse(adds[1].Replace("DBX", ""));
// 将 value 转换为字节数组,确保其长度符合要求
byte[] byteArray = Encoding.ASCII.GetBytes(value);
if (byteArray.Length > len)
{
throw new ArgumentException($"Value length exceeds the specified length of {len} bytes.");
}
// 填充字节数组到指定长度
byte[] dataToWrite = new byte[len];
Array.Copy(byteArray, dataToWrite, byteArray.Length);
plc.Write(S7.DataType.DataBlock, db, startByteAdr, dataToWrite);
}
/// <summary>
/// 读取RFID
/// </summary>

@ -1,7 +1,11 @@
using Khd.Core.EntityFramework;
using Jc.SnowId;
using Khd.Core.Domain.Dto.TaskType;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Khd.Core.Library;
using Khd.Core.Wcs.Global;
using Khd.Core.Wcs.Wcs;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Data;
@ -31,6 +35,7 @@ namespace Khd.Core.Wcs
/// </summary>
public void Start()
{
LoggerUtils logger = new LoggerUtils();
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
@ -43,6 +48,7 @@ namespace Khd.Core.Wcs
StaticData.BaseEquip = dbContext.BaseEquip.ToList();//设备信息
StaticData.BaseDictionary = dbContext.BaseDictionary.ToList();//字典表Agv任务模板
StaticData.DmsBaseAlarmRuleList = dbContext.DmsBaseAlarmRule.ToList();
foreach (var plcConfig in StaticData.PlcConfigs)
{
if (!StaticData.PlcDic.Any(t => t.Key == plcConfig.Code))
@ -61,6 +67,7 @@ namespace Khd.Core.Wcs
StaticData.PlcDic.TryAdd(plcConfig.Code, plc);
}
}
//创建定时器
SystemTimer systemTimer = new(_host);
systemTimer.Start();
@ -77,11 +84,11 @@ namespace Khd.Core.Wcs
SecondFloorPoint secondFloorPoint = new(_host, 2);
secondFloorPoint.StartPoint();
//二层AGV
////二层AGV
SecondFloorAGV secondFloorAGV = new(_host, 2);
secondFloorAGV.StartPoint();
//二楼线体
// //二楼线体
SecondFloorLine secondFloorLine = new(_host, 2);
secondFloorLine.StartPoint();
@ -109,7 +116,7 @@ namespace Khd.Core.Wcs
FiveFloorAGV fifthFloorAGV = new(_host, 5);
fifthFloorAGV.StartPoint();
//背负式Agv
////背负式Agv
FiveFloorBearAgv fiveFloorBearAgv = new(_host, 5);
fiveFloorBearAgv.StartPoint();
}
@ -118,7 +125,12 @@ namespace Khd.Core.Wcs
Console.WriteLine(ex.Message);
logger.Error(ex.Message + "\n" + ex.StackTrace);
}
}
}
}

File diff suppressed because it is too large Load Diff

@ -420,6 +420,10 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
else
{ //TODO 物料未绑定仓库,添加报警
}
}
}
}
@ -541,7 +545,10 @@ namespace Khd.Core.Wcs.Wcs
BaseEquip lineEquip = dbContext.BaseEquip.First(t => t.objid == wcsTask.floorNo);
if (wcsTask.taskStatus == 0 && Convert.ToInt32(hoisterTrayIn06Value) == 0)//创建状态,并且里面没有货物
{
if (lineEquip.equipStatus == 1)
// 目的楼层从接驳位出发入库的任务 --待测试
var InTask = dbContext.WcsTask.FirstOrDefault(t => t.currPointId == lineEquip.objid);
if (lineEquip.equipStatus == 1 && InTask==null)
{
_logger.Info("提升机线程:" + wcsTask.floorNo + "楼接驳位有AGV任务跳过当前任务");
continue;

@ -7,6 +7,7 @@ using Khd.Core.Library.Mapper;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
using Masuit.Tools;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
@ -463,6 +464,48 @@ namespace Khd.Core.Wcs.Wcs
});
dbContext.Remove(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 6 });
#region 插入移库记录
WmsMove wmsMove = new WmsMove();
wmsMove.MoveId = StaticData.SnowId.NextId();
wmsMove.TaskCode = StaticData.SnowId.NextId().ToString();
wmsMove.WarehouseId = wmsBaseLocation.warehouseId;
wmsMove.OriLocationCode = wmsBaseLocation.locationCode;
wmsMove.TargetLocationCode = toLocation.locationCode;
wmsMove.InstockBatch = wmsRawStock.instockBatch;
wmsMove.MaterialId = wmsRawStock.materialId;
wmsMove.PlanAmount = 1;
wmsMove.RealOutstockAmount = 1;
wmsMove.RealInstockAmount = 1;
wmsMove.OperationType = "3";
wmsMove.MoveWay = "2";
wmsMove.MoveType = "1";
wmsMove.AuditStatus = "1";
wmsMove.ExecuteStatus = "2";
wmsMove.UpdateBy = "WCS";
wmsMove.UpdateDate = DateTime.Now;
wmsMove.BeginTime = DateTime.Now;
wmsMove.EndTime = DateTime.Now;
WmsMoveDetail wmsMoveDetail = new WmsMoveDetail();
wmsMoveDetail.MoveId = wmsMove.MoveId;
wmsMoveDetail.MaterialBarcode = wmsMove.InstockBatch;
wmsMoveDetail.InstockBatch = wmsMove.InstockBatch;
wmsMoveDetail.MaterialId = (long)wmsRawStock.materialId;
wmsMoveDetail.LocationCode = toLocation.locationCode;
wmsMoveDetail.PlanAmount = 1;
wmsMoveDetail.RealInstockAmount = 1;
wmsMoveDetail.RealAmount = 1;
wmsMoveDetail.ExecuteStatus = "2";
wmsMoveDetail.ExecuteTime = DateTime.Now;
wmsMoveDetail.ExecuteEndTime = DateTime.Now;
wmsMoveDetail.ExecutePerson = "WCS";
wmsMoveDetail.UpdateBy = "WCS";
wmsMoveDetail.UpdateDate = DateTime.Now;
dbContext.WmsMove.Add(wmsMove);
dbContext.WmsMoveDetail.Add(wmsMoveDetail);
#endregion
dbContext.SaveChanges();
dbContextTransaction.Commit();
}
@ -483,27 +526,47 @@ namespace Khd.Core.Wcs.Wcs
{
Console.WriteLine(DateTime.Now + ":五楼AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
_logger.Info("五楼Agv完成任务成功" + item.ToJsonString());
var wmsProductOutstockDetail = dbContext.WmsProductOutstockDetail.FirstOrDefault(t => t.productOutstockId == item.orderId && t.executeStatus == "1" && t.locationCode == item.currPointNo);
var wmsProductOutstock = dbContext.WmsProductOutstock.FirstOrDefault(t => t.productOutstockId == item.orderId);
if (wmsProductOutstockDetail != null && wmsProductOutstock != null)
if ( wmsProductOutstock != null)
{
wmsProductOutstockDetail.executeStatus = "2";
wmsProductOutstockDetail.endTime = DateTime.Now;
dbContext.Update(wmsProductOutstockDetail);
var wmsBaseLocation = dbContext.WmsBaseLocation.Where(t => t.locationId == item.currPointId).First();
WmsProductStock wmsProductStock = dbContext.WmsProductStock.First(t => t.locationCode == wmsBaseLocation.locationCode);
wmsProductOutstock.outstockQty += 1;
if (wmsProductOutstock.applyQty <= wmsProductOutstock.outstockQty)
{
wmsProductOutstock.endTime = DateTime.Now;
wmsProductOutstock.executeStatus = "2";
}
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation
.First(t => t.locationId == item.currPointId && t.warehouseFloor == 5);
WmsProductOutstockDetail newWmsProductOutstockDetail = new WmsProductOutstockDetail();
newWmsProductOutstockDetail.productOutstockId = wmsProductOutstock.productOutstockId;
newWmsProductOutstockDetail.warehouseId = wmsProductOutstock.warehouseId;
newWmsProductOutstockDetail.locationCode = wmsBaseLocation.locationCode;
newWmsProductOutstockDetail.productBarcode = wmsProductStock.productBatch;
newWmsProductOutstockDetail.productId = wmsProductStock.productId;
newWmsProductOutstockDetail.planAmount = wmsProductOutstock.applyQty;
newWmsProductOutstockDetail.outstockAmount = wmsProductOutstock.outstockQty;
newWmsProductOutstockDetail.executeStatus = "2";
newWmsProductOutstockDetail.updateBy = "WCS";
newWmsProductOutstockDetail.updateDate = DateTime.Now;
newWmsProductOutstockDetail.beginTime = DateTime.Now;
newWmsProductOutstockDetail.endTime = DateTime.Now;
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.containerCode = null;
wmsBaseLocation.updateTime = DateTime.Now;
wmsBaseLocation.updateBy = "WCS";
dbContext.Update(wmsBaseLocation);
SystemData.UnLockOutLocation(wmsBaseLocation, dbContext);
dbContext.WmsProductStock.Where(t => t.locationCode == wmsBaseLocation.locationCode).Delete();
BaseEquip floorLineEquip = StaticData.BaseEquip.First(t => t.equipType == 1 && t.floorNo == 5);
WcsTask newTask = CoreMapper.Map<WcsTask>(item);
@ -514,6 +577,7 @@ namespace Khd.Core.Wcs.Wcs
newTask.floorNo = 1;
newTask.taskStatus = 6;
newTask.objid = StaticData.SnowId.NextId();
dbContext.Add(newWmsProductOutstockDetail);
dbContext.Remove(item);
dbContext.Add(newTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(newTask);
@ -529,14 +593,11 @@ namespace Khd.Core.Wcs.Wcs
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)
{
wmsRawOutstock.realOutstockAmount += 1;
wmsRawOutstockDetail.executeStatus = "2";
wmsRawOutstock.executeStatus = "2";
wmsRawOutstock.endTime = DateTime.Now;
wmsRawOutstockDetail.outstockTime = DateTime.Now;
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
SystemData.UnLockOutLocation(wmsBaseLocation, dbContext);
wmsBaseLocation.returnFlag = "0";
@ -545,13 +606,13 @@ namespace Khd.Core.Wcs.Wcs
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.WcsTask.Remove(item);
dbContext.SaveChanges();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
}
}
}
else if (item.taskType == StaticTaskType.FiveHalfIn)//半成品入库
@ -598,7 +659,7 @@ namespace Khd.Core.Wcs.Wcs
occupyAmount = 0,
planCode = wmsProductInstock.planCode,
planDetailCode = wmsProductInstock.planDetailCode,
warehouseId = 512
warehouseId = 521
};
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == item.currPointId);
//wmsProductInstockDetail.executeStatus = "2";
@ -620,31 +681,58 @@ namespace Khd.Core.Wcs.Wcs
Console.WriteLine(DateTime.Now + ":五楼AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
_logger.Info("五楼Agv完成任务成功" + item.ToJsonString());
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)
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
WmsRawStock? wmsRawStock = dbContext.WmsRawStock.Where(t => t.locationCode == wmsBaseLocation.locationCode).FirstOrDefault();
if (wmsRawOutStock != null && wmsRawStock != null)
{
wmsRawOutStock.realOutstockAmount += 1;
wmsRawOutstockDetail.executeStatus = "2";
wmsRawOutStock.executeStatus = "2";
wmsRawOutStock.endTime = DateTime.Now;
wmsRawOutstockDetail.outstockTime = DateTime.Now;
dbContext.Update(wmsRawOutStock);
dbContext.Update(wmsRawOutstockDetail);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
WmsRawOutstockDetail newWmsRawOutstockDetail = new WmsRawOutstockDetail();
newWmsRawOutstockDetail.rawOutstockId = wmsRawOutStock.rawOutstockId;
newWmsRawOutstockDetail.taskCode = wmsRawOutStock.taskCode;
newWmsRawOutstockDetail.warehouseId = wmsRawOutStock.warehouseId;
newWmsRawOutstockDetail.locationCode = wmsRawStock.locationCode;
newWmsRawOutstockDetail.materialBarcode = wmsRawStock.instockBatch;
newWmsRawOutstockDetail.materialId = wmsRawStock.materialId;
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.barcodeInfo == wmsRawStock.instockBatch).FirstOrDefault();
if (mesBaseBarcodeInfo != null)
{
newWmsRawOutstockDetail.instockBatch = mesBaseBarcodeInfo.batchCode;
newWmsRawOutstockDetail.materialProductionDate = mesBaseBarcodeInfo.productionDate;
}
newWmsRawOutstockDetail.planAmount = wmsRawOutStock.outstockAmount;
newWmsRawOutstockDetail.outstockAmount = wmsRawOutStock.realOutstockAmount;
newWmsRawOutstockDetail.executeStatus = "2";
newWmsRawOutstockDetail.outstockPerson = wmsRawOutStock.applyBy;
newWmsRawOutstockDetail.outstockTime = DateTime.Now;
newWmsRawOutstockDetail.outstockWay = "2";
newWmsRawOutstockDetail.createBy = "WCS";
newWmsRawOutstockDetail.createDate = DateTime.Now;
newWmsRawOutstockDetail.stackAmount = 1;
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.containerCode = null;
wmsBaseLocation.updateTime = DateTime.Now;
wmsBaseLocation.updateBy = "WCS";
SystemData.UnLockOutLocation(wmsBaseLocation, dbContext);
WmsRawStock? wmsRawStock = dbContext.WmsRawStock.Where(t => t.locationCode == wmsBaseLocation.locationCode).FirstOrDefault();
if (wmsRawStock != null)
{
dbContext.Remove(wmsRawStock);
dbContext.Update(wmsBaseLocation);
dbContext.Remove(item);
dbContext.SaveChanges();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
}
dbContext.Update(wmsRawOutStock);
dbContext.Add(newWmsRawOutstockDetail);
dbContext.Remove(wmsRawStock);
dbContext.Update(wmsBaseLocation);
dbContext.Remove(item);
dbContext.SaveChanges();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
}
}
else if (item.taskType == StaticTaskType.FiveRawSplitReturn)//柜体拆分到原材料
@ -688,23 +776,13 @@ namespace Khd.Core.Wcs.Wcs
updateDate = DateTime.Now,
warehouseId = 511,
};
WmsRawInstock wmsRawInstock = new WmsRawInstock()
{
beginTime = System.DateTime.Now,
endTime = DateTime.Now,
locationCode = wmsBaseLocation.locationCode,
executeStatus = "2",
instockAmount = 1,
instockType = "2",
materialBatchCode = mesBaseBarcodeInfo.barcodeInfo,
materialId = mesBaseBarcodeInfo.materialId,
operationType = "3",
palletInfoCode = mesBaseBarcodeInfo.palletInfoCode,
poNo = mesBaseBarcodeInfo.poNo,
warehouseId = 511
};
WmsRawInstock? WmsRawInstock = dbContext.WmsRawInstock.FirstOrDefault(t => t.materialBarCode == mesBasePalletInfo.materialBarcode && t.instockType == "2");
WmsRawInstock.returnFlag = null;
WmsRawInstock.executeStatus = "2";
WmsRawInstock.updateDate = DateTime.Now;
SystemData.UnLockOutLocation(wmsBaseLocation, dbContext);
dbContext.Add(wmsRawInstock);
dbContext.Update(WmsRawInstock);
dbContext.Add(wmsRawStock);
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == item.currPointId);
startEquip.emptyCount = 0;
@ -730,6 +808,68 @@ namespace Khd.Core.Wcs.Wcs
var mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
if (mesBaseBarcodeInfo != null)
{
if (mesBaseBarcodeInfo.PurchaseOrderId == -1)
{ // 虚拟托盘号,合并的物料分别插入WmsRawInstock
List<MesSaleOrderRelate> mesSaleOrderRelates = dbContext.MesSaleOrderRelate.Where(x => x.SaleOrderId == mesBaseBarcodeInfo.saleOrderId).ToList();
List<WmsRawInstock>? wmsRawInstocks = new List<WmsRawInstock>();
foreach(var mesSaleOrderRelate in mesSaleOrderRelates)
{
WmsRawInstock wmsRawInstock = new WmsRawInstock()
{
taskCode = StaticData.SnowId.NextId().ToString(),
materialBarCode = null,
materialBatchCode = null,
applyBy = "wcs",
applyDate = System.DateTime.Now,
purchaseOrderId = mesSaleOrderRelate.PurchaseOrderId,
beginTime = DateTime.Now,
endTime = DateTime.Now,
locationCode = wmsBaseLocation.locationCode,
executeStatus = "2",
instockAmount = mesSaleOrderRelate.RelateSaleOrderAmount,
instockType = "1",
materialId = mesSaleOrderRelate.MaterialId,
operationType = "3",
palletInfoCode = mesBaseBarcodeInfo.palletInfoCode,
poNo = mesBaseBarcodeInfo.poNo,
warehouseId = 511
};
wmsRawInstocks.Add(wmsRawInstock);
}
if(wmsRawInstocks.Count > 0)
{
dbContext.WmsRawInstock.AddRange(wmsRawInstocks);
}
}
else
{
WmsRawInstock wmsRawInstock = new WmsRawInstock()
{
taskCode = StaticData.SnowId.NextId().ToString(),
materialBarCode = mesBaseBarcodeInfo.barcodeInfo,
materialBatchCode = mesBaseBarcodeInfo.batchCode,
applyBy = "wcs",
applyDate = System.DateTime.Now,
purchaseOrderId = mesBaseBarcodeInfo.PurchaseOrderId,
beginTime = DateTime.Now,
endTime = DateTime.Now,
locationCode = wmsBaseLocation.locationCode,
executeStatus = "2",
instockAmount = 1,
instockType = "1",
materialId = mesBaseBarcodeInfo.materialId,
operationType = "3",
palletInfoCode = mesBaseBarcodeInfo.palletInfoCode,
poNo = mesBaseBarcodeInfo.poNo,
warehouseId = 511
};
dbContext.Add(wmsRawInstock);
}
WmsRawStock wmsRawStock = new()
{
palletInfoCode = mesBasePalletInfo.palletInfoCode,
@ -755,23 +895,8 @@ namespace Khd.Core.Wcs.Wcs
updateDate = DateTime.Now,
warehouseId = 511,
};
WmsRawInstock wmsRawInstock = new WmsRawInstock()
{
beginTime = DateTime.Now,
endTime = DateTime.Now,
locationCode = wmsBaseLocation.locationCode,
executeStatus = "2",
instockAmount = 1,
instockType = "1",
materialBatchCode = mesBaseBarcodeInfo.barcodeInfo,
materialId = mesBaseBarcodeInfo.materialId,
operationType = "3",
palletInfoCode = mesBaseBarcodeInfo.palletInfoCode,
poNo = mesBaseBarcodeInfo.poNo,
warehouseId = 511
};
SystemData.UnLockOutLocation(wmsBaseLocation, dbContext);
dbContext.Add(wmsRawInstock);
wmsBaseLocation.returnFlag = "0";
BaseEquip lineEquip = dbContext.BaseEquip.First(t => t.objid == 5);
lineEquip.equipStatus = 0;

@ -148,7 +148,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
if (task.taskType == StaticTaskType.FiveAccessoryOut || task.taskType == StaticTaskType.FiveAccessoryRemove)
if (task.taskType == StaticTaskType.FiveAccessoryOut || task.taskType == StaticTaskType.FiveAccessoryRemove || task.taskType == StaticTaskType.FiveAccessoryStorage)
{
dbContext.WcsTask.Where(t => t.objid == task.objid).Delete();
#region 暂不使用-因为删除之后ctu无法知道还有几个箱子///如果已经开始入库,还有出库任务,删除出库任务
@ -418,7 +418,7 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == StaticTaskType.FiveAccessoryIn)//入库任务
{
bool haveOut = taskList.Where(t => t.taskType == StaticTaskType.FiveAccessoryOut).Where(t => t.taskStatus != 6).Any();
bool haveOut = taskList.Where(t => item.taskType == StaticTaskType.FiveAccessoryOut || item.taskType == StaticTaskType.FiveAccessoryStorage || item.taskType == StaticTaskType.FiveAccessoryRemove).Where(t => t.taskStatus != 6).Any();
if (!haveOut && CtuWaitLogic())
{
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == item.currPointId);
@ -455,7 +455,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Update(item);
lock (SystemData.outStockLock)
{
bool hasTask = dbContext.WcsTask.Where(t => t.nextPointId == 11 && t.taskType == StaticTaskType.FiveAccessoryOut).Any();
bool hasTask = dbContext.WcsTask.Where(t => t.nextPointId == 11 && (t.taskType == StaticTaskType.FiveAccessoryOut || t.taskType == StaticTaskType.FiveAccessoryStorage || t.taskType == StaticTaskType.FiveAccessoryRemove) ).Any();
int taskCount = dbContext.WcsTask.Where(t => t.nextPointId == 11 && t.taskType == StaticTaskType.FiveAccessoryIn).Count();
if ((!hasTask && item.ud3 == "1") || (taskCount >= 6))//如果CTU当前任务数量很多取消预执行任务,或者出库的任务都生成了入库任务
{
@ -532,7 +532,7 @@ namespace Khd.Core.Wcs.Wcs
{
_logger.Info("五楼CTU线程完成任务" + item.objid);
Console.WriteLine(DateTime.Now + ":五楼CTU线程完成任务" + item.currPointNo + "," + item.endPointNo);
if (item.taskType == StaticTaskType.FiveAccessoryOut)//出库任务
if (item.taskType == StaticTaskType.FiveAccessoryOut || item.taskType == StaticTaskType.FiveAccessoryStorage || item.taskType == StaticTaskType.FiveAccessoryRemove)//出库任务
{
WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.FirstOrDefault(t => t.taskCode == item.objid.ToString());
if (wmsRawOutstockDetail != null)

@ -43,6 +43,56 @@ namespace Khd.Core.Wcs.Wcs
_logger.Info("二楼AGV上件扫描监听启动成功");
}
/// <summary>
/// 开启线程监听2分钟小包出口光电信号如果小包出口到位信号消失即取托盘完成发送信号通知线体
/// </summary>
/// <param name="timeoutMinutes"></param>
public static void ListenForSignal(int timeoutMinutes = 2)
{
// 创建一个 CancellationTokenSource 来控制超时
var cts = new CancellationTokenSource(TimeSpan.FromMinutes(timeoutMinutes));
Task.Run(async () =>
{
var agvGetPoint = StaticData.BasePlcpointList.First(t => t.id == 53);
var agvGetValue = StaticData.PlcDic[2].Read(agvGetPoint.plcpointAddress);
while (!cts.Token.IsCancellationRequested)
{
// 每隔 1 秒检查一次小包出口光电信号
await Task.Delay(1000, cts.Token);
agvGetValue = StaticData.PlcDic[2].Read(agvGetPoint.plcpointAddress);
if (agvGetValue != null && Convert.ToInt32(agvGetValue) == 0)
{
// 信号消失20s后执行相关操作
Thread.Sleep(1000*20);
// 取托盘确认信号DB4.DBX310.1写true
BasePlcpoint secondOutGetOverPoint = StaticData.BasePlcpointList.First(t => t.id == 71);
StaticData.PlcDic[2].WriteToPoint(secondOutGetOverPoint.plcpointAddress, true, secondOutGetOverPoint.plcpointLength.ToString());
// 清空小包出口RFID
BasePlcpoint rfid2001Point = StaticData.BasePlcpointList.First(t => t.id == 52);
StaticData.PlcDic[2].WriteRFID(rfid2001Point.plcpointAddress, "", 12);
// 满足条件后退出循环
break;
}
}
// 任务被取消或者超时
if (cts.Token.IsCancellationRequested)
{
Console.WriteLine("任务超时或被取消");
}
}).Wait();
}
public void MonitorInLocatorPoint()
{
using var scope = _host.Services.CreateScope();
@ -225,7 +275,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("楼Agv下发任务失败" + item.taskType + result);
_logger.Info("2楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == StaticTaskType.SecondStorageToLift)//库位-提升机
@ -538,8 +588,16 @@ namespace Khd.Core.Wcs.Wcs
{
dbContext.WcsTask.Where(t => t.objid == item.objid).Update(t => new WcsTask() { taskStatus = 4 });
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 4 });
// 开启线程监听2分钟小包出口光电信号如果小包出口到位信号消失即取托盘完成发送信号通知线体
ListenForSignal(2);
}
}
}
else
{
@ -557,13 +615,29 @@ namespace Khd.Core.Wcs.Wcs
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 4 });
}
}
}
else if (item.taskStatus == 5)
{
if (item.taskType == StaticTaskType.SecondLineToSmallPackage)
{
if (true)
// 托盘库叫料信号
var agvPutPoint = StaticData.BasePlcpointList.First(t => t.id == 54);
//2F托盘库产线数据通讯情况
var ConnectStatus2FPoint = StaticData.BasePlcpointList.First(t => t.id == 73);
//2F托盘库入口上料光电
var PalletInIsHas2FPoint = StaticData.BasePlcpointList.First(t => t.id == 74);
var agvPutValue = StaticData.PlcDic[2].Read(agvPutPoint.plcpointAddress);//托盘库叫料信号
var ConnectStatus2F = StaticData.PlcDic[2].Read(ConnectStatus2FPoint.plcpointAddress);//2F托盘库产线数据通讯情况
var PalletInIsHas2F = StaticData.PlcDic[2].Read(PalletInIsHas2FPoint.plcpointAddress);//2F托盘库入口上料光电
if (agvPutValue !=null && ConnectStatus2F != null && PalletInIsHas2F !=null&& Convert.ToInt32(agvPutValue) == 1 && Convert.ToInt32(ConnectStatus2F) == 1 && Convert.ToInt32(PalletInIsHas2F) == 0)
{
// 托盘库叫料信号,并且通讯正常,并且小包入口无料 ,才可放托盘
var agvTask = new RequestAGVTaskDto
{
reqCode = StaticData.SnowId.NextId().ToString(),
@ -579,6 +653,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
}
else if (item.taskStatus == 7)
{
@ -588,7 +663,7 @@ namespace Khd.Core.Wcs.Wcs
lineEquip.equipStatus = 0;
dbContext.Update(lineEquip);
}
if (item.taskType == StaticTaskType.SecondSmallPackageToStorage)
if (item.taskType == StaticTaskType.SecondSmallPackageToStorage) //小包出口到库位
{
//WmsProductInstock? wmsProductInstock = dbContext.WmsProductInstock.FirstOrDefault(t => t.productInstockId == item.orderId);
//if (wmsProductInstock != null)
@ -607,6 +682,7 @@ namespace Khd.Core.Wcs.Wcs
wmsBaseLocation.containerCode = item.containerNo;
WmsProductStock wmsProductStock = new WmsProductStock()
{
productId = mesBasePalletInfo.materialId,
activeFlag = "1",
frozenAmount = 0,
@ -619,7 +695,7 @@ namespace Khd.Core.Wcs.Wcs
occupyAmount = 0,
totalAmount = 1,
palletInfoCode = item.containerNo,
planCode = mesBaseBarcodeInfo.planCode,
planCode = StaticData.SnowId.NextId().ToString(),
planDetailCode = mesBaseBarcodeInfo.planDetailCode,
productBatch = mesBasePalletInfo.materialBarcode,
saleorderCode = mesBaseBarcodeInfo.saleorderCode,
@ -630,6 +706,34 @@ namespace Khd.Core.Wcs.Wcs
warehouseFloor = 2,
warehouseId = wmsBaseLocation.warehouseId
};
#region 插入WmsProductInstock表
WmsProductInstock wmsProductInstock = new WmsProductInstock();
wmsProductInstock.taskCode = StaticData.SnowId.NextId().ToString();
wmsProductInstock.warehouseId = wmsBaseLocation.warehouseId;
wmsProductInstock.warehouseFloor = 2;
wmsProductInstock.locationCode = wmsBaseLocation.locationCode;
wmsProductInstock.productType = "3";
wmsProductInstock.operationType = "3";
wmsProductInstock.planCode = StaticData.SnowId.NextId().ToString();
wmsProductInstock.planDetailCode = mesBaseBarcodeInfo.planDetailCode;
wmsProductInstock.SaleOrderId = mesBaseBarcodeInfo.saleOrderId;
wmsProductInstock.saleorderCode = mesBaseBarcodeInfo.saleorderCode;
wmsProductInstock.instockType = "1";
wmsProductInstock.productId = mesBaseBarcodeInfo.materialId;
wmsProductInstock.productBatch = mesBaseBarcodeInfo.barcodeInfo;
wmsProductInstock.instockAmount = mesBaseBarcodeInfo.amount;
wmsProductInstock.palletInfoCode = mesBaseBarcodeInfo.palletInfoCode;
wmsProductInstock.auditStatus = "1";
wmsProductInstock.executeStatus = "2";
wmsProductInstock.applyBy = "WCS";
wmsProductInstock.applyDate = DateTime.Now;
wmsProductInstock.updateBy = "WCS";
wmsProductInstock.updateDate = DateTime.Now;
wmsProductInstock.beginTime = DateTime.Now;
wmsProductInstock.endTime = DateTime.Now;
dbContext.Add(wmsProductInstock);
#endregion
//wmsProductInstockDetail.executeStatus = "2";
//wmsProductInstock.endTime = DateTime.Now;
//wmsProductInstock.executeStatus = "2";
@ -652,33 +756,47 @@ namespace Khd.Core.Wcs.Wcs
WmsProductOutstock? wmsProductOutstock = dbContext.WmsProductOutstock.FirstOrDefault(t => t.productOutstockId == item.orderId);
if (wmsProductOutstock != null)
{
WmsProductOutstockDetail? wmsProductOutstockDetail = dbContext.WmsProductOutstockDetail.FirstOrDefault(t => t.productOutstockId == wmsProductOutstock.productOutstockId);
if (wmsProductOutstockDetail != null)
var wmsBaseLocation = dbContext.WmsBaseLocation.Where(t => t.locationId == item.currPointId).First();
WmsProductStock wmsProductStock = dbContext.WmsProductStock.First(t => t.locationCode == wmsBaseLocation.locationCode);
wmsProductOutstock.outstockQty++;
if (wmsProductOutstock.applyQty <= wmsProductOutstock.outstockQty)
{
var wmsBaseLocation = dbContext.WmsBaseLocation.Where(t => t.locationId == item.currPointId).First();
WmsProductStock wmsProductStock = dbContext.WmsProductStock.First(t => t.locationCode == wmsBaseLocation.locationCode);
wmsProductOutstock.outstockQty++;
if (wmsProductOutstock.applyQty <= wmsProductOutstock.outstockQty)
{
wmsProductOutstock.endTime = DateTime.Now;
wmsProductOutstock.executeStatus = "2";
}
wmsProductOutstockDetail.executeStatus = "2";
wmsProductOutstockDetail.endTime = DateTime.Now;
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.containerCode = null;
item.nextPointId = 2;
item.taskStatus = 8;
SystemData.UnLockOutLocation(wmsBaseLocation, dbContext);
dbContext.Remove(wmsProductStock);
dbContext.Update(wmsBaseLocation);
dbContext.Update(wmsProductOutstockDetail);
dbContext.Update(wmsProductOutstock);
dbContext.Update(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
wmsProductOutstock.endTime = DateTime.Now;
wmsProductOutstock.executeStatus = "2";
}
WmsProductOutstockDetail newWmsProductOutstockDetail = new WmsProductOutstockDetail();
newWmsProductOutstockDetail.productOutstockId = wmsProductOutstock.productOutstockId;
newWmsProductOutstockDetail.warehouseId = wmsProductOutstock.warehouseId;
newWmsProductOutstockDetail.locationCode = wmsBaseLocation.locationCode;
newWmsProductOutstockDetail.productBarcode = wmsProductStock.productBatch;
newWmsProductOutstockDetail.productId = wmsProductStock.productId;
newWmsProductOutstockDetail.planAmount = wmsProductOutstock.applyQty;
newWmsProductOutstockDetail.outstockAmount = wmsProductOutstock.outstockQty;
newWmsProductOutstockDetail.executeStatus = "2";
newWmsProductOutstockDetail.updateBy = "WCS";
newWmsProductOutstockDetail.updateDate = DateTime.Now;
newWmsProductOutstockDetail.beginTime = DateTime.Now;
newWmsProductOutstockDetail.endTime = DateTime.Now;
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.containerCode = null;
item.nextPointId = 2;
item.taskStatus = 8;
SystemData.UnLockOutLocation(wmsBaseLocation, dbContext);
dbContext.Remove(wmsProductStock);
dbContext.Update(wmsBaseLocation);
dbContext.Add(newWmsProductOutstockDetail);
dbContext.Update(wmsProductOutstock);
dbContext.Update(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
}
}
else if (item.taskType == StaticTaskType.SecondLiftToTransit)//空托盘入周转位
@ -709,6 +827,12 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == StaticTaskType.SecondLineToSmallPackage)//输送线到小包入口
{
// 小包入口放料完成确认信号
//放托盘确认信号DB4.DBX310.0写true
BasePlcpoint SecondInPutOverPoint = StaticData.BasePlcpointList.First(t => t.id == 72);
StaticData.PlcDic[2].WriteToPoint(SecondInPutOverPoint.plcpointAddress, true, SecondInPutOverPoint.plcpointLength.ToString());
BaseEquip startEquip = dbContext.BaseEquip.First(t => t.objid == item.currPointId);
startEquip.equipStatus = 0;
dbContext.Update(startEquip);
@ -763,6 +887,50 @@ namespace Khd.Core.Wcs.Wcs
});
dbContext.Remove(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
#region 插入移库记录
WmsMove wmsMove = new WmsMove();
wmsMove.MoveId = StaticData.SnowId.NextId();
wmsMove.TaskCode = StaticData.SnowId.NextId().ToString();
wmsMove.WarehouseId = wmsBaseLocation.warehouseId;
wmsMove.OriLocationCode = wmsBaseLocation.locationCode;
wmsMove.TargetLocationCode = toLocation.locationCode;
wmsMove.InstockBatch = wmsProductStock.productBatch;
wmsMove.MaterialId = wmsProductStock.productId;
wmsMove.PlanAmount = 1;
wmsMove.RealOutstockAmount = 1;
wmsMove.RealInstockAmount = 1;
wmsMove.OperationType = "3";
wmsMove.MoveWay = "2";
wmsMove.MoveType = "1";
wmsMove.AuditStatus = "1";
wmsMove.ExecuteStatus = "2";
wmsMove.UpdateBy = "WCS";
wmsMove.UpdateDate = DateTime.Now;
wmsMove.BeginTime = DateTime.Now;
wmsMove.EndTime = DateTime.Now;
WmsMoveDetail wmsMoveDetail = new WmsMoveDetail();
wmsMoveDetail.MoveId = wmsMove.MoveId;
wmsMoveDetail.MaterialBarcode = wmsMove.InstockBatch;
wmsMoveDetail.InstockBatch = wmsMove.InstockBatch;
wmsMoveDetail.MaterialId = (long)wmsProductStock.productId;
wmsMoveDetail.LocationCode = toLocation.locationCode;
wmsMoveDetail.PlanAmount = 1;
wmsMoveDetail.RealInstockAmount = 1;
wmsMoveDetail.RealAmount = 1;
wmsMoveDetail.ExecuteStatus = "2";
wmsMoveDetail.ExecuteTime = DateTime.Now;
wmsMoveDetail.ExecuteEndTime = DateTime.Now;
wmsMoveDetail.ExecutePerson = "WCS";
wmsMoveDetail.UpdateBy = "WCS";
wmsMoveDetail.UpdateDate = DateTime.Now;
dbContext.WmsMove.Add(wmsMove);
dbContext.WmsMoveDetail.Add(wmsMoveDetail);
#endregion
transaction.Commit();
dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);

@ -45,7 +45,13 @@ namespace Khd.Core.Wcs.Wcs
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var rfidPoint = StaticData.BasePlcpointList.First(t => t.id == 52);
var agvGetPoint = StaticData.BasePlcpointList.First(t => t.id == 53);
// 托盘库叫料信号
var agvPutPoint = StaticData.BasePlcpointList.First(t => t.id == 54);
//2F托盘库产线数据通讯情况
var ConnectStatus2FPoint = StaticData.BasePlcpointList.First(t => t.id == 73);
//2F托盘库入口上料光电
var PalletInIsHas2FPoint = StaticData.BasePlcpointList.First(t => t.id == 74);
BaseEquip agvEquip = StaticData.BaseEquip.First(t => t.objid == 8);
BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == 36);
List<string> canNotIn = new List<string>();
@ -54,13 +60,18 @@ namespace Khd.Core.Wcs.Wcs
try
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var agvPutValue = StaticData.PlcDic[2].Read(agvPutPoint.plcpointAddress);//小包入口叫料
var agvPutValue = StaticData.PlcDic[2].Read(agvPutPoint.plcpointAddress);//托盘库叫料信号
var ConnectStatus2F = StaticData.PlcDic[2].Read(ConnectStatus2FPoint.plcpointAddress);//2F托盘库产线数据通讯情况
var PalletInIsHas2F = StaticData.PlcDic[2].Read(PalletInIsHas2FPoint.plcpointAddress);//2F托盘库入口上料光电
var agvGetValue = StaticData.PlcDic[2].Read(agvGetPoint.plcpointAddress);//小包出口的到位
var rfidValue = StaticData.PlcDic[2].ReadRFID(rfidPoint.plcpointAddress);//小包出口的RFID
if (agvGetValue != null && agvPutValue != null && rfidValue != null)//读Plc
var rfidValue = StaticData.PlcDic[2].ReadRFID(rfidPoint.plcpointAddress, 15);//小包出口的RFID
if (agvGetValue != null && agvPutValue != null && rfidValue != null && ConnectStatus2F != null && PalletInIsHas2F != null)//读Plc
{
if (Convert.ToInt32(agvPutValue) == 0)//小包入口叫料
// 托盘库叫料信号,并且通讯正常,并且小包入口无料才可叫料
if (Convert.ToInt32(agvPutValue) == 1 && Convert.ToInt32(ConnectStatus2F) == 1 && Convert.ToInt32(PalletInIsHas2F) == 0)//小包入口叫料
{
bool canCreate = dbContext.WcsTask.Where(t => t.nextPointId == 8 || t.endPointId == endEquip.objid).Any();//有没有生成任务
//36 是小包入口的设备信息8是二楼Agv设备
if (!canCreate)//没有任务
@ -218,9 +229,10 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
//todo:没有空托盘
Console.WriteLine(DateTime.Now + ":二楼码垛输送线没有空托盘");
_logger.Info("二楼码垛输送线没有空托盘");
//todo:没有空托盘超过十次预警报警
Console.WriteLine(DateTime.Now + ":二楼码垛输送线没有空托盘,叫托盘失败!");
_logger.Info("二楼码垛输送线没有空托盘,叫托盘失败!");
Thread.Sleep(1000 * 5);
}
}
}
@ -228,71 +240,101 @@ namespace Khd.Core.Wcs.Wcs
}
if (Convert.ToInt32(agvGetValue) == 1 && !string.IsNullOrEmpty(rfidValue))//小包出口成品入口
{
lock (SystemData.SecondTaskLock)
bool canCreate = dbContext.WcsTask.Where(t => t.nextPointId == 8).Any();//有没有生成任务
if (!canCreate)
{
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == rfidValue);
if (mesBasePalletInfo != null)
lock (SystemData.SecondTaskLock)
{
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
if (mesBaseBarcodeInfo != null)
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == rfidValue);
if (mesBasePalletInfo != null)
{
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.warehouseFloor == FloorNo)
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.locationStatus == "1")
.Where(t => t.warehouseId == 231)
.ToList();//所有可用库位
var wmsProductStocks = dbContext.WmsProductStock
.Where(t => t.warehouseId == 231)
.ToList();//仓库的库存
WmsBaseLocation? wmsBaseLocation = null;
if (wmsBaseLocations.Count > 0)
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
if (mesBaseBarcodeInfo != null)
{
List<string> containerCodes = wmsBaseLocations
.Where(t => t.locDeep == 1)
.Select(t => t.containerCode).ToList();//深库位的有托盘
containerCodes.RemoveAll(t => string.IsNullOrEmpty(t));
// 目标库位
WmsBaseLocation? wmsBaseLocation = null;
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.warehouseFloor == FloorNo)
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.locationStatus == "1")
.Where(t => t.warehouseId == 231)
.ToList();//所有未锁定的库位
List<WmsProductStock> productStocks = wmsProductStocks.Where(t => t.productId == mesBaseBarcodeInfo.materialId)
//深库位有库存的库位
List<string> DeepContainerCodes = wmsBaseLocations
.Where(t => t.locDeep == 1)
.Where(t => !string.IsNullOrEmpty(t.containerCode))
.Select(t => t.containerCode).ToList();
//相同型号及销售订单的深库位库存
List<WmsProductStock> productStocks = dbContext.WmsProductStock.Where(t => t.productId == mesBaseBarcodeInfo.materialId)
.Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)
.Where(t => t.palletInfoCode != null)
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();
.Where(t => t.warehouseId== 231)
.Where(t => DeepContainerCodes.Contains(t.palletInfoCode)).ToList();
var bill = from a in productStocks
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 b.locDeep == 2//浅库位
&& b.locRow == (a.b.locRow % 2 == 0 ? a.b.locRow - 1 : a.b.locRow + 1)
//如果是4则找3如果是1则找2
&& a.b.locColumn == b.locColumn//列数相同
&& string.IsNullOrEmpty(b.containerCode)
select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
wmsBaseLocation ??= outBill.Where(t => !canNotIn.Contains(t.b.locationCode)).FirstOrDefault()?.b;//先找相同物料的外侧库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
if (wmsBaseLocation != null)//如果找到库位,生成入库任务
{
if (wmsBaseLocation.locDeep == 1)
if(productStocks.Count > 0)
{ //优先找同销售订单的有库存的深库位对应的浅库位
foreach(var productStock in productStocks)
{
var hasLocation = wmsBaseLocations
.Where(t => t.locRow == (wmsBaseLocation.locRow % 2 == 1 ? (wmsBaseLocation.locRow + 1) : (wmsBaseLocation.locRow - 1)))
.Where(t => t.locColumn == wmsBaseLocation.locColumn)
.Where(t => !string.IsNullOrEmpty(t.containerCode) || t.locationStatus != "1")
.Any();
if (hasLocation)
// 深库位库存对用的Location信息
var deepStockLocation = wmsBaseLocations.Where(t => t.containerCode == productStock.palletInfoCode).FirstOrDefault();
wmsBaseLocation = wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode) && t.locationStatus=="1")
.Where(t=> t.locDeep == 2 && t.locColumn ==deepStockLocation.locColumn)
.Where(t=> t.locRow == (deepStockLocation.locRow % 2 == 0 ? (deepStockLocation.locRow - 1) :(deepStockLocation.locRow + 1)) )
.FirstOrDefault();
if (wmsBaseLocation != null)
{
canNotIn.Add(wmsBaseLocation.locationCode);
Console.WriteLine(DateTime.Now + $":目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库");
_logger.Info($"目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库");
continue;
break;
}
}
}
if(wmsBaseLocation == null)
{ // 找深库位有库存的库位对应的浅库位
var stockLocations = wmsBaseLocations.Where(x => !string.IsNullOrEmpty(x.containerCode) && x.locDeep==1).ToList();
foreach (var item in stockLocations)
{
wmsBaseLocation = wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode) && t.locationStatus == "1")
.Where(t => t.locDeep == 2 && t.locColumn == item.locColumn)
.Where(t => t.locRow == (item.locRow % 2 == 0 ? (item.locRow - 1) : (item.locRow + 1)))
.FirstOrDefault();
if (wmsBaseLocation != null)
{
break;
}
}
}
if(wmsBaseLocation == null)
{ // 在所有符合条件的库位里,找一个库位,优先深库位,但是如果是深库位,需要判断浅库位状态是否正常
var searchLocations = wmsBaseLocations.Where(x => string.IsNullOrEmpty(x.containerCode) && x.locationStatus == "1").OrderBy(x=>x.locDeep).ToList();
foreach (var item in searchLocations)
{
if(item.locDeep == 1)
{
//浅库位能否使用
var shallowLocation = wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode) && t.locationStatus == "1")
.Where(t => t.locDeep == 2 && t.locColumn == item.locColumn)
.Where(t => t.locRow == (item.locRow % 2 == 0 ? (item.locRow - 1) : (item.locRow + 1)))
.FirstOrDefault();
if (shallowLocation != null)
{
wmsBaseLocation = item;
break;
}
}
else
{
wmsBaseLocation = item;
break;
}
}
}
if (wmsBaseLocation != null)//如果找到库位,生成入库任务
{
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == 37);
var wcsTask = new WcsTask()
{
@ -325,12 +367,17 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
//报警
Console.WriteLine(DateTime.Now + ":2楼调度入库任务,未找到库位");
_logger.Info("2楼调度入库任务,未找到库位");
// TODO: 没有找到库位,添加报警处理
Thread.Sleep(1000 * 5);
}
}
}
}
}
}
}
}

@ -738,6 +738,17 @@ namespace Khd.Core.Wcs.Wcs
var Ylc = basePlcs.First(t => t.Name.Contains('Y'));
StaticData.PlcDic[2].WriteToPoint(XPlc.Address, cardStatus.PosX.ToString(), XPlc.type);
StaticData.PlcDic[2].WriteToPoint(Ylc.Address, cardStatus.PosY.ToString(), Ylc.type);
#region 经过走廊区域报警
if (int.Parse(cardStatus.PosX) >= 53040 && int.Parse(cardStatus.PosX) <= 58090 && (int.Parse(cardStatus.PosY) >= 53520 && int.Parse(cardStatus.PosY) <= 64590))
{
Console.WriteLine("=======>3F走廊区域预警");
}
else
{
// Console.WriteLine("3F走廊区域正常");
}
#endregion
}
}
catch
@ -777,7 +788,22 @@ namespace Khd.Core.Wcs.Wcs
var Ylc = basePlcs.First(t => t.Name.Contains('Y'));
StaticData.PlcDic[2].WriteToPoint(XPlc.Address, cardStatus.PosX.ToString(), XPlc.type);
StaticData.PlcDic[2].WriteToPoint(Ylc.Address, cardStatus.PosY.ToString(), Ylc.type);
#region 经过走廊区域报警
if (int.Parse(cardStatus.PosX) >= 119000 && int.Parse(cardStatus.PosX) <= 122800 && (int.Parse(cardStatus.PosY) >= 124100 && int.Parse(cardStatus.PosY) <= 134435))
{
Console.WriteLine("=======>2F走廊区域预警");
}
else
{
// Console.WriteLine("2F走廊区域正常");
}
#endregion
}
}
catch
{

@ -599,6 +599,50 @@ namespace Khd.Core.Wcs.Wcs
});
dbContext.Remove(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 6 });
#region 插入移库记录
WmsMove wmsMove = new WmsMove();
wmsMove.MoveId = StaticData.SnowId.NextId();
wmsMove.TaskCode = StaticData.SnowId.NextId().ToString();
wmsMove.WarehouseId = wmsBaseLocation.warehouseId;
wmsMove.OriLocationCode = wmsBaseLocation.locationCode;
wmsMove.TargetLocationCode = toLocation.locationCode;
wmsMove.InstockBatch = wmsRawStock.instockBatch;
wmsMove.MaterialId = wmsRawStock.materialId;
wmsMove.PlanAmount = 1;
wmsMove.RealOutstockAmount = 1;
wmsMove.RealInstockAmount = 1;
wmsMove.OperationType = "3";
wmsMove.MoveWay = "2";
wmsMove.MoveType = "1";
wmsMove.AuditStatus = "1";
wmsMove.ExecuteStatus = "2";
wmsMove.UpdateBy = "WCS";
wmsMove.UpdateDate = DateTime.Now;
wmsMove.BeginTime = DateTime.Now;
wmsMove.EndTime = DateTime.Now;
WmsMoveDetail wmsMoveDetail = new WmsMoveDetail();
wmsMoveDetail.MoveId = wmsMove.MoveId;
wmsMoveDetail.MaterialBarcode = wmsMove.InstockBatch;
wmsMoveDetail.InstockBatch = wmsMove.InstockBatch;
wmsMoveDetail.MaterialId = (long)wmsRawStock.materialId;
wmsMoveDetail.LocationCode = toLocation.locationCode;
wmsMoveDetail.PlanAmount = 1;
wmsMoveDetail.RealInstockAmount = 1;
wmsMoveDetail.RealAmount = 1;
wmsMoveDetail.ExecuteStatus = "2";
wmsMoveDetail.ExecuteTime = DateTime.Now;
wmsMoveDetail.ExecuteEndTime = DateTime.Now;
wmsMoveDetail.ExecutePerson = "WCS";
wmsMoveDetail.UpdateBy = "WCS";
wmsMoveDetail.UpdateDate = DateTime.Now;
dbContext.WmsMove.Add(wmsMove);
dbContext.WmsMoveDetail.Add(wmsMoveDetail);
#endregion
dbContext.SaveChanges();
transaction.Commit();
}
@ -654,13 +698,20 @@ namespace Khd.Core.Wcs.Wcs
};
WmsRawInstock wmsRawInstock = new WmsRawInstock()
{
taskCode = item.taskCode,
materialBarCode = mesBaseBarcodeInfo.barcodeInfo,
materialBatchCode = mesBaseBarcodeInfo.batchCode,
applyBy = "wcs",
applyDate = System.DateTime.Now,
purchaseOrderId = mesBaseBarcodeInfo.PurchaseOrderId,
beginTime = System.DateTime.Now,
endTime = DateTime.Now,
locationCode = wmsBaseLocation.locationCode,
executeStatus = "2",
instockAmount = 1,
instockType = item.fromFloorNo == 1 ? "1" : "3",
materialBatchCode = mesBaseBarcodeInfo.barcodeInfo,
materialId = mesBaseBarcodeInfo.materialId,
operationType = "3",
palletInfoCode = mesBaseBarcodeInfo.palletInfoCode,
@ -705,42 +756,63 @@ namespace Khd.Core.Wcs.Wcs
wmsBaseLocation.updateBy = "WCS";
WmsRawOutstock? wmsRawOutstock = dbContext.WmsRawOutstock.FirstOrDefault(t => t.rawOutstockId == item.orderId);
if (wmsRawOutstock != null)
WmsRawStock? wmsRawStock = dbContext.WmsRawStock.Where(t => t.locationCode == item.currPointNo).FirstOrDefault();
if (wmsRawOutstock != null && wmsRawStock != null)
{
WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.FirstOrDefault(t => t.rawOutstockId == wmsRawOutstock.rawOutstockId && t.executeStatus == "1");
if (wmsRawOutstockDetail != null)
wmsRawOutstock.realOutstockAmount += 1;
if (wmsRawOutstock.realOutstockAmount >= wmsRawOutstock.outstockAmount)
{
wmsRawOutstockDetail.executeStatus = "2";
wmsRawOutstockDetail.outstockTime = DateTime.Now;
WmsRawStock? wmsRawStock = dbContext.WmsRawStock.Where(t => t.locationCode == item.currPointNo).FirstOrDefault();
if (wmsRawStock != null)
{
BaseEquip endEquip = dbContext.BaseEquip.First(t => t.objid == 31);
endEquip.emptyCount = 1;
wmsRawOutstock.realOutstockAmount += 1;
if (wmsRawOutstock.realOutstockAmount >= wmsRawOutstock.outstockAmount)
{
wmsRawOutstock.endTime = DateTime.Now;
wmsRawOutstock.executeStatus = "2";
}
SystemData.UnLockOutLocation(wmsBaseLocation, dbContext);
dbContext.Update(endEquip);
dbContext.Update(wmsRawOutstock);
dbContext.Remove(wmsRawStock);
dbContext.Update(wmsBaseLocation);
WcsTask wcsTask = CoreMapper.Map<WcsTask>(item);
wcsTask.objid = StaticData.SnowId.NextId();
wcsTask.taskStatus = 0;
wcsTask.useFlag = 0;
wcsTask.taskType = StaticTaskType.ThirdFlipToBin;
wcsTask.createBy = "WCS";
wcsTask.createTime = DateTime.Now;
dbContext.Remove(item);
dbContext.Add(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
dbContext.SaveChanges();
}
wmsRawOutstock.endTime = DateTime.Now;
wmsRawOutstock.executeStatus = "2";
}
WmsRawOutstockDetail newWmsRawOutstockDetail = new WmsRawOutstockDetail();
newWmsRawOutstockDetail.rawOutstockId = wmsRawOutstock.rawOutstockId;
newWmsRawOutstockDetail.taskCode = wmsRawOutstock.taskCode;
newWmsRawOutstockDetail.warehouseId = wmsRawOutstock.warehouseId;
newWmsRawOutstockDetail.locationCode = wmsRawStock.locationCode;
newWmsRawOutstockDetail.materialBarcode = wmsRawStock.instockBatch;
newWmsRawOutstockDetail.materialId = wmsRawStock.materialId;
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.barcodeInfo == wmsRawStock.instockBatch).FirstOrDefault();
if (mesBaseBarcodeInfo != null)
{
newWmsRawOutstockDetail.instockBatch = mesBaseBarcodeInfo.batchCode;
newWmsRawOutstockDetail.materialProductionDate = mesBaseBarcodeInfo.productionDate;
}
newWmsRawOutstockDetail.planAmount = wmsRawOutstock.outstockAmount;
newWmsRawOutstockDetail.outstockAmount = wmsRawOutstock.realOutstockAmount;
newWmsRawOutstockDetail.executeStatus = "2";
newWmsRawOutstockDetail.outstockPerson = wmsRawOutstock.applyBy;
newWmsRawOutstockDetail.outstockTime = DateTime.Now;
newWmsRawOutstockDetail.outstockWay = "2";
newWmsRawOutstockDetail.createBy = "WCS";
newWmsRawOutstockDetail.createDate = DateTime.Now;
newWmsRawOutstockDetail.stackAmount = 1;
BaseEquip endEquip = dbContext.BaseEquip.First(t => t.objid == 31);
endEquip.emptyCount = 1;
SystemData.UnLockOutLocation(wmsBaseLocation, dbContext);
dbContext.Update(endEquip);
dbContext.Update(wmsRawOutstock);
dbContext.Remove(wmsRawStock);
dbContext.Add(newWmsRawOutstockDetail);
dbContext.Update(wmsBaseLocation);
WcsTask wcsTask = CoreMapper.Map<WcsTask>(item);
wcsTask.objid = StaticData.SnowId.NextId();
wcsTask.taskStatus = 0;
wcsTask.useFlag = 0;
wcsTask.taskType = StaticTaskType.ThirdFlipToBin;
wcsTask.createBy = "WCS";
wcsTask.createTime = DateTime.Now;
dbContext.Remove(item);
dbContext.Add(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
dbContext.SaveChanges();
}
}
else if (item.taskType == StaticTaskType.ThirdFlipToBin)//翻转机就到收集架

@ -76,57 +76,90 @@ namespace Khd.Core.Wcs.Wcs
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
if (mesBaseBarcodeInfo != null)
{
var wmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseFloor == FloorNo)
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.locationStatus == "1")
.OrderByDescending(t => t.locRow)
.ThenByDescending(t => t.locColumn)
.ToList();
// 目标库位
WmsBaseLocation? wmsBaseLocation = null;
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.warehouseFloor == FloorNo)
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.locationStatus == "1")
.Where(t => t.warehouseId == 311)
.ToList();//所有未锁定的库位
List<string> containerCodes = wmsBaseLocations.Where(t => t.locDeep == 1).Select(t => t.containerCode).ToList();//深库位的托盘
containerCodes.RemoveAll(t => string.IsNullOrEmpty(t));
//深库位有库存的库位
List<string> DeepContainerCodes = wmsBaseLocations
.Where(t => t.locDeep == 1)
.Where(t => !string.IsNullOrEmpty(t.containerCode))
.Select(t => t.containerCode).ToList();
//相同型号及销售订单的深库位库存
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => t.materialId == mesBaseBarcodeInfo.materialId)
.Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)
.Where(t => t.palletInfoCode != null)
.Where(t => t.warehouseId == 311)
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();
var bill = from a in wmsRawStocks
join b in wmsBaseLocations.Where(t => t.locDeep == 1 && !string.IsNullOrEmpty(t.containerCode)) on a.palletInfoCode equals b.containerCode
select new { b };//等于当前任务的物料的托盘的库位信息
var outBill = from b in wmsBaseLocations
from a in bill
where b.locDeep == 2
&& b.locRow == (a.b.locRow % 2 == 0 ? a.b.locRow - 1 : a.b.locRow + 1)
&& a.b.locColumn == b.locColumn
&& b.locationStatus == "1"
&& string.IsNullOrEmpty(b.containerCode)
select new { b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
WmsBaseLocation? wmsBaseLocation = outBill.Where(t => !canNotIn.Contains(t.b.locationCode)).FirstOrDefault()?.b;//先找相同物料的外侧库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null)
{
if (wmsBaseLocation.locDeep == 1)
.Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)
.Where(t => DeepContainerCodes.Contains(t.palletInfoCode))
.Where(t => t.warehouseId == 311).ToList();
if (wmsRawStocks.Count > 0)
{ //优先找同销售订单的有库存的深库位对应的浅库位
foreach (var wmsRawStock in wmsRawStocks)
{
bool hasLocation = wmsBaseLocations
.Where(t => t.locRow == (wmsBaseLocation.locRow % 2 == 1 ? (wmsBaseLocation.locRow + 1) : (wmsBaseLocation.locRow - 1)))
.Where(t => t.locColumn == wmsBaseLocation.locColumn)
.Where(t => !string.IsNullOrEmpty(t.containerCode) || t.locationStatus != "1")
.Any();
if (hasLocation)
// 深库位库存对用的Location信息
var deepStockLocation = wmsBaseLocations.Where(t => t.containerCode == wmsRawStock.palletInfoCode).FirstOrDefault();
wmsBaseLocation = wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode) && t.locationStatus == "1")
.Where(t => t.locDeep == 2 && t.locColumn == deepStockLocation.locColumn)
.Where(t => t.locRow == (deepStockLocation.locRow % 2 == 0 ? (deepStockLocation.locRow - 1) : (deepStockLocation.locRow + 1)))
.FirstOrDefault();
if (wmsBaseLocation != null)
{
canNotIn.Add(wmsBaseLocation.locationCode);
Console.WriteLine(DateTime.Now + $":目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库");
_logger.Info($"目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库");
continue;
break;
}
}
}
if (wmsBaseLocation == null)
{ // 找深库位有库存的库位对应的浅库位
var stockLocations = wmsBaseLocations.Where(x => !string.IsNullOrEmpty(x.containerCode) && x.locDeep == 1).ToList();
foreach (var item in stockLocations)
{
wmsBaseLocation = wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode) && t.locationStatus == "1")
.Where(t => t.locDeep == 2 && t.locColumn == item.locColumn)
.Where(t => t.locRow == (item.locRow % 2 == 0 ? (item.locRow - 1) : (item.locRow + 1)))
.FirstOrDefault();
if (wmsBaseLocation != null)
{
break;
}
}
}
if (wmsBaseLocation == null)
{ // 在所有符合条件的库位里,找一个库位,优先深库位,但是如果是深库位,需要判断浅库位状态是否正常
var searchLocations = wmsBaseLocations.Where(x => string.IsNullOrEmpty(x.containerCode) && x.locationStatus == "1").OrderBy(x => x.locDeep).ToList();
foreach (var item in searchLocations)
{
if (item.locDeep == 1)
{
//浅库位能否使用
var shallowLocation = wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode) && t.locationStatus == "1")
.Where(t => t.locDeep == 2 && t.locColumn == item.locColumn)
.Where(t => t.locRow == (item.locRow % 2 == 0 ? (item.locRow - 1) : (item.locRow + 1)))
.FirstOrDefault();
if (shallowLocation != null)
{
wmsBaseLocation = item;
break;
}
}
else
{
wmsBaseLocation = item;
break;
}
}
}
if ( wmsBaseLocation != null)
{
dbContext.Remove(wcsTask);
WcsTask newTask = CoreMapper.Map<WcsTask>(wcsTask);
newTask.objid = StaticData.SnowId.NextId();
@ -155,6 +188,9 @@ namespace Khd.Core.Wcs.Wcs
{
Console.WriteLine(DateTime.Now + ":三楼楼接驳位调度入库任务,未找到库位");
_logger.Info("三楼接驳位调度入库任务,未找到库位");
// TODO: 没有找到库位,添加报警处理
Thread.Sleep(1000 * 5);
}
}
}

@ -15,7 +15,12 @@
Height="1080"
>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--<hc:ThemeResources/>
<hc:Theme/>-->
@ -362,6 +367,51 @@
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="FontSize" Value="14"></Setter>
</Style>
<DataTemplate x:Key="LocationTemplate">
<Button Content="{Binding}" Click="LocationButton_Click" Height="50" Margin="0 0 2 2">
<Button.Style>
<Style TargetType="Button">
<!--有库存绿色#75F76D无库存但是有空料箱#D78E28无库存无料箱#4789AE库位禁用有个小红点-->
<Setter Property="Background" Value="#75F76D"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Status}" Value="OutOfStock">
<Setter Property="Background" Value="#4789AE"/>
</DataTrigger>
<DataTrigger Binding="{Binding Status}" Value="EmptyInStock">
<Setter Property="Background" Value="#D78E28"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<Button.ContentTemplate>
<DataTemplate>
<Grid>
<!-- 主内容 -->
<TextBlock Text="{Binding Code}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontSize="20"
RenderTransformOrigin="0.5, 0.5">
<TextBlock.RenderTransform>
<RotateTransform Angle="90"/>
</TextBlock.RenderTransform>
</TextBlock>
<!-- 圆点 -->
<Ellipse Width="7" Height="7"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Margin="0,0,0,0"
Fill="Red" Visibility="{Binding isFreeze}"/>
</Grid>
</DataTemplate>
</Button.ContentTemplate>
</Button>
</DataTemplate>
</ResourceDictionary>
</Window.Resources>
@ -390,7 +440,7 @@
<Grid Width="1880" Height="1080">
<TabControl x:Name="TabControl" Background="Transparent" BorderThickness="0" HorizontalAlignment="Center" VerticalContentAlignment="Center" SelectionChanged="TabControl_SelectionChanged" TabStripPlacement="Left" Width="1890" Margin="-10,0,0,0">
<TabItem Visibility="Collapsed" x:Name="FirstItem"></TabItem>
<TabItem x:Name="TaskManager" Header="任务管理" Style="{StaticResource DefaultItem}" Background="#213269" Foreground="White" FontSize="25" Width="160" Height="100" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="2,0,0,0" >
<TabItem x:Name="TaskManager" Header="任务管理" Style="{StaticResource DefaultItem}" Background="#213269" Foreground="White" FontSize="25" Width="160" Height="80" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="2,0,0,0" >
<StackPanel
x:Name="essentialData"
Orientation="Vertical"
@ -958,7 +1008,7 @@
<Label Content="Label"/>
</StackPanel>
</TabItem>
<TabItem x:Name="LocationManager" Header="库存信息" Background="#213269" Style="{StaticResource DefaultItem}" Foreground="White" FontSize="25" Width="160" Height="100" VerticalAlignment="Top" HorizontalAlignment="Center" >
<TabItem x:Name="LocationManager" Header="库存信息" Background="#213269" Style="{StaticResource DefaultItem}" Foreground="White" FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignment="Center" >
<StackPanel
x:Name="orderControl"
Canvas.Left="174"
@ -1203,6 +1253,67 @@
</Grid>
</StackPanel>
</TabItem>
<TabItem x:Name="LocationManager11" Header="库位状态" Background="#213269"
Style="{StaticResource DefaultItem}" Foreground="White"
FontSize="25" Width="160" Height="80" VerticalAlignment="Top" HorizontalAlignment="Center">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="9*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="仓库位置:" FontSize="25" VerticalAlignment="Center" Foreground="White" />
<ComboBox x:Name="QueryPositionCombox" Height="50" Width="150" FontSize="25" SelectionChanged="QueryPositionCombox_SelectionChanged">
<ComboBoxItem Content="南侧" Tag="1" />
<ComboBoxItem Content="北侧" Tag="2" />
</ComboBox>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="600 0 0 0">
<Rectangle Width="50" Height="50" Fill="#75F76D" />
<TextBlock Text=" 有库存" FontSize="30"/>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="30 0 0 0">
<Rectangle Width="50" Height="50" Fill="#D78E28" />
<TextBlock Text=" 空料箱在库里" FontSize="30"/>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="30 0 0 0">
<Rectangle Width="50" Height="50" Fill="#4789AE" />
<TextBlock Text=" 空库位" FontSize="30"/>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="30 0 0 0">
<!-- 包含透明正方形和红点的 Canvas -->
<Canvas Width="50" Height="50" VerticalAlignment="Center" HorizontalAlignment="Center">
<!-- 透明的正方形 -->
<Rectangle Width="50" Height="50" Fill="Transparent" Stroke="Black" StrokeThickness="1"/>
<!-- 中间的红点 -->
<Ellipse Width="10" Height="10" Fill="Red"
Canvas.Left="20" Canvas.Top="20" />
</Canvas>
<TextBlock Text=" 库位锁定" FontSize="30"/>
</StackPanel>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<ItemsControl x:Name="LocationsControl" ItemTemplate="{StaticResource LocationTemplate}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="36" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</TabItem>
<!--<TabItem Header="指令管理" Foreground="White" FontSize="25" Width="160" Height="100" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5" >
<StackPanel
x:Name="UpperStart"
@ -1451,7 +1562,7 @@
</StackPanel>
</StackPanel>
</TabItem>-->
<TabItem x:Name="WasterManager" Header="废料区管理" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">
<TabItem x:Name="WasterManager" Header="废料区管理" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="80" Margin="5">
<Grid Height="1100" Width="1700">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@ -1613,7 +1724,7 @@
</Border>
</Grid>
</TabItem>
<TabItem x:Name="CallPersonManager" Header="人工叫料" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">
<TabItem x:Name="CallPersonManager" Header="人工叫料" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="80" Margin="5">
<Grid Height="1100" Width="1700">
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
@ -1816,7 +1927,7 @@
</StackPanel>
</Grid>
</TabItem>
<TabItem Visibility="Collapsed" x:Name="InventoryManager" Header="盘库任务" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">
<TabItem Visibility="Visible" x:Name="InventoryManager" Header="盘库任务" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="80" Margin="5">
<Grid Height="1100" Width="1700">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
@ -1827,6 +1938,7 @@
<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="200" Margin="20,0,0,0" Click="AddInventoryButton_Click"/>
<Button Content="库存盘点" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="150" Margin="20,0,0,0" Click="InventoryTaskButton_Click"/>
<Button Content="一键收料" Grid.Row="7" Grid.ColumnSpan="2" FontSize="25" Height="50" Width="150" Background="#346DFF" Foreground="White" Click="callPlc_Click" HorizontalAlignment="Left" Grid.Column="4" Margin="222,0,0,0"/>
</StackPanel>
<DataGrid
Style="{StaticResource DataGridStyle}"
@ -1869,7 +1981,7 @@
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Width="180*"
Width="130*"
Binding="{Binding LocationAmount}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
@ -1877,7 +1989,7 @@
Header="库位数"
IsReadOnly="True" />
<DataGridTextColumn
Width="180*"
Width="200*"
Binding="{Binding InventoryingAmount}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
@ -1907,7 +2019,7 @@
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="创建时间"
IsReadOnly="True" />
IsReadOnly="True" Visibility="Collapsed" />
<DataGridTextColumn
Width="220*"
Binding="{Binding BeginTime,StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}"
@ -1932,10 +2044,14 @@
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Content="开始盘点" Style="{StaticResource ButtonPrimary}" FontSize="25" Width="125" Height="75" Click="StartInventory" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Content="{Binding StartContent}" Style="{StaticResource ButtonPrimary}" IsEnabled="{Binding StartEnable}" FontSize="15" Width="90" Height="55" Click="StartInventory" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Content="结束盘点" Style="{StaticResource ButtonPrimary}" IsEnabled="{Binding EndEnable}" Margin="5 0 0 0" FontSize="15" Width="90" Height="55" Click="EndInventory" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Content="详情" Style="{StaticResource ButtonPrimary}" Margin="5 0 0 0" FontSize="15" Width="90" Height="55" Click="OpenInventoryDetails" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
@ -1974,7 +2090,7 @@
<hc:Pagination x:Name="Pagination3" Grid.Row="3" 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">
<TabItem x:Name="ScanInManager" Header="扫描入库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="80" 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">
@ -1988,14 +2104,14 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="167*"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="167*"/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="166.667"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="167*"/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="119.048"/>
</Grid.RowDefinitions>
<TextBlock Text="扫描入库" FontSize="50" Grid.ColumnSpan="6" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="扫描料箱号:" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
@ -2014,7 +2130,7 @@
<hc:TextBox x:Name="materialName" IsReadOnly="True" hc:InfoElement.ShowClearButton="True" FontSize="50" Width="900" HorizontalAlignment="Left" VerticalAlignment="Center" Height="100" Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="3"/>
<hc:TextBox x:Name="materialSpec" IsReadOnly="True" hc:InfoElement.ShowClearButton="True" FontSize="50" Width="900" HorizontalAlignment="Left" VerticalAlignment="Center" Height="100" Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="3"/>
<hc:TextBox x:Name="txtInScan" FontSize="50" IsReadOnly="True" Width="900" HorizontalAlignment="Left" VerticalAlignment="Center" Height="100" Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="3" KeyDown="ScanInKeyDown" />
<Button Content="确认入库" Grid.Row="6" Grid.ColumnSpan="6" Width="300" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="InRawBaseLocaltion_Click"/>
<Button Content="确认入库" Grid.Row="6" Grid.ColumnSpan="2" Width="300" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="InRawBaseLocaltion_Click" Grid.Column="2" HorizontalAlignment="Left" Margin="125,0,0,10" VerticalAlignment="Bottom"/>
<Button Content="取消预调度" x:Name="CancelPreScheduling" Grid.Row="6" Grid.ColumnSpan="2" Width="328" Height="100" FontSize="50" Background="#346DFF" Foreground="White" HorizontalAlignment="Left" Grid.Column="4" Margin="222,0,0,0" Click="CancelPreScheduling_Click"/>
<Button Content="一键收料" Grid.Row="7" Grid.ColumnSpan="2" Width="328" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="callPlc_Click" HorizontalAlignment="Left" Grid.Column="4" Margin="222,0,0,0"/>
<TextBlock Grid.Row="7" Text="提示信息:" HorizontalAlignment="Center" Grid.Column="1" Grid.ColumnSpan="1" Width="250" Height="100" FontSize="50" Foreground="White" />
@ -2026,7 +2142,7 @@
</StackPanel>
</TabItem>
<TabItem x:Name="ScanReturnManager" Header="扫描退库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">
<TabItem x:Name="ScanReturnManager" Header="扫描退库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="80" Margin="5">
<StackPanel 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">
@ -2174,7 +2290,7 @@
</StackPanel>
</TabItem>
<TabItem x:Name="ScanOutManager" Header="扫描出库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">
<TabItem x:Name="ScanOutManager" Header="扫描出库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="80" Margin="5">
<StackPanel 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">
@ -2183,7 +2299,7 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
@ -2197,12 +2313,24 @@
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border BorderBrush="White" BorderThickness="2" Grid.ColumnSpan="1" Grid.Column="5" Grid.RowSpan="2" Margin="20 0 0 0">
<Border BorderBrush="White" BorderThickness="2" Grid.ColumnSpan="1" Grid.Column="4" Grid.RowSpan="2" Margin="20 0 0 0">
<StackPanel Orientation="Vertical" >
<TextBlock x:Name="OutOrder" Background="Transparent" Grid.ColumnSpan="2" Grid.RowSpan="2" VerticalAlignment="Top" HorizontalAlignment="Center"/>
<TextBlock x:Name="thisOutEndStation" Background="Transparent" Grid.ColumnSpan="2" Grid.RowSpan="2" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,20,0,0"/>
</StackPanel>
</Border>
<Border BorderBrush="White" BorderThickness="0" Grid.ColumnSpan="1" Grid.Column="6" Grid.RowSpan="2" Margin="20 0 0 0">
<StackPanel Orientation="Vertical" >
<Button x:Name="SelectOutButton" Content="选择出库" Background="#346DFF" Foreground="White" FontSize="50" Margin="20,0,0,0" Height="100" Width="250" Click="SelectOutBtn_Click"/>
<Button Content="继续出库" Background="#346DFF" Foreground="White" FontSize="50" Margin="20,50,0,0" Height="100" Width="250" Click="ContineOutBtn_Click"/>
</StackPanel>
</Border>
<Border BorderBrush="White" BorderThickness="2" Grid.Column="0" Grid.ColumnSpan="6" Grid.Row="6" Grid.RowSpan="2" Margin="20">
@ -2224,7 +2352,7 @@
Width="*"
/>
<DataGridTextColumn
Header="物料描述"
Header="物料规格"
Binding="{Binding materialSpec}"
ElementStyle="{StaticResource dgCell}"
Width="*"
@ -2255,18 +2383,10 @@
Width="*"
ElementStyle="{StaticResource dgCell}"
/>
<!--<DataGridTextColumn
Header="箱体携带数量"
Binding="{Binding thisOutAmount}"
ElementStyle="{StaticResource dgCell}"
Width="3*"
/>-->
<DataGridTemplateColumn
Width="3*"
Width="3*"
CanUserSort="False"
Header="箱携带数量"
Header="料箱携带数量"
IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
@ -2275,8 +2395,6 @@
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
@ -2290,6 +2408,7 @@
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="Auto" />
</Style>
</DataGrid.RowStyle>
<DataGrid.RowHeaderStyle>
@ -2342,8 +2461,7 @@
<Grid>
<hc:TextBox hc:InfoElement.ShowClearButton="True" IsReadOnly="True" x:Name="outMaterialNameTxt" FontSize="50" LostFocus="txtOutBox_TextChanged" Width="700" HorizontalAlignment="Left" VerticalAlignment="Center" Height="80" Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="3"/>
</Grid>
<Button Content="选择出库" Background="#346DFF" Grid.ColumnSpan="6" Grid.Row="1" Foreground="White" FontSize="50" Margin="20,0,0,0" Height="100" Width="250" Click="SelectOutBtn_Click"/>
<Button Content="继续出库" Background="#346DFF" Grid.ColumnSpan="6" Grid.Row="1" Foreground="White" FontSize="50" Margin="20,0,0,0" Height="100" Width="250" Click="ContineOutBtn_Click"/>
</StackPanel>
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Grid.Row="3" Grid.ColumnSpan="6">
<TextBlock Text="物料规格:" Width="280" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="50"/>
@ -2475,7 +2593,7 @@
</StackPanel>
</StackPanel>
</TabItem>
<TabItem x:Name="RemoveManager" Header="辅料移库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="#213269" Foreground="White" Width="160" Height="100" Margin="5">
<TabItem x:Name="RemoveManager" Header="辅料移库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="#213269" Foreground="White" Width="160" Height="80" Margin="5">
<Grid Height="1100" Width="1700">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@ -2485,6 +2603,7 @@
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
@ -2496,14 +2615,14 @@
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="原料箱号:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<hc:TextBox x:Name="rawSourceBox" TextChanged="rawSourceBox_TextChanged" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<hc:TextBox x:Name="rawSourceBox" TextChanged="rawSourceBox_TextChanged" FontSize="40" Width="600" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<Button Click="rawSourceBoxClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="-100,0,0,0" Grid.Column="5" Grid.Row="2">
<Image Source="..\Resources\cancel.png"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="原条码号:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="rawSourceBarCode" FontSize="40" TextChanged="rawSourceBarCode_TextChanged" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<hc:TextBox x:Name="rawSourceBarCode" FontSize="40" TextChanged="rawSourceBarCode_TextChanged" Width="600" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<Button Click="rawSourceBarCodeClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="-100,0,0,0" Grid.Column="5" Grid.Row="2">
<Image Source="..\Resources\cancel.png"/>
</Button>
@ -2511,7 +2630,7 @@
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="移库料箱:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeSourceBox" FontSize="40" TextChanged="removeSourceBox_TextChanged" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<hc:TextBox x:Name="removeSourceBox" FontSize="40" TextChanged="removeSourceBox_TextChanged" Width="600" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<Button Click="removeSourceBoxClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="-100,0,0,0" Grid.Column="5" Grid.Row="2">
<Image Source="..\Resources\cancel.png"/>
</Button>
@ -2520,7 +2639,7 @@
<StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="移库条码:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeSourceBarCode" FontSize="40" TextChanged="removeSourceBarCode_TextChanged" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<hc:TextBox x:Name="removeSourceBarCode" FontSize="40" TextChanged="removeSourceBarCode_TextChanged" Width="600" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<Button Click="removeSourceBarCodeClear_Click" HorizontalAlignment="Right" Height="100" Panel.ZIndex="1" Width="100" Margin="-100,0,0,0" Grid.Column="5" Grid.Row="2">
<Image Source="..\Resources\cancel.png"/>
</Button>
@ -2528,40 +2647,45 @@
<StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="物料名称:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="rawSourceMaterialName" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<hc:TextBox x:Name="rawSourceMaterialName" FontSize="40" Width="600" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="物料规格:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="rawSourceMaterialSpec" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<hc:TextBox x:Name="rawSourceMaterialSpec" FontSize="40" Width="600" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="物料名称:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeSourceMaterialName" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<hc:TextBox x:Name="removeSourceMaterialName" FontSize="40" Width="600" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="物料规格:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeSourceMaterialSpec" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<hc:TextBox x:Name="removeSourceMaterialSpec" FontSize="40" Width="600" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="移库数量:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeScan" FontSize="40" Width="500" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<hc:TextBox x:Name="removeScan" FontSize="40" Width="600" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
</StackPanel>
<Button Content="确认移库" Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="4" Width="500" Height="150" FontSize="75" Background="#346DFF" Foreground="White" Click="btnRemoveConfirmBox_Click"/>
<StackPanel Orientation="Horizontal" Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" Margin="5">
<TextBlock Text="物料库存:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<hc:TextBox x:Name="removeTotalStock" FontSize="40" Width="600" Height="100" Margin="0,0,0,0" hc:InfoElement.ShowClearButton="True"/>
<StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Left" Margin="100 0 0 0 ">
</StackPanel>
<Button Content="确认移库" Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" Width="500" Height="150" FontSize="75" Background="#346DFF" Foreground="White" Click="btnRemoveConfirmBox_Click"/>
<StackPanel Orientation="Horizontal" Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Left" Margin="100 0 0 0 ">
<TextBlock Text="提示信息:" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<TextBlock x:Name="RemoveMsg" HorizontalAlignment="Left" FontSize="40" Foreground="White" Width="1200" Height="60" Margin="10,0,0,0" />
<TextBlock x:Name="RemoveMsg" HorizontalAlignment="Left" FontSize="40" Foreground="White" Width="1200" Height="60" Margin="10,0,0,0" />
</StackPanel>
</Grid>
</TabItem>
<TabItem x:Name="FirstFloorManager" Header="一楼接驳位" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="#213269" Foreground="White" Width="160" Height="100" Margin="5">
<TabItem x:Name="FirstFloorManager" Header="一楼接驳位" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="#213269" Foreground="White" Width="160" Height="80" Margin="5">
<Grid Height="1100" Width="1700">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@ -2605,7 +2729,7 @@
</Border>
</Grid>
</TabItem>
<TabItem x:Name="PlcManager" Header="PLC信息" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="#213269" Foreground="White" Width="160" Height="100" Margin="5">
<TabItem x:Name="PlcManager" Header="PLC信息" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="#213269" Foreground="White" Width="160" Height="80" Margin="5">
<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="Vertical" Margin="20,5,0,0">
@ -2808,7 +2932,7 @@
</StackPanel>
</StackPanel>
</TabItem>
<TabItem x:Name="AgvManager" Header="Agv信息" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="#213269" Foreground="White" Width="160" Height="100" Margin="5" >
<TabItem x:Name="AgvManager" Header="Agv信息" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Background="#213269" Foreground="White" Width="160" Height="80" Margin="5" >
<DataGrid
x:Name="AgvDataGrid"
AlternationCount="2"

File diff suppressed because it is too large Load Diff

@ -478,6 +478,11 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>
<Compile Update="WindowPage\InventoryMaterialWindow.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

@ -22,7 +22,7 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="空托盘数量" Foreground="White" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30"/>
<TextBlock Text="空料箱数量" Foreground="White" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30"/>
<ComboBox x:Name="EmptyCount" FontSize="30" Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" VerticalAlignment="Center" Width="300" Height="75"/>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="5">
<Button Content="保存" Width="150" Height="75" FontSize="50" Background="#2196F3" Foreground="White" Click="Button_Click"/>

@ -0,0 +1,52 @@
<Window x:Class="Khd.Core.Wpf.TaskForm.AddNewStockForm"
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"
WindowState="Normal"
WindowStartupLocation="CenterScreen"
Background="DarkBlue"
Loaded="Window_Loaded"
Title="" Height="450" Width="800" ResizeMode="NoResize" WindowStyle="None">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text=" 料箱号: " FontSize="30" Foreground="White" />
<TextBlock x:Name="txtInBox" Text="" Width="500" FontSize="30" Foreground="Black" Background="White" Margin="5,0,0,0"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text=" 条码号: " FontSize="30" Foreground="White" />
<TextBox x:Name="txtInBarCode" Text="" TextChanged="txtInBarCode_TextChanged" Width="500" FontSize="30" Foreground="Black" Background="White" Margin="5,0,0,0"/>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text="物料名称: " FontSize="30" Foreground="White" />
<TextBlock x:Name="materialName" Text="" Width="500" FontSize="30" Foreground="Black" Background="White" Margin="5,0,0,0"/>
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text="物料规格: " FontSize="30" Foreground="White" />
<TextBlock x:Name="materialSpec" Text="" Width="500" FontSize="30" Foreground="Black" Background="White" Margin="5,0,0,0"/>
</StackPanel>
<StackPanel Grid.Row="4" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Text=" 库存数: " FontSize="30" Foreground="White" />
<TextBox x:Name="txtInScan" Text="" Width="500" FontSize="30" Foreground="Black" Background="White" Margin="5,0,0,0"/>
</StackPanel>
<StackPanel Grid.Row="5" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<RepeatButton Background="LimeGreen" x:Name="ScanButton" Content="添加入库" Style="{StaticResource RepeatButtonPrimary}" Width="100" Height="40" FontSize="20" Margin="20,0,0,0" Click="InRawBaseLocaltion_Click" />
<RepeatButton Background="Yellow" x:Name="ScanButton11" Content="取 消" Style="{StaticResource RepeatButtonPrimary}" Width="100" Height="40" FontSize="20" Margin="200,0,0,0" Click="CancelBtn_Click" />
</StackPanel>
</Grid>
</Window>

@ -0,0 +1,335 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc;
using Khd.Core.Plc.S7;
using Khd.Core.Wpf.Form;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace Khd.Core.Wpf.TaskForm
{
/// <summary>
/// AddTask.xaml 的交互逻辑
/// </summary>
public partial class AddNewStockForm : Window
{
public delegate void RefreshDelegate(string containerCode);
public static event RefreshDelegate? RefreshDelegateEvent;
private readonly IHost _host;
public AddNewStockForm(IHost host,string containerCode)
{
InitializeComponent();
_host = host;
txtInBox.Text = containerCode;
txtInBarCode.Focus();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
private void UpdateBtn_Click(object sender, RoutedEventArgs e)
{
}
private void CancelBtn_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
//入库
private void InRawBaseLocaltion_Click(object sender, RoutedEventArgs e)
{
ScanInBox();
}
private void ScanInBox()
{
try
{
if (!string.IsNullOrEmpty(txtInBox.Text) && !string.IsNullOrEmpty(txtInBarCode.Text))
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
if (txtInScan.Text == "")
{
HandyControl.Controls.MessageBox.Error("请先输入数量"); return;
}
decimal amount = decimal.Parse(txtInScan.Text);
// 计算入库后当前总数量,仅用来提示使用
decimal? totalMessage = 0;
if (amount <= 0)
{
HandyControl.Controls.MessageBox.Error("入库数量需大于0");
return;
}
var material = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == txtInBarCode.Text);
var container = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == txtInBox.Text && t.warehouseId == 512);
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock
.Where(t => txtInBarCode.Text == t.instockBatch && t.palletInfoCode== txtInBox.Text)
.Where(t => t.warehouseFloor == 5 && t.warehouseId == 512).ToList();
if (container == null)
{
txtInBox.Focus();
txtInBox.Text = string.Empty;
txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty;
HandyControl.Controls.MessageBox.Error("未查询到该容器"); return;
}
if (material == null)
{
HandyControl.Controls.MessageBox.Error("未查询到该条码内容");
txtInBox.Text = string.Empty;
txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty;
txtInBox.Focus();
return;
}
if (wmsRawStocks.Count > 0)
{
if (material.batchFlag != "1")
{
HandyControl.Controls.MessageBox.Error($"该条码已入库!料箱号为{wmsRawStocks.First().palletInfoCode},库位号为{wmsRawStocks.First().locationCode}");
txtInBox.Text = string.Empty;
txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty;
txtInBox.Focus();
return;
}
else
{
WmsRawStock wmsRawStock = wmsRawStocks.First();
wmsRawStock.totalAmount += amount;
dbContext.WmsRawStock.Update(wmsRawStock);
var mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == txtInBarCode.Text);
WmsRawInstock wmsRawInstock = new WmsRawInstock()
{
taskCode = Global.SnowId.NextId().ToString(),
materialBarCode = mesBaseBarcodeInfo.barcodeInfo,
materialBatchCode = mesBaseBarcodeInfo.batchCode,
applyBy = "WPF",
applyDate = System.DateTime.Now,
purchaseOrderId = mesBaseBarcodeInfo.PurchaseOrderId,
beginTime = System.DateTime.Now,
endTime = DateTime.Now,
locationCode = container.locationCode,
executeStatus = "1",
instockAmount = amount,
instockType = "1",
materialId = material.materialId,
operationType = "1",
palletInfoCode = container.containerCode,
poNo = mesBaseBarcodeInfo.poNo,
warehouseId = 512
};
dbContext.WmsRawInstock.Add(wmsRawInstock);
dbContext.SaveChanges();
totalMessage = wmsRawStock.totalAmount;
}
}
else
{
var newRawStock = new WmsRawStock()
{
materialId = material.materialId,
supplierId = material.manufacturerId,
instockBatch = txtInBarCode.Text,
locationCode = container.locationCode,
stockType = "1",
palletInfoCode = container.containerCode,
totalAmount = material.batchFlag == "1" ? amount : 1,
activeFlag = "1",
occupyAmount = 0,
completeFlag = "1",
frozenAmount = 0,
instockDate = System.DateTime.Now,
rawStockId = Global.SnowId.NextId(),
saleOrderId = material.saleOrderId == null ? 0 : material.saleOrderId,
warehouseFloor = 5,
warehouseId = 512,
createBy = "扫描入库",
createDate = System.DateTime.Now,
safeFlag = material.safeFlag
};
dbContext.WmsRawStock.Add(newRawStock);
var mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == txtInBarCode.Text);
WmsRawInstock wmsRawInstock = new WmsRawInstock()
{
taskCode = Global.SnowId.NextId().ToString(),
materialBarCode = mesBaseBarcodeInfo.barcodeInfo,
materialBatchCode = mesBaseBarcodeInfo.batchCode,
applyBy = "WPF",
applyDate = System.DateTime.Now,
purchaseOrderId = mesBaseBarcodeInfo.PurchaseOrderId,
beginTime = System.DateTime.Now,
endTime = DateTime.Now,
locationCode = container.locationCode,
executeStatus = "2",
instockAmount = amount,
instockType = "1",
materialId = material.materialId,
operationType = "1",
palletInfoCode = container.containerCode,
poNo = mesBaseBarcodeInfo.poNo,
warehouseId = 512
};
dbContext.WmsRawInstock.Add(wmsRawInstock);
#region 添加盘点明细
WmsInventoryCheck wmsInventoryCheck = dbContext.WmsInventoryCheck.Where(x => x.CheckStatus == "1").FirstOrDefault();
if(wmsInventoryCheck != null)
{
WmsInventoryCheckDetail wmsInventoryCheckDetail= new WmsInventoryCheckDetail
{
InventoryCheckDetailId = Global.SnowId.NextId(),
InventoryCheckId = wmsInventoryCheck.InventoryCheckId,
CheckStatus = "2",
CreateBy = "WPF",
CreateTime = DateTime.Now,
StockAmount = newRawStock.totalAmount,
RealAmount = newRawStock.totalAmount,
InventoryCount = 0,
LocationCode = newRawStock.locationCode,
MaterialBatch = newRawStock.instockBatch,
StockId = 1,
StockType = "1",
MaterialId = newRawStock.materialId,
ErpStatus = "0",
ErpAmount = 0,
CheckType = "2"
};
dbContext.WmsInventoryCheckDetail.Add(wmsInventoryCheckDetail);
}
#endregion
dbContext.SaveChanges();
totalMessage = newRawStock.totalAmount;
}
txtInBox.Focus();
HandyControl.Controls.MessageBox.Info($"入库成功!当前库存:{totalMessage}");
txtInBox.Text = string.Empty;
txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty;
}
else
{
HandyControl.Controls.MessageBox.Error("请先扫描容器号和条码");
}
}
catch (Exception ex)
{
txtInBox.Text = string.Empty;
txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty;
HandyControl.Controls.MessageBox.Error("入库失败");
txtInBarCode.Focus();
}
}
/// <summary>
/// 入库条码改变
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txtInBarCode_TextChanged(object sender, RoutedEventArgs e)
{
try
{
materialName.Text = string.Empty;
materialSpec.Text = string.Empty;
string barCode = txtInBarCode.Text;
if (barCode.Length < 19) return;
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
if (!string.IsNullOrEmpty(barCode))
{
var material = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == barCode);
if (material == null)
{
HandyControl.Controls.MessageBox.Error("未查询到该条码内容!");
txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty;
txtInBarCode.Focus();
}
else
{
var mesBaseMaterialInfo = dbContext.MesBaseMaterialInfo.FirstOrDefault(t => t.MaterialId == material.materialId);
if (mesBaseMaterialInfo == null)
{
HandyControl.Controls.MessageBox.Error("未查询到该条码绑定的物料信息!");
txtInBarCode.Text = string.Empty;
txtInScan.Text = string.Empty;
txtInBarCode.Focus();
}
else
{
txtInScan.Text = (material.batchFlag == "1") ? "" : "1.00";
materialName.Text = mesBaseMaterialInfo.MaterialName;
materialSpec.Text = mesBaseMaterialInfo.MaterialSpec;
if (mesBaseMaterialInfo.BatchFlag == "0")
{
txtInScan.IsReadOnly = true;
}
else
{
txtInScan.IsReadOnly = false;
}
txtInScan.Focus();
}
}
}
}
catch
{
}
}
}
}

@ -0,0 +1,117 @@
<Window x:Class="Khd.Core.Wpf.TaskForm.InventoryDetails"
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="#213269"
Loaded="Window_Loaded"
WindowStartupLocation="CenterScreen"
Height="900" Width="1700">
<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" DisplayMemberPath="containerNo" 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"/>
<Button Content="编辑" FontSize="30" Height="50" Foreground="White" Width="100" Background="#2196F3" Margin="10,0,0,0" Click="EditBtn_Click"/>
</StackPanel>-->
<DataGrid
Style="{StaticResource DataGridStyle}"
Grid.Row="1"
x:Name="InventoryDetailsDataGrid"
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 Id}" ElementStyle="{StaticResource dgCell}" Width="50*"/>
<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="300*"
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*"/>
<DataGridTextColumn Header="盘库时间" Binding="{Binding UpdateDate,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" ElementStyle="{StaticResource dgCell}" Width="140*"/>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Background" Value="#213269" />
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#213269" />
</Style>
</DataGrid.RowStyle>
<DataGrid.RowHeaderStyle>
<Style TargetType="{x:Type DataGridRowHeader}">
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Background" Value="#213269" />
</Style>
</DataGrid.RowHeaderStyle>
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Foreground" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Background" Value="#213269" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="White" />
<Setter Property="FontSize" Value="20" />
</Style>
</DataGrid.ColumnHeaderStyle>
</DataGrid>
</Grid>
</Window>

@ -0,0 +1,85 @@
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.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Media3D;
namespace Khd.Core.Wpf.TaskForm
{
/// <summary>
/// InventoryTaskForm.xaml 的交互逻辑
/// </summary>
public partial class InventoryDetails : Window
{
private readonly IHost _host;
private readonly long inventoryCheckId = 0;
public InventoryDetails(IHost host,long id)
{
InitializeComponent();
_host = host;
inventoryCheckId = id;
}
//在载入行的时候在行表头添加编号
private void dgvMH_LoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Header = (e.Row.GetIndex() + 1).ToString();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
try
{
GetData();
}
catch
{
Console.WriteLine("InventoryDetails-Window_Loaded加载失败");
}
}
private void GetData()
{
int amount = 0;
if (inventoryCheckId == 0) return;
using var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
List<WmsInventoryCheckDetail> wmsInventoryCheckDetails = dbContext.WmsInventoryCheckDetail
.Where(t => t.InventoryCheckId == inventoryCheckId)
.ToList();
List<long?> list = wmsInventoryCheckDetails.Select(t => t.MaterialId).Distinct().ToList();
List<MesBaseMaterialInfo> mesBaseMaterialInfos = dbContext.MesBaseMaterialInfo.Where(t => list.Contains(t.MaterialId)).ToList();
this.InventoryDetailsDataGrid.ItemsSource = wmsInventoryCheckDetails.Select(t =>
new
{
Id = ++amount,
LocationCode = t.LocationCode,
MaterialId = t.MaterialId,
MaterialName = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.MaterialId)?.MaterialSpec,
StockAmount = t.StockAmount,
RealAmount = t.RealAmount,
UpdateDate = t.UpdateTime,
});
this.InventoryDetailsDataGrid.Items.Refresh();
}
private void SearchBtn_Click(object sender, RoutedEventArgs e)
{
GetData();
}
}
}

@ -28,23 +28,28 @@
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="请选择容器编号:" FontSize="30" Foreground="White" VerticalAlignment="Center"/>
<ComboBox x:Name="ContainerCodeBox" IsEditable="True" DisplayMemberPath="containerNo" Style="{StaticResource ComboBoxExtend}" Width="300" hc:InfoElement.Placeholder="容器编码" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Necessary="True" FontSize="30" />
<TextBlock Text="请扫描容器编号:" FontSize="30" Foreground="White" VerticalAlignment="Center"/>
<!--<ComboBox x:Name="ContainerCodeBox" IsEditable="True" DisplayMemberPath="containerNo" Style="{StaticResource ComboBoxExtend}" Width="300" hc:InfoElement.Placeholder="容器编码" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Necessary="True" FontSize="30" />-->
<hc:TextBox x:Name="txtInBox" hc:InfoElement.ShowClearButton="True" FontSize="20" TextChanged="txtInBox_TextChanged" Width="300" Background="White" HorizontalAlignment="Left" VerticalAlignment="Center" Height="50" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="4"/>
<Button x:Name="SearchBtn" Content="搜索" FontSize="30" Height="50" Foreground="White" Width="100" Background="#2196F3" Margin="10,0,0,0" Click="SearchBtn_Click"/>
<Button Content="编辑" FontSize="30" Height="50" Foreground="White" Width="100" Background="#2196F3" Margin="10,0,0,0" Click="EditBtn_Click"/>
<Button Content="补入库" FontSize="30" Height="50" Foreground="White" Width="150" Background="GreenYellow" Margin="50,0,0,0" Click="EditBtn_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"
@ -52,18 +57,20 @@
CanUserResizeRows="False"
Focusable="False"
HeadersVisibility="Column"
IsReadOnly="True"
IsReadOnly="False"
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*"/>
<DataGridTextColumn Header="库位号" Binding="{Binding LocationCode}" ElementStyle="{StaticResource dgCell}" Width="150*"/>
<!--<DataGridTextColumn Header="料箱号" Binding="{Binding ContainerNo}" ElementStyle="{StaticResource dgCell}" Width="200*"/>-->
<DataGridTextColumn Header="物料编码" Binding="{Binding MaterialId}" ElementStyle="{StaticResource dgCell}" Width="80*"/>
<DataGridTextColumn Header="物料条码" Binding="{Binding MaterialBatch}" ElementStyle="{StaticResource dgCell}" Width="180*"/>
<DataGridTextColumn Header="物料规格" Binding="{Binding MaterialSpec}" ElementStyle="{StaticResource dgCell}" Width="150*"/>
<DataGridTemplateColumn
Width="350*"
Width="250*"
CanUserSort="False"
Header="物料描述"
IsReadOnly="True" >
@ -73,12 +80,27 @@
</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="操作">
<DataGridTextColumn Header="库存数量" Binding="{Binding StockAmount}" ElementStyle="{StaticResource dgCell}" Width="110*"/>
<!--<DataGridTemplateColumn Header="实际数量" Width="110*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="编辑" Foreground="White" Width="75" Background="#2196F3" Click="EditBtn_Click"/>
<TextBlock Text="{Binding RealAmount}"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="16" Foreground="White" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox IsReadOnly="False" Text="{Binding RealAmount}"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="16" Foreground="Black" Background="White" BorderThickness="1" BorderBrush="#2196F3"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>-->
<DataGridTemplateColumn Header="操作" Width="100*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="编辑" Foreground="White" Width="100" Background="#2196F3" Click="Update_Click"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

@ -1,11 +1,17 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Khd.Core.Wpf.Scan;
using Khd.Core.Wpf.TaskForm.Inventory;
using Masuit.Tools.Logging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace Khd.Core.Wpf.TaskForm
{
@ -14,30 +20,80 @@ namespace Khd.Core.Wpf.TaskForm
/// </summary>
public partial class InventoryTaskForm : Window
{
private readonly IHost _host;
public InventoryTaskForm(IHost host)
{
InitializeComponent();
_host = host;
Thread scanThread = new Thread(ScanMessage);
scanThread.IsBackground = true;
scanThread.Start();
UpdateAmountWindow.RefreshDelegateEvent += GetData;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
private void ScanMessage()
{
while (true)
{
try
{
if (SystemData.isUpdate)
{
if (!string.IsNullOrEmpty(SystemData.message))
{
Dispatcher.Invoke(() =>
{
var focusedElement = FocusManager.GetFocusedElement(this);
if (focusedElement is TextBox textBox)
{
textBox.Text = SystemData.message;
SystemData.isUpdate = false;
}
});
}
}
}
catch (Exception ex)
{
LogManager.Error(ex);
}
Thread.Sleep(500);
}
}
private void txtInBox_TextChanged(object sender, RoutedEventArgs e)
{
if(txtInBox.Text.Length == 15)
{
GetData(txtInBox.Text);
}
else
{
this.InventoryDataGrid.ItemsSource = null;
}
}
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.Distinct();
}
else
{
HandyControl.Controls.MessageBox.Show("未找到盘库已完成的小车任务!");
this.Close();
}
//if (wcsTasks.Count > 0)
//{
// this.ContainerCodeBox.ItemsSource = wcsTasks.Distinct();
//}
//else
//{
// HandyControl.Controls.MessageBox.Show("未找到盘库已完成的小车任务!");
// this.Close();
//}
}
catch
{
@ -45,80 +101,108 @@ namespace Khd.Core.Wpf.TaskForm
}
}
private void GetData()
private void GetData(string containerNo)
{
if (this.ContainerCodeBox.SelectedItem is WcsTask task)
{
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 == task.containerNo).FirstOrDefault();
.Where(t => t.containerNo == containerNo).FirstOrDefault();
if (wcsTask != null)
{
WmsInventoryCheck check = dbContext.WmsInventoryCheck.Where(x => x.CheckStatus == "1").FirstOrDefault();
if (check == null)
{
HandyControl.Controls.MessageBox.Show("当前无正在执行的盘库任务");
return;
}
var wmsInventoryCheckDetails = dbContext.WmsInventoryCheckDetail
.Where(t => t.InventoryCheckId == wcsTask.orderId)
.Where(t => t.InventoryCheckId == check.InventoryCheckId)
.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();
//this.InventoryDataGrid.ItemsSource = wmsInventoryCheckDetails.GroupBy(t => t.MaterialId).Select(t =>
// new
// {
// //ContainerNo = wcsTask.containerNo,
// MaterialBatch = t.FirstOrDefault(n => n.MaterialId == t.Key)?.MaterialBatch,
// MaterialSpec = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.Key)?.MaterialSpec,
// MaterialName = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.Key)?.MaterialName,
// StockAmount = t.Sum(n => n.StockAmount),
// LocationCode = wcsTask.currPointNo,
// MaterialId = t.Key,
// //RealAmount = (t.Sum(n => n.RealAmount)).ToString(),
// });
this.InventoryDataGrid.ItemsSource = wmsInventoryCheckDetails.Select(t =>
new
{
//ContainerNo = wcsTask.containerNo,
MaterialBatch = t.MaterialBatch,
MaterialSpec = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.MaterialId)?.MaterialSpec,
MaterialName = mesBaseMaterialInfos.FirstOrDefault(m => m.MaterialId == t.MaterialId)?.MaterialName,
StockAmount = t.StockAmount,
LocationCode = wcsTask.currPointNo,
MaterialId = t.MaterialId,
//RealAmount = (t.Sum(n => n.RealAmount)).ToString(),
});
this.InventoryDataGrid.Items.Refresh();
if (wmsInventoryCheckDetails.Count == 0)
{
HandyControl.Controls.MessageBox.Show("该料箱为空料箱");
}
}
}
else
{
HandyControl.Controls.MessageBox.Show("请扫描盘库任务里面的料箱");
}
}
private void SearchBtn_Click(object sender, RoutedEventArgs e)
{
}
private void EditBtn_Click(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(txtInBox.Text))
{
AddNewStockForm editForm = new AddNewStockForm(_host, txtInBox.Text);
editForm.ShowDialog();
}
else
{
HandyControl.Controls.MessageBox.Show("请先选择料箱号!");
}
}
private void SearchBtn_Click(object sender, RoutedEventArgs e)
{
GetData();
}
private void EditBtn_Click(object sender, RoutedEventArgs e)
private void Update_Click(object sender, RoutedEventArgs e)
{
if (this.InventoryDataGrid.SelectedItem != null)
{
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();
}
else
{
if (this.ContainerCodeBox.SelectedItem is WcsTask task)
{
InventoryTaskEditForm editForm = new InventoryTaskEditForm(_host, 0, task.containerNo, "", task.currPointNo, this);
this.Hide();
editForm.ShowDialog();
GetData();
}
else
{
HandyControl.Controls.MessageBox.Show("请先选择料箱号!");
}
UpdateAmountWindow updateStockAmount = new UpdateAmountWindow(_host, item.MaterialBatch, item.LocationCode, txtInBox.Text);
updateStockAmount.ShowDialog();
//long materialId = item.MaterialId;
//string containerNo = txtInBox.Text;
//string materialName = item.MaterialName;
//string locationCode = item.LocationCode;
//string realAmount = item.RealAmount;
//GetData(txtInBox.Text);
}
}
}
}

@ -0,0 +1,34 @@
<Window x:Class="Khd.Core.Wpf.TaskForm.UpdateAmountWindow"
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"
WindowState="Normal"
WindowStartupLocation="CenterScreen"
Background="#333333"
Loaded="Window_Loaded"
Title="" Height="450" Width="800" ResizeMode="NoResize" WindowStyle="None">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="库存数量修改: " Foreground="White" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBox x:Name="StockAmount" Text="" Width="250" Background="White" Foreground="Black" FontSize="40" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Row="2" HorizontalAlignment="Center" >
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button x:Name="AddTaskBtn" Content="修改库存" FontSize="25" Width="160" Height="50" Foreground="White" Background="#2196F3" VerticalAlignment="Center" HorizontalAlignment="Center" Click="UpdateBtn_Click"/>
<Button x:Name="CancelBtn" Content="取消" FontSize="25" Width="160" Height="50" Foreground="White" Background="#F44336" Click="CancelBtn_Click" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="100,0,0,0"/>
</StackPanel>
</StackPanel>
</Grid>
</Window>

@ -0,0 +1,100 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc;
using Khd.Core.Plc.S7;
using Khd.Core.Wpf.Form;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace Khd.Core.Wpf.TaskForm
{
/// <summary>
/// AddTask.xaml 的交互逻辑
/// </summary>
public partial class UpdateAmountWindow : Window
{
public delegate void RefreshDelegate(string containerCode);
public static event RefreshDelegate? RefreshDelegateEvent;
private string barcodeInfo;
private string locationCode;
private string containerCode;
private readonly IHost _host;
public UpdateAmountWindow(IHost host,string barcodeInfo,string locationCode,string containerCode)
{
InitializeComponent();
_host = host;
this.barcodeInfo = barcodeInfo;
this.locationCode = locationCode;
this.containerCode = containerCode;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
private void UpdateBtn_Click(object sender, RoutedEventArgs e)
{
string input = this.StockAmount.Text.Trim(); // 去除前后空白
if (string.IsNullOrEmpty(input))
{
MessageBox.Show("数量不能为空,请输入有效数值。");
return;
}
decimal stockAmountValue;
if (!decimal.TryParse(input, out stockAmountValue))
{
MessageBox.Show("输入的数值格式不正确,请输入有效的十进制数。");
return;
}
//
if (stockAmountValue <0)
{
MessageBox.Show("数值必须大于0");
return;
}
var scope = _host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var wmsRawStocks = dbContext.WmsRawStock.Where(x => x.locationCode == locationCode && x.instockBatch == barcodeInfo).ToList();
WmsRawStock wmsRawStock = wmsRawStocks.FirstOrDefault();
if (wmsRawStock != null)
{
wmsRawStock.totalAmount = stockAmountValue;
dbContext.Update(wmsRawStock);
// 修改盘库明细
WmsInventoryCheckDetail wmsInventoryDetail = dbContext.WmsInventoryCheckDetail.Where(x => x.LocationCode == locationCode && x.MaterialBatch == barcodeInfo && x.CheckStatus=="1").OrderByDescending(X=>X.CreateTime).FirstOrDefault();
if(wmsInventoryDetail != null)
{
wmsInventoryDetail.StockAmount = stockAmountValue;
wmsInventoryDetail.RealAmount = stockAmountValue;
wmsInventoryDetail.UpdateTime = DateTime.Now;
dbContext.Update(wmsInventoryDetail);
}
dbContext.SaveChanges();
this.Close();
RefreshDelegateEvent?.Invoke(containerCode);
}
}
private void CancelBtn_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

@ -44,7 +44,6 @@ namespace Khd.Core.Wpf.TaskForm
baseEquip.IsOut = _isOut;
dbContext.BaseEquip.Update(baseEquip);
dbContext.SaveChanges();
MessageBox.Show("保存成功!");
this.Close();
}
}

@ -0,0 +1,193 @@
<Window x:Class="Khd.Core.Wpf.WindowPage.InventoryMaterialWindow"
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.WindowPage"
mc:Ignorable="d"
Title="选择盘库型号" Height="900" Width="1900" WindowStartupLocation="CenterScreen" Background="#172557">
<Window.Resources>
<ResourceDictionary>
<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.MergedDictionaries>
<!--<hc:ThemeResources/>
<hc:Theme/>-->
<ResourceDictionary Source="/CSS/SearchBtnClass.xaml" />
<ResourceDictionary Source="/CSS/SearchTextClass.xaml" />
<ResourceDictionary Source="/CSS/DataGridClass.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="2*"/>
<RowDefinition Height="8*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
<TextBox x:Name="SearchTxt" Width="200" Height="40" Margin="5,0,0,0" VerticalAlignment="Center" />
<Button x:Name="SearchButton" Foreground="White" Background="Blue" Content="搜 索" FontSize="20" Margin="20 0 25 0" Height="50" Width="100" Click="SearchButton_Click"/>
<!--<TextBlock Text="选中物料" Foreground="White" FontSize="25" Margin="0 0 25 0" VerticalAlignment="Center"/>
<TextBox x:Name="SelectMaterialId" Width="50" Height="40" Margin="5,0,0,0" VerticalAlignment="Center" IsReadOnly="True"/>
<TextBox x:Name="SelectMaterialName" Width="200" Height="40" Margin="5,0,0,0" VerticalAlignment="Center" IsReadOnly="True"/>-->
<!--<Button x:Name="ClearButton" Foreground="White" Background="Blue" Content="清除" FontSize="20" Margin="20 0 25 0" Height="50" Width="100" Click="ClearButton_Click" />-->
<Button x:Name="CreateInventoryTask" Foreground="White" Background="DarkGreen" Content="创建盘库任务" FontSize="20" Margin="200 0 25 0" Height="50" Width="200" Click="CreateInventoryTask_Click" />
</StackPanel>
</Grid>
<Border Grid.Row="1" Height="100" Background="Transparent" BorderThickness="2" CornerRadius="10" Margin="0,5,0,0">
<ItemsControl x:Name="itemsControl">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
<!-- 使项自动换行 -->
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="5" Padding="5">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding materialName}" Foreground="White" FontSize="20" VerticalAlignment="Center"/>
<Button Content="删除" FontSize="15" Width="50" Background="LightSkyBlue" Foreground="Red" Margin="0,0,10,0" Click="DeleteButton_Click" Tag="{Binding }"/>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
<Grid Grid.Row="2">
<DataGrid
Style="{StaticResource DataGridStyle}"
Grid.Row="2" AlternationCount="2"
AutoGenerateColumns="False"
MinRowHeight="50"
Background="#172557"
CanUserAddRows="False"
GridLinesVisibility="None"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
Focusable="False"
Height="auto"
HeadersVisibility="Column"
IsReadOnly="True"
RowHeaderWidth="0"
SelectionMode="Single" FontSize="16"
Visibility="Visible"
VerticalAlignment="Top"
x:Name="StockDataGrid">
<DataGrid.Columns>
<DataGridTemplateColumn Width="130*" Header="选择">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.Tag>
<Binding Path="IsSelected"/>
</Grid.Tag>
<CheckBox
IsChecked="{Binding Tag, RelativeSource={RelativeSource AncestorType=Grid}}"
Click="CheckPersonBox_Click"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Width="200*"
Binding="{Binding materialId}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="物料ID"
IsReadOnly="True" />
<DataGridTextColumn
Width="200*"
Binding="{Binding materialCode}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="物料编码"
IsReadOnly="True" />
<DataGridTemplateColumn
Width="280*"
CanUserSort="False"
Header="物料名称"
IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding materialName}" ToolTip="{Binding materialNameSrc}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn
Width="300*"
CanUserSort="False"
Header="物料规格"
IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding materialSpec}" ToolTip="{Binding materialSpecSrc}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" />
</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" />
</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>
</Grid>
</Grid>
</Window>

@ -0,0 +1,280 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Khd.Core.Wpf.dto;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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.Media.Media3D;
using System.Windows.Shapes;
using static Khd.Core.Wpf.Form.FormBoardT;
namespace Khd.Core.Wpf.WindowPage
{
/// <summary>
/// StockWindow.xaml 的交互逻辑
/// </summary>
public partial class InventoryMaterialWindow : Window
{
private IHost host = null;
private ObservableCollection<StockItem> itemsControlItems;
/// <summary>
/// 刷新盘库任务列表
/// </summary>
public delegate void RefreshInventoryList();
public static event RefreshInventoryList? RefreshInventoryListEvent;
public InventoryMaterialWindow(IHost _host)
{
host = _host;
InitializeComponent();
Init();
itemsControlItems = new ObservableCollection<StockItem>();
itemsControl.ItemsSource = itemsControlItems;
}
public async Task Init()
{
using var scope = host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
//var location = await dbContext.WmsBaseLocation.Where(x => x.locationId == locationId).FirstOrDefaultAsync();
var stockList = await dbContext.WmsRawStock.Where(x => x.warehouseId ==512).ToListAsync();
if(stockList != null && stockList.Count > 0)
{
// 获取所有库存物料 ID
var materialIds = stockList.Select(stock => stock.materialId).Distinct().ToList();
var materialInfos = await dbContext.MesBaseMaterialInfo
.Where(material => materialIds.Contains(material.MaterialId))
.ToListAsync();
// 将库存物料信息和物料详细信息合并
var stockDetails = materialInfos.Select(material => new StockItem
{
IsSelected = false,
materialId = material.MaterialId.ToString(),
materialCode = material.MaterialCode,
materialName = material.MaterialName,
materialSpec = material.MaterialSpec,
}).ToList();
StockDataGrid.ItemsSource = stockDetails;
}
}
private void SearchButton_Click(object sender, RoutedEventArgs e)
{
string searchStr = SearchTxt.Text;
if (string.IsNullOrEmpty(searchStr))
{
Init();
}
else
{
var target = StockDataGrid.ItemsSource.Cast<dynamic>().Where(x => x.materialCode.Contains(searchStr) || x.materialName.Contains(searchStr) || x.materialSpec.Contains(searchStr)).ToList();
StockDataGrid.ItemsSource = target;
}
}
public class StockItem
{
public bool IsSelected { get; set; }
public string materialId { get; set; }
public string materialCode { get; set; }
public string materialName { get; set; }
public string materialSpec { get; set; }
}
private void CreateInventoryTask_Click(object sender, RoutedEventArgs e)
{
try
{
using var scope = host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
int locationCount = 0;
if(itemsControlItems.Count == 0)
{
locationCount = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512 && t.ContainerStatus == "1" && t.locationStatus=="1").Count();
}
else
{
var materialIdList = itemsControlItems.Select(t => long.Parse(t.materialId)).ToList();
var locations = dbContext.WmsRawStock.Where(t => materialIdList.Contains((long)t.materialId)).ToList().Select(t=>t.locationCode).Distinct();
locationCount = locations.Count();
}
string materialIds = null;
if (itemsControlItems.Count > 0)
{
materialIds = string.Join(";", itemsControlItems.Select(t => t.materialId));
}
var Orders = dbContext.WmsInventoryCheck.Where(t => t.CheckStatus == "0" || t.CheckStatus == "1").ToList();
if (Orders != null && Orders.Count > 0)
{
MessageBoxResult messageBoxResult = HandyControl.Controls.MessageBox.Show("已经有盘库任务是否继续创建新盘库任务?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (messageBoxResult == MessageBoxResult.OK)
{
Orders.ForEach(t =>
{
t.EndTime = DateTime.Now;
t.CheckStatus = "2";
});
dbContext.UpdateRange(Orders);
dbContext.Add(new WmsInventoryCheck()
{
CreateTime = DateTime.Now,
CheckStatus = "0",
LocationAmount = locationCount,
InventoriedAmount = 0,
InventoryingAmount = 0,
WarehouseId = 512,
CreateBy = "WCS",
MaterialId = materialIds
}) ;
dbContext.SaveChanges();
HandyControl.Controls.Growl.Info("创建盘库任务成功!");
}
else
{
return;
}
}
else
{
MessageBoxResult messageBoxResult = HandyControl.Controls.MessageBox.Show("是否创建一个盘库任务?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (messageBoxResult == MessageBoxResult.OK)
{
dbContext.Add(new WmsInventoryCheck()
{
CreateTime = DateTime.Now,
CheckStatus = "0",
LocationAmount = locationCount,
InventoriedAmount = 0,
InventoryingAmount = 0,
WarehouseId = 512,
CreateBy = "WCS",
MaterialId = materialIds
});
dbContext.SaveChanges();
HandyControl.Controls.Growl.Info("创建盘库任务成功!");
}
}
this.Close();
//刷新列表
RefreshInventoryListEvent?.Invoke();
}
catch
{
}
}
/// <summary>
/// 单选
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckPersonBox_Click(object sender, RoutedEventArgs e)
{
if (sender is CheckBox checkbox)
{
dynamic Currentselected = StockDataGrid.SelectedItem;
if (checkbox.IsChecked != null && checkbox.IsChecked.Value)
{
//if (itemsControlItems != null && itemsControlItems.Count >= 6)
//{
// MessageBox.Show("最多只能选择6个");
// checkbox.IsChecked = false;
// return;
//}
// 添加选中项
string selectedItem = Currentselected.materialName;
bool isIn = itemsControlItems.Any(t => t.materialId == Currentselected.materialId);
if (!isIn)
{
itemsControlItems.Add(new StockItem
{
materialId = Currentselected.materialId,
materialCode = Currentselected.materialCode,
materialName = Currentselected.materialName,
materialSpec = Currentselected.materialSpec,
});
}
}
else
{
// 删除选中项
StockItem model = itemsControlItems.FirstOrDefault(x => x.materialId == Currentselected.materialId);
if (model != null)
{
itemsControlItems.Remove(model);
}
}
}
}
/// <summary>
/// 删除选中的值
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
// 获取点击按钮的实例
Button button = sender as Button;
// 从按钮的 Tag 属性中获取当前数据项
StockItem itemToRemove = button.Tag as StockItem;
if (itemToRemove != null)
{
// 从集合中移除数据项
itemsControlItems.Remove(itemToRemove);
}
}
}
}

@ -0,0 +1,167 @@
<Window x:Class="Khd.Core.Wpf.WindowPage.StockWindow"
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.WindowPage"
mc:Ignorable="d"
Title="查看库存" Height="600" Width="1500" WindowStartupLocation="CenterScreen" Background="#172557">
<Window.Resources>
<ResourceDictionary>
<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.MergedDictionaries>
<!--<hc:ThemeResources/>
<hc:Theme/>-->
<ResourceDictionary Source="/CSS/SearchBtnClass.xaml" />
<ResourceDictionary Source="/CSS/SearchTextClass.xaml" />
<ResourceDictionary Source="/CSS/DataGridClass.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="8*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Horizontal">
<TextBox x:Name="positionRowTxt" FontSize="25" Margin="0 0 10 0" Width="100"/>
<TextBlock Text="行" Foreground="White" FontSize="25" Margin="0 0 25 0"/>
<TextBox x:Name="positionColumnTxt" FontSize="25" Margin="0 0 10 0" Width="100"/>
<TextBlock Text="列" Foreground="White" FontSize="25" Margin="0 0 25 0"/>
<TextBox x:Name="positionLayerTxt" FontSize="25" Margin="0 0 10 0" Width="80"/>
<TextBlock Text="层" Foreground="White" FontSize="25" Margin="0 0 150 0"/>
<TextBlock Text="库位编号:" Foreground="White" FontSize="25" Margin="0 0 8 0"/>
<TextBlock x:Name="locationTxt" Foreground="White" FontSize="25" Margin="0 0 58 0" Width="250"/>
<TextBlock Text="托盘编号:" Foreground="White" FontSize="25" Margin="0 0 8 0"/>
<TextBlock x:Name="palletTxt" Foreground="White" FontSize="25"/>
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<DataGrid
Style="{StaticResource DataGridStyle}"
Grid.Row="2" AlternationCount="2"
AutoGenerateColumns="False"
MinRowHeight="50"
Background="#172557"
CanUserAddRows="False"
GridLinesVisibility="None"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
Focusable="False"
Height="auto"
HeadersVisibility="Column"
IsReadOnly="True"
RowHeaderWidth="0"
SelectionMode="Single" FontSize="16"
Visibility="Visible"
VerticalAlignment="Top"
x:Name="StockDataGrid">
<DataGrid.Columns>
<DataGridTextColumn
Width="200*"
Binding="{Binding materialCode}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="物料编码"
IsReadOnly="True" />
<DataGridTemplateColumn
Width="280*"
CanUserSort="False"
Header="物料名称"
IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding materialName}" ToolTip="{Binding materialNameSrc}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn
Width="300*"
CanUserSort="False"
Header="物料规格"
IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding materialSpec}" ToolTip="{Binding materialSpecSrc}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn
Width="130*"
CanUserSort="False"
Header="总数"
IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding totalAmount}" ToolTip="{Binding totalAmount}" Height="auto" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn
Width="130*"
CanUserSort="False"
Header="冻结数量"
IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="WrapWithOverflow" Text="{Binding frozenAmount}" Height="auto" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" />
</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" />
</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>
</Grid>
</Grid>
</Window>

@ -0,0 +1,75 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
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.WindowPage
{
/// <summary>
/// StockWindow.xaml 的交互逻辑
/// </summary>
public partial class StockWindow : Window
{
private IHost host = null;
public StockWindow(IHost _host,long locationId)
{
host = _host;
InitializeComponent();
Init(locationId);
}
public async Task Init(long locationId)
{
using var scope = host.Services.CreateScope();
var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var location = await dbContext.WmsBaseLocation.Where(x => x.locationId == locationId).FirstOrDefaultAsync();
positionRowTxt.Text = location.locRow.ToString();
positionColumnTxt.Text = location.locColumn.ToString();
positionLayerTxt.Text = location.layerNum.ToString();
locationTxt.Text = location.locationCode;
palletTxt.Text = location.containerCode;
var stockList = await dbContext.WmsRawStock.Where(x => x.palletInfoCode == location.containerCode).ToListAsync();
if(stockList != null && stockList.Count > 0)
{
// 获取所有库存物料 ID
var materialIds = stockList.Select(stock => stock.materialId).Distinct().ToList();
var materialInfos = await dbContext.MesBaseMaterialInfo
.Where(material => materialIds.Contains(material.MaterialId))
.ToListAsync();
// 将库存物料信息和物料详细信息合并
var stockDetails = from stock in stockList
from material in materialInfos
where stock.materialId == material.MaterialId
select new
{
materialCode = material.MaterialCode,
materialName = material.MaterialName,
materialSpec = material.MaterialSpec,
totalAmount = stock.totalAmount,
frozenAmount = stock.frozenAmount
};
StockDataGrid.ItemsSource = stockDetails;
}
}
}
}

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace Khd.Core.Wpf.dto
{
public class Location
{
public long LocationId { get; set; } // 新增 LocationId
public string Code { get; set; }
public LocationStatus Status { get; set; }
public Visibility isFreeze { get; set; }
}
public enum LocationStatus
{
// 在库有库存
InAndStock,
//// 空料箱在库无库存
EmptyInStock,
//库外
OutOfStock,
}
}
Loading…
Cancel
Save