|
|
using BWP.B3ClientService.BO;
|
|
|
using Forks.EnterpriseServices.BusinessInterfaces;
|
|
|
using Forks.EnterpriseServices.DomainObjects2;
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery;
|
|
|
using Forks.EnterpriseServices.SqlDoms;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Web.Script.Serialization;
|
|
|
using TSingSoft.WebPluginFramework;
|
|
|
using TSingSoft.WebPluginFramework.BWPClients;
|
|
|
|
|
|
namespace BWP.B3ClientService.Tasks.UpdateLoad
|
|
|
{
|
|
|
public static class UploadSecondOrder
|
|
|
{
|
|
|
public static void Execute(string uri)
|
|
|
{
|
|
|
var serializer = new JavaScriptSerializer();
|
|
|
//获取所有未上传的数据
|
|
|
var allBill = GetAllNeedSyncBill();
|
|
|
foreach (var group in allBill.GroupBy(x => x.Item3))
|
|
|
{
|
|
|
var bwpClient = new BWPClient(uri, group.Key);
|
|
|
foreach (var item in group)
|
|
|
{
|
|
|
using (var context = new TransactionContext())
|
|
|
{
|
|
|
var sync = serializer.Serialize(new CTuple<long, int>(item.Item1, item.Item2));
|
|
|
bwpClient.Call("/MainSystem/B3ButcherManage/Rpcs/ButcherOrderRpc/UpdateHotFadeNumber", sync);
|
|
|
SetSyncd(context.Session, item.Item1);
|
|
|
context.Commit();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private static List<CTuple<long, int, string>> GetAllNeedSyncBill()
|
|
|
{
|
|
|
var main = new JoinAlias(typeof(SecondOrder));
|
|
|
var order = new JoinAlias(typeof(OrderDetail));
|
|
|
var query = new DQueryDom(main);
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(order), DQCondition.EQ(main, "OrderDetail_ID", order, "ID"));
|
|
|
query.Columns.Add(DQSelectColumn.Field("OrderDetail_ID"));
|
|
|
query.Columns.Add(DQSelectColumn.Field("HotFadeNumber"));
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("OrderDetail_ID"));
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field(order, "B3ID")), DQCondition.EQ(main, "IsOk", true), DQCondition.EQ(main, "Sync", false)));
|
|
|
return query.EExecuteList<long, int, string>().Select(x => new CTuple<long, int, string>(x.Item1, x.Item2, x.Item3)).ToList();
|
|
|
}
|
|
|
|
|
|
static void SetSyncd(IDmoSession session, long orderDetailID)
|
|
|
{
|
|
|
var update = new DQUpdateDom(typeof(SecondOrder));
|
|
|
update.Columns.Add(new DQUpdateColumn("Sync", true));
|
|
|
update.Where.Conditions.Add(DQCondition.EQ("OrderDetail_ID", orderDetailID));
|
|
|
session.ExecuteNonQuery(update);
|
|
|
}
|
|
|
}
|
|
|
}
|