更新wcs api

master
sunzy 2 years ago
parent 39ddeacd25
commit 55c7d9a67f

@ -1,38 +0,0 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Khd.Core.Application.Interface;
using Khd.Core.Domain.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Masuit.Tools.Logging;
using System;
using NuGet.Protocol;
using Khd.Core.Application;
using Khd.Core.Domain.Dto.webapi;
using Microsoft.Build.Utilities;
using Masuit.Tools;
namespace Khd.Core.Api.Controllers
{
[Route("wcs/[controller]")]
[ApiController]
public class ReceiveProdPlanController : ControllerBase
{
//private readonly IMesProdPlanApplication _application;
//public ReceiveProdPlanController(IMesProdPlanApplication application)
//{
// _application = application;
//}
[HttpPost]
public ReponseBase SaveProdPlan(RequestInfo model)
{
LogManager.Info($"收到MES接口信息{model.ToJsonString()}");
//return _application.SaveProdPlan(model);
return null;
}
}
}

@ -0,0 +1,42 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Khd.Core.Application.Interface;
using Khd.Core.Domain.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Masuit.Tools.Logging;
using System;
using NuGet.Protocol;
using Khd.Core.Application;
using Khd.Core.Domain.Dto.webapi;
using Microsoft.Build.Utilities;
using Masuit.Tools;
namespace Khd.Core.Api.Controllers
{
[Route("wcs/[controller]")]
[ApiController]
public class RecieveRcsController : ControllerBase
{
private readonly IWcsTaskApplication _application;
public RecieveRcsController(IWcsTaskApplication application)
{
_application = application;
}
/// <summary>
/// 接收agv接收任务通知接口
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost("agvCallback")]
public ReponseagvCallbackDto agvCallback(string a)
{
LogManager.Info($"RecieveRcsController接口信息{a.ToJsonString()}");
agvCallbackDto agvCallbackDto=new agvCallbackDto();
return _application.AgvCallback(agvCallbackDto);
}
}
}

@ -11,7 +11,7 @@
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "server=106.12.13.113;port=3336;database=khd_suspension_chain;uid=khd;pwd=khd@123;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True"
"DefaultConnection": "server=106.12.13.113;port=3336;database=khd_jyhb;uid=khd;pwd=khd@123;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True"
// "DefaultConnection": "Data Source=localhost;Initial Catalog=lanju_op_xiaolan_ds;Persist Security Info=True;User ID=sa;Password=root;MultipleActiveResultSets=True;TrustServerCertificate=True",
//"DefaultConnection": "Data Source=121.36.58.109;Initial Catalog=lanju_op_xiaolan_ds;Persist Security Info=True;User ID=sa;Password=haiwei@123;MultipleActiveResultSets=True;TrustServerCertificate=True"
},

@ -8,7 +8,7 @@ namespace Khd.Core.Application
{
public static void AddApplication(this IServiceCollection services)
{
//services.AddTransient<IMesProdPlanApplication, MesProdPlanApplication>();
services.AddTransient<IWcsTaskApplication, WcsTaskApplication>();
}
}
}

@ -7,6 +7,6 @@ namespace Khd.Core.Application.Interface
{
}
public interface IProWetMaterialPlanDetail<TEntity> { }
}

@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Khd.Core.Domain.Dto.webapi;
using Khd.Core.Domain.Models;
namespace Khd.Core.Application.Interface
{
public interface IWcsTaskApplication : IBaseApplication<WcsTask>
{
WcsTask Get(int id);
WcsTask Add(WcsTask model);
WcsTask Update(WcsTask model);
ReponseagvCallbackDto AgvCallback(agvCallbackDto agvCallbackDto);
}
}

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Khd.Core.Application.Interface;
using Khd.Core.Domain.Dto.webapi;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Masuit.Tools;
using Masuit.Tools.Logging;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.Extensions.DependencyInjection;
using Z.EntityFramework.Plus;
namespace Khd.Core.Application
{
public class WcsTaskApplication : IWcsTaskApplication
{
private readonly DefaultDbContext _dbContext;
public WcsTaskApplication(IServiceProvider serviceProvider)
{
_dbContext = serviceProvider.GetService<DefaultDbContext>();
}
public WcsTask Get(int id)
{
var entity = _dbContext.WcsTask
.Where(c => 1== 1)
.FirstOrDefault();
return entity;
}
public WcsTask Add(WcsTask model)
{
var entity = _dbContext.Add(model);
_dbContext.SaveChanges();
return entity.Entity;
}
public WcsTask Update(WcsTask model)
{
var list = _dbContext.WcsTask.Where(t => t.objid == model.objid).Update(a => model);
return model;
}
/// <summary>
/// 接收agv接收任务通知接口
/// </summary>
/// <param name="agvCallbackDto"></param>
/// <returns></returns>
public ReponseagvCallbackDto AgvCallback(agvCallbackDto agvCallbackDto)
{
ReponseagvCallbackDto reponseagvCallbackDto = new ReponseagvCallbackDto();
//记录日志
LogManager.Info("AgvCallback入参:"+ agvCallbackDto.ToJsonString());
//处理逻辑
//返回请求
reponseagvCallbackDto.code = "0";
reponseagvCallbackDto.message = "成功";
reponseagvCallbackDto.reqCode = reponseagvCallbackDto.reqCode;
return reponseagvCallbackDto;
}
}
}

@ -12,4 +12,44 @@ namespace Khd.Core.Domain.Dto.webapi
public string CODE { get; set; }
public string MESSAGE { get; set; }
}
/// <summary>
/// 手工出库参数
/// </summary>
public class ManualOutWareDto
{
public string MATERIAL_CODE { get; set; }
public string BATCH_NO { get; set; }
public int QTY { get; set; }
public string LOCALTION_CODE { get; set; }
public string ORDER_CODE { get; set; }
public string WARE_TYPE { get; set; }
public string CREATE_TIME { get; set; }
}
/// <summary>
/// 盘点参数
/// </summary>
public class CheckDto
{
public string MATERIAL_CODE { get; set; }
public string BATCH_NO { get; set; }
public int QTY { get; set; }
public string LOCALTION_CODE { get; set; }
public string CHECK_CODE { get; set; }
public string CREATE_TIME { get; set; }
}
/// <summary>
/// 手工出库入参
/// </summary>
public class RequestManualOutWare
{
List<ManualOutWareDto> DATA { get; set; }
}
/// <summary>
/// 盘点入参
/// </summary>
public class RequestCheck
{
List<CheckDto> DATA { get; set; }
}
}

@ -3,6 +3,7 @@ using System.Collections.Generic;
namespace Khd.Core.Domain.Dto.webapi
{
//RCS调用WCS接口参数
public class agvCallbackDto
{
/// <summary>
@ -34,5 +35,21 @@ namespace Khd.Core.Domain.Dto.webapi
public string seq { get; set; }
public string eqpCode { get; set; }
}
public class ReponseagvCallbackDto
{
/// <summary>
/// 返回码
/// </summary>
public string code { get; set; }
/// <summary>
/// 返回消息
/// </summary>
public string message { get; set; }
/// <summary>
/// 请求编号
/// </summary>
public string reqCode { get; set; }
}
}

@ -135,6 +135,12 @@ namespace Khd.Core.Domain.Models
/// </summary>
[Column("remark")]
public string remark { get; set; }
/// <summary>
/// 下发标志
/// </summary>
[Column("send_flag")]
public int? sendFlag { get; set; }
}
}

@ -62,7 +62,7 @@ namespace Khd.Core.Domain.Models
/// 物料号
/// </summary>
[Column("material_no")]
public int? materialNo { get; set; }
public string? materialNo { get; set; }
/// <summary>
/// 数量
@ -177,6 +177,8 @@ namespace Khd.Core.Domain.Models
/// </summary>
[Column("remark")]
public string remark { get; set; }
}
}

@ -113,7 +113,6 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Add(wcsTask);
dbContext.SaveChanges();
}
}
}
catch (Exception ex)

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Khd.Core.Wcs.Wcs
{
/// <summary>
/// 下件点线程
/// </summary>
public class DownLine
{
}
}

