master
2 years ago
parent 531c9bbd59
commit 66bbced58f

@ -70,19 +70,28 @@ namespace Khd.Core.Application
reponseagvCallbackDto.code = "0";
reponseagvCallbackDto.message = "成功";
}
//已取货待放货
if (agvCallbackDto.method.ToLower() == "continue")
if (agvCallbackDto.method.ToLower() == "con")
{
wcscmd.cmdStatus = 3;
wcscmd.sendFlag = 1;
wcsTask.taskStatus = 3;
wcscmd.cmdStatus = 4;
wcsTask.taskStatus = 4;
_dbContext.WcsCmd.Update(wcscmd);
_dbContext.Update(wcsTask);
_dbContext.WcsTask.Update(wcsTask);
_dbContext.SaveChanges();
reponseagvCallbackDto.code = "0";
reponseagvCallbackDto.message = "成功";
}
//已取货待放货
if (agvCallbackDto.method.ToLower() == "continue")
{
wcscmd.sendFlag = 1;
wcscmd.cmdStatus = 3;
wcsTask.taskStatus = 3;
_dbContext.WcsCmd.Update(wcscmd);
_dbContext.WcsTask.Update(wcsTask);
_dbContext.SaveChanges();
reponseagvCallbackDto.code = "0";
reponseagvCallbackDto.message = "成功";
//_dbContext.WcsTask.Where(t => t.objid == wcscmd.taskId).Update(t=>t.taskStatus==3);
}
//放货完成
if (agvCallbackDto.method.ToLower() == "end")
@ -91,7 +100,7 @@ namespace Khd.Core.Application
wcscmd.sendFlag = 1;
wcsTask.taskStatus = 5;
_dbContext.WcsCmd.Update(wcscmd);
_dbContext.Update(wcsTask);
_dbContext.WcsTask.Update(wcsTask);
_dbContext.SaveChanges();
reponseagvCallbackDto.code = "0";
reponseagvCallbackDto.message = "成功";
@ -230,6 +239,7 @@ namespace Khd.Core.Application
_dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
WcsTask wcsTask = _dbContext.WcsTask
.Where(t => t.taskType == 28)
.Where(t=>t.startPointNo==taskReturn.PointNo)
.Where(t => t.materialId == taskReturn.materialId)
.FirstOrDefault();
if (wcsTask != null)

@ -17,11 +17,13 @@ namespace Khd.Core.Domain.Dto.webapi
public class TaskContinue
{
public long? materialId { get; set; }
public string PointNo { get; set; }
}
public class TaskReturn
{
public long? materialId { get; set; }
public string PointNo { get; set; }
}
public class AgvCompeletedResponse

@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace Khd.Core.Domain.Models
{
[Table("mes_base_material_info")]
public class MesBaseMaterialInfo
{
[Key]
[Column("material_id")]
public long? MaterialId { get; set; }
[Column("erp_id")]
public long? ErpId { get; set; }
[Column("material_code")]
public string MaterialCode { get; set; }
[Column("old_material_code")]
public string OldMaterialCode { get; set; }
[Column("material_name")]
public string MaterialName { get; set; }
[Column("material_categories")]
public string MaterialCategories { get; set; }
[Column("material_subclass")]
public string MaterialSubclass { get; set; }
[Column("material_type_id")]
public string MaterialTypeId { get; set; }
[Column("batch_flag")]
public int? BatchFlag { get; set; }
[Column("batch_amount")]
public int? BatchAmount { get; set; }
[Column("material_unit_id")]
public long? MaterialUnitId { get; set; }
[Column("material_unit")]
public string MaterialUnit { get; set; }
[Column("material_matkl")]
public string MaterialMatkl { get; set; }
[Column("material_spec")]
public string MaterialSpec { get; set; }
[Column("net_weight")]
public decimal? NetWeight { get; set; }
[Column("gross_weight")]
public decimal? GrossWeight { get; set; }
[Column("bind_flag")]
public decimal? BindFlag { get; set; }
[Column("factory_id")]
public string FactoryId { get; set; }
[Column("create_org_id")]
public long? CreateOrgId { get; set; }
[Column("use_org_id")]
public long? UseOrgId { get; set; }
[Column("prodline_id")]
public int? ProdlineId { get; set; }
[Column("active_flag")]
public int? ActiveFlag { get; set; }
[Column("deleted_flag")]
public int? DeletedFlag { get; set; }
[Column("remark")]
public string Remark { get; set; }
[Column("purchase_price_unit_id")]
public long? PurchasePriceUnitId { get; set; }
[Column("create_by")]
public long? CreateBy { get; set; }
[Column("create_time")]
public DateTime? CreateTime { get; set; }
[Column("update_by")]
public long? UpdateBy { get; set; }
[Column("update_time")]
public DateTime? UpdateTime { get; set; }
[Column("approve_date")]
public DateTime? ApproveDate { get; set; }
[Column("erp_modify_date")]
public DateTime? ErpModifyDate { get; set; }
}
}

@ -204,7 +204,7 @@ namespace Khd.Core.Domain.Models
/// 备用字段3
/// </summary>
[Column("ud1")]
public string ud1 { get; set; }
public int? ud1 { get; set; }
/// <summary>
/// 备用字段3
/// </summary>

@ -204,7 +204,7 @@ namespace Khd.Core.Domain.Models
/// 备用字段3
/// </summary>
[Column("ud1")]
public string ud1 { get; set; }
public int? ud1 { get; set; }
/// <summary>
/// 备用字段3
/// </summary>

@ -0,0 +1,215 @@
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("wcs_task_manual")]
public class WcsTaskManual
{
[Column("from_floor_no")]
public int? fromFloorNo { get; set; }
[Key]
[Column("objid")]
public long objid { get; set; }
/// <summary>
/// wcs_warehouse_order 主键id
/// </summary>
[Column("master_id")]
public long? masterId { get; set; }
/// <summary>
/// wms出入库记录表id
/// </summary>
[Column("order_id")]
public long? orderId { get; set; }
/// <summary>
/// 流水号
/// </summary>
[Column("serial_no")]
public long? serialNo { get; set; }
/// <summary>
/// 设备编号
/// </summary>
[Column("equipment_no")]
public string equipmentNo { get; set; }
/// <summary>
/// 容器号(托盘或者箱号)
/// </summary>
[Column("container_no")]
public string containerNo { get; set; }
/// <summary>
/// 任务类型,字典表
/// 27提升机输送线对接位-验收拆分区
/// 28验收拆分区-原材料周转区
/// 29回转输送线回库口-辅料库货架
/// 30辅料库货架-回转输送线出库口
/// 31回转输送线回库口-辅料库货架
/// 32物料分拣位-装配区领料工位
/// 33原材料周转区-背板安装区
/// 34背板安装区-半成品周转区
/// 35半成品周转区-检测台
/// 37检验台-成品区
/// 38成品区-提升机输送线对接点
/// 46原材料-柜体拆分区
/// 47接驳位-原材料周转区
///
///
/// </summary>
[Column("task_type")]
public int? taskType { get; set; }
/// <summary>
/// 任务状态,字典表
/// </summary>
[Column("task_status")]
public int? taskStatus { get; set; }
/// <summary>
/// 物料ID
/// </summary>
[Column("material_id")]
public long? materialId { get; set; }
/// <summary>
/// 物料号
/// </summary>
[Column("material_no")]
public string? materialNo { get; set; }
/// <summary>
/// 数量
/// </summary>
[Column("qty")]
public int? qty { get; set; }
/// <summary>
/// 起始点编号
/// </summary>
[Column("start_point_no")]
public string startPointNo { get; set; }
/// <summary>
/// 起始点id
/// </summary>
[Column("start_point_id")]
public long? startPointId { get; set; }
/// <summary>
/// 当前点编号
/// </summary>
[Column("curr_point_no")]
public string currPointNo { get; set; }
/// <summary>
/// 当前点id
/// </summary>
[Column("curr_point_id")]
public long? currPointId { get; set; }
/// <summary>
/// 下一点位id
/// </summary>
[Column("next_point_id")]
public long? nextPointId { get; set; }
/// <summary>
/// 下一点位编号
/// </summary>
[Column("next_point_no")]
public string nextPointNo { get; set; }
/// <summary>
/// 结束点编号
/// </summary>
[Column("end_point_no")]
public string endPointNo { get; set; }
/// <summary>
/// 结束点id
/// </summary>
[Column("end_point_id")]
public long? endPointId { get; set; }
/// <summary>
/// 所属楼层
/// </summary>
[Column("floor_no")]
public int? floorNo { get; set; }
/// <summary>
/// 是否可用 0:不可用 1:可用
/// </summary>
[Column("use_flag")]
public int? useFlag { get; set; }
/// <summary>
/// 创建者
/// </summary>
[Column("create_by")]
public string createBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Column("create_time")]
public DateTime? createTime { get; set; }
/// <summary>
/// 更新者
/// </summary>
[Column("update_by")]
public string updateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[Column("update_time")]
public DateTime? updateTime { get; set; }
/// <summary>
/// 备用字段1
/// </summary>
[Column("ctu_execute")]
public string CTUExecute { get; set; }
/// <summary>
/// 备用字段2
/// </summary>
[Column("is_empty")]
public string isEmpty { get; set; }
/// <summary>
/// 备用字段3
/// </summary>
[Column("ud3")]
public string ud3 { get; set; }
/// <summary>
/// 备用字段3
/// </summary>
[Column("ud1")]
public int? ud1 { get; set; }
/// <summary>
/// 备用字段3
/// </summary>
[Column("ud2")]
public string ud2 { get; set; }
/// <summary>
/// 备注
/// </summary>
[Column("remark")]
public string remark { get; set; }
}
}

@ -56,11 +56,11 @@ namespace Khd.Core.Domain.Models
[Column("material_id")]
public long? materialId { get; set; }
/// <summary>
/// 物料批次
/// </summary>
[Column("material_batch")]
public string materialBatch { get; set; }
///// <summary>
///// 物料批次
///// </summary>
//[Column("material_batch")]
//public string materialBatch { get; set; }
/// <summary>
/// 计划出库数量

@ -117,7 +117,8 @@ namespace Khd.Core.Domain.Models
/// </summary>
[Column("create_by")]
public string createBy { get; set; }
[Column("safe_flag")]
public string safeFlag { get; set; }
/// <summary>
/// 创建时间
/// </summary>

@ -9,8 +9,9 @@ namespace Khd.Core.EntityFramework
public DefaultDbContext(DbContextOptions<DefaultDbContext> options) : base(options)
{
}
public DbSet<MesBaseMaterialInfo> MesBaseMaterialInfo { get; set; }
public DbSet<WmsRawReturn> WmsRawReturn { get; set; }
public DbSet<WcsTaskManual> WcsTaskManual { get; set; }
public DbSet<BaseDictionary> BaseDictionary { get; set; }
public DbSet<BaseEquip> BaseEquip { get; set; }

@ -76,6 +76,10 @@ namespace Khd.Core.Plc
{
return Convert.ToString(value);
}
if (len == "10")
{
return Convert.ToBoolean(value);
}
return 0;
}
}

@ -69,10 +69,11 @@ namespace Khd.Core.Wcs
StaticData.PlcDic.TryAdd(plcConfig.Code, plc);
}
}
//////创建任务
//CreateTaskByRecord createTaskByRecord = new(_host, StaticData.PlcDic[0], "");
//createTaskByRecord.StartPoint();
//SystemTimer systemTimer = new SystemTimer(_host);
//systemTimer.Start();
//创建任务
CreateTaskByRecord createTaskByRecord = new(_host, "");
createTaskByRecord.StartPoint();
////一楼提升机以及接驳位
//FirstFloor firstFloor = new(_host, StaticData.PlcDic[0]);
@ -113,14 +114,14 @@ namespace Khd.Core.Wcs
//FiveFloorLine fiveFloorLine = new(_host, StaticData.PlcDic[0], FiveFloorLineEquip.floorNo.Value, FiveFloorLineEquip.equipNo);
//fiveFloorLine.StartPoint();
////五层CTU
//var FiveFloorCTUEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 6).First();
//FiveFloorCTU fiveFloorCTU = new(_host, StaticData.PlcDic[1], FiveFloorCTUEquip.floorNo.Value, FiveFloorCTUEquip.equipNo);
//fiveFloorCTU.StartPoint();
//五层CTU
var FiveFloorCTUEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 6).First();
FiveFloorCTU fiveFloorCTU = new(_host, StaticData.PlcDic[1], FiveFloorCTUEquip.floorNo.Value, FiveFloorCTUEquip.equipNo);
fiveFloorCTU.StartPoint();
////五层AGV
//var FifthFloorAgvEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 5).First();
//FiveFloorAGV fifthFloorAGV = new(_host, StaticData.PlcDic[0], FifthFloorAgvEquip.floorNo.Value, FifthFloorAgvEquip.equipNo);
//FiveFloorAGV fifthFloorAGV = new(_host, StaticData.PlcDic[2], FifthFloorAgvEquip.floorNo.Value, FifthFloorAgvEquip.equipNo);
//fifthFloorAGV.StartPoint();
//var FifthFloorBearAgvEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 11).First();

@ -9,9 +9,9 @@ namespace Khd.Core.Wcs
{
public class SystemData
{
public static long _serialNo { get; set; } = 1;
private static long _serialNo { get; set; } = 1;
public static object serialLock = new object();
private static object serialLock = new object();
public static long GetSerialNo(DefaultDbContext dbContext)
{
@ -29,6 +29,6 @@ namespace Khd.Core.Wcs
return _serialNo;
}
}
public static object outStockLock = new object();
}
}

@ -22,7 +22,6 @@ namespace Khd.Core.Wcs.Wcs
public class CreateTaskByRecord
{
private readonly IHost _host;
private readonly Plc.S7.Plc _plc;
List<BasePlcpoint> ScanPoint { get; set; }//点位信息
private BaseSitenode? sitenode { get; set; }//站台信息
@ -33,10 +32,9 @@ namespace Khd.Core.Wcs.Wcs
private NodeSetting? NodeSettingWcsSend { get; set; }
private NodeSetting? NodeSettingWcsSendMaterial { get; set; }
private NodeSetting? NodeSettingPLCSendSendMaterialstate { get; set; }
public CreateTaskByRecord(IHost host, Plc.S7.Plc plc, string siteNo)
public CreateTaskByRecord(IHost host, string siteNo)
{
this._host = host;
this._plc = plc;
this.ScanPoint = StaticData.BasePlcpointList.ToList();//加载当前站点所对应的点位
this.sitenode = StaticData.SiteNodeList.FirstOrDefault(t => t.siteNo == siteNo);//获取当前站台信息
//this.NodeSettingCarNo = this.ScanPoint.FirstOrDefault(t => t.plcpointNo.Contains("carno"));
@ -64,20 +62,20 @@ namespace Khd.Core.Wcs.Wcs
/// </summary>
public void StartPoint()
{
var createBearAgvReturnThread = new Thread(CreateBearAgvReturnLogic);
createBearAgvReturnThread.Start();
//var createBearAgvReturnThread = new Thread(CreateBearAgvReturnLogic);
//createBearAgvReturnThread.Start();
var createRawInWareTaskThread = new Thread(CreateRawInWareTaskLogic);
createRawInWareTaskThread.Start();
//var createRawInWareTaskThread = new Thread(CreateRawInWareTaskLogic);
//createRawInWareTaskThread.Start();
var createFiveProductTaskThread = new Thread(CreateFiveProductTaskLogic);
createFiveProductTaskThread.Start();
//var createFiveProductTaskThread = new Thread(CreateFiveProductTaskLogic);
//createFiveProductTaskThread.Start();
var createRawTaskThread = new Thread(CreateRawTaskLogic);
createRawTaskThread.Start();
var createThirdOutTaskThread = new Thread(CreateThirdOutTaskLogic);
createThirdOutTaskThread.Start();
//var createThirdOutTaskThread = new Thread(CreateThirdOutTaskLogic);
//createThirdOutTaskThread.Start();
Console.WriteLine(DateTime.Now + ":出库任务监听启动成功");
LogManager.Info("出库任务监听启动成功");
@ -293,7 +291,7 @@ namespace Khd.Core.Wcs.Wcs
floorNo = 5,
masterId = wmsRawReturn.materialId,
fromFloorNo = 5,
materialNo = wmsRawReturn.materialBatch,
//materialNo = wmsRawReturn.materialBatch,
};
wmsRawReturn.executeStatus = "1";
dbContext.Add(wcsTask);
@ -449,7 +447,7 @@ namespace Khd.Core.Wcs.Wcs
location.updateBy = "WCS";
location.updateTime = DateTime.Now;
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.barcodeInfo == stock.productBatch).FirstOrDefault();
if(mesBaseBarcodeInfo != null)
if (mesBaseBarcodeInfo != null)
{
WmsProductOutstockDetail wmsProductOutstockDetail = new WmsProductOutstockDetail()
{
@ -464,7 +462,7 @@ namespace Khd.Core.Wcs.Wcs
planAmount = item.applyQty,
warehouseId = item.warehouseId,
productBatch = mesBaseBarcodeInfo.batchCode,
productBarcode=mesBaseBarcodeInfo.barcodeInfo
productBarcode = mesBaseBarcodeInfo.barcodeInfo
};
dbContext.Add(wmsProductOutstockDetail);
dbContext.Update(location);
@ -475,9 +473,9 @@ namespace Khd.Core.Wcs.Wcs
{
break;
}
}
}
}
if (item.beginTime == null)
{
item.beginTime = DateTime.Now;
@ -514,242 +512,150 @@ namespace Khd.Core.Wcs.Wcs
.Where(t => t.outstockAmount > t.realOutstockAmount)
.Where(t => t.auditStatus == "1")
.ToList();
List<WcsTaskManual> wcsTaskManuals = dbContext.WcsTaskManual.OrderBy(t => t.createBy).ToList();
if (wcsTaskManuals.Count > 0)
{
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
int taskCount = dbContext.WcsTask.Where(t => t.nextPointId == 11).Count();
if (taskCount == 0 && wcsOutstockLock.qty == 0 && wcsOutstockLock.boxStatus == 0)
{
foreach (var wcs in wcsTaskManuals.Take(6))
{
WcsTask wcsTask = CoreMapper.Map<WcsTask>(wcs);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
wcsOutstockLock.qty += 1;
wcsOutstockLock.boxStatus = 1;
dbContext.Update(wcsOutstockLock);
dbContext.Add(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.WcsTaskManual.Where(t => t.objid == wcs.objid).Delete();
}
dbContext.SaveChanges();
}
}
foreach (var item in rawOutStock)
{
decimal? RealOutNumber = item.realOutstockAmount;
var endEquip = StaticData.BaseEquip.FirstOrDefault(t => t.equipNo == item.endStationCode);
if (endEquip != null && endEquip.floorNo == 5)
{
if (endEquip.equipType == 8)//CTU出库
lock (SystemData.outStockLock)
{
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
if (wcsOutstockLock.qty == 0 && wcsOutstockLock.boxStatus == 0)
if (endEquip.equipType == 8)//CTU出库
{
var wmsRawStocks = rawStock
.Where(t => t.materialId == item.materialId)
.Where(t => t.warehouseId == item.warehouseId)
.Select(t => t.locationCode)
.ToList();
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.instockFlag == "0")
.Where(t => t.outstockFlag == "0")
.Where(t => t.ContainerStatus == "1")
.Where(t => t.warehouseId == item.warehouseId)
.Where(t => wmsRawStocks.Contains(t.locationCode))
.ToList();
decimal? needNumber = item.outstockAmount - RealOutNumber;
var bill = from a in wmsBaseLocations
from b in rawStock
where a.locationCode == b.locationCode
select new { a, b };
//如果第一列满足需求,则按第一列排序,否则按最后一列排序
if (bill.Where(t => t.a.locColumn == 1).Select(t => t.b.totalAmount - t.b.occupyAmount - t.b.frozenAmount).Sum() > needNumber)
var wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
if (wcsOutstockLock.qty == 0 && wcsOutstockLock.boxStatus == 0)
{
bill = bill.OrderBy(t => t.a.locColumn).ToList();
}
else
{
bill = bill.OrderByDescending(t => t.a.locColumn).ToList();
}
//做数量限制
var wmsRawStocks = rawStock
.Where(t => t.materialId == item.materialId)
.Where(t => t.warehouseId == item.warehouseId)
.Select(t => t.locationCode)
.ToList();
//bill = bill.Take(5 - dbContext.WcsCmd.Where(t => t.cmdStatus < 3 && t.nextPointId == 20).Count());
bill = bill.Take(6);
BaseEquip ctuEquip = StaticData.BaseEquip.First(t => t.objid == 11);
BaseEquip lineEquip = StaticData.BaseEquip.First(t => t.objid == 20);
foreach (var b in bill)
{
needNumber = item.outstockAmount - RealOutNumber;
item.executeStatus = "1";
WmsBaseLocation location = b.a;
WmsRawStock stock = b.b;
WcsTask wcsTask;
int qty = 0;
int outNumber = 0;
if (stock.totalAmount - stock.occupyAmount - stock.frozenAmount <= needNumber)//该料箱全部出
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.instockFlag == "0")
.Where(t => t.outstockFlag == "0")
.Where(t => t.ContainerStatus == "1")
.Where(t => t.warehouseId == item.warehouseId)
.Where(t => wmsRawStocks.Contains(t.locationCode))
.ToList();
decimal? needNumber = item.outstockAmount - RealOutNumber;
var bill = from a in wmsBaseLocations
from b in rawStock
where a.locationCode == b.locationCode
select new { a, b };
//如果第一列满足需求,则按第一列排序,否则按最后一列排序
if (bill.Where(t => t.a.locColumn == 1).Select(t => t.b.totalAmount - t.b.occupyAmount - t.b.frozenAmount).Sum() > needNumber)
{
RealOutNumber += stock.totalAmount - stock.occupyAmount - stock.frozenAmount;
outNumber = Convert.ToInt32(stock.totalAmount - stock.occupyAmount - stock.frozenAmount);
qty = Convert.ToInt32(stock.totalAmount - stock.frozenAmount);
stock.updateDate = DateTime.Now;
bill = bill.OrderBy(t => t.a.locColumn).ToList();
}
else
{
RealOutNumber += needNumber;
outNumber = Convert.ToInt32(needNumber);
qty = Convert.ToInt32(needNumber);
stock.updateDate = DateTime.Now;
bill = bill.OrderByDescending(t => t.a.locColumn).ToList();
}
wcsTask = new WcsTask()
{
objid = StaticData.SnowId.NextId(),
orderId = item.rawOutstockId,
taskType = 38,
containerNo = location.containerCode,
createBy = "WCS",
createTime = DateTime.Now,
taskStatus = 0,
materialId = item.materialId,
currPointId = location.locationId,
currPointNo = location.locationCode,
startPointId = location.locationId,
startPointNo = location.locationCode,
nextPointId = ctuEquip.objid,
nextPointNo = ctuEquip.equipNo,
endPointId = lineEquip.objid,
endPointNo = lineEquip.equipNo,
equipmentNo = ctuEquip.equipNo,
useFlag = 1,
qty = outNumber
};
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.barcodeInfo == stock.instockBatch).FirstOrDefault();
if (mesBaseBarcodeInfo != null)
{
WmsRawOutstockDetail wmsProductOutstockDetail = new WmsRawOutstockDetail()
{
rawOutstockDetailId = StaticData.SnowId.NextId(),
rawOutstockId = item.rawOutstockId,
materialId = item.materialId,
createDate = DateTime.Now,
createBy = "WCS",
taskCode = wcsTask.objid.ToString(),
executeStatus = "1",
locationCode = location.locationCode,
outstockAmount = qty,
planAmount = item.outstockAmount,
warehouseId = item.warehouseId,
materialBarcode= mesBaseBarcodeInfo.barcodeInfo,
instockBatch=mesBaseBarcodeInfo.batchCode
};
dbContext.Add(wmsProductOutstockDetail);
location.outstockFlag = "1";
location.locationStatus = "6";
location.updateBy = "WCS";
location.updateTime = DateTime.Now;
wcsOutstockLock.boxStatus = 1;
dbContext.Update(location);
dbContext.Add(wcsTask);
dbContext.Update(stock);
dbContext.SaveChanges();
if (qty >= needNumber)
{
break;
}
}
}
if (item.beginTime == null)
{
item.beginTime = DateTime.Now;
}
dbContext.Update(wcsOutstockLock);
dbContext.Update(item);
dbContext.SaveChanges();
}
}//CTU出库
else if (endEquip.equipType == 10)//CTU出库到装配区
{
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock
.Where(t => t.warehouseId == 512)
.First();
if (wcsOutstockLock.qty == 0 && wcsOutstockLock.boxStatus == 0)
{
var orderList = rawOutStock.Where(t => t.endStationCode == item.endStationCode).ToList();
foreach (var order in orderList)
{
decimal? RealOutNummber = order.realOutstockAmount;
WcsTask? task = dbContext.WcsTask.FirstOrDefault(t => t.taskType == 32);
if (task == null)
{
var wmsRawStocks = rawStock
.Where(t => t.materialId == order.materialId && t.warehouseId == order.warehouseId)
.Select(t => t.palletInfoCode)
.ToList();
//做数量限制
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.instockFlag == "0")
.Where(t => t.outstockFlag == "0")
.Where(t => t.warehouseId == order.warehouseId)
.Where(t => wmsRawStocks.Contains(t.containerCode))
.ToList();
decimal? needNumber = order.outstockAmount - RealOutNummber;
var bill = from a in wmsBaseLocations
from b in rawStock
where a.containerCode == b.palletInfoCode
select new { a, b };
//如果第一列满足需求,则按第一列排序,否则按最后一列排序
if (bill.Where(t => t.a.locColumn == 1).Select(t => t.b.totalAmount - t.b.occupyAmount - t.b.frozenAmount).Sum() > needNumber)
//bill = bill.Take(5 - dbContext.WcsCmd.Where(t => t.cmdStatus < 3 && t.nextPointId == 20).Count());
bill = bill.Take(6);
BaseEquip ctuEquip = StaticData.BaseEquip.First(t => t.objid == 11);
BaseEquip lineEquip = StaticData.BaseEquip.First(t => t.objid == 20);
foreach (var b in bill)
{
needNumber = item.outstockAmount - RealOutNumber;
item.executeStatus = "1";
WmsBaseLocation location = b.a;
WmsRawStock stock = b.b;
WcsTask wcsTask;
int qty = 0;
int outNumber = 0;
if (stock.totalAmount - stock.occupyAmount - stock.frozenAmount <= needNumber)//该料箱全部出
{
bill = bill.OrderBy(t => t.a.locColumn).ToList();
RealOutNumber += stock.totalAmount - stock.occupyAmount - stock.frozenAmount;
outNumber = Convert.ToInt32(stock.totalAmount - stock.occupyAmount - stock.frozenAmount);
qty = Convert.ToInt32(stock.totalAmount - stock.frozenAmount);
stock.updateDate = DateTime.Now;
}
else
{
bill = bill.OrderByDescending(t => t.a.locColumn).ToList();
RealOutNumber += needNumber;
outNumber = Convert.ToInt32(needNumber);
qty = Convert.ToInt32(needNumber);
stock.updateDate = DateTime.Now;
}
//做数量限制
bill = bill.Take(5 - dbContext.WcsCmd.Where(t => t.cmdStatus < 3 && t.nextPointId == 20).Count());
BaseEquip ctuEquip = StaticData.BaseEquip.First(t => t.objid == 11);
BaseEquip lineEquip = StaticData.BaseEquip.First(t => t.objid == 20);
foreach (var b in bill)
wcsTask = new WcsTask()
{
item.executeStatus = "1";
WmsBaseLocation location = b.a;
WmsRawStock stock = b.b;
WcsTask wcsTask;
int qty = 0;
if (stock.totalAmount - stock.occupyAmount - stock.frozenAmount <= needNumber)//该料箱全部出
objid = StaticData.SnowId.NextId(),
orderId = item.rawOutstockId,
taskType = 38,
containerNo = location.containerCode,
createBy = "WCS",
createTime = DateTime.Now,
taskStatus = -1,
materialId = item.materialId,
currPointId = location.locationId,
currPointNo = location.locationCode,
startPointId = location.locationId,
startPointNo = location.locationCode,
nextPointId = ctuEquip.objid,
nextPointNo = ctuEquip.equipNo,
endPointId = lineEquip.objid,
endPointNo = lineEquip.equipNo,
equipmentNo = ctuEquip.equipNo,
ud1 = location.locColumn,
useFlag = 1,
qty = outNumber
};
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.barcodeInfo == stock.instockBatch).FirstOrDefault();
if (mesBaseBarcodeInfo != null)
{
WmsRawOutstockDetail wmsProductOutstockDetail = new WmsRawOutstockDetail()
{
RealOutNummber += stock.totalAmount - stock.occupyAmount - stock.frozenAmount;
qty = Convert.ToInt32(stock.totalAmount - stock.frozenAmount);
stock.occupyAmount += qty;
stock.updateDate = DateTime.Now;
}
else
{
RealOutNummber += needNumber;
stock.occupyAmount += needNumber;
qty = Convert.ToInt32(needNumber);
stock.updateDate = DateTime.Now;
}
wcsTask = new WcsTask()
{
objid = StaticData.SnowId.NextId(),
orderId = item.rawOutstockId,
taskType = 38,
containerNo = location.containerCode,
createBy = "WCS",
createTime = DateTime.Now,
taskStatus = 0,
rawOutstockDetailId = StaticData.SnowId.NextId(),
rawOutstockId = item.rawOutstockId,
materialId = item.materialId,
currPointId = location.locationId,
currPointNo = location.locationCode,
startPointId = location.locationId,
startPointNo = location.locationCode,
nextPointId = ctuEquip.objid,
nextPointNo = ctuEquip.equipNo,
endPointId = lineEquip.objid,
endPointNo = lineEquip.equipNo,
equipmentNo = ctuEquip.equipNo,
useFlag = 1,
qty = qty
createDate = DateTime.Now,
createBy = "WCS",
taskCode = wcsTask.objid.ToString(),
executeStatus = "1",
locationCode = location.locationCode,
outstockAmount = qty,
planAmount = item.outstockAmount,
warehouseId = item.warehouseId,
materialBarcode = mesBaseBarcodeInfo.barcodeInfo,
instockBatch = mesBaseBarcodeInfo.batchCode
};
dbContext.Add(wmsProductOutstockDetail);
location.outstockFlag = "1";
location.locationStatus = "6";
location.updateBy = "WCS";
location.updateTime = DateTime.Now;
wcsOutstockLock.qty += 1;
dbContext.Update(wcsOutstockLock);
wcsOutstockLock.boxStatus = 1;
dbContext.Update(location);
dbContext.Add(wcsTask);
dbContext.Update(stock);
@ -760,156 +666,284 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
BaseEquip startStationEquip = StaticData.BaseEquip.First(t => t.objid == 21);
BaseEquip bearAgvEquip = StaticData.BaseEquip.First(t => t.objid == 10);
BaseEquip endStationEquip = StaticData.BaseEquip.First(t => t.equipNo == item.endStationCode);
WcsTask bearAgvTask = new()
{
objid = StaticData.SnowId.NextId(),
orderId = item.orderId,
taskType = 32,
containerNo = "",
startPointId = startStationEquip.objid,
startPointNo = startStationEquip.equipNo,
currPointId = startStationEquip.objid,
currPointNo = startStationEquip.equipNo,
nextPointId = bearAgvEquip.objid,
nextPointNo = bearAgvEquip.equipNo,
endPointId = endStationEquip.objid,
endPointNo = endStationEquip.equipNo,
serialNo = SystemData.GetSerialNo(dbContext),
taskStatus = 0,
createTime = DateTime.Now,
createBy = "WCS",
materialId = item.materialId,
qty = 1,
useFlag = 0,
equipmentNo = startStationEquip.equipNo,
remark = "组装出库",
floorNo = 5,
masterId = item.materialId,
fromFloorNo = 5,
materialNo = item.materialBatch,
};
if (item.beginTime == null)
{
item.beginTime = DateTime.Now;
}
wcsOutstockLock.boxStatus = 1;
dbContext.Update(wcsOutstockLock);
dbContext.Add(bearAgvTask);
dbContext.Update(item);
dbContext.SaveChanges();
}
}//CTU出库
if (endEquip.equipType == 10)//CTU出库到装配区
{
bool CreateSuccess = false;
var wcsOutstockLock = dbContext.WcsOutstockLock
.Where(t => t.warehouseId == 512)
.First();
if (wcsOutstockLock.qty == 0 && wcsOutstockLock.boxStatus == 0)
{
var orderList = rawOutStock.Where(t => t.endStationCode == item.endStationCode).ToList();
foreach (var order in orderList)
{
decimal? RealOutNummber = order.realOutstockAmount;
WcsTask? task = dbContext.WcsTask.FirstOrDefault(t => t.taskType == 32);
if (task == null)
{
var wmsRawStocks = rawStock
.Where(t => t.materialId == order.materialId && t.warehouseId == order.warehouseId)
.Select(t => t.palletInfoCode)
.ToList();
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.instockFlag == "0")
.Where(t => t.outstockFlag == "0")
.Where(t => t.warehouseId == order.warehouseId)
.Where(t => wmsRawStocks.Contains(t.containerCode))
.ToList();
decimal? needNumber = order.outstockAmount - RealOutNummber;
var bill = from a in wmsBaseLocations
from b in rawStock
where a.containerCode == b.palletInfoCode
select new { a, b };
//如果第一列满足需求,则按第一列排序,否则按最后一列排序
if (bill.Where(t => t.a.locColumn == 1).Select(t => t.b.totalAmount - t.b.occupyAmount - t.b.frozenAmount).Sum() > needNumber)
{
bill = bill.OrderBy(t => t.a.locColumn).ToList();
}
else
{
bill = bill.OrderByDescending(t => t.a.locColumn).ToList();
}
//做数量限制
bill = bill.Take(5 - dbContext.WcsCmd.Where(t => t.cmdStatus < 3 && t.nextPointId == 20).Count());
BaseEquip ctuEquip = StaticData.BaseEquip.First(t => t.objid == 11);
BaseEquip lineEquip = StaticData.BaseEquip.First(t => t.objid == 20);
foreach (var b in bill)
{
item.executeStatus = "1";
WmsBaseLocation location = b.a;
WmsRawStock stock = b.b;
WcsTask wcsTask;
int qty = 0;
if (stock.totalAmount - stock.occupyAmount - stock.frozenAmount <= needNumber)//该料箱全部出
{
RealOutNummber += stock.totalAmount - stock.occupyAmount - stock.frozenAmount;
qty = Convert.ToInt32(stock.totalAmount - stock.frozenAmount);
stock.occupyAmount += qty;
stock.updateDate = DateTime.Now;
}
else
{
RealOutNummber += needNumber;
stock.occupyAmount += needNumber;
qty = Convert.ToInt32(needNumber);
stock.updateDate = DateTime.Now;
}
wcsTask = new WcsTask()
{
objid = StaticData.SnowId.NextId(),
orderId = item.rawOutstockId,
taskType = 30,
containerNo = location.containerCode,
createBy = "WCS",
createTime = DateTime.Now,
taskStatus = 0,
materialId = item.materialId,
currPointId = location.locationId,
currPointNo = location.locationCode,
startPointId = location.locationId,
startPointNo = location.locationCode,
nextPointId = ctuEquip.objid,
nextPointNo = ctuEquip.equipNo,
endPointId = lineEquip.objid,
endPointNo = lineEquip.equipNo,
equipmentNo = ctuEquip.equipNo,
ud1 = location.locColumn,
useFlag = 0,
qty = qty
};
location.outstockFlag = "1";
location.locationStatus = "6";
location.updateBy = "WCS";
location.updateTime = DateTime.Now;
wcsOutstockLock.qty += 1;
wcsOutstockLock.boxStatus = 1;
dbContext.Update(wcsOutstockLock);
dbContext.Update(location);
dbContext.Add(wcsTask);
dbContext.Update(stock);
dbContext.SaveChanges();
CreateSuccess = true;
if (qty >= needNumber)
{
break;
}
}
}
if (CreateSuccess)
{
BaseEquip startStationEquip = StaticData.BaseEquip.First(t => t.objid == 21);
BaseEquip bearAgvEquip = StaticData.BaseEquip.First(t => t.objid == 10);
BaseEquip endStationEquip = StaticData.BaseEquip.First(t => t.equipNo == item.endStationCode);
WcsTask bearAgvTask = new()
{
objid = StaticData.SnowId.NextId(),
orderId = item.orderId,
taskType = 32,
containerNo = "",
startPointId = startStationEquip.objid,
startPointNo = startStationEquip.equipNo,
currPointId = startStationEquip.objid,
currPointNo = startStationEquip.equipNo,
nextPointId = bearAgvEquip.objid,
nextPointNo = bearAgvEquip.equipNo,
endPointId = endStationEquip.objid,
endPointNo = endStationEquip.equipNo,
serialNo = SystemData.GetSerialNo(dbContext),
taskStatus = 0,
createTime = DateTime.Now,
createBy = "WCS",
materialId = item.materialId,
qty = 1,
useFlag = 1,
equipmentNo = startStationEquip.equipNo,
remark = "组装出库",
floorNo = 5,
masterId = item.materialId,
fromFloorNo = 5,
materialNo = item.materialBatch,
};
if (item.beginTime == null)
{
item.beginTime = DateTime.Now;
}
dbContext.Add(bearAgvTask);
dbContext.Update(item);
dbContext.SaveChanges();
}
}
}
}
}
else if (endEquip.equipType == 12 || endEquip.equipType == 13)//原材料到柜体验收区
if (endEquip.equipType == 12 || endEquip.equipType == 13)//原材料到柜体验收区
{
var wmsRawStocks = rawStock
.Where(t => t.materialId == item.materialId && t.warehouseId == item.warehouseId)
.WhereIf(endEquip.equipType == 13, t => t.completeFlag == "0")
.WhereIf(endEquip.equipType == 12, t => t.completeFlag == "1")
.Select(t => t.palletInfoCode)
.ToList();
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.instockFlag == "0")
.Where(t => t.outstockFlag == "0")
.Where(t => t.warehouseId == item.warehouseId)
.Where(t => wmsRawStocks.Contains(t.containerCode))
.ToList();
decimal? needNumber = item.outstockAmount - item.realOutstockAmount;
if (needNumber <= 0)
if (endEquip.emptyCount == 0)
{
item.executeStatus = "2";
dbContext.Update(item);
dbContext.SaveChanges();
continue;
}
var wmsRawStocks = rawStock
.Where(t => t.materialId == item.materialId && t.warehouseId == item.warehouseId)
.WhereIf(endEquip.equipType == 13, t => t.completeFlag == "0")
.WhereIf(endEquip.equipType == 12, t => t.completeFlag == "1")
.Where(t => t.totalAmount > t.occupyAmount + t.frozenAmount)
.Select(t => t.palletInfoCode)
.ToList();
var bill = from a in wmsBaseLocations
from b in rawStock
where a.containerCode == b.palletInfoCode
select new { a, b };
//如果第一列满足需求,则按第一列排序,否则按最后一列排序
if (bill.Where(t => t.a.locColumn == 1).Select(t => t.b.totalAmount - t.b.occupyAmount - t.b.frozenAmount).Sum() > needNumber)
{
bill = bill.OrderBy(t => t.a.locColumn).Take(1).ToList();
}
else
{
bill = bill.OrderByDescending(t => t.a.locColumn).Take(1).ToList();
}
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.instockFlag == "0")
.Where(t => t.outstockFlag == "0")
.Where(t => t.warehouseId == item.warehouseId)
.Where(t => wmsRawStocks.Contains(t.containerCode))
.ToList();
BaseEquip bearAgvEquip = StaticData.BaseEquip.First(t => t.objid == 10);
BaseEquip lineEquip = StaticData.BaseEquip.First(t => t.equipNo == item.endStationCode);
foreach (var b in bill)
{
item.executeStatus = "1";
WmsBaseLocation location = b.a;
WmsRawStock stock = b.b;
WcsTask wcsTask;
int qty = 0;
if (stock.totalAmount - stock.occupyAmount - stock.frozenAmount <= needNumber)//该料箱全部出
decimal? needNumber = item.outstockAmount - item.realOutstockAmount;
if (needNumber <= 0)
{
item.realOutstockAmount += stock.totalAmount - stock.occupyAmount - stock.frozenAmount;
qty = Convert.ToInt32(stock.totalAmount - stock.frozenAmount);
stock.occupyAmount += qty;
stock.updateDate = DateTime.Now;
item.executeStatus = "2";
dbContext.Update(item);
dbContext.SaveChanges();
continue;
}
var bill = from a in wmsBaseLocations
from b in rawStock
where a.containerCode == b.palletInfoCode
select new { a, b };
//如果第一列满足需求,则按第一列排序,否则按最后一列排序
if (bill.Where(t => t.a.locColumn == 1).Select(t => t.b.totalAmount - t.b.occupyAmount - t.b.frozenAmount).Sum() > needNumber)
{
bill = bill.OrderBy(t => t.a.locColumn).Take(1).ToList();
}
else
{
item.realOutstockAmount += needNumber;
stock.occupyAmount += needNumber;
qty = Convert.ToInt32(needNumber);
stock.updateDate = DateTime.Now;
bill = bill.OrderByDescending(t => t.a.locColumn).Take(1).ToList();
}
wcsTask = new WcsTask()
BaseEquip bearAgvEquip = StaticData.BaseEquip.First(t => t.objid == 28);
BaseEquip lineEquip = StaticData.BaseEquip.First(t => t.equipNo == item.endStationCode);
foreach (var b in bill)
{
objid = StaticData.SnowId.NextId(),
orderId = item.rawOutstockId,
taskType = endEquip.equipType == 12 ? 46 : 33,//如果是12那么就是原材料到柜体验收区,如果是13那么就是原材料到背板安装区
containerNo = location.containerCode,
createBy = "WCS",
createTime = DateTime.Now,
taskStatus = 0,
materialId = item.materialId,
currPointId = location.locationId,
currPointNo = location.locationCode,
startPointId = location.locationId,
startPointNo = location.locationCode,
nextPointId = bearAgvEquip.objid,
nextPointNo = bearAgvEquip.equipNo,
endPointId = lineEquip.objid,
endPointNo = lineEquip.equipNo,
equipmentNo = bearAgvEquip.equipNo,
useFlag = 1,
qty = qty
};
location.outstockFlag = "1";
location.locationStatus = "6";
location.updateBy = "WCS";
location.updateTime = DateTime.Now;
dbContext.Update(location);
dbContext.Add(wcsTask);
dbContext.Update(stock);
item.executeStatus = "1";
WmsBaseLocation location = b.a;
WmsRawStock stock = b.b;
WcsTask wcsTask;
int qty = 0;
if (stock.totalAmount - stock.occupyAmount - stock.frozenAmount <= needNumber)//该料箱全部出
{
item.realOutstockAmount += stock.totalAmount - stock.occupyAmount - stock.frozenAmount;
qty = Convert.ToInt32(stock.totalAmount - stock.frozenAmount);
stock.occupyAmount += qty;
stock.updateDate = DateTime.Now;
}
else
{
item.realOutstockAmount += needNumber;
stock.occupyAmount += needNumber;
qty = Convert.ToInt32(needNumber);
stock.updateDate = DateTime.Now;
}
wcsTask = new WcsTask()
{
objid = StaticData.SnowId.NextId(),
orderId = item.rawOutstockId,
taskType = endEquip.equipType == 12 ? 46 : 33,//如果是12那么就是原材料到柜体验收区,如果是13那么就是原材料到背板安装区
containerNo = location.containerCode,
createBy = "WCS",
createTime = DateTime.Now,
taskStatus = 0,
materialId = item.materialId,
currPointId = location.locationId,
currPointNo = location.locationCode,
startPointId = location.locationId,
startPointNo = location.locationCode,
nextPointId = bearAgvEquip.objid,
nextPointNo = bearAgvEquip.equipNo,
endPointId = lineEquip.objid,
endPointNo = lineEquip.equipNo,
equipmentNo = bearAgvEquip.equipNo,
useFlag = 1,
qty = qty
};
location.outstockFlag = "1";
location.locationStatus = "6";
location.updateBy = "WCS";
location.updateTime = DateTime.Now;
endEquip.emptyCount = 1;
dbContext.Update(endEquip);
dbContext.Update(location);
dbContext.Add(wcsTask);
dbContext.Update(stock);
dbContext.SaveChanges();
if (qty >= needNumber)
{
break;
}
}
if (item.beginTime == null)
{
item.beginTime = DateTime.Now;
}
dbContext.Update(item);
dbContext.SaveChanges();
if (qty >= needNumber)
{
break;
}
}
if (item.beginTime == null)
{
item.beginTime = DateTime.Now;
}
dbContext.Update(item);
dbContext.SaveChanges();
}
}
}

@ -27,6 +27,7 @@ namespace Khd.Core.Wcs.Wcs
/// 一楼RFID 读
/// </summary>
private readonly BasePlcpoint RFID001;
private readonly BasePlcpoint automatic;
/// <summary>
/// 到位信号 读
/// </summary>
@ -74,6 +75,7 @@ namespace Khd.Core.Wcs.Wcs
//一楼提升机流水号 读
this.serialno06 = StaticData.BasePlcpointList.First(t => t.equipmentNo.Contains("Hoister") && t.plcpointNo.Contains("serialno06"));
this.automatic = StaticData.BasePlcpointList.First(t => t.equipmentNo.Contains("Hoister") && t.plcpointNo.Contains("automatic"));
//一楼提升机状态 读
this.equipstate06 = StaticData.BasePlcpointList.First(t => t.equipmentNo.Contains("Hoister") && t.plcpointNo.Contains("equipstate06"));
//一楼提升机任务状态 读
@ -288,144 +290,148 @@ namespace Khd.Core.Wcs.Wcs
{
try
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var serialno06Value = this._plc.Read(this.serialno06.plcpointAddress); //提升机流水号 读
var equipstate06Value = this._plc.Read(this.equipstate06.plcpointAddress); //提升机状态 读
var hoisterTrayIn06Value = this._plc.Read(this.hoistertrayin06.plcpointAddress); //提升机货物到位状态 读
var currentfloor06Value = this._plc.Read(this.currentfloor06.plcpointAddress); //提升机当前楼层 读
var targetfloor06Value = this._plc.Read(this.targetfloor06.plcpointAddress); //提升机目的楼层 写
var reserialno06 = this._plc.Read(this.reserialno06.plcpointAddress); //反馈流水号
var canwritewcsrun06value = this._plc.Read(this.canwritewcsrun06.plcpointAddress);
//正常读到plc值
if (targetfloor06Value != null && canwritewcsrun06value != null && serialno06Value != null && equipstate06Value != null && currentfloor06Value != null && reserialno06 != null && hoisterTrayIn06Value != null)
var automatic06Value = this._plc.Read(this.automatic.plcpointAddress);//提升机自动状态
if (automatic06Value != null && Convert.ToInt32(automatic06Value) == 1)
{
//提升机空闲
if (Convert.ToInt32(equipstate06Value) == 0)
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var serialno06Value = this._plc.Read(this.serialno06.plcpointAddress); //提升机流水号 读
var equipstate06Value = this._plc.Read(this.equipstate06.plcpointAddress); //提升机状态 读
var hoisterTrayIn06Value = this._plc.Read(this.hoistertrayin06.plcpointAddress); //提升机货物到位状态 读
var currentfloor06Value = this._plc.Read(this.currentfloor06.plcpointAddress); //提升机当前楼层 读
var targetfloor06Value = this._plc.Read(this.targetfloor06.plcpointAddress); //提升机目的楼层 写
var reserialno06 = this._plc.Read(this.reserialno06.plcpointAddress); //反馈流水号
var canwritewcsrun06value = this._plc.Read(this.canwritewcsrun06.plcpointAddress);
//正常读到plc值
if (targetfloor06Value != null && canwritewcsrun06value != null && serialno06Value != null && equipstate06Value != null && currentfloor06Value != null && reserialno06 != null && hoisterTrayIn06Value != null)
{
var wcsTasks = dbContext.WcsTask.Where(t => t.nextPointId == T01).OrderBy(t => t.createTime).ToList();
foreach (var wcsTask in wcsTasks)
//提升机空闲
if (Convert.ToInt32(equipstate06Value) == 0)
{
if (wcsTasks.Where(t => t.taskStatus > 0).Where(t => t.objid != wcsTask.objid).Any())
var wcsTasks = dbContext.WcsTask.Where(t => t.nextPointId == T01).OrderBy(t => t.createTime).ToList();
foreach (var wcsTask in wcsTasks)
{
LogManager.Info("提升机线程:有其他任务正在执行,跳过当前任务");
continue;
}
BaseEquip lineEquip = StaticData.BaseEquip.First(t => t.objid == wcsTask.floorNo);
if (wcsTask.taskStatus == 0 && Convert.ToInt32(hoisterTrayIn06Value) == 0)//创建状态,并且里面没有货物
{
if (lineEquip.equipStatus == 1)
if (wcsTasks.Where(t => t.taskStatus > 0).Where(t => t.objid != wcsTask.objid).Any())
{
LogManager.Info("提升机线程:" + wcsTask.floorNo + "楼接驳位有AGV任务,跳过当前任务");
LogManager.Info("提升机线程:有其他任务正在执行,跳过当前任务");
continue;
}
BasePlcpoint floorPoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "RFID00" + wcsTask.fromFloorNo);
if (wcsTask.containerNo == this._plc.ReadRFID(floorPoint.plcpointAddress))
BaseEquip lineEquip = StaticData.BaseEquip.First(t => t.objid == wcsTask.floorNo);
if (wcsTask.taskStatus == 0 && Convert.ToInt32(hoisterTrayIn06Value) == 0)//创建状态,并且里面没有货物
{
if (Convert.ToInt32(currentfloor06Value) == wcsTask.fromFloorNo)
if (lineEquip.equipStatus == 1)
{
if (Convert.ToInt32(canwritewcsrun06value) == 0)
LogManager.Info("提升机线程:" + wcsTask.floorNo + "楼接驳位有AGV任务跳过当前任务");
continue;
}
BasePlcpoint floorPoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "RFID00" + wcsTask.fromFloorNo);
if (wcsTask.containerNo == this._plc.ReadRFID(floorPoint.plcpointAddress))
{
if (Convert.ToInt32(currentfloor06Value) == wcsTask.fromFloorNo)
{
wcsTask.taskStatus = 2;
if (Convert.ToInt32(canwritewcsrun06value) == 0)
{
wcsTask.taskStatus = 2;
wcsTask.updateBy = "提升机线程";
wcsTask.updateTime = DateTime.Now;
wcsTask.remark = "提升机任务执行中";
BasePlcpoint basePlcpoint = StaticData.BasePlcpointList.First(t => t.floorNo == wcsTask.fromFloorNo && t.plcpointNo.Contains("wcsrun"));
this._plc.WriteToPoint(basePlcpoint.plcpointAddress, "1", basePlcpoint.plcpointLength.ToString());
this._plc.WriteToPoint(this.serialno06.plcpointAddress, wcsTask.serialNo.ToString(), this.serialno06.plcpointLength.ToString());
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 2, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行中" });
lineEquip.equipStatus = 1;
dbContext.Update(lineEquip);
dbContext.SaveChanges();
}
}
else
{
wcsTask.taskStatus = 1;
wcsTask.updateBy = "提升机线程";
wcsTask.updateTime = DateTime.Now;
wcsTask.remark = "提升机任务执行中";
BasePlcpoint basePlcpoint = StaticData.BasePlcpointList.First(t => t.floorNo == wcsTask.fromFloorNo && t.plcpointNo.Contains("wcsrun"));
this._plc.WriteToPoint(basePlcpoint.plcpointAddress, "1", basePlcpoint.plcpointLength.ToString());
this._plc.WriteToPoint(this.targetfloor06.plcpointAddress, wcsTask.fromFloorNo.ToString(), this.targetfloor06.plcpointLength.ToString());//目的地楼层
this._plc.WriteToPoint(this.serialno06.plcpointAddress, wcsTask.serialNo.ToString(), this.serialno06.plcpointLength.ToString());
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 2, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行中" });
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 1, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行中" });
lineEquip.equipStatus = 1;
dbContext.Update(lineEquip);
dbContext.SaveChanges();
}
}
else
{
wcsTask.taskStatus = 1;
wcsTask.updateBy = "提升机线程";
wcsTask.updateTime = DateTime.Now;
wcsTask.remark = "提升机任务执行中";
this._plc.WriteToPoint(this.targetfloor06.plcpointAddress, wcsTask.fromFloorNo.ToString(), this.targetfloor06.plcpointLength.ToString());//目的地楼层
this._plc.WriteToPoint(this.serialno06.plcpointAddress, wcsTask.serialNo.ToString(), this.serialno06.plcpointLength.ToString());
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 1, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行中" });
lineEquip.equipStatus = 1;
dbContext.Update(lineEquip);
dbContext.SaveChanges();
}
}
}
if (wcsTask.taskStatus == 1 && Convert.ToInt32(reserialno06) == wcsTask.serialNo)
{
BasePlcpoint floorPoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "RFID00" + wcsTask.fromFloorNo);
if (wcsTask.containerNo == this._plc.ReadRFID(floorPoint.plcpointAddress))
if (wcsTask.taskStatus == 1 && Convert.ToInt32(reserialno06) == wcsTask.serialNo)
{
if (Convert.ToInt32(canwritewcsrun06value) == 0)
BasePlcpoint floorPoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "RFID00" + wcsTask.fromFloorNo);
if (wcsTask.containerNo == this._plc.ReadRFID(floorPoint.plcpointAddress))
{
if (Convert.ToInt32(currentfloor06Value) == wcsTask.fromFloorNo)//提升机当前楼层为初始地楼层
if (Convert.ToInt32(canwritewcsrun06value) == 0)
{
wcsTask.taskStatus = 2;
wcsTask.updateBy = "提升机线程";
wcsTask.updateTime = DateTime.Now;
wcsTask.remark = "提升机任务执行中";
BasePlcpoint basePlcpoint = StaticData.BasePlcpointList.First(t => t.floorNo == wcsTask.fromFloorNo && t.plcpointNo.Contains("wcsrun"));
this._plc.WriteToPoint(basePlcpoint.plcpointAddress, "1", basePlcpoint.plcpointLength.ToString());
this._plc.WriteToPoint(this.serialno06.plcpointAddress, wcsTask.serialNo.ToString(), this.serialno06.plcpointLength.ToString());
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 2, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行中" });
dbContext.SaveChanges();
if (Convert.ToInt32(currentfloor06Value) == wcsTask.fromFloorNo)//提升机当前楼层为初始地楼层
{
wcsTask.taskStatus = 2;
wcsTask.updateBy = "提升机线程";
wcsTask.updateTime = DateTime.Now;
wcsTask.remark = "提升机任务执行中";
BasePlcpoint basePlcpoint = StaticData.BasePlcpointList.First(t => t.floorNo == wcsTask.fromFloorNo && t.plcpointNo.Contains("wcsrun"));
this._plc.WriteToPoint(basePlcpoint.plcpointAddress, "1", basePlcpoint.plcpointLength.ToString());
this._plc.WriteToPoint(this.serialno06.plcpointAddress, wcsTask.serialNo.ToString(), this.serialno06.plcpointLength.ToString());
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 2, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行中" });
dbContext.SaveChanges();
}
}
}
}
}
if (wcsTask.taskStatus == 2 && Convert.ToInt32(reserialno06) == wcsTask.serialNo)
{
if (Convert.ToInt32(hoisterTrayIn06Value) == 1)//托盘已经进提升机
if (wcsTask.taskStatus == 2 && Convert.ToInt32(reserialno06) == wcsTask.serialNo)
{
wcsTask.taskStatus = 3;
if (Convert.ToInt32(hoisterTrayIn06Value) == 1)//托盘已经进提升机
{
wcsTask.taskStatus = 3;
wcsTask.updateBy = "提升机线程";
wcsTask.updateTime = DateTime.Now;
wcsTask.remark = "提升机任务执行完成";
this._plc.WriteToPoint(this.targetfloor06.plcpointAddress, wcsTask.floorNo.ToString(), this.targetfloor06.plcpointLength.ToString());//目的地楼层
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 3, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行完成" });
dbContext.SaveChanges();
}
}
if (wcsTask.taskStatus == 3 && Convert.ToInt32(currentfloor06Value) == wcsTask.floorNo && Convert.ToInt32(reserialno06) == wcsTask.serialNo)//任务状态为3且当前楼层为任务的目的楼层
{
if (Convert.ToInt32(canwritewcsrun06value) == 0)
{
wcsTask.taskStatus = 4;
wcsTask.updateBy = "提升机线程";
wcsTask.updateTime = DateTime.Now;
wcsTask.remark = "提升机任务执行完成";
BasePlcpoint basePlcpoint = StaticData.BasePlcpointList.First(t => t.floorNo == wcsTask.fromFloorNo && t.plcpointNo.Contains("wcsrun"));
this._plc.WriteToPoint(basePlcpoint.plcpointAddress, "2", basePlcpoint.plcpointLength.ToString());//去向为2表示提升机已到达目的地让货出去
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 4, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行完成" });
dbContext.SaveChanges();
}
}
else if (wcsTask.taskStatus == 4)
{
BaseEquip floorEquip = StaticData.BaseEquip.First(t => t.objid == wcsTask.floorNo);
wcsTask.nextPointId = floorEquip.objid;
wcsTask.nextPointNo = floorEquip.equipNo;
wcsTask.taskStatus = 5;
wcsTask.updateBy = "提升机线程";
wcsTask.updateTime = DateTime.Now;
wcsTask.remark = "提升机任务执行完成";
this._plc.WriteToPoint(this.targetfloor06.plcpointAddress, wcsTask.floorNo.ToString(), this.targetfloor06.plcpointLength.ToString());//目的地楼层
lineEquip.equipStatus = 0;
dbContext.Update(lineEquip);
dbContext.SaveChanges();
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 3, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行完成" });
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 5, nextPointId = floorEquip.objid, nextPointNo = floorEquip.equipNo, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行完成" });
dbContext.SaveChanges();
}
break;
}
if (wcsTask.taskStatus == 3 && Convert.ToInt32(currentfloor06Value) == wcsTask.floorNo && Convert.ToInt32(reserialno06) == wcsTask.serialNo)//任务状态为3且当前楼层为任务的目的楼层
{
if (Convert.ToInt32(canwritewcsrun06value) == 0)
{
wcsTask.taskStatus = 4;
wcsTask.updateBy = "提升机线程";
wcsTask.updateTime = DateTime.Now;
wcsTask.remark = "提升机任务执行完成";
BasePlcpoint basePlcpoint = StaticData.BasePlcpointList.First(t => t.floorNo == wcsTask.fromFloorNo && t.plcpointNo.Contains("wcsrun"));
this._plc.WriteToPoint(basePlcpoint.plcpointAddress, "2", basePlcpoint.plcpointLength.ToString());//去向为2表示提升机已到达目的地让货出去
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 4, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行完成" });
dbContext.SaveChanges();
}
}
else if (wcsTask.taskStatus == 4)
{
BaseEquip floorEquip = StaticData.BaseEquip.First(t => t.objid == wcsTask.floorNo);
wcsTask.nextPointId = floorEquip.objid;
wcsTask.nextPointNo = floorEquip.equipNo;
wcsTask.taskStatus = 5;
wcsTask.updateBy = "提升机线程";
wcsTask.updateTime = DateTime.Now;
wcsTask.remark = "提升机任务执行完成";
lineEquip.equipStatus = 0;
dbContext.Update(lineEquip);
dbContext.SaveChanges();
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 5, nextPointId = floorEquip.objid, nextPointNo = floorEquip.equipNo, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行完成" });
dbContext.SaveChanges();
}
break;
}
}
}

@ -74,6 +74,7 @@ namespace Khd.Core.Wcs.Wcs
var taskList = dbContext.WcsTask
.Where(t => t.useFlag == 1)
.Where(t => t.nextPointId == agvID).OrderBy(t => t.createTime).ToList();
dbContext.ChangeTracker.Entries().ToList().ForEach (e => e.Reload());
if (taskList.Count == 0)
{
LogManager.Info(FloorNo + "楼AGV无任务");
@ -87,6 +88,7 @@ namespace Khd.Core.Wcs.Wcs
}
if (item.taskStatus == 0)//下发任务
{
BaseDictionary baseDictionary = StaticData.BaseDictionary.First(t => t.objid == item.taskType);
if (item.taskType == 37)//入库任务
{
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
@ -108,7 +110,7 @@ namespace Khd.Core.Wcs.Wcs
};
var agvTask = new RequestAGVTaskDto
{
reqCode = item.objid.ToString(),
reqCode = wcsCmd.objid.ToString(),
positionCodePath = new List<Position>
{
new ()
@ -122,6 +124,7 @@ namespace Khd.Core.Wcs.Wcs
type="00"
}
},
taskTyp= baseDictionary.dicValue,
ctnrTyp = "2",
};
string message = JsonConvert.SerializeObject(agvTask);
@ -162,9 +165,9 @@ namespace Khd.Core.Wcs.Wcs
BaseEquip nextEquip = StaticData.BaseEquip.First(t => t.floorNo == 5 && t.equipType == 1);
WcsCmd wcsCmd = new()
{
objid = item.objid,
objid = StaticData.SnowId.NextId(),
cmdStatus = 0,
taskId = item.orderId,
taskId = item.objid,
useFlag = 1,
cmdType = item.taskType,
containerNo = item.containerNo,
@ -177,7 +180,7 @@ namespace Khd.Core.Wcs.Wcs
};
RequestAGVTaskDto agvTask = new()
{
reqCode = item.objid.ToString(),
reqCode = wcsCmd.objid.ToString(),
positionCodePath = new List<Position>
{
new ()
@ -191,7 +194,7 @@ namespace Khd.Core.Wcs.Wcs
type="00"
}
},
taskTyp = "",
taskTyp = baseDictionary.dicValue,
ctnrTyp = "2"
};
string message = JsonConvert.SerializeObject(agvTask);
@ -222,9 +225,9 @@ namespace Khd.Core.Wcs.Wcs
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.startPointId);
WcsCmd wcsCmd = new()
{
objid = item.objid,
objid = StaticData.SnowId.NextId(),
cmdStatus = 0,
taskId = item.orderId,
taskId = item.objid,
useFlag = 1,
cmdType = item.taskType,
containerNo = item.containerNo,
@ -232,12 +235,12 @@ namespace Khd.Core.Wcs.Wcs
createBy = FloorNo + "楼AGV",
currPointId = item.currPointId,
currPointNo = wmsBaseLocation.agvPositionCode,
nextPointId = 30,
nextPointId = endEquip.objid,
nextPointNo = endEquip.agvPositionCode,
};
RequestAGVTaskDto agvTask = new()
{
reqCode = item.objid.ToString(),
reqCode = wcsCmd.objid.ToString(),
positionCodePath = new List<Position>
{
new ()
@ -251,7 +254,7 @@ namespace Khd.Core.Wcs.Wcs
type="00"
}
},
taskTyp = "",
taskTyp = baseDictionary.dicValue,
ctnrTyp = "2"
};
string message = JsonConvert.SerializeObject(agvTask);
@ -295,7 +298,7 @@ namespace Khd.Core.Wcs.Wcs
};
var agvTask = new RequestAGVTaskDto
{
reqCode = item.objid.ToString(),
reqCode = wcsCmd.objid.ToString(),
positionCodePath = new List<Position>
{
new ()
@ -309,6 +312,7 @@ namespace Khd.Core.Wcs.Wcs
type="00"
}
},
taskTyp= baseDictionary.dicValue,
ctnrTyp = "2",
};
string message = JsonConvert.SerializeObject(agvTask);
@ -337,9 +341,9 @@ namespace Khd.Core.Wcs.Wcs
BaseEquip currentEquip = StaticData.BaseEquip.First(t => t.objid == 29);
WcsCmd wcsCmd = new()
{
objid = item.objid,
objid = StaticData.SnowId.NextId(),
cmdStatus = 0,
taskId = item.orderId,
taskId = item.objid,
useFlag = 1,
cmdType = item.taskType,
containerNo = item.containerNo,
@ -352,7 +356,7 @@ namespace Khd.Core.Wcs.Wcs
};
RequestAGVTaskDto agvTask = new()
{
reqCode = item.objid.ToString(),
reqCode = wcsCmd.objid.ToString(),
positionCodePath = new List<Position>
{
new ()
@ -366,7 +370,7 @@ namespace Khd.Core.Wcs.Wcs
type="00"
}
},
taskTyp = "",
taskTyp = baseDictionary.dicValue,
ctnrTyp = "2"
};
string message = JsonConvert.SerializeObject(agvTask);
@ -395,9 +399,9 @@ namespace Khd.Core.Wcs.Wcs
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
WcsCmd wcsCmd = new()
{
objid = item.objid,
objid = StaticData.SnowId.NextId(),
cmdStatus = 0,
taskId = item.orderId,
taskId = item.objid,
useFlag = 1,
cmdType = item.taskType,
containerNo = item.containerNo,
@ -410,7 +414,7 @@ namespace Khd.Core.Wcs.Wcs
};
RequestAGVTaskDto agvTask = new()
{
reqCode = item.objid.ToString(),
reqCode = wcsCmd.objid.ToString(),
positionCodePath = new List<Position>
{
new()
@ -423,7 +427,10 @@ namespace Khd.Core.Wcs.Wcs
positionCode = wcsCmd.nextPointNo,
type = "00"
}
}
},
taskTyp= baseDictionary.dicValue,
ctnrTyp="2"
};
string message = JsonConvert.SerializeObject(agvTask);
string result = HttpHelper.SendPostMessage(baseEquip.serverIp, baseEquip.serverPort.Value, "rcms/services/rest/hikRpcService/genAgvSchedulingTask", message);
@ -466,7 +473,7 @@ namespace Khd.Core.Wcs.Wcs
};
var agvTask = new RequestAGVTaskDto
{
reqCode = item.objid.ToString(),
reqCode = wcsCmd.objid.ToString(),
positionCodePath = new List<Position>
{
new ()
@ -480,6 +487,65 @@ namespace Khd.Core.Wcs.Wcs
type="00"
}
},
taskTyp= baseDictionary.dicValue,
ctnrTyp = "2",
};
string message = JsonConvert.SerializeObject(agvTask);
string result = HttpHelper.SendPostMessage(baseEquip.serverIp, baseEquip.serverPort.Value, "rcms/services/rest/hikRpcService/genAgvSchedulingTask", message);
var reponseMessage = JsonConvert.DeserializeObject<ReponseMessage>(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
wcsCmd.taskCode = reponseMessage.data;
wcsCmd.cmdStatus = 1;
item.taskStatus = 1;
dbContext.Update(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 1 });
WcsCmdLog wcsCmdLog = CoreMapper.Map<WcsCmdLog>(wcsCmd);
dbContext.Add(wcsCmdLog);
dbContext.Add(wcsCmd);
dbContext.SaveChanges();
}
else
{
LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 49)//移库
{
WmsBaseLocation fromBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
WmsBaseLocation toBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
WcsCmd wcsCmd = new()
{
objid = StaticData.SnowId.NextId(),
cmdStatus = 0,
taskId = item.objid,
useFlag = 1,
cmdType = item.taskType,
containerNo = item.containerNo,
createTime = DateTime.Now,
createBy = FloorNo + "楼AGV",
currPointId = item.currPointId,
currPointNo = fromBaseLocation.agvPositionCode,
nextPointId = item.endPointId,
nextPointNo = toBaseLocation.agvPositionCode,
};
var agvTask = new RequestAGVTaskDto
{
reqCode = wcsCmd.objid.ToString(),
positionCodePath = new List<Position>
{
new ()
{
positionCode=wcsCmd.currPointNo,
type="00"
},
new ()
{
positionCode=wcsCmd.nextPointNo,
type="00"
}
},
taskTyp = baseDictionary.dicValue,
ctnrTyp = "2",
};
string message = JsonConvert.SerializeObject(agvTask);
@ -512,7 +578,7 @@ namespace Khd.Core.Wcs.Wcs
{
var agvTask = new RequestAGVTaskDto
{
reqCode = item.objid.ToString(),
reqCode = StaticData.SnowId.NextId().ToString(),
taskCode = wcsCmd.taskCode
};
string message = JsonConvert.SerializeObject(agvTask);
@ -530,7 +596,34 @@ namespace Khd.Core.Wcs.Wcs
}
else if (wcsCmd.cmdStatus == 5)
{
if (item.taskType == 37)//入库
if (item.taskType == 49)
{
WmsBaseLocation fromBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
WmsBaseLocation toBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
fromBaseLocation.outstockFlag = "0";
fromBaseLocation.locationStatus = "1";
toBaseLocation.instockFlag = "0";
toBaseLocation.locationStatus = "1";
var wmsRawStock = dbContext.WmsRawStock.Where(t => t.locationCode == fromBaseLocation.locationCode).FirstOrDefault();
if (wmsRawStock != null)
{
wmsRawStock.locationCode = toBaseLocation.locationCode;
dbContext.Update(wmsRawStock);
}
else
{
var wmsProductStock = dbContext.WmsProductStock.FirstOrDefault(t => t.locationCode == fromBaseLocation.locationCode);
if (wmsProductStock != null)
{
wmsProductStock.locationCode = toBaseLocation.locationCode;
dbContext.Update(wmsProductStock);
}
}
dbContext.Update(fromBaseLocation);
dbContext.Update(toBaseLocation);
dbContext.SaveChanges();
}
else if (item.taskType == 37)//入库
{
//WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation
@ -657,6 +750,9 @@ namespace Khd.Core.Wcs.Wcs
planDetailCode = wmsProductInstock.planDetailCode,
warehouseId = 512
};
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == item.startPointId);
startEquip.emptyCount = 0;
dbContext.Update(startEquip);
dbContext.Add(wmsProductStock);
dbContext.Update(wmsBaseLocation);
dbContext.WcsCmd.Where(t => t.objid == wcsCmd.objid).Delete();
@ -668,31 +764,42 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == 46)//该任务结束后立刻生成一个新的返库任务但是是否使用标志未0等待mes通知
{
WcsTask newTask = CoreMapper.Map<WcsTask>(item);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.startPointId);
wmsBaseLocation.outstockFlag = "0";
wmsBaseLocation.instockFlag = "1";
wmsBaseLocation.containerCode = "";
wmsBaseLocation.locationStatus = "2";
wmsBaseLocation.containerCode = null;
wmsBaseLocation.updateTime = DateTime.Now;
wmsBaseLocation.updateBy = "WCS";
dbContext.Update(wmsBaseLocation);
dbContext.WcsTask.Where(t => t.objid == item.objid).Delete();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog { cmdStatus = 6 });
dbContext.WcsCmd.Where(t => t.objid == wcsCmd.objid).Delete();
item.objid = StaticData.SnowId.NextId();
item.currPointId = item.endPointId;
item.currPointNo = item.endPointNo;
item.endPointId = item.startPointId;
item.endPointNo = item.startPointNo;
item.startPointId = item.currPointId;
item.startPointNo = item.currPointNo;
item.taskType = 28;
item.taskStatus = 0;
item.useFlag = 0;
dbContext.Add(item);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(item);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
WmsRawStock? wmsRawStock = dbContext.WmsRawStock.Where(t => t.locationCode == wmsBaseLocation.locationCode).FirstOrDefault();
if(wmsRawStock != null)
{
wmsRawStock.completeFlag = "0";
wmsRawStock.updateDate = DateTime.Now;
wmsRawStock.updateBy = "WCS";
dbContext.Update(wmsRawStock);
dbContext.Update(wmsBaseLocation);
dbContext.WcsTask.Where(t => t.objid == item.objid).Delete();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog { cmdStatus = 6 });
dbContext.WcsCmd.Where(t => t.objid == wcsCmd.objid).Delete();
item.objid = StaticData.SnowId.NextId();
item.currPointId = item.endPointId;
item.currPointNo = item.endPointNo;
item.endPointId = item.startPointId;
item.endPointNo = item.startPointNo;
item.startPointId = item.currPointId;
item.startPointNo = item.currPointNo;
item.taskType = 28;
item.taskStatus = 0;
item.useFlag = 0;
dbContext.Add(item);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(item);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
}
}
else if (item.taskType == 28)//柜体拆分到原材料
{
@ -709,6 +816,10 @@ namespace Khd.Core.Wcs.Wcs
wmsRawStock.completeFlag = "0";
wmsRawStock.updateDate = DateTime.Now;
wmsRawStock.updateBy = "WCS";
wmsRawStock.occupyAmount = 0;
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == item.currPointId);
startEquip.emptyCount = 0;
dbContext.Update(startEquip);
dbContext.Update(wmsRawStock);
dbContext.Update(wmsBaseLocation);
dbContext.WcsTask.Where(t => t.objid == item.objid).Delete();

@ -28,6 +28,9 @@ namespace Khd.Core.Wcs.Wcs
private readonly BasePlcpoint LineRFID;
private readonly BasePlcpoint isarrive;
private readonly BasePlcpoint isput;
private readonly BasePlcpoint canReceive;
private readonly BasePlcpoint ReceiveMaterial;
private readonly BasePlcpoint CtuLineWaring;
private bool isWait = false;
private bool isSendWait = false;
int FloorNo { get; set; }
@ -43,7 +46,9 @@ namespace Khd.Core.Wcs.Wcs
this.LineRFID = this.ScanPoint.First(t => t.plcpointNo.Contains("RFID5001"));
this.isarrive = this.ScanPoint.First(t => t.plcpointNo.Contains("isarrive"));
this.isput = this.ScanPoint.First(t => t.plcpointNo.Contains("isput"));
this.canReceive = this.ScanPoint.First(t => t.plcpointNo.Contains("canReceive"));
this.ReceiveMaterial = this.ScanPoint.First(t => t.plcpointNo.Contains("ReceiveMaterial"));
this.CtuLineWaring = this.ScanPoint.First(t => t.plcpointNo.Contains("CTULineWaring"));
//var lineRFID = this._plc.Read(NodeSettingCarNo.plcpointAddress);
try
{
@ -63,23 +68,51 @@ namespace Khd.Core.Wcs.Wcs
public void StartPoint()
{
Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
FlowPointThread.Start();
//Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
//FlowPointThread.Start();
Thread FlowCTUInWareThread = new Thread(MonitorInWare);
FlowCTUInWareThread.Start();
//Thread FlowCTUInWareThread = new Thread(MonitorInWare);
//FlowCTUInWareThread.Start();
Thread CtuWaitThread = new Thread(CtuWaitLogic);
CtuWaitThread.Start();
Thread HeartThread = new Thread(HeartLogic);
HeartThread.Start();
Console.WriteLine(DateTime.Now + ":五楼CTU上件扫描监听启动");
LogManager.Info("五楼CTU上件扫描监听启动");
}
private void HeartLogic(object? obj)
{
BasePlcpoint heartPoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "CTUHeart");
bool flag = true;
while (true)
{
try
{
flag = !flag;
this._plc.WriteToPoint(heartPoint.plcpointAddress,flag.ToString(),heartPoint.plcpointLength.ToString());
}
catch
{
try
{
this._plc = new Plc.S7.Plc(this._plc.CPU,this._plc.IP, this._plc.Port, this._plc.Rack, this._plc.Slot);
this._plc.Open();
}
catch
{
}
}
Thread.Sleep(1000);
}
}
private void MonitorInWare(object? obj)
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
bool IsStart = false;
while (true)
{
try
@ -87,8 +120,15 @@ namespace Khd.Core.Wcs.Wcs
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var rfid = this._plc.ReadRFID(LineRFID.plcpointAddress);
var isArrive = this._plc.Read(isarrive.plcpointAddress);
if (rfid != null && isArrive != null && Convert.ToInt32(isArrive) == 1)
var receiveMaterial = this._plc.Read(ReceiveMaterial.plcpointAddress);
var waring = this._plc.Read(CtuLineWaring.plcpointAddress);
bool haveAny = dbContext.WcsTask.Where(t => t.nextPointId == 11).Any();
if (rfid != null && isArrive != null && receiveMaterial != null && Convert.ToInt32(receiveMaterial) == 1 && Convert.ToInt32(isArrive) == 1)
{
if (Convert.ToBoolean(waring))
{
this._plc.WriteToPoint(CtuLineWaring.plcpointAddress, "false", CtuLineWaring.plcpointLength.ToString());
}
rfid = rfid[rfid.IndexOf('C')..];
WcsTask? task = dbContext.WcsTask.FirstOrDefault(t => t.containerNo == rfid);
if (task == null)
@ -115,6 +155,7 @@ namespace Khd.Core.Wcs.Wcs
endPointNo = wmsBaseLocation.agvPositionCode,
taskType = 29,
taskStatus = 0,
useFlag = 1,
floorNo = 5,
containerNo = rfid.ToString(),
equipmentNo = baseEquip.equipNo,
@ -123,14 +164,92 @@ namespace Khd.Core.Wcs.Wcs
};
wmsBaseLocation.instockFlag = "1";
wmsBaseLocation.locationStatus = "2";
wmsBaseLocation.updateTime = DateTime.Now;
dbContext.Update(wmsBaseLocation);
dbContext.Add(wcsTask);
//WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
//dbContext.WcsTaskLog.Add(wcsTaskLog);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
}
}
}
else
{
if (task.taskType == 30)
{
dbContext.WcsTask.Where(t => t.objid == task.objid).Delete();
//根据rfid找到库位
//生成入库任务
var wmsBaseLocation = dbContext.WmsBaseLocation.FirstOrDefault(t => t.containerCode == rfid);
if (wmsBaseLocation != null)
{
BaseEquip baseEquip = StaticData.BaseEquip.First(t => t.equipNo == "FL051");
BaseEquip ctuEquip = StaticData.BaseEquip.First(t => t.objid == 11);
if (wmsBaseLocation != null)
{
var wcsTask = new WcsTask()
{
objid = StaticData.SnowId.NextId(),
startPointId = baseEquip.objid,
startPointNo = baseEquip.agvPositionCode,
currPointId = baseEquip.objid,
currPointNo = baseEquip.agvPositionCode,
nextPointId = ctuEquip.objid,
useFlag = 1,
endPointId = wmsBaseLocation.locationId,
endPointNo = wmsBaseLocation.agvPositionCode,
taskType = 29,
taskStatus = 0,
floorNo = 5,
containerNo = rfid.ToString(),
equipmentNo = baseEquip.equipNo,
createBy = FloorNo + "楼CTU",
createTime = DateTime.Now,
};
wmsBaseLocation.instockFlag = "1";
wmsBaseLocation.locationStatus = "2";
wmsBaseLocation.updateTime = DateTime.Now;
dbContext.Update(wmsBaseLocation);
dbContext.Add(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
}
}
}
}
}
else if(Convert.ToInt32(receiveMaterial) == 1 && Convert.ToInt32(isArrive) == 1 && string.IsNullOrEmpty(rfid))
{
if (!Convert.ToBoolean(waring))
{
this._plc.WriteToPoint(CtuLineWaring.plcpointAddress, "true", CtuLineWaring.plcpointLength.ToString());
}
}
else if (receiveMaterial != null && Convert.ToInt32(receiveMaterial) == 1)
{
if (!IsStart && !haveAny)
{
Task.Run(() =>
{
IsStart = true;
Thread.Sleep(10000);
lock (SystemData.outStockLock)
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
bool haveTask = dbContext.WcsTask.Where(t => t.nextPointId == 11).Any();
if (!haveTask && wcsOutstockLock.boxStatus == 1)
{
wcsOutstockLock.boxStatus = 0;
wcsOutstockLock.qty = 0;
dbContext.Update(wcsOutstockLock);
dbContext.SaveChanges();
}
IsStart = false;
}
});
}
}
}
catch (Exception ex)
@ -147,6 +266,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
LogManager.Error(ex);
}
Thread.Sleep(1000);
}
@ -155,45 +275,75 @@ namespace Khd.Core.Wcs.Wcs
/// <summary>
/// 预执行任务下发
/// </summary>
private void CtuWaitLogic()
//private void CtuWaitLogic()
//{
// BaseEquip baseEquip = StaticData.BaseEquip.First(t => t.objid == CTUID);
// BaseEquip Fl051 = StaticData.BaseEquip.First(t => t.objid == 19);//入库输送线
// while (true)
// {
// try
// {
// while (isWait)
// {
// var waitTask = new
// {
// reqCode = StaticData.SnowId.NextId().ToString(),
// positionCode = "CTU_IN",
// nextTask = 1200
// };
// string waitMessage = JsonConvert.SerializeObject(waitTask);
// string waitResult = HttpHelper.SendPostMessage(baseEquip.serverIp, baseEquip.serverPort.Value, "rcms/services/rest/hikRpcService/genPreScheduleTask", waitMessage);
// var waitReponse = JsonConvert.DeserializeObject<ReponseMessage>(waitResult);
// if (waitReponse != null && waitReponse.code == "0")
// {
// isSendWait = true;
// }
// else
// {
// LogManager.Info("CTU下发预执行任务失败:\nwaitTask:" + waitMessage + "\nwaitResult:" + waitResult);
// }
// Thread.Sleep(1000 * 60 * 10);//每10分钟重新下发预执行任务
// }
// isSendWait = false;
// }
// catch (Exception ex)
// {
// LogManager.Error(ex);
// }
// Thread.Sleep(3000);
// }
//}
private bool CtuWaitLogic()
{
BaseEquip baseEquip = StaticData.BaseEquip.First(t => t.objid == CTUID);
BaseEquip Fl051 = StaticData.BaseEquip.First(t => t.objid == 19);//入库输送线
while (true)
try
{
try
var waitTask = new
{
while (isWait)
{
var waitTask = new
{
reqCode = StaticData.SnowId.NextId().ToString(),
positionCode = "CTU_IN",
nextTask = 1200
};
string waitMessage = JsonConvert.SerializeObject(waitTask);
string waitResult = HttpHelper.SendPostMessage(baseEquip.serverIp, baseEquip.serverPort.Value, "rcms/services/rest/hikRpcService/genPreScheduleTask", waitMessage);
var waitReponse = JsonConvert.DeserializeObject<ReponseMessage>(waitResult);
if (waitReponse != null && waitReponse.code == "0")
{
isSendWait = true;
}
else
{
LogManager.Info("CTU下发预执行任务失败:\nwaitTask:" + waitMessage + "\nwaitResult:" + waitResult);
}
Thread.Sleep(1000 * 60 * 10);//每10分钟重新下发预执行任务
}
isSendWait = false;
}
catch (Exception ex)
reqCode = StaticData.SnowId.NextId().ToString(),
positionCode = "CTU_IN",
nextTask = 120
};
string waitMessage = JsonConvert.SerializeObject(waitTask);
string waitResult = HttpHelper.SendPostMessage(baseEquip.serverIp, baseEquip.serverPort.Value, "rcms/services/rest/hikRpcService/genPreScheduleTask", waitMessage);
var waitReponse = JsonConvert.DeserializeObject<ReponseMessage>(waitResult);
if (waitReponse != null && waitReponse.code == "0")
{
LogManager.Error(ex);
return true;
}
else
{
LogManager.Info("CTU下发预执行任务失败:\nwaitTask:" + waitMessage + "\nwaitResult:" + waitResult);
}
Thread.Sleep(3000);
}
catch (Exception ex)
{
LogManager.Error(ex);
return false;
}
return false;
}
/// <summary>
/// 监控上件扫描点位
/// </summary>
@ -208,27 +358,15 @@ namespace Khd.Core.Wcs.Wcs
try
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var taskList = dbContext.WcsTask.Where(t => t.nextPointId == CTUID).OrderBy(t => t.createTime).ToList();
var taskList = dbContext.WcsTask
.Where(t => t.useFlag == 1)
.Where(t => t.nextPointId == CTUID).OrderByDescending(t => t.ud1).ToList();
if (taskList.Count == 0)
{
LogManager.Info(FloorNo + "楼CTU无任务");
}
foreach (var item in taskList)
{
if (!taskList.Where(t => t.taskType == 29 && t.CTUExecute == "2").Any())
{
if (item.CTUExecute == "1")
{
ExecuteInTask(baseEquip);
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
wcsOutstockLock.qty = 0;
wcsOutstockLock.boxStatus = 0;
dbContext.Update(wcsOutstockLock);
isWait = false;
item.CTUExecute = "2";
dbContext.Update(item);
}
}
if (item.taskStatus == 0)//CTU会同时生成多个任务生成就下发
{
if (item.taskType == 30)//出库任务
@ -283,7 +421,7 @@ namespace Khd.Core.Wcs.Wcs
WcsCmdLog wcsCmdLog = CoreMapper.Map<WcsCmdLog>(wcsCmd);
dbContext.Add(wcsCmdLog);
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
wcsOutstockLock.qty = wcsOutstockLock.qty + 1;
wcsOutstockLock.qty++;
dbContext.Update(wcsOutstockLock);
dbContext.WcsCmd.Add(wcsCmd);
dbContext.SaveChanges();
@ -295,26 +433,27 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskType == 29)//入库任务
{
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == item.startPointId);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
var wcsCmd = new WcsCmd()
{
objid = StaticData.SnowId.NextId(),
cmdStatus = 0,
taskId = item.objid,
useFlag = 1,
cmdType = item.taskType,
containerNo = item.containerNo,
createTime = DateTime.Now,
createBy = FloorNo + "楼CTU",
nextPointId = wmsBaseLocation.locationId,
nextPointNo = wmsBaseLocation.agvPositionCode,
currPointId = startEquip.objid,
currPointNo = startEquip.agvPositionCode,
};
isWait = true;
if (isSendWait)
bool haveOut = taskList.Where(t => t.taskType == 30).Where(t => t.taskStatus != 6).Any();
if (!haveOut && CtuWaitLogic())
{
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == item.startPointId);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
var wcsCmd = new WcsCmd()
{
objid = StaticData.SnowId.NextId(),
cmdStatus = 0,
taskId = item.objid,
useFlag = 1,
cmdType = item.taskType,
containerNo = item.containerNo,
createTime = DateTime.Now,
createBy = FloorNo + "楼CTU",
nextPointId = wmsBaseLocation.locationId,
nextPointNo = wmsBaseLocation.agvPositionCode,
currPointId = startEquip.objid,
currPointNo = startEquip.agvPositionCode,
};
var agvTask = new
{
reqCode = StaticData.SnowId.NextId().ToString(),
@ -347,15 +486,18 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Add(wcsCmdLog);
dbContext.Update(item);
dbContext.Add(wcsCmd);
int ctuTaskCount = dbContext.WcsTask.Where(t => t.taskType == 29 || t.taskType == 30).Count();
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
if (ctuTaskCount >= 6 || wcsOutstockLock.qty == ctuTaskCount)//如果CTU当前任务数量很多取消预执行任务
int ctuTaskCount = dbContext.WcsTask.Where(t => t.taskType == 29).Count();
lock (SystemData.outStockLock)
{
ExecuteInTask(baseEquip);
wcsOutstockLock.qty = 0;
wcsOutstockLock.boxStatus = 0;
dbContext.Update(wcsOutstockLock);
isWait = false;
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
if (ctuTaskCount >= 6 || wcsOutstockLock.qty == ctuTaskCount)//如果CTU当前任务数量很多取消预执行任务
{
ExecuteInTask(baseEquip);
wcsOutstockLock.qty = 0;
wcsOutstockLock.boxStatus = 0;
dbContext.Update(wcsOutstockLock);
isWait = false;
}
}
dbContext.SaveChanges();
}
@ -376,7 +518,7 @@ namespace Khd.Core.Wcs.Wcs
if (item.taskType == 30)
{
var canOut = this._plc.Read(isput.plcpointAddress);
if (canOut != null && Convert.ToInt64(canOut) == 1)
if (canOut != null && Convert.ToInt64(canOut) == 0)
{
var agvTask = new
{
@ -434,13 +576,19 @@ namespace Khd.Core.Wcs.Wcs
.First(t => t.locationId == item.startPointId && t.warehouseFloor == 5);
wmsBaseLocation.outstockFlag = "0";
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.locationStatus = "2";
dbContext.Update(wmsBaseLocation);
dbContext.WmsRawOutstockDetail.Where(t => t.locationCode == wmsBaseLocation.locationCode).Update(t => new WmsRawOutstockDetail { executeStatus = "2" });
dbContext.WcsCmd.Where(t => t.objid == wcsCmd.objid).Delete();
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog() { cmdStatus = 6 });
dbContext.WcsTask.Where(t => t.objid == item.objid).Delete();
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Delete();
dbContext.WcsTask.Where(t => t.objid == item.objid).Update(t => new WcsTask() { taskStatus = 6 });
dbContext.WcsTaskLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsTaskLog() { taskStatus = 6 });
dbContext.SaveChanges();
int wcsTaskCount = dbContext.WcsTask.Where(t => t.taskType == 30 && t.taskStatus != 6).Count();
if (wcsTaskCount == 0)
{
this._plc.WriteToPoint(this.canReceive.plcpointAddress, "1", this.canReceive.plcpointLength?.ToString());
}
}
else if (item.taskType == 29)//入库任务
{
@ -448,11 +596,24 @@ namespace Khd.Core.Wcs.Wcs
.First(t => t.locationId == item.endPointId && t.warehouseFloor == 5);
wmsBaseLocation.instockFlag = "0";
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.locationStatus = "1";
wmsBaseLocation.ContainerStatus = "1";
dbContext.Update(wmsBaseLocation);
dbContext.WcsCmd.Where(t => t.objid == wcsCmd.objid).Delete();
dbContext.WcsCmdLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsCmdLog() { cmdStatus = 6 });
dbContext.WcsTask.Where(t => t.objid == item.objid).Delete();
dbContext.WcsTaskLog.Where(t => t.objid == wcsCmd.objid).Update(t => new WcsTaskLog() { taskStatus = 6 });
lock (SystemData.outStockLock)
{
int wcsTaskCount = dbContext.WcsTask.Where(t => t.taskType == 29).Count();
if (wcsTaskCount == 0)
{
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
wcsOutstockLock.qty = 0;
wcsOutstockLock.boxStatus = 0;
dbContext.Update(wcsOutstockLock);
}
}
dbContext.SaveChanges();
}
}
@ -462,6 +623,18 @@ namespace Khd.Core.Wcs.Wcs
}
catch (Exception ex)
{
if (ex is PlcException)
{
try
{
this._plc = new Plc.S7.Plc(this._plc.CPU, this._plc.IP, this._plc.Port, this._plc.Rack, this._plc.Slot);
this._plc.Open();
}
catch
{
}
}
LogManager.Error(ex);
}
finally

