Browse Source

完善业务。

master
yibo 7 years ago
parent
commit
15f9e70aac
9 changed files with 295 additions and 20 deletions
  1. +3
    -1
      B3ClientService/B3ClientService.csproj
  2. +101
    -0
      B3ClientService/BO/Bill/CarcassFullInfo.cs
  3. +6
    -0
      B3ClientService/NamedValueTemplate.cs
  4. +81
    -3
      B3ClientService/OfflinRpc/CarcassInStoreRpc.cs
  5. +18
    -0
      B3ClientService/OfflinRpc/ExtensionObj.cs
  6. +75
    -0
      B3ClientService/OfflinRpc/GradeAndWeightBL.cs
  7. +0
    -14
      B3ClientService/OfflinRpc/SimpleBackObjs.cs
  8. +7
    -2
      B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs
  9. +4
    -0
      WebFolder/config/NamedValue/B3ClientService.xml

+ 3
- 1
B3ClientService/B3ClientService.csproj View File

@ -101,6 +101,7 @@
<Compile Include="BO\BaseInfo\WorkShop.cs" />
<Compile Include="BO\BaseInfo\WorkUnit.cs" />
<Compile Include="BO\BaseInfo\Zone.cs" />
<Compile Include="BO\Bill\CarcassFullInfo.cs" />
<Compile Include="BO\Bill\CarcassStateWeight\CarcassStateWeight.cs" />
<Compile Include="BO\Bill\CarcassStateWeight\CarcassStateWeightByCode.cs" />
<Compile Include="BO\Bill\CarcassStateWeight\CarcassStateWeightInStore.cs" />
@ -148,8 +149,9 @@
<Compile Include="NamedValueTemplate.cs" />
<Compile Include="OfflinRpc\BaseInfoRpc.cs" />
<Compile Include="OfflinRpc\CarcassInStoreRpc.cs" />
<Compile Include="OfflinRpc\ExtensionObj.cs" />
<Compile Include="OfflinRpc\GradeAndWeightBL.cs" />
<Compile Include="OfflinRpc\LoginRpc.cs" />
<Compile Include="OfflinRpc\SimpleBackObjs.cs" />
<Compile Include="Rpcs\BillRpc\BaseInfoRpc.cs" />
<Compile Include="Rpcs\BillRpc\BeforeDeathRpc.cs" />
<Compile Include="Rpcs\BillRpc\ByProductWeightRecordRpc.cs" />


+ 101
- 0
B3ClientService/BO/Bill/CarcassFullInfo.cs View File

@ -0,0 +1,101 @@
using BWP.B3ClientService.NamedValueTemplate;
using BWP.B3Frameworks.BO;
using Forks.EnterpriseServices;
using Forks.EnterpriseServices.DataDictionary;
using Forks.EnterpriseServices.DataForm;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.Utils;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace BWP.B3ClientService.BO
{
[DBIndex("IDX_B3ClientService_CarcassFullInfo_Clustered", "BarCode", false, 0)]
[DBIndexType("IDX_B3ClientService_CarcassFullInfo_Clustered", IndexType.Normal)]
[DFClass]
[LogicName("白条数据表")]
public class CarcassFullInfo : Base
{
public CarcassFullInfo()
{
CreateTime = DateTime.Now;
}
[DbColumn(DbType = SqlDbType.DateTime)]
[LogicName("创建时间")]
public DateTime CreateTime { get; set; }
[DbColumn(AllowNull = false, Unique = true)]
[LogicName("条码")]
public string BarCode { get; set; }
#region 定级信息
[LogicName("屠宰日期")]
public DateTime? ButcherDate { get; set; }
[DbColumn(DbType = SqlDbType.DateTime)]
[LogicName("定级时间")]
public DateTime? GradeTime { get; set; }
[LogicName("定级员")]
public long? GradeWorker_ID { get; set; }
[LogicName("胴体级别")]
public long? Livestock_ID { get; set; }
[LogicName("胴体重量")]
public decimal? GradeWeight { get; set; }
#endregion
#region 入库信息
[LogicName("入库员")]
public long? InStoreWorker_ID { get; set; }
[LogicName("工作单元")]
public long? WorkUnit_ID { get; set; }
[LogicName("生产批次")]
public long? ProductBatch_ID { get; set; }
[LogicName("入库存货")]
public long? InStoreGoods_ID { get; set; }
[LogicName("入库重量")]
public decimal? InStoreWeight { get; set; }
[LogicName("入库时间")]
[DbColumn(DbType = SqlDbType.DateTime)]
public DateTime? InStoreTime { get; set; }
#endregion
#region 领用信息
[LogicName("领用人员")]
public long? PickWorker_ID { get; set; }
[LogicName("领用时间")]
public DateTime? PickTime { get; set; }
[LogicName("领用类型")]
public NamedValue<>? PickType { get; set; }
[LogicName("销售存货")]
public long? SaleGoods_ID { get; set; }
[LogicName("领用重量")]
public decimal? PickWeight { get; set; }
[LogicName("领用重量")]
public long? PickGroupID { get; set; }
#endregion
}
}

+ 6
- 0
B3ClientService/NamedValueTemplate.cs View File

@ -27,4 +27,10 @@ namespace BWP.B3ClientService.NamedValueTemplate
public static readonly NamedValue<> = new NamedValue<>(1);
public static readonly NamedValue<> = new NamedValue<>(2);
}
public sealed class
{
public static readonly NamedValue<> = new NamedValue<>(0);
public static readonly NamedValue<> = new NamedValue<>(1);
}
}

+ 81
- 3
B3ClientService/OfflinRpc/CarcassInStoreRpc.cs View File

@ -45,6 +45,8 @@ namespace BWP.B3ClientService.Rpcs
{
if (string.IsNullOrEmpty(barCode))
throw new Exception("编码为空");
if (barCode.Length != 23)
throw new Exception("条码格式不正确");
using (var session = Dmo.NewSession())
{
var id = CheckExist(barCode, session);
@ -116,7 +118,7 @@ namespace BWP.B3ClientService.Rpcs
[Rpc(RpcFlags.SkipAuth)]
public static int SetPadDataSync(string backInfo)
{
var arr = JsonConvert.DeserializeObject<List<IDRowVersion>>(backInfo);
var arr = JsonConvert.DeserializeObject<List<ExtensionObj>>(backInfo);
using (var session = Dmo.NewSession())
{
foreach (var item in arr)
@ -126,17 +128,80 @@ namespace BWP.B3ClientService.Rpcs
return 1;
}
static void UpdateSynced(IDRowVersion info, IDmoSession session)
static void UpdateSynced(ExtensionObj 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)));
update.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("ID", info.LongExt1), DQCondition.EQ("RowVersion", info.DecimalExt1)));
session.ExecuteNonQuery(update);
}
#endregion
[Rpc(RpcFlags.SkipAuth)]
public static int UploadCarcassInfo(string json)
{
var list = JsonConvert.DeserializeObject<List<CarcassInStoreObj>>(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, CarcassInStoreObj obj, IDmoSession session)
{
var update = new DQUpdateDom(typeof(CarcassFullInfo));
update.Columns.Add(new DQUpdateColumn("InStoreWorker_ID", obj.InStoreWorker_ID));
update.Columns.Add(new DQUpdateColumn("WorkUnit_ID", obj.WorkUnit_ID));
update.Columns.Add(new DQUpdateColumn("ProductBatch_ID", obj.ProductBatch_ID));
update.Columns.Add(new DQUpdateColumn("InStoreGoods_ID", obj.InStoreGoods_ID));
update.Columns.Add(new DQUpdateColumn("InStoreWeight", obj.InStoreWeight));
update.Columns.Add(new DQUpdateColumn("InStoreTime", obj.InStoreTime));
update.Where.Conditions.Add(DQCondition.EQ("ID", id));
session.ExecuteNonQuery(update);
}
static void Insert(CarcassInStoreObj obj, IDmoSession session)
{
var entity = new CarcassFullInfo();
entity.BarCode = obj.BarCode;
entity.InStoreWorker_ID = obj.InStoreWorker_ID;
entity.WorkUnit_ID = obj.WorkUnit_ID;
entity.ProductBatch_ID = obj.ProductBatch_ID;
entity.InStoreGoods_ID = obj.InStoreGoods_ID;
entity.InStoreWeight = obj.InStoreWeight;
entity.InStoreTime = obj.InStoreTime;
session.Insert(entity);
}
[Rpc(RpcFlags.SkipAuth)]
public static string GetWeightInfo(List<string> codeList)
{
var query = new DQueryDom(new JoinAlias(typeof(CarcassFullInfo)));
query.Columns.Add(DQSelectColumn.Field("BarCode"));
query.Columns.Add(DQSelectColumn.Field("GradeWeight"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field("GradeWeight")), DQCondition.InList(DQExpression.Field("BarCode"), codeList.Select(x => DQExpression.Value(x)).ToArray())));
var result = query.EExecuteList<string, decimal?>();
var back = result.Select(x => new ExtensionObj { StringExt1 = x.Item1, DecimalExt1 = x.Item2 });
return JsonConvert.SerializeObject(back);
}
}
class MinGoodsObj
@ -144,4 +209,17 @@ namespace BWP.B3ClientService.Rpcs
public long Goods_ID { get; set; }
public string Goods_Name { get; set; }
}
class CarcassInStoreObj
{
public long ID { get; set; }
public int RowVersion { get; set; }
public string BarCode { get; set; }
public long? InStoreWorker_ID { get; set; }
public long? WorkUnit_ID { get; set; }
public long? ProductBatch_ID { get; set; }
public long? InStoreGoods_ID { get; set; }
public decimal? InStoreWeight { get; set; }
public DateTime? InStoreTime { get; set; }
}
}

+ 18
- 0
B3ClientService/OfflinRpc/ExtensionObj.cs View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BWP.B3ClientService.BO
{
public class ExtensionObj
{
public long? LongExt1 { get; set; }
public long? LongExt2 { get; set; }
public decimal? DecimalExt1 { get; set; }
public string StringExt1 { get; set; }
}
}

+ 75
- 0
B3ClientService/OfflinRpc/GradeAndWeightBL.cs View File

@ -0,0 +1,75 @@
using BWP.B3ClientService.BO;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TSingSoft.WebPluginFramework;
namespace BWP.B3ClientService.BL
{
public static class GradeAndWeightBL
{
public static void UpdataOrInsert(GradeAndWeight_Detail obj, IDmoSession session)
{
if (string.IsNullOrEmpty(obj.BarCode))
return;
var id = GetID(obj.BarCode, session);
if (id.HasValue)
Update(id.Value, obj, session);
else
Insert(obj, session);
}
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, GradeAndWeight_Detail obj, IDmoSession session)
{
var update = new DQUpdateDom(typeof(CarcassFullInfo));
update.Columns.Add(new DQUpdateColumn("ButcherDate", obj.Date));
update.Columns.Add(new DQUpdateColumn("GradeTime", obj.Time));
//update.Columns.Add(new DQUpdateColumn("GradeWorker_ID", obj.Worker_ID));
update.Columns.Add(new DQUpdateColumn("Livestock_ID", obj.Livestock_ID));
update.Columns.Add(new DQUpdateColumn("GradeWeight", obj.Weight));
update.Where.Conditions.Add(DQCondition.EQ("ID", id));
session.ExecuteNonQuery(update);
}
static void Insert(GradeAndWeight_Detail obj, IDmoSession session)
{
var entity = new CarcassFullInfo();
entity.BarCode = obj.BarCode;
entity.ButcherDate = obj.Date;
entity.GradeTime = obj.Time;
//entity.GradeWorker_ID = obj.Worker_ID;
entity.Livestock_ID = obj.Livestock_ID;
entity.GradeWeight = obj.Weight;
session.Insert(entity);
}
public static void Delete(string barCode, IDmoSession session)
{
if (string.IsNullOrEmpty(barCode))
return;
var id = GetID(barCode, session);
if (id == null)
return;
var update = new DQUpdateDom(typeof(CarcassFullInfo));
update.Columns.Add(new DQUpdateColumn("ButcherDate", null));
update.Columns.Add(new DQUpdateColumn("GradeTime", null));
//update.Columns.Add(new DQUpdateColumn("GradeWorker_ID", obj.));
update.Columns.Add(new DQUpdateColumn("Livestock_ID", null));
update.Columns.Add(new DQUpdateColumn("GradeWeight", null));
update.Where.Conditions.Add(DQCondition.EQ("ID", id));
session.ExecuteNonQuery(update);
}
}
}

+ 0
- 14
B3ClientService/OfflinRpc/SimpleBackObjs.cs View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BWP.B3ClientService.Rpcs
{
public class IDRowVersion
{
public long ID { get; set; }
public int RowVersion { get; set; }
}
}

+ 7
- 2
B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc.cs View File

@ -1,4 +1,5 @@
using BWP.B3ClientService.BO;
using BWP.B3ClientService.BL;
using BWP.B3ClientService.BO;
using BWP.B3ClientService.RpcBO;
using BWP.B3ClientService.Rpcs.RpcBO;
using BWP.B3Frameworks.Utils;
@ -73,7 +74,10 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
using (var session = Dmo.NewSession())
{
if (entity.IsDeleted)
{
GradeAndWeightBL.Delete(entity.BarCode, session);
session.Delete(new DmoIdentity(typeof(GradeAndWeight_Detail), entity.ID));
}
else
{
entity.ID = GetIDIfExist(session, entity.SID) ?? 0;
@ -81,6 +85,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
session.Insert(entity);
else
session.Update(entity);
GradeAndWeightBL.UpdataOrInsert(entity, session);
}
session.Commit();
}
@ -152,7 +157,7 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
var list = new List<DataConfirmList>();
while (reader.Read())
{
list.Add(new DataConfirmList { Order = (int)reader[0], PlanNumber = (int)reader[1], HotFadeNumber = (int?)reader[2] ?? 0 ,WeightID=(long?)reader[3]});
list.Add(new DataConfirmList { Order = (int)reader[0], PlanNumber = (int)reader[1], HotFadeNumber = (int?)reader[2] ?? 0, WeightID = (long?)reader[3] });
}
return serializer.Serialize(list);
}


+ 4
- 0
WebFolder/config/NamedValue/B3ClientService.xml View File

@ -16,4 +16,8 @@
<Word name="分割品" value="1"/>
<Word name="副产品" value="2"/>
</NamedValue>
<NamedValue type="BWP.B3ClientService.NamedValueTemplate.领用类型, B3ClientService">
<Word name="分割领用" value="0"/>
<Word name="白条销售" value="1"/>
</NamedValue>
</NamedValueSettings>

Loading…
Cancel
Save