master
CaesarBao 2 months ago
parent 63540f27e8
commit 9ee4f9dff8

@ -54,15 +54,14 @@ namespace SlnMesnac.Quartz.Job
{
try
{
DateTime start = Convert.ToDateTime(DateTime.Now.ToString("D").ToString());
DateTime end = Convert.ToDateTime(DateTime.Now.AddDays(1).ToString("D").ToString()).AddSeconds(-1);
List<data1_Table> _data1Tables = _data1TableService.Getdata1TableListAsync().Result;
if (_data1Tables != null && _data1Tables.Count > 0)
{
List<T_RP_StationPara_110_1> newList = new List<T_RP_StationPara_110_1>();
foreach (var data1Table in _data1Tables)
{
newList.Add(new T_RP_StationPara_110_1()
T_RP_StationPara_110_1 T_RP_StationPara_110_1 = new T_RP_StationPara_110_1()
{
semibarcode = data1Table.dpqrcode,
scanbarcode = data1Table.jpqrcode,
@ -76,19 +75,31 @@ namespace SlnMesnac.Quartz.Job
para7 = data1Table.e3value,
para8 = data1Table.e4value,
inserttime = DateTime.Parse(data1Table.time)
});
data1Table.flag = "F";
var iflag = _data1TableService.UpdateAsync(data1Table).Result;
if (iflag)
};
bool insertflag = false;
var GetFlag = await _tr_stationPara_110_1Service.GetResultAsync(data1Table.jpqrcode, data1Table.dpqrcode);
if (GetFlag != null)
{
Console.WriteLine(StringChange.ModeToJson(data1Table));
_logger.LogDebug(StringChange.ModeToJson(data1Table));
T_RP_StationPara_110_1.id = GetFlag.id;
insertflag = _tr_stationPara_110_1Service.Update(T_RP_StationPara_110_1);
}
else
{
insertflag = _tr_stationPara_110_1Service.Insert(T_RP_StationPara_110_1);
}
if (insertflag)
{
data1Table.flag = "F";
var iflag = _data1TableService.UpdateAsync(data1Table).Result;
if (iflag)
{
Console.WriteLine(StringChange.ModeToJson(data1Table));
}
}
}
if (newList != null && newList.Count != 0)
{
bool insertflag = await _tr_stationPara_110_1Service.AddTaskAsync(newList);
}
}
}
catch (Exception ex)
@ -125,6 +136,8 @@ namespace SlnMesnac.Quartz.Job
inserttime = _data1Tables[i].time
};
//查询是否同条码多次测量
bool insertflag = await _tr_stationPara_110_2Service.AddTaskAsync(t_RP_StationPara_110_2);
if (insertflag)

@ -39,9 +39,9 @@ namespace SlnMesnac.Quartz
//q.ScheduleJob<GetTaskInfo_Job>(trigger =>
// trigger.WithCronSchedule("*/5 * * * * ?").WithIdentity("GetTaskInfo_Job", "MyJobGroup") // 示例每5s执行一次
//);
q.ScheduleJob<GetTaskInfo_Job>(trigger =>
trigger.WithCronSchedule("* * 0/2 * * ? *").WithIdentity("GetTaskInfo_Job", "MyJobGroup") // 示例每5s执行一次
);
// q.ScheduleJob<GetTaskInfo_Job>(trigger =>
// trigger.WithCronSchedule("* * 0/2 * * ? *").WithIdentity("GetTaskInfo_Job", "MyJobGroup") // 示例每5s执行一次
//);
//q.ScheduleJob<MyJob>(trigger =>
// trigger.WithCronSchedule("*/3 * * * * ?").WithIdentity("MyJob", "MyJobGroup") // 示例每3s执行一次
//);

@ -10,5 +10,7 @@ namespace SlnMesnac.Repository.service
public interface IT_RP_StationPara_110_1Service: IBaseService<T_RP_StationPara_110_1>
{
Task<bool> AddTaskAsync(List<T_RP_StationPara_110_1> record);
Task<T_RP_StationPara_110_1> GetResultAsync(string jpcode, string dpcode);
Task<bool> UpdateResultAsync(T_RP_StationPara_110_1 t_RP_StationPara_110_1);
}
}

