|
|
|
@ -0,0 +1,164 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using BWP.B3ClientService.BO; |
|
|
|
using BWP.B3Frameworks.Utils; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
|
using Forks.EnterpriseServices.JsonRpc; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
|
|
|
|
namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
|
{ |
|
|
|
|
|
|
|
[Rpc] |
|
|
|
public static class SegmentationInStoreRecordRpc |
|
|
|
{ |
|
|
|
|
|
|
|
[Rpc]//根据汇总码得到所有的
|
|
|
|
public static string GetWeightRecordList(string barcode) |
|
|
|
{ |
|
|
|
var query = new DmoQuery(typeof(SegmentationWeightRecord)); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("CardBarCode", barcode)); |
|
|
|
var list = query.EExecuteList().Cast<SegmentationWeightRecord>().ToList(); |
|
|
|
return JsonConvert.SerializeObject(list); |
|
|
|
} |
|
|
|
|
|
|
|
[Rpc] |
|
|
|
public static string GetWeightRecord(string barcode) |
|
|
|
{ |
|
|
|
SegmentationWeightRecord record; |
|
|
|
var query = new DmoQuery(typeof(SegmentationWeightRecord)); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barcode)); |
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); |
|
|
|
var list = query.EExecuteList().Cast<SegmentationWeightRecord>().ToList(); |
|
|
|
if (list.Count > 0) |
|
|
|
{ |
|
|
|
record = list[0]; |
|
|
|
return JsonConvert.SerializeObject(record); |
|
|
|
} |
|
|
|
throw new Exception("无效条码"); |
|
|
|
} |
|
|
|
|
|
|
|
private static SegmentationWeightRecord GetWeightRecordDmo(string barcode) |
|
|
|
{ |
|
|
|
var query = new DmoQuery(typeof(SegmentationWeightRecord)); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barcode)); |
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); |
|
|
|
var list = query.EExecuteList().Cast<SegmentationWeightRecord>().ToList(); |
|
|
|
if (list.Count > 0) |
|
|
|
{ |
|
|
|
return list[0]; |
|
|
|
} |
|
|
|
throw new Exception("无效条码"); |
|
|
|
} |
|
|
|
|
|
|
|
private static readonly object _insertObj = new object(); |
|
|
|
[Rpc] |
|
|
|
public static long Insert(string json) |
|
|
|
{ |
|
|
|
lock (_insertObj) |
|
|
|
{ |
|
|
|
var dmo = JsonConvert.DeserializeObject<SegmentationInStoreRecord>(json); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
var record = GetExist(session, dmo.BarCode); |
|
|
|
if (record == null) |
|
|
|
{ |
|
|
|
dmo.CreateTime = DateTime.Now; |
|
|
|
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; |
|
|
|
} |
|
|
|
UpdateWeightRecordInStored(session, dmo.BarCode); |
|
|
|
session.Insert(dmo); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
record.Goods_ID = dmo.Goods_ID; |
|
|
|
record.Goods_Name = dmo.Goods_Name; |
|
|
|
record.Goods_Spec = dmo.Goods_Spec; |
|
|
|
record.Weight = dmo.Weight; |
|
|
|
record.Store_ID = dmo.Store_ID; |
|
|
|
record.Store_Name = dmo.Store_Name; |
|
|
|
record.BiaoShi = dmo.BiaoShi; |
|
|
|
record.ProductBatch = dmo.ProductBatch; |
|
|
|
record.CardBarCode = dmo.CardBarCode; |
|
|
|
record.CreateUserName = dmo.CreateUserName; |
|
|
|
session.Update(record); |
|
|
|
} |
|
|
|
session.Commit(); |
|
|
|
} |
|
|
|
return dmo.ID; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static SegmentationInStoreRecord GetExist(IDmoSession session, string barCode) |
|
|
|
{ |
|
|
|
var query = new DmoQuery(typeof(SegmentationInStoreRecord)); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode)); |
|
|
|
var res = session.ExecuteList(query).Cast<SegmentationInStoreRecord>().ToList(); |
|
|
|
if (res.Count > 0) |
|
|
|
{ |
|
|
|
return res[0]; |
|
|
|
} |
|
|
|
//throw new Exception("存在多条记录,请找管理员");
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static readonly object _updateObj = new object(); |
|
|
|
[Rpc] |
|
|
|
public static int Update(string json) |
|
|
|
{ |
|
|
|
lock (_updateObj) |
|
|
|
{ |
|
|
|
var clientRecord = JsonConvert.DeserializeObject<SegmentationInStoreRecordDto>(json); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
var record = session.Load(new DmoIdentity(typeof(SegmentationInStoreRecord), clientRecord.Service_ID ?? 0)); |
|
|
|
DmoUtil.CopyDmoFields(clientRecord, record, "ID", "B3_ID"); |
|
|
|
session.Update(record); |
|
|
|
session.Commit(); |
|
|
|
//需要更新大表???
|
|
|
|
} |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Rpc] |
|
|
|
public static int Delete(long id) |
|
|
|
{ |
|
|
|
var delDom = new DQDeleteDom(typeof(SegmentationInStoreRecord)); |
|
|
|
delDom.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
session.ExecuteNonQuery(delDom); |
|
|
|
session.Commit(); |
|
|
|
//需要删除大表
|
|
|
|
} |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void UpdateWeightRecordInStored(IDmoSession session, string barCode) |
|
|
|
{ |
|
|
|
var updateDom = new DQUpdateDom(typeof(SegmentationWeightRecord)); |
|
|
|
updateDom.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode)); |
|
|
|
updateDom.Columns.Add(new DQUpdateColumn("IsInStored", true)); |
|
|
|
session.ExecuteNonQuery(updateDom); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |