|
|
@ -5,62 +5,136 @@ using Forks.EnterpriseServices.DomainObjects2; |
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
using Forks.EnterpriseServices.DomainObjects2.DQuery; |
|
|
using Forks.EnterpriseServices.JsonRpc; |
|
|
using Forks.EnterpriseServices.JsonRpc; |
|
|
using Newtonsoft.Json; |
|
|
using Newtonsoft.Json; |
|
|
|
|
|
using TSingSoft.WebPluginFramework; |
|
|
|
|
|
using Forks.EnterpriseServices.SqlDoms; |
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
|
namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
namespace BWP.B3ClientService.Rpcs.BillRpc |
|
|
{ |
|
|
{ |
|
|
[Rpc] |
|
|
[Rpc] |
|
|
public static class MaterialRequisitionRecordRpc |
|
|
public static class MaterialRequisitionRecordRpc |
|
|
{ |
|
|
{ |
|
|
private static readonly object _insertObj = new object(); |
|
|
|
|
|
|
|
|
[Rpc] |
|
|
|
|
|
public static string GetUnSubmitList() |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(MaterialRequisitionRecord))); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("DeleteState", false), DQCondition.EQ("IsSubmited", false))); |
|
|
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); |
|
|
|
|
|
var list = query.EExecuteDmoList<MaterialRequisitionRecord>("ID", "BarCode", "Goods_Name", "Goods_Code", "Goods_MainUnit", "Weight"); |
|
|
|
|
|
return JsonConvert.SerializeObject(list); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[Rpc] |
|
|
[Rpc] |
|
|
public static long Insert(string json) |
|
|
|
|
|
|
|
|
public static string GetSubmitedList() |
|
|
{ |
|
|
{ |
|
|
lock (_insertObj) |
|
|
|
|
|
{ |
|
|
|
|
|
var record = JsonConvert.DeserializeObject<MaterialRequisitionRecord>(json); |
|
|
|
|
|
record.CreateTime = DateTime.Now; |
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
|
|
{ |
|
|
|
|
|
session.Insert(record); |
|
|
|
|
|
session.Commit(); |
|
|
|
|
|
} |
|
|
|
|
|
return record.ID; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(MaterialRequisitionRecord))); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("IsSubmited", true)); |
|
|
|
|
|
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true)); |
|
|
|
|
|
query.Range = SelectRange.Top(50); |
|
|
|
|
|
|
|
|
|
|
|
var list = query.EExecuteDmoList<MaterialRequisitionRecord>("ID", "BarCode", "Goods_Name", "Goods_Code", "Goods_MainUnit", "Number", "BeforeWeight", "Weight"); |
|
|
|
|
|
|
|
|
|
|
|
return JsonConvert.SerializeObject(list); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static readonly object _updateObj = new object(); |
|
|
|
|
|
[Rpc] |
|
|
[Rpc] |
|
|
public static int Update(string json) |
|
|
|
|
|
|
|
|
public static string GetCodeStoreInfo(string code) |
|
|
{ |
|
|
{ |
|
|
lock (_updateObj) |
|
|
|
|
|
|
|
|
var main = new JoinAlias(typeof(TrunksIousOutInStoreRecord)); |
|
|
|
|
|
var take = new JoinAlias(typeof(MaterialRequisitionRecord)); |
|
|
|
|
|
var query = new DQueryDom(main); |
|
|
|
|
|
query.From.AddJoin(JoinType.Left, new DQDmoSource(take), DQCondition.And(DQCondition.EQ(main, "BarCode", take, "BarCode"), DQCondition.EQ(take, "DeleteState", false))); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("ID", main)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Weight", main)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Name", main)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Store_ID", main)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_ID", main)); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(main, "BarCode", code), DQCondition.IsNull(DQExpression.Field(take, "ID")))); |
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
{ |
|
|
{ |
|
|
var clientRecord = JsonConvert.DeserializeObject<MaterialRequisitionRecordDto>(json); |
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
|
|
|
|
|
using (var reader = session.ExecuteReader(query)) |
|
|
{ |
|
|
{ |
|
|
var record = session.Load(new DmoIdentity(typeof(MaterialRequisitionRecord), clientRecord.Service_ID ?? 0)); |
|
|
|
|
|
if (record == null) |
|
|
|
|
|
|
|
|
while (reader.Read()) |
|
|
{ |
|
|
{ |
|
|
return 0; |
|
|
|
|
|
|
|
|
var r = new MaterialRequisitionRecord(); |
|
|
|
|
|
r.ID = (long)reader[0]; |
|
|
|
|
|
r.Weight = (decimal?)reader[1]; |
|
|
|
|
|
r.Goods_Name = (string)reader[2]; |
|
|
|
|
|
r.Store_ID = (long?)reader[3]; |
|
|
|
|
|
r.Goods_ID = (long?)reader[4]; |
|
|
|
|
|
return JsonConvert.SerializeObject(r); |
|
|
} |
|
|
} |
|
|
DmoUtil.CopyDmoFields(clientRecord, record, "ID", "B3_ID"); |
|
|
|
|
|
session.Update(record); |
|
|
|
|
|
session.Commit(); |
|
|
|
|
|
} |
|
|
} |
|
|
return 1; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
return string.Empty; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Rpc] |
|
|
[Rpc] |
|
|
public static int Delete(long id) |
|
|
|
|
|
|
|
|
public static string Insert(string json) |
|
|
{ |
|
|
{ |
|
|
var delDom = new DQDeleteDom(typeof(MaterialRequisitionRecord)); |
|
|
|
|
|
delDom.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
|
|
|
|
|
|
var record = JsonConvert.DeserializeObject<MaterialRequisitionRecord>(json); |
|
|
using (var session = Dmo.NewSession()) |
|
|
using (var session = Dmo.NewSession()) |
|
|
{ |
|
|
{ |
|
|
session.ExecuteNonQuery(delDom); |
|
|
|
|
|
|
|
|
record.CreateTime = record.ModifyTime = DateTime.Now; |
|
|
|
|
|
FillGoodsInfo(record, session); |
|
|
|
|
|
session.Insert(record); |
|
|
session.Commit(); |
|
|
session.Commit(); |
|
|
} |
|
|
} |
|
|
|
|
|
return JsonConvert.SerializeObject(record); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void FillGoodsInfo(MaterialRequisitionRecord record, IDmoSession session) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = new DQueryDom(new JoinAlias(typeof(ClientGoodsSet_Detail))); |
|
|
|
|
|
query.Where.Conditions.Add(DQCondition.EQ("Goods_ID", record.Goods_ID)); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Name")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_MainUnit")); |
|
|
|
|
|
query.Columns.Add(DQSelectColumn.Field("Goods_Code")); |
|
|
|
|
|
query.Range = SelectRange.Top(1); |
|
|
|
|
|
var r = query.EExecuteScalar<string, string, string>(session); |
|
|
|
|
|
if (r != null) |
|
|
|
|
|
{ |
|
|
|
|
|
record.Goods_Name = r.Item1; |
|
|
|
|
|
record.Goods_MainUnit = r.Item2; |
|
|
|
|
|
record.Goods_Code = r.Item3; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Rpc] |
|
|
|
|
|
public static int FillWeight(long id, decimal weight) |
|
|
|
|
|
{ |
|
|
|
|
|
var update = new DQUpdateDom(typeof(MaterialRequisitionRecord)); |
|
|
|
|
|
update.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("Weight", weight)); |
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
|
|
{ |
|
|
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
|
|
session.Commit(); |
|
|
|
|
|
} |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Rpc] |
|
|
|
|
|
public static int Submit(List<long> arr) |
|
|
|
|
|
{ |
|
|
|
|
|
var update = new DQUpdateDom(typeof(MaterialRequisitionRecord)); |
|
|
|
|
|
update.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("ID"), arr.Select(x => DQExpression.Value(x)).ToArray())); |
|
|
|
|
|
update.Columns.Add(new DQUpdateColumn("IsSubmited", true)); |
|
|
|
|
|
using (var session = Dmo.NewSession()) |
|
|
|
|
|
{ |
|
|
|
|
|
session.ExecuteNonQuery(update); |
|
|
|
|
|
session.Commit(); |
|
|
|
|
|
} |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Rpc] |
|
|
|
|
|
public static int Delete(long id) |
|
|
|
|
|
{ |
|
|
|
|
|
var delete = new DQDeleteDom(typeof(MaterialRequisitionRecord)); |
|
|
|
|
|
delete.Where.Conditions.Add(DQCondition.EQ("ID", id)); |
|
|
|
|
|
delete.EExecute(); |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|