@ -1,120 +0,0 @@
//using Khd.Core.Domain.Dto.webapi;
//using Khd.Core.Domain.Models;
//using Khd.Core.EntityFramework;
//using Khd.Core.Wcs.Global;
//using Masuit.Tools.Logging;
//using Microsoft.Extensions.DependencyInjection;
//using Microsoft.Extensions.Hosting;
//using Z.EntityFramework.Plus;
//namespace Khd.Core.Wcs.Wcs
//{
// /// <summary>
// /// 五楼人工分拣输送线
// /// </summary>
// public class FiveFloorLine
// {
// List<BasePlcpoint> ScanPoint { get; set; }//点位信息
// private readonly IHost _host;
// private readonly Plc.S7.Plc _plc;
// private readonly BasePlcpoint LineRFID;
// private readonly BasePlcpoint IsArrive;
// private readonly BasePlcpoint IsPut;
// int FloorNo { get; set; }
// string EquipNo = "";
// int CTUID = 11;
// public FiveFloorLine(IHost host, Plc.S7.Plc plc, int floor, string equipNo)
// {
// this._host = host;
// this._plc = plc;
// FloorNo = floor;
// EquipNo = equipNo;
// this.ScanPoint = StaticData.BasePlcpointList.Where(t => t.floorNo == floor).ToList();//加载当前站点所对应的点位
// this.LineRFID = this.ScanPoint.First(t => t.plcpointNo == "RFID5001");
// this.IsArrive = this.ScanPoint.First(t => t.plcpointNo.Contains("isarrive"));
// this.IsPut = this.ScanPoint.First(t => t.plcpointNo == "isput");
// //var lineRFID = this._plc.Read(NodeSettingCarNo.plcpointAddress);
// try
// {
// //默认启动,清理plc的上位机写入点位值
// this._plc.Write(LineRFID.plcpointAddress, MainCentralControl.QingKongDianWei);
// }
// catch (Exception ex)
// {
// Console.WriteLine("楼层" + floor + " 初始化数据异常" + ex.Message);
// LogManager.Error(ex);
// }
// }
// /// <summary>
// /// 启动上件扫描监听
// /// </summary>
// public void StartPoint()
// {
// Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
// FlowPointThread.Start();
// Console.WriteLine(DateTime.Now+":五楼人工分拣输送线启动成功");
// LogManager.Info("五楼人工分拣输送线启动成功");
// }
// public void MonitorInLocatorPoint()
// {
// using var scope = _host.Services.CreateScope();
// using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
// while (true)
// {
// try
// {
// dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
// var rfid = this._plc.Read(LineRFID.plcpointAddress);
// var isarrive = this._plc.Read(IsArrive.plcpointAddress);
// //获取条码信息
// var palletNo = Convert.ToString(rfid);
// var taskid = 0;
// WcsToWms wcsToWms = new WcsToWms();
// continueTaskDto agvtask = new continueTaskDto();
// //入库:待取料
// if (rfid != null && isarrive != null)
// {
// //正常读到输送线信息 有到位信号,并且有托盘,获取条码信息
// if (Convert.ToInt32(isarrive) == 1)
// {
// var wcsTaskList = dbContext.WcsTask.Where(t => t.taskType == 7).ToList();
// var cmd = dbContext.WcsCmd.Where(t => t.containerNo == rfid && t.cmdStatus == 14).FirstOrDefault();
// if (cmd != null)
// {
// agvtask.reqCode = cmd.taskId.ToString();
// //给ctu下发继续任务指令
// wcsToWms.continueTask(agvtask);
// }
// }
// }
// //出库:取料完成待放料
// if (IsPut != null)
// {
// var cmdList = dbContext.WcsCmd.Where(t => t.cmdStatus == 15).ToList();
// if (cmdList == null) return;
// foreach (var item in cmdList)
// {
// if (item != null)
// {
// agvtask.reqCode = item.taskId.ToString();
// //给ctu下发继续任务指令
// wcsToWms.continueTask(agvtask);
// }
// }
// }
// }
// catch (Exception ex)
// {
// LogManager.Error(ex);
// }
// finally
// {
// Thread.Sleep(1000);
// }
// }
// }
// }
//}

@ -95,12 +95,15 @@ namespace Khd.Core.Wcs.Wcs
.Where(t => t.locationScrapType == "1")
.Where(t => t.instockFlag == "0")
.Where(t => t.outstockFlag == "0")
.Where(t=>t.warehouseId==511)
//.Where(t => t.locationStatus == "1")
//.Where(t => string.IsNullOrEmpty(t.containerCode))
.ToList();
if (wmsBaseLocations.Count > 0)
{
List<string> containerCodes = wmsBaseLocations.Where(t => t.locDeep == 1).Select(t => t.containerCode).ToList();//深库位的托盘
List<string> containerCodes = wmsBaseLocations
.Where(t => t.locDeep == 1)
.Select(t => t.containerCode).ToList();//深库位的托盘
List<MesBasePalletInfo> mesBasePalletInfos = dbContext.MesBasePalletInfo
.Where(t => t.materialId == wcsTask.materialId)
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料
@ -138,31 +141,25 @@ namespace Khd.Core.Wcs.Wcs
wcsTask.nextPointNo = AgvEquip.equipNo;
wcsTask.endPointId = wmsBaseLocation.locationId;
wcsTask.endPointNo = wmsBaseLocation.locationCode;
if (wmsBaseLocation.warehouseId == 531)
{
wcsTask.taskType = 37;
wcsTask.useFlag = 1;
}
else if (wmsBaseLocation.warehouseId == 511 && wcsTask.fromFloorNo == 4)
{
wcsTask.taskType = 47;//?28?
wcsTask.useFlag = 0;
}
else if (wmsBaseLocation.warehouseId == 511)
if(wcsTask.fromFloorNo != 1)
{
wcsTask.taskType = 47;
wcsTask.useFlag = 1;
}
else
{
Console.WriteLine($"{DateTime.Now}:5楼接驳位查找入库类型失败");
Thread.Sleep(1000);
continue;
wcsTask.taskType = 47;//?28?
wcsTask.useFlag = 0;
}
wmsBaseLocation.instockFlag = "1";
wmsBaseLocation.locationStatus = "2";
dbContext.Update(wmsBaseLocation);
dbContext.Update(wcsTask);
dbContext.WcsTask.Where(t => t.objid == wcsTask.objid).Delete();
wcsTask.objid = StaticData.SnowId.NextId();
wcsTask.createTime = DateTime.Now;
dbContext.Add(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
@ -178,7 +175,7 @@ namespace Khd.Core.Wcs.Wcs
else if (wcsTask.taskStatus == 6) //出库任务,小车任务是完成状态
{
int? floor = 0;
var wmsProductOutstock = dbContext.WmsProductOutstock.FirstOrDefault(t => t.saleOrderId == wcsTask.orderId);
var wmsProductOutstock = dbContext.WmsProductOutstock.FirstOrDefault(t => t.productOutstockId == wcsTask.orderId);
if (wmsProductOutstock != null)
{
var endEquip = StaticData.BaseEquip.FirstOrDefault(t => t.equipNo == wmsProductOutstock.endStationCode);
@ -189,7 +186,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
var wmsRawOutstock = dbContext.WmsRawOutstock.FirstOrDefault(t => t.orderId == wcsTask.orderId);
var wmsRawOutstock = dbContext.WmsRawOutstock.FirstOrDefault(t => t.rawOutstockId == wcsTask.orderId);
if (wmsRawOutstock != null)
{
var endEquip = StaticData.BaseEquip.FirstOrDefault(t => t.equipNo == wmsRawOutstock.endStationCode);
@ -207,28 +204,21 @@ namespace Khd.Core.Wcs.Wcs
continue;
}
BaseEquip nextEquip = StaticData.BaseEquip.First(t => t.equipType == 2);//提升机
dbContext.WcsTask.Where(t => t.objid == wcsTask.objid).Delete();
wcsTask.objid = StaticData.SnowId.NextId();
wcsTask.serialNo = SystemData.GetSerialNo(dbContext);
wcsTask.nextPointId = nextEquip.objid;
wcsTask.nextPointNo = nextEquip.equipNo;
wcsTask.currPointId = baseEquip.objid;
wcsTask.currPointNo = baseEquip.equipNo;
wcsTask.fromFloorNo = FloorNo;
wcsTask.taskType = 6;//成品出库
wcsTask.floorNo = floor;//出库到一
wcsTask.floorNo = floor;//出库
wcsTask.taskStatus = 0;
wcsTask.updateTime = DateTime.Now;
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid)
.Update(t => new WcsTaskLog
{
nextPointId = nextEquip.objid,
nextPointNo = nextEquip.equipNo,
currPointId = baseEquip.objid,
currPointNo = baseEquip.equipNo,
fromFloorNo = FloorNo,
floorNo = floor,
taskStatus = 0,
updateTime = DateTime.Now,
});
wcsTask.createTime = DateTime.Now;
dbContext.Add(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.WcsTaskLog.Add(wcsTaskLog);
dbContext.SaveChanges();
}
}

@ -5,6 +5,7 @@ using Khd.Core.Plc;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
using Masuit.Tools;
using Masuit.Tools.Logging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
@ -20,8 +21,9 @@ namespace Khd.Core.Wcs.Wcs
{
private readonly IHost host;
private Plc.S7.Plc Plc30 = StaticData.PlcDic[0];
private Plc.S7.Plc Plc31 = StaticData.PlcDic[0];
private Plc.S7.Plc Plc31 = StaticData.PlcDic[1];
private Plc.S7.Plc Plc220 = StaticData.PlcDic[2];
public SystemTimer(IHost host)
{
this.host = host;
@ -29,13 +31,133 @@ namespace Khd.Core.Wcs.Wcs
public void Start()
{
Thread messageSynchronousThread = new(MessageSynchronousLogic);
var messageSynchronousThread = new Thread(MessageSynchronousLogic)
{
IsBackground = true
};
messageSynchronousThread.Start();
Thread baseEquipThread = new Thread(BaseEquipLogic);
baseEquipThread.Start();
//var baseEquipThread = new Thread(BaseEquipLogic)
//{
// IsBackground = true
//};
//baseEquipThread.Start();
//var PlcHeartBeat30Thread = new Thread(PlcHeartBeat30Logic)
//{
// IsBackground = true
//};
//PlcHeartBeat30Thread.Start();
//var PlcHeartBeat31Thread = new Thread(PlcHeartBeat31Logic)
//{
// IsBackground = true
//};
//PlcHeartBeat31Thread.Start();
Console.WriteLine($"{DateTime.Now}: SystemTimer started");
}
/// <summary>
/// 定时发送心跳包
/// </summary>
/// <param name="obj"></param>
private void PlcHeartBeat30Logic(object? obj)
{
BasePlcpoint HeartBeat30 = StaticData.BasePlcpointList.First(t => t.plcpointNo == "HeartBeat30");
int heartBeatCount = 0;
while (true)
{
try
{
if (heartBeatCount == 0)
{
heartBeatCount = 1;
}
else
{
heartBeatCount = 0;
}
StaticData.PlcDic[0].WriteToPoint(HeartBeat30.plcpointAddress, heartBeatCount.ToString(), HeartBeat30.plcpointType?.ToString());
}
catch (Exception ex)
{
if (ex is PlcException)
{
try
{
foreach (var item in StaticData.PlcDic)
{
if (item.Value.IP == ex.Message)
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
}
LogManager.Error(ex);
}
Thread.Sleep(1000);
}
}
/// <summary>
/// 定时发送心跳包
/// </summary>
/// <param name="obj"></param>
private void PlcHeartBeat31Logic(object? obj)
{
BasePlcpoint HeartBeat31 = StaticData.BasePlcpointList.First(t => t.plcpointNo == "HeartBeat31");
int heartBeatCount = 0;
while(true)
{
try
{
if (heartBeatCount == 0)
{
heartBeatCount = 1;
}
else
{
heartBeatCount = 0;
}
StaticData.PlcDic[1].WriteToPoint(HeartBeat31.plcpointAddress, heartBeatCount.ToString(), HeartBeat31.plcpointType?.ToString());
}
catch (Exception ex)
{
if (ex is PlcException)
{
try
{
foreach (var item in StaticData.PlcDic)
{
if (item.Value.IP == ex.Message)
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
}
LogManager.Error(ex);
}
Thread.Sleep(1000);
}
}
/// <summary>
/// 定时更新基础设备信息
/// </summary>
/// <param name="obj"></param>
private void BaseEquipLogic(object? obj)
{
using var scope = host.Services.CreateScope();
@ -65,44 +187,56 @@ namespace Khd.Core.Wcs.Wcs
}
}
/// <summary>
/// 定时同步消息
/// </summary>
/// <param name="obj"></param>
private void MessageSynchronousLogic(object? obj)
{
try
{
using var scope = host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
HositerLogic();
CtuLineLogic();
ThirdAgvLogic(dbContext);
SecondAgvLogic(dbContext);
FiveAgvLogic(dbContext);
FiveBearAgvLogic(dbContext);
CtuCmdLogic(dbContext);
}
catch (Exception ex)
while (true)
{
try
{
if (ex is PlcException)
using var scope = host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
HositerLogic();
CtuLineLogic();
ThirdAgvLogic(dbContext);
FiveAgvLogic(dbContext);
FiveBearAgvLogic(dbContext);
CtuCmdLogic(dbContext);
//SecondAgvLogic(dbContext);
}
catch (Exception ex)
{
try
{
foreach (var item in StaticData.PlcDic)
if (ex is PlcException)
{
if (item.Value.IP == ex.Message)
foreach (var item in StaticData.PlcDic)
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
if (item.Value.IP == ex.Message)
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
}
}
catch
{
catch
{
}
}
Thread.Sleep(5000);
}
Thread.Sleep(5000);
}
/// <summary>
/// 定时更新三楼AGV信息
/// </summary>
/// <param name="dbContext"></param>
private void ThirdAgvLogic(DefaultDbContext dbContext)
{
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 9);
@ -127,6 +261,10 @@ namespace Khd.Core.Wcs.Wcs
}
}
/// <summary>
/// 定时更新二楼AGV信息
/// </summary>
/// <param name="dbContext"></param>
private void SecondAgvLogic(DefaultDbContext dbContext)
{
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 8);
@ -151,6 +289,10 @@ namespace Khd.Core.Wcs.Wcs
}
}
/// <summary>
/// 定时更新五楼AGV信息
/// </summary>
/// <param name="dbContext"></param>
private void FiveAgvLogic(DefaultDbContext dbContext)
{
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 10);
@ -213,6 +355,10 @@ namespace Khd.Core.Wcs.Wcs
}
}
/// <summary>
/// 定时更新五楼背负式AGV信息
/// </summary>
/// <param name="dbContext"></param>
private void FiveBearAgvLogic(DefaultDbContext dbContext)
{
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 10);
@ -241,6 +387,10 @@ namespace Khd.Core.Wcs.Wcs
}
}
/// <summary>
/// 定时更新五楼CTU信息
/// </summary>
/// <param name="dbContext"></param>
private void CtuCmdLogic(DefaultDbContext dbContext)
{
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 11);
@ -292,6 +442,9 @@ namespace Khd.Core.Wcs.Wcs
}
}
/// <summary>
/// 定时更新五楼U型线信息
/// </summary>
private void CtuLineLogic()
{
var basePlcpoints = StaticData.BasePlcpointList.ToList();

@ -6,14 +6,14 @@
//"DefaultConnection": "server=175.27.215.92;port=3306;database=hwjy-cloud;uid=kehaida;pwd=khd2024;charset='utf8';persistsecurityinfo=True;SslMode=None;Allow User Variables=True"
},
"PlcConfigs": [
{
"IP": "192.168.2.30",
"Port": 102, //102
"CpuType": 40,
"Rack": 0,
"Slot": 1,
"Code": 0
},
//{
// "IP": "192.168.2.30",
// "Port": 102, //102
// "CpuType": 40,
// "Rack": 0,
// "Slot": 1,
// "Code": 0
//},
{
"IP": "192.168.2.31",
"Port": 102, //102
@ -22,14 +22,14 @@
"Slot": 1,
"Code": 1
},
{
"IP": "192.168.2.220",
"Port": 102, //102
"CpuType": 40,
"Rack": 0,
"Slot": 1,
"Code": 2
}
//{
// "IP": "192.168.2.220",
// "Port": 102, //102
// "CpuType": 40,
// "Rack": 0,
// "Slot": 1,
// "Code": 2
//}
],
"PLCSetting": {
"Mode": "0",

@ -2,6 +2,7 @@
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
@ -14,6 +15,7 @@ namespace Khd.Core.Wpf
{
public App()
{
//UI线程未捕获异常处理事件UI主线程
this.DispatcherUnhandledException += App_DispatcherUnhandledException;

@ -441,7 +441,7 @@
</ControlTemplate>
</Button.Template>
</Button>
<Button Content="删除任务" Margin="500,-8,0,-100" FontSize="25" Foreground="White" Height="50" Width="132" Click="btnDelTask_Click">
<Button Content="删除任务" Visibility="Hidden" Margin="500,-8,0,-100" FontSize="25" Foreground="White" Height="50" Width="132" Click="btnDelTask_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -451,7 +451,7 @@
</ControlTemplate>
</Button.Template>
</Button>
<Button Content="开始任务" Margin="800,-8,0,-100" FontSize="25" Foreground="White" Height="50" Width="132" Click="btnEditTask_Click">
<Button Content="开始任务" Margin="500,-8,0,-100" FontSize="25" Foreground="White" Height="50" Width="132" Click="btnEditTask_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
@ -587,22 +587,6 @@
IsReadOnly="True" />
<DataGridTextColumn
Width="300*"
Binding="{Binding currPointNo,Converter={StaticResource EquipConverter}}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="当前站点"
IsReadOnly="True" />
<DataGridTextColumn
Width="200*"
Binding="{Binding nextPointNo,Converter={StaticResource EquipConverter}}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="下一站点"
IsReadOnly="True" />
<DataGridTextColumn
Width="300*"
Binding="{Binding endPointNo,Converter={StaticResource EquipConverter}}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
@ -1408,7 +1392,176 @@
</StackPanel>
</StackPanel>
</TabItem>-->
<TabItem Header="物料扫描" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="125" Margin="5">
<TabItem Header="人工叫料" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="125" Margin="5">
<Grid Height="1100" Width="1700">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="1041"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Margin="0,5,0,0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="物料名称:" FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox x:Name="MaterialName" Width="200" Height="40" Margin="5,0,0,0" VerticalAlignment="Center"/>
<Button Content="搜索" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="100" Margin="20,0,0,0" Click="SelectButton_Click"/>
<Button Content="出空箱" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="100" Margin="20,0,0,0" Click="CallEmptyBtn_Click"/>
<Button Content="出选择料箱" Background="#346DFF" Foreground="White" FontSize="25" Height="50" Width="200" Margin="20,0,0,0" Click="CallTrayBtn_Click"/>
</StackPanel>
</Border>
<DataGrid Grid.Row="1" AlternationCount="2"
AutoGenerateColumns="False"
Background="#172557"
CanUserAddRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
Focusable="False"
HeadersVisibility="Column"
IsReadOnly="True"
LoadingRow="dgData_LoadingRow"
RowHeaderWidth="0"
SelectionMode="Single" FontSize="16"
Visibility="Visible" x:Name="PersonCallMaterial">
<DataGrid.Columns>
<DataGridTemplateColumn Width="130*" Header="选择">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Grid.Tag>
<Binding Path="IsSelected"/>
</Grid.Tag>
<CheckBox
IsChecked="{Binding Tag, RelativeSource={RelativeSource AncestorType=Grid}}"
Style="{StaticResource CheckBoxStyle}"
Click="CheckPersonBox_Click"
/>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn
Width="100"
MinWidth="10"
Header=" 序号"
IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Focusable="False"
FontSize="20"
Text="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}, Mode=FindAncestor}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn
Width="180*"
Binding="{Binding locationCode}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="库位号"
IsReadOnly="True" />
<DataGridTextColumn
Width="180*"
Binding="{Binding materialId}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="物料Id"
IsReadOnly="True" />
<DataGridTextColumn
Width="180*"
Binding="{Binding materialName}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="物料名称"
IsReadOnly="True" />
<DataGridTextColumn
Width="180*"
Binding="{Binding materialSpec}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="物料规格"
IsReadOnly="True" />
<DataGridTextColumn
Width="180*"
Binding="{Binding palletInfoCode}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="料箱号"
IsReadOnly="True" />
<DataGridTextColumn
Width="180*"
Binding="{Binding instockDate}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="入库时间"
IsReadOnly="True" />
<DataGridTextColumn
Width="180*"
Binding="{Binding totalAmount}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="总数"
IsReadOnly="True" />
<DataGridTextColumn
Width="180*"
Binding="{Binding frozenAmount}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="冻结数量"
IsReadOnly="True" />
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="#213269" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="50" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
</DataGrid.CellStyle>
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="#213269" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="50" />
</Style>
</DataGrid.RowStyle>
<DataGrid.RowHeaderStyle>
<Style TargetType="{x:Type DataGridRowHeader}">
<Setter Property="Background" Value="#213269" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="50" />
<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="Height" Value="50" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="BorderThickness" Value="5" />
<Setter Property="BorderBrush" Value="#172540" />
<Setter Property="FontSize" Value="30" />
</Style>
</DataGrid.ColumnHeaderStyle>
</DataGrid>
<hc:Pagination x:Name="Pagination2" Grid.Row="2" MaxWidth="1500" MaxPageCount="1" Margin="0,0,0,15" PageUpdated="Pagination2_PageUpdated" IsJumpEnabled="True" HorizontalAlignment="Center" Width="339" />
</Grid>
</TabItem>
<TabItem Header="扫描入库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="125" Margin="5">
<StackPanel x:Name="splMaterialCode" Height="1060" Width="1703" Background="#213269" Canvas.Left="175" Canvas.Top="110" Orientation="Horizontal">
<StackPanel Orientation="Horizontal" Width="1750">
<StackPanel Orientation="Vertical" Margin="20,5,0,0">
@ -1419,67 +1572,75 @@
Height="35"
Margin="60,0,0,0"
Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/>
<Label Content="人工叫料" Foreground="White" FontSize="20" Width="150" Height="40" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
<TextBlock Text="人工叫料" Foreground="White" FontSize="20" Width="150" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Margin="0,5,0,0">
<StackPanel Margin="0,10,10,10">
<Label
Width="152"
Height="73"
Content="物料 :"
FontSize="25" Margin="0,0,750,-60"
Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
/>
<TextBox x:Name="callMaterialId" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
LostFocus="callMaterialId_LostFocus"
Width="180" Height="50" Margin="0,0,400,0"/>
<Label
Width="152"
Height="73"
Content="数量 :"
FontSize="25" Margin="0,0,750,-60"
Foreground="White" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
/>
<TextBox x:Name="txtNum" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="0,0,400,0"/>
<Button x:Name="btnCallMaterial" Content="呼叫料箱" Margin="0,-50,10,0" Foreground="White" Height="50" Width="132" Click="btnCallBox_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<Grid Height="300">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="4*"/>
</Grid.RowDefinitions>
<TextBlock Text="请选择物料名称:" Grid.Row="0" Grid.Column="0"/>
<TextBlock Text="物料规格:" Grid.Row="1" Grid.Column="0"/>
<ComboBox x:Name="MaterialName" DisplayMemberPath="MaterialName" SelectionChanged="MaterialName_SelectionChanged" Grid.Column="1" IsEditable="True" Grid.Row="0" Width="170" VerticalAlignment="Center" HorizontalAlignment="Left"/>
<ComboBox x:Name="MaterialSpec" DisplayMemberPath="MaterialSpec" Grid.Column="1" Grid.Row="1" Width="170" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</Grid>
</Border>-->
<StackPanel Orientation="Horizontal" Margin="0">
<Image
x:Name="img_plcmesssage2"
Width="40"
Height="35"
Margin="60,0,0,0"
Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/>
<TextBlock Text="物料扫描" Foreground="White" FontSize="20" Width="150" Height="40" Margin="10,10,80,0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
x:Name="img_plcmesssage2"
Width="40"
Height="35"
Margin="60,0,0,0"
Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/>
<TextBlock Text="物料扫描" Foreground="White" FontSize="25" Width="150" Height="40" Margin="10,10,80,0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Height="500" Margin="0,5,0,0">
<Grid Width="1650" Height="1000">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="83*"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="166.667"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="83*"/>
</Grid.RowDefinitions>
<TextBlock Text="扫描料箱号:" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<TextBlock Text="扫描条码号:" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<TextBlock Text="入库数量:" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<hc:TextBox x:Name="txtInBox" hc:InfoElement.ShowClearButton="True" FontSize="50" LostFocus="txtInBox_TextChanged" Width="500" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="1" Grid.Column="3" Grid.ColumnSpan="2"/>
<hc:TextBox x:Name="txtInBarCode" hc:InfoElement.ShowClearButton="True" FontSize="50" LostFocus="txtInBarCode_TextChanged" Width="500" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="2"/>
<hc:TextBox x:Name="txtInScan" FontSize="50" IsReadOnly="True" Width="500" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="2" />
<Button Content="确认入库" Grid.Row="4" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="InRawBaseLocaltion_Click"/>
<Button Content="一键收料" Grid.Row="5" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="callPlc_Click"/>
<Button Content="执行CTU入库任务" Visibility="Hidden" Click="btnCtuInConfirmBox_Click" Grid.Row="5" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White"/>
</Grid>
<!--<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Height="500" Margin="0,5,0,0">
<StackPanel Margin="0,10,10,10">
<TextBlock
Width="152"
Height="37"
Text="业务类型 :"
FontSize="25" Margin="0,20,750,-60"
Foreground="White"
/>
<ComboBox x:Name="cbxType" Margin="0,10,400,0" Width="180" Height="50" >
<ComboBoxItem Content="入库" IsSelected="True"/>
<ComboBoxItem Content="出库" />
<ComboBoxItem Content="回库" />
</ComboBox>
Width="152"
Height="37"
Text="业务类型 :"
FontSize="25" Margin="0,20,750,-60"
Foreground="White"
/>
<TextBlock x:Name="cbxType" Margin="0,20,400,0" Width="180" Height="50" Text="入库" />
<TextBlock
Width="152"
@ -1562,7 +1723,149 @@
</Button.Template>
</Button>
</StackPanel>
</Border>
</Border>-->
</StackPanel>
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Header="扫描出库" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="125" 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">
<StackPanel Orientation="Horizontal" Margin="0">
<Image
Width="40"
Height="35"
Margin="60,0,0,0"
Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/>
<TextBlock Text="物料扫描" Foreground="White" FontSize="25" Width="150" Height="40" Margin="10,10,80,0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<Grid Width="1650" Height="1000">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="167*"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="166.667"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="167*"/>
<RowDefinition Height="83*"/>
</Grid.RowDefinitions>
<TextBlock Text="待执行CTU任务数:" Visibility="Hidden" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="50"/>
<TextBlock x:Name="outTaskCount" Visibility="Hidden" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<Button Content="执行CTU出库任务" Visibility="Hidden" Grid.Row="0" Grid.Column="3" Grid.ColumnSpan="2" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="ExecuteCtuTask_Click"/>
<TextBlock Text="扫描料箱号:" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<TextBlock Text="扫描条码号:" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<TextBlock Text="出库数量:" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="75"/>
<hc:TextBox hc:InfoElement.ShowClearButton="True" x:Name="txtOutBox" FontSize="50" LostFocus="txtOutBox_TextChanged" Width="500" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="1" Grid.Column="3" Grid.ColumnSpan="2"/>
<hc:TextBox hc:InfoElement.ShowClearButton="True" x:Name="txtOutBarCode" FontSize="50" LostFocus="txtOutBarCode_TextChanged" Width="500" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="2"/>
<hc:TextBox x:Name="txtOutScan" IsReadOnly="True" FontSize="50" Width="500" HorizontalAlignment="Left" VerticalAlignment="Center" Height="130" Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="2" />
<Button Content="确认出库" Grid.Row="4" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="OutRawBaseLocaltion_Click"/>
<Button Content="背负式小车捡料完成" Grid.Row="5" Grid.ColumnSpan="6" Width="500" Height="100" FontSize="50" Background="#346DFF" Foreground="White" Click="btnBearConfirmBox_Click"/>
</Grid>
<!--<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="900" Height="500" Margin="0,5,0,0">
<StackPanel Margin="0,10,10,10">
<TextBlock
Width="152"
Height="37"
Text="业务类型 :"
FontSize="25" Margin="0,20,750,-60"
Foreground="White"
/>
<TextBlock x:Name="cbxType" Margin="0,20,400,0" Width="180" Height="50" Text="入库" />
<TextBlock
Width="152"
Height="36"
Text="料箱 :"
FontSize="25" Margin="0,30,750,-60"
Foreground="White"
/>
<TextBox x:Name="txtBox" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="0,15,400,0" KeyDown="txtBox_KeyDown"/>
<TextBlock
Width="152"
Height="39"
Text="条码:"
FontSize="25" Margin="0,20,750,-60"
Foreground="White"
/>
<TextBox x:Name="txtBarCode" Style="{StaticResource XingHaoBianMaYangShi}" IsEnabled="true"
Width="180" Height="50" Margin="0,20,400,0" TextChanged="txtBarCode_KeyDown"/>
<Button Content="清除料箱条码" FontSize="25" Margin="400,-180,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="170" Click="clearRFID_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
<Button Content="清除条码" FontSize="25" Margin="400,-50,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="170" Click="clearBarCode_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
<TextBlock
Width="152"
Height="42"
Text="已扫描数量:"
FontSize="25" Margin="0,20,750,-60"
Foreground="White"
/>
<TextBox x:Name="txtScan" Style="{StaticResource XingHaoBianMaYangShi}" IsReadOnly="True"
Width="180" Height="50" Margin="0,10,400,0" IsEnabled="False" />
<Button Content="确认" FontSize="25" Margin="150,30,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="132" Click="btnConfirmBox_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
<Button Content="背负式小车捡料完成" FontSize="25" Margin="50,50,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="300" Click="btnBearConfirmBox_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
<Button Content="执行小车入库任务" FontSize="25" Margin="500,-50,10,0" HorizontalAlignment="Left" Foreground="White" Height="50" Width="300" Click="btnCtuInConfirmBox_Click">
<Button.Template >
<ControlTemplate TargetType="{x:Type Button}" >
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="4,4,4,4">
<Border.Background>#346DFF</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
</Border>-->
</StackPanel>
</StackPanel>
</StackPanel>
@ -1675,7 +1978,7 @@
HorizontalAlignment="Left"
Background="#213269"
Orientation="Horizontal">
<StackPanel Orientation ="Horizontal" Width="1000">
<StackPanel Orientation ="Horizontal" Width="700">
<Image
Width="160"
Height="100"
@ -1693,7 +1996,7 @@
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="-100,0,0,0" Width="920">
<StackPanel Orientation="Horizontal" Margin="-100,0,0,0" Width="1100">
<Image
Width="40"
Height="40"
@ -1702,7 +2005,7 @@
<TextBlock
x:Name="LabDate"
Height="55"
Margin="25,0,0,0"
Margin="25,20,0,0"
FontSize="30"
Width="255"
Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
@ -1714,10 +2017,11 @@
<TextBlock
x:Name="LabTime"
Height="55"
Margin="20,0,0,0"
Margin="20,20,0,0"
FontSize="30"
Width="170"
Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Content="开打键盘" Background="#346DFF" Foreground="White" Width="150" Height="75" FontSize="25" Click="Button_Click"/>
</StackPanel>
</StackPanel>
</Grid>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,172 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace Khd.Core.Wpf
{
public class HttpHelper
{
public static string SendPostMessage(string ip, int port, string url, string message,string contentType="application/Text")
{
string retsult = HttpPost("http://" + ip + ":" + port + "/" + url, message, contentType, 30, null);
return retsult;
}
public static string SendGetMessage(string ip, int port, string url)
{
string retsult = HttpGet("http://" + ip + ":" + port + "/" + url);
return retsult;
}
/// <summary>
/// 发起POST同步请求
///
/// </summary>
/// <param name="url"></param>
/// <param name="postData"></param>
/// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
/// <param name="headers">填充消息头</param>
/// <returns></returns>
public static string HttpPost(string url, string postData = null, string contentType = null, int timeOut = 30, Dictionary<string, string> headers = null)
{
postData = postData ?? "";
using (HttpClient client = new HttpClient())
{
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
using (HttpContent httpContent = new StringContent(postData, Encoding.UTF8))
{
if (contentType != null)
httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
HttpResponseMessage response = client.PostAsync(url, httpContent).Result;
return response.Content.ReadAsStringAsync().Result;
}
}
}
/// <summary>
/// 发起POST异步请求
/// </summary>
/// <param name="url"></param>
/// <param name="postData"></param>
/// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
/// <param name="headers">填充消息头</param>
/// <returns></returns>
public static async Task<string> HttpPostAsync(string url, string postData = null, string contentType = null, int timeOut = 30, Dictionary<string, string> headers = null)
{
postData = postData ?? "";
using (HttpClient client = new HttpClient())
{
client.Timeout = new TimeSpan(0, 0, timeOut);
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
using (HttpContent httpContent = new StringContent(postData, Encoding.UTF8))
{
if (contentType != null)
httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
HttpResponseMessage response = await client.PostAsync(url, httpContent);
return await response.Content.ReadAsStringAsync();
}
}
}
/// <summary>
/// 发起GET同步请求
/// </summary>
/// <param name="url"></param>
/// <param name="headers"></param>
/// <param name="contentType"></param>
/// <returns></returns>
public static string HttpGet(string url, Dictionary<string, string> headers = null)
{
using (HttpClient client = new HttpClient())
{
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
HttpResponseMessage response = client.GetAsync(url).Result;
return response.Content.ReadAsStringAsync().Result;
}
}
/// <summary>
/// 发起GET异步请求
/// </summary>
/// <param name="url"></param>
/// <param name="headers"></param>
/// <param name="contentType"></param>
/// <returns></returns>
public static async Task<string> HttpGetAsync(string url, Dictionary<string, string> headers = null)
{
using (HttpClient client = new HttpClient())
{
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
HttpResponseMessage response = await client.GetAsync(url);
return await response.Content.ReadAsStringAsync();
}
}
/// <summary>
/// 发起GET同步请求
/// </summary>
/// <param name="url"></param>
/// <param name="headers"></param>
/// <param name="contentType"></param>
/// <returns></returns>
public static string HttpDelete(string url, Dictionary<string, string> headers = null)
{
using (HttpClient client = new HttpClient())
{
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
HttpResponseMessage response = client.DeleteAsync(url).Result;
return response.Content.ReadAsStringAsync().Result;
}
}
/// <summary>
/// 发起GET异步请求
/// </summary>
/// <param name="url"></param>
/// <param name="headers"></param>
/// <param name="contentType"></param>
/// <returns></returns>
public static async Task<string> HttpDeleteAsync(string url, Dictionary<string, string> headers = null)
{
using (HttpClient client = new HttpClient())
{
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
HttpResponseMessage response = await client.DeleteAsync(url);
return await response.Content.ReadAsStringAsync();
}
}
}
}

@ -83,6 +83,7 @@ namespace Khd.Core.Wpf
public static List<BasePlcpoint> BasePlcpoints { get; set; }
public static List<BaseEquip> BaseEquip { get; internal set; }
public static List<WmsBaseWarehouse> BaseWareHouse { get; internal set; }
public static List<MesBaseMaterialInfo> MesBaseMaterialInfo { get; set; }
public static List<BaseDictionary> BaseDictionary =new List<BaseDictionary>();
public static List<PlcConfig> PlcConfigs =new List<PlcConfig>();

@ -0,0 +1,32 @@
<Window x:Class="Khd.Core.Wpf.TaskForm.EmptyCountForm"
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"
WindowStartupLocation="CenterScreen"
Background="#333333"
Title="EmptyCountForm" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<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"/>
<Button Content="取消" Margin="200,0,0,0" Width="150" Height="75" FontSize="50" Background="#F44336" Foreground="White" Click="Button_Click_1"/>
</StackPanel>
</Grid>
</Window>

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Khd.Core.Wpf.TaskForm
{
/// <summary>
/// EmptyCountForm.xaml 的交互逻辑
/// </summary>
public partial class EmptyCountForm : Window
{
public static int EmptyTaskCount = 0;
public static bool IsSelect = false;
public EmptyCountForm()
{
InitializeComponent();
this.EmptyCount.ItemsSource = new List<int>() { 1, 2, 3, 4, 5, 6 };
this.EmptyCount.SelectedIndex =0;
IsSelect = false;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
object selectedItem = this.EmptyCount.SelectedItem;
EmptyTaskCount = Convert.ToInt32(selectedItem);
IsSelect = true;
this.Close();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
IsSelect = false;
this.Close();
}
}
}

@ -15,14 +15,14 @@
"Slot": 1,
"Code": 0
},
//{
// "IP": "192.168.2.31",
// "Port": 102, //102
// "CpuType": 40,
// "Rack": 0,
// "Slot": 1,
// "Code": 1
//},
{
"IP": "192.168.2.31",
"Port": 102, //102
"CpuType": 40,
"Rack": 0,
"Slot": 1,
"Code": 1
},
//{
// "IP": "192.168.2.220",
// "Port": 102, //102

Loading…
Cancel
Save