@ -23,16 +23,20 @@ using Thrift.Protocol;
using System.Security.Cryptography.Xml;
using Z.EntityFramework.Plus;
using System.Net.NetworkInformation;
using Khd.Core.Application.Interface;
using Khd.Core.Application;
namespace Khd.Core.Wcs.Wcs
{
/// <summary>
/// 一楼线程
/// 一楼线程(包括接驳位,提升机调度)
/// </summary>
public class FirstFloor
{
private readonly IHost _host;
private readonly Plc.S7.Plc _plc;
private long F01=1;
private long T01 = 6;
/// <summary>
/// 一楼RFID 读
/// </summary>
@ -53,35 +57,82 @@ namespace Khd.Core.Wcs.Wcs
/// 流水号 读
/// </summary>
BasePlcpoint? serialno01 { get; set; }
/// <summary>
/// 反馈流水号 写
/// </summary>
BasePlcpoint? feedserialno01 { get; set; }
/// <summary>
/// 一楼提升机流水号 读
/// 提升机流水号 读
/// </summary>
BasePlcpoint? serialno06 { get; set; }
/// <summary>
/// 一楼提升机状态 读
/// 提升机状态 读
/// </summary>
BasePlcpoint? equipstate06 { get; set; }
/// <summary>
/// 一楼提升机任务状态 读
/// 提升机任务状态 读
/// </summary>
BasePlcpoint? taskstate06 { get; set; }
/// <summary>
/// 一楼提升机当前楼层 写
/// 提升机当前楼层 写
/// </summary>
BasePlcpoint? currentfloor06 { get; set; }
/// <summary>
/// 一楼提升机目的楼层 写
/// 提升机目的楼层 写
/// </summary>
BasePlcpoint? targetfloor06 { get; set; }
/// <summary>
/// 一楼提升机到位信号 读
/// 提升机到位信号 读
/// </summary>
BasePlcpoint? linesignal06 { get; set; }
/// <summary>
/// 一楼提升机前允许取 读
/// </summary>
BasePlcpoint? hoisterallowedtake01 { get; set; }
/// <summary>
/// 一楼提升机前反馈流水号 读
/// </summary>
BasePlcpoint? feedserialno01 { get; set; }
/// <summary>
/// 二楼提升机前允许取 读
/// </summary>
BasePlcpoint? hoisterallowedtake02 { get; set; }
/// <summary>
/// 二楼提升机前反馈流水号 读
/// </summary>
BasePlcpoint? feedserialno02 { get; set; }
/// <summary>
/// 三楼提升机前允许取 读
/// </summary>
BasePlcpoint? hoisterallowedtake03 { get; set; }
/// <summary>
/// 三楼提升机前反馈流水号 读
/// </summary>
BasePlcpoint? feedserialno03 { get; set; }
/// <summary>
/// 四楼提升机前允许取 读
/// </summary>
BasePlcpoint? hoisterallowedtake04 { get; set; }
/// <summary>
/// 四楼提升机前反馈流水号 读
/// </summary>
BasePlcpoint? feedserialno04 { get; set; }
/// <summary>
/// 五楼提升机前允许取 读
/// </summary>
BasePlcpoint? hoisterallowedtake05 { get; set; }
/// <summary>
/// 五楼提升机前反馈流水号 读
/// </summary>
BasePlcpoint? feedserialno05 { get; set; }
public FirstFloor(IHost host, Plc.S7.Plc plc, string siteNo)
{
this._host = host;
@ -97,8 +148,7 @@ namespace Khd.Core.Wcs.Wcs
this.wcsrun01 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FirstFloorLine") && t.plcpointNo.Contains("wcsrun01"));
//流水号 读
this.serialno01 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FirstFloorLine") && t.plcpointNo.Contains("serialno01"));
//反馈流水号 写
this.feedserialno01 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FirstFloorLine") && t.plcpointNo.Contains("feedserialno01"));
//一楼提升机流水号 读
this.serialno06 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FirstFloorHoister") && t.plcpointNo.Contains("serialno06"));
@ -112,6 +162,20 @@ namespace Khd.Core.Wcs.Wcs
this.targetfloor06 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FirstFloorHoister") && t.plcpointNo.Contains("targetfloor06"));
//一楼提升机到位信号 读
this.linesignal06 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FirstFloorHoister") && t.plcpointNo.Contains("linesignal06"));
//一楼提升机前允许取
this.hoisterallowedtake01 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FirstFloorBeforeHoister") && t.plcpointNo.Contains("hoisterallowedtake01"));
//一楼提升机前反馈流水号
this.feedserialno01 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FirstFloorBeforeHoister") && t.plcpointNo.Contains("feedserialno01"));
this.hoisterallowedtake02 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("SecondFloorBeforeHoister") && t.plcpointNo.Contains("hoisterallowedtake02"));
this.feedserialno02 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("SecondFloorBeforeHoister") && t.plcpointNo.Contains("feedserialno02"));
this.hoisterallowedtake03 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("ThirdFloorBeforeHoister") && t.plcpointNo.Contains("hoisterallowedtake03"));
this.feedserialno03 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("ThirdFloorBeforeHoister") && t.plcpointNo.Contains("feedserialno03"));
this.hoisterallowedtake04 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FourthlyFloorBeforeHoister") && t.plcpointNo.Contains("hoisterallowedtake04"));
this.feedserialno04 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FourthlyFloorBeforeHoister") && t.plcpointNo.Contains("feedserialno04"));
this.hoisterallowedtake05 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FifthFloorBeforeHoister") && t.plcpointNo.Contains("hoisterallowedtake05"));
this.feedserialno05 = StaticData.BasePlcpointList.FirstOrDefault(t => t.equipmentNo.Contains("FifthFloorBeforeHoister") && t.plcpointNo.Contains("feedserialno05"));
}
/// <summary>
/// 启动线程
@ -142,7 +206,7 @@ namespace Khd.Core.Wcs.Wcs
var ispallet01Value = this._plc.Read(this.ispallet01.plcpointAddress); //是否有托盘 读
var wcsrun01Value = this._plc.Read(this.wcsrun01.plcpointAddress); //去向 写
var serialno01Value = this._plc.Read(this.serialno01.plcpointAddress); //流水号 读
var feedserialno01Value = this._plc.Read(this.feedserialno01.plcpointAddress); //反馈流水号 写
using (var scope = _host.Services.CreateScope())
{
using (var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>())
@ -153,12 +217,59 @@ namespace Khd.Core.Wcs.Wcs
//正常托盘到位
if (Convert.ToInt32(linesignal01Value) != 0 && Convert.ToInt32(serialno01Value) != 0 && Convert.ToInt32(ispallet01Value) == 1 && Convert.ToInt32(ispallet01Value) != 0)
{
//根据托盘号获取物料码
//下发去向
//判断task表里没有该rfid的未完成的入库信息未下发去向
var task = dbContext.WcsTask.Where(t => t.customerNo == RFID001Value.ToString() && t.taskStatus < 1).FirstOrDefault();
if (task == null)
{
//根据托盘号获取物料码
var material = dbContext.MesBasePalletInfo.Where(t => t.palletInfoCode == RFID001Value.ToString()).FirstOrDefault();
if (material != 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)
{
//插入task表
IWcsTaskApplication wcsTaskApplication=new WcsTaskApplication(scope.ServiceProvider);
Jc.SnowId.JcSnowId id = new Jc.SnowId.JcSnowId(1, 1);
var dic = StaticData.BaseDictionary.Where(t => t.dicKey == "TaskType" && t.ud1 == "I" && t.dicField == TargetFloor.warehouseInstockType).FirstOrDefault();
WcsTask newTask = new WcsTask()
{
objid = id.NextId(),
serialNo = Convert.ToInt32(serialno01Value),
equipmentNo = "F01",
taskType = Convert.ToInt32(dic.dicValue),
taskStatus = 0,
customerNo = RFID001Value.ToString(),
materialNo = material.materialCode,
materialId = material.materialId,
qty = Convert.ToInt32(material.bindAmount),
startPointId = F01,
startPointNo = "F01",
currPointId = F01,
currPointNo = "F01",
nextPointId = T01,
nextPointNo = "T01",
endPointId= warehouseId,
floorNo=1,
useFlag=1,
createBy= "一楼接驳位",
createTime =DateTime.Now,
remark="一楼创建入库任务"
};
wcsTaskApplication.Add(newTask);
//下发去向
this._plc.Write(this.wcsrun01.plcpointAddress, 1);
}
}
}
}
}
}
}
}
}
@ -166,14 +277,12 @@ namespace Khd.Core.Wcs.Wcs
{
LogManager.Error(ex);
}
Thread.Sleep(2000);
Thread.Sleep(1000);
}
}
/// <summary>
/// 启动一楼提升机线程
/// 提升机线程
/// </summary>
private void FirstFloorHoister()
{
@ -181,12 +290,23 @@ namespace Khd.Core.Wcs.Wcs
{
try
{
var serialno06Value = this._plc.Read(this.serialno06.plcpointAddress); //一楼提升机流水号 读
var equipstate06Value = this._plc.Read(this.equipstate06.plcpointAddress); //一楼提升机状态 读
var taskstate06Value = this._plc.Read(this.taskstate06.plcpointAddress); //一楼提升机任务状态 读
var currentfloor06Value = this._plc.Read(this.currentfloor06.plcpointAddress); //一楼提升机当前楼层 写
var targetfloor06Value = this._plc.Read(this.targetfloor06.plcpointAddress); //一楼提升机目的楼层 写
var linesignal06Value = this._plc.Read(this.linesignal06.plcpointAddress); //一楼提升机到位信号 读
var serialno06Value = this._plc.Read(this.serialno06.plcpointAddress); //提升机流水号 读
var equipstate06Value = this._plc.Read(this.equipstate06.plcpointAddress); //提升机状态 读
var taskstate06Value = this._plc.Read(this.taskstate06.plcpointAddress); //提升机任务状态 读
var currentfloor06Value = this._plc.Read(this.currentfloor06.plcpointAddress); //提升机当前楼层 写
var targetfloor06Value = this._plc.Read(this.targetfloor06.plcpointAddress); //提升机目的楼层 写
var linesignal06Value = this._plc.Read(this.linesignal06.plcpointAddress); //提升机到位信号 读
var hoisterallowedtake01Value = this._plc.Read(this.hoisterallowedtake01.plcpointAddress); //一楼提升机前允许取
var feedserialno01Value = this._plc.Read(this.feedserialno01.plcpointAddress); //一楼提升机前反馈流水号
var hoisterallowedtake02Value = this._plc.Read(this.hoisterallowedtake02.plcpointAddress); //二楼提升机前允许取
var feedserialno02Value = this._plc.Read(this.feedserialno02.plcpointAddress); //二楼提升机前反馈流水号
var hoisterallowedtake03Value = this._plc.Read(this.hoisterallowedtake03.plcpointAddress); //三楼提升机前允许取
var feedserialno03Value = this._plc.Read(this.feedserialno03.plcpointAddress); //三楼提升机前反馈流水号
var hoisterallowedtake04Value = this._plc.Read(this.hoisterallowedtake04.plcpointAddress); //四楼提升机前允许取
var feedserialno04Value = this._plc.Read(this.feedserialno04.plcpointAddress); //四楼提升机前反馈流水号
var hoisterallowedtake05Value = this._plc.Read(this.hoisterallowedtake05.plcpointAddress); //五楼提升机前允许取
var feedserialno05Value = this._plc.Read(this.feedserialno05.plcpointAddress); //五楼提升机前反馈流水号
using (var scope = _host.Services.CreateScope())
{
using (var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>())
@ -194,10 +314,144 @@ namespace Khd.Core.Wcs.Wcs
//正常读到plc值
if (serialno06Value != null && equipstate06Value != null || taskstate06Value != null || linesignal06Value != null)
{
//正常托盘到位
if (Convert.ToInt32(serialno06Value) != 0 && Convert.ToInt32(equipstate06Value) != 1 && Convert.ToInt32(linesignal06Value) == 1)
//提升机空闲
if ( Convert.ToInt32(equipstate06Value) == 0)
{
//根据流水号查询任务 分配去向
//一楼到位
if (Convert.ToInt32(hoisterallowedtake01Value) == 1 && Convert.ToInt32(feedserialno01Value) > 0)
{
var task = dbContext.WcsTask.Where(t => t.serialNo == Convert.ToInt32(feedserialno01Value)).FirstOrDefault();
if (task != null)
{
if (task.nextPointId == T01)
{
//给提升机下发去向
this._plc.Write(this.currentfloor06.plcpointAddress, 1);
this._plc.Write(this.targetfloor06.plcpointAddress,task.floorNo);
var nextPoint = dbContext.BaseEquip.Where(t => t.floorNo == task.floorNo).FirstOrDefault();
//修改task状态
task.currPointId = T01;
task.currPointNo = "T01";
task.nextPointId = nextPoint.objid;
task.nextPointNo = nextPoint.equipNo;
task.taskStatus = 1;
task.updateBy = "提升机线程";
task.updateTime = DateTime.Now;
task.remark = "一楼到位提升机线程";
dbContext.WcsTask.Update(task);
dbContext.SaveChanges();
}
}
continue;
}
//二楼到位
if (Convert.ToInt32(hoisterallowedtake02Value) == 1 && Convert.ToInt32(feedserialno02Value) > 0)
{
var task = dbContext.WcsTask.Where(t => t.serialNo == Convert.ToInt32(feedserialno01Value)).FirstOrDefault();
if (task != null)
{
if (task.nextPointId == T01)
{
//给提升机下发去向
this._plc.Write(this.currentfloor06.plcpointAddress, 2);
this._plc.Write(this.targetfloor06.plcpointAddress, task.floorNo);
var nextPoint = dbContext.BaseEquip.Where(t => t.floorNo == task.floorNo).FirstOrDefault();
//修改task状态
task.currPointId = T01;
task.currPointNo = "T01";
task.nextPointId = nextPoint.objid;
task.nextPointNo = nextPoint.equipNo;
task.taskStatus = 1;
task.updateBy = "提升机线程";
task.updateTime = DateTime.Now;
task.remark = "二楼到位提升机线程";
dbContext.WcsTask.Update(task);
dbContext.SaveChanges();
}
}
continue;
}
//三楼到位
if (Convert.ToInt32(hoisterallowedtake03Value) == 1 && Convert.ToInt32(feedserialno03Value) > 0)
{
var task = dbContext.WcsTask.Where(t => t.serialNo == Convert.ToInt32(feedserialno01Value)).FirstOrDefault();
if (task != null)
{
if (task.nextPointId == T01)
{
//给提升机下发去向
this._plc.Write(this.currentfloor06.plcpointAddress, 1);
this._plc.Write(this.targetfloor06.plcpointAddress, task.floorNo);
var nextPoint = dbContext.BaseEquip.Where(t => t.floorNo == task.floorNo).FirstOrDefault();
//修改task状态
task.currPointId = T01;
task.currPointNo = "T01";
task.nextPointId = nextPoint.objid;
task.nextPointNo = nextPoint.equipNo;
task.taskStatus = 1;
task.updateBy = "提升机线程";
task.updateTime = DateTime.Now;
task.remark = "三楼到位提升机线程";
dbContext.WcsTask.Update(task);
dbContext.SaveChanges();
}
}
continue;
}
//四楼到位
if (Convert.ToInt32(hoisterallowedtake04Value) == 1 && Convert.ToInt32(feedserialno04Value) > 0)
{
var task = dbContext.WcsTask.Where(t => t.serialNo == Convert.ToInt32(feedserialno01Value)).FirstOrDefault();
if (task != null)
{
if (task.nextPointId == T01)
{
//给提升机下发去向
this._plc.Write(this.currentfloor06.plcpointAddress, 1);
this._plc.Write(this.targetfloor06.plcpointAddress, task.floorNo);
var nextPoint = dbContext.BaseEquip.Where(t => t.floorNo == task.floorNo).FirstOrDefault();
//修改task状态
task.currPointId = T01;
task.currPointNo = "T01";
task.nextPointId = nextPoint.objid;
task.nextPointNo = nextPoint.equipNo;
task.taskStatus = 1;
task.updateBy = "提升机线程";
task.updateTime = DateTime.Now;
task.remark = "四楼到位提升机线程";
dbContext.WcsTask.Update(task);
dbContext.SaveChanges();
}
}
continue;
}
//五楼到位
if (Convert.ToInt32(hoisterallowedtake05Value) == 1 && Convert.ToInt32(feedserialno05Value) > 0)
{
var task = dbContext.WcsTask.Where(t => t.serialNo == Convert.ToInt32(feedserialno01Value)).FirstOrDefault();
if (task != null)
{
if (task.nextPointId == T01)
{
//给提升机下发去向
this._plc.Write(this.currentfloor06.plcpointAddress, 1);
this._plc.Write(this.targetfloor06.plcpointAddress, task.floorNo);
var nextPoint = dbContext.BaseEquip.Where(t => t.floorNo == task.floorNo).FirstOrDefault();
//修改task状态
task.currPointId = T01;
task.currPointNo = "T01";
task.nextPointId = nextPoint.objid;
task.nextPointNo = nextPoint.equipNo;
task.taskStatus = 1;
task.updateBy = "提升机线程";
task.updateTime = DateTime.Now;
task.remark = "五楼到位提升机线程";
dbContext.WcsTask.Update(task);
dbContext.SaveChanges();
}
}
continue;
}
}
}
@ -208,7 +462,7 @@ namespace Khd.Core.Wcs.Wcs
{
LogManager.Error(ex);
}
Thread.Sleep(2000);
Thread.Sleep(1000);
}

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Khd.Core.Wcs.Wcs
{
//入库点线程
public class InWarePoint
{
}
}

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Khd.Core.Wcs.Wcs
{
/// <summary>
/// 处理订单
/// </summary>
public class OrderProcess
{
}
}

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Khd.Core.Wcs.Wcs
{
/// <summary>
/// 出库线程
/// </summary>
public class OutWare
{
}
}

@ -113,11 +113,12 @@ namespace Khd.Core.Wcs.Wcs
var equip = StaticData.BaseEquip.ToList();
var startEquip = equip.Where(t => t.equipNo == equipNo).FirstOrDefault();
//var currEquip=
Jc.SnowId.JcSnowId id = new Jc.SnowId.JcSnowId(1, 1);
if (palletInfo != null)
{
WcsTask newTask = new()
{
objid = Guid.NewGuid(),
objid = id.NextId(),
taskType = Convert.ToInt32(dic.dicValue),
customerNo = customerNo,
taskStatus = 0,

@ -0,0 +1,82 @@
using Khd.Core.Domain.Dto.webapi;
using Masuit.Tools;
using Masuit.Tools.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Khd.Core.Wcs.Wcs
{
public class WcsToWms
{
/// <summary>
/// 手工出库调用
/// </summary>
/// <param name="requestManualOutWare"></param>
/// <returns></returns>
public bool ManualOutWare(RequestManualOutWare requestManualOutWare)
{
//推送出库数据
var url = "/api/Interface/ManualOutWare";
var concontentType = "application/json";
var result = HttpHelper.HttpPost(url, requestManualOutWare.ToJsonString(), concontentType, 60, null);
var model = (ReponseBase)JsonConvert.DeserializeObject(result.ToString(), typeof(ReponseBase));
if (model.CODE =="S")
{
LogManager.Info("调用成功。");
}
else
{
LogManager.Info("调用失败。");
}
return true;
}
/// <summary>
/// 盘盈调用
/// </summary>
/// <param name="requestCheck"></param>
/// <returns></returns>
public bool CheckProfit(RequestCheck requestCheck)
{
//推送出库数据
var url = "/api/Interface/CheckProfit";
var concontentType = "application/json";
var result = HttpHelper.HttpPost(url, requestCheck.ToJsonString(), concontentType, 60, null);
var model = (ReponseBase)JsonConvert.DeserializeObject(result.ToString(), typeof(ReponseBase));
if (model.CODE == "S")
{
LogManager.Info("调用成功。");
}
else
{
LogManager.Info("调用失败。");
}
return true;
}
/// <summary>
/// 盘亏调用
/// </summary>
/// <param name="requestCheck"></param>
/// <returns></returns>
public bool CheckLoss(RequestCheck requestCheck)
{
//推送出库数据
var url = "/api/Interface/CheckLoss";
var concontentType = "application/json";
var result = HttpHelper.HttpPost(url, requestCheck.ToJsonString(), concontentType, 60, null);
var model = (ReponseBase)JsonConvert.DeserializeObject(result.ToString(), typeof(ReponseBase));
if (model.CODE == "S")
{
LogManager.Info("调用成功。");
}
else
{
LogManager.Info("调用失败。");
}
return true;
}
}
}

@ -7,7 +7,7 @@
xmlns:local="clr-namespace:Khd.Core.Wpf.Form"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="950"
Title="车身长度管理页面" Height="600" Width="950" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Loaded="Window_Loaded">
Title="物料管理" Height="600" Width="950" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Loaded="Window_Loaded">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@ -276,148 +276,62 @@
</Window.Resources>
<Grid Background="#213269">
<StackPanel>
<StackPanel
Orientation="Horizontal"
Margin="0,10,0,0"
Height="50"
Width="850">
<Label Foreground="White" FontSize="25" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="量型 : " Margin="255,0,0,0" Background="Transparent" BorderThickness="0"/>
<TextBox x:Name="tbx_wuliaoname" HorizontalAlignment="Center" VerticalAlignment="Center" Width="150" Height="40"
FontSize="30" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Margin="5,0,20,0" Background="White" BorderThickness="0" Style="{StaticResource XingHaoBianMaYangShi}" />
<Button Width="80" Height="40" VerticalAlignment="Center" Foreground="White" FontSize="25" Background="Transparent" BorderThickness="0" Click="ChaXunButton_Click" Style="{StaticResource chaxunButton}" >
<TextBlock x:Name="ChaXunButton" Text="查询"/>
</Button>
</StackPanel>
<StackPanel
Height="400"
Height="460"
Width="850"
Margin="0,10,0,0"
Margin="0,30,0,0"
>
<DataGrid
BorderThickness="0"
GridLinesVisibility="All"
x:Name="dtg_LoadCarMessage"
Height="400"
Width="850"
AlternationCount="2"
AutoGenerateColumns="False"
Background="#172557"
CanUserAddRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
Focusable="False"
HeadersVisibility="Column"
IsReadOnly="False"
LoadingRow="dgData_LoadingRow"
RowHeaderWidth="0"
SelectionMode="Single"
FontSize="15"
Visibility="Visible"
CellEditEnding="dtg_LoadCarMessage_CellEditEnding"
KeyDown="DataGrid_KeyDown"
ItemsSource="{Binding tableCollection}">
<DataGrid.Columns>
<DataGridTemplateColumn
x:Name="grid1"
Width="90"
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="325"
Binding="{Binding Path=materialNo}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="车辆型号"
IsReadOnly="False" />
<DataGridTextColumn
Width="*"
Binding="{Binding Path=k46upLength}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="上件1K46"
IsReadOnly="False" />
<DataGridTextColumn
Width="*"
Binding="{Binding Path=k48upLength}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="上件2K48"
IsReadOnly="False" />
<DataGridTextColumn
Width="*"
Binding="{Binding Path=downLength}"
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="下件"
IsReadOnly="False" />
</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>
<Grid Height="100" Margin="0,30"
Width="840">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30*"/>
<ColumnDefinition Width="70*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Label Content="物料名称:" FontSize="35" HorizontalAlignment="Right" Background="Transparent" Foreground="White" BorderThickness="0"></Label>
</Grid>
<Grid Grid.Column="1">
<TextBox Margin="20,15" Name="marterName" Text="123456" FontSize="35"></TextBox>
</Grid>
</Grid>
<Grid Height="100" Margin="0,30"
Width="840">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30*"/>
<ColumnDefinition Width="70*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Label Content="物料编码:" FontSize="35" HorizontalAlignment="Right" Background="Transparent" Foreground="White" BorderThickness="0"></Label>
</Grid>
<Grid Grid.Column="1">
<TextBox Margin="20,15" Text="123456" Name="marterCode" FontSize="35"></TextBox>
</Grid>
</Grid>
<Grid Height="100" Margin="0,30"
Width="840">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30*"/>
<ColumnDefinition Width="70*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Label Content="物料类型:" FontSize="35" HorizontalAlignment="Right" Background="Transparent" Foreground="White" BorderThickness="0"></Label>
</Grid>
<Grid Grid.Column="1">
<TextBox Margin="20,15" Text="123456" FontSize="35"></TextBox>
<ComboBox Margin="20,15" FontSize="35" Name="marterType">
<ComboBoxItem Content="物料" />
<ComboBoxItem Content="成品" />
</ComboBox>
</Grid>
</Grid>
</StackPanel>
<StackPanel
Orientation="Horizontal"
Margin="0,20,0,0"
Height="55"
Width="850">
<Button FontSize="25" Name="jia" Margin="0,0,100,0" Height="50" Background="Transparent" Click="jia_Click" BorderBrush="Transparent" BorderThickness="0">
<Image Source="../Resources/jiahao.png"/>
</Button>
<Button Content="保 存" FontSize="25" Name="inster" Margin="30,0,150,0" Height="50" Width="100" Background="#3B56FD" Foreground="White" Click="inster_Click"></Button>
<Button Content="保 存" FontSize="25" Name="inster" Margin="200,0,150,0" Height="50" Width="100" Background="#3B56FD" Foreground="White" Click="inster_Click"></Button>
<Button Content="关 闭" FontSize="25" Name="close" Margin="130,0,300,0" Height="50" Width="100" Background="#3B56FD" Foreground="White" Click="cloce_Click" ></Button>
</StackPanel>
</StackPanel>

@ -1,4 +1,5 @@
using Khd.Core.Domain.Models;
using HandyControl.Tools.Extension;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
using Masuit.Tools.Logging;
using Microsoft.EntityFrameworkCore;
@ -45,49 +46,13 @@ namespace Khd.Core.Wpf.Form
{
try
{
GetCarMessage("");
}
catch (Exception ex)
{
LogManager.Info($"窗体加载事件报错 >>> {ex.Message}");
}
}
private void GetCarMessage(string sql)
{
try
{
string wheresql = string.IsNullOrEmpty(sql) ? "" : $"and material_no like '%{sql}'";
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var data = dbContext.ExecuteSqlQuery<BaseMaterialinfo>
($@"SELECT id,
material_no as materialNo,
k46up_length as k46upLength,
k48up_length as k48upLength,
down_length as downLength
FROM `base_materialinfo`
where is_delete = 0 {wheresql} order by material_no;");
if (data?.Count > 0)
{
List<BaseMaterialinfo> materialinfo_list = new();
foreach (var item in data)
{
BaseMaterialinfo materialinfo_model = new();
materialinfo_model.materialNo = item.materialNo;
materialinfo_model.k46upLength = item.k46upLength;
materialinfo_model.k48upLength = item.k48upLength;
materialinfo_model.downLength = item.downLength;
materialinfo_list.Add(materialinfo_model);
}
this.dtg_LoadCarMessage.ItemsSource = materialinfo_list;
this.dtg_LoadCarMessage.Items.Refresh();
}
}
catch (Exception ex)
{
LogManager.Info($"获取辆号信息加载到datagrid方法报错 >>> {ex.Message}");
}
}
/// <summary>
/// 显示序号事件
/// </summary>
@ -95,62 +60,7 @@ namespace Khd.Core.Wpf.Form
/// <param name="e"></param>
private void dgData_LoadingRow(object sender, DataGridRowEventArgs e)
{ e.Row.Header = e.Row.GetIndex() + 1; }
/// <summary>
/// datagrid编辑文本框触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dtg_LoadCarMessage_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
try
{
if (e != null)
{
if (e.EditAction == DataGridEditAction.Commit)
{
// 获取鼠标点击的单元格
DataGridCellInfo cellInfo = dtg_LoadCarMessage.CurrentCell;
int columnIndex = cellInfo.Column.DisplayIndex;
BaseMaterialinfo data = this.dtg_LoadCarMessage.SelectedItem as BaseMaterialinfo;
var editedTextbox = e.EditingElement as System.Windows.Controls.TextBox; // 假设编辑的是文本框
var newValue = editedTextbox.Text; // 获取编辑后的值
string zfc;
switch (columnIndex)
{
case 1:
zfc = "material_no";
break;
case 2:
zfc = "k46up_length";
break;
case 3:
zfc = "k48up_length";
break;
case 4:
zfc = "down_length";
break;
default:
zfc = "";
break;
}
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
if (!string.IsNullOrWhiteSpace(data.materialNo))
{
string setsql = zfc == "material_no" ? $",material_name ='{newValue}'" : "";
dbContext.ExecuteSqlQuery<BaseMaterialinfo>($@" UPDATE base_materialinfo set {zfc} = '{newValue}'{setsql} where material_no = '{data.materialNo}';");
this.dtg_LoadCarMessage.ItemsSource = null;
GetCarMessage("");
LogManager.Info($"当前事件 :{DateTime.Now},修改字段{zfc}为{newValue} >>> 日志记录!");
}
}
}
}
catch (Exception ex)
{
LogManager.Info("datagrid编辑文本框触发事件报错 >>> " + ex.Message.ToString());
}
}
private void DataGrid_KeyDown(object sender, KeyEventArgs e)
{
try
@ -182,36 +92,13 @@ namespace Khd.Core.Wpf.Form
{
try
{
var datagridMessage = dtg_LoadCarMessage.ItemsSource as List<BaseMaterialinfo>;
if (datagridMessage != null)
if (!marterCode.Text.IsNullOrEmpty()&&!marterName.Text.IsNullOrEmpty()&&marterType.SelectedIndex!=-1)
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var material_model = dbContext.BaseMaterialinfo.Where(t => t.isDelete == 0).ToList();
foreach (var item in datagridMessage)
{
var number = material_model.Find(C => C.materialNo == item.materialNo);
if (number == null && !string.IsNullOrWhiteSpace(item.materialNo))
{
BaseMaterialinfo model = new BaseMaterialinfo();
model.id = Guid.NewGuid();
model.materialNo = item.materialNo;
model.k46upLength = string.IsNullOrWhiteSpace(item.k46upLength) ? "" : item.k46upLength;
model.k48upLength = string.IsNullOrWhiteSpace(item.k48upLength) ? "" : item.k48upLength;
model.downLength = string.IsNullOrWhiteSpace(item.downLength) ? "" : item.downLength;
model.isDelete = 0;
model.materialName = item.materialNo;
model.createTime = DateTime.Now;
model.createBy = "AdmianInsert";
dbContext.Add(model);
var insertresult = dbContext.SaveChanges();
string showResult = insertresult == 1 ? "成功" : "失败";
MessageBox.Show($"物料{item.materialNo}添加操作{showResult}!", "操作成功提示!");
this.dtg_LoadCarMessage.ItemsSource = null;
GetCarMessage("");
}
}
}
else
{
MessageBox.Show("请输入完整数据!!!");
}
}
catch (Exception ex)
@ -219,44 +106,5 @@ namespace Khd.Core.Wpf.Form
MessageBox.Show($"数据添加报错 >>> {ex.Message}","操作失败提示!");
}
}
/// <summary>
/// 添加按钮点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void jia_Click(object sender, RoutedEventArgs e)
{
try
{
var listinfo = this.dtg_LoadCarMessage.ItemsSource as List<BaseMaterialinfo>;
BaseMaterialinfo model = new BaseMaterialinfo();
listinfo.Add(model);
dtg_LoadCarMessage.ItemsSource = listinfo;
dtg_LoadCarMessage.Items.Refresh();
var lastItem = listinfo[listinfo.Count - 1];
// 将数据源的最后一个元素滚动到可视区域
this.dtg_LoadCarMessage.ScrollIntoView(lastItem);
}
catch (Exception ex)
{
MessageBox.Show($"数据添加报错 >>> {ex.Message}");
}
}
/// <summary>
/// 查询按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ChaXunButton_Click(object sender, RoutedEventArgs e)
{
try
{
var liangxing = this.tbx_wuliaoname.Text.Trim().ToUpper().ToString();
GetCarMessage(liangxing);
}
catch (Exception)
{
}
}
}
}

@ -1,10 +1,10 @@
<Window
x:Class="XGL.FormItem.FormBoard"
x:Class="Khd.Core.Wpf.Form.FormBoard"
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:input="clr-namespace:System.Windows.Input;assembly=PresentationCore"
xmlns:local="clr-namespace:XGL.FormItem"
xmlns:local="Khd.Core.Wpf.Form.FormBoard"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="FormBoard"
@ -29,37 +29,6 @@
<ResourceDictionary Source="/CSS/DataGridClass.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid>
<Border
Name="Border"
Background="#213269"
BorderBrush="#172557"
BorderThickness="3,0,20,3">
<ContentPresenter
x:Name="ContentSite"
Margin="12,2,12,2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Header" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background" Value="#213269" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Border" Property="Background" Value="#213269" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="CustomButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
@ -284,6 +253,21 @@
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="FontSize" Value="14"></Setter>
</Style>
<!-- 订单清空备份按钮样式 -->
<Style x:Key="ClearOrderButton" TargetType ="{x:Type Button}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="1" CornerRadius="5">
<Border.Background>#FF7F00</Border.Background>
<ContentPresenter Content="{TemplateBinding ContentControl.Content}" HorizontalAlignment="Center" VerticalAlignment="Center" ></ContentPresenter>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="FontSize" Value="14"></Setter>
</Style>
</ResourceDictionary>
</Window.Resources>
<Viewbox Stretch="Fill">
@ -291,13 +275,20 @@
Width="1920"
Height="1080"
Background="#172557">
<!--<Grid Width="1920" Height="1200" >
<TabControl>
<TabItem Header="用户管理" FontSize="25" Foreground="#515A6E" Width="160" Height="50" >
</TabItem>
</TabControl>
</Grid>-->
<!-- 上件操作 -->
<StackPanel
x:Name="UpperStart"
Canvas.Left="174"
Canvas.Top="110"
Width="1746"
Width="1740"
Height="890"
HorizontalAlignment="Right"
Background="#213269" Visibility="Visible">
@ -485,7 +476,20 @@
VerticalAlignment="Center"
Foreground="White"
FontSize="25"
Margin="360,0,0,0"
Margin="150,0,0,0"
Visibility="Visible"
Style="{StaticResource ClearOrderButton}"
Click="btn_ClearOrder_Click">
<TextBlock x:Name="btn_clearOrder"
Text="订单清空"/>
</Button>
<Button
Width="150"
Height="55"
VerticalAlignment="Center"
Foreground="White"
FontSize="25"
Margin="60,0,0,0"
Visibility="Visible"
Style="{StaticResource qingkongButton}"
Click="btn_dingdandaoru_Click">
@ -537,7 +541,7 @@
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="VIN码"
Header="Vin条码"
IsReadOnly="True" />
<DataGridTextColumn
@ -564,7 +568,7 @@
CanUserSort="False"
ElementStyle="{StaticResource dgCell}"
FontSize="20"
Header="是否完成"
Header="订单状态"
IsReadOnly="True" />
<DataGridTextColumn
@ -703,7 +707,7 @@
</StackPanel>
<StackPanel
Width="1920"
Width="1915"
Height=" 90"
HorizontalAlignment="Left"
Background="#213269"
@ -720,7 +724,7 @@
Width="400"
Height="55"
Margin="0"
Content="金寨雅迪悬挂链"
Content="爱玛悬挂链"
FontSize="25"
Foreground="White"
HorizontalContentAlignment="Center"
@ -759,7 +763,7 @@
<Label
x:Name="LabTime"
Height="55"
Margin="10,0,0,0"
Margin="20,0,0,0"
FontSize="30"
Width="170"
Foreground="White" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/>
@ -884,17 +888,17 @@
FontSize="16px"
Foreground="White" />
</StackPanel>
<!-- plc信息面板 -->
<StackPanel x:Name="splPlcMessage" Height="890" Width="1745" Background="#213269" Canvas.Left="175" Canvas.Top="110" Visibility="Hidden" Orientation="Horizontal">
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical" Margin="20,5,0,0">
<StackPanel Orientation="Horizontal" Margin="0">
<Image
x:Name="img_plcmesssage"
Width="40"
Height="35"
Margin="65,0,0,0"
Margin="60,0,0,0"
Source="..\Resources\chanpintiaoma.png" Visibility="Visible"/>
<Label Content="PLC交互信息" Foreground="White" FontSize="20" Width="150" Height="40" Margin="10,0,80,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
</StackPanel>
@ -986,15 +990,9 @@
<TextBox Text="0" x:Name="tbxK02WriteMaterial" FontSize="15" Width="60" Height="50" Margin="10,0,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsReadOnly="True" Style="{StaticResource tbxStyle}"/>
<TextBox Text="0" x:Name="tbxK02WriteMaterialPlc" FontSize="15" Width="60" Height="50" Margin="40,0,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsReadOnly="True" Style="{StaticResource tbxStyle}"/>
</StackPanel>
</StackPanel>
</Border>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="20,10,0,0">
<StackPanel Orientation="Horizontal" >
@ -1002,7 +1000,7 @@
x:Name="img_plccaozuo"
Width="40"
Height="35"
Margin="65,0,0,0"
Margin="60,0,0,0"
Source="..\Resources\zaijudaoweizhuangtai.png" Visibility="Visible" />
<Label Content="上件闸口人工操作" Foreground="White" FontSize="20" Width="180" Height="40" Margin="10,0,80,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
</StackPanel>
@ -1047,6 +1045,94 @@
</Border>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="20,5,0,0" Width="540">
<StackPanel Orientation="Horizontal" >
<Image
Width="40"
Height="35"
Margin="60,0,0,0"
Source="..\Resources\kucun.png" Visibility="Visible" />
<Label Content="订单状态重置" Foreground="White" FontSize="20" Width="180" Height="40" Margin="10,0,0,0" HorizontalContentAlignment="Left" VerticalContentAlignment="Center"/>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Border Background="#213269" BorderBrush="Silver" BorderThickness="2" CornerRadius="10" Width="530" Margin="0,5,0,0">
<StackPanel Orientation="Vertical" >
<StackPanel Orientation="Horizontal" >
<Label Content="上线挂具号 :"
Foreground="White"
FontSize="20"
Width="150"
Height="60"
Margin="10,0,20,0"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"/>
<TextBox
x:Name="tbx_JieBangByCarNo"
FontSize="20"
Width="100"
Height="45"
Margin="5,0,0,0"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
IsReadOnly="False"
Style="{StaticResource tbxStyle}" />
<Button Width="80" Height="45" VerticalAlignment="Center" Foreground="White" FontSize="20" Style="{StaticResource chaxunButton}" Margin="30,0,0,0" Visibility="Visible" Click="Btn_ChaXunByCarNo_Click">
<TextBlock x:Name="Btn_ChaXunByCarNo" Text="查询"/>
</Button>
<Button Width="80" Height="45" VerticalAlignment="Center" Foreground="White" FontSize="20" Style="{StaticResource qingkongButton}" Margin="30,0,0,0" Visibility="Visible" Click="Btn_ChaXunByCarNoClear_Click">
<TextBlock x:Name="Btn_ChaXunByCarNoClear" Text="清空"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Label Content="对应Vin条码 :"
Foreground="White"
FontSize="20"
Width="150"
Height="60"
Margin="10,0,20,0"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"/>
<TextBox x:Name="tbx_JieBangByVin"
FontSize="20"
Width="220"
Height="45"
Margin="5,0,0,0"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
IsReadOnly="True"
Style="{StaticResource tbxStyle}" />
<Button Width="90" Height="45" VerticalAlignment="Center" Foreground="White" FontSize="20" Style="{StaticResource ClearOrderButton}" Margin="15,0,0,0" Visibility="Visible" Click="Btn_JieBangByCarNo_Click">
<TextBlock x:Name="Btn_JieBangByCarNo" Text="解绑重置"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Label Content="一键重置所有订单、挂具状态 >>>"
Foreground="White"
FontSize="20"
Width="350"
Height="60"
Margin="10,0,0,0"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"/>
<Button Width="130" Height="45" VerticalAlignment="Center" Foreground="White" FontSize="20" Style="{StaticResource jinggaoButton}" Margin="15,0,0,0" Visibility="Visible" Click="Btn_JieBangAll_Click">
<TextBlock x:Name="Btn_JieBangAll" Text="一键重置"/>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Label Content="--->注:携带物料挂具解绑重置后视为空车,从下件返回!"
Foreground="Orange"
FontSize="20"
Width="525"
Height="55"
Margin="0"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"/>
</StackPanel>
</StackPanel>
</Border>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</Canvas>

@ -3,7 +3,6 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
@ -13,22 +12,22 @@ using Masuit.Tools.Logging;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Khd.Core.EntityFramework;
using Khd.Core.Plc.S7;
using Khd.Core.Wpf;
using Thrift.Server;
using Thrift.Transport;
using ThriftService;
using Thrift.Protocol;
using Khd.Core.Domain.Models;
using Z.EntityFramework.Plus;
using Khd.Core.Wpf.Form;
using OfficeOpenXml;
using Microsoft.Win32;
using System.IO;
using AngleSharp.Dom;
using System.Windows;
using Masuit.Tools;
using Microsoft.EntityFrameworkCore;
using System.Text.RegularExpressions;
using Khd.Core.Plc.S7;
namespace XGL.FormItem
namespace Khd.Core.Wpf.Form
{
/// <summary>
/// FormBoard.xaml 的交互逻辑
@ -36,14 +35,10 @@ namespace XGL.FormItem
public partial class FormBoard : Window
{
private readonly IHost _host;
private Plc _plc;
/// <summary>
/// 时间刷新计时器
/// </summary>
private Khd.Core.Plc.S7.Plc _plc;
private DispatcherTimer ShowTimer;//刷新时间
private DispatcherTimer PLCMessage;//呈现PLC机柜信息
private DispatcherTimer ShowOrderMessage;//呈现PLC机柜信息
private object order_code;
private int UpState;//对应上件站点的状态,0为良好 1为损坏
//FormShowSelect formSelect;
@ -66,21 +61,19 @@ namespace XGL.FormItem
{
try
{
LogManager.Info($"--------------------------当前时间 :{DateTime.Now} >>> 客户端启动;");
//设置显示任务栏
if (WindowState == WindowState.Normal)
{
MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
WindowState = WindowState.Maximized;
}
//加载dategrid信息
LoadMaterial_GetMessage("");
//连接PLC判断
var plc = new Khd.Core.Plc.S7.Plc((CpuType)PlcConfig.CpuType, PlcConfig.IP, PlcConfig.Port,
PlcConfig.Rack, PlcConfig.Slot);
plc.Open();
// plc.Open();
if (!plc.IsConnected)
{
MessageBox.Show("PLC连接失败,重新连接");
@ -90,68 +83,68 @@ namespace XGL.FormItem
this._plc = plc;
}
ShowTimer = new System.Windows.Threading.DispatcherTimer();
ShowTimer.Tick += new EventHandler(ShowCurTimer);//起个Timer一直获取当前时间
ShowTimer.Interval = new TimeSpan(0, 0, 0, 1, 0);
ShowTimer.Start();
//ShowTimer = new System.Windows.Threading.DispatcherTimer();
//ShowTimer.Tick += new EventHandler(ShowCurTimer);//起个Timer一直获取当前时间
//ShowTimer.Interval = new TimeSpan(0, 0, 0, 1, 0);
//ShowTimer.Start();
#region 测试client调用wcs服务端
//#region 测试client调用wcs服务端
//TTransport transport = new TSocket("localhost", 9091);
//transport.Open();
//TProtocol protocol = new TBinaryProtocol(transport);
//WcsThrift.Client client = new WcsThrift.Client(protocol);
//client.hello("Sunzy");
////TTransport transport = new TSocket("localhost", 9091);
////transport.Open();
////TProtocol protocol = new TBinaryProtocol(transport);
////WcsThrift.Client client = new WcsThrift.Client(protocol);
////client.hello("Sunzy");
#endregion
//#endregion
//启动Thriftserver
Thread ThriftThread = new Thread(StartThriftServer);//接收服务端的推送信息
ThriftThread.IsBackground = true;
ThriftThread.Start();
////启动Thriftserver
//Thread ThriftThread = new Thread(StartThriftServer);//接收服务端的推送信息
//ThriftThread.IsBackground = true;
//ThriftThread.Start();
PLCMessage = new DispatcherTimer();
PLCMessage.Tick += new EventHandler(PLCmessage); //委托获取点位方法
PLCMessage.Interval = new TimeSpan(0, 0, 0, 0, 300);
PLCMessage.Start();
//PLCMessage = new DispatcherTimer();
//PLCMessage.Tick += new EventHandler(PLCmessage); //委托获取点位方法
//PLCMessage.Interval = new TimeSpan(0, 0, 0, 0, 300);
//PLCMessage.Start();
//string result = ThriftConfig.UpSite == "k46" ? " K46" : " K48";
//this.lab_Title.Content = (string)this.lab_Title.Content + result;
////string result = ThriftConfig.UpSite == "k46" ? " K46" : " K48";
////this.lab_Title.Content = (string)this.lab_Title.Content + result;
//载具到位状态
this.labzjydw.Visibility = System.Windows.Visibility.Hidden;
this.imgzjydw.Visibility = System.Windows.Visibility.Hidden;
this.labzjwdw.Visibility = System.Windows.Visibility.Visible;
this.imgzjwdw.Visibility = System.Windows.Visibility.Visible;
////载具到位状态
//this.labzjydw.Visibility = System.Windows.Visibility.Hidden;
//this.imgzjydw.Visibility = System.Windows.Visibility.Hidden;
//this.labzjwdw.Visibility = System.Windows.Visibility.Visible;
//this.imgzjwdw.Visibility = System.Windows.Visibility.Visible;
if (ThriftConfig.UpSite == "k48")
{
this.spl_sunhuaizhakoumianban.Visibility = System.Windows.Visibility.Visible;
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var getFlagState = dbContext.BaseAmima.Where(t => t.name == "UpState").FirstOrDefault();
if (getFlagState != null)
{
int zhuangtai = getFlagState.password == "2" ? 2 : 1;
string quxiang = getFlagState.direction == 1 ? "直通" : "弯通";
if (zhuangtai == 2)
{
this.lab_shangjiandianzhuangtai.Content = "上件点正常!K22按照任务线别方向流转.";
this.lab_shangjiandianzhuangtai.Foreground = new SolidColorBrush(Colors.Green);
this.spl_sunhuaizhakouquxiang.Visibility = System.Windows.Visibility.Hidden;
}
else
{
this.lab_shangjiandianzhuangtai.Content = $"上件点损坏!人工维护去向:{quxiang}";
this.lab_shangjiandianzhuangtai.Foreground = new SolidColorBrush(Colors.Red);
this.spl_sunhuaizhakouquxiang.Visibility = System.Windows.Visibility.Visible;
}
}
}
else
{
this.spl_sunhuaizhakoumianban.Visibility = System.Windows.Visibility.Hidden;
}
//if (ThriftConfig.UpSite == "k48")
//{
// this.spl_sunhuaizhakoumianban.Visibility = System.Windows.Visibility.Visible;
// using var scope = _host.Services.CreateScope();
// using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
// var getFlagState = dbContext.BaseAmima.Where(t => t.name == "UpState").FirstOrDefault();
// if (getFlagState != null)
// {
// int zhuangtai = getFlagState.password == "2" ? 2 : 1;
// string quxiang = getFlagState.direction == 1 ? "直通" : "弯通";
// if (zhuangtai == 2)
// {
// this.lab_shangjiandianzhuangtai.Content = "上件点正常!K22按照任务线别方向流转.";
// this.lab_shangjiandianzhuangtai.Foreground = new SolidColorBrush(Colors.Green);
// this.spl_sunhuaizhakouquxiang.Visibility = System.Windows.Visibility.Hidden;
// }
// else
// {
// this.lab_shangjiandianzhuangtai.Content = $"上件点损坏!人工维护去向:{quxiang}";
// this.lab_shangjiandianzhuangtai.Foreground = new SolidColorBrush(Colors.Red);
// this.spl_sunhuaizhakouquxiang.Visibility = System.Windows.Visibility.Visible;
// }
// }
//}
//else
//{
// this.spl_sunhuaizhakoumianban.Visibility = System.Windows.Visibility.Hidden;
//}
}
catch (Exception ex)
@ -164,14 +157,14 @@ namespace XGL.FormItem
{
try
{
int point = Convert.ToInt32(ThriftConfig.JiesShouDuanKou);
WcsServer wcsServer = new WcsServer();
//wcsServer.SendCarEvent += SendCar;
wcsServer.helloEvent += hello;
WcsThrift.Processor processor = new WcsThrift.Processor(wcsServer);
TServerTransport serverTransport = new TServerSocket(point);
TServer server = new TSimpleServer(processor, serverTransport);
server.Serve();
//int point = Convert.ToInt32(ThriftConfig.JiesShouDuanKou);
//WcsServer wcsServer = new WcsServer();
////wcsServer.SendCarEvent += SendCar;
//wcsServer.helloEvent += hello;
//WcsThrift.Processor processor = new WcsThrift.Processor(wcsServer);
//TServerTransport serverTransport = new TServerSocket(point);
//TServer server = new TSimpleServer(processor, serverTransport);
//server.Serve();
}
catch (Exception ex)
{
@ -179,7 +172,7 @@ namespace XGL.FormItem
delegate
{
//设置图片为未到位
this.CarNo.Clear();
this.CarNo.Text = "Null";
this.labzjydw.Visibility = System.Windows.Visibility.Hidden;
this.imgzjydw.Visibility = System.Windows.Visibility.Hidden;
this.labzjwdw.Visibility = System.Windows.Visibility.Visible;
@ -214,6 +207,7 @@ namespace XGL.FormItem
delegate
{
//设置图片为未到位
//this.CarNo.Clear();
this.labzjydw.Visibility = System.Windows.Visibility.Hidden;
this.imgzjydw.Visibility = System.Windows.Visibility.Hidden;
this.labzjwdw.Visibility = System.Windows.Visibility.Visible;
@ -233,8 +227,7 @@ namespace XGL.FormItem
/// </summary>
/// <param name="carlist"></param>
/// <param name="order_code">Vin条码号</param>
/// <param name="amount">三轮车辆长度</param>
public void SendCar(List<string> carlist, string order_code, string amount)
public void SendCar(List<string> carlist, string order_code)
{
TTransport transport = new TSocket(ThriftConfig.ThriftIpAddress, ThriftConfig.TuiSongDuankou);
try
@ -244,37 +237,37 @@ namespace XGL.FormItem
transport.Open();
TProtocol protocol = new TBinaryProtocol(transport);
WcsThrift.Client client = new WcsThrift.Client(protocol);
var ret = client.SendCar(carlist, order_code, amount);
if (ret == "1")//与服务端交互成功发车时
{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
//发车成功提示反馈
this.lba_ThrifTtitle.Foreground = new SolidColorBrush(Colors.Green);
this.lba_ThrifTtitle.Content = "发车成功!";
//设置为未到位
this.labzjwdw.Visibility = System.Windows.Visibility.Visible;
this.imgzjwdw.Visibility = System.Windows.Visibility.Visible;
this.labzjydw.Visibility = System.Windows.Visibility.Hidden;
this.imgzjydw.Visibility = System.Windows.Visibility.Hidden;
}));
}
else//与服务端交互失败时
{
//var ret = client.SendCar(carlist, order_code, order_code);
//if (ret == "1")//与服务端交互成功发车时
//{
// Application.Current.Dispatcher.Invoke(new Action(
// delegate
// {
// //发车成功提示反馈
// this.lba_ThrifTtitle.Foreground = new SolidColorBrush(Colors.Green);
// this.lba_ThrifTtitle.Content = "发车成功!";
// //设置为未到位
// this.labzjwdw.Visibility = System.Windows.Visibility.Visible;
// this.imgzjwdw.Visibility = System.Windows.Visibility.Visible;
// this.labzjydw.Visibility = System.Windows.Visibility.Hidden;
// this.imgzjydw.Visibility = System.Windows.Visibility.Hidden;
// }));
//}
//else//与服务端交互失败时
//{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
this.lba_ThrifTtitle.Foreground = new SolidColorBrush(Colors.Red);
this.lba_ThrifTtitle.Content = $"Thrift交互失败!";
//发车失败依然显示到位
this.labzjwdw.Visibility = System.Windows.Visibility.Hidden;
this.imgzjwdw.Visibility = System.Windows.Visibility.Hidden;
this.labzjydw.Visibility = System.Windows.Visibility.Visible;
this.imgzjydw.Visibility = System.Windows.Visibility.Visible;
}));
}
// Application.Current.Dispatcher.Invoke(new Action(
// delegate
// {
// this.lba_ThrifTtitle.Foreground = new SolidColorBrush(Colors.Red);
// this.lba_ThrifTtitle.Content = $"Thrift交互失败!";
// //发车失败依然显示到位
// this.labzjwdw.Visibility = System.Windows.Visibility.Hidden;
// this.imgzjwdw.Visibility = System.Windows.Visibility.Hidden;
// this.labzjydw.Visibility = System.Windows.Visibility.Visible;
// this.imgzjydw.Visibility = System.Windows.Visibility.Visible;
// }));
//}
}
catch (Exception ex)
{
@ -316,11 +309,15 @@ namespace XGL.FormItem
/// <param name="e"></param>
private void btnExit_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show("是否确认关闭程序", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.No)
{
//if (MessageBox.Show("是否确认关闭程序", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.No)
//{
}
else
//}
//else
//{
// System.Environment.Exit(System.Environment.ExitCode);
//}
if (MessageBox.Show("是否确认关闭程序", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
{
System.Environment.Exit(System.Environment.ExitCode);
}
@ -830,8 +827,6 @@ namespace XGL.FormItem
{
}
}
/// <summary>
/// 使用DataTable当做数据传递中介向DataGrid中传输数据源
/// </summary>
@ -850,10 +845,10 @@ namespace XGL.FormItem
IsOver AS isover
FROM base_production_order_split
{pjsql}
ORDER BY est ,IsOver";
ORDER BY IsOver , est ;";
var QueryOrder = dbContext.ExecuteSqlQuery<BaseProductionOrderSplit>(sql);
#region 注释代码折叠
//($@"SELECT
//string sql = ($@"SELECT
// a.line_code AS lineCode,
@ -871,7 +866,7 @@ namespace XGL.FormItem
// LEFT JOIN base_waitdownline b
// ON a.order_code = b.materiel_no {sql} ORDER BY est ,IsOver ");
// ON a.order_code = b.materiel_no {pjsql} ORDER BY est ,IsOver ");
//var QueryOrder = dbContext.BaseProductionOrderSplit.OrderBy(t => t.est).OrderBy(t => t.isover).ToList();
#endregion
if (QueryOrder?.Count > 0)
@ -892,11 +887,14 @@ namespace XGL.FormItem
dr["isover"] = i.isover.ToString();
switch (i.isover)
{
case 1:
dr["isover"] = "已完成";
break;
case 0:
dr["isover"] = "未完成";
dr["isover"] = "未上线";
break;
case 1:
dr["isover"] = "已上线";
break;
case 2:
dr["isover"] = "已完成";
break;
default:
dr["isover"] = "状态错误!";
@ -904,7 +902,7 @@ namespace XGL.FormItem
}
dt.Rows.Add(dr);
}
this.LoadMaterial.ItemsSource = dt.DefaultView;
this.LoadMaterial.ItemsSource = dt.DefaultView;
this.LoadMaterial.Items.Refresh();
}
}
@ -944,14 +942,14 @@ namespace XGL.FormItem
/// <param name="e"></param>
private void Btn_shangjiansunhuai_Click(object sender, RoutedEventArgs e)
{
this.spl_sunhuaizhakouquxiang.Visibility = System.Windows.Visibility.Visible;
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
dbContext.BaseAmima.Where(t => t.name == "UpState").Update(a => new BaseAmima() { password = "1" });
var data = dbContext.BaseAmima.Where(t => t.name == "UpState").FirstOrDefault();
string quxiang = data.direction == 1 ? "直通" : "弯通";
this.lab_shangjiandianzhuangtai.Content = $"上件点状态:损坏!K22固定去向:" + quxiang;
this.lab_shangjiandianzhuangtai.Foreground = new SolidColorBrush(Colors.Red);
//this.spl_sunhuaizhakouquxiang.Visibility = System.Windows.Visibility.Visible;
//using var scope = _host.Services.CreateScope();
//using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
//dbContext.BaseAmima.Where(t => t.name == "UpState").Update(a => new BaseAmima() { password = "1" });
//var data = dbContext.BaseAmima.Where(t => t.name == "UpState").FirstOrDefault();
//string quxiang = data.direction == 1 ? "直通" : "弯通";
//this.lab_shangjiandianzhuangtai.Content = $"上件点状态:损坏!K22固定去向:" + quxiang;
//this.lab_shangjiandianzhuangtai.Foreground = new SolidColorBrush(Colors.Red);
}
/// <summary>
/// 上件点状态良好确认按钮点击事件
@ -965,7 +963,7 @@ namespace XGL.FormItem
this.lab_shangjiandianzhuangtai.Content = $"上件点状态:正常!K22走任务线别去向!";
this.lab_shangjiandianzhuangtai.Foreground = new SolidColorBrush(Colors.Green);
this.spl_sunhuaizhakouquxiang.Visibility = System.Windows.Visibility.Hidden;
dbContext.BaseAmima.Where(t => t.name == "UpState").Update(a => new BaseAmima() { password = "2" });
// dbContext.BaseAmima.Where(t => t.name == "UpState").Update(a => new BaseAmima() { password = "2" });
}
/// <summary>
/// 上件点状态维护损坏后固定K22去向1
@ -974,11 +972,11 @@ namespace XGL.FormItem
/// <param name="e"></param>
private void Btn_K22QuXiang1_Click(object sender, RoutedEventArgs e)
{
this.spl_sunhuaizhakouquxiang.Visibility = System.Windows.Visibility.Visible;
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
dbContext.BaseAmima.Where(t => t.name == "UpState").Update(a => new BaseAmima() { direction = 1 });
Btn_shangjiansunhuai_Click(null, null);
//this.spl_sunhuaizhakouquxiang.Visibility = System.Windows.Visibility.Visible;
//using var scope = _host.Services.CreateScope();
//using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
//dbContext.BaseAmima.Where(t => t.name == "UpState").Update(a => new BaseAmima() { direction = 1 });
//Btn_shangjiansunhuai_Click(null, null);
}
/// <summary>
@ -991,7 +989,7 @@ namespace XGL.FormItem
this.spl_sunhuaizhakouquxiang.Visibility = System.Windows.Visibility.Visible;
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
dbContext.BaseAmima.Where(t => t.name == "UpState").Update(a => new BaseAmima() { direction = 2 });
//dbContext.BaseAmima.Where(t => t.name == "UpState").Update(a => new BaseAmima() { direction = 2 });
Btn_shangjiansunhuai_Click(null, null);
}
/// <summary>
@ -1019,27 +1017,26 @@ namespace XGL.FormItem
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
string VinResult = this.tBoxMessage.Text.Trim().ToUpper().ToString();
if (string.IsNullOrWhiteSpace(VinResult))
{
return;
}
var orderModel = dbContext.BaseProductionOrderSplit.Where(t => t.orderCode == VinResult).FirstOrDefault();
if (orderModel == null)
{
return;
}
var waitdownlineModel = dbContext.BaseWaitdownline.Where(t => t.definefield1 == orderModel.lineCode).ToList();
int FlagNum = waitdownlineModel.Count();
if (FlagNum >= FlagConfig.UpFlagNum)
{
//如果上件数量大于等于设置的闸口数量时
SolidColorBrush myBrush = new SolidColorBrush();
myBrush.Color = System.Windows.Media.Color.FromRgb(255, 130, 0); // 设置RGB值为(255, 0, 0)(红色)
this.lba_ThrifTtitle.Foreground = myBrush;
this.lba_ThrifTtitle.Content = $"上线数量:{FlagNum}>=缓存数量:{FlagConfig.UpFlagNum},限制发车!";
LogManager.Info($"当前时间:{DateTime.Now},物料:{orderModel.orderCode},线别:{orderModel.lineCode},数量:{FlagNum} >= 缓存数量:{FlagConfig.UpFlagNum},限制发车操作!");
return;
}
//var orderModel = dbContext.BaseProductionOrderSplit.Where(t => t.orderCode == VinResult).FirstOrDefault();
//if (orderModel == null)
//{
// MessageBox.Show($"该VIN条码:{VinResult}未搜索到对应订单!");
// return;
//}
//if (orderModel.isover != 0)
//{
// if (orderModel.isover == 1) MessageBox.Show($"该Vin条码:{VinResult}对应订单已上线!", "发车错误提示!");
// if (orderModel.isover == 2) MessageBox.Show($"该Vin条码:{VinResult}对应订单已下线完成!", "发车错误提示!");
// return;
//}
// var waitdownlineModel = dbContext.BaseWaitdownline.Where(t => t.definefield1 == orderModel.lineCode).ToList();
//int FlagNum = waitdownlineModel.Count();
//if (FlagNum >= FlagConfig.UpFlagNum)
//{
// MessageBox.Show($"已上线数量:{FlagNum}>=缓存闸口设置数量:{FlagConfig.UpFlagNum},限制发车操作!", "发车错误提示!");
// LogManager.Info($"当前时间:{DateTime.Now},物料:{orderModel.orderCode},线别:{orderModel.lineCode},数量:{FlagNum} >= 缓存数量:{FlagConfig.UpFlagNum},限制发车操作!");
// return;
//}
string sqlQuery = @$"
SELECT
b1.material_no AS materialNo,
@ -1070,26 +1067,37 @@ namespace XGL.FormItem
#endregion
if (QueryOrder?.Count == 0)
{
MessageBox.Show($"Vin:{VinResult}不存在对应车型长度", "发车操作提示!");
MessageBox.Show($"未查找到Vin:{VinResult}对应车型", "发车错误提示!");
return;
}
string changduText = ThriftConfig.UpSite == "k46" ? QueryOrder[0].k46upLength : QueryOrder[0].k48upLength;
changduText = changduText == "" ? "Null" : changduText;
string zhandianText = ThriftConfig.UpSite == "k46" ? "K46" : "K48";
this.tbx_CheLiangChangDu.Text = changduText;
string CarLengthResult = this.tbx_CheLiangChangDu.Text.Trim().ToString();
if (!string.IsNullOrWhiteSpace(CarLengthResult) && !string.IsNullOrWhiteSpace(VinResult))
if (string.IsNullOrWhiteSpace(changduText))
{
List<string> carList = new List<string>
{
$"上件站点 >>> {zhandianText}"
};
SendCar(carList, VinResult, CarLengthResult);
LogManager.Info($"当前时间;{DateTime.Now},发车方法调用记录 >>> 上件站点:{carList[0]} , Vin条码号:{VinResult},车身长度:{CarLengthResult}");
carList.Clear();
this.LoadMaterial.ItemsSource = null;
LoadMaterial_GetMessage("");
MessageBox.Show($"未查找到Vin:{VinResult}对应车型长度", "发车错误提示!");
return;
}
string carId = this.CarNo.Text;
if (string.IsNullOrWhiteSpace(carId))
{
MessageBox.Show($"挂具号为空!", "发车错误提示!");
return;
}
string zhandianText = ThriftConfig.UpSite == "k46" ? "K46" : "K48";
List<string> carList = new()
{
$"上件站点 >>> {zhandianText}"
};
SendCar(carList, VinResult);
LogManager.Info($"当前时间;{DateTime.Now},发车方法调用记录 >>> 挂具ID:{carId},上件站点:{carList[0]} , Vin条码号:{VinResult},车身长度:{changduText}");
carList.Clear();
//this.LoadMaterial.Items.Refresh();
this.LoadMaterial.ItemsSource = null;
LoadMaterial_GetMessage("");
}
else if (this.tBoxMessage.Text.Trim().Length < 17 && e.Key == Key.Enter)
{
MessageBox.Show($"输入Vin条码:{this.tBoxMessage.Text.Trim()}长度有误!");
return;
}
}
catch (Exception ex)
@ -1107,107 +1115,111 @@ namespace XGL.FormItem
try
{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
// 设置 EPPlus 许可上下文
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Excel Files|*.xls;*.xlsx";
if (openFileDialog.ShowDialog() == true)
{
FileInfo fileInfo = new FileInfo(openFileDialog.FileName);
delegate
{
// 设置 EPPlus 许可上下文
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Excel Files|*.xls;*.xlsx";
if (openFileDialog.ShowDialog() == true)
{
FileInfo fileInfo = new FileInfo(openFileDialog.FileName);
using (ExcelPackage package = new ExcelPackage(fileInfo))
{
ExcelWorksheet worksheet = package.Workbook.Worksheets.FirstOrDefault();
using (ExcelPackage package = new ExcelPackage(fileInfo))
{
ExcelWorksheet worksheet = package.Workbook.Worksheets.FirstOrDefault();
if (worksheet != null)
{
// 获取 Excel 表头
var columnHeaders = worksheet.Cells[1, 1, 1, worksheet.Dimension.End.Column]
.Select(cell => cell.Text)
.ToList();
BaseProductionOrderSplit orderMoedel = new();
// 映射数据库字段,这里需要根据你的实际需求进行调整
var columnMappings = new Dictionary<string, string>
{
// 添加映射
{columnHeaders[0],"production_sequence"},
{columnHeaders[1],"line_code"},
{columnHeaders[3],"prod_code"},
{columnHeaders[4],"Quantity"},
{columnHeaders[5],"order_code"}
};
int ordernum = 0;
// 遍历 Excel 数据行
for (int row = 2; row <= worksheet.Dimension.End.Row; row++)
{
// 创建 SQL 插入语句
//string insertCommand = $"INSERT INTO YourTableName ({string.Join(", ", columnMappings.Values)}) VALUES (";
List<string> values = new();
if (worksheet != null)
{
// 获取 Excel 表头
var columnHeaders = worksheet.Cells[1, 1, 1, worksheet.Dimension.End.Column]
.Select(cell => cell.Text)
.ToList();
BaseProductionOrderSplit orderMoedel = new();
// 映射数据库字段,这里需要根据你的实际需求进行调整
var columnMappings = new Dictionary<string, string>
{
// 添加映射
{columnHeaders[0],"production_sequence"},
{columnHeaders[1],"line_code"},
{columnHeaders[3],"prod_code"},
{columnHeaders[4],"Quantity"},
{columnHeaders[5],"order_code"}
};
int ordernum = 0;
// 获取实际的行数和列数
int rowCount = worksheet.Dimension.Rows;
int colCount = worksheet.Dimension.Columns;
// 遍历 Excel 数据行
for (int row = 2; row <= rowCount; row++)
{
// 创建 SQL 插入语句
//string insertCommand = $"INSERT INTO YourTableName ({string.Join(", ", columnMappings.Values)}) VALUES (";
List<string> values = new();
// 遍历 Excel 数据列
for (int col = 1; col <= colCount; col++)
{
string columnName = columnHeaders[col - 1];
string databaseColumnName;
// 映射 Excel 列名到数据库列名
if (columnMappings.TryGetValue(columnName, out databaseColumnName))
{
// 获取 Excel 单元格的值
var cellValue = worksheet.Cells[row, col].Text;
// 添加值到插入语句
values.Add(cellValue);
//values.Add($"'{cellValue.Replace("'", "''")}'");
//if (!string.IsNullOrWhiteSpace(cellValue))
//{
// values.Add(cellValue);
//}
}
}
// 使用 LINQ 查询空值
bool containsNull = values.Any(item => item == "" || item == null);
if (containsNull)
{
//MessageBox.Show("Excel表格中存在空值,不执行导入操作!", "订单导入操作提示!");
//LogManager.Info($"订单导入按钮事件错误 >>> Excel表格中存在空值!不执行导入操作!");
break;
}
// 获得插入语句
//string fullInsertCommand = $"{insertCommand} {string.Join(", ", values)} )";
var xianbiename = Char.GetNumericValue(values[1][values[1].Length - 1]).ToString();
int orderSequence = int.Parse(values[0].Trim());
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
// var orderModel = dbContext.BaseProductionOrderSplit.OrderBy(t => t.productionSequence).ToList();
//var data = orderModel.Find(t => t.orderCode == values[4].Trim().ToUpper());
//if (data == null)
//{
// BaseProductionOrderSplit InserOrderModel = new()
// {
// id = Guid.NewGuid().ToString(),
// lineCode = values[1].Trim(),
// lineName = xianbiename == "1" ? "二线" : "一线",
// orderCode = values[4].Trim().ToUpper(),
// prodCode = values[2].Trim(),
// prodDesc = values[2].Trim(),
// productionSequence = orderSequence,
// est = DateTime.Now,
// isover = 0,
// quantity = 1,
// createBy = "ExcelInsert"
// };
// dbContext.Add(InserOrderModel);
// dbContext.SaveChanges();
// ordernum++;
//}
}
// 遍历 Excel 数据列
for (int col = 1; col <= worksheet.Dimension.End.Column; col++)
{
string columnName = columnHeaders[col - 1];
string databaseColumnName;
// 映射 Excel 列名到数据库列名
if (columnMappings.TryGetValue(columnName, out databaseColumnName))
{
// 获取 Excel 单元格的值
var cellValue = worksheet.Cells[row, col].Text;
// 添加值到插入语句
values.Add(cellValue);
//values.Add($"'{cellValue.Replace("'", "''")}'");
//if (!string.IsNullOrWhiteSpace(cellValue))
//{
// values.Add(cellValue);
//}
}
}
// 使用 LINQ 查询空值
bool containsNull = values.Any(item => item == "" || item == null);
if (containsNull)
{
MessageBox.Show("Excel表格中存在空值,不执行导入操作!", "订单导入操作提示!");
LogManager.Info($"按钮订单导入事件粗无日志 >>> Excel表格中存在空值!不执行导入操作!");
continue;
}
// 获得插入语句
//string fullInsertCommand = $"{insertCommand} {string.Join(", ", values)} )";
var xianbiename = Char.GetNumericValue(values[1][values[1].Length - 1]).ToString();
int orderSequence = int.Parse(values[0].Trim());
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
var orderModel = dbContext.BaseProductionOrderSplit.OrderBy(t => t.productionSequence).ToList();
var data = orderModel.Find(t => t.orderCode == values[4].Trim().ToUpper());
if (data == null)
{
BaseProductionOrderSplit InserOrderModel = new()
{
id = Guid.NewGuid().ToString(),
lineCode = values[1].Trim(),
lineName = xianbiename == "1" ? "二线" : "一线",
orderCode = values[4].Trim().ToUpper(),
prodCode = values[2].Trim(),
prodDesc = values[2].Trim(),
productionSequence = orderSequence,
est = DateTime.Now,
isover = 0,
quantity = 1
};
dbContext.Add(InserOrderModel);
dbContext.SaveChanges();
ordernum++;
}
}
MessageBox.Show($"{ordernum}条订单导入系统!", "订单导入操作提示!");
this.LoadMaterial.ItemsSource = null;
LoadMaterial_GetMessage("");
}
}
}
}));
MessageBox.Show($"{ordernum}条订单导入系统!", "订单导入操作提示!");
this.LoadMaterial.ItemsSource = null;
LoadMaterial_GetMessage("");
}
}
}
}));
}
catch (Exception ex)
{
@ -1231,5 +1243,155 @@ namespace XGL.FormItem
this.lba_ThrifTtitle.Content = string.Empty;
}
}
/// <summary>
/// 订单清空按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_ClearOrder_Click(object sender, RoutedEventArgs e)
{
try
{
var data = this.LoadMaterial.ItemsSource;
if (data == null)
{
MessageBox.Show($"当前订单信息为空,无需清空操作!", "订单手动清空提示!");
return;
}
if (MessageBox.Show("确认是否清空当前预存订单?",
"订单手动清空提示",
MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
string sqlQuery = @"INSERT INTO
base_production_order_split_bak
(id,site_code, line_code, line_name, order_code,prod_code,prod_desc,IsOver,est,Quantity,production_sequence)
SELECT
id,site_code, line_code, line_name, order_code,prod_code,prod_desc,IsOver,est,Quantity,production_sequence
FROM base_production_order_split;";
string sqlDelete = @"Delete
FROM
base_production_order_split;";
var ret = dbContext.Database.ExecuteSqlRaw(sqlQuery);
dbContext.Database.ExecuteSqlRaw(sqlDelete);
string zhandianText = ThriftConfig.UpSite == "k46" ? "K46" : "K48";
string saveLog = ret == 0 ? "清空后备份任务SQL执行失败!" : "清空后备份任务SQL语句执行成功!";
if (ret != 0) MessageBox.Show($"{ret}条订单清空完毕!", "订单清空提示!");
LogManager.Info($"手动清空任务日志记录 >>> 站点:{zhandianText}{saveLog}");
this.LoadMaterial.ItemsSource = null;
LoadMaterial_GetMessage("");
}
}
catch (Exception ex)
{
LogManager.Info($"手动清空任务方法报错 >>> {ex.Message}");
}
}
/// <summary>
/// 查询挂具绑定Vin物料点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_ChaXunByCarNo_Click(object sender, RoutedEventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(this.tbx_JieBangByCarNo.Text))
{
MessageBox.Show("上线挂具号输入框为空!", "查询挂具物料绑定关系操作提示!");
return;
}
if (!Regex.IsMatch(this.tbx_JieBangByCarNo.Text, @"^\d+$"))
{
MessageBox.Show("挂具号输入格式有误!", "查询挂具物料绑定关系操作提示!");
this.tbx_JieBangByVin.Clear();
return;
//textBox.Text = textBox.Text.Replace("非数字字符", ""); // 移除非数字字符
}
if (this.tbx_JieBangByCarNo.Text.Length >= 3)
{
MessageBox.Show("挂具号输入长度有误!", "查询挂具物料绑定关系操作提示!");
this.tbx_JieBangByVin.Clear();
return;
}
int ShuRuCarNo = int.Parse(this.tbx_JieBangByCarNo.Text);
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
//var listWaitDownLine = dbContext.BaseWaitdownline.Where(t => t.isDelete == 0 && t.carNo == ShuRuCarNo).ToList();
//if (string.IsNullOrWhiteSpace(listWaitDownLine[0].materielNo))
//{
// MessageBox.Show($"{ShuRuCarNo}号为空挂具,不存在与Vin绑定信息!", "查询挂具物料绑定关系操作提示!");
// return;
//}
// var listOrder = dbContext.BaseProductionOrderSplit.Where(t => t.orderCode == listWaitDownLine[0].materielNo).ToList();
//var resultOrderList = (from waitdownline in listWaitDownLine
// join order in listOrder on waitdownline.materielNo equals order.orderCode
// select new BaseProductionOrderSplit
// {
// id = order.id,
// lineCode = order.lineCode,
// orderCode = order.orderCode
// }).ToList();
//if (resultOrderList?.Count > 0)
//{
// this.tbx_JieBangByVin.Text = resultOrderList[0].orderCode;
//}
}
catch (Exception ex)
{
MessageBox.Show($"查询挂具物料绑定关系报错 >>> {ex.Message}");
LogManager.Info($"查询挂具物料绑定关系报错 >>> {ex.Message}");
}
}
/// <summary>
/// 解绑按钮点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_JieBangByCarNo_Click(object sender, RoutedEventArgs e)
{
try
{
}
catch (Exception ex)
{
LogManager.Info($"解绑载具物料绑定关系操作报错 >>> {ex.Message}");
}
}
/// <summary>
/// 清空输入框点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_ChaXunByCarNoClear_Click(object sender, RoutedEventArgs e)
{
try
{
this.tbx_JieBangByCarNo.Clear();
this.tbx_JieBangByVin.Clear();
}
catch (Exception)
{
}
}
/// <summary>
/// 一键重置点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_JieBangAll_Click(object sender, RoutedEventArgs e)
{
try
{
}
catch (Exception EX)
{
LogManager.Info($"一键重置订单、挂具状态方法报错 >>> {EX.Message}");
}
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,684 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Masuit.Tools.Logging;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Khd.Core.EntityFramework;
using Khd.Core.Plc.S7;
using Thrift.Server;
using Thrift.Transport;
using ThriftService;
using Thrift.Protocol;
using Khd.Core.Domain.Models;
using Z.EntityFramework.Plus;
using OfficeOpenXml;
using Microsoft.Win32;
using System.IO;
using System.Windows;
using Microsoft.EntityFrameworkCore;
using System.Text.RegularExpressions;
using System.Net.Http;
using System.Net.Http.Json;
using Khd.Core.Domain.Dto.webapi;
using Newtonsoft.Json;
using HandyControl.Tools.Extension;
namespace Khd.Core.Wpf.Form
{
/// <summary>
/// FormBoardT.xaml 的交互逻辑
/// </summary>
public partial class FormBoardT : Window
{
private readonly IHost _host;
private Khd.Core.Plc.S7.Plc _plc;
private DispatcherTimer ShowTimer;//刷新时间
private DispatcherTimer PLCMessage;//呈现PLC机柜信息
private DispatcherTimer UPMessageTimer;//刷新上件记录
private DispatcherTimer ShowOrderMessage;//呈现PLC机柜信息
private object order_code;
private int UpState;//对应上件站点的状态,0为良好 1为损坏
List<BasePlcpoint> basePlcpoints = new List<BasePlcpoint>();
object timerjilu;
public class selectOrderData
{
public string Id { get; set; }
public string orderCode { get; set; }
}
private string selectedId;
//FormShowSelect formSelect;
// public static int WeekNo = CommonHelper.WeekOfYear(DateTime.Now, new System.Globalization.CultureInfo("zh-CN"));
public FormBoardT(IHost host)
{
InitializeComponent();
this._host = host;
}
/// <summary>
/// 页面加载事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FormBoard_Loaded(object sender, RoutedEventArgs e)
{
try
{
LogManager.Info($"--------------------------当前时间 :{DateTime.Now} >>> 客户端启动;");
//设置显示任务栏
if (WindowState == WindowState.Normal)
{
MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
WindowState = WindowState.Maximized;
}
//加载dategrid信息
//LoadMaterial_GetMessage("");
//连接PLC判断
var plc = new Khd.Core.Plc.S7.Plc((CpuType)PlcConfig.CpuType, PlcConfig.IP, PlcConfig.Port,
PlcConfig.Rack, PlcConfig.Slot);
//plc.Open();
//if (!plc.IsConnected)
//{
// MessageBox.Show("PLC连接失败,重新连接");
//}
//else
//{
// this._plc = plc;
//}
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
basePlcpoints = dbContext.BasePlcpoint.Where(t => t.isDelete == 0).ToList();
//var baseMaterials = dbContext.BaseMaterial.Where(t => t.IsDelete == 0).ToList();
//
PLCMessage = new DispatcherTimer();
PLCMessage.Tick += new EventHandler(PLCmessage); //委托获取点位方法
PLCMessage.Interval = new TimeSpan(0, 0, 0, 0, 1000);
PLCMessage.Start();
UPMessageTimer = new DispatcherTimer();
UPMessageTimer.Tick += new EventHandler(UpMessage); //委托刷新上件记录
UPMessageTimer.Interval = new TimeSpan(0, 0, 0, 0, 2000);
UPMessageTimer.Start();
Button_Click_1(null, null);
SetTime();
List<string> list = new List<string>
{
"101上件点",
"102上件点",
"103上件点"
};
MoHuChaXunWuLiaoName.ItemsSource = list;
MoHuChaXunWuLiaoName.SelectedIndex = 0;
List<string> list2 = new List<string>
{
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10"
};
comnumber.ItemsSource = list2;
comnumber.SelectedIndex = 5;
// shangjianwuliaocombox.ItemsSource= dbContext.BaseProductionOrderSplit.Where( t => t.isCompleted == "0" && t.quantity != t.onlineQuantity).GroupBy(c=>c.prodDesc).Select(r=>r.Key).ToList();
//StartThriftServer();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
/// <summary>
/// 刷新日期
/// </summary>
private void SetTime()
{
new Thread(() =>
{
while (true)
{
try
{
Dispatcher.Invoke(new Action(delegate
{
LabDate.Content = DateTime.Now.ToString("yyyy年MM月dd日");
LabTime.Content = DateTime.Now.ToString("HH:mm:ss");
}));
}
catch (Exception ex)
{
}
finally
{
Thread.Sleep(1000);
}
}
}).Start();
}
public void UpMessage(object sender, EventArgs e)
{
MoHuChaXunWuLiaoName_SelectionChanged(timerjilu, null);
}
/// <summary>
/// WCS通讯方法
/// </summary>
public void StartThriftServer()
{
try
{
int point = Convert.ToInt32(ThriftConfig.JiesShouDuanKou);
WcsServer wcsServer = new WcsServer();
//wcsServer.SendCarEvent += SendCar;
// wcsServer.helloEvent += hello;
WcsThrift.Processor processor = new WcsThrift.Processor(wcsServer);
TServerTransport serverTransport = new TServerSocket(point);
TServer server = new TSimpleServer(processor, serverTransport);
server.Serve();
}
catch (Exception ex)
{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
//设置图片为未到位
this.CarNo.Text = "Null";
this.labzjydw.Visibility = System.Windows.Visibility.Hidden;
this.imgzjydw.Visibility = System.Windows.Visibility.Hidden;
this.labzjwdw.Visibility = System.Windows.Visibility.Visible;
this.imgzjwdw.Visibility = System.Windows.Visibility.Visible;
}));
LogManager.Error(ex);
}
}
public string hello(string name)
{
//Console.WriteLine($"hello {name}");
//return $"ServerResponse receive from client name:{name}";
try
{
if (!string.IsNullOrWhiteSpace(name))
{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
//设置图片为已到位、显示挂具号
this.CarNo.Text = name;
this.labzjydw.Visibility = System.Windows.Visibility.Visible;
this.imgzjydw.Visibility = System.Windows.Visibility.Visible;
this.labzjwdw.Visibility = System.Windows.Visibility.Hidden;
this.imgzjwdw.Visibility = System.Windows.Visibility.Hidden;
}));
}
else
{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
//设置图片为未到位
//this.CarNo.Clear();
this.labzjydw.Visibility = System.Windows.Visibility.Hidden;
this.imgzjydw.Visibility = System.Windows.Visibility.Hidden;
this.labzjwdw.Visibility = System.Windows.Visibility.Visible;
this.imgzjwdw.Visibility = System.Windows.Visibility.Visible;
}));
}
}
catch (Exception ex)
{
LogManager.Info($"客户端接收服务端推送的小车信息方法报错 >>> {ex.Message}");
}
return "";
}
/// <summary>
/// 发车方法
///
/// </summary>
/// <param name="carlist"></param>
/// <param name="prodCode">物料号</param>
/// <param name="amount">三轮车辆长度</param>
public void SendCar(List<string> carlist, string prodCode, string bunber,string ordercodeid)
{
TTransport transport = new TSocket(ThriftConfig.ThriftIpAddress, ThriftConfig.TuiSongDuankou);
try
{
//Console.WriteLine($"hello carlist[0]:{carlist.FirstOrDefault()}|order_code:{order_code}|amount:{amount}");
//return $"ServerResponse receive from client order_code:{order_code}";
transport.Open();
TProtocol protocol = new TBinaryProtocol(transport);
WcsThrift.Client client = new WcsThrift.Client(protocol);
// var ret = client.SendCar(carlist, prodCode, bunber, ordercodeid);
if ("1" == "1")//与服务端交互成功发车时
{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
//发车成功提示反馈
this.lba_ThrifTtitle.Foreground = new SolidColorBrush(Colors.Green);
this.lba_ThrifTtitle.Text = "发车成功!";
//设置为未到位
this.labzjwdw.Visibility = System.Windows.Visibility.Visible;
this.imgzjwdw.Visibility = System.Windows.Visibility.Visible;
this.labzjydw.Visibility = System.Windows.Visibility.Hidden;
this.imgzjydw.Visibility = System.Windows.Visibility.Hidden;
}));
}
else//与服务端交互失败时
{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
this.lba_ThrifTtitle.Foreground = new SolidColorBrush(Colors.Red);
this.lba_ThrifTtitle.Text = $"Thrift交互失败!";
//发车失败依然显示到位
this.labzjwdw.Visibility = System.Windows.Visibility.Hidden;
this.imgzjwdw.Visibility = System.Windows.Visibility.Hidden;
this.labzjydw.Visibility = System.Windows.Visibility.Visible;
this.imgzjydw.Visibility = System.Windows.Visibility.Visible;
}));
}
}
catch (Exception ex)
{
LogManager.Info($"发车方法报错 >>> {ex.Message}");
}
finally
{
transport.Close();
transport.Dispose();
}
}
/// <summary>
/// 显示序号事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgData_LoadingRow(object sender, DataGridRowEventArgs e)
{ e.Row.Header = e.Row.GetIndex() + 1; }
/// <summary>
/// 点击退出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnExit_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show("是否确认关闭程序", "提示信息", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
{
System.Environment.Exit(System.Environment.ExitCode);
}
}
private void Close(object sender, EventArgs e)
{
System.Environment.Exit(System.Environment.ExitCode);
}
public int i = 0;
/// <summary>
/// 电气机柜信息面板定时器调用方法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PLCmessage(object sender, EventArgs e)
{
try
{
if (i == 1000)
{
i = 0;
}
foreach (var item in basePlcpoints)
{
//通过名称找到TextBox
TextBox FoundTextBox = (TextBox)FindName(item.plcpointNo);
if (FoundTextBox == null)
{
continue;
}
string value = i.ToString();
//string value = _plc.Read(item.plcpointAddress).ToString();
//if (value.IsNullOrEmpty())
//{
// continue;
//}
//if (FoundTextBox.IsFocused == true)
//{
// continue;
//}
FoundTextBox.Text = value;
i++;
LogManager.Info(i.ToString());
}
}
catch (Exception ex)
{
LogManager.Info($"电气机柜信息面板定时器调用方法报错 >>> {ex.Message}");
}
}
/// <summary>
/// PLC读取方法封装
/// </summary>
/// <param name="plcAddress">plc地址位</param>
/// <param name="plcDataType">plc数据类型(int类型默认为1)</param>
/// <param name="plcValueLength">plc地址位长度(string类型默认为2)</param>
/// <param name="textBoxXcid">载具号文本输入框</param>
/// <param name="textBoxGjdw">载具到位文本输入框</param>
/// <param name="textBoxClzt">PLC车辆状态文本输入框</param>
/// <param name="textBoxXcqx">载具去向文本输入框</param>
/// <param name="textBoxWcsclzt">WCS处理状态文本输入框</param>
private void ReadPlcData(string plcAddress, int plcDataType, string plcValueLength,
TextBox textBoxXcid, TextBox textBoxGjdw, TextBox textBoxClzt,
TextBox textBoxXcqx, TextBox textBoxWcsclzt)
{
try
{
// 载具号
ReadAndSetText(plcAddress, textBoxXcid);
// 载具到位
//DQXX.plcpointAddress = $"DB4.DBW{GetOffset(plcAddress, 0)}";
string gjdw = $"DB4.DBW{GetOffset(plcAddress, 0)}";
ReadAndSetText(gjdw, textBoxGjdw);
// PLC处理状态
//DQXX.plcpointAddress = $"DB4.DBW{GetOffset(plcAddress, 2)}";
string plcclzt = $"DB4.DBW{GetOffset(plcAddress, 2)}";
ReadAndSetText(plcclzt, textBoxClzt);
// 小车去向
//DQXX.plcpointAddress = $"DB5.DBW{GetOffset(plcAddress, 0)}";
string xcqx = $"DB5.DBW{GetOffset(plcAddress, 0)}";
ReadAndSetText(xcqx, textBoxXcqx, textBoxXcqx.IsFocused);
// WCS处理完成
//DQXX.plcpointAddress = $"DB5.DBW{GetOffset(plcAddress, 2)}";
string wcsclzt = $"DB5.DBW{GetOffset(plcAddress, 2)}";
ReadAndSetText(wcsclzt, textBoxWcsclzt, textBoxWcsclzt.IsFocused);
//-------------------------------------------------------------------------以下为方法内部嵌套方法
//嵌套方法1
void ReadAndSetText(string dw, TextBox textBox, bool checkFocus = false)
{
string value = _plc.Read(dw).ToString();
if (value != null && (!checkFocus || !textBox.IsFocused))
{
textBox.Text = value;
}
}
//嵌套方法2
int GetOffset(string PlcAddress, int baseOffset)
{
int result = int.Parse(PlcAddress.Substring(4, 1)) * 4 + baseOffset;
return result;
}
}
catch (Exception ex)
{
LogManager.Info($"PLC读取方法封装报错 >>> {ex.Message}");
}
}
/// <summary>
/// 订单导入按钮点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_dingdandaoru_Click(object sender, RoutedEventArgs e)
{
try
{
Application.Current.Dispatcher.Invoke(new Action(
delegate
{
// 设置 EPPlus 许可上下文
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Excel Files|*.xls;*.xlsx";
if (openFileDialog.ShowDialog() == true)
{
FileInfo fileInfo = new FileInfo(openFileDialog.FileName);
using (ExcelPackage package = new ExcelPackage(fileInfo))
{
ExcelWorksheet worksheet = package.Workbook.Worksheets.FirstOrDefault();
if (worksheet != null)
{
// 获取 Excel 表头
var columnHeaders = worksheet.Cells[1, 1, 1, worksheet.Dimension.End.Column]
.Select(cell => cell.Text)
.ToList();
BaseProductionOrderSplit orderMoedel = new();
// 映射数据库字段,这里需要根据你的实际需求进行调整
var columnMappings = new Dictionary<string, string>
{
// 添加映射
{columnHeaders[0],"production_sequence"},
{columnHeaders[1],"line_code"},
{columnHeaders[3],"prod_code"},
{columnHeaders[4],"Quantity"},
{columnHeaders[5],"order_code"}
};
int ordernum = 0;
// 获取实际的行数和列数
int rowCount = worksheet.Dimension.Rows;
int colCount = worksheet.Dimension.Columns;
// 遍历 Excel 数据行
for (int row = 2; row <= rowCount; row++)
{
// 创建 SQL 插入语句
//string insertCommand = $"INSERT INTO YourTableName ({string.Join(", ", columnMappings.Values)}) VALUES (";
List<string> values = new();
// 遍历 Excel 数据列
for (int col = 1; col <= colCount; col++)
{
string columnName = columnHeaders[col - 1];
string databaseColumnName;
// 映射 Excel 列名到数据库列名
if (columnMappings.TryGetValue(columnName, out databaseColumnName))
{
// 获取 Excel 单元格的值
var cellValue = worksheet.Cells[row, col].Text;
// 添加值到插入语句
values.Add(cellValue);
//values.Add($"'{cellValue.Replace("'", "''")}'");
//if (!string.IsNullOrWhiteSpace(cellValue))
//{
// values.Add(cellValue);
//}
}
}
// 使用 LINQ 查询空值
bool containsNull = values.Any(item => item == "" || item == null);
if (containsNull)
{
//MessageBox.Show("Excel表格中存在空值,不执行导入操作!", "订单导入操作提示!");
//LogManager.Info($"订单导入按钮事件错误 >>> Excel表格中存在空值!不执行导入操作!");
break;
}
// 获得插入语句
//string fullInsertCommand = $"{insertCommand} {string.Join(", ", values)} )";
var xianbiename = Char.GetNumericValue(values[1][values[1].Length - 1]).ToString();
int orderSequence = int.Parse(values[0].Trim());
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
// var orderModel = dbContext.BaseProductionOrderSplit.OrderBy(t => t.productionSequence).ToList();
///var data = orderModel.Find(t => t.orderCode == values[4].Trim().ToUpper());
//
}
MessageBox.Show($"{ordernum}条订单导入系统!", "订单导入操作提示!");
//LoadMaterial_GetMessage("");
}
}
}
}));
}
catch (Exception ex)
{
MessageBox.Show($"订单导入失败 >>> {ex.Message}", "订单导入操作提示!");
LogManager.Info($"按钮订单导入事件报错 >>> {ex.Message}");
}
}
/// <summary>
/// 接收到载具号后,清空残留信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CarNo_TextChanged(object sender, TextChangedEventArgs e)
{
//if (!string.IsNullOrWhiteSpace(this.tBoxMessage.Text) && this.tBoxMessage.Text.Length == 17)
//{
// //清空缓存信息
// this.CarNo.Clear();
// this.tBoxMessage.Clear();
// this.lba_ThrifTtitle.Text = string.Empty;
//}
}
/// <summary>
/// 订单清空按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_ClearOrder_Click(object sender, RoutedEventArgs e)
{
try
{
var data = this.LoadMaterial.ItemsSource;
if (data == null)
{
MessageBox.Show($"当前订单信息为空,无需清空操作!", "订单手动清空提示!");
return;
}
if (MessageBox.Show("确认是否清空当前预存订单?",
"订单手动清空提示",
MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
string sqlQuery = @"INSERT INTO
base_production_order_split_bak
(id,site_code, line_code, line_name, order_code,prod_code,prod_desc,IsOver,est,Quantity,production_sequence)
SELECT
id,site_code, line_code, line_name, order_code,prod_code,prod_desc,IsOver,est,Quantity,production_sequence
FROM base_production_order_split;";
string sqlDelete = @"Delete
FROM
base_production_order_split;";
var ret = dbContext.Database.ExecuteSqlRaw(sqlQuery);
dbContext.Database.ExecuteSqlRaw(sqlDelete);
string zhandianText = ThriftConfig.UpSite == "k46" ? "K46" : "K48";
string saveLog = ret == 0 ? "清空后备份任务SQL执行失败!" : "清空后备份任务SQL语句执行成功!";
if (ret != 0) MessageBox.Show($"{ret}条订单清空完毕!", "订单清空提示!");
LogManager.Info($"手动清空任务日志记录 >>> 站点:{zhandianText}{saveLog}");
this.LoadMaterial.ItemsSource = null;
//LoadMaterial_GetMessage("");
}
}
catch (Exception ex)
{
LogManager.Info($"手动清空任务方法报错 >>> {ex.Message}");
}
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
try
{
//
}
catch (Exception ex)
{
MessageBox.Show("查询订单遇到错误~>>>>>>>>>>>>>>>>>>>>" + ex);
LogManager.Info("查询订单遇到错误~>>>>>>>>>>>>>>>>>>>>" + ex);
}
}
/// <summary>
/// 选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MoHuChaXunWuLiaoName_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
timerjilu = sender;
ComboBox comboBox = (ComboBox)sender;
var shangjiandian = comboBox.SelectedItem;
string numberPart = Regex.Match(shangjiandian.ToString(), @"\d+").Value;
try
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
//
}
catch (Exception ex)
{
MessageBox.Show("查询订单遇到错误~>>>>>>>>>>>>>>>>>>>>" + ex);
LogManager.Info("查询订单遇到错误~>>>>>>>>>>>>>>>>>>>>" + ex);
}
}
/// <summary>
/// 删除物料
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Click_2(object sender, RoutedEventArgs e)
{
if (LoadMaterial0.SelectedIndex == -1)
{
MessageBox.Show("请选择要删除的物料!");
}
else
{
var quere = MessageBox.Show("确定删除吗", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Asterisk);
//
}
}
/// <summary>
/// 刷新产线
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Click_3(object sender, RoutedEventArgs e)
{
//
}
/// <summary>
/// 物料选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void shangjianwuliaocombox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//
}
private void orderselect_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
private void Button_Click(object sender, RoutedEventArgs e)
{
//
}
}
}

@ -0,0 +1,43 @@
using System.ComponentModel;
namespace Khd.Core.Wpf.Form
{
public class TabItemInfo : INotifyPropertyChanged
{
private string imagePath;
private string text;
public string ImagePath
{
get { return imagePath; }
set
{
if (imagePath != value)
{
imagePath = value;
OnPropertyChanged(nameof(ImagePath));
}
}
}
public string Text
{
get { return text; }
set
{
if (text != value)
{
text = value;
OnPropertyChanged(nameof(Text));
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

@ -0,0 +1,24 @@
<UserControl x:Class="Khd.Core.Wpf.Form.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Khd.Core.Wpf.Form"
mc:Ignorable="d"
d:DesignHeight="330" d:DesignWidth="200">
<Grid DataContext="{Binding RelativeSource={RelativeSource Self}}">
<!-- Your UserControl content here -->
<Border Background="#213269">
<StackPanel Orientation="Horizontal">
<!-- Image in TabItem -->
<Image Source="{Binding ImagePath}" Width="40" Height="40" Margin="5"/>
<TextBlock Text="{Binding Text, RelativeSource={RelativeSource AncestorType={x:Type local:UserControl1}}}" Width="140" Height="30" FontSize="25" HorizontalAlignment="Center" VerticalAlignment="Center" />
</StackPanel>
</Border>
<!-- Main content for UserControl1 -->
<!-- You can add more UI elements here -->
</Grid>
</UserControl>

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Navigation;
using System.Windows.Shapes;
namespace Khd.Core.Wpf.Form
{
/// <summary>
/// UserControl1.xaml 的交互逻辑
/// </summary>
public partial class UserControl1 : UserControl
{
public static readonly DependencyProperty TabItemInfoProperty = DependencyProperty.Register(
"TabItemInfo",
typeof(TabItemInfo),
typeof(UserControl1),
new PropertyMetadata(null, OnTabItemInfoChanged));
public TabItemInfo TabItemInfo
{
get { return (TabItemInfo)GetValue(TabItemInfoProperty); }
set { SetValue(TabItemInfoProperty, value); }
}
public UserControl1()
{
InitializeComponent();
}
private static void OnTabItemInfoChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is UserControl1 userControl)
{
// 在这里处理数据变更例如更新UI
// userControl.TabItemInfo 包含了最新的数据
Debug.WriteLine($"ImagePath: {userControl.TabItemInfo?.ImagePath}, Text: {userControl.TabItemInfo?.Text}");
}
}
}
}

@ -9,12 +9,11 @@
<ItemGroup>
<Compile Remove="AssemblyInfo.cs" />
<Compile Remove="Form\CheShenChangDuGuanLi.xaml.cs" />
<Compile Remove="Form\FormBoard.xaml.cs" />
<Compile Remove="LoginPage.xaml.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\amma.png" />
<None Remove="Resources\amma3.png" />
<None Remove="Resources\Background.png" />
<None Remove="Resources\bg.png" />
<None Remove="Resources\Boardbg.png" />
@ -123,12 +122,12 @@
</ItemGroup>
<ItemGroup>
<Page Remove="Form\CheShenChangDuGuanLi.xaml" />
<Page Remove="Form\FormBoard.xaml" />
<Page Remove="LoginPage.xaml" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\amma.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\amma3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="Resources\jiahao.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
@ -149,6 +148,11 @@
<ProjectReference Include="..\Khd.Core.Plc\Khd.Core.Plc.csproj" />
<ProjectReference Include="..\Khd.Core.Thrift\Khd.Core.Thrift.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="HBInformationBase">
<HintPath>C:\Users\ZJ\.nuget\packages\hbinformationbase\22.2.15.1313\lib\net5.0\HBInformationBase.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Background.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@ -468,7 +472,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Form\" />
</ItemGroup>
</Project>

@ -14,7 +14,6 @@ using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Masuit.Tools.Logging;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
using XGL.FormItem;
using System.Collections;
using Masuit.Tools.Logging;
using Microsoft.Extensions.Logging;
@ -24,6 +23,8 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Khd.Core.EntityFramework;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
using Khd.Core.Wpf.Form;
namespace Khd.Core.Wpf
{
@ -37,11 +38,26 @@ namespace Khd.Core.Wpf
{
InitializeComponent();
this.Hide();
//string[] args;
IHost host = CreateHostBuilder(null).Build();
_host = host;
FormBoard mainWindow = new FormBoard(_host);
mainWindow.Show();
//IHost host = CreateHostBuilder(null).Build();
//_host = host;
//FormBoard mainWindow = new FormBoard(_host);
//mainWindow.Show();
// 通过进程名称查找进程
bool ret;
string upsite = ThriftConfig.UpSite == "k48" ? "K48" : "K46";
System.Threading.Mutex mutex = new System.Threading.Mutex(true, $"Khd.Core.Wpf", out ret);
if (ret)
{
IHost host = CreateHostBuilder(null).Build();
_host = host;
FormBoardT mainWindow = new FormBoardT(_host);
mainWindow.Show();
}
else
{
MessageBox.Show("系统重复开启,请先关闭之前窗口!");
mutex.ReleaseMutex(); // 释放 Mutex
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

@ -8,25 +8,15 @@ namespace ThriftService
{
public class WcsServer : WcsThrift.Iface
{
public delegate string deletehello(string name);
public deletehello helloEvent;
public string hello(string name)
public string hello(string name)
{
if (helloEvent != null)
{
return helloEvent(name);
}
return "";
Console.WriteLine($"hello {name}");
return $"ServerResponse receive from client name:{name}";
}
public delegate string deleteSendCar(List<string> carlist, string order_code, string amount);
public deleteSendCar SendCarEvent;
public string SendCar(List<string> carlist, string order_code, string amount)
{
if (SendCarEvent != null)
{
return SendCarEvent(carlist, order_code, amount);
}
return "";
Console.WriteLine($"hello carlist[0]:{carlist.FirstOrDefault()}|order_code:{order_code}|amount:{amount}");
return $"ServerResponse receive from client order_code:{order_code}";
}
}

@ -1,14 +1,14 @@
{
"ConnectionStrings": {
//mysql
"DefaultConnection": "server=localhost;port=3306;database=khd_suspension_chain;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True"
"DefaultConnection": "server=localhost;port=3306;database=khd_jyhb;uid=root;pwd=root;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True"
//khd
//"DefaultConnection": "server=106.12.13.113;port=3336;database=khd_suspension_chain;uid=khd;pwd=khd@123;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True"
// "DefaultConnection": "server=106.12.13.113;port=3336;database=khd_suspension_chain;uid=khd;pwd=khd@123;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True"
//
//"DefaultConnection": "server=localhost;port=3306;database=khd_suspension_chain;uid=root;pwd=123456;charset='utf8';persistsecurityinfo=True;SslMode=none;Allow User Variables=True"
},
"PlcConfig": {
"IP": "192.168.0.1",
"IP": "127.0.0.1",
"Port": "102",
"CpuType": 30,
"Rack": "0",

Loading…
Cancel
Save