change - 修改对接条码系统业务

dev
liuwf 1 year ago
parent d84f46b624
commit 400ad86d41

@ -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
{
/// <summary>
/// 成品下线
/// </summary>
public interface IProductOffLineServices : IBaseServices<BaseTest>
{
/// <summary>
/// 条码系统获取校验字符串
/// </summary>
public Task<string> QueryChecked(string barCode);
/// <summary>
/// 条码系统入库接口
/// </summary>
public Task<string> SaveBarcodeInfo();
}
}

@ -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
{
/// <summary>
/// 接收从条码系统获取的校验字符串
///</summary>
public string result { get; set; }
}
}

@ -57,6 +57,11 @@ namespace Admin.Core.Repository
#region 异步方法
//public ISqlSugarClient GetDb(string configID)
//{
// return _dbBase.ChangeDatabase(configID);
//}
public async Task<TEntity> QueryByIdAsync(object objId)
{
//return await Task.Run(() => _db.Queryable<TEntity>().InSingle(objId));

@ -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<TEntity> : IBaseServices<TEntity> where TEntity : class, new()
{
//public IBaseRepository<TEntity> baseDal = new BaseRepository<TEntity>();
public IBaseRepository<TEntity> BaseDal { get; set; }//通过在子类的构造函数中注入,这里是基类,不用构造函数

@ -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<BaseTest> baseRepository;
List<OrderBomInfo> bbinfolist = new List<OrderBomInfo>();
public BaseOrderInfoServices(IBaseRepository<BaseOrderInfo> dal, IPrintOrderInfoRepository printOrderInfoRepository,
IOrderBomInfoRepository orderBomInfoRepository, IBaseOrderInfoRepository baseOrderInfoRepository)
IOrderBomInfoRepository orderBomInfoRepository, IBaseOrderInfoRepository baseOrderInfoRepository, IBaseRepository<BaseTest> baseRepository)
{
this._dal = dal;
base.BaseDal = dal;
_orderBomInfoRepository = orderBomInfoRepository;
_printOrderInfoRepository = printOrderInfoRepository;
_baseOrderInfoRepository = baseOrderInfoRepository;
this.baseRepository = baseRepository;
}
/// <summary>
@ -216,4 +223,6 @@ namespace Admin.Core.Service
}
}
}

@ -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<BaseTest>, IProductOffLineServices
{
#region 对象引用
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(ProductOffLineServices));
#endregion
private readonly IBaseRepository<BaseTest> baseRepository;
private ICodeBindingRecordRepository _codeBindingRecordRepository;
public ProductOffLineServices(IBaseRepository<BaseTest> baseRepository)
{
this.baseRepository = baseRepository;
}
/// <summary>
/// 条码系统获取校验字符串
/// </summary>
public async Task<string> QueryChecked(string barCode)
{
try
{
var _db = baseRepository.Db;
var infos = await _db.Ado.SqlQueryAsync<BaseTest>($"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;
}
}
/// <summary>
/// 条码系统入库接口
/// </summary>
public async Task<string> SaveBarcodeInfo()
{
try
{
// 保存业务
var _db = baseRepository.Db;
var infos = await _db.Ado.SqlQueryAsync<BaseTest>($"");
return infos.FirstOrDefault().result;
}
catch (Exception ex)
{
log.Error("条码系统入库异常" + ex);
return null;
}
}
}
}

@ -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}

@ -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<IProductOffLineServices>();
_baseOrderInfoServices = App.ServiceProvider.GetService<IBaseOrderInfoServices>();
_productPlanInfoServices = App.ServiceProvider.GetService<IProductPlanInfoServices>();
MvCodeHelper.ReceiveCodeEvent += ReceiveCode;
// test();
//List<MutiDBOperate> listdatabase = Appsettings.app<MutiDBOperate>("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
/// <summary>
/// 连接测试
/// </summary>
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);
}
}
/// <summary>

@ -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"
}
],

Loading…
Cancel
Save