Browse Source

优化销售出库单上传销售信息到MES的逻辑。支持现场退货功能。

master
yibo 7 years ago
parent
commit
fc9844fc19
3 changed files with 97 additions and 31 deletions
  1. +2
    -2
      B3QingDaoWanFu/BO/SaleOutStoreBarCodeToMESLog.cs
  2. +71
    -22
      B3QingDaoWanFu/Tasks/SyncSaleOutStoreInfoToMES.cs
  3. +24
    -7
      B3QingDaoWanFu/TypeIOCs/SaleOutStoreBLTypeIoc.cs

+ 2
- 2
B3QingDaoWanFu/BO/SaleOutStoreBarCodeToMESLog.cs View File

@ -9,9 +9,9 @@ namespace BWP.B3QingDaoWanFu.BO
{
[BOClass]
[KeyField("ScanBar_ID", KeyGenType.assigned)]
[KeyField("SaleOutStore_ID", KeyGenType.assigned)]
public class SaleOutStoreBarCodeToMESLog
{
public long ScanBar_ID { get; set; }
public long SaleOutStore_ID { get; set; }
}
}

+ 71
- 22
B3QingDaoWanFu/Tasks/SyncSaleOutStoreInfoToMES.cs View File

@ -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


+ 24
- 7
B3QingDaoWanFu/TypeIOCs/SaleOutStoreBLTypeIoc.cs View File

@ -161,15 +161,32 @@ namespace BWP.B3QingDaoWanFu.TypeIOCs
query.Columns.Add(DQSelectColumn.Field("Car_Name", bill));
query.Columns.Add(DQSelectColumn.Field("LoadTime", bill));
query.Columns.Add(DQSelectColumn.Field("BarCode", scan));
query.Columns.Add(DQSelectColumn.Field("NetWeight", weight));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(detail, "SaleOutStore_ID", id), DQCondition.IsNotNull(DQExpression.Field(scan, "ID"))));
var list = query.EExecuteList<string, string, DateTime, string>(session);
if (!list.Any())
return new List<TractBillSaleInfo>();
var letList = list.Select(x => new TractBillSaleInfo { Code = x.Item4, SendCustomer = x.Item1, CarNo = x.Item2, SendDate = x.Item3.ToString("yyyyMMdd") }).ToList();
return letList;
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(weight, "NetWeight", true));
var list = new List<TractBillSaleInfo>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var entity = new TractBillSaleInfo();
entity.Code = (string)reader[3];
var wv = (Money<decimal>)reader[4];
if (wv < 0)
{
var first = list.FirstOrDefault(x => x.Code == entity.Code);
if (first != null)
list.Remove(first);
continue;
}
entity.SendCustomer = (string)reader[0];
entity.CarNo = (string)reader[1];
entity.SendDate = ((DateTime)reader[2]).ToString("yyyyMMdd");
list.Add(entity);
}
}
return list;
}
public override string Name


Loading…
Cancel
Save