|
|
|
@ -15,6 +15,7 @@ using TSingSoft.WebPluginFramework; |
|
|
|
using Forks.JsonRpc.Client; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using BWP.B3Frameworks.BO.NamedValueTemplate; |
|
|
|
using BWP.B3ButcherManage.Utils; |
|
|
|
|
|
|
|
namespace BWP.B3QingDaoWanFu.Tasks |
|
|
|
{ |
|
|
|
@ -42,63 +43,86 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
|
if (!ClientServerFacedRpcFacadeUtil.InitRpcFacade()) |
|
|
|
return; |
|
|
|
var main = new JoinAlias(typeof(SaleOutStore)); |
|
|
|
var relate = new JoinAlias(typeof(SaleOutStoreBarCodeToMESLog)); |
|
|
|
var detail = new JoinAlias(typeof(SaleOutStore_Detail)); |
|
|
|
var weight = new JoinAlias(typeof(WeightingInfor)); |
|
|
|
var scan = new JoinAlias(typeof(WeightingInfo_ScanDetail)); |
|
|
|
var relate = new JoinAlias(typeof(SaleOutStoreBarCodeToMESLog)); |
|
|
|
var temp = new JoinAlias(typeof(Temp)); |
|
|
|
var query = new DQueryDom(main); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(relate), DQCondition.EQ(main, "ID", relate, "SaleOutStore_ID")); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "SaleOutStore_ID")); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.And(DQCondition.EQ(detail, "ID", weight, "DetailID"), DQCondition.EQ(weight, "BillType", DmoTypeIDAttribute.GetID(typeof(SaleOutStore))))); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(scan), DQCondition.And(DQCondition.EQ(detail, "ID", scan, "Detail_ID"), DQCondition.EQ(weight, "ID", scan, "WeightingInfo_ID"))); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(relate), DQCondition.EQ(scan, "ID", relate, "ScanBar_ID")); |
|
|
|
query.RegisterQueryTable(typeof(Temp), new string[] { "GroupID", "Weight" }, Temp.GetQueryDom()); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(temp), DQCondition.EQ(detail, "ID", temp, "GroupID")); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", scan)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", main)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode", scan)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("NetWeight", weight)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", detail)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("LoadTime", main)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", weight)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Code", detail)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weight", temp)); |
|
|
|
|
|
|
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.IsNull(DQExpression.Field(relate, "ScanBar_ID")), DQCondition.IsNotNull(DQExpression.Field(scan, "ID")))); |
|
|
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.IsNull(DQExpression.Field(relate, "SaleOutStore_ID")), DQCondition.IsNotNull(DQExpression.Field(scan, "ID")))); |
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(main, "ID")); |
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(weight, "NetWeight", true)); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
var list = new List<CarcassSaleOutStoreObj>(); |
|
|
|
var ids = new List<long>(); |
|
|
|
var discont = new Dictionary<long, decimal>(); |
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
|
{ |
|
|
|
while (reader.Read()) |
|
|
|
{ |
|
|
|
var id = (long)reader[0]; |
|
|
|
if (!ids.Contains(id)) |
|
|
|
ids.Add(id); |
|
|
|
var entity = new CarcassSaleOutStoreObj(); |
|
|
|
entity.BarCode = (string)reader[1]; |
|
|
|
entity.Weight = ((Money<decimal>?)reader[2]).EToDecimal(); |
|
|
|
entity.Time = (DateTime?)reader[3]; |
|
|
|
entity.GroupID = (long)reader[4]; |
|
|
|
var wv = ((Money<decimal>?)reader[2]).EToDecimal(); |
|
|
|
entity.GroupID = (long)reader[3]; |
|
|
|
if (wv < 0) |
|
|
|
{ |
|
|
|
var first = list.FirstOrDefault(x => x.GroupID == entity.GroupID && x.BarCode == entity.BarCode); |
|
|
|
if (first != null) |
|
|
|
list.Remove(first); |
|
|
|
continue; |
|
|
|
} |
|
|
|
entity.Time = (DateTime?)reader[4]; |
|
|
|
entity.SaleGoods_Code = (string)reader[5]; |
|
|
|
entity.Weight = (decimal?)reader[6]; |
|
|
|
list.Add(entity); |
|
|
|
ids.Add((long)reader[0]); |
|
|
|
} |
|
|
|
} |
|
|
|
if (list.Count == 0) |
|
|
|
if (ids.Count == 0) |
|
|
|
return; |
|
|
|
|
|
|
|
foreach (var g in list.GroupBy(x => x.GroupID)) |
|
|
|
if (list.Any()) |
|
|
|
{ |
|
|
|
var first = true; |
|
|
|
foreach (var item in g) |
|
|
|
foreach (var g in list.GroupBy(x => x.GroupID)) |
|
|
|
{ |
|
|
|
if (first) |
|
|
|
first = false; |
|
|
|
else |
|
|
|
item.Weight = 0; |
|
|
|
var first = true; |
|
|
|
foreach (var item in g) |
|
|
|
{ |
|
|
|
if (first) |
|
|
|
first = false; |
|
|
|
else |
|
|
|
item.Weight = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var slist = TraceBackInfoUtil.SplitList(list, 1000); |
|
|
|
foreach (var items in slist) |
|
|
|
{ |
|
|
|
var par = JsonConvert.SerializeObject(items); |
|
|
|
var json = RpcFacade.Call<int>("/MainSystem/B3ClientService/Rpcs/CarcassSaleOutStoreRpc/UploadCarcassInfo", par); |
|
|
|
} |
|
|
|
} |
|
|
|
var par = JsonConvert.SerializeObject(list); |
|
|
|
|
|
|
|
var json = RpcFacade.Call<int>("/MainSystem/B3ClientService/Rpcs/CarcassSaleOutStoreRpc/UploadCarcassInfo", par); |
|
|
|
foreach (var item in ids) |
|
|
|
session.Insert(new SaleOutStoreBarCodeToMESLog { ScanBar_ID = item }); |
|
|
|
session.Insert(new SaleOutStoreBarCodeToMESLog { SaleOutStore_ID = item }); |
|
|
|
|
|
|
|
session.Commit(); |
|
|
|
} |
|
|
|
@ -108,6 +132,31 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
|
{ |
|
|
|
get { return "上传审核的销售出库扫码信息到MES"; } |
|
|
|
} |
|
|
|
|
|
|
|
class Temp |
|
|
|
{ |
|
|
|
public long GroupID { get; set; } |
|
|
|
public decimal? Weight { get; set; } |
|
|
|
|
|
|
|
public static DQueryDom GetQueryDom() |
|
|
|
{ |
|
|
|
var main = new JoinAlias(typeof(SaleOutStore)); |
|
|
|
var relate = new JoinAlias(typeof(SaleOutStoreBarCodeToMESLog)); |
|
|
|
var detail = new JoinAlias(typeof(SaleOutStore_Detail)); |
|
|
|
var weight = new JoinAlias(typeof(WeightingInfor)); |
|
|
|
var query = new DQueryDom(main); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(relate), DQCondition.EQ(main, "ID", relate, "SaleOutStore_ID")); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "SaleOutStore_ID")); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.And(DQCondition.EQ(detail, "ID", weight, "DetailID"), DQCondition.EQ(weight, "BillType", DmoTypeIDAttribute.GetID(typeof(SaleOutStore))))); |
|
|
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", detail)); |
|
|
|
query.Columns.Add(DQSelectColumn.Sum(weight, "NetWeight")); |
|
|
|
query.GroupBy.Expressions.Add(DQExpression.Field(detail, "ID")); |
|
|
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.IsNull(DQExpression.Field(relate, "SaleOutStore_ID")), DQCondition.IsNotNull(DQExpression.Field(weight, "ID")))); |
|
|
|
return query; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class CarcassSaleOutStoreObj |
|
|
|
|