|
|
@ -16,6 +16,7 @@ using Forks.JsonRpc.Client; |
|
|
using Newtonsoft.Json; |
|
|
using Newtonsoft.Json; |
|
|
using BWP.B3Frameworks.BO.NamedValueTemplate; |
|
|
using BWP.B3Frameworks.BO.NamedValueTemplate; |
|
|
using BWP.B3ButcherManage.Utils; |
|
|
using BWP.B3ButcherManage.Utils; |
|
|
|
|
|
using BWP.B3ButcherManage.BO; |
|
|
|
|
|
|
|
|
namespace BWP.B3QingDaoWanFu.Tasks |
|
|
namespace BWP.B3QingDaoWanFu.Tasks |
|
|
{ |
|
|
{ |
|
|
@ -38,9 +39,42 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool inited = false; |
|
|
|
|
|
bool InitRpcFacade() |
|
|
|
|
|
{ |
|
|
|
|
|
if (!inited) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
var url = GetMesUrl(); |
|
|
|
|
|
if (string.IsNullOrEmpty(url)) |
|
|
|
|
|
return false; |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
RpcFacade.Init(url, "B3ClientService"); |
|
|
|
|
|
inited = true; |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
if (ex.Message == "Can only start once") |
|
|
|
|
|
inited = true; |
|
|
|
|
|
else |
|
|
|
|
|
throw; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return inited; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string GetMesUrl() |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(ClientConfig))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("MesUrl")); |
|
|
|
|
|
return query.EExecuteScalar<string>(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void DoExecute() |
|
|
private void DoExecute() |
|
|
{ |
|
|
{ |
|
|
if (!ClientServerFacedRpcFacadeUtil.InitRpcFacade()) |
|
|
|
|
|
|
|
|
// http://172.28.1.194:7799/B2/Rest.aspx
|
|
|
|
|
|
if (!InitRpcFacade()) |
|
|
return; |
|
|
return; |
|
|
var main = new JoinAlias(typeof(SaleOutStore)); |
|
|
var main = new JoinAlias(typeof(SaleOutStore)); |
|
|
var relate = new JoinAlias(typeof(SaleOutStoreBarCodeToMESLog)); |
|
|
var relate = new JoinAlias(typeof(SaleOutStoreBarCodeToMESLog)); |
|
|
@ -58,13 +92,16 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
query.Columns.Add(DQSelectColumn.Field("CheckTime", main)); |
|
|
query.Columns.Add(DQSelectColumn.Field("CheckTime", main)); |
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Code", scan)); |
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Code", scan)); |
|
|
query.Columns.Add(DQSelectColumn.Field("Number", scan)); |
|
|
query.Columns.Add(DQSelectColumn.Field("Number", scan)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Flag", scan)); |
|
|
|
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", 单据状态.已审核), DQCondition.IsNull(DQExpression.Field(relate, "SaleOutStore_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.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThan(scan, "Weight", 0), DQCondition.GreaterThan(scan, "Number", 0))); |
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThan(scan, "Weight", 0), DQCondition.GreaterThan(scan, "Number", 0))); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.InEQ(scan, "Flag", 2)); |
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(main, "ID")); |
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(main, "ID")); |
|
|
using (var session = Dmo.NewSession()) |
|
|
using (var session = Dmo.NewSession()) |
|
|
{ |
|
|
{ |
|
|
var list = new List<CarcassSaleOutStoreObj>(); |
|
|
|
|
|
|
|
|
var carcassList = new List<CarcassSaleOutStoreObj>(); |
|
|
|
|
|
var segmentList = new List<SegmentSaleOutStoreObj>(); |
|
|
var ids = new List<long>(); |
|
|
var ids = new List<long>(); |
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
{ |
|
|
{ |
|
|
@ -73,21 +110,31 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
var id = (long)reader[0]; |
|
|
var id = (long)reader[0]; |
|
|
if (!ids.Contains(id)) |
|
|
if (!ids.Contains(id)) |
|
|
ids.Add(id); |
|
|
ids.Add(id); |
|
|
var entity = new CarcassSaleOutStoreObj(); |
|
|
|
|
|
entity.BarCode = (string)reader[1]; |
|
|
|
|
|
entity.Weight = (decimal?)reader[2]; |
|
|
|
|
|
entity.ProductBatch_ID = (long?)reader[3]; |
|
|
|
|
|
entity.Time = (DateTime?)reader[4]; |
|
|
|
|
|
entity.SaleGoods_Code = (string)reader[5]; |
|
|
|
|
|
entity.Number = (decimal?)reader[6]; |
|
|
|
|
|
list.Add(entity); |
|
|
|
|
|
|
|
|
var flag = (int)reader[7]; |
|
|
|
|
|
if (flag == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var entity = new CarcassSaleOutStoreObj(); |
|
|
|
|
|
entity.BarCode = (string)reader[1]; |
|
|
|
|
|
entity.Weight = (decimal?)reader[2]; |
|
|
|
|
|
entity.ProductBatch_ID = (long?)reader[3]; |
|
|
|
|
|
entity.Time = (DateTime?)reader[4]; |
|
|
|
|
|
entity.SaleGoods_Code = (string)reader[5]; |
|
|
|
|
|
entity.Number = (decimal?)reader[6]; |
|
|
|
|
|
carcassList.Add(entity); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
var entity = new SegmentSaleOutStoreObj(); |
|
|
|
|
|
entity.BarCode = (string)reader[1]; |
|
|
|
|
|
entity.Time = (DateTime?)reader[4]; |
|
|
|
|
|
segmentList.Add(entity); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (ids.Count == 0) |
|
|
if (ids.Count == 0) |
|
|
return; |
|
|
return; |
|
|
if (list.Any()) |
|
|
|
|
|
|
|
|
if (carcassList.Any()) |
|
|
{ |
|
|
{ |
|
|
var slist = TraceBackInfoUtil.SplitList(list, 1000); |
|
|
|
|
|
|
|
|
var slist = TraceBackInfoUtil.SplitList(carcassList, 1000); |
|
|
foreach (var items in slist) |
|
|
foreach (var items in slist) |
|
|
{ |
|
|
{ |
|
|
var par = JsonConvert.SerializeObject(items); |
|
|
var par = JsonConvert.SerializeObject(items); |
|
|
@ -95,6 +142,16 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (segmentList.Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
var slist = TraceBackInfoUtil.SplitList(segmentList, 1000); |
|
|
|
|
|
foreach (var items in slist) |
|
|
|
|
|
{ |
|
|
|
|
|
var par = JsonConvert.SerializeObject(items); |
|
|
|
|
|
var json = RpcFacade.Call<int>("/MainSystem/B3ClientService/Rpcs/SegmentSaleOutStoreRpc/UploadSegmentInfo", par); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
foreach (var item in ids) |
|
|
foreach (var item in ids) |
|
|
session.Insert(new SaleOutStoreBarCodeToMESLog { SaleOutStore_ID = item }); |
|
|
session.Insert(new SaleOutStoreBarCodeToMESLog { SaleOutStore_ID = item }); |
|
|
|
|
|
|
|
|
@ -117,4 +174,10 @@ namespace BWP.B3QingDaoWanFu.Tasks |
|
|
public long? ProductBatch_ID { get; set; } |
|
|
public long? ProductBatch_ID { get; set; } |
|
|
public decimal? Number { get; set; } |
|
|
public decimal? Number { get; set; } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class SegmentSaleOutStoreObj |
|
|
|
|
|
{ |
|
|
|
|
|
public string BarCode { get; set; } |
|
|
|
|
|
public DateTime? Time { get; set; } |
|
|
|
|
|
} |
|
|
} |
|
|
} |