@ -10,5 +10,7 @@ namespace SlnMesnac.Repository.service
public interface IT_RP_StationPara_110_2Service: IBaseService<T_RP_StationPara_110_2>
{
Task<bool> AddTaskAsync(T_RP_StationPara_110_2 record);
Task<T_RP_StationPara_110_2> GetResultAsync(string record);
Task<bool> UpdateResultAsync(T_RP_StationPara_110_2 t_RP_StationPara_110_2);
}
}

@ -1,9 +1,11 @@
using Microsoft.Extensions.Logging;
using SlnMesnac.Common;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace SlnMesnac.Repository.service.Impl
@ -29,7 +31,36 @@ namespace SlnMesnac.Repository.service.Impl
{
return false;
}
}
public async Task<T_RP_StationPara_110_1> GetResultAsync(string jpcode,string dpcode)
{
try
{
Expression<Func<T_RP_StationPara_110_1, bool>> exp = x => true;
exp = exp.And(x =>
(x.scanbarcode == jpcode && x.semibarcode == dpcode)
);
var result = await _repository.GetFirstAsync(exp);
return result;
}
catch (Exception ex)
{
return null;
}
}
public async Task<bool> UpdateResultAsync(T_RP_StationPara_110_1 t_RP_StationPara_110_1)
{
try
{
bool result = await _repository.UpdateAsync(t_RP_StationPara_110_1);
return result;
}
catch (Exception ex)
{
return false;
}
}
}
}

@ -1,8 +1,11 @@
using Microsoft.Extensions.Logging;
using SlnMesnac.Common;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.@base;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace SlnMesnac.Repository.service.Impl
@ -29,5 +32,35 @@ namespace SlnMesnac.Repository.service.Impl
}
}
public async Task<T_RP_StationPara_110_2> GetResultAsync(string record)
{
try
{
Expression<Func<T_RP_StationPara_110_2, bool>> exp = x => true;
exp = exp.And(x =>
(x.scanbarcode == record)
);
var result = await _repository.GetSingleAsync(exp);
return result;
}
catch (Exception ex)
{
return null;
}
}
public async Task<bool> UpdateResultAsync(T_RP_StationPara_110_2 t_RP_StationPara_110_2)
{
try
{
bool result = await _repository.UpdateAsync(t_RP_StationPara_110_2);
return result;
}
catch (Exception ex)
{
return false;
}
}
}
}

@ -108,14 +108,14 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
{
try
{
DateTime start = Convert.ToDateTime(DateTime.Now.ToString("D").ToString());
DateTime end = Convert.ToDateTime(DateTime.Now.AddDays(1).ToString("D").ToString()).AddSeconds(-1);
List<data1_Table> _data1Tables = _data1TableService.Getdata1TableListAsync().Result;
if (_data1Tables != null && _data1Tables.Count > 0)
{
List<T_RP_StationPara_110_1> newList = new List<T_RP_StationPara_110_1>();
foreach (var data1Table in _data1Tables)
{
newList.Add(new T_RP_StationPara_110_1()
T_RP_StationPara_110_1 T_RP_StationPara_110_1 = new T_RP_StationPara_110_1()
{
semibarcode = data1Table.dpqrcode,
scanbarcode = data1Table.jpqrcode,
@ -129,18 +129,31 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
para7 = data1Table.e3value,
para8 = data1Table.e4value,
inserttime = DateTime.Parse(data1Table.time)
});
data1Table.flag = "F";
var iflag = _data1TableService.UpdateAsync(data1Table).Result;
if (iflag)
};
bool insertflag = false;
var GetFlag = await _tr_stationPara_110_1Service.GetResultAsync(data1Table.jpqrcode, data1Table.dpqrcode);
if (GetFlag != null)
{
Console.WriteLine(StringChange.ModeToJson(data1Table));
T_RP_StationPara_110_1.id = GetFlag.id;
insertflag = _tr_stationPara_110_1Service.Update(T_RP_StationPara_110_1);
}
else
{
insertflag = _tr_stationPara_110_1Service.Insert(T_RP_StationPara_110_1);
}
if (insertflag)
{
data1Table.flag = "F";
var iflag = _data1TableService.UpdateAsync(data1Table).Result;
if (iflag)
{
Console.WriteLine(StringChange.ModeToJson(data1Table));
}
}
}
if (newList != null && newList.Count != 0)
{
bool insertflag = await _tr_stationPara_110_1Service.AddTaskAsync(newList);
}
}
}
catch (Exception ex)
@ -150,13 +163,71 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage
}
private async void LoadEDataInfo()
{
try
{
DateTime start = Convert.ToDateTime(DateTime.Now.ToString("D").ToString());
DateTime end = Convert.ToDateTime(DateTime.Now.AddDays(1).ToString("D").ToString()).AddSeconds(-1);
List<data2_Table> _data1Tables = _data2TableService.Getdata2TableListAsync(start, end).Result;
if (_data1Tables != null && _data1Tables.Count > 0)
{
for (global::System.Int32 i = 0; i < _data1Tables.Count; i++)
{
T_RP_StationPara_110_2 t_RP_StationPara_110_2 = new T_RP_StationPara_110_2()
{
scanbarcode = _data1Tables[i].qrcode,
state = _data1Tables[i].totaljudge == "OK" ? "1" : "2",
para1 = _data1Tables[i].f1value,
para1State = _data1Tables[i].f1judge == "OK" ? "1" : "2",
para2 = _data1Tables[i].f2value,
para2State = _data1Tables[i].f2judge == "OK" ? "1" : "2",
para3 = _data1Tables[i].f3value,
para3State = _data1Tables[i].f3judge == "OK" ? "1" : "2",
para4 = _data1Tables[i].f4value,
para4State = _data1Tables[i].f4judge == "OK" ? "1" : "2",
para5 = _data1Tables[i].frangevalue,
para5State = _data1Tables[i].frange == "OK" ? "1" : "2",
inserttime = _data1Tables[i].time
};
var GetFlag = await _tr_stationPara_110_2Service.GetResultAsync(_data1Tables[i].qrcode);
bool insertflag = false;
//存在相同测量数据则更新
if (GetFlag != null)
{
t_RP_StationPara_110_2.id = GetFlag.id;
insertflag = await _tr_stationPara_110_2Service.UpdateResultAsync(t_RP_StationPara_110_2);
}
//反之则插入
else
{
insertflag = await _tr_stationPara_110_2Service.AddTaskAsync(t_RP_StationPara_110_2);
}
if (insertflag)
{
_data1Tables[i].flag = "F";
var iflag = _data2TableService.UpdateAsync(_data1Tables[i]).Result;
if (iflag)
{
Console.WriteLine(StringChange.ModeToJson(_data1Tables[i]));
_logger.LogDebug(StringChange.ModeToJson(_data1Tables[i]));
}
}
}
}
}
catch (Exception ex)
{
_logger.LogError($"异常:{ex.Message}");
}
}
private void Init()
{
#region 测试数据
//LoadEDataInfo();
//LoadTaskInfo();
LoadTaskInfo();
//Thread.Sleep(5000);
//_tcpServer.SendReplyGetManualException(

@ -23,7 +23,7 @@
{
"configId": "Local",
"dbType": 2,
"connStr": "Data Source=F:\\Mesnac\\2023部门项目\\奥特佳-滁州3期\\源码\\HightWay_Middle_Ware\\SlnMesnac.WPF\\bin\\Debug\\net6.0-windows\\data\\FData.db3"
"connStr": "Data Source=F:\\Mesnac\\2023部门项目\\奥特佳-滁州3期\\源码\\HightWay_Middle_Ware\\SlnMesnac.WPF\\bin\\Debug\\net6.0-windows\\data\\EData.db3"
}
],
"PlcConfig": [

Loading…
Cancel
Save