|
|
|
@ -0,0 +1,175 @@ |
|
|
|
using BWP.B3ClientService.BO; |
|
|
|
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 SegmentInStoreRpc |
|
|
|
{ |
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
public static string GetSegmentProductInfo(string barCode) |
|
|
|
{ |
|
|
|
var main = new JoinAlias(typeof(SegmentProductionInfo)); |
|
|
|
var goods = new JoinAlias(typeof(Goods)); |
|
|
|
var query = new DQueryDom(main); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(main, "Goods_ID", goods, "ID")); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Code", goods)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Name", goods)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Spec", goods)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ProductTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weight")); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
|
{ |
|
|
|
if (reader.Read()) |
|
|
|
{ |
|
|
|
var entity = new SegmentProductObj(); |
|
|
|
entity.Goods_Code = (string)reader[0]; |
|
|
|
entity.Goods_Name = (string)reader[1]; |
|
|
|
entity.Goods_Spec = (string)reader[2]; |
|
|
|
entity.ProductTime = (DateTime?)reader[3]; |
|
|
|
entity.Weight = (decimal?)reader[4]; |
|
|
|
|
|
|
|
return JsonConvert.SerializeObject(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return string.Empty; |
|
|
|
} |
|
|
|
|
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
public static int UploadSegmentInStoreInfo(string json) |
|
|
|
{ |
|
|
|
var list = JsonConvert.DeserializeObject<List<SegmentInStoreObj>>(json); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
/* BarCode InStoreTime Store_ID State */ |
|
|
|
foreach (var item in list) |
|
|
|
{ |
|
|
|
var id = Exist(session, item.BarCode); |
|
|
|
if (id == null) |
|
|
|
{ |
|
|
|
if (item.Delete) |
|
|
|
continue; |
|
|
|
var entity = new SegmentProductionInfo(); |
|
|
|
entity.BarCode = item.BarCode; |
|
|
|
if (item.State == 2) |
|
|
|
{ |
|
|
|
entity.InStoreTime = item.InStoreTime; |
|
|
|
entity.Store_ID = item.Store_ID; |
|
|
|
entity.IsDelete = true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
entity.InStoreTime = item.InStoreTime; |
|
|
|
entity.Store_ID = item.Store_ID; |
|
|
|
} |
|
|
|
session.Insert(entity); |
|
|
|
} |
|
|
|
else |
|
|
|
Update(session, id.Value, item); |
|
|
|
} |
|
|
|
session.Commit(); |
|
|
|
} |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
static long? Exist(IDmoSession session, string barCode) |
|
|
|
{ |
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(SegmentProductionInfo))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID")); |
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode)); |
|
|
|
return query.EExecuteScalar<long?>(session); |
|
|
|
} |
|
|
|
|
|
|
|
private static void Update(IDmoSession session, long id, SegmentInStoreObj entity) |
|
|
|
{ |
|
|
|
var update = new DQUpdateDom(typeof(SegmentProductionInfo)); |
|
|
|
if (entity.Delete || entity.State == 2) |
|
|
|
{ |
|
|
|
update.Columns.Add(new DQUpdateColumn("InStoreTime", DQExpression.NULL)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("Store_ID", DQExpression.NULL)); |
|
|
|
if (entity.State == 2) |
|
|
|
update.Columns.Add(new DQUpdateColumn("IsDelete", true)); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
update.Columns.Add(new DQUpdateColumn("InStoreTime", entity.InStoreTime)); |
|
|
|
update.Columns.Add(new DQUpdateColumn("Store_ID", entity.Store_ID)); |
|
|
|
} |
|
|
|
update.Columns.Add(new DQUpdateColumn("IsSync", false)); |
|
|
|
update.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
} |
|
|
|
|
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
public static string GetUnInStoreList() |
|
|
|
{ |
|
|
|
var main = new JoinAlias(typeof(SegmentProductionInfo)); |
|
|
|
var goods = new JoinAlias(typeof(Goods)); |
|
|
|
var query = new DQueryDom(main); |
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(main, "Goods_ID", goods, "ID")); |
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNull(DQExpression.Field("InStoreTime")), DQCondition.EQ("IsDelete", false))); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Code", goods)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Name", goods)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Spec", goods)); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("ProductTime")); |
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weight")); |
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID")); |
|
|
|
var list = new List<SegmentProductObj>(); |
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
{ |
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
|
{ |
|
|
|
while (reader.Read()) |
|
|
|
{ |
|
|
|
var obj = new SegmentProductObj(); |
|
|
|
obj.BarCode = (string)reader[0]; |
|
|
|
obj.Goods_Code = (string)reader[1]; |
|
|
|
obj.Goods_Name = (string)reader[2]; |
|
|
|
obj.Goods_Spec = (string)reader[3]; |
|
|
|
obj.ProductTime = (DateTime?)reader[4]; |
|
|
|
obj.Weight = (decimal?)reader[5]; |
|
|
|
list.Add(obj); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return JsonConvert.SerializeObject(list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class SegmentInStoreObj |
|
|
|
{ |
|
|
|
public string BarCode { get; set; } |
|
|
|
|
|
|
|
public DateTime InStoreTime { get; set; } |
|
|
|
|
|
|
|
public long? Store_ID { get; set; } |
|
|
|
|
|
|
|
public int State { get; set; } |
|
|
|
|
|
|
|
public bool Delete { get; set; } |
|
|
|
} |
|
|
|
|
|
|
|
class SegmentProductObj |
|
|
|
{ |
|
|
|
public string BarCode { get; set; } |
|
|
|
public string Goods_Name { get; set; } |
|
|
|
public string Goods_Code { get; set; } |
|
|
|
public string Goods_Spec { get; set; } |
|
|
|
public decimal? Weight { get; set; } |
|
|
|
public DateTime? ProductTime { get; set; } |
|
|
|
} |
|
|
|
} |