|
|
@ -2,6 +2,8 @@ |
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
using Forks.EnterpriseServices.SqlDoms; |
|
|
using Forks.EnterpriseServices.SqlDoms; |
|
|
|
|
|
using Forks.JsonRpc.Client; |
|
|
|
|
|
using Newtonsoft.Json; |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.ComponentModel; |
|
|
using System.ComponentModel; |
|
|
@ -25,6 +27,7 @@ namespace ButcherFactory.BO.LocalBL |
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Name")); |
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Name")); |
|
|
query.Columns.Add(DQSelectColumn.Field("GroupID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("GroupID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("TrunOutID")); |
|
|
query.Columns.Add(DQSelectColumn.Field("TrunOutID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Spec")); |
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Delete", false), DQCondition.EQ("Submited", submited))); |
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Delete", false), DQCondition.EQ("Submited", submited))); |
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); |
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); |
|
|
if (submited) |
|
|
if (submited) |
|
|
@ -44,6 +47,7 @@ namespace ButcherFactory.BO.LocalBL |
|
|
entity.Goods_Name = (string)reader[4]; |
|
|
entity.Goods_Name = (string)reader[4]; |
|
|
entity.GroupID = (long?)reader[5]; |
|
|
entity.GroupID = (long?)reader[5]; |
|
|
entity.TrunOutID = (long?)reader[6]; |
|
|
entity.TrunOutID = (long?)reader[6]; |
|
|
|
|
|
entity.Goods_Spec = (string)reader[7]; |
|
|
entity.Submited = submited; |
|
|
entity.Submited = submited; |
|
|
list.Add(entity); |
|
|
list.Add(entity); |
|
|
} |
|
|
} |
|
|
@ -64,7 +68,7 @@ namespace ButcherFactory.BO.LocalBL |
|
|
entity.WorkUnit_ID = workUnitID; |
|
|
entity.WorkUnit_ID = workUnitID; |
|
|
entity.ProductBatch_ID = productBatchID; |
|
|
entity.ProductBatch_ID = productBatchID; |
|
|
entity.RowIndex = GenerateRowIndex(productBatchID, session); |
|
|
entity.RowIndex = GenerateRowIndex(productBatchID, session); |
|
|
entity.BarCode = string.Format("A26091201{0:yyyyMMdd}{1:00000}", batchDate, entity.RowIndex); |
|
|
|
|
|
|
|
|
entity.BarCode = string.Format("260912011{0:yyyyMMdd}{1:00000}", batchDate, entity.RowIndex); |
|
|
session.Insert(entity); |
|
|
session.Insert(entity); |
|
|
session.Commit(); |
|
|
session.Commit(); |
|
|
return entity; |
|
|
return entity; |
|
|
@ -125,5 +129,92 @@ namespace ButcherFactory.BO.LocalBL |
|
|
delete.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
delete.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
delete.EExecute(); |
|
|
delete.EExecute(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void UploadSegmentInfo() |
|
|
|
|
|
{ |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
using (var session = DmoSession.New()) |
|
|
|
|
|
{ |
|
|
|
|
|
var needUpload = GetUnSyncData(session); |
|
|
|
|
|
if (needUpload.Count == 0) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.SerializeObject(needUpload); |
|
|
|
|
|
RpcFacade.Call<int>(RpcPath + "Insert", json); |
|
|
|
|
|
foreach (var item in needUpload) |
|
|
|
|
|
SetLocalAsSyncd(item, session); |
|
|
|
|
|
session.Commit(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
catch |
|
|
|
|
|
{ |
|
|
|
|
|
#if DEBUG
|
|
|
|
|
|
throw; |
|
|
|
|
|
#endif
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static List<SegmentProductionMin> GetUnSyncData(IDmoSession session) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias("_main", typeof(SegmentProduction))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("RowVersion")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("UserID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("WorkUnit_ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ProductBatch_ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weight")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("CreateTime")); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Submited", true), DQCondition.EQ("Sync", false))); |
|
|
|
|
|
query.Range = SelectRange.Top(10); |
|
|
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID")); |
|
|
|
|
|
|
|
|
|
|
|
var upload = new List<SegmentProductionMin>(); |
|
|
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
|
|
|
{ |
|
|
|
|
|
while (reader.Read()) |
|
|
|
|
|
{ |
|
|
|
|
|
var obj = new SegmentProductionMin(); |
|
|
|
|
|
obj.ID = (long)reader[0]; |
|
|
|
|
|
obj.RowVersion = (int)reader[1]; |
|
|
|
|
|
obj.BarCode = (string)reader[2]; |
|
|
|
|
|
obj.Worker_ID = (long)reader[3]; |
|
|
|
|
|
obj.WorkUnit_ID = (long?)reader[4]; |
|
|
|
|
|
obj.ProductBatch_ID = (long?)reader[5]; |
|
|
|
|
|
obj.Goods_ID = (long)reader[6]; |
|
|
|
|
|
obj.Weight = (decimal)reader[7]; |
|
|
|
|
|
obj.ProductTime = (DateTime)reader[8]; |
|
|
|
|
|
upload.Add(obj); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return upload; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void SetLocalAsSyncd(SegmentProductionMin obj, IDmoSession session) |
|
|
|
|
|
{ |
|
|
|
|
|
var update = new DQUpdateDom(typeof(SegmentProduction)); |
|
|
|
|
|
update.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("ID", obj.ID), DQCondition.EQ("RowVersion", obj.RowVersion))); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("Sync", true)); |
|
|
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class SegmentProductionMin |
|
|
|
|
|
{ |
|
|
|
|
|
[JsonIgnore] |
|
|
|
|
|
public long ID { get; set; } |
|
|
|
|
|
[JsonIgnore] |
|
|
|
|
|
public long RowVersion { get; set; } |
|
|
|
|
|
public string BarCode { get; set; } |
|
|
|
|
|
public DateTime? ProductTime { get; set; } |
|
|
|
|
|
public long? Worker_ID { get; set; } |
|
|
|
|
|
public long? WorkUnit_ID { get; set; } |
|
|
|
|
|
public long? ProductBatch_ID { get; set; } |
|
|
|
|
|
public long? Goods_ID { get; set; } |
|
|
|
|
|
public decimal? Weight { get; set; } |
|
|
|
|
|
public DateTime? InStoreTime { get; set; } |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |