You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
3.8 KiB
C#
113 lines
3.8 KiB
C#
using Confluent.Kafka;
|
|
using Google.OrTools.ConstraintSolver;
|
|
using log4net;
|
|
using log4net.Repository.Hierarchy;
|
|
using MongoDB.Bson;
|
|
using MongoDB.Driver;
|
|
using MongoDB.Driver.Linq;
|
|
using SlabHandle.Enity;
|
|
using SOA.Persistent;
|
|
using Swashbuckle.Swagger;
|
|
using System;
|
|
using System.CodeDom;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Dynamic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
using System.Web.Http.Results;
|
|
using static System.Net.WebRequestMethods;
|
|
|
|
namespace SlabHandle
|
|
{
|
|
public class SubResultControler
|
|
{
|
|
#region 变量常量
|
|
|
|
//Log4net 日志输出
|
|
private static readonly ILog logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
//后端 Service
|
|
private static SlabNumService SerService = new SlabNumService();
|
|
|
|
public static IList<TB_SUB_RESULT> tB_SUB_RESULTs = new List<TB_SUB_RESULT>();
|
|
public static IList<TB_SUB_RESULT> tB_SUB_RESULTs_HIS = new List<TB_SUB_RESULT>();
|
|
#endregion 变量常量
|
|
|
|
/// <summary>
|
|
/// 接口批量替代板坯
|
|
/// </summary>
|
|
/// <param name="TM">定时器</param>
|
|
/// <returns></returns>
|
|
///
|
|
public static RequestEntity reqBulkSlabSupersede()
|
|
{
|
|
RequestEntity result = new RequestEntity(); //声明返回参数实体类
|
|
|
|
try
|
|
{
|
|
SaveInfo();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.msg = "数据库错误!";
|
|
result.code = "0";
|
|
logger.Error("AddSurplusMaterial 报错 : ", ex);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public static void SaveInfo()
|
|
{
|
|
IList<TB_SUB_RESULT> tB_SUB_RESULT1 = new List<TB_SUB_RESULT>();
|
|
IList<TB_SUB_RESULT> tB_SUB_RESULT2 = new List<TB_SUB_RESULT>();
|
|
IList<TB_SUB_RESULT> tB_SUB_RESULT3 = new List<TB_SUB_RESULT>();
|
|
tB_SUB_RESULTs_HIS = SlabNumService.GetHisRATE();
|
|
Task[] tasks = new Task[4];
|
|
tasks[0] = Task.Factory.StartNew(() =>
|
|
{
|
|
tB_SUB_RESULT1 = SlabNumService.GetHisC1RATE_ALL();
|
|
logger.Info("C1:"+tB_SUB_RESULT1.Count());
|
|
});
|
|
tasks[1] = Task.Factory.StartNew(() =>
|
|
{
|
|
tB_SUB_RESULT2 = SlabNumService.GetHisC2RATE_ALL();
|
|
logger.Info("C2:"+tB_SUB_RESULT2.Count());
|
|
});
|
|
tasks[2] = Task.Factory.StartNew(() =>
|
|
{
|
|
tB_SUB_RESULT3 = SlabNumService.GetHisC3RATE_ALL();
|
|
logger.Info("C3:"+tB_SUB_RESULT3.Count());
|
|
});
|
|
tasks[3] = Task.Factory.StartNew(() =>
|
|
{
|
|
tB_SUB_RESULTs_HIS = SlabNumService.GetHisRATE();
|
|
logger.Info(tB_SUB_RESULTs_HIS.Count());
|
|
});
|
|
Task.WaitAll(tasks);
|
|
tB_SUB_RESULTs = tB_SUB_RESULTs.Union(tB_SUB_RESULT1).ToList();
|
|
tB_SUB_RESULTs = tB_SUB_RESULTs.Union(tB_SUB_RESULT2).ToList();
|
|
tB_SUB_RESULTs = tB_SUB_RESULTs.Union(tB_SUB_RESULT3).ToList();
|
|
foreach (string INS_DATE in tB_SUB_RESULTs.GroupBy(p => p.SUB_DATE).Select(q => q.Key))
|
|
{
|
|
if (tB_SUB_RESULTs_HIS.Where(p => p.SUB_DATE == INS_DATE).Count() > 0)
|
|
{
|
|
logger.Info("删除"+ INS_DATE+"数据");
|
|
SlabNumService.deleteInfo(INS_DATE);
|
|
}
|
|
logger.Info("插入" + INS_DATE + "数据");
|
|
SlabNumService.SaveInfo(tB_SUB_RESULTs.Where(p=>p.SUB_DATE== INS_DATE).ToList());
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
} |