master
1 year ago
parent 914fc7d33c
commit d94839bf3a

@ -16,5 +16,7 @@ namespace Khd.Core.Domain.Auth
[Column("MENU_VISIBLE")]
public int MenuVisble { get; set; }
[Column("MENU_ICON")]
public string MenuIcon { get; set; }
}
}

@ -17,7 +17,8 @@ namespace Khd.Core.Domain.Models
[Table("mes_base_barcode_info")]
public class MesBaseBarcodeInfo
{
[Column("purchase_order_id")]
public int? PurchaseOrderId { get; set; }
[Key]
[Column("barcode_id")]
public long barcodeId { get; set; }

@ -216,7 +216,8 @@ namespace Khd.Core.Domain.Models
[Column("remark")]
public string remark { get; set; }
[Column("is_delete")]
public int? IsDelete { get; set; }
}
}

@ -48,7 +48,7 @@ namespace Khd.Core.Plc
if (res.Contains("JYHB"))
{
return res[res.IndexOf('J')..];
return res[res.IndexOf('J')..].Substring(0,12);
}
else if(res.Contains('C'))
{

@ -42,7 +42,6 @@ namespace Khd.Core.Wcs
StaticData.basePlcs = dbContext.BasePlc.ToList();//陈工Agv和设备信息推送
StaticData.BaseEquip = dbContext.BaseEquip.ToList();//设备信息
StaticData.BaseDictionary = dbContext.BaseDictionary.ToList();//字典表Agv任务模板
foreach (var plcConfig in StaticData.PlcConfigs)
{
if (!StaticData.PlcDic.Any(t => t.Key == plcConfig.Code))
@ -51,7 +50,7 @@ namespace Khd.Core.Wcs
plc = new Plc.S7.Plc(plcConfig.CpuType, plcConfig.IP, plcConfig.Port, plcConfig.Rack, plcConfig.Slot);
try
{
//plc.Open();
plc.Open();
Console.WriteLine(DateTime.Now + ":连接PLC" + plcConfig.IP);
}
catch

@ -184,6 +184,10 @@ namespace Khd.Core.Wcs.Wcs
taskType = agvEquip.objid == 28 ? 66 : 55,
qty = 1,
};
fromLocationCode.locationStatus = "4";
dbContext.Update(fromLocationCode);
wmsBaseLocation.locationStatus = "4";
dbContext.Update(wmsBaseLocation);
dbContext.Add(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
@ -281,6 +285,10 @@ namespace Khd.Core.Wcs.Wcs
taskType = agvEquip.objid == 28 ? 66 : 67,
qty = 1,
};
fromLocationCode.locationStatus = "4";
dbContext.Update(fromLocationCode);
wmsBaseLocation.locationStatus = "4";
dbContext.Update(wmsBaseLocation);
dbContext.Add(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
@ -1480,17 +1488,14 @@ namespace Khd.Core.Wcs.Wcs
List<WcsTaskManual> wcsTaskManuals = dbContext.WcsTaskManual.Where(t => t.nextPointId == 11).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)
//if (taskCount == 0 && wcsOutstockLock.qty == 0 && wcsOutstockLock.boxStatus == 0)
if (taskCount == 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();
@ -1647,10 +1652,8 @@ namespace Khd.Core.Wcs.Wcs
if (!string.IsNullOrEmpty(endStationCodeEquip.endStationCode))
{
bool CreateSuccess = false;
var wcsOutstockLock = dbContext.WcsOutstockLock
.Where(t => t.warehouseId == 512)
.First();
if (wcsOutstockLock.qty == 0 && wcsOutstockLock.boxStatus == 0)
bool hasTask = dbContext.WcsTask.Where(t => t.nextPointId == 11).Any();
if (!hasTask)
{
var orderList = rawOutStock.Where(t => t.endStationCode == endStationCodeEquip.endStationCode).ToList();
List<WcsTask> tasks = new();
@ -1790,8 +1793,6 @@ namespace Khd.Core.Wcs.Wcs
location.updateBy = "WCS";
location.ContainerStatus = "2";
location.updateTime = DateTime.Now;
wcsOutstockLock.qty += 1;
wcsOutstockLock.boxStatus = 1;
dbContext.Update(location);
dbContext.Update(stock);
CreateSuccess = true;
@ -1815,7 +1816,7 @@ 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);
bool hasTask = dbContext.WcsTask.Where(t => t.taskType == 32).Any();
hasTask = dbContext.WcsTask.Where(t => t.taskType == 32).Any();
if (!hasTask)
{
WcsTask bearAgvTask = new()
@ -1857,7 +1858,6 @@ namespace Khd.Core.Wcs.Wcs
if (tasks.Count > 0)
{
dbContext.AddRange(tasks);
dbContext.Update(wcsOutstockLock);
}
dbContext.SaveChanges();
}

@ -174,7 +174,7 @@ namespace Khd.Core.Wcs.Wcs
{
if (ex is PlcException)
{
}
else
{
@ -236,7 +236,7 @@ namespace Khd.Core.Wcs.Wcs
{
if (ex is PlcException)
{
}
else
{
@ -290,163 +290,175 @@ namespace Khd.Core.Wcs.Wcs
BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 1);
if (Convert.ToInt32(linesignal01Value) == 1)
{
//判断task表里没有该rfid的未完成的入库
//信息,未下发去向
var task = dbContext.WcsTask.Where(t => t.IsDelete == 0).Where(t => t.nextPointId == 1).OrderBy(t => t.createTime).FirstOrDefault();
if (task == null)
{
//判断task表里没有该rfid的未完成的入库
//信息,未下发去向
var task = dbContext.WcsTask.Where(t => t.nextPointId == 1).OrderBy(t => t.createTime).FirstOrDefault();
if (task == null)
if (BigContainerCodes.Contains(RFID001Value))
{
if (BigContainerCodes.Contains(RFID001Value))
var newTask = new WcsTask()
{
var newTask = new WcsTask()
{
objid = StaticData.SnowId.NextId(),
serialNo = SystemData.GetSerialNo(dbContext),
equipmentNo = "F01",
taskType = 5,
taskStatus = 0,
containerNo = RFID001Value,
currPointId = F01,
currPointNo = "TSJ_01",
nextPointId = T01,
nextPointNo = "TSJ_01",
fromFloorNo = 1,
floorNo = 4,
useFlag = 1,
createBy = "一楼接驳位",
createTime = DateTime.Now,
remark = "一楼创建入库任务"
};
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(newTask);
dbContext.Add(wcsTaskLog);
dbContext.Add(newTask);
dbContext.SaveChanges();
}
else
{
//根据托盘号获取物料码
var material = dbContext.MesBasePalletInfo.Where(t => t.palletInfoCode == RFID001Value).FirstOrDefault();
WcsTaskLog? taskLog = dbContext.WcsTaskLog.Where(t => t.containerNo == RFID001Value).OrderByDescending(t => t.createTime).FirstOrDefault();
objid = StaticData.SnowId.NextId(),
serialNo = SystemData.GetSerialNo(dbContext),
equipmentNo = "F01",
taskType = 5,
taskStatus = 0,
containerNo = RFID001Value,
currPointId = F01,
currPointNo = "TSJ_01",
nextPointId = T01,
nextPointNo = "TSJ_01",
fromFloorNo = 1,
floorNo = 4,
useFlag = 1,
createBy = "一楼接驳位",
createTime = DateTime.Now,
remark = "一楼创建入库任务"
};
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(newTask);
dbContext.Add(wcsTaskLog);
dbContext.Add(newTask);
dbContext.SaveChanges();
}
else
{
//根据托盘号获取物料码
var material = dbContext.MesBasePalletInfo.Where(t => t.palletInfoCode == RFID001Value).FirstOrDefault();
WcsTaskLog? taskLog = dbContext.WcsTaskLog.Where(t => t.containerNo == RFID001Value).OrderByDescending(t => t.createTime).FirstOrDefault();
if (material != null)
if (material != null)
{
if (string.IsNullOrEmpty(material.materialBarcode))
{
if (taskLog != null)
continue;
}
bool hasBarInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.palletInfoCode == RFID001Value && t.barcodeInfo == material.materialBarcode).Any();
if (!hasBarInfo)
{
continue;
}
if (taskLog != null)
{
if (taskLog.materialBarcode == material.materialBarcode)
{
if (taskLog.materialBarcode == material.materialBarcode)
if (baseEquip.containerNo == "0")
{
if (baseEquip.containerNo == "0")
{
baseEquip.containerNo = null;
dbContext.Update(baseEquip);
dbContext.SaveChanges();
_logger.Info("一楼接驳位线程:托盘" + RFID001Value + "解绑信息更新成功");
}
else if (baseEquip.containerNo != RFID001Value)
{
baseEquip.containerNo = RFID001Value;
dbContext.Update(baseEquip);
dbContext.SaveChanges();
_logger.Info("一楼接驳位线程:托盘" + RFID001Value + "绑定信息更新成功");
Console.WriteLine(DateTime.Now + ":一楼接驳位线程:托盘" + RFID001Value + "绑定信息更新成功");
Thread.Sleep(3000);
continue;
}
else
{
Thread.Sleep(3000);
continue;
}
baseEquip.containerNo = null;
dbContext.Update(baseEquip);
dbContext.SaveChanges();
_logger.Info("一楼接驳位线程:托盘" + RFID001Value + "解绑信息更新成功");
}
else if (baseEquip.containerNo != RFID001Value)
{
baseEquip.containerNo = RFID001Value;
dbContext.Update(baseEquip);
dbContext.SaveChanges();
_logger.Info("一楼接驳位线程:托盘" + RFID001Value + "绑定信息更新成功");
Console.WriteLine(DateTime.Now + ":一楼接驳位线程:托盘" + RFID001Value + "绑定信息更新成功");
Thread.Sleep(3000);
continue;
}
else
{
Thread.Sleep(3000);
continue;
}
}
}
var warehouseId = dbContext.WmsWarehouseMaterial.Where(t => t.storageType == "1" && t.storageId == material.materialId).FirstOrDefault()?.warehouseId;
if (warehouseId != null)
var warehouseId = dbContext.WmsWarehouseMaterial.Where(t => t.storageType == "1" && t.storageId == material.materialId).FirstOrDefault()?.warehouseId;
if (warehouseId != null)
{
var TargetFloor = dbContext.WmsBaseWarehouse.Where(t => t.warehouseId == warehouseId).FirstOrDefault();
if (TargetFloor != null)
{
var TargetFloor = dbContext.WmsBaseWarehouse.Where(t => t.warehouseId == warehouseId).FirstOrDefault();
if (TargetFloor != null)
{
//插入task表
//插入task表
var dic = StaticData.BaseDictionary.Where(t => t.dicKey == "TaskType" && t.agvType == "I" && t.dicField == TargetFloor.warehouseInstockType).FirstOrDefault();
if (dic != null)
var dic = StaticData.BaseDictionary.Where(t => t.dicKey == "TaskType" && t.agvType == "I" && t.dicField == TargetFloor.warehouseInstockType).FirstOrDefault();
if (dic != null)
{
var newTask = new WcsTask()
{
var newTask = new WcsTask()
{
objid = StaticData.SnowId.NextId(),
serialNo = SystemData.GetSerialNo(dbContext),
equipmentNo = "F01",
taskType = Convert.ToInt32(dic.dicValue),
taskStatus = 0,
containerNo = RFID001Value,
materialBarcode = material.materialBarcode,
materialId = material.materialId,
qty = Convert.ToInt32(material.bindAmount),
currPointId = F01,
currPointNo = "TSJ_01",
nextPointId = T01,
nextPointNo = "TSJ_01",
endPointId = warehouseId,
fromFloorNo = 1,
floorNo = TargetFloor.warehouseFloor,
useFlag = 1,
createBy = "一楼接驳位",
createTime = DateTime.Now,
remark = "一楼创建入库任务"
};
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(newTask);
dbContext.Add(wcsTaskLog);
dbContext.Add(newTask);
dbContext.SaveChanges();
}
objid = StaticData.SnowId.NextId(),
serialNo = SystemData.GetSerialNo(dbContext),
equipmentNo = "F01",
taskType = Convert.ToInt32(dic.dicValue),
taskStatus = 0,
containerNo = RFID001Value,
materialBarcode = material.materialBarcode,
materialId = material.materialId,
qty = Convert.ToInt32(material.bindAmount),
currPointId = F01,
currPointNo = "TSJ_01",
nextPointId = T01,
nextPointNo = "TSJ_01",
endPointId = warehouseId,
fromFloorNo = 1,
floorNo = TargetFloor.warehouseFloor,
useFlag = 1,
createBy = "一楼接驳位",
createTime = DateTime.Now,
remark = "一楼创建入库任务"
};
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(newTask);
dbContext.Add(wcsTaskLog);
dbContext.Add(newTask);
dbContext.SaveChanges();
}
}
}
}
}
}
else
{
if (string.IsNullOrEmpty(task.containerNo))//人工调出
{
if (task.useFlag == 1)
{
if (task.qty > 1)//多个托盘
{
if (task.endPointId != 1)
{
task.nextPointId = 6;
dbContext.SaveChanges();
}
}
else if (task.qty == 1)
{
if (task.endPointId != 1)
{
task.nextPointId = 6;
task.containerNo = RFID001Value;
dbContext.SaveChanges();
}
}
}
}
else
{
if (string.IsNullOrEmpty(task.containerNo))//人工调出
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == RFID001Value);
if (mesBasePalletInfo != null)
{
if (task.useFlag == 1)
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.palletInfoCode == RFID001Value).FirstOrDefault();
if (mesBaseBarcodeInfo != null)
{
if (task.qty > 1)//多个托盘
{
if (task.endPointId != 1)
{
task.nextPointId = 6;
dbContext.SaveChanges();
}
}
else if (task.qty == 1)
{
if (task.endPointId != 1)
{
task.nextPointId = 6;
task.containerNo = RFID001Value;
dbContext.SaveChanges();
}
}
}
}
else
{
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == RFID001Value);
if (mesBasePalletInfo != null)
{
mesBasePalletInfo.bindAmount = null;
mesBasePalletInfo.bindAmount = null;
mesBasePalletInfo.materialBarcode = null;
mesBasePalletInfo.materialCode = null;
mesBasePalletInfo.materialId = null;
mesBasePalletInfo.materialName = null;
mesBasePalletInfo.updateBy = "WCS";
mesBasePalletInfo.updateTime = DateTime.Now;
dbContext.Update(mesBasePalletInfo);
dbContext.Remove(task);
dbContext.WcsTaskLog.Where(t => t.objid == task.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
dbContext.SaveChanges();
mesBaseBarcodeInfo.palletInfoCode = null;
dbContext.Update(mesBaseBarcodeInfo);
}
mesBasePalletInfo.bindAmount = null;
mesBasePalletInfo.bindAmount = null;
mesBasePalletInfo.materialBarcode = null;
mesBasePalletInfo.materialCode = null;
mesBasePalletInfo.materialId = null;
mesBasePalletInfo.materialName = null;
mesBasePalletInfo.updateBy = "WCS";
mesBasePalletInfo.updateTime = DateTime.Now;
dbContext.Update(mesBasePalletInfo);
dbContext.Remove(task);
dbContext.WcsTaskLog.Where(t => t.objid == task.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
dbContext.SaveChanges();
}
}
}
@ -457,14 +469,14 @@ namespace Khd.Core.Wcs.Wcs
{
if (ex is PlcException)
{
}
else
{
_logger.Error(ex.Message + "\n" + ex.StackTrace);
}
}
Thread.Sleep(1000);
Thread.Sleep(3000);
}
}
@ -512,6 +524,7 @@ namespace Khd.Core.Wcs.Wcs
_logger.Info("提升机线程:" + wcsTask.floorNo + "楼接驳位有AGV任务跳过当前任务");
continue;
}
BasePlcpoint floorPoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "RFID00" + wcsTask.fromFloorNo);
if (wcsTask.containerNo == StaticData.PlcDic[0].ReadRFID(floorPoint.plcpointAddress) || (string.IsNullOrEmpty(wcsTask.containerNo) && wcsTask.qty > 1))
{
@ -697,7 +710,7 @@ namespace Khd.Core.Wcs.Wcs
{
if (ex is PlcException)
{
}
else
{

@ -59,6 +59,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var taskList = dbContext.WcsTask
.Where(t => t.useFlag == 1)
.Where(t=>t.IsDelete==0)
.Where(t => t.nextPointId == agvID).OrderBy(t => t.createTime).ToList();
foreach (var item in taskList)
{
@ -88,7 +89,7 @@ namespace Khd.Core.Wcs.Wcs
}
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
BaseEquip nextEquip = StaticData.BaseEquip.First(t => t.floorNo == 5 && t.equipType == 1);
RequestAGVTaskDto agvTask = new()
RequestAGVTaskDto agvTask = new ()
{
reqCode = StaticData.SnowId.NextId().ToString(),
positionCodePath = new List<Position>
@ -125,7 +126,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
@ -168,7 +169,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 34)//背板安装到半成品
@ -209,7 +210,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 46)//原材料到拆分区
@ -250,7 +251,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 28)//拆分区返库
@ -292,7 +293,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 47)//原材料入库
@ -333,7 +334,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 66)//移库
@ -374,7 +375,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
}
@ -434,7 +435,7 @@ namespace Khd.Core.Wcs.Wcs
var wmsRawStock = dbContext.WmsRawStock.Where(t => t.locationCode == item.currPointNo).FirstOrDefault();
if (wmsRawStock != null)
{
wmsRawStock.locationCode = item.endPointNo;
wmsRawStock.locationCode = item.currPointNo;
dbContext.Update(wmsRawStock);
}
else
@ -748,7 +749,7 @@ namespace Khd.Core.Wcs.Wcs
instockBatch = mesBaseBarcodeInfo.barcodeInfo,
updateBy = "WCS",
updateDate = DateTime.Now,
warehouseId = 511
warehouseId = 511,
};
BaseEquip lineEquip = dbContext.BaseEquip.First(t => t.objid == 5);
lineEquip.equipStatus = 0;

@ -53,12 +53,10 @@ namespace Khd.Core.Wcs.Wcs
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var taskList = dbContext.WcsTask
.Where(t => t.IsDelete == 0)
.Where(t => t.nextPointId == agvID)
.OrderBy(t => t.createTime).ToList();
if (taskList.Count == 0)
{
_logger.Info(FloorNo + "楼AGV无任务");
}
foreach (var item in taskList)//出库
{
if (item.taskStatus == 0)//下发任务

@ -50,7 +50,7 @@ namespace Khd.Core.Wcs.Wcs
Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
FlowPointThread.IsBackground = true;
FlowPointThread.Name= "FiveFloorCTU";
FlowPointThread.Name = "FiveFloorCTU";
FlowPointThread.Start();
Thread FlowCTUInWareThread = new Thread(MonitorInWare);
@ -78,7 +78,7 @@ namespace Khd.Core.Wcs.Wcs
}
catch
{
}
Thread.Sleep(1000);
}
@ -88,7 +88,6 @@ namespace Khd.Core.Wcs.Wcs
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
//bool IsStart = false;
while (true)
{
try
@ -231,39 +230,30 @@ namespace Khd.Core.Wcs.Wcs
{
if (!Convert.ToBoolean(waring))
{
StaticData.PlcDic[1].WriteToPoint(CtuLineWaring.plcpointAddress, "true", CtuLineWaring.plcpointLength.ToString());
StaticData.PlcDic[1].WriteToPoint(CtuLineWaring.plcpointAddress, true, CtuLineWaring.plcpointLength.ToString());
}
}
else if (receiveMaterial != null && Convert.ToInt32(receiveMaterial) == 1)
{
//Task.Run(() =>
//{
// var receiveMaterial2 = StaticData.PlcDic[1].Read(ReceiveMaterial.plcpointAddress);
// while (receiveMaterial2 != null && Convert.ToInt32(receiveMaterial2) == 1)
// {
// receiveMaterial2 = StaticData.PlcDic[1].Read(ReceiveMaterial.plcpointAddress);
// lock (SystemData.outStockLock)
// {
// WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
// bool haveTask = dbContext.WcsTask.Where(t => t.nextPointId == 11).Any();
// if (!haveTask && wcsOutstockLock.boxStatus == 1)
// {
// wcsOutstockLock.boxStatus = 0;
// wcsOutstockLock.qty = 0;
// dbContext.Update(wcsOutstockLock);
// dbContext.SaveChanges();
// }
// }
// Thread.Sleep(3000);
// }
//});
}
//else if (receiveMaterial != null && Convert.ToInt32(receiveMaterial) == 0)
//{
// lock (SystemData.outStockLock)
// {
// WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
// bool haveTask = dbContext.WcsTask.Where(t => t.nextPointId == 11).Any();
// if (!haveTask && wcsOutstockLock.boxStatus == 1)
// {
// wcsOutstockLock.boxStatus = 0;
// wcsOutstockLock.qty = 0;
// dbContext.Update(wcsOutstockLock);
// dbContext.SaveChanges();
// }
// }
//}
}
catch (Exception ex)
{
if (ex is PlcException)
{
}
else
{
@ -363,11 +353,8 @@ namespace Khd.Core.Wcs.Wcs
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var taskList = dbContext.WcsTask
.Where(t => t.useFlag == 1)
.Where(t => t.IsDelete == 0)
.Where(t => t.nextPointId == CTUID).OrderByDescending(t => t.ud1).ToList();
if (taskList.Count == 0)
{
_logger.Info(FloorNo + "楼CTU无任务");
}
foreach (var item in taskList)
{
if (item.taskStatus == 0)//CTU会同时生成多个任务生成就下发
@ -450,16 +437,12 @@ namespace Khd.Core.Wcs.Wcs
item.taskStatus = 1;
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 1 });
dbContext.Update(item);
int ctuTaskCount = dbContext.WcsTask.Where(t => t.taskType == 29).Count();
lock (SystemData.outStockLock)
{
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
if (ctuTaskCount >= 6 || wcsOutstockLock.qty == ctuTaskCount)//如果CTU当前任务数量很多取消预执行任务
bool hasTask = dbContext.WcsTask.Where(t=>t.nextPointId==11&&t.taskType==30).Any();
if (!hasTask)//如果CTU当前任务数量很多取消预执行任务
{
ExecuteInTask(baseEquip);
wcsOutstockLock.qty = 0;
wcsOutstockLock.boxStatus = 0;
dbContext.Update(wcsOutstockLock);
}
}
dbContext.SaveChanges();
@ -605,14 +588,6 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Remove(item);
dbContext.SaveChanges();
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 6 });
lock (SystemData.outStockLock)
{
WcsOutstockLock wcsOutstockLock = dbContext.WcsOutstockLock.Where(t => t.warehouseId == 512).First();
wcsOutstockLock.qty = 0;
wcsOutstockLock.boxStatus = 0;
dbContext.Update(wcsOutstockLock);
dbContext.SaveChanges();
}
}
else if (item.taskType == 100)//出库任务
{
@ -639,7 +614,7 @@ namespace Khd.Core.Wcs.Wcs
{
if (ex is PlcException)
{
}
else
{

@ -61,6 +61,7 @@ namespace Khd.Core.Wcs.Wcs
//获取条码号,如果该条码任务存在就继续任务,如果条码不存在,创建入库任务并调度agv
var taskList = dbContext.WcsTask
.Where(t => t.useFlag == 1)
.Where(t => t.IsDelete == 0)
.Where(t => t.nextPointId == EquipID).OrderBy(t => t.createTime).ToList();
foreach (var item in taskList)
{
@ -103,7 +104,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 56)//废料工位-库位
@ -144,7 +145,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 49)//小包出口-库位
@ -185,7 +186,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("二楼Agv下发任务失败" + item.taskType + message);
_logger.Info("二楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 57)//周转位-小包入口
@ -225,7 +226,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 50)//库位-提升机
@ -270,7 +271,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
}
@ -313,7 +314,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 53)//提升机-废料工位
@ -352,7 +353,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 54)//周转位-废料工位
@ -394,7 +395,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
}
@ -435,7 +436,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 59)//周转位-小包入口
@ -477,7 +478,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
}
@ -744,7 +745,7 @@ namespace Khd.Core.Wcs.Wcs
var wmsProductStock = dbContext.WmsProductStock.FirstOrDefault(t => t.locationCode == item.currPointNo);
if (wmsProductStock != null)
{
wmsProductStock.locationCode = item.endPointNo;
wmsProductStock.locationCode = item.currPointNo;
dbContext.Update(wmsProductStock);
}
dbContext.WmsBaseLocation.Where(t => t.locationId == item.currPointId).Update(t => new WmsBaseLocation

@ -54,9 +54,64 @@ namespace Khd.Core.Wcs.Wcs
};
PlcHearBeat220Thread.Start();
var deleteTaskThread=new Thread(DeleteTaskLogic)
{
Name = "DeleteTaskThread",
IsBackground = true
};
deleteTaskThread.Start();
Console.WriteLine($"{DateTime.Now}: SystemTimer started");
}
private void DeleteTaskLogic(object? obj)
{
using var scope = host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
while (true)
{
try
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => t.IsDelete == 1).ToList();
foreach (var item in wcsTasks)
{
if (!string.IsNullOrEmpty(item.taskCode))
{
BaseEquip agvEquip = StaticData.BaseEquip.First(t=>t.objid==item.nextPointId);
dbContext.WcsTask.Remove(item);
var cancelTask = new
{
reqCode = StaticData.SnowId.NextId().ToString(),
taskCode = item.taskCode
};
string reponse = HttpHelper.SendPostMessage(agvEquip.serverIp, agvEquip.serverPort.Value, "rcms/services/rest/hikRpcService/cancelTask", cancelTask.ToJsonString());
var result = JsonConvert.DeserializeObject<ReponseMessage>(reponse);
if (result != null && result.code == "0")
{
dbContext.SaveChanges();
_logger.Info($"任务{item.taskCode}已删除");
}
else
{
_logger.Error($"任务{item.taskCode}删除失败,原因:{result?.message}");
}
}
else
{
dbContext.WcsTask.Remove(item);
dbContext.SaveChanges();
_logger.Info($"任务{item.objid}已删除");
}
}
}
catch
{
}
Thread.Sleep(1000);
}
}
private void PlcHearBeat220Logic(object? obj)
{
BasePlcpoint HeartBeat30 = StaticData.BasePlcpointList.First(t => t.plcpointNo == "putTray");

@ -64,7 +64,7 @@ namespace Khd.Core.Wcs.Wcs
var getTrayValue = StaticData.PlcDic[2].Read(getTrayPoint.plcpointAddress);
if (getTrayValue != null && Convert.ToBoolean(getTrayValue))
{
var task = dbContext.WcsTask.Where(t => t.taskType == 42 && t.useFlag == 0).FirstOrDefault();
var task = dbContext.WcsTask.Where(t => t.IsDelete == 0).Where(t => t.taskType == 42 && t.useFlag == 0).FirstOrDefault();
if (task != null)
{
BaseEquip endEquip = dbContext.BaseEquip.First(t => t.objid == 35);
@ -98,7 +98,7 @@ namespace Khd.Core.Wcs.Wcs
{
if (ex is PlcException)
{
}
else
{
@ -164,7 +164,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("五楼Agv下发任务失败" + item.taskType + message);
_logger.Info("五楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 39)//提升机-库位
@ -205,14 +205,14 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("三楼Agv下发任务失败" + item.taskType + message);
_logger.Info("三楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 41)//库位-翻转机
{
BasePlcpoint basePlcpoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "putTray");
var callMaterial = StaticData.PlcDic[2].Read(basePlcpoint.plcpointAddress);
if (callMaterial != null&&Convert.ToBoolean(callMaterial))
if (callMaterial != null && Convert.ToBoolean(callMaterial))
{
WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.FirstOrDefault(t => t.rawOutstockId == item.orderId && t.executeStatus == "0");
if (wmsRawOutstockDetail != null)
@ -257,7 +257,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("三楼Agv下发任务失败" + item.taskType + message);
_logger.Info("三楼Agv下发任务失败" + item.taskType + result);
}
}
}
@ -301,7 +301,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("三楼Agv下发任务失败" + item.taskType + message);
_logger.Info("三楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 42)//翻转机-收集架
@ -343,7 +343,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("三楼Agv下发任务失败" + item.taskType + message);
_logger.Info("三楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 43)//收集架-周转区
@ -386,7 +386,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("三楼Agv下发任务失败" + item.taskType + message);
_logger.Info("三楼Agv下发任务失败" + item.taskType + result);
}
}
else if (item.taskType == 44)//周转区-提升机
@ -395,7 +395,7 @@ namespace Khd.Core.Wcs.Wcs
BaseEquip lineEquip = dbContext.BaseEquip.First(t => t.objid == 3);
if (lineEquip.equipStatus == 0)
{
var agvTask = new RequestAGVTaskDto
{
reqCode = StaticData.SnowId.NextId().ToString().ToString(),
@ -433,7 +433,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("三楼Agv下发任务失败" + item.taskType + message);
_logger.Info("三楼Agv下发任务失败" + item.taskType + result);
}
}
}
@ -480,14 +480,14 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
_logger.Info("三楼Agv下发任务失败" + item.taskType + message);
_logger.Info("三楼Agv下发任务失败" + item.taskType + result);
}
}
}
}
else
{
{
if (item.taskStatus == 3)
{
@ -547,7 +547,7 @@ namespace Khd.Core.Wcs.Wcs
var wmsRawStock = dbContext.WmsRawStock.Where(t => t.locationCode == item.endPointNo).FirstOrDefault();
if (wmsRawStock != null)
{
wmsRawStock.locationCode = item.endPointNo;
wmsRawStock.locationCode = item.currPointNo;
dbContext.Update(wmsRawStock);
}
dbContext.WmsBaseLocation.Where(t => t.locationId == item.currPointId).Update(t => new WmsBaseLocation
@ -591,7 +591,7 @@ namespace Khd.Core.Wcs.Wcs
{
rawStockId = StaticData.SnowId.NextId(),
activeFlag = "1",
saleOrderId = mesBaseBarcodeInfo.saleOrderId==null?0:mesBaseBarcodeInfo.saleOrderId,
saleOrderId = mesBaseBarcodeInfo.saleOrderId == null ? 0 : mesBaseBarcodeInfo.saleOrderId,
stockType = "1",
supplierId = mesBaseBarcodeInfo.manufacturerId,
qualityStatus = "1",
@ -687,6 +687,12 @@ namespace Khd.Core.Wcs.Wcs
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == item.containerNo);
if (mesBasePalletInfo != null)
{
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.palletInfoCode == item.containerNo).FirstOrDefault();
if (mesBaseBarcodeInfo != null)
{
mesBaseBarcodeInfo.palletInfoCode = null;
dbContext.Update(mesBaseBarcodeInfo);
}
mesBasePalletInfo.bindAmount = null;
mesBasePalletInfo.materialBarcode = null;
mesBasePalletInfo.materialCode = null;
@ -755,7 +761,7 @@ namespace Khd.Core.Wcs.Wcs
{
if (ex is PlcException)
{
}
else
{
@ -768,6 +774,5 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
}
}

@ -13,7 +13,7 @@
"Rack": 0,
"Slot": 1,
"Code": 0
},//
}, //
{
"IP": "192.168.2.31",
"Port": 102, //102
@ -21,7 +21,7 @@
"Rack": 0,
"Slot": 1,
"Code": 1
},//U线
}, //U线
{
"IP": "192.168.2.220",
"Port": 102, //102
@ -29,7 +29,7 @@
"Rack": 0,
"Slot": 1,
"Code": 2
}//
} //
],
"PLCSetting": {
"Mode": "0",

@ -1518,16 +1518,15 @@
Header="托盘号"
IsReadOnly="True" />
<DataGridTemplateColumn
Visibility="Collapsed"
Width="300"
MinWidth="10"
Header=" 操作"
IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Content="清除" Style="{StaticResource ButtonPrimary}" FontSize="25" Width="125" Height="75" Click="clearLocation_Click"/>
<Button Content="出库" Style="{StaticResource ButtonPrimary}" FontSize="25" Width="125" Height="75" Click="outLocation_Click"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<!--<Button Content="清除" Style="{StaticResource ButtonPrimary}" FontSize="25" Width="125" Height="75" Click="clearLocation_Click"/>-->
<Button Content="出库" Style="{StaticResource ButtonPrimary}" FontSize="25" Width="125" Height="75" Click="outLocation_Click"/>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>

@ -522,6 +522,7 @@ namespace Khd.Core.Wpf.Form
}
var data = dbContext.WcsTask
.WhereIf(nextPointId != 0, t => t.nextPointId == nextPointId)
.Where(t => t.IsDelete != 1)
.Where(t => t.containerNo.Contains(palletNo) && t.equipmentNo.Contains(equipCode)).ToList();
List<taskModel> taskModel = CoreMapper.Map<List<taskModel>>(data);
SelectedItem.Clear();
@ -572,40 +573,20 @@ namespace Khd.Core.Wpf.Form
}
}
BaseEquip agvEquip = SystemData.BaseEquip.First(t => t.objid == 10);
List<WcsCmd> wcsCmds = dbContext.WcsCmd.Where(t => ids.Contains(t.taskId)).ToList();
List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => ids.Contains(t.objid)).ToList();
foreach (var item in wcsCmds)
foreach (var item in wcsTasks)
{
var cancelTask = new
if (string.IsNullOrEmpty(item.taskCode))
{
reqCode = Global.SnowId.NextId().ToString(),
taskCode = item.taskCode
};
string reponse = HttpHelper.SendPostMessage(agvEquip.serverIp, agvEquip.serverPort.Value, "rcms/services/rest/hikRpcService/cancelTask", cancelTask.ToJsonString());
var result = JsonConvert.DeserializeObject<ReponseMessage>(reponse);
if (result != null && result.code == "0")
{
WcsTask? wcsTask = wcsTasks.Where(t => t.objid == item.taskId).FirstOrDefault();
if (wcsTask != null)
{
dbContext.Remove(wcsTask);
}
ids.Remove(item.taskId);
dbContext.Remove(item);
dbContext.WcsTaskLog.Where(t => ids.Contains(t.objid)).Update(t => new WcsTaskLog { IsDelete = 1 });
dbContext.SaveChanges();
}
else
{
MessageBoxResult messageBoxResult1 = MessageBox.Show("取消小车端任务失败,是否继续删除调度任务?", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (messageBoxResult1 == MessageBoxResult.Yes)
{
ids.Remove(item.taskId);
dbContext.Remove(item);
dbContext.WcsTaskLog.Where(t => ids.Contains(t.objid)).Update(t => new WcsTaskLog { IsDelete = 1 });
dbContext.SaveChanges();
}
item.IsDelete = 1;
dbContext.Update(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog { IsDelete = 1 });
}
dbContext.SaveChanges();
}
GetTask();
}
@ -1569,7 +1550,7 @@ namespace Khd.Core.Wpf.Form
}
else
{
txtInScan.IsReadOnly = true;
txtInScan.IsReadOnly = false;
}
}
}
@ -1766,21 +1747,27 @@ namespace Khd.Core.Wpf.Form
}
else
{
MessageBox.Show("该条码的销售订单不正确");
txtOutScan.Text = string.Empty;
txtOutBarCode.Text = string.Empty;
return;
//wmsRawStock.totalAmount -= outScan;
//if (wmsRawStock.totalAmount == 0)
//{
// dbContext.WmsRawStock.Remove(wmsRawStock);
// dbContext.SaveChanges();
//}
//else
//{
// dbContext.WmsRawStock.Update(wmsRawStock);
// dbContext.SaveChanges();
//}
if (mesBaseBarcodeInfo.PurchaseOrderId == null)
{
wmsRawStock.totalAmount -= outScan;
if (wmsRawStock.totalAmount == 0)
{
dbContext.WmsRawStock.Remove(wmsRawStock);
dbContext.SaveChanges();
}
else
{
dbContext.WmsRawStock.Update(wmsRawStock);
dbContext.SaveChanges();
}
}
else
{
MessageBox.Show("该条码的销售订单不正确");
txtOutScan.Text = string.Empty;
txtOutBarCode.Text = string.Empty;
return;
}
}
MessageBox.Show("出库成功!");

@ -108,7 +108,7 @@ namespace Khd.Core.Wpf.TaskForm
createTime = DateTime.Now,
equipmentNo = startEquip.equipNo,
useFlag = 0,
qty = Convert.ToInt32(EmptyCount.SelectedItem),
qty = Convert.ToInt32(EmptyCount.SelectedIndex)+1,
isEmpty = "1"
};
dbContext.Add(wcsTask);

@ -65,7 +65,7 @@
</DataGridTemplateColumn>
<DataGridTextColumn
Width="200*"
Binding="{Binding MenuName}"
Binding="{Binding MenuIcon}"
CanUserSort="False"
FontSize="20"
ElementStyle="{StaticResource dgCell}"

@ -96,6 +96,7 @@ namespace Khd.Core.Wpf.TaskForm
{
public long OBJID { get; set; }
public string MenuName { get; set; }
public string MenuIcon { get; set; }
public bool IsSeleted { get; set; }
}
}

@ -68,6 +68,19 @@ namespace Khd.Core.Wpf.myConverter
{5,"已到达目的地" },
{6,"任务结束" }
}
},
{
11,
new Dictionary<int?, string>(){
{-1,"人工创建" },
{0,"未下发" },
{1,"已下发" },
{2,"已开始" },
{3,"已到达起始地" },
{4,"起始地继续任务" },
{5,"已到达目的地" },
{6,"任务结束" }
}
}
};
private DataGridRow GetDataGridRow(DependencyObject dependencyObject)

Loading…
Cancel
Save