|
|
@ -0,0 +1,99 @@ |
|
|
|
|
|
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.OfflinRpc |
|
|
|
|
|
{ |
|
|
|
|
|
[Rpc] |
|
|
|
|
|
public static class CarcassTakeOutRpc |
|
|
|
|
|
{ |
|
|
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
|
|
public static int UploadCarcassInfo(string json) |
|
|
|
|
|
{ |
|
|
|
|
|
var list = JsonConvert.DeserializeObject<List<CarcassTakeOutObj>>(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, CarcassTakeOutObj obj, IDmoSession session) |
|
|
|
|
|
{ |
|
|
|
|
|
var update = new DQUpdateDom(typeof(CarcassFullInfo)); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("PickWorker_ID", obj.TakeOutWorker_ID)); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("PickWorkUnit_ID", obj.WorkUnit_ID)); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("PickGroupID", obj.GroupID)); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("PickWeight", obj.Weight)); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("PickTime", obj.Time)); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("PickType", 领用类型.分割领用)); |
|
|
|
|
|
update.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void Insert(CarcassTakeOutObj obj, IDmoSession session) |
|
|
|
|
|
{ |
|
|
|
|
|
var entity = new CarcassFullInfo(); |
|
|
|
|
|
entity.BarCode = obj.BarCode; |
|
|
|
|
|
entity.PickWorker_ID = obj.TakeOutWorker_ID; |
|
|
|
|
|
entity.PickWorkUnit_ID = obj.WorkUnit_ID; |
|
|
|
|
|
entity.PickWeight = obj.Weight; |
|
|
|
|
|
entity.PickGroupID = obj.GroupID; |
|
|
|
|
|
entity.PickTime = obj.Time; |
|
|
|
|
|
entity.PickType = 领用类型.分割领用; |
|
|
|
|
|
session.Insert(entity); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Rpc(RpcFlags.SkipAuth)] |
|
|
|
|
|
public static string GetBeforeInfo(List<string> codeList) |
|
|
|
|
|
{ |
|
|
|
|
|
var main = new JoinAlias(typeof(CarcassFullInfo)); |
|
|
|
|
|
var goods = new JoinAlias(typeof(Goods)); |
|
|
|
|
|
var query = new DQueryDom(main); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(main, "InStoreGoods_ID", goods, "ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("BarCode")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("InStoreWeight")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("InStoreGoods_ID")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Name", goods)); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field("InStoreWeight")), DQCondition.InList(DQExpression.Field("BarCode"), codeList.Select(x => DQExpression.Value(x)).ToArray()))); |
|
|
|
|
|
var result = query.EExecuteList<string, decimal, long, string>(); |
|
|
|
|
|
var back = result.Select(x => new ExtensionObj { StringExt1 = x.Item1, DecimalExt1 = x.Item2, LongExt1 = x.Item3, StringExt2 = x.Item4 }); |
|
|
|
|
|
return JsonConvert.SerializeObject(back); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class CarcassTakeOutObj |
|
|
|
|
|
{ |
|
|
|
|
|
public string BarCode { get; set; } |
|
|
|
|
|
public long? TakeOutWorker_ID { get; set; } |
|
|
|
|
|
public long? WorkUnit_ID { get; set; } |
|
|
|
|
|
public decimal? Weight { get; set; } |
|
|
|
|
|
public DateTime? Time { get; set; } |
|
|
|
|
|
public long? GroupID { get; set; } |
|
|
|
|
|
} |
|
|
|
|
|
} |