diff --git a/Admin.Core.IService/IService_New/IProductOffLineServices.cs b/Admin.Core.IService/IService_New/IProductOffLineServices.cs
new file mode 100644
index 00000000..9fb39351
--- /dev/null
+++ b/Admin.Core.IService/IService_New/IProductOffLineServices.cs
@@ -0,0 +1,27 @@
+using Admin.Core.IService;
+using Admin.Core.Model;
+using Admin.Core.Model.Model_New;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Admin.Core.IService
+{
+ ///
+ /// 成品下线
+ ///
+ public interface IProductOffLineServices : IBaseServices
+ {
+
+ ///
+ /// 条码系统获取校验字符串
+ ///
+ public Task QueryChecked(string barCode);
+
+ ///
+ /// 条码系统入库接口
+ ///
+ public Task SaveBarcodeInfo();
+
+
+ }
+}
\ No newline at end of file
diff --git a/Admin.Core.Model/Model_New/BaseTest.cs b/Admin.Core.Model/Model_New/BaseTest.cs
new file mode 100644
index 00000000..c64495ec
--- /dev/null
+++ b/Admin.Core.Model/Model_New/BaseTest.cs
@@ -0,0 +1,21 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Admin.Core.Model.Model_New
+{
+
+ [SugarTable("BaseTest", "AUCMA_TIAOMA")]
+ public class BaseTest
+ {
+ ///
+ /// 接收从条码系统获取的校验字符串
+ ///
+ public string result { get; set; }
+
+
+ }
+}
diff --git a/Admin.Core.Repository/BASE/BaseRepository.cs b/Admin.Core.Repository/BASE/BaseRepository.cs
index 696bb4c0..84a38851 100644
--- a/Admin.Core.Repository/BASE/BaseRepository.cs
+++ b/Admin.Core.Repository/BASE/BaseRepository.cs
@@ -57,6 +57,11 @@ namespace Admin.Core.Repository
#region 异步方法
+ //public ISqlSugarClient GetDb(string configID)
+ //{
+ // return _dbBase.ChangeDatabase(configID);
+ //}
+
public async Task QueryByIdAsync(object objId)
{
//return await Task.Run(() => _db.Queryable().InSingle(objId));
diff --git a/Admin.Core.Service/BASE/BaseServices.cs b/Admin.Core.Service/BASE/BaseServices.cs
index f213de61..dc45fd6a 100644
--- a/Admin.Core.Service/BASE/BaseServices.cs
+++ b/Admin.Core.Service/BASE/BaseServices.cs
@@ -1,6 +1,7 @@
using Admin.Core.IRepository;
using Admin.Core.IService;
using Admin.Core.Model;
+using Admin.Core.Model.Model_New;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -12,6 +13,7 @@ namespace Admin.Core.Service
{
public class BaseServices : IBaseServices where TEntity : class, new()
{
+
//public IBaseRepository baseDal = new BaseRepository();
public IBaseRepository BaseDal { get; set; }//通过在子类的构造函数中注入,这里是基类,不用构造函数
diff --git a/Admin.Core.Service/Service_New/BaseOrderInfoServices.cs b/Admin.Core.Service/Service_New/BaseOrderInfoServices.cs
index 056de7d1..7aecfd8b 100644
--- a/Admin.Core.Service/Service_New/BaseOrderInfoServices.cs
+++ b/Admin.Core.Service/Service_New/BaseOrderInfoServices.cs
@@ -4,10 +4,13 @@ using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using Admin.Core.Model.ViewModels;
+using Microsoft.Extensions.Hosting;
using NPOI.SS.Formula.Functions;
using StackExchange.Redis;
+using System;
using System.Collections;
using System.Collections.Generic;
+using System.Data;
using System.Linq;
using System.Reflection.Emit;
using System.Threading.Tasks;
@@ -22,16 +25,20 @@ namespace Admin.Core.Service
private readonly IOrderBomInfoRepository _orderBomInfoRepository;
//private readonly IBaseBomInfoRepository _baseBomInfoRepository;
+ private readonly IBaseRepository baseRepository;
+
List bbinfolist = new List();
public BaseOrderInfoServices(IBaseRepository dal, IPrintOrderInfoRepository printOrderInfoRepository,
- IOrderBomInfoRepository orderBomInfoRepository, IBaseOrderInfoRepository baseOrderInfoRepository)
+ IOrderBomInfoRepository orderBomInfoRepository, IBaseOrderInfoRepository baseOrderInfoRepository, IBaseRepository baseRepository)
{
this._dal = dal;
base.BaseDal = dal;
_orderBomInfoRepository = orderBomInfoRepository;
_printOrderInfoRepository = printOrderInfoRepository;
_baseOrderInfoRepository = baseOrderInfoRepository;
+ this.baseRepository = baseRepository;
+
}
///
@@ -216,4 +223,6 @@ namespace Admin.Core.Service
}
-}
\ No newline at end of file
+}
+
+
diff --git a/Admin.Core.Service/Service_New/ProductOffLineServices.cs b/Admin.Core.Service/Service_New/ProductOffLineServices.cs
new file mode 100644
index 00000000..eb004c10
--- /dev/null
+++ b/Admin.Core.Service/Service_New/ProductOffLineServices.cs
@@ -0,0 +1,67 @@
+using Admin.Core.IRepository;
+using Admin.Core.IService;
+using Admin.Core.Model;
+using Admin.Core.Model.Model_New;
+using log4net;
+using Microsoft.IdentityModel.Logging;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Admin.Core.Service
+{
+ public class ProductOffLineServices : BaseServices, IProductOffLineServices
+ {
+ #region 对象引用
+ private static readonly log4net.ILog log = LogManager.GetLogger(typeof(ProductOffLineServices));
+ #endregion
+ private readonly IBaseRepository baseRepository;
+ private ICodeBindingRecordRepository _codeBindingRecordRepository;
+ public ProductOffLineServices(IBaseRepository baseRepository)
+ {
+ this.baseRepository = baseRepository;
+
+ }
+
+
+ ///
+ /// 条码系统获取校验字符串
+ ///
+ public async Task QueryChecked(string barCode)
+ {
+ try
+ {
+ var _db = baseRepository.Db;
+ var infos = await _db.Ado.SqlQueryAsync($"SELECT ILS_TMPRD.ILS_SORT_BARCODE_PKG.GET_BARCODE_DATA({barCode}) FROM DUAL");
+ return infos.FirstOrDefault().result;
+ }
+ catch (Exception ex)
+ {
+ log.Error("条码系统获取校验字符串异常"+ex);
+ return null;
+ }
+ }
+
+ ///
+ /// 条码系统入库接口
+ ///
+ public async Task SaveBarcodeInfo()
+ {
+ try
+ {
+ // 保存业务
+ var _db = baseRepository.Db;
+ var infos = await _db.Ado.SqlQueryAsync($"");
+ return infos.FirstOrDefault().result;
+ }
+ catch (Exception ex)
+ {
+ log.Error("条码系统入库异常" + ex);
+ return null;
+ }
+ }
+
+ }
+}
diff --git a/Admin.Core.sln b/Admin.Core.sln
index c3fe781f..6c741b6d 100644
--- a/Admin.Core.sln
+++ b/Admin.Core.sln
@@ -217,7 +217,7 @@ Global
{5CF85AD7-DBC9-4466-952B-6742F37E417D} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE}
{C24510B9-90E2-46FA-937B-AB291EAAA7CD} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE}
{9EE12F11-F9E4-46DD-935D-F6EDD495A6FC} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE}
- {680718C5-E39C-442F-AC9E-4A56E15AF261} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE}
+ {680718C5-E39C-442F-AC9E-4A56E15AF261} = {A4C60BC6-0120-48F4-A60D-C73160B122AA}
{61EE37C2-A9C2-40DE-A96E-D7E4DEB5FEC3} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE}
{5515C937-1E2E-4111-8775-EE6898E5933A} = {BD987F3A-4E6C-4C47-B28F-1671F875EAE3}
{C70810CE-041A-4880-99B3-FFCC8B672B42} = {BD987F3A-4E6C-4C47-B28F-1671F875EAE3}
diff --git a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
index 73f91d6f..b72d94d2 100644
--- a/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
+++ b/Aucma.Core.ProductOffLine/ViewModels/IndexPageViewModel.cs
@@ -22,6 +22,11 @@ using Admin.Core.IService;
using Microsoft.Extensions.DependencyInjection;
using Admin.Core.Model.Model_New;
using Admin.Core.Model;
+using SqlSugar;
+using System.Data.Common;
+using static Org.BouncyCastle.Math.EC.ECCurve;
+using Admin.Core.IRepository;
+using Admin.Core.Service;
/*
* 成品分舵入库首页信息
@@ -32,20 +37,21 @@ namespace Aucma.Core.ProductOffLine.ViewModels
public partial class IndexPageViewModel : ObservableObject
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel));
- private readonly IBaseOrderInfoServices? _baseOrderInfoServices;
+ private readonly IBaseOrderInfoServices _baseOrderInfoServices;
private readonly IProductPlanInfoServices? _productPlanInfoServices;
+ private readonly IProductOffLineServices ? _productOffLineServices;
public IndexPageViewModel()
{
+ _productOffLineServices = App.ServiceProvider.GetService();
_baseOrderInfoServices = App.ServiceProvider.GetService();
_productPlanInfoServices = App.ServiceProvider.GetService();
MvCodeHelper.ReceiveCodeEvent += ReceiveCode;
-
// test();
- //List listdatabase = Appsettings.app("DBS")
- // .Where(i => i.Enabled).ToList();
+ // test33();
InitEveryDayMethod();
- //*** test2();
+ //*** test2();
+
}
#region 扫描信息
@@ -220,14 +226,14 @@ namespace Aucma.Core.ProductOffLine.ViewModels
private async void ReceiveCode(string code, int scannerNo)
{
//1.扫描的SN条码去条码系统查询GET_BARCODE_DATA
-
+ //条码系统返回校验数据
+ // string result = _productOffLineServices.QueryChecked(code).Result
string result = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000000807@BCD-160C,家电下乡@@BCD-160C@皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01";
// 如果校验失败,下发报警
if("N".Equals(result.Substring(0,1)))
{
sendPlcError();
// 刷新页面提示信息 result.Substring(2)
-
return;
}
//2.查询到的数据分割处理,结果中用"@"号分隔,刷新页面显示并存到scada数据库(表待建)
@@ -239,11 +245,11 @@ namespace Aucma.Core.ProductOffLine.ViewModels
}
//3.调条码系统保存接口入库SaveBarcodeInfo
-
+ _productOffLineServices.SaveBarcodeInfo();
//4.更新mes数据库完成数量和时间(BASE_ORDERINFO,PRODUCT_PLANINFO) 注意:查询的字段可能需要修改,确保数据一致
- //4.1截取订单号去查询更新BASE_ORDERINFO
+ //4.1截取订单号去查询更新BASE_ORDERINFO,全放到service处理
string orderCode = "11215484";
BaseOrderInfo order = _baseOrderInfoServices.Query(x => x.OrderCode == orderCode).FirstOrDefault();
if (order.CompleteAmount == 0)
@@ -292,6 +298,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels
bool result = false;
try
{
+
var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("成品下线Plc"));
if (obj != null)
{
@@ -430,33 +437,23 @@ namespace Aucma.Core.ProductOffLine.ViewModels
///
/// 连接测试
///
- void test()
+ private void test33()
{
- // string aa = BaseDBConfig.MutiInitConn().Item1[2].Connection;
- string connectionString = "Data Source=(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.50)(PORT = 1521)))(CONNECT_DATA=(SERVICE_NAME=tmdata)));User ID=ILS_SORT;Password=Aucma_2019;";
- // string connectionString = "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;";
- // string functionQuery = "SELECT COUNT(*) from CODE_BINDING";
- string sql = "SELECT ILS_TMPRD.ILS_SORT_BARCODE_PKG.GET_BARCODE_DATA('16160030000000910779') FROM DUAL";
- using (OracleConnection connection = new OracleConnection(connectionString))
- {
- connection.Open();
-
- using (OracleCommand command = new OracleCommand(sql, connection))
- {
- // 执行函数并获取结果
- string result = command.ExecuteScalar().ToString();
- // 在结果中用"@"号分隔
- string[] resultArray = result.Split('@');
+
+ // 使用条码数据库连接
+ try
+ {
+ //条码系统返回校验数据
+ string result = _productOffLineServices.QueryChecked("5").Result;
+ Console.WriteLine(result);
- // 输出结果
- foreach (string item in resultArray)
- {
- Thread.Sleep(2000);
- MessageBox.Show(item);
- }
- }
+ }catch(Exception ex)
+ {
+ Console.WriteLine(ex.Message);
}
+
+
}
///
diff --git a/Aucma.Core.ProductOffLine/appsettings.json b/Aucma.Core.ProductOffLine/appsettings.json
index a7392bb6..337a1d6a 100644
--- a/Aucma.Core.ProductOffLine/appsettings.json
+++ b/Aucma.Core.ProductOffLine/appsettings.json
@@ -98,7 +98,8 @@
"DBType": 3,
"Enabled": true,
"HitRate": 40,
- "Connection": "Data Source=(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.1.50)(PORT = 1521)))(CONNECT_DATA=(SERVICE_NAME=tmdata)));User ID=ILS_SORT;Password=Aucma_2019;",
+ // "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=(PROTOCOL=TCP)(HOST = 10.100.86.225)(PORT = 1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=swndev)));User ID=ILS_SORT;Password=Aucma_2019;",
"ProviderName": "System.Data.SqlClient"
}
],