Browse Source

销售出库接口。

master
yibo 7 years ago
parent
commit
87fe6fb412
2 changed files with 95 additions and 0 deletions
  1. +1
    -0
      B3ClientService/B3ClientService.csproj
  2. +94
    -0
      B3ClientService/OfflinRpc/CarcassSaleOutStoreRpc.cs

+ 1
- 0
B3ClientService/B3ClientService.csproj View File

@ -149,6 +149,7 @@
<Compile Include="NamedValueTemplate.cs" /> <Compile Include="NamedValueTemplate.cs" />
<Compile Include="OfflinRpc\BaseInfoRpc.cs" /> <Compile Include="OfflinRpc\BaseInfoRpc.cs" />
<Compile Include="OfflinRpc\CarcassInStoreRpc.cs" /> <Compile Include="OfflinRpc\CarcassInStoreRpc.cs" />
<Compile Include="OfflinRpc\CarcassSaleOutStoreRpc.cs" />
<Compile Include="OfflinRpc\CarcassTakeOutRpc.cs" /> <Compile Include="OfflinRpc\CarcassTakeOutRpc.cs" />
<Compile Include="OfflinRpc\ExtensionObj.cs" /> <Compile Include="OfflinRpc\ExtensionObj.cs" />
<Compile Include="OfflinRpc\GradeAndWeightBL.cs" /> <Compile Include="OfflinRpc\GradeAndWeightBL.cs" />


+ 94
- 0
B3ClientService/OfflinRpc/CarcassSaleOutStoreRpc.cs View File

@ -0,0 +1,94 @@
using BWP.B3ClientService.BO;
using BWP.B3ClientService.NamedValueTemplate;
using BWP.B3Frameworks.Utils;
using Forks.EnterpriseServices;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.JsonRpc;
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 CarcassSaleOutStoreRpc
{
[Rpc(RpcFlags.SkipAuth)]
public static int UploadCarcassInfo(string json)
{
var list = JsonConvert.DeserializeObject<List<CarcassSaleOutStoreObj>>(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, CarcassSaleOutStoreObj obj, IDmoSession session)
{
var goodsID = GetGoodsID(obj.SaleGoods_Code, session);
var update = new DQUpdateDom(typeof(CarcassFullInfo));
update.Columns.Add(new DQUpdateColumn("PickGroupID", obj.GroupID));
update.Columns.Add(new DQUpdateColumn("SaleGoods_ID", goodsID));
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 Dictionary<string, long?> GoodsCodeToID = new Dictionary<string, long?>();
static void Insert(CarcassSaleOutStoreObj obj, IDmoSession session)
{
var entity = new CarcassFullInfo();
entity.BarCode = obj.BarCode;
entity.PickWeight = obj.Weight;
entity.PickGroupID = obj.GroupID;
entity.PickTime = obj.Time;
entity.SaleGoods_ID = GetGoodsID(obj.SaleGoods_Code, session);
entity.PickType = .;
session.Insert(entity);
}
static long? GetGoodsID(string code, IDmoSession session)
{
if (!GoodsCodeToID.ContainsKey(code))
{
var id = InnerBLUtil.GetDmoProperty<long?>(session, typeof(Goods), "ID", new Tuple<string, object>("Code", code));
GoodsCodeToID.Add(code, id);
}
return GoodsCodeToID[code];
}
}
class CarcassSaleOutStoreObj
{
public string BarCode { get; set; }
public decimal? Weight { get; set; }
public DateTime? Time { get; set; }
public long? GroupID { get; set; }
public string SaleGoods_Code { get; set; }
}
}

Loading…
Cancel
Save