|
|
|
@ -7,6 +7,7 @@ using BWP.B3Frameworks.Utils; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
|
using Forks.EnterpriseServices.JsonRpc; |
|
|
|
using Forks.JsonRpc.Client; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
|
|
|
|
@ -17,6 +18,58 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
|
public static class SegmentationInStoreRecordRpc |
|
|
|
{ |
|
|
|
|
|
|
|
[Rpc] |
|
|
|
public static long CreateTodayB3ProductInStoreBill() |
|
|
|
{ |
|
|
|
var serverUri = ServerHost.GetServerUrl(); |
|
|
|
if (string.IsNullOrEmpty(serverUri)) |
|
|
|
{ |
|
|
|
throw new Exception("请配置服务器地址"); |
|
|
|
} |
|
|
|
try |
|
|
|
{ |
|
|
|
RpcFacade.Init(serverUri, "B3ClientServer"); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
if (ex.Message != "Can only start once") |
|
|
|
throw; |
|
|
|
} |
|
|
|
|
|
|
|
var today = DateTime.Today; |
|
|
|
var query = new DmoQuery(typeof(SegmentationInStoreRecord)); |
|
|
|
query.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", today)); |
|
|
|
query.Where.Conditions.Add(DQCondition.LessThan("CreateTime", today.AddDays(1))); |
|
|
|
query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("B3_ID"))); |
|
|
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
var list = session.ExecuteList(query).Cast<SegmentationInStoreRecord>().ToList(); |
|
|
|
if (list.Count == 0) |
|
|
|
{ |
|
|
|
return -1; |
|
|
|
} |
|
|
|
var json = JsonConvert.SerializeObject(list); |
|
|
|
var b3Id = RpcFacade.Call<long>("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/CreateB3ProductInStore", json); |
|
|
|
if (b3Id > 0) |
|
|
|
{ |
|
|
|
var update = new DQUpdateDom(typeof(SegmentationInStoreRecord)); |
|
|
|
update.Where.Conditions.Add(DQCondition.GreaterThanOrEqual("CreateTime", today)); |
|
|
|
update.Where.Conditions.Add(DQCondition.LessThan("CreateTime", today.AddDays(1))); |
|
|
|
update.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("B3_ID"))); |
|
|
|
update.Columns.Add(new DQUpdateColumn("B3_ID", b3Id)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("SyncToB3DateTime", DateTime.Now)); |
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
session.Commit(); |
|
|
|
return b3Id; |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Rpc]//根据汇总码得到所有的
|
|
|
|
public static string GetWeightRecordList(string barcode) |
|
|
|
{ |
|
|
|
@ -39,7 +92,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
|
record = list[0]; |
|
|
|
return JsonConvert.SerializeObject(record); |
|
|
|
} |
|
|
|
throw new Exception("无效条码"); |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
private static SegmentationWeightRecord GetWeightRecordDmo(string barcode) |
|
|
|
@ -52,7 +105,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
|
{ |
|
|
|
return list[0]; |
|
|
|
} |
|
|
|
throw new Exception("无效条码"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private static readonly object _insertObj = new object(); |
|
|
|
@ -71,14 +124,17 @@ namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
|
if (string.IsNullOrWhiteSpace(dmo.Goods_Name)) |
|
|
|
{ |
|
|
|
var weight = GetWeightRecordDmo(dmo.BarCode); |
|
|
|
dmo.Goods_ID = weight.Goods_ID; |
|
|
|
dmo.Goods_Name = weight.Goods_Name; |
|
|
|
dmo.Goods_Spec = weight.Goods_Spec; |
|
|
|
dmo.Weight = weight.Weight; |
|
|
|
dmo.BiaoShi = weight.BiaoShi; |
|
|
|
dmo.ProductBatch = weight.ProductBatch; |
|
|
|
dmo.CardBarCode = weight.CardBarCode; |
|
|
|
dmo.CreateUserName = weight.CreateUserName; |
|
|
|
if (weight != null) |
|
|
|
{ |
|
|
|
dmo.Goods_ID = weight.Goods_ID; |
|
|
|
dmo.Goods_Name = weight.Goods_Name; |
|
|
|
dmo.Goods_Spec = weight.Goods_Spec; |
|
|
|
dmo.Weight = weight.Weight; |
|
|
|
dmo.BiaoShi = weight.BiaoShi; |
|
|
|
dmo.ProductBatch = weight.ProductBatch; |
|
|
|
dmo.CardBarCode = weight.CardBarCode; |
|
|
|
dmo.CreateUserName = weight.CreateUserName; |
|
|
|
} |
|
|
|
} |
|
|
|
UpdateWeightRecordInStored(session, dmo.BarCode); |
|
|
|
session.Insert(dmo); |
|
|
|
|