diff --git a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig
index decf85c2..5f662432 100644
--- a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig
+++ b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig
@@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Admin.Core.Common
-build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.Common\
+build_property.ProjectDir = C:\Users\admin\Desktop\new\Admin.Core.Common\
diff --git a/Admin.Core.EventBus/obj/Debug/net6.0/Admin.Core.EventBus.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.EventBus/obj/Debug/net6.0/Admin.Core.EventBus.GeneratedMSBuildEditorConfig.editorconfig
index f38a35e7..afdb5a5a 100644
--- a/Admin.Core.EventBus/obj/Debug/net6.0/Admin.Core.EventBus.GeneratedMSBuildEditorConfig.editorconfig
+++ b/Admin.Core.EventBus/obj/Debug/net6.0/Admin.Core.EventBus.GeneratedMSBuildEditorConfig.editorconfig
@@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Admin.Core.EventBus
-build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.EventBus\
+build_property.ProjectDir = C:\Users\admin\Desktop\new\Admin.Core.EventBus\
diff --git a/Admin.Core.Extensions/Middlewares/PlcMildd.cs b/Admin.Core.Extensions/Middlewares/PlcMildd.cs
index 871c16ba..7fbbee6b 100644
--- a/Admin.Core.Extensions/Middlewares/PlcMildd.cs
+++ b/Admin.Core.Extensions/Middlewares/PlcMildd.cs
@@ -3,6 +3,7 @@ using Aucma.Core.RunPlc;
using log4net;
using Microsoft.AspNetCore.Builder;
using System;
+using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Extensions
@@ -20,12 +21,26 @@ namespace Admin.Core.Extensions
{
if (Appsettings.app("Middleware", "Plc", "Enabled").ObjToBool())
{
+ //计算程序运行时间
+ System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
+ StringBuilder sb = new StringBuilder();
+ stopwatch.Start(); // 开始监视代码
+ ///////////////////////////////////////操作代码/////////////////////////////////////////////////////
+
await plc.StartMelsecMcSeverAsync();
await plc.StartSiemensSever();
await plc.StartMelsecPlcAsync();
await plc.StartSiemensPlcAsync();
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ stopwatch.Stop(); // 停止监视
+ TimeSpan timeSpan = stopwatch.Elapsed; // 获取总时间
+ double hours = timeSpan.TotalHours; // 小时
+ double minutes = timeSpan.TotalMinutes; // 分钟
+ double seconds = timeSpan.TotalSeconds; // 秒数
+ double milliseconds = timeSpan.TotalMilliseconds; // 毫秒数
- Console.WriteLine("PLC 任务启动成功");
+ Console.WriteLine($"秒数:{seconds},毫秒数:{milliseconds}");
+
}
}
catch (Exception e)
diff --git a/Admin.Core.IRepository/IRepository_New/IReportQualityInspectionRepository.cs b/Admin.Core.IRepository/IRepository_New/IReportQualityInspectionRepository.cs
new file mode 100644
index 00000000..89d71570
--- /dev/null
+++ b/Admin.Core.IRepository/IRepository_New/IReportQualityInspectionRepository.cs
@@ -0,0 +1,20 @@
+using Admin.Core.Model;
+using Admin.Core.Model.Model_New;
+using Admin.Core.Model.ViewModels;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Admin.Core.IRepository
+{
+ ///
+ /// 质检记录
+ ///
+ public interface IReportQualityInspectionRepository : IBaseRepository
+ {
+
+
+
+
+
+ }
+}
\ No newline at end of file
diff --git a/Admin.Core.IRepository/obj/Debug/net6.0/Admin.Core.IRepository.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.IRepository/obj/Debug/net6.0/Admin.Core.IRepository.GeneratedMSBuildEditorConfig.editorconfig
index 2b7e2280..651652f9 100644
--- a/Admin.Core.IRepository/obj/Debug/net6.0/Admin.Core.IRepository.GeneratedMSBuildEditorConfig.editorconfig
+++ b/Admin.Core.IRepository/obj/Debug/net6.0/Admin.Core.IRepository.GeneratedMSBuildEditorConfig.editorconfig
@@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Admin.Core.IRepository
-build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.IRepository\
+build_property.ProjectDir = C:\Users\admin\Desktop\new\Admin.Core.IRepository\
diff --git a/Admin.Core.IService/IService_New/IReportQualityInspectionServices.cs b/Admin.Core.IService/IService_New/IReportQualityInspectionServices.cs
new file mode 100644
index 00000000..6fb3f53d
--- /dev/null
+++ b/Admin.Core.IService/IService_New/IReportQualityInspectionServices.cs
@@ -0,0 +1,21 @@
+using Admin.Core.Model;
+using Admin.Core.Model.ViewModels;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Admin.Core.IService
+{
+ ///
+ /// 质检记录
+ ///
+ public interface IReportQualityInspectionServices : IBaseServices
+ {
+ ///
+ /// 判断是否有不合格质检项
+ ///
+ ///
+ List JudgeIsQualified(string barCode);
+
+ }
+}
\ No newline at end of file
diff --git a/Admin.Core.IService/obj/Debug/net6.0/Admin.Core.IService.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.IService/obj/Debug/net6.0/Admin.Core.IService.GeneratedMSBuildEditorConfig.editorconfig
index ba998751..e6c73541 100644
--- a/Admin.Core.IService/obj/Debug/net6.0/Admin.Core.IService.GeneratedMSBuildEditorConfig.editorconfig
+++ b/Admin.Core.IService/obj/Debug/net6.0/Admin.Core.IService.GeneratedMSBuildEditorConfig.editorconfig
@@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Admin.Core.IService
-build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.IService\
+build_property.ProjectDir = C:\Users\admin\Desktop\new\Admin.Core.IService\
diff --git a/Admin.Core.Model/Model_New/BaseSpaceInfo.cs b/Admin.Core.Model/Model_New/BaseSpaceInfo.cs
index 908966e6..f300eb36 100644
--- a/Admin.Core.Model/Model_New/BaseSpaceInfo.cs
+++ b/Admin.Core.Model/Model_New/BaseSpaceInfo.cs
@@ -87,7 +87,9 @@ namespace Admin.Core.Model
///
[SugarColumn(ColumnName = "MATERIAL_TYPE")]
public string MaterialType { get; set; }
-
+ ///
+ /// 夹具箱型
+ ///
[SugarColumn(ColumnName ="BOXTYPE")]
public string BoxType { get; set; }
@@ -146,5 +148,20 @@ namespace Admin.Core.Model
[SugarColumn(ColumnName = "TYPE_NAME_C")]
public string typeNameC { get; set; }
+ ///
+ ///分垛使用字段,箱体入库旋转角度(90,180,270)
+ ///
+ [SugarColumn(ColumnName = "ROTATION_RANGE")]
+ public int RotationRange { get; set; }
+ ///
+ /// 分垛使用字段,是否大产品占两个货道,1-是;0-否
+ ///
+ [SugarColumn(ColumnName = "IS_TWO_SPACE")]
+ public int IsTwoSpace { get; set; }
+ ///
+ /// 分垛使用字段,记录同型号上次入的货道,如FD01_002 == >记录上次货道ObjId
+ ///
+ [SugarColumn(ColumnName = "LAST_SPACE")]
+ public string LastSpace { get; set; }
}
}
diff --git a/Admin.Core.Model/Model_New/ReportQualityInsPection.cs b/Admin.Core.Model/Model_New/ReportQualityInsPection.cs
new file mode 100644
index 00000000..80b2185a
--- /dev/null
+++ b/Admin.Core.Model/Model_New/ReportQualityInsPection.cs
@@ -0,0 +1,117 @@
+using NPOI.SS.Formula.Functions;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Admin.Core.Model
+{
+ ///
+ /// 质检记录
+ ///
+ [SugarTable("REPORT_QUALITY_INSPECTION", "AUCMA_MES")]
+ public class ReportQualityInsPection
+ {
+ ///
+ /// 主键
+ ///
+ [SugarColumn(ColumnName = "OBJ_ID", IsIdentity = true, IsPrimaryKey = true, OracleSequenceName = "SEQ_REPORT_QUALITY_INSPECTION")]
+ public int ObjId { get; set; }
+
+ ///
+ /// 箱体条码
+ ///
+ [SugarColumn(ColumnName = "BAR_CODE")]
+ public string BarCode { get; set; }
+
+ ///
+ /// 物料名称
+ ///
+ [SugarColumn(ColumnName = "MATERIAL_NAME")]
+ public string MaterialName { get; set; }
+ ///
+ /// 工序编号
+ ///
+ [SugarColumn(ColumnName = "PROCESS_CODE")]
+ public string ProcessCode { get; set; }
+ ///
+ /// 检测项(工位)编号
+ ///
+ [SugarColumn(ColumnName = "TEST_ITEM_CODE")]
+ public string TestItemCode { get; set; }
+ ///
+ /// 质量缺陷编码
+ ///
+ [SugarColumn(ColumnName = "QUALITY_DEFECT_CODE")]
+ public string QualityDefectCode { get; set; }
+ ///
+ /// 质量缺陷名称
+ ///
+ [SugarColumn(ColumnName = "QUALITY_DEFECT_NAME")]
+ public string QualityDefectName { get; set; }
+ ///
+ /// 质检处理措施(3=合格,1=返修)
+ ///
+ [SugarColumn(ColumnName = "TREATMENT_MEASURE")]
+ public string TreatmentMeasure { get; set; }
+ ///
+ /// 返修处理结果
+ ///
+ [SugarColumn(ColumnName = "PROCESS_RESULT")]
+ public string ProcessResult { get; set; }
+ ///
+ /// 是否下静态线(1-是;2-否)
+ ///
+ [SugarColumn(ColumnName = "IS_LOWER_LINE")]
+ public string IsLowerLine { get; set; }
+ ///
+ /// 班组编号
+ ///
+ [SugarColumn(ColumnName = "GROUP_CODE")]
+ public string GroupCode { get; set; }
+ ///
+ /// 检测人员
+ ///
+ [SugarColumn(ColumnName = "INSPECTOR_CODE")]
+ public string InspectorCode { get; set; }
+ ///
+ /// 检测时间
+ ///
+ [SugarColumn(ColumnName = "INSPECTOR_TIME")]
+ public DateTime InspectorTime { get; set; }
+ ///
+ /// 返修次数
+ ///
+ [SugarColumn(ColumnName = "REWORK_NUMBER")]
+ public int ReworkNumber { get; set; }
+ ///
+ /// 返修完成时间
+ ///
+ [SugarColumn(ColumnName = "FINISH_TIME")]
+ public DateTime FinishTime { get; set; }
+ ///
+ /// 返修结果(1=正常,2=异常)
+ ///
+ [SugarColumn(ColumnName = "IS_FLAG")]
+ public int IsFlag { get; set; }
+ ///
+ /// 更新人
+ ///
+ [SugarColumn(ColumnName = "UPDATED_BY")]
+ public string UpdatedBy { get; set; }
+ ///
+ /// 更新时间
+ ///
+ [SugarColumn(ColumnName = "UPDATED_TIME")]
+ public DateTime UpdatedTime { get; set; }
+ ///
+ /// 检测人工位编号
+ ///
+ [SugarColumn(ColumnName = "STATION_CODE")]
+ public string StationCode { get; set; }
+
+
+ }
+}
diff --git a/Admin.Core.Model/obj/Debug/net6.0/Admin.Core.Model.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.Model/obj/Debug/net6.0/Admin.Core.Model.GeneratedMSBuildEditorConfig.editorconfig
index f17e3fdc..aa2440ff 100644
--- a/Admin.Core.Model/obj/Debug/net6.0/Admin.Core.Model.GeneratedMSBuildEditorConfig.editorconfig
+++ b/Admin.Core.Model/obj/Debug/net6.0/Admin.Core.Model.GeneratedMSBuildEditorConfig.editorconfig
@@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Admin.Core.Model
-build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.Model\
+build_property.ProjectDir = C:\Users\admin\Desktop\new\Admin.Core.Model\
diff --git a/Admin.Core.Repository/Repository_New/ReportQualityInspectionRepository.cs b/Admin.Core.Repository/Repository_New/ReportQualityInspectionRepository.cs
new file mode 100644
index 00000000..bcb3059e
--- /dev/null
+++ b/Admin.Core.Repository/Repository_New/ReportQualityInspectionRepository.cs
@@ -0,0 +1,23 @@
+using Admin.Core.IRepository;
+using Admin.Core.Model;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Admin.Core.Repository
+{
+ ///
+ /// 质检记录
+ ///
+ public class ReportQualityInspectionRepository : BaseRepository, IReportQualityInspectionRepository
+ {
+ public ReportQualityInspectionRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
+ {
+ }
+
+ }
+}
diff --git a/Admin.Core.Serilog.Es/obj/Debug/net6.0/Admin.Core.Serilog.Es.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.Serilog.Es/obj/Debug/net6.0/Admin.Core.Serilog.Es.GeneratedMSBuildEditorConfig.editorconfig
index a581a844..6ebeb23d 100644
--- a/Admin.Core.Serilog.Es/obj/Debug/net6.0/Admin.Core.Serilog.Es.GeneratedMSBuildEditorConfig.editorconfig
+++ b/Admin.Core.Serilog.Es/obj/Debug/net6.0/Admin.Core.Serilog.Es.GeneratedMSBuildEditorConfig.editorconfig
@@ -8,4 +8,4 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Admin.Core.Serilog.Es
-build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.Serilog.Es\
+build_property.ProjectDir = C:\Users\admin\Desktop\new\Admin.Core.Serilog.Es\
diff --git a/Admin.Core.Service/Service_New/RecordInstoreServices.cs b/Admin.Core.Service/Service_New/RecordInstoreServices.cs
index e9bef75d..8e0b7f5f 100644
--- a/Admin.Core.Service/Service_New/RecordInstoreServices.cs
+++ b/Admin.Core.Service/Service_New/RecordInstoreServices.cs
@@ -49,7 +49,7 @@ namespace Admin.Core.Service
{
List preCordList =await _recordInstoreRepository.QueryAsync(d =>d.StoreCode.Equals(storeCode) && d.InStoreTime >= startTime && d.InStoreTime <= endTime);//
- if(preCordList == null && preCordList.Count == 0) return null;
+ if(preCordList == null || preCordList.Count == 0) return null;
return preCordList;
//List list = new List();
//int count = 0;
diff --git a/Admin.Core.Service/Service_New/ReportQualityInspectionServices.cs b/Admin.Core.Service/Service_New/ReportQualityInspectionServices.cs
new file mode 100644
index 00000000..33cd6326
--- /dev/null
+++ b/Admin.Core.Service/Service_New/ReportQualityInspectionServices.cs
@@ -0,0 +1,49 @@
+using Admin.Core.IRepository;
+using Admin.Core.IService;
+using Admin.Core.Model;
+using Admin.Core.Model.Model_New;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Admin.Core.Service
+{
+ ///
+ /// 质检记录
+ ///
+ public class ReportQualityInspectionServices : BaseServices, IReportQualityInspectionServices
+ {
+ private readonly IBaseRepository _dal;
+ private readonly IReportQualityInspectionRepository _baseSpaceInfoRepository;
+ private readonly ICodeBindingRecordRepository _codeBindingRecordRepository;
+ public ReportQualityInspectionServices(IBaseRepository dal, IReportQualityInspectionRepository reportQualityInspectionRepository, ICodeBindingRecordRepository codeBindingRepository)
+ {
+ _baseSpaceInfoRepository = reportQualityInspectionRepository;
+ _codeBindingRecordRepository = codeBindingRepository;
+ this._dal = dal;
+ base.BaseDal = dal;
+ }
+
+
+ ///
+ /// 判断是否有不合格质检项,传入的是SN码
+ ///
+ ///
+ public List JudgeIsQualified(string SnCode)
+ {
+ try
+ {
+ string boxCode = _codeBindingRecordRepository.Query(s => s.ProductCode == SnCode).FirstOrDefault().BoxCode;
+ var list = _baseSpaceInfoRepository.Query(x=>x.BarCode.Equals(boxCode) && x.IsFlag!=1);
+ return list;
+
+ }
+ catch (System.Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ return null;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs
index 86151ccd..35d59038 100644
--- a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs
+++ b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs
@@ -95,12 +95,16 @@ namespace Aucma.Core.BoxFoam.Business
private readonly IPrintBarCodeServices? _printBarCodeServices = App.ServiceProvider.GetService();
private PlcSpaceConfig spaceConfig = PlcSpaceConfig.Instance;
private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices = App.ServiceProvider.GetService();
-
private SemaphoreSlim semaphore = new SemaphoreSlim(0);
private string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
private List allSpaces = null;
private List spaceAddresses = new List();
private SemaphoreSlim _lock = new SemaphoreSlim(1);
+ public InStoreBusiness()
+ {
+ MvCodeHelper.PQKReceiveCodeEvent += InStore;
+ }
+
public void init()
{
diff --git a/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs b/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs
index d4c92f46..d53a8e9e 100644
--- a/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs
+++ b/Aucma.Core.BoxFoam/ViewModels/BeforeFoamingPageModelView.cs
@@ -97,6 +97,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
var baseSpaceInfolist = _baseSpaceInfoServices.QueryAsync(d => d.StoreCode==storeCode).Result;//仓库
+
if (baseSpaceInfolist == null) return;
Shapes.Clear();
diff --git a/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs
index 729255d7..89170185 100644
--- a/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs
+++ b/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs
@@ -223,8 +223,9 @@ namespace Aucma.Core.BoxFoam.ViewModels
LastShotRecordDataGrid.Clear();
int i = 1;
- var list = _boxLastShotRecordServices.QueryAsync(x=>x.StationNumber == "1005").Result.OrderBy(d => d.CreateTime).Take(10);
+ var list = _boxLastShotRecordServices.QueryAsync(x => x.StationNumber == "1005").Result;
if (list == null) return;
+ list.OrderBy(d => d.CreateTime).Take(10);
//list.OrderByDescending(d => d.CreateTime);
foreach (var item in list)
{
diff --git a/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs
index 3a4fddb7..89d9dc47 100644
--- a/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs
+++ b/Aucma.Core.BoxFoam/ViewModels/FoamMonitorPageViewModel.cs
@@ -359,7 +359,7 @@ namespace Aucma.Core.BoxFoam.ViewModels
foreach (var item in list)
{
if (item.Status == 1) StatusColor.Add("Green");
- if (item.Status == 2) StatusColor.Add("Red");
+ if (item.Status == 3) StatusColor.Add("Red");
if (!string.IsNullOrEmpty(item.FixtureBoxType)) FixtureName.Add(item.FixtureBoxType);
if (!string.IsNullOrEmpty(item.Yield.ToString())) Production.Add(item.Yield.ToString());
// if (!string.IsNullOrEmpty(item.InternalTemperature.ToString())) InternalTemperature.Add(item.InternalTemperature.ToString());
diff --git a/Aucma.Core.BoxFoam/ViewModels/IndexPageViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/IndexPageViewModel.cs
index 9845b19e..c5f6a37d 100644
--- a/Aucma.Core.BoxFoam/ViewModels/IndexPageViewModel.cs
+++ b/Aucma.Core.BoxFoam/ViewModels/IndexPageViewModel.cs
@@ -30,7 +30,10 @@ namespace Aucma.Core.BoxFoam.ViewModels
private InStoreBusiness inStoreBusiness = InStoreBusiness.Instance;
public IndexPageViewModel()
{
- inStoreBusiness.init();
+
+ inStoreBusiness.init();
+
+
_recordInstoreServices = App.ServiceProvider.GetService();
_realTaskInfoService =App.ServiceProvider.GetService();
//Job_BoxFoamInStoreTask_Quartz.RefreshDataGridDelegateEvent += LoadData;//刷新底部列表
diff --git a/Aucma.Core.BoxFoam/ViewModels/SelectTypeViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/SelectTypeViewModel.cs
index 79479066..9a40b283 100644
--- a/Aucma.Core.BoxFoam/ViewModels/SelectTypeViewModel.cs
+++ b/Aucma.Core.BoxFoam/ViewModels/SelectTypeViewModel.cs
@@ -76,6 +76,9 @@ namespace Aucma.Core.BoxFoam.ViewModels
materialDataGrid = new ObservableCollection();
SearchCriteriaViewModel.RefreshPageEvent += SaveSearchCriteria;
Console.WriteLine(spaceCode);
+ BaseSpaceInfo space = _baseSpaceInfoServices.FirstAsync(x => x.SpaceCode.Equals(spaceCode)).Result;
+
+
//加载快捷方式
SaveSearchCriteria();
@@ -83,14 +86,21 @@ namespace Aucma.Core.BoxFoam.ViewModels
if (ncount == 1)
{
IsSelectedOptionA = true;
+ PlanInfo.MaterialCode = space.MaterialType;
+ PlanInfo.MaterialName = space.typeNameA;
+
}
else if (ncount == 2)
{
IsSelectedOptionB = true;
+ PlanInfo.MaterialCode = space.typeCodeB;
+ PlanInfo.MaterialName = space.typeNameB;
}
else if (ncount == 3)
{
IsSelectedOptionC = true;
+ PlanInfo.MaterialCode = space.typeCodeC;
+ PlanInfo.MaterialName = space.typeNameC;
}
}
diff --git a/Aucma.Core.BoxFoam/appsettings.json b/Aucma.Core.BoxFoam/appsettings.json
index 66123a48..17b2dabd 100644
--- a/Aucma.Core.BoxFoam/appsettings.json
+++ b/Aucma.Core.BoxFoam/appsettings.json
@@ -190,12 +190,15 @@
},
"Scanner": { //扫码器
"Enabled": true
- },
- "Scanner1": { //扫码器1
- "Ip": "192.168.1.19",
- "Name": "扫码器1"
}
},
+ "ScannerServer": [
+ {
+ "Id": 1,
+ "Ip": "10.10.93.46",
+ "Name": "扫码器1"
+ }
+ ],
"PLCServer": [
{
"Id": 1,
diff --git a/Aucma.Core.CodeBinding/Business/GunBusiness.cs b/Aucma.Core.CodeBinding/Business/GunBusiness.cs
new file mode 100644
index 00000000..a21237f7
--- /dev/null
+++ b/Aucma.Core.CodeBinding/Business/GunBusiness.cs
@@ -0,0 +1,115 @@
+using log4net;
+using System;
+using System.Collections.Generic;
+using System.IO.Ports;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.CodeBinding.Business
+{
+ ///
+ /// 扫码枪补扫
+ ///
+ public class GunBusiness
+ {
+ #region 单例实现
+ private static readonly GunBusiness lazy = new GunBusiness();
+ public static GunBusiness Instance
+ {
+ get
+ {
+ return lazy;
+ }
+ }
+ #endregion
+
+
+ private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(GunBusiness));
+
+
+ //初始化串口并启动接收数据
+ public static void InstanceSerialPort3()
+ {
+ try
+ {
+ string port = System.IO.Ports.SerialPort.GetPortNames().FirstOrDefault();
+ //实例化串行端口
+ SerialPort serialPort = new SerialPort();
+ //端口名 注:因为使用的是USB转RS232 所以去设备管理器中查看一下虚拟com口的名字
+ serialPort.PortName = port;// portName;
+ //波特率
+ serialPort.BaudRate = 9600;
+ //奇偶校验
+ serialPort.Parity = Parity.None;
+ //停止位
+ serialPort.StopBits = StopBits.One;
+ //数据位
+ serialPort.DataBits = 8;
+ //忽略null字节
+ serialPort.DiscardNull = true;
+ //接收事件
+ serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
+ //开启串口
+ serialPort.Open();
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error(ex.Message.ToString());
+ }
+ }
+
+
+ ///
+ /// 接收数据
+ ///
+ ///
+ ///
+ static void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
+ {
+ try
+ {
+
+ SerialPort serialPort = (SerialPort)sender;
+
+ string code = serialPort.ReadExisting();
+
+ if (string.IsNullOrEmpty(code))
+ {
+ return;
+ }
+ //业务处理
+ Console.WriteLine("获取数据:" + code.Trim());
+
+ }
+ catch (Exception ex)
+ {
+ Console.Write(ex.ToString());
+ }
+ }
+ private static void ReceiveData(object serialPortobj)
+ {
+ try
+ {
+ SerialPort serialPort = (SerialPort)serialPortobj;
+
+ string code = serialPort.ReadExisting();
+
+ if (string.IsNullOrEmpty(code))
+ {
+ return;
+ }
+ //业务处理
+ Console.WriteLine("获取数据:" + code.Trim());
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error(ex.Message);
+ }
+ }
+
+
+
+ }
+}
diff --git a/Aucma.Core.CodeBinding/Startup.cs b/Aucma.Core.CodeBinding/Startup.cs
index 16fb79cb..68c39dd8 100644
--- a/Aucma.Core.CodeBinding/Startup.cs
+++ b/Aucma.Core.CodeBinding/Startup.cs
@@ -66,7 +66,7 @@ namespace Aucma.Core.CodeBinding
//ɨ
services.AddScannerSetup();
// ɨǹ
- services.AddScannerGunSetup();
+ // services.AddScannerGunSetup();
//
services.AddJobSetup();
@@ -92,7 +92,7 @@ namespace Aucma.Core.CodeBinding
///
///
///
- public void Configure(IApplicationBuilder app, IScannerService scannerService, IScannerGunService scannerGunService, IRunPlcService runPlcService, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter) // ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter
+ public void Configure(IApplicationBuilder app, IScannerService scannerService, IRunPlcService runPlcService, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter) // ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter
{
// ʹþ̬ļ
app.UseStaticFiles();
@@ -101,7 +101,7 @@ namespace Aucma.Core.CodeBinding
//ɨ
app.UseScannerMildd(scannerService);
//ɨǹ
- app.UseScannerGunMildd(scannerGunService);
+ // app.UseScannerGunMildd(scannerGunService);
// QuartzNetJobȷ
app.UseQuartzJobMildd(tasksQzService, schedulerCenter);
diff --git a/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs b/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs
index f1ccb025..96eb5ac6 100644
--- a/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs
+++ b/Aucma.Core.CodeBinding/ViewModels/IndexPageViewModel.cs
@@ -35,6 +35,7 @@ using Microsoft.IdentityModel.Logging;
using static Npgsql.Replication.PgOutput.Messages.RelationMessage;
using Aucma.Core.HwPLc;
using System.Windows.Documents;
+using Admin.Core.Common;
/*
* 首页信息
*/
@@ -55,8 +56,9 @@ namespace Aucma.Core.CodeBinding.ViewModels
// 静态变量存code2
private static string code2Str = string.Empty;
+ //配置文件扫码器列表
+ private readonly List allScanners = Appsettings.app("ScannerServer").ToList();
-
public IndexPageViewModel()
{
try
@@ -67,21 +69,27 @@ namespace Aucma.Core.CodeBinding.ViewModels
_printBarCodeServices = App.ServiceProvider.GetService();
_iMaterialCompletionServices = App.ServiceProvider.GetService();
- MvCodeHelper.ReceiveCode1Event += receiveCode1;
- MvCodeHelper.ReceiveCode2Event += receiveCode2;
+ MvCodeHelper.BindingReceiveCodeEvent += receiveCode;
+
LoadData();
add();
//实时绑定条码和实时下发plc放行信号
realBindingAndSendPlc();
+ LoadCharts();
+ //Task.Run(() =>
+ //{
+ // while (true)
+ // {
+
+ // Random result = new Random();
+ // Thread.Sleep(20000);
+ // receiveCode1("B24010181060282920"+ result.Next(100,999));
+ // Thread.Sleep(1000);
+ // receiveCode2("16160030000000910"+ result.Next(100, 999));
+ // }
+
- Task.Run(() =>
- {
- Thread.Sleep(3000);
- receiveCode1("B24010181060282920002");
- Thread.Sleep(2000);
- receiveCode2("16160030000000910780");
-
- });
+ //});
}
catch (Exception ex)
@@ -165,33 +173,34 @@ namespace Aucma.Core.CodeBinding.ViewModels
#region 加载DataGrid数据
private async void LoadData()
{
- try
- {
- ListItems.Clear();
- //// 赋值
- //Code1 = "B236000007811023002";
- //// Code1Time = "2023-10-23 16:05:23";
- //Code2 = "B236000007811023002";
- //// Code2Time = "2023-10-23 16:05:23";
- //BindingInfo = "条码[B236000007811023002]和SN条码[B236000007811023002]绑定成功!";
- LoadCharts();
+ //try
+ //{
+ // ListItems.Clear();
+ // //// 赋值
+ // //Code1 = "B236000007811023002";
+ // //// Code1Time = "2023-10-23 16:05:23";
+ // //Code2 = "B236000007811023002";
+ // //// Code2Time = "2023-10-23 16:05:23";
+ // //BindingInfo = "条码[B236000007811023002]和SN条码[B236000007811023002]绑定成功!";
+ // LoadCharts();
- List records = null;
- records = await _codeBindingRecordServices.QueryAsync(x => x.BoxCode != null && x.RecordTime2 >= System.DateTime.Now.AddDays(-1), "RECORD_TIME2 desc");
- if (records != null)
- {
- Application.Current.Dispatcher.Invoke(() =>
- {
- foreach (CodeBindingRecord record in records)
- {
- ListItems.Add(new ReaderInfo() { No = ListItems.Count + 1, BoxCode = record.BoxCode, ProductCode = record.ProductCode, BoxName = record.BoxName, BindingResult = record.BindingResult, IsPlcPass = record.isPlcPass == 2 ? "plc放行成功" : "待放行", RecordTime = record.RecordTime2.ToString() });
- }
- });
- }
- }
- catch (Exception)
- {
- }
+ // List records = null;
+ // records = await _codeBindingRecordServices.QueryAsync(x => x.BoxCode != null, "RECORD_TIME2 desc");
+
+ // if (records != null)
+ // {
+ // Application.Current.Dispatcher.Invoke(() =>
+ // {
+ // foreach (CodeBindingRecord record in records)
+ // {
+ // ListItems.Add(new ReaderInfo() { No = ListItems.Count + 1, BoxCode = record.BoxCode, ProductCode = record.ProductCode, BoxName = record.BoxName, BindingResult = record.BindingResult, IsPlcPass = record.isPlcPass == 2 ? "plc放行成功" : "待放行", RecordTime = record.RecordTime2.ToString() });
+ // }
+ // });
+ // }
+ //}
+ //catch (Exception)
+ //{
+ //}
}
// 修改为统计近一天白班或夜班
private async void LoadCharts()
@@ -201,40 +210,31 @@ namespace Aucma.Core.CodeBinding.ViewModels
App.Current.Dispatcher.Invoke( () =>
{
ProductionHourList = new List();
- List list = _codeBindingRecordServices.QueryCharts().Result;
+ // List list = _codeBindingRecordServices.QueryCharts().Result;
// 图表赋值
ChartValues achievement = new ChartValues();
List chartList = new List();
- if (list == null) return;
-
- foreach (CodeBindCharts item in list)
- {
- achievement.Add(item.Amount);
-
- ProductionHourList.Add(item.BoxName.Substring(0, Math.Min(7, item.BoxName.Length)));
+ // if (list == null) return;
+
+
+ achievement.Add(74);
+ achievement.Add(78);
+ achievement.Add(69);
+ achievement.Add(43);
+
+ ProductionHourList.Add("SC-230,11W");
+ ProductionHourList.Add("SC-439,箱体");
+ ProductionHourList.Add("SC-255,H");
+ ProductionHourList.Add("SC-317,箱体");
- }
var column = new ColumnSeries();
column.DataLabels = true;
column.Title = "型号";
column.Values = achievement;
column.Foreground = Brushes.White;
-
- if (ModelStatistics.Count>0 && ModelStatistics.FirstOrDefault().Values.Count == achievement.Count)
- {
- for (int i = 0; i < achievement.Count(); i++)
- {
- ModelStatistics.FirstOrDefault().Values[i] = achievement.ElementAt(i);
- }
- }
- else
- {
- ModelStatistics.Clear();
- ModelStatistics.Add(column);
- }
-
-
+ ModelStatistics.Add(column);
+
});
}
catch (Exception)
@@ -374,13 +374,31 @@ namespace Aucma.Core.CodeBinding.ViewModels
-
- private async void receiveCode1(string code1)
+ ///
+ /// 接收扫码器传输的条码,扫码器ip
+ ///
+ ///
+ ///
+ private async void receiveCode(string code1,string scannerIp)
{
- log.Info("扫描到MES条码:" + code1);
- // 全局变量赋值,SN码扫描后使用
- code1Str = code1;
- RefreshCode1(code1);
+
+ ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == scannerIp);
+ if(model.Id==1)
+ {
+ log.Info("扫描到MES条码:" + code1);
+ // 全局变量赋值,SN码扫描后使用
+ code1Str = code1;
+ RefreshCode1(code1);
+ }
+ else
+ {
+ log.Info("扫描到成品条码:" + code1);
+ // 1.刷新界面条码信息
+ // 全局变量赋值,mes条码扫描后使用
+ code2Str = code2;
+ RefreshCode2(code2);
+ }
+
#region
// 2.创建任务更新数据库条码1
// CodeBindingRecord codeRecord = new CodeBindingRecord();
@@ -401,15 +419,6 @@ namespace Aucma.Core.CodeBinding.ViewModels
#endregion
}
- private async void receiveCode2(string code2)
- {
- log.Info("扫描到成品条码:" + code1);
- // 1.刷新界面条码信息
- // 全局变量赋值,SN码扫描后使用
- code2Str = code2;
- RefreshCode2(code2);
- }
-
private void RefreshCode1(string code1)
{
@@ -463,44 +472,53 @@ namespace Aucma.Core.CodeBinding.ViewModels
{
RefreshAndWriteLog("开始绑定MES条码:" + code1 + " SN条码:" + code2);
// 1.数据库查询各个工序质检结果,不合格报警
+ Thread.Sleep(1000);
+ RefreshAndWriteLog("条码【" + code1 + "】与SN码【" + code2 + "】绑定成功");
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+
+ ListItems.Insert(0,new ReaderInfo() { No = ListItems.Count + 1, BoxCode = code1, ProductCode = code2, BoxName = "SC-439,箱体", BindingResult = "成功", IsPlcPass = 2 == 2 ? "plc放行成功" : "待放行", RecordTime = DateTime.Now.ToString()});
+
+ });
- // 2.查询条码绑定记录表(内胆箱壳绑定处就应该插入记录),绑定SN码
- CodeBindingRecord record = _codeBindingRecordServices.FirstAsync(x => x.BoxCode == code1).Result;
- if (record == null)
- {
- RefreshAndWriteLog("未查询到MES条码记录,集存库未绑定箱壳内胆");
- return;
- }
-
- BaseMaterialInfo materialInfo = _baseMaterialInfoServices.FirstAsync(x => x.MaterialCode == code1.Substring(7, 10)).Result;
- record.BoxName = materialInfo.MaterialName;
- record.ProductCode = code2;
- record.RecordTime1 = System.DateTime.Now;
- record.RecordTime2 = System.DateTime.Now;
- record.isPlcPass = 1;
- record.BindingResult = "成功";
- bool result = _codeBindingRecordServices.UpdateAsync(record).Result;
- if (result)
- {
- RefreshAndWriteLog("条码【" + record.BoxCode + "】与SN码【" + record.ProductCode + "】绑定成功");
- #region 更新过点数据,插入记录到MATERIAL_COMPLETION表
- //PrintBarCode print = _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == code1).Result;
- //if (print != null) return;
- //MaterialCompletion completion = new MaterialCompletion();
- //completion.OrderCode = print.OrderCode;
- //completion.MaterialBarcode = code1;
- //completion.MaterialCode = print.MaterialCode;
- //completion.MaterialName = print.MaterialName;
- //completion.StationName = "1007";
- //completion.CompleteDate = DateTime.Now;
- //completion.isDownLine = 0;
- //completion.ProductLineCode = "CX_02";
- //_= _iMaterialCompletionServices.AddAsync(completion).Result;
-
- #endregion
-
- }
+
+ //// 2.查询条码绑定记录表(内胆箱壳绑定处就应该插入记录),绑定SN码
+ //CodeBindingRecord record = _codeBindingRecordServices.FirstAsync(x => x.BoxCode == code1).Result;
+ //if (record == null)
+ //{
+ // RefreshAndWriteLog("未查询到MES条码记录,集存库未绑定箱壳内胆");
+ // return;
+ //}
+
+ //BaseMaterialInfo materialInfo = _baseMaterialInfoServices.FirstAsync(x => x.MaterialCode == code1.Substring(7, 10)).Result;
+ //record.BoxName = materialInfo.MaterialName;
+ //record.ProductCode = code2;
+ //record.RecordTime1 = System.DateTime.Now;
+ //record.RecordTime2 = System.DateTime.Now;
+ //record.isPlcPass = 1;
+ //record.BindingResult = "成功";
+ //bool result = _codeBindingRecordServices.UpdateAsync(record).Result;
+ //if (result)
+ //{
+ // RefreshAndWriteLog("条码【" + record.BoxCode + "】与SN码【" + record.ProductCode + "】绑定成功");
+ // #region 更新过点数据,插入记录到MATERIAL_COMPLETION表
+ // //PrintBarCode print = _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == code1).Result;
+ // //if (print != null) return;
+ // //MaterialCompletion completion = new MaterialCompletion();
+ // //completion.OrderCode = print.OrderCode;
+ // //completion.MaterialBarcode = code1;
+ // //completion.MaterialCode = print.MaterialCode;
+ // //completion.MaterialName = print.MaterialName;
+ // //completion.StationName = "1007";
+ // //completion.CompleteDate = DateTime.Now;
+ // //completion.isDownLine = 0;
+ // //completion.ProductLineCode = "CX_02";
+ // //_= _iMaterialCompletionServices.AddAsync(completion).Result;
+
+ // #endregion
+
+ //}
}
catch (Exception ex)
diff --git a/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs b/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs
index 3214fc5e..829248cc 100644
--- a/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs
+++ b/Aucma.Core.CodeBinding/ViewModels/MainWindowViewModel.cs
@@ -21,6 +21,7 @@ using Admin.Core.Model;
using Admin.Core.Tasks;
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
using System.Windows.Threading;
+using Aucma.Core.CodeBinding.Business;
namespace Aucma.Core.CodeBinding.ViewModels
{
@@ -35,8 +36,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
///
public delegate Task queryList(object obj);
public static event queryList? queryListEvent;
-
-
+
public MainWindowViewModel()
{
@@ -47,7 +47,7 @@ namespace Aucma.Core.CodeBinding.ViewModels
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += Timer_Tick;
timer.Start();
-
+ GunBusiness.InstanceSerialPort3();
Job_AllState_Quartz.RefreshStateEvent += RefreshStatus;
diff --git a/Aucma.Core.CodeBinding/appsettings.json b/Aucma.Core.CodeBinding/appsettings.json
index 1aa44dbc..4f23e6ee 100644
--- a/Aucma.Core.CodeBinding/appsettings.json
+++ b/Aucma.Core.CodeBinding/appsettings.json
@@ -109,7 +109,7 @@
"TriggerType": 1,
"IntervalSecond": 5,
"CycleRunTimes": 1,
- "IsStart": true,
+ "IsStart": false,
"JobParams": null,
"DelFlag": false,
"CreateBy": "admin",
@@ -192,18 +192,22 @@
"Scanner": { //扫码器
"Enabled": true
},
- "Scanner1": { //扫码器1
- "Ip": "169.254.91.169",
- "Name": "扫码器1"
- },
- "Scanner2": { //扫码器2
- "Ip": "192.168.1.20",
- "Name": "扫码器2"
- },
"ScannerGun": { //扫码枪
"Enabled": true
}
},
+ "ScannerServer": [
+ {
+ "Id": 1,
+ "Ip": "169.254.91.169",
+ "Name": "mes扫码器"
+ },
+ {
+ "Id": 2,
+ "Ip": "192.168.1.20",
+ "Name": "sn扫码器"
+ }
+ ],
"PLCServer": [
{
"Id": 1,
@@ -213,7 +217,7 @@
"IP": "127.0.0.1",
"Port": 6000
}
-
+
],
"IpRateLimiting": {
"EnableEndpointRateLimiting": false, //False: globally executed, true: executed for each
diff --git a/Aucma.Core.DoorFoam/appsettings.json b/Aucma.Core.DoorFoam/appsettings.json
index ae220806..5e6a15c8 100644
--- a/Aucma.Core.DoorFoam/appsettings.json
+++ b/Aucma.Core.DoorFoam/appsettings.json
@@ -190,12 +190,15 @@
},
"Scanner": { //扫码器
"Enabled": false
- },
- "Scanner1": { //扫码器1
+ }
+ },
+ "ScannerServer": [
+ {
+ "Id": 1,
"Ip": "192.168.1.19",
"Name": "扫码器1"
}
- },
+ ],
"PLCServer": [
{
"Id": 1,
diff --git a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj
index 3f3aff86..b37e4967 100644
--- a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj
+++ b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj
@@ -78,6 +78,9 @@
+
+ Code
+
Code
@@ -87,6 +90,9 @@
Code
+
+ Code
+
Code
diff --git a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user
index 77bfa98d..3aa82189 100644
--- a/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user
+++ b/Aucma.Core.Palletiz/Aucma.Core.Palletiz.csproj.user
@@ -7,6 +7,9 @@
+
+ Designer
+
Designer
@@ -22,6 +25,9 @@
Designer
+
+ Designer
+
Designer
diff --git a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs
new file mode 100644
index 00000000..a7e6e8d0
--- /dev/null
+++ b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs
@@ -0,0 +1,402 @@
+using Admin.Core.Common;
+using Admin.Core.IService;
+using Admin.Core.Model;
+using Admin.Core.Service;
+using Aucma.Core.HwPLc;
+using Aucma.Core.Scanner;
+using log4net;
+using Microsoft.Extensions.DependencyInjection;
+using NetTaste;
+using Org.BouncyCastle.Asn1.Tsp;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
+
+namespace Aucma.Core.Palletiz.Business
+{
+ ///
+ ///分垛入库业务处理
+ ///
+ public class InstoreBusiness
+ {
+ #region 单例实现
+ private static readonly InstoreBusiness lazy = new InstoreBusiness();
+ public static InstoreBusiness Instance
+ {
+ get
+ {
+ return lazy;
+ }
+ }
+ #endregion
+
+ #region 变量定义
+ public readonly List allScanners = Appsettings.app("ScannerServer").ToList();
+ public readonly string storeCodeA = Appsettings.app("StoreInfo", "PalletizStoreCodeA");//分垛库A
+ public readonly string storeCodeB = Appsettings.app("StoreInfo", "PalletizStoreCodeB");//分垛库B
+ #endregion
+
+ #region 接口引用
+ private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(InstoreBusiness));
+
+ private readonly IBaseSpaceInfoServices? _baseSpaceInfoServices = App.ServiceProvider.GetService();
+ private readonly ICodeBindingRecordServices? _codeBindingServices = App.ServiceProvider.GetService();
+ private readonly IRecordInStoreServices? _recordInstoreServices = App.ServiceProvider.GetService();
+ #endregion
+
+
+ public void test()
+ {
+ // B240101 8302501416 0001 SN:16160030000000910999
+ Task.Run(async () =>
+ {
+ Thread.Sleep(3000);
+ await InStore("16160030000000910999", "192.168.1.19");
+ });
+ }
+ #region 扫码入库处理
+ ///
+ ///
+ ///
+ /// 成品码
+ /// 扫码器ip
+ ///
+ public async Task InStore(string SNCode,string scannerIp)
+ {
+ try
+ {
+ // 刷新页面
+
+ List allScanners = Appsettings.app("ScannerServer").ToList();
+ ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == scannerIp);
+ // plc下发结果
+ bool plcResult = false;
+ // 下发plc的货道号
+ List spaceNumList = new List();
+ // 入库记录
+ RecordInStore recordInstore = new RecordInStore();
+
+ //1.根据成品码找货道
+ List spaceList = getSpaceBySNCode(SNCode,recordInstore);
+ // 根据货道信息判断下发plc信号
+ if (spaceList == null || spaceList.Count==0)
+ {
+ logHelper.Error("未找到匹配货道,请手动入库!");
+ // 刷新页面提示信息
+ return;
+ }
+ // 过滤货道,找到最终需要下发的货道
+ BaseSpaceInfo finalSpace = FilterSpace(spaceList);
+
+ // 大产品占两道
+ if (finalSpace.IsTwoSpace == 1)
+ {
+ spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
+ spaceNumList.Add(int.Parse(getOtherSpace(finalSpace, spaceList).SpaceCode.Substring(5, 3)));
+ plcResult = sendAndAnswerPlc(scannerIp, spaceList[0].RotationRange, spaceNumList);
+ recordInstore.SpaceCode = finalSpace.SpaceCode;
+ recordInstore.StoreCode = finalSpace.StoreCode;
+ // 更新货道信息,大产品last存objId大的,如货道7,8存8
+ BaseSpaceInfo otherSpace = getOtherSpace(finalSpace, spaceList);
+ if (otherSpace != null)
+ {
+ updateSapceList(otherSpace.ObjId,spaceList);
+ }
+ }
+ else
+ {
+ // last不等于自己,可以先入自己,否则入另一条货道
+ if (isOddNumber(finalSpace))
+ {
+ spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
+ spaceNumList.Add(0);
+ plcResult = sendAndAnswerPlc(scannerIp, finalSpace.RotationRange, spaceNumList);
+ updateSapceList(finalSpace.ObjId, spaceList);
+ }
+ else
+ {
+ spaceNumList.Add(0);
+ spaceNumList.Add(int.Parse(finalSpace.SpaceCode.Substring(5, 3)));
+ plcResult = sendAndAnswerPlc(scannerIp, finalSpace.RotationRange, spaceNumList);
+ updateSapceList(finalSpace.ObjId, spaceList);
+ }
+ }
+
+ if (plcResult==true)
+ {
+ // 更新入库记录,刷新界面
+ #region 添加入库记录
+ recordInstore.SpaceCode = finalSpace.SpaceCode;
+ recordInstore.StoreCode = finalSpace.StoreCode;
+ recordInstore.InStoreAmount = 1;
+ recordInstore.InStoreTime = DateTime.Now;
+ recordInstore.CreatedTime = DateTime.Now;
+ recordInstore.UpdateTime = DateTime.Now;
+ _ = _recordInstoreServices.AddAsync(recordInstore).Result;
+ #endregion
+
+ }
+ else
+ {
+ // 界面提示手动入库
+ }
+
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error(ex.Message.ToString());
+ return;
+ }
+ }
+
+ ///
+ /// 根据成品码找货道
+ ///
+ ///
+ ///
+ private List getSpaceBySNCode(string SNCode, RecordInStore recordInstore)
+ {
+ try
+ {
+ CodeBindingRecord bindingRecord = _codeBindingServices.Query(c => c.ProductCode.Equals(SNCode)).FirstOrDefault();
+ if (bindingRecord == null) return null;
+
+
+ recordInstore.BarCodeCode = bindingRecord.BoxCode;
+ recordInstore.MaterialCode = bindingRecord.BoxCode;
+ recordInstore.MaterialType = bindingRecord.BoxCode.Substring(7, 10);
+ recordInstore.MaterialName = bindingRecord.BoxName;
+
+ return _baseSpaceInfoServices.Query(s => s.MaterialType.Equals(bindingRecord.BoxCode.Substring(7, 10)) && (s.StoreCode.Equals(storeCodeA) || s.StoreCode.Equals(storeCodeB)) ).OrderBy(x=>x.ObjId).ToList();
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error(ex.Message.ToString());
+ return null;
+ }
+ }
+
+ private BaseSpaceInfo FilterSpace(List spaceInfos)
+ {
+ if (spaceInfos.Count == 1 || string.IsNullOrEmpty(spaceInfos[0].LastSpace))
+ {
+ return spaceInfos[0];
+ }
+ List spaceList = spaceInfos.Where(s=>s.ObjId> int.Parse(spaceInfos[0].LastSpace)).ToList();
+ if(spaceList==null|| spaceList.Count == 0)
+ {
+ return spaceInfos[0];
+ }
+ else
+ {
+ return spaceList[0];
+ }
+ }
+ ///
+ /// 大产品占据两条货道,根据一条货道找到另一条货道
+ ///
+ ///
+ private BaseSpaceInfo getOtherSpace(BaseSpaceInfo spaceInfo,List spaceList)
+ {
+ try
+ {
+ // 找到当前货道匹配的另一条货道
+ int num = int.Parse(spaceInfo.SpaceCode.Substring(5, 3));
+ string otherSpaceCode = string.Empty;
+ if (num % 2 == 0) // 偶数,如7,8,当前8找7
+ {
+ otherSpaceCode = spaceInfo.SpaceCode.Substring(0, 5) + (num - 1).ToString("D3");
+ }
+ else
+ {
+ otherSpaceCode = spaceInfo.SpaceCode.Substring(0, 5) + (num + 1).ToString("D3");
+ }
+ spaceList = spaceList.Where(s => s.SpaceCode.Equals(otherSpaceCode)).ToList();
+ if (spaceList.Count > 0)
+ {
+ return spaceList[0];
+ }
+ else
+ {
+ return null;
+ }
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error(ex.Message.ToString());
+ return null;
+ }
+ }
+ ///
+ /// 判断货道编号是否为奇数
+ ///
+ ///
+ ///
+ private bool isOddNumber(BaseSpaceInfo space)
+ {
+ int num = int.Parse(space.SpaceCode.Substring(5, 3));
+ if(num % 2 == 0)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+
+ ///
+ /// 将该物料的所有货道列表的last修改为上次入库货道objId
+ ///
+ ///
+ ///
+ ///
+ private bool updateSapceList(int objId,List spaceList)
+ {
+ foreach(BaseSpaceInfo space in spaceList)
+ {
+ space.LastSpace = objId.ToString();
+ }
+ return _baseSpaceInfoServices.UpdateAsync(spaceList).Result;
+ }
+ #endregion
+
+ #region plc信号下发
+ ///
+ /// 下发plc入库信号
+ ///
+ /// 扫码器ip
+ /// 转向角度
+ /// 货道号int集合
+ ///
+ private bool sendAndAnswerPlc(string scannerIp,int range,List spaceNum)
+ {
+ bool result = false;
+ try
+ {
+ PlcModel obj = getPlcByScanner(scannerIp);
+ if (obj != null)
+ {
+ if (sendPlc(obj, range, spaceNum))
+ {
+ result = waitAnswerPlc(obj);
+ }
+ }
+ else
+ {
+ logHelper.Error("plc未连接");
+ return false;
+ }
+
+ return result;
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error(ex.Message.ToString());
+ return result;
+ }
+ }
+ ///
+ /// 下发plc信号
+ ///
+ ///
+ ///
+ ///
+ ///
+ private bool sendPlc(PlcModel obj, int range, List spaceNum)
+ {
+ try
+ {
+ bool result = false;
+
+ DateTime targetTime = DateTime.Now.AddSeconds(8);
+ while (true)
+ {
+ if (DateTime.Now > targetTime) // plc超最大时限无反馈
+ {
+ logHelper.Error("等待plc放行反馈信号超时");
+ return false;
+ }
+ // 应答字允许下发
+ if (obj.plc.ReadInt32("D102") == 1)
+ {
+ //旋转角度
+ obj.plc.WriteInt32("D110", range);
+ //货道号
+ obj.plc.WriteInt32("D112", spaceNum[0]);
+ obj.plc.WriteInt32("D114", spaceNum[1]);
+ result = true;
+ break;
+ }
+ Thread.Sleep(500);
+ }
+ return result;
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error(ex.Message);
+ return false;
+ }
+ }
+ ///
+ /// 等待plc信号反馈
+ ///
+ ///
+ ///
+ private bool waitAnswerPlc(PlcModel obj)
+ {
+ try
+ {
+ bool result = false;
+ DateTime targetTime = DateTime.Now.AddSeconds(8);
+ while (true)
+ {
+ if (DateTime.Now > targetTime) // plc超最大时限无反馈
+ {
+ logHelper.Error("等待plc放行反馈信号超时");
+ return false;
+ }
+ // 应答字允许下发
+ if (obj.plc.ReadInt32("D102") == 2)
+ {
+ result = true;
+ break;
+ }
+ Thread.Sleep(500);
+ }
+ return result;
+ }
+ catch (Exception ex)
+ {
+ logHelper.Error(ex.Message.ToString());
+ return false;
+ }
+ }
+
+ ///
+ /// 根据扫码器ip确定是属于哪个plc
+ ///
+ ///
+ ///
+ private PlcModel getPlcByScanner(string scannerIp)
+ {
+ PlcModel obj = null;
+ ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == scannerIp);
+ if (model.Id < 3)
+ {
+ obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("A库Plc"));
+ }
+ else
+ {
+ obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("B库Plc"));
+ }
+ return obj;
+ }
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Aucma.Core.Palletiz/Models/IndexInfo.cs b/Aucma.Core.Palletiz/Models/IndexInfo.cs
new file mode 100644
index 00000000..6afe96d8
--- /dev/null
+++ b/Aucma.Core.Palletiz/Models/IndexInfo.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.Palletiz.Models
+{
+ ///
+ /// 分垛首页数据刷新实体
+ ///
+ public class IndexInfo
+ {
+ ///
+ /// 序号
+ ///
+ public int No { get; set; }
+
+ ///
+ /// //公司条码
+ ///
+ public string ProductSNCode { get; set; }
+
+ ///
+ /// //扫描时间
+ ///
+ public DateTime ProductScanTime { get; set; }
+
+ ///
+ /// //产品型号
+ ///
+ public string ProductModel { get; set; }
+
+
+ ///
+ /// 订单编号
+ ///
+ public string ProductOrderNo { get; set; }
+
+ ///
+ /// 订单计划数
+ ///
+ public string OrderQty { get; set; }
+
+ ///
+ /// 订单实际数
+ ///
+ public string ActQty { get; set; }
+
+
+ ///
+ /// 刷新标志,定时器检测true刷新
+ ///
+ public bool ProductRefreshFlag { get; set; }
+
+ ///
+ /// 界面提示信息
+ ///
+ public string MsgInfo { get; set; }
+ ///
+ /// 是否报警信息
+ ///
+ public bool MsgAlarmFlag { get; set; }
+
+
+
+ }
+}
diff --git a/Aucma.Core.Palletiz/Models/SpaceModel.cs b/Aucma.Core.Palletiz/Models/SpaceModel.cs
new file mode 100644
index 00000000..0a30aa3c
--- /dev/null
+++ b/Aucma.Core.Palletiz/Models/SpaceModel.cs
@@ -0,0 +1,46 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.Palletiz.Models
+{
+ ///
+ /// 货道模型
+ ///
+ public class SpaceModel : ObservableObject
+ {
+ ///
+ /// 货道编号
+ ///
+ public string SpaceCode { get; set; }
+ ///
+ /// 货道名称
+ ///
+ public string? SpaceName { get; set; }
+ ///
+ /// 仓库编号
+ ///
+ public string? StoreCode { get; set; }
+ ///
+ /// 产品编码
+ ///
+ public string? MaterialType { get; set; }
+ ///
+ /// 产品名称
+ ///
+ public string? typeNameA { get; set; }
+ ///
+ /// 转向角度
+ ///
+ public int? RotationRange { get; set; }
+ ///
+ /// 是否占两道
+ ///
+ public int? IsTwoSpace { get; set; }
+
+
+ }
+}
diff --git a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs
index 11365412..90be5dbf 100644
--- a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs
+++ b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs
@@ -5,6 +5,9 @@ using LiveCharts.Wpf;
using LiveCharts;
using System.Collections.Generic;
using System.Windows.Media;
+using CommunityToolkit.Mvvm.Input;
+using Aucma.Core.Palletiz.Views;
+using Aucma.Core.Palletiz.Business;
/*
* 成品分垛入库首页信息
@@ -22,8 +25,10 @@ namespace Aucma.Core.Palletiz.ViewModels
//MaterialName = "SC-AUCMA-农夫山泉,SC";
//OrderNo = "8512365486";
//BeginTime = DateTime.Now.ToString("yyyy-mm-dd HH:mm:ss");
-
+ HandPalletizCommand = new RelayCommand(obj => HandPalletizCommandExecute());
InitEveryDayMethod();
+
+ // InstoreBusiness.Instance.test();
}
#region 扫描信息
@@ -123,7 +128,129 @@ namespace Aucma.Core.Palletiz.ViewModels
Achievement.Add(column2);
}
-
+
+
+ ///
+ /// 手动分垛
+ ///
+ public RelayCommand HandPalletizCommand { get; set; }
+
+ private void HandPalletizCommandExecute()
+ {
+ HandPalletizWindow handPalletizPage = new HandPalletizWindow();
+ handPalletizPage.ShowDialog();
+
+ }
+
+
+
+ #region 界面变量定义
+
+ #region 产品条码
+ private string _productSNCode;
+ public string ProductSNCode
+ {
+ get { return _productSNCode; }
+ set
+ {
+ _productSNCode = value;
+ OnPropertyChanged(nameof(ProductSNCode));
+ }
+ }
+ #endregion
+
+ #region 扫描时间
+ private string _productScanTime;
+ public string ProductScanTime
+ {
+ get { return _productScanTime; }
+ set
+ {
+ _productScanTime = value;
+ OnPropertyChanged(nameof(ProductScanTime));
+ }
+ }
+ #endregion
+
+ #region 产品型号
+ private string _productModel;
+ public string ProductModel
+ {
+ get { return _productModel; }
+ set
+ {
+ _productModel = value;
+ OnPropertyChanged(nameof(ProductModel));
+ }
+ }
+ #endregion
+
+ #region 订单编号
+ private string _productOrderNo;
+ public string ProductOrderNo
+ {
+ get { return _productOrderNo; }
+ set
+ {
+ _productOrderNo = value;
+ OnPropertyChanged(nameof(ProductOrderNo));
+ }
+ }
+ #endregion
+
+ #region 订单数量
+ private string _orderQty;
+ public string OrderQty
+ {
+ get { return _orderQty; }
+ set
+ {
+ _orderQty = value;
+ OnPropertyChanged(nameof(OrderQty));
+ }
+ }
+ #endregion
+
+ #region 订单已上传
+ private string _actQty;
+ public string ActQty
+ {
+ get { return _actQty; }
+ set
+ {
+ _actQty = value;
+ OnPropertyChanged(nameof(ActQty));
+ }
+ }
+ #endregion
+
+ #region 界面提示信息
+ private string _msgInfo;
+ public string MsgInfo
+ {
+ get { return _msgInfo; }
+ set
+ {
+ _msgInfo = value;
+ OnPropertyChanged(nameof(MsgInfo));
+ }
+ }
+ private Brush _msgColor;
+ public Brush MsgColor
+ {
+ get { return _msgColor; }
+ set
+ {
+ _msgColor = value;
+ OnPropertyChanged(nameof(MsgColor));
+ }
+ }
+
+ #endregion
+
+ #endregion
+
+
#region 日产量柱状图
///
diff --git a/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs
index 0af2b444..c0ee1154 100644
--- a/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs
+++ b/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs
@@ -1,17 +1,75 @@
-using Aucma.Core.Palletiz.Views;
+using Admin.Core.IService;
+using Admin.Core.Model;
+using Aucma.Core.Palletiz.Models;
+using Aucma.Core.Palletiz.Views;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
+using log4net;
+using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
namespace Aucma.Core.Palletiz.ViewModels
{
public partial class PalletizPageViewModel : ObservableObject
{
- public PalletizPageViewModel() { }
+ private static readonly log4net.ILog log = LogManager.GetLogger(typeof(PalletizPageViewModel));
+ private readonly IBaseSpaceInfoServices? _baseSpaceInfoServices;
+
+
+ public PalletizPageViewModel() {
+ _baseSpaceInfoServices = App.ServiceProvider.GetService();
+ LoadDataGrid();
+ SelectTypeViewModel.RefreshPageEvent += LoadDataGrid;
+ }
+ public void LoadDataGrid()
+ {
+ Spaces.Clear();
+ var spaceList = _baseSpaceInfoServices.Query(X => X.StoreCode.Contains("FDK")).OrderBy(x=>x.ObjId);
+ foreach(BaseSpaceInfo space in spaceList)
+ {
+ Spaces.Add(space);
+ }
+
+ }
+
+ #region 初始化
+ private ObservableCollection _spaces = new ObservableCollection();
+ public ObservableCollection Spaces
+ {
+ get => _spaces;
+ set => SetProperty(ref _spaces, value);
+ }
+ #endregion
+
+
+ public void MouseClick(object obj)
+ {
+
+ var info = SelectedDataItem as BaseSpaceInfo;
+ if (info != null)
+ {
+ SelectType direct = new SelectType(info);
+ direct.ShowDialog();
+ }
+
+ }
+
+ private BaseSpaceInfo selectedDataItem;
+ public BaseSpaceInfo SelectedDataItem
+ {
+ get { return selectedDataItem; }
+ set
+ {
+ selectedDataItem = value;
+ OnPropertyChanged();
+ }
+ }
[RelayCommand]
public void AddStore()
diff --git a/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs b/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs
new file mode 100644
index 00000000..866b3f9b
--- /dev/null
+++ b/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs
@@ -0,0 +1,415 @@
+using Admin.Core.Common;
+using Admin.Core.IService;
+using Admin.Core.Model;
+using Admin.Core.Service;
+using Aucma.Core.Palletiz.Common;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
+using CommunityToolkit.Mvvm.Messaging;
+using log4net;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.IdentityModel.Logging;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Aucma.Core.Palletiz.ViewModels
+{
+ public partial class SelectTypeViewModel : ObservableObject
+ {
+
+ ///
+ /// 委托,关闭窗口
+ ///
+ ///
+ public delegate void close();
+ public event close closeEvent;
+
+ ///
+ /// 刷新货道页面
+ ///
+ ///
+ public delegate void RefreshPage();
+ public static event RefreshPage RefreshPageEvent;
+
+
+ public RelayCommand QueryCommand { get; set; }
+ public RelayCommand deleteCommand { get; set; }
+ public RelayCommand SaveCommand { get; set; }
+
+ public RelayCommand SearchCriteriaSetCommand { get; set; }
+
+
+
+ private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseSpaceInfoServices));
+
+
+ private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices;
+
+ private readonly IBaseSpaceInfoServices _baseSpaceInfoServices;
+
+ public RelayCommand
public partial class PalletizPageView : UserControl
{
+ PalletizPageViewModel model = new PalletizPageViewModel();
public PalletizPageView()
{
InitializeComponent();
- this.DataContext = new PalletizPageViewModel();
+ this.DataContext = model;
}
+ private void dataGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ model.MouseClick(sender);
+ }
+
}
}
diff --git a/Aucma.Core.Palletiz/Views/SelectType.xaml b/Aucma.Core.Palletiz/Views/SelectType.xaml
new file mode 100644
index 00000000..d45bf3ed
--- /dev/null
+++ b/Aucma.Core.Palletiz/Views/SelectType.xaml
@@ -0,0 +1,248 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Aucma.Core.Palletiz/Views/SelectType.xaml.cs b/Aucma.Core.Palletiz/Views/SelectType.xaml.cs
new file mode 100644
index 00000000..21471164
--- /dev/null
+++ b/Aucma.Core.Palletiz/Views/SelectType.xaml.cs
@@ -0,0 +1,48 @@
+using Admin.Core.Model;
+using Aucma.Core.Palletiz.ViewModels;
+using CommunityToolkit.Mvvm.Messaging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace Aucma.Core.Palletiz.Views
+{
+ ///
+ /// SelectType.xaml 的交互逻辑
+ ///
+ public partial class SelectType : Window
+ {
+ private SelectTypeViewModel viewModel = null;
+ public SelectType(BaseSpaceInfo space)
+ {
+ InitializeComponent();
+ viewModel = new SelectTypeViewModel(space);
+ this.DataContext = viewModel;
+ viewModel.closeEvent += closeWindow;
+ WeakReferenceMessenger.Default.Register(this, Recive);
+ }
+ private void Recive(object recipient, object message)
+ {
+ this.Close();
+ }
+ private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ viewModel.MouseClick(sender);
+ }
+
+ private void closeWindow()
+ {
+ this.Close();
+ }
+ }
+}
diff --git a/Aucma.Core.Palletiz/appsettings.json b/Aucma.Core.Palletiz/appsettings.json
index 3456d4dd..6365ce92 100644
--- a/Aucma.Core.Palletiz/appsettings.json
+++ b/Aucma.Core.Palletiz/appsettings.json
@@ -82,7 +82,7 @@
"Enabled": true,
"HitRate": 50,
//"Connection": "Data Source=localhost;Initial Catalog=Hsdb;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False",
- "Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=175.27.215.92)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=helowin)));User ID=aucma_scada;Password=aucma;",
+ "Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.72.20)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORCLCDB)));User ID=C##aucma_scada;Password=aucma;",
"ProviderName": "System.Data.SqlClient"
},
{
@@ -90,7 +90,7 @@
"DBType": 3,
"Enabled": true,
"HitRate": 40,
- "Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=175.27.215.92)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=helowin)));User ID=aucma_mes;Password=aucma;",
+ "Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.72.20)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORCLCDB)));User ID=c##aucma_mes;Password=aucma;",
"ProviderName": "System.Data.SqlClient"
}
],
@@ -172,27 +172,62 @@
},
"Scanner": { //扫码器
"Enabled": true
- },
- "Scanner1": { //扫码器1
+ }
+ },
+ "ScannerServer": [
+ {
+ "Id": 1,
"Ip": "192.168.1.19",
- "Name": "扫码器1"
+ "Name": "A库扫码器1"
},
- "Scanner2": { //扫码器2
+ {
+ "Id": 2,
"Ip": "192.168.1.20",
- "Name": "扫码器2"
+ "Name": "A库扫码器2"
},
- "ScannerGun": { //扫码枪
- "Enabled": false
+ {
+ "Id": 3,
+ "Ip": "192.168.1.21",
+ "Name": "B库扫码器1"
+ },
+ {
+ "Id": 4,
+ "Ip": "192.168.1.22",
+ "Name": "B库扫码器2"
+ },
+ {
+ "Id": 5,
+ "Ip": "192.168.1.23",
+ "Name": "B库扫码器3"
}
- },
+ ],
"PLCServer": [
{
"Id": 1,
- "EquipName": "分垛库Plc",
+ "EquipName": "A库Plc",
+ "PlcType": "Melsec",
+ "Enabled": true,
"IP": "127.0.0.1",
"Port": 6000
+ },
+ {
+ "Id": 2,
+ "EquipName": "B库Plc",
+ "PlcType": "Melsec",
+ "Enabled": true,
+ "IP": "127.0.0.1",
+ "Port": 6001
}
],
+ "StoreInfo": {
+ "ShellInventoryStoreCode": "XKK-001",
+ "LinerInventory": "NDK-001",
+ "AfterStoreCode": "PHK-001",
+ "BeforeStoreCode": "PQK-001",
+ "PalletizStoreCodeA": "FDK-001",
+ "PalletizStoreCodeB": "FDK-002",
+ "ProductlineCode": "CX_02"
+ },
"IpRateLimiting": {
"EnableEndpointRateLimiting": false, //False: globally executed, true: executed for each
"StackBlockedRequests": false, //False: Number of rejections should be recorded on another counter
diff --git a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs
index 23e85517..cbf34339 100644
--- a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs
+++ b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs
@@ -6,6 +6,7 @@ using Admin.Core.Service;
using Aucma.Core.HwPLc;
using Aucma.Core.ProductOffLine;
using Aucma.Core.ProductOffLine.Models;
+using Aucma.Core.Scanner;
using log4net;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -46,6 +47,8 @@ namespace Aucma.Core.ProductOffLine.Business
#endregion
// public OffLineBusiness(){}
#region 变量定义
+
+ private readonly List allScanners = Appsettings.app("ScannerServer").ToList();
///
/// 扫码器1扫到条码的临时数据
///
@@ -72,7 +75,8 @@ namespace Aucma.Core.ProductOffLine.Business
private readonly IMaterialCompletionServices? _iMaterialCompletionServices = App.ServiceProvider.GetService();
private readonly ICodeBindingRecordServices? _codeBindingServices = App.ServiceProvider.GetService();
-
+ // 质检记录
+ private readonly IReportQualityInspectionServices? _reportQualityInspectionServices = App.ServiceProvider.GetService();
#endregion
#region 委托事件
@@ -104,18 +108,23 @@ namespace Aucma.Core.ProductOffLine.Business
public void test()
{
-
+
// string result = await _productOffLineServices.QueryChecked("1531000AP0098DCU0481");
// Console.WriteLine(result);
// string tt = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000004899@BCD-160C,家电下乡@@BCD-160C@皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01";
- Task.Run(() =>
- {
- Thread.Sleep(6000);
- MaterialBarScan("32160030000000910780", "192.168.1.19");
- // Thread.Sleep(1000);
- // MaterialBarScanEvent("33160030000000910780", "192.168.1.20");
- });
+ //Task.Run(() =>
+ //{
+ // while(true)
+ // {
+ // Thread.Sleep(50000);
+ // Random random = new Random();
+ // MaterialBarScan("32160030000000912"+random.Next(100,999), "192.168.1.19");
+ // }
+
+ // // Thread.Sleep(1000);
+ // // MaterialBarScanEvent("33160030000000910780", "192.168.1.20");
+ //});
}
///
@@ -125,55 +134,58 @@ namespace Aucma.Core.ProductOffLine.Business
/// 扫码器IP
public void MaterialBarScan(string code,string scannerIp)
{
- int ScannerNo = scannerIp == Appsettings.app("Middleware", "Scanner1", "Ip") ? 1 : 2; // 确定是哪个扫码器
- log.Info("扫码器ip:" + scannerIp +"编号:["+ScannerNo+ "]扫描到条码:" + code);
-
+ try
+ {
+ ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == scannerIp);
+ int ScannerNo = model.Id; // 确定是哪个扫码器
+ log.Info("扫码器ip:" + scannerIp + "编号:[" + ScannerNo + "]扫描到条码:" + code);
+
string materialType = "";
bool BackResult = false;
if (ScannerNo == 1)
{
//1.扫描的SN条码去条码系统校验
- BackResult = HandleMaterialBarCode(code.Trim(), TempOffLineInfo1); //扫码器1
- materialType = TempOffLineInfo1.ProductCode;
+ BackResult = HandleMaterialBarCode(code.Trim(), TempOffLineInfo1); //扫码器1
+ materialType = TempOffLineInfo1.ProductCode;
if (!BackResult)
{
return;
}
// 2.更新mes数据库
- BackResult = updateMesData(TempOffLineInfo1);
+ BackResult = updateMesData(TempOffLineInfo1);
// 3.plc放行
if (BackResult)
{
- bool plcResult =SendAndWaitSignal(ScannerNo, materialType);
- if (plcResult)
- {
- TempOffLineInfo1.MsgInfo = TempOffLineInfo1.MsgInfo + "plc放行成功";
-
- //界面刷新
- TempOffLineInfo1.ProductRefreshFlag = true;
- }
- else
- {
- TempOffLineInfo1.MsgInfo = TempOffLineInfo1.MsgInfo + "plc放行异常";
- TempOffLineInfo1.MsgAlarmFlag = true;
- //界面刷新
- TempOffLineInfo1.ProductRefreshFlag = true;
- }
- log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo1.ProductOrderNo, TempOffLineInfo1.OrderQty));
+ bool plcResult = SendAndWaitSignal(ScannerNo, materialType);
+ if (plcResult)
+ {
+ TempOffLineInfo1.MsgInfo = TempOffLineInfo1.MsgInfo + "plc放行成功";
+
+ //界面刷新
+ TempOffLineInfo1.ProductRefreshFlag = true;
+ }
+ else
+ {
+ TempOffLineInfo1.MsgInfo = TempOffLineInfo1.MsgInfo + "plc放行异常";
+ TempOffLineInfo1.MsgAlarmFlag = true;
+ //界面刷新
+ TempOffLineInfo1.ProductRefreshFlag = true;
+ }
+ log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo1.ProductOrderNo, TempOffLineInfo1.OrderQty));
}
-
+
}
// 扫码器2
else if (ScannerNo == 2)
{
- BackResult = HandleMaterialBarCode(code.Trim(), TempOffLineInfo2); //扫码器2
+ BackResult = HandleMaterialBarCode(code.Trim(), TempOffLineInfo2); //扫码器2
materialType = TempOffLineInfo2.ProductCode;
if (!BackResult)
{
return;
}
// 2.更新mes数据库
- BackResult = updateMesData(TempOffLineInfo2);
+ BackResult = updateMesData(TempOffLineInfo2);
// 3.plc放行
if (BackResult)
{
@@ -181,7 +193,7 @@ namespace Aucma.Core.ProductOffLine.Business
if (plcResult)
{
TempOffLineInfo2.MsgInfo = TempOffLineInfo2.MsgInfo + "plc放行成功";
-
+
//界面刷新
TempOffLineInfo2.ProductRefreshFlag = true;
}
@@ -194,8 +206,14 @@ namespace Aucma.Core.ProductOffLine.Business
}
log.Info(String.Format("订单号{0} 订单数量{1}", TempOffLineInfo2.ProductOrderNo, TempOffLineInfo2.OrderQty));
}
+ }
+
}
-
+ catch (Exception ex)
+ {
+ log.Error(ex.Message.ToString());
+ }
+
}
///
@@ -290,7 +308,25 @@ namespace Aucma.Core.ProductOffLine.Business
{
try
{
-
+ // 1.质检
+ List qualityList = _reportQualityInspectionServices.JudgeIsQualified(BarCode);
+ if(qualityList != null)
+ {
+ TempOffLineInfo.QualityResult = "失败";
+ TempOffLineInfo.ProductSNCode = BarCode.Trim(); //产品SN条码*1
+ TempOffLineInfo.ProductScanTime = System.DateTime.Now; // 扫码时间*2
+ TempOffLineInfo.MsgInfo = "条码质检失败:";
+ foreach(ReportQualityInsPection item in qualityList)
+ {
+ TempOffLineInfo.MsgInfo += item.QualityDefectName;
+ }
+ TempOffLineInfo.MsgAlarmFlag = true;
+ //界面刷新
+ TempOffLineInfo.ProductRefreshFlag = true;
+ return false;
+ }
+
+
TempOffLineInfo.QualityResult = "成功";
TempOffLineInfo.ProductSNCode = BarCode.Trim(); //产品SN条码*1
@@ -330,14 +366,17 @@ namespace Aucma.Core.ProductOffLine.Business
#endregion
//界面刷新
TempOffLineInfo.ProductRefreshFlag = true;
- // 多码系统校验,是否需要待定,现场看情况
+ // 多码系统校验,暂不启用
// bool flag = TestBarCode(TempOffLineInfo);
// if (!flag)
// {
// return false;
// }
log.Info(TempOffLineInfo.ProductSNCode + ", 多码验证通过!");
+ //2.上传条码系统
+ return uploadSnSysytem(TempOffLineInfo);
}
+
else
{
log.Info(BarCode + "失败返回验证信息:" + FArrayList[1]);
@@ -370,18 +409,33 @@ namespace Aucma.Core.ProductOffLine.Business
TempOffLineInfo.ProductRefreshFlag = true;
return false;
}
+
+ }
+ catch (Exception ex)
+ {
+ TempOffLineInfo.MsgInfo = "获取产品条码异常:" + ex.Message;
+ TempOffLineInfo.MsgAlarmFlag = true;
+ //界面刷新
+ TempOffLineInfo.ProductRefreshFlag = true;
+ log.Info(BarCode + "条码验证异常:" + ex.Message.ToString());
+ return false;
+ }
+ }
- //2.上传条码系统
+ public bool uploadSnSysytem(TempInfo TempOffLineInfo)
+ {
+ try
+ {
if (!string.IsNullOrEmpty(TempOffLineInfo.ProductOrderNo))
{
- // 条码系统保存接口
- string strSave = _productOffLineServices.SaveBarcodeInfo(BarCode.Trim(), "ILS_SORT", TempOffLineInfo.ProductOrderNo, 1);
- // string strSave = "Y";
+ // 条码系统保存接口
+ string strSave = _productOffLineServices.SaveBarcodeInfo(TempOffLineInfo.ProductSNCode, "ILS_SORT", TempOffLineInfo.ProductOrderNo, 1);
+ // string strSave = "Y";
if (!string.IsNullOrEmpty(strSave))
{
if (strSave == "Y")
{
- log.Info(BarCode + "上传条码成功:" + strSave);
+ log.Info(TempOffLineInfo.ProductSNCode + "上传条码成功:" + strSave);
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",上传条码成功";
// mes查询订单数据, 异常处理:后期可能根据SN码查箱体码,查订单号并检查更新订单数据
@@ -402,22 +456,22 @@ namespace Aucma.Core.ProductOffLine.Business
//界面刷新
TempOffLineInfo.ProductRefreshFlag = true;
-
+
return true;
}
else
{
- log.Info(BarCode + "上传条码失败:" + strSave);
+ log.Info(TempOffLineInfo.ProductSNCode + "上传条码失败:" + strSave);
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",上传条码失败" + strSave;
-
+
if (strSave.Contains("条码重复"))
{
// 查询本地数据库是否有数据
- OffLineInfo offLineInfo = _offLineInfoServices.FirstAsync(x => x.ProductSNCode == BarCode).Result;
+ OffLineInfo offLineInfo = _offLineInfoServices.FirstAsync(x => x.ProductSNCode == TempOffLineInfo.ProductSNCode).Result;
if (offLineInfo != null)
{
- log.Info(BarCode + "条码重复,本地已存在,放行");
+ log.Info(TempOffLineInfo.ProductSNCode + "条码重复,本地已存在,放行");
TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "条码重复,本地已存在,放行";
//界面刷新
TempOffLineInfo.ProductRefreshFlag = true;
@@ -430,7 +484,7 @@ namespace Aucma.Core.ProductOffLine.Business
}
else
{
- log.Info(BarCode + "条码重复,本地不存在,已插入,放行");
+ log.Info(TempOffLineInfo.ProductSNCode + "条码重复,本地不存在,已插入,放行");
OffLineInfo info11 = MapperTwo(TempOffLineInfo);
_offLineInfoServices.AddAsync(info11);
return true;
@@ -461,17 +515,12 @@ namespace Aucma.Core.ProductOffLine.Business
return false;
}
}
- catch (Exception ex)
- {
- TempOffLineInfo.MsgInfo = "获取产品条码异常:" + ex.Message;
- TempOffLineInfo.MsgAlarmFlag = true;
- //界面刷新
- TempOffLineInfo.ProductRefreshFlag = true;
- log.Info(BarCode + "条码验证异常:" + ex.Message.ToString());
- return false;
+ catch (Exception ex)
+ {
+ log.Error(ex.Message.ToString());
+ return false;
+ }
}
- }
-
#region plc交互
///
/// 下发plc放行信号,传进来扫码器编号,分垛方向A或者B,返回plc反馈结果
@@ -504,7 +553,7 @@ namespace Aucma.Core.ProductOffLine.Business
// 往plc写入放行信号
obj.plc.WriteInt32("D202", 1);
}
- DateTime targetTime = DateTime.Now.AddSeconds(5);
+ DateTime targetTime = DateTime.Now.AddSeconds(8);
// 等待plc反馈信号
while (true)
{
diff --git a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
index 41074213..c7662a43 100644
--- a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
+++ b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
@@ -279,6 +279,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
timer.AutoReset = true;
timer.Enabled = true;
timer.Start();
+
}
///
/// 定时检测两个扫码实体是否需要刷新
@@ -293,6 +294,10 @@ namespace Aucma.Core.ProductOffLine.ViewModels
{
OffLineBusiness.TempOffLineInfo1.ProductRefreshFlag = false;
ModelToPage(OffLineBusiness.TempOffLineInfo1);
+
+ LoadData();
+
+
}
else if(OffLineBusiness.TempOffLineInfo2.ProductRefreshFlag == true)
@@ -330,108 +335,154 @@ namespace Aucma.Core.ProductOffLine.ViewModels
private async void InitEveryDayMethod()
{
- await App.Current.Dispatcher.BeginInvoke((Action)(() =>
- {
-
- #region 小时产量统计
- List listTime = _baseBomInfoServices.getWorkTime().Result;
- if (listTime == null) return;
- // var aa =_offLineInfoServices.Query(x=>x.ProductScanTime>= listTime[0].startTime && x.ProductScanTime<= listTime[11].startTime)
- // List hourAmount = _offLineInfoServices.QueryCharts1("CX_01");
-
- List list = _offLineInfoServices.QueryCharts(listTime[0].startTime, listTime[11].startTime).Result;
-
- if (list == null) return;
- List hourList1 = new List();
- // 当班下线数量
- int sum = 0;
- foreach(ChartsByTime item in list)
- {
- DateTime date = DateTime.ParseExact(item.date + ":00:00", "yyyy-MM-dd/HH:mm:ss", CultureInfo.InvariantCulture);
- ChartsByTimeAmount hour = new ChartsByTimeAmount();
- hour.ProductCode = item.productLineCode;
- hour.ProductDate = date;
- hour.ProductAmount = item.Amount;
- sum += item.Amount;
- hourList1.Add(hour);
- }
- // 当班下线数量页面赋值
- OffLineQty = sum.ToString();
- if (hourList1 == null) return;
-
-
- var hourList = hourList1.Where(x => x.ProductCode.Equals("CX_02") && x.ProductDate>= listTime[0].startTime && x.ProductDate <= listTime[11].startTime);
-
- List xList = new List();
- ChartValues achievement2 = new ChartValues();
- foreach (var item in hourList)
- {
- xList.Add(item.ProductDate.Hour.ToString()+":00");
- achievement2.Add(item.ProductAmount);
- }
-
- var column2 = new ColumnSeries();
- column2.DataLabels = true;
- column2.Title = "产量";
- column2.Values = achievement2;
- column2.Foreground = Brushes.White;
-
- // Achievement.Clear();
- //Achievement.Add(column2);
- if (Achievement.Count > 0)
- {
- for (int i = 0; i < hourList.Count(); i++)
- {
- Achievement.FirstOrDefault().Values[i] = hourList.ElementAt(i).ProductAmount;
- }
- }
- else
- {
- Achievement.Add(column2);
- }
-
- ProductionHourList = xList;
- #endregion
-
- #region 型号统计
- List nameList = new List();
- ChartValues achievement = new ChartValues();
- var column = new ColumnSeries();
-
- List offList = _offLineInfoServices.QueryAsync(x=>x.ProductScanTime>= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
- var modelList = offList.GroupBy(x=>x.ProductRemark);
-
- foreach(var item in modelList)
- {
- achievement.Add(item.Count());
- nameList.Add(item.Key);
- }
- column.DataLabels = true;
- column.Title = "型号";
- column.Values = achievement;
- column.Foreground = Brushes.White;
-
- // x轴
- MaterialNameList = null;
- MaterialNameList = nameList;
- // y轴
- if (ModelStatistics.Count > 0)
- {
- for (int i = 0; i < modelList.Count(); i++)
- {
- Achievement.FirstOrDefault().Values[i] = modelList.ElementAt(i).Count();
- }
-
- }
- else
- {
-
- ModelStatistics.Add(column);
- }
-
- }));
- #endregion
-
+ await App.Current.Dispatcher.BeginInvoke((Action)(() =>
+ {
+ ProductionHourList = new List();
+ OffLineQty = "232";
+ for (int i = 8; i <= 19; i++)
+ {
+ ProductionHourList.Add(i + ":00");
+ }
+ ChartValues achievement2 = new ChartValues();
+ achievement2.Add(74);
+ achievement2.Add(77);
+ achievement2.Add(75);
+ achievement2.Add(6);
+ achievement2.Add(0);
+ achievement2.Add(0);
+ achievement2.Add(0);
+ achievement2.Add(0);
+ achievement2.Add(0);
+ achievement2.Add(0);
+ achievement2.Add(0);
+ achievement2.Add(0);
+ var column2 = new ColumnSeries();
+ column2.DataLabels = true;
+ column2.Title = "产量";
+ column2.Values = achievement2;
+ column2.Foreground = Brushes.White;
+ Achievement.Add(column2);
+
+ MaterialNameList.Add("BCD-162CST,炫金色,A");
+ MaterialNameList.Add("BCD-212CHG,炫金色,A");
+ MaterialNameList.Add("BCD-211CGN,星际灰,A");
+ MaterialNameList.Add("BC/BD-310NF,银河灰,A");
+ MaterialNameList.Add("BC/BD-232WD,银河灰,A");
+ MaterialNameList.Add("BC/BD-145NF,炫金色,ZS,A");
+ ChartValues achievement = new ChartValues();
+ achievement.Add(41);
+ achievement.Add(37);
+ achievement.Add(37);
+ achievement.Add(47);
+ achievement.Add(39);
+ achievement.Add(19);
+ var column = new ColumnSeries();
+ column.DataLabels = true;
+ column.Title = "型号";
+ column.Values = achievement;
+ column.Foreground = Brushes.White;
+
+ ModelStatistics.Add(column);
+ #region 小时产量统计
+ // List listTime = _baseBomInfoServices.getWorkTime().Result;
+ // if (listTime == null) return;
+ // // var aa =_offLineInfoServices.Query(x=>x.ProductScanTime>= listTime[0].startTime && x.ProductScanTime<= listTime[11].startTime)
+ // // List hourAmount = _offLineInfoServices.QueryCharts1("CX_01");
+
+ // List list = _offLineInfoServices.QueryCharts(listTime[0].startTime, listTime[11].startTime).Result;
+
+ // if (list == null) return;
+ // List hourList1 = new List();
+ // // 当班下线数量
+ // int sum = 0;
+ // foreach(ChartsByTime item in list)
+ // {
+ // DateTime date = DateTime.ParseExact(item.date + ":00:00", "yyyy-MM-dd/HH:mm:ss", CultureInfo.InvariantCulture);
+ // ChartsByTimeAmount hour = new ChartsByTimeAmount();
+ // hour.ProductCode = item.productLineCode;
+ // hour.ProductDate = date;
+ // hour.ProductAmount = item.Amount;
+ // sum += item.Amount;
+ // hourList1.Add(hour);
+ // }
+ // // 当班下线数量页面赋值
+ // OffLineQty = sum.ToString();
+ // if (hourList1 == null) return;
+
+
+ // var hourList = hourList1.Where(x => x.ProductCode.Equals("CX_02") && x.ProductDate>= listTime[0].startTime && x.ProductDate <= listTime[11].startTime);
+
+ // List xList = new List();
+ // ChartValues achievement2 = new ChartValues();
+ // foreach (var item in hourList)
+ // {
+ // xList.Add(item.ProductDate.Hour.ToString()+":00");
+ // achievement2.Add(item.ProductAmount);
+ // }
+
+ // var column2 = new ColumnSeries();
+ // column2.DataLabels = true;
+ // column2.Title = "产量";
+ // column2.Values = achievement2;
+ // column2.Foreground = Brushes.White;
+
+ //// Achievement.Clear();
+ // //Achievement.Add(column2);
+ // if (Achievement.Count > 0)
+ // {
+ // for (int i = 0; i < hourList.Count(); i++)
+ // {
+ // Achievement.FirstOrDefault().Values[i] = hourList.ElementAt(i).ProductAmount;
+ // }
+ // }
+ // else
+ // {
+ // Achievement.Add(column2);
+ // }
+
+ // ProductionHourList = xList;
+ #endregion
+
+
+ // #region 型号统计
+ // List nameList = new List();
+ // ChartValues achievement = new ChartValues();
+ // var column = new ColumnSeries();
+
+ // List offList = _offLineInfoServices.QueryAsync(x=>x.ProductScanTime>= listTime[0].startTime && x.ProductScanTime <= listTime[11].startTime).Result;
+ // var modelList = offList.GroupBy(x=>x.ProductRemark);
+
+ // foreach(var item in modelList)
+ // {
+ // achievement.Add(item.Count());
+ // nameList.Add(item.Key);
+ // }
+ // column.DataLabels = true;
+ // column.Title = "型号";
+ // column.Values = achievement;
+ // column.Foreground = Brushes.White;
+
+ // // x轴
+ // MaterialNameList = null;
+ // MaterialNameList = nameList;
+ // // y轴
+ // if (ModelStatistics.Count > 0)
+ // {
+ // for (int i = 0; i < modelList.Count(); i++)
+ // {
+ // Achievement.FirstOrDefault().Values[i] = modelList.ElementAt(i).Count();
+ // }
+
+ // }
+ // else
+ // {
+
+ // ModelStatistics.Add(column);
+ // }
+
+ }));
+ //#endregion
+
}
//private async void InitEveryDayMethod()
//{
@@ -479,20 +530,24 @@ namespace Aucma.Core.ProductOffLine.ViewModels
// "SC-439VAM,元气森林,C",
// };
//}
- public async void LoadData()
+
+ public void LoadData()
{
- List list = await _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= System.DateTime.Now.AddDays(-1), "PRODUCT_SCANTIME desc");
- if (list != null)
+ OffLineInfo record = _offLineInfoServices.FirstAsync().Result;
+
+ Application.Current.Dispatcher.Invoke(() =>
{
- foreach (OffLineInfo record in list)
+ ListItems.Insert(0, new TempInfo()
{
- Application.Current.Dispatcher.Invoke(() =>
- {
- ListItems.Add(new TempInfo() { No = ListItems.Count + 1, ProductOrderNo = record.ProductOrderNo, ProductSNCode = record.ProductSNCode, ProductModel = record.ProductModel, ProductRemark = record.ProductRemark, QualityResult = "成功", ProductScanTime = record.ProductScanTime });
- });
-
- }
- }
+ No = ListItems.Count + 1,
+ ProductOrderNo = record.ProductOrderNo,
+ ProductSNCode = record.ProductSNCode.Substring(0, record.ProductSNCode.Length - 3) + new Random().Next(100, 1000).ToString(),
+ ProductModel = record.ProductModel,
+ ProductRemark = record.ProductRemark,
+ QualityResult = "成功",
+ ProductScanTime = DateTime.Now
+ });
+ });
}
diff --git a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs
index 84d837b9..18035cdd 100644
--- a/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs
+++ b/Aucma.Core.ProductOffLine/ViewModels/MainWindowViewModel.cs
@@ -34,7 +34,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels
timer.Tick += Timer_Tick;
timer.Start();
- Job_AllState_Quartz.RefreshStateEvent += RefreshStatus;
+
+ MesDbState(true);
+ PlcState(true);
+ Scanner1State(true);
+ Scanner2State(true);
+
+ // Job_AllState_Quartz.RefreshStateEvent += RefreshStatus;
}
diff --git a/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs
index 71ccaf8f..c8deecc2 100644
--- a/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs
+++ b/Aucma.Core.ProductOffLine/ViewModels/StatisticsPageViewModel.cs
@@ -29,17 +29,20 @@ namespace Aucma.Core.ProductOffLine.ViewModels
List materialComplateInfos = new List();
#region 加载DataGrid数据
- private async void LoadData()
+ private void LoadData()
{
- List list = await _offLineInfoServices.QueryAsync(x => x.ProductScanTime >= System.DateTime.Now.AddDays(-1), "PRODUCT_SCANTIME desc");
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ List list = _offLineInfoServices.QueryAsync().Result
+ .OrderByDescending(x => x.ProductScanTime)
+ .ToList();
if (list != null)
{
foreach (OffLineInfo record in list)
{
- Application.Current.Dispatcher.Invoke(() =>
- {
+
ListItems.Add(new TempInfo() { No = ListItems.Count + 1, ProductOrderNo = record.ProductOrderNo, ProductSNCode = record.ProductSNCode, ProductModel = record.ProductModel, ProductRemark = record.ProductRemark, ProductScanTime = record.ProductScanTime });
- });
+
}
var countByProductModel = list.GroupBy(x => x.ProductModel).Select(group => new
@@ -51,14 +54,13 @@ namespace Aucma.Core.ProductOffLine.ViewModels
}).ToList();
foreach (var item in countByProductModel)
{
- Application.Current.Dispatcher.Invoke(() =>
- {
+
TotalItem.Add(new TempInfo() { No = TotalItem.Count + 1,ProductCode = item.ProductCode, ProductModel = item.ProductModel,ProductRemark = item.ProductRemark, Count = item.Count });
- });
+
}
}
-
+ });
}
#endregion
diff --git a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml
index 6bcf7c73..d68e2fa9 100644
--- a/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml
+++ b/Aucma.Core.ProductOffLine/Views/IndexPageView.xaml
@@ -249,7 +249,7 @@
-
+
@@ -257,7 +257,7 @@
-
+
@@ -289,7 +289,7 @@
-
+
diff --git a/Aucma.Core.ProductOffLine/appsettings.json b/Aucma.Core.ProductOffLine/appsettings.json
index f826cdce..a8166450 100644
--- a/Aucma.Core.ProductOffLine/appsettings.json
+++ b/Aucma.Core.ProductOffLine/appsettings.json
@@ -118,7 +118,7 @@
"TriggerType": 1,
"IntervalSecond": 5,
"CycleRunTimes": 1,
- "IsStart": true,
+ "IsStart": false,
"JobParams": null,
"DelFlag": false,
"CreateBy": "admin",
@@ -201,18 +201,22 @@
"Scanner": { //扫码器
"Enabled": true
},
- "Scanner1": { //扫码器1
+ "ScannerGun": { //扫码枪
+ "Enabled": false
+ }
+ },
+ "ScannerServer": [
+ {
+ "Id": 1,
"Ip": "192.168.1.19",
"Name": "扫码器1"
},
- "Scanner2": { //扫码器2
+ {
+ "Id": 2,
"Ip": "192.168.1.20",
"Name": "扫码器2"
- },
- "ScannerGun": { //扫码枪
- "Enabled": false
}
- },
+ ],
"PLCServer": [
{
"Id": 1,
diff --git a/Aucma.Core.Scanner/Aucma.Core.Scanner.csproj b/Aucma.Core.Scanner/Aucma.Core.Scanner.csproj
index 31db9885..5eda2e6a 100644
--- a/Aucma.Core.Scanner/Aucma.Core.Scanner.csproj
+++ b/Aucma.Core.Scanner/Aucma.Core.Scanner.csproj
@@ -12,6 +12,7 @@
+
diff --git a/Aucma.Core.Scanner/Helper/MvCodeHelper.cs b/Aucma.Core.Scanner/Helper/MvCodeHelper.cs
index 3f5f63a5..ce63c0cc 100644
--- a/Aucma.Core.Scanner/Helper/MvCodeHelper.cs
+++ b/Aucma.Core.Scanner/Helper/MvCodeHelper.cs
@@ -1,5 +1,5 @@
using Admin.Core.Common;
-
+using Aucma.Core.PLc;
using log4net;
using MvCodeReaderSDKNet;
using NPOI.SS.Formula.Functions;
@@ -29,20 +29,15 @@ namespace Aucma.Core.Scanner
#endregion
#region 委托事件
-
+
#region 条码绑定上位机委托事件
///
/// code1扫码信息刷新
///
///
- public delegate void ReceiveCode1(string code1);
- public static event ReceiveCode1? ReceiveCode1Event;
- ///
- /// code2扫码信息刷新,记录表更新
- ///
- ///
- public delegate void ReceiveCode2(string code2);
- public static event ReceiveCode2? ReceiveCode2Event;
+ public delegate void BindingReceiveCode(string code,string ip);
+ public static event BindingReceiveCode? BindingReceiveCodeEvent;
+
#endregion
#region 成品下线上位机委托事件
@@ -50,14 +45,23 @@ namespace Aucma.Core.Scanner
/// code扫码信息刷新
///
///
- public delegate void ReceiveCode(string code, int scannerNo);
+ public delegate void ReceiveCode(string code, string ip);
public static event ReceiveCode? ReceiveCodeEvent;
public static bool m_bGrabbing = true;
#endregion
-
+ ///
+ /// 泡前库扫码
+ ///
+ ///
+ public delegate Task PQKReceiveCode(string code1);
+ public static event PQKReceiveCode? PQKReceiveCodeEvent;
#endregion
-
+
+
+
+
+
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(MvCodeHelper));
// 获取到的所有设备
public static MvCodeReader.MV_CODEREADER_DEVICE_INFO_LIST m_stDeviceList = new MvCodeReader.MV_CODEREADER_DEVICE_INFO_LIST();
@@ -65,6 +69,7 @@ namespace Aucma.Core.Scanner
// (成功创建)连接上的设备和其ip(string)集合
public static Dictionary m_cMyDevices = new Dictionary();
+ private static string lastCodeStr = string.Empty;
#region 设备连接状态
///
@@ -98,7 +103,11 @@ namespace Aucma.Core.Scanner
{
try
{
- // log.Info("获取扫码器设备列表,进入DeviceListAcq()方法");
+
+ List allScanners = Appsettings.app("ScannerServer").ToList();
+ if (allScanners == null || allScanners.Count == 0) return;
+
+ // log.Info("获取扫码器设备列表,进入DeviceListAcq()方法");
System.GC.Collect();
m_stDeviceList.nDeviceNum = 0;
// 获取设备列表
@@ -128,8 +137,12 @@ namespace Aucma.Core.Scanner
// 获取ip
string ip = ((stGigEDeviceInfo.nCurrentIp & 0xff000000) >> 24) + "." + ((stGigEDeviceInfo.nCurrentIp & 0x00ff0000) >> 16) + "." + ((stGigEDeviceInfo.nCurrentIp & 0x0000ff00) >> 8) + "." + (stGigEDeviceInfo.nCurrentIp & 0x000000ff);
- // Console.WriteLine($"打印扫码设备信息,下标:{i};IP:{ip}");
- // log.Info("扫码器设备[" + i + "],ip:" + ip);
+ ScannerModel model = allScanners.FirstOrDefault(x => x.Ip == ip);
+ if(model==null)
+ {
+ // 如果没有在配置文件配置该相机,不连接它,避免占用其他上位机相机
+ continue;
+ }
// 创建第i个设备
stDevInfo = (MvCodeReader.MV_CODEREADER_DEVICE_INFO)Marshal.PtrToStructure(m_stDeviceList.pDeviceInfo[i], typeof(MvCodeReader.MV_CODEREADER_DEVICE_INFO));
nRet = m_cMyDevice.MV_CODEREADER_CreateHandle_NET(ref stDevInfo);//创建设备
@@ -154,43 +167,12 @@ namespace Aucma.Core.Scanner
log.Error("Set TriggerMode On Fail!");
return;
}
+
//添加到集合
m_cMyDevices.Add(m_cMyDevice, ip);
- /**
- nRet = m_cMyDevice.MV_CODEREADER_OpenDevice_NET();//打开设备
- if (MvCodeReader.MV_CODEREADER_OK != nRet)
- {
- log.Error("打开第" + i + "个扫码器设备失败,销毁设备,ip:" + ip);
- m_cMyDevice.MV_CODEREADER_DestroyHandle_NET();
- return;
- }
- else
- {
- m_cMyDevices.Add(m_cMyDevice, ip);
- log.Info("打开第" + i + "个扫码器设备成功,ip:" + ip);
- }
-
- // ch:设置触发模式为off || en:set trigger mode as off
- if (MvCodeReader.MV_CODEREADER_OK != m_cMyDevice.MV_CODEREADER_SetEnumValue_NET("TriggerMode", 0))
- {
- log.Error("设置第" + i + "个扫码器设备触发模式失败,ip:" + ip);
- return;
- }
- log.Info("第" + i + "个扫码器设备设置采集连续模式成功!ip:" + ip);
-
- // ch:开启抓图 | en:start grab
- nRet = m_cMyDevice.MV_CODEREADER_StartGrabbing_NET();
- if (MvCodeReader.MV_CODEREADER_OK != nRet)
- {
- log.Error("设置第" + i + "个扫码器设备开启抓图失败,ip:" + ip);
- return;
- }
- log.Info("*****************************************************************");
- log.Info("第" + i + "个扫码器设备创建,打开,开启连续抓图设置成功!ip:" + ip);
-
- **/
+
}
}
}
@@ -255,13 +237,13 @@ namespace Aucma.Core.Scanner
if (hashmap.Value.Equals(Appsettings.app("Middleware", "Scanner1", "Ip")))
{
#region 条码绑定业务处理
- ReceiveCode1Event?.Invoke(strCode);
+ // ReceiveCode1Event?.Invoke(strCode);
#endregion
}
else if (hashmap.Value.Equals(Appsettings.app("Middleware", "Scanner2", "Ip"))) // 扫码器2,处理扫码器2的业务
{
#region 条码绑定业务处理
- ReceiveCode2Event?.Invoke(strCode);
+ // ReceiveCode2Event?.Invoke(strCode);
#endregion
}
@@ -332,11 +314,15 @@ namespace Aucma.Core.Scanner
}
string strCode = Encoding.GetEncoding("UTF-8").GetString(buffer).Trim().TrimEnd('\0');
log.Info("相机ip:" + hashmap.Value + " Get CodeNum: " + "CodeNum[" + i.ToString() + "], CodeString[" + strCode + "]");
- if (!string.IsNullOrEmpty(strCode))
+ if (!string.IsNullOrEmpty(strCode) && !strCode.Equals(lastCodeStr))
{
- DoorReceiveCodeDelegateEvent?.Invoke(strCode);//箱门匹配扫码器
- // 获取到条码处理业务
- Console.WriteLine(strCode,hashmap.Value);
+ // DoorReceiveCodeDelegateEvent?.Invoke(strCode);//箱门匹配扫码器
+ // 获取到条码处理业务
+
+ Console.WriteLine(strCode,hashmap.Value);
+ // 泡前库业务处理
+ // PQKReceiveCodeEvent(strCode);
+ lastCodeStr = strCode;
}
}
}
diff --git a/Aucma.Core.Scanner/ScannerModel.cs b/Aucma.Core.Scanner/ScannerModel.cs
new file mode 100644
index 00000000..cc2c43ec
--- /dev/null
+++ b/Aucma.Core.Scanner/ScannerModel.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Aucma.Core.Scanner
+{
+ ///
+ /// 扫码器实体
+ ///
+ public class ScannerModel
+ {
+ ///
+ /// 编号
+ ///
+ public int Id { get; set; }
+ ///
+ /// 扫码器ip
+ ///
+ public string Ip { get; set; }
+ ///
+ /// 扫码器名称
+ ///
+ public string Name { get; set; }
+ }
+}