|
|
@ -9,6 +9,7 @@ using System.Linq; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using TSingSoft.WebPluginFramework.TimerTasks; |
|
|
using TSingSoft.WebPluginFramework.TimerTasks; |
|
|
using TSingSoft.WebPluginFramework; |
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
|
|
using Forks.EnterpriseServices.SqlDoms; |
|
|
|
|
|
|
|
|
namespace BWP.B3ClientService.Tasks |
|
|
namespace BWP.B3ClientService.Tasks |
|
|
{ |
|
|
{ |
|
|
@ -19,23 +20,29 @@ namespace BWP.B3ClientService.Tasks |
|
|
var url = new B3ClientServiceOnLineConfig().TraceBackUrl.Value; |
|
|
var url = new B3ClientServiceOnLineConfig().TraceBackUrl.Value; |
|
|
if (string.IsNullOrEmpty(url)) |
|
|
if (string.IsNullOrEmpty(url)) |
|
|
return; |
|
|
return; |
|
|
url = url + "InsertInStore"; |
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
using (var session = Dmo.NewSession()) |
|
|
{ |
|
|
{ |
|
|
var list = GetUnSyncdInfo(session); |
|
|
|
|
|
if (!list.Any()) |
|
|
|
|
|
return; |
|
|
|
|
|
var splitList = TraceBackInfoUtil.SplitList(list, 1000); |
|
|
|
|
|
foreach (var infos in splitList) |
|
|
|
|
|
{ |
|
|
|
|
|
var arr = JsonConvert.SerializeObject(infos); |
|
|
|
|
|
TraceBackInfoUtil.Insert(url, arr); |
|
|
|
|
|
} |
|
|
|
|
|
DeleteSyncd(session, list.Min(x => x.ID), list.Max(x => x.ID)); |
|
|
|
|
|
|
|
|
UploadButcherInfo(session, url); |
|
|
|
|
|
UploadInStoreInfo(session, url); |
|
|
session.Commit(); |
|
|
session.Commit(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UploadInStoreInfo(IDmoSession session, string url) |
|
|
|
|
|
{ |
|
|
|
|
|
var sUrl = url + "InsertInStore"; |
|
|
|
|
|
var list = GetUnSyncdInfo(session); |
|
|
|
|
|
if (!list.Any()) |
|
|
|
|
|
return; |
|
|
|
|
|
var splitList = TraceBackInfoUtil.SplitList(list, 1000); |
|
|
|
|
|
foreach (var infos in splitList) |
|
|
|
|
|
{ |
|
|
|
|
|
var arr = JsonConvert.SerializeObject(infos); |
|
|
|
|
|
TraceBackInfoUtil.Insert(sUrl, arr); |
|
|
|
|
|
} |
|
|
|
|
|
DeleteSyncd(session, list.Min(x => x.ID), list.Max(x => x.ID)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
List<TraceBackInStoreInfo> GetUnSyncdInfo(IDmoSession session) |
|
|
List<TraceBackInStoreInfo> GetUnSyncdInfo(IDmoSession session) |
|
|
{ |
|
|
{ |
|
|
var query = new DQueryDom(new JoinAlias(typeof(SyncCarcassInStoreLog))); |
|
|
var query = new DQueryDom(new JoinAlias(typeof(SyncCarcassInStoreLog))); |
|
|
@ -54,10 +61,133 @@ namespace BWP.B3ClientService.Tasks |
|
|
session.ExecuteNonQuery(delete); |
|
|
session.ExecuteNonQuery(delete); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UploadButcherInfo(IDmoSession session, string url) |
|
|
|
|
|
{ |
|
|
|
|
|
var sUrl = url + "ButcherInsert"; |
|
|
|
|
|
var list = GetTraceBackInfo(session); |
|
|
|
|
|
if (!list.Any()) |
|
|
|
|
|
return; |
|
|
|
|
|
var arr = JsonConvert.SerializeObject(list); |
|
|
|
|
|
TraceBackInfoUtil.Insert(sUrl, arr); |
|
|
|
|
|
foreach (var item in list) |
|
|
|
|
|
session.Insert(new ButcherTraceBackLog { GradeAndWeight_ID = item.ID }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<TraceBackInfo> GetTraceBackInfo(IDmoSession session) |
|
|
|
|
|
{ |
|
|
|
|
|
var list = new List<TraceBackInfo>(); |
|
|
|
|
|
|
|
|
|
|
|
var main = new JoinAlias(typeof(GradeAndWeight_Detail)); |
|
|
|
|
|
var log = new JoinAlias(typeof(ButcherTraceBackLog)); |
|
|
|
|
|
var detail = new JoinAlias(typeof(OrderDetail)); |
|
|
|
|
|
var weight = new JoinAlias(typeof(WeightBill)); |
|
|
|
|
|
var query = new DQueryDom(main); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(log), DQCondition.EQ(main, "ID", log, "GradeAndWeight_ID")); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(main, "OrderDetail_ID", detail, "ID")); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.EQ(detail, "WeightBill_ID", weight, "ID")); |
|
|
|
|
|
var wd = WeightFramerTemp.Register(query, weight); |
|
|
|
|
|
var farmer = new JoinAlias(typeof(Farmer)); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(farmer), DQCondition.EQ(wd, "Farmer_ID", farmer, "ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Technics")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Time")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Date")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Index")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("AnimalTestNumber", weight)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("AnimalTestMan", weight)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Name", farmer)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Address", farmer)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
|
|
query.Range = SelectRange.Top(500); |
|
|
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID")); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.InEQ(DQExpression.Field("BarCode"), DQExpression.Value("")), DQCondition.IsNull(DQExpression.Field(log, "GradeAndWeight_ID")))); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.GreaterThan("Date", new DateTime(2018, 2, 12))); |
|
|
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
|
|
|
{ |
|
|
|
|
|
while (reader.Read()) |
|
|
|
|
|
{ |
|
|
|
|
|
var info = new TraceBackInfo(); |
|
|
|
|
|
info.Code = (string)reader[0]; |
|
|
|
|
|
info.Goods_Name = (short)reader[1] == 0 ? "带皮白条" : "去皮白条"; |
|
|
|
|
|
info.ProductDate = string.Format("{0:yyyyMMdd}", reader[2]); |
|
|
|
|
|
info.ExpirationTime = "0-4℃ 4日"; |
|
|
|
|
|
info.ProductCompany = "青岛万福集团股份有限公司"; |
|
|
|
|
|
info.CompanyAddress = "青岛莱西市珠海路五号"; |
|
|
|
|
|
info.CompanyTel = "0532-55650698"; |
|
|
|
|
|
info.ButcherTime = string.Format("{0:yyyyMMdd}", reader[3]); |
|
|
|
|
|
info.ButcherBatch = string.Format("{0}{1:000}", info.ButcherTime, reader[4]); |
|
|
|
|
|
info.TestingNo = (string)reader[5]; |
|
|
|
|
|
info.TestingMan = (string)reader[6]; |
|
|
|
|
|
if (!string.IsNullOrEmpty(info.TestingNo)) |
|
|
|
|
|
info.TestingResult = "合格"; |
|
|
|
|
|
info.Farmer = (string)reader[7]; |
|
|
|
|
|
info.PigFarmAddress = (string)reader[8]; |
|
|
|
|
|
info.ID = (long)reader[9]; |
|
|
|
|
|
list.Add(info); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public string Name |
|
|
public string Name |
|
|
{ |
|
|
{ |
|
|
get { return "抽取白条入库信息到追溯服务器"; } |
|
|
|
|
|
|
|
|
get { return "抽取白条信息到追溯服务器"; } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class WeightFramerTemp |
|
|
|
|
|
{ |
|
|
|
|
|
public long WeightID { get; set; } |
|
|
|
|
|
public long? Farmer_ID { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public static JoinAlias Register(DQueryDom root, JoinAlias weight) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(WeightBill_FarmerDetail))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("WeightBill_ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Max("Farmer_ID")); |
|
|
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field("WeightBill_ID")); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("DeleteState", false)); |
|
|
|
|
|
|
|
|
|
|
|
var alias = new JoinAlias(typeof(WeightFramerTemp)); |
|
|
|
|
|
root.RegisterQueryTable(typeof(WeightFramerTemp), new string[] { "WeightID", "Farmer_ID" }, query); |
|
|
|
|
|
root.From.AddJoin(JoinType.Left, new DQDmoSource(alias), DQCondition.EQ(weight, "ID", alias, "WeightID")); |
|
|
|
|
|
return alias; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class TraceBackInfo |
|
|
|
|
|
{ |
|
|
|
|
|
[JsonIgnore] |
|
|
|
|
|
public long ID { get; set; } |
|
|
|
|
|
//[LogicName("条码")]
|
|
|
|
|
|
public string Code { get; set; } |
|
|
|
|
|
//[LogicName("产品名称")]
|
|
|
|
|
|
public string Goods_Name { get; set; } |
|
|
|
|
|
//[LogicName("生产日期")]
|
|
|
|
|
|
public string ProductDate { get; set; } |
|
|
|
|
|
//[LogicName("保质期")]
|
|
|
|
|
|
public string ExpirationTime { get; set; } |
|
|
|
|
|
//[LogicName("生产厂家")]
|
|
|
|
|
|
public string ProductCompany { get; set; } |
|
|
|
|
|
//[LogicName("生产厂址")]
|
|
|
|
|
|
public string CompanyAddress { get; set; } |
|
|
|
|
|
//[LogicName("电话")]
|
|
|
|
|
|
public string CompanyTel { get; set; } |
|
|
|
|
|
//[LogicName("生猪产地")]
|
|
|
|
|
|
public string PigFarmAddress { get; set; } |
|
|
|
|
|
//[LogicName("动检证号")]
|
|
|
|
|
|
public string TestingNo { get; set; } |
|
|
|
|
|
//[LogicName("动检结果")]
|
|
|
|
|
|
public string TestingResult { get; set; } |
|
|
|
|
|
//[LogicName("动检人员")]
|
|
|
|
|
|
public string TestingMan { get; set; } |
|
|
|
|
|
//[LogicName("养殖户")]
|
|
|
|
|
|
public string Farmer { get; set; } |
|
|
|
|
|
//[LogicName("屠宰批次")]
|
|
|
|
|
|
public string ButcherBatch { get; set; } |
|
|
|
|
|
//[LogicName("屠宰时间")]
|
|
|
|
|
|
public string ButcherTime { get; set; } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class TraceBackInStoreInfo |
|
|
class TraceBackInStoreInfo |
|
|
|