|
|
|
@ -45,6 +45,8 @@ namespace BWP.B3ClientService.Rpcs |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(barCode)) |
|
|
|
throw new Exception("编码为空"); |
|
|
|
if (barCode.Length != 23) |
|
|
|
throw new Exception("条码格式不正确"); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
var id = CheckExist(barCode, session); |
|
|
|
@ -116,7 +118,7 @@ namespace BWP.B3ClientService.Rpcs |
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
public static int SetPadDataSync(string backInfo) |
|
|
|
{ |
|
|
|
var arr = JsonConvert.DeserializeObject<List<IDRowVersion>>(backInfo); |
|
|
|
var arr = JsonConvert.DeserializeObject<List<ExtensionObj>>(backInfo); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
foreach (var item in arr) |
|
|
|
@ -126,17 +128,80 @@ namespace BWP.B3ClientService.Rpcs |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
static void UpdateSynced(IDRowVersion info, IDmoSession session) |
|
|
|
static void UpdateSynced(ExtensionObj info, IDmoSession session) |
|
|
|
{ |
|
|
|
var update = new DQUpdateDom(typeof(PadCarcassInStore)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("Sync", true)); |
|
|
|
update.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("ID", info.ID), DQCondition.EQ("RowVersion", info.RowVersion))); |
|
|
|
update.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("ID", info.LongExt1), DQCondition.EQ("RowVersion", info.DecimalExt1))); |
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
public static int UploadCarcassInfo(string json) |
|
|
|
{ |
|
|
|
var list = JsonConvert.DeserializeObject<List<CarcassInStoreObj>>(json); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
foreach (var item in list) |
|
|
|
{ |
|
|
|
var id = GetID(item.BarCode, session); |
|
|
|
if (id.HasValue) |
|
|
|
Update(id.Value, item, session); |
|
|
|
else |
|
|
|
Insert(item, session); |
|
|
|
} |
|
|
|
session.Commit(); |
|
|
|
} |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
static long? GetID(string code, IDmoSession session) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(CarcassFullInfo))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("BarCode", code)); |
|
|
|
return query.EExecuteScalar<long?>(session); |
|
|
|
} |
|
|
|
|
|
|
|
static void Update(long id, CarcassInStoreObj obj, IDmoSession session) |
|
|
|
{ |
|
|
|
var update = new DQUpdateDom(typeof(CarcassFullInfo)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("InStoreWorker_ID", obj.InStoreWorker_ID)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("WorkUnit_ID", obj.WorkUnit_ID)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("ProductBatch_ID", obj.ProductBatch_ID)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("InStoreGoods_ID", obj.InStoreGoods_ID)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("InStoreWeight", obj.InStoreWeight)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("InStoreTime", obj.InStoreTime)); |
|
|
|
update.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
} |
|
|
|
|
|
|
|
static void Insert(CarcassInStoreObj obj, IDmoSession session) |
|
|
|
{ |
|
|
|
var entity = new CarcassFullInfo(); |
|
|
|
entity.BarCode = obj.BarCode; |
|
|
|
entity.InStoreWorker_ID = obj.InStoreWorker_ID; |
|
|
|
entity.WorkUnit_ID = obj.WorkUnit_ID; |
|
|
|
entity.ProductBatch_ID = obj.ProductBatch_ID; |
|
|
|
entity.InStoreGoods_ID = obj.InStoreGoods_ID; |
|
|
|
entity.InStoreWeight = obj.InStoreWeight; |
|
|
|
entity.InStoreTime = obj.InStoreTime; |
|
|
|
session.Insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
public static string GetWeightInfo(List<string> codeList) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(CarcassFullInfo))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("GradeWeight")); |
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field("GradeWeight")), DQCondition.InList(DQExpression.Field("BarCode"), codeList.Select(x => DQExpression.Value(x)).ToArray()))); |
|
|
|
var result = query.EExecuteList<string, decimal?>(); |
|
|
|
var back = result.Select(x => new ExtensionObj { StringExt1 = x.Item1, DecimalExt1 = x.Item2 }); |
|
|
|
return JsonConvert.SerializeObject(back); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class MinGoodsObj |
|
|
|
@ -144,4 +209,17 @@ namespace BWP.B3ClientService.Rpcs |
|
|
|
public long Goods_ID { get; set; } |
|
|
|
public string Goods_Name { get; set; } |
|
|
|
} |
|
|
|
|
|
|
|
class CarcassInStoreObj |
|
|
|
{ |
|
|
|
public long ID { get; set; } |
|
|
|
public int RowVersion { get; set; } |
|
|
|
public string BarCode { get; set; } |
|
|
|
public long? InStoreWorker_ID { get; set; } |
|
|
|
public long? WorkUnit_ID { get; set; } |
|
|
|
public long? ProductBatch_ID { get; set; } |
|
|
|
public long? InStoreGoods_ID { get; set; } |
|
|
|
public decimal? InStoreWeight { get; set; } |
|
|
|
public DateTime? InStoreTime { get; set; } |
|
|
|
} |
|
|
|
} |