|
|
@ -0,0 +1,147 @@ |
|
|
|
|
|
using BWP.B3ClientService.BO; |
|
|
|
|
|
using BWP.B3ClientService.NamedValueTemplate; |
|
|
|
|
|
using Forks.EnterpriseServices.DomainObjects2; |
|
|
|
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
|
|
|
using Forks.EnterpriseServices.JsonRpc; |
|
|
|
|
|
using Forks.EnterpriseServices.SqlDoms; |
|
|
|
|
|
using Newtonsoft.Json; |
|
|
|
|
|
using System; |
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
using System.Linq; |
|
|
|
|
|
using System.Text; |
|
|
|
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
|
|
|
|
|
|
|
|
namespace BWP.B3ClientService.Rpcs |
|
|
|
|
|
{ |
|
|
|
|
|
[Rpc] |
|
|
|
|
|
public static class CarcassInStoreRpc |
|
|
|
|
|
{ |
|
|
|
|
|
#region 手持机端调用
|
|
|
|
|
|
|
|
|
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
|
|
public static string ScarBarCode(string url) |
|
|
|
|
|
{ |
|
|
|
|
|
if (url.Contains("?")) |
|
|
|
|
|
{ |
|
|
|
|
|
var arr = url.Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries); |
|
|
|
|
|
if (arr.Length > 1) |
|
|
|
|
|
{ |
|
|
|
|
|
var list = arr[1].Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries); |
|
|
|
|
|
foreach (var item in list) |
|
|
|
|
|
{ |
|
|
|
|
|
var l = item.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); |
|
|
|
|
|
if (l.Length == 2 && l[0].ToUpper() == "CODE") |
|
|
|
|
|
return l[1].Trim(); |
|
|
|
|
|
} |
|
|
|
|
|
return string.Empty; |
|
|
|
|
|
} |
|
|
|
|
|
return string.Empty; |
|
|
|
|
|
} |
|
|
|
|
|
return url.Trim(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
|
|
public static long PadInsert(long goodsID, string barCode) |
|
|
|
|
|
{ |
|
|
|
|
|
if (string.IsNullOrEmpty(barCode)) |
|
|
|
|
|
throw new Exception("编码为空"); |
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
|
|
{ |
|
|
|
|
|
var id = CheckExist(barCode, session); |
|
|
|
|
|
if (id == null) |
|
|
|
|
|
{ |
|
|
|
|
|
var entity = new PadCarcassInStore(); |
|
|
|
|
|
entity.Goods_ID = goodsID; |
|
|
|
|
|
entity.BarCode = barCode; |
|
|
|
|
|
session.Insert(entity); |
|
|
|
|
|
id = entity.ID; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
Update(id.Value, goodsID, session); |
|
|
|
|
|
session.Commit(); |
|
|
|
|
|
return id.Value; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static long? CheckExist(string barCode, IDmoSession session) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(PadCarcassInStore))); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
|
|
return query.EExecuteScalar<long?>(session); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void Update(long id, long goodsID, IDmoSession session) |
|
|
|
|
|
{ |
|
|
|
|
|
var update = new DQUpdateDom(typeof(PadCarcassInStore)); |
|
|
|
|
|
update.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("Goods_ID", goodsID)); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("Sync", false)); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("RowVersion", DQExpression.Add(DQExpression.Field("RowVersion"), DQExpression.Value(1)))); |
|
|
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
|
|
public static string PadGetGoodsList() |
|
|
|
|
|
{ |
|
|
|
|
|
var main = new JoinAlias(typeof(ClientGoodsSet)); |
|
|
|
|
|
var detail = new JoinAlias(typeof(ClientGoodsSet_Detail)); |
|
|
|
|
|
var query = new DQueryDom(main); |
|
|
|
|
|
query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "ClientGoodsSet_ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_ID", detail)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Name", detail)); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Stopped", false), DQCondition.EQ("ApplyClient", 适用客户端.白条出入库))); |
|
|
|
|
|
var list = query.EExecuteList<long, string>(); |
|
|
|
|
|
return JsonConvert.SerializeObject(list.Select(x => new MinGoodsObj { Goods_ID = x.Item1, Goods_Name = x.Item2 })); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 客户端处理手持机数据
|
|
|
|
|
|
|
|
|
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
|
|
public static string GetUnSyncPadData() |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(PadCarcassInStore))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("RowVersion")); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Sync", false)); |
|
|
|
|
|
var r = query.EExecuteList<long, string, long, int>(); |
|
|
|
|
|
var list = r.Select(x => new PadCarcassInStore { ID = x.Item1, BarCode = x.Item2, Goods_ID = x.Item3, RowVersion = x.Item4 }); |
|
|
|
|
|
return JsonConvert.SerializeObject(list); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
|
|
public static int SetPadDataSync(string backInfo) |
|
|
|
|
|
{ |
|
|
|
|
|
var arr = JsonConvert.DeserializeObject<List<IDRowVersion>>(backInfo); |
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var item in arr) |
|
|
|
|
|
UpdateSynced(item, session); |
|
|
|
|
|
session.Commit(); |
|
|
|
|
|
} |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void UpdateSynced(IDRowVersion 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))); |
|
|
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class MinGoodsObj |
|
|
|
|
|
{ |
|
|
|
|
|
public long Goods_ID { get; set; } |
|
|
|
|
|
public string Goods_Name { get; set; } |
|
|
|
|
|
} |
|
|
|
|
|
} |