Browse Source

同步 分割大表

master
wugang 8 years ago
parent
commit
27afbb9702
15 changed files with 365 additions and 8 deletions
  1. +6
    -0
      B3ClientService/B3ClientService.csproj
  2. +18
    -0
      B3ClientService/BO/BaseInfo/ProductBatch.cs
  3. +13
    -0
      B3ClientService/BO/BaseInfo/Store.cs
  4. +12
    -0
      B3ClientService/BO/BaseInfo/WorkShop.cs
  5. +14
    -0
      B3ClientService/BO/BaseInfo/WorkUnit.cs
  6. +1
    -0
      B3ClientService/BO/ByProductWeightRecord_/ByProductWeightRecord.cs
  7. +42
    -0
      B3ClientService/BO/SegmentationByPproductTrace_/SegmentationByPproductTrace.cs
  8. +1
    -0
      B3ClientService/BO/SegmentationWeightRecord_/SegmentationWeightRecord.cs
  9. +3
    -0
      B3ClientService/BO/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecord.cs
  10. +29
    -0
      B3ClientService/Rpcs/BaseInfoRpc.cs
  11. +14
    -0
      B3ClientService/Rpcs/BillRpc/ByProductWeightRecordRpc.cs
  12. +15
    -0
      B3ClientService/Rpcs/BillRpc/SegmentationWeightRecordRpc.cs
  13. +64
    -8
      B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc.cs
  14. +71
    -0
      B3ClientService/Tasks/SyncInfoFromServer.cs
  15. +62
    -0
      B3ClientService/Utils/SegmentationByPproductTraceBL.cs

+ 6
- 0
B3ClientService/B3ClientService.csproj View File

@ -82,10 +82,14 @@
<Compile Include="BO\BaseInfo\LiveColonyHouse.cs" />
<Compile Include="BO\BaseInfo\Livestock.cs" />
<Compile Include="BO\BaseInfo\LiveVarieties.cs" />
<Compile Include="BO\BaseInfo\ProductBatch.cs" />
<Compile Include="BO\BaseInfo\PurchaseType.cs" />
<Compile Include="BO\BaseInfo\Sanction.cs" />
<Compile Include="BO\BaseInfo\Store.cs" />
<Compile Include="BO\BaseInfo\Supplier.cs" />
<Compile Include="BO\BaseInfo\WhiteBar.cs" />
<Compile Include="BO\BaseInfo\WorkShop.cs" />
<Compile Include="BO\BaseInfo\WorkUnit.cs" />
<Compile Include="BO\BaseInfo\Zone.cs" />
<Compile Include="BO\Bill\CarcassStateWeight\CarcassStateWeight.cs" />
<Compile Include="BO\Bill\CarcassStateWeight\CarcassStateWeightByCode.cs" />
@ -110,6 +114,7 @@
<Compile Include="BO\ClientGoodsSet_\ClientGoodsSet_Detail.cs" />
<Compile Include="BO\ClientSyncBase.cs" />
<Compile Include="BO\ClientSyncBaseDto.cs" />
<Compile Include="BO\SegmentationByPproductTrace_\SegmentationByPproductTrace.cs" />
<Compile Include="BO\SegmentationInStoreRecord_\SegmentationInStoreRecord.cs" />
<Compile Include="BO\SegmentationWeightRecord_\SegmentationWeightRecord.cs" />
<Compile Include="BO\SyncBase.cs" />
@ -166,6 +171,7 @@
<Compile Include="Tasks\UpdateLoad\UploadTest.cs" />
<Compile Include="Tasks\UpdateLoad\UpLoadWeightBill.cs" />
<Compile Include="ClientServiceUtils.cs" />
<Compile Include="Utils\SegmentationByPproductTraceBL.cs" />
<Compile Include="WordPair.cs" />
</ItemGroup>
<ItemGroup>


+ 18
- 0
B3ClientService/BO/BaseInfo/ProductBatch.cs View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Forks.EnterpriseServices.DomainObjects2;
using TSingSoft.WebPluginFramework;
namespace BWP.B3ClientService.BO
{
[Serializable, BOClass]
[KeyField("ID", KeyGenType.assigned)]
public class ProductBatch
{
public long ID { get; set; }
public string Name { get; set; }
}
}

+ 13
- 0
B3ClientService/BO/BaseInfo/Store.cs View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BWP.B3ClientService.BO
{
[Serializable]
public class Store: BaseInfo
{
}
}

+ 12
- 0
B3ClientService/BO/BaseInfo/WorkShop.cs View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BWP.B3ClientService.BO
{
[Serializable]
public class WorkShop:BaseInfo
{
}
}

+ 14
- 0
B3ClientService/BO/BaseInfo/WorkUnit.cs View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BWP.B3ClientService.BO;
namespace BWP.B3ClientService.BO
{
[Serializable]
public class WorkUnit:BaseInfo
{
public string Code { get; set; }
}
}

+ 1
- 0
B3ClientService/BO/ByProductWeightRecord_/ByProductWeightRecord.cs View File

@ -24,6 +24,7 @@ namespace BWP.B3ClientService.BO
public long Goods_ID { get; set; }
public string Goods_Name { get; set; }
public string Goods_Spec { get; set; }
public decimal PiWeight { get; set; }//皮重


+ 42
- 0
B3ClientService/BO/SegmentationByPproductTrace_/SegmentationByPproductTrace.cs View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using BWP.B3Frameworks.BO;
using Forks.EnterpriseServices.DomainObjects2;
namespace BWP.B3ClientService.BO
{
/// <summary>
/// 分割品入库
/// </summary>
[Serializable]
public class SegmentationByPproductTrace : Base
{
private DateTime mCreateTime = DateTime.Now;
[DbColumn(DbType = SqlDbType.DateTime)]
public DateTime CreateTime { get { return mCreateTime; } set { mCreateTime = value; } }
public string BarCode { get; set; }//条码
public long? Goods_ID { get; set; }
public string Goods_Name { get; set; }
public string Goods_Spec { get; set; }
public decimal Weight { get; set; }
public DateTime? ProductTime { get; set; }//生产时间
public DateTime? InStoreTime { get; set; }//入库时间
public DateTime? SendTime { get; set; }//发货时间
public string Customer_Name { get; set; }
public string CarNumber { get; set; }//车牌
public long? B3SaleOutStore_ID { get; set; }
}
}

+ 1
- 0
B3ClientService/BO/SegmentationWeightRecord_/SegmentationWeightRecord.cs View File

@ -25,6 +25,7 @@ namespace BWP.B3ClientService.BO
public long Goods_ID { get; set; }
public string Goods_Name { get; set; }
public string Goods_Spec { get; set; }
public decimal PiWeight { get; set; }//皮重


+ 3
- 0
B3ClientService/BO/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecord.cs View File

@ -23,5 +23,8 @@ namespace BWP.B3ClientService.BO
public string CarcassStatus { get; set; }// 胴体状态
public bool? IsSubmited { get; set; }//界面有2个状态 待提交 已提交 , 有条码有重量为已提交
public decimal? LossWeight{ get; set; }//损耗
}
}

+ 29
- 0
B3ClientService/Rpcs/BaseInfoRpc.cs View File

@ -10,6 +10,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using Newtonsoft.Json;
using TSingSoft.WebPluginFramework;
namespace BWP.B3ClientService.Rpcs
@ -19,6 +20,34 @@ namespace BWP.B3ClientService.Rpcs
{
static JavaScriptSerializer serializer = new JavaScriptSerializer();
[Rpc]
public static List<WordPair> GetWorkShopList(string input, string args, int top)
{
return GetBaseInfoList<WorkShop>(input, args, top);
}
[Rpc]
public static string GetWorkUnitList()
{
var query = new DmoQuery(typeof(WorkUnit));
var list = query.EExecuteList().Cast<WorkUnit>().ToList();
return JsonConvert.SerializeObject(list);
}
[Rpc]
public static string GetProductBatchList(string input)
{
var query = new DmoQuery(typeof(ProductBatch));
if (!string.IsNullOrEmpty(input))
{
query.Where.Conditions.Add(DQCondition.Like("Name", input));
}
var list = query.EExecuteList().Cast<ProductBatch>().ToList();
return JsonConvert.SerializeObject(list);
}
[Rpc]
public static List<WordPair> GetCarList(string input, string args, int top)
{


+ 14
- 0
B3ClientService/Rpcs/BillRpc/ByProductWeightRecordRpc.cs View File

@ -1,5 +1,6 @@
using System;
using BWP.B3ClientService.BO;
using BWP.B3ClientService.Utils;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.JsonRpc;
using Newtonsoft.Json;
@ -17,10 +18,23 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
using (var session = Dmo.NewSession())
{
session.Insert(record);
var segmentationByPproductTrace = GetSegmentationByPproductTrace(record);
SegmentationByPproductTraceBL.Insert(session, segmentationByPproductTrace);
session.Commit();
}
return record.ID;
}
private static SegmentationByPproductTrace GetSegmentationByPproductTrace(ByProductWeightRecord record)
{
var dmo = new SegmentationByPproductTrace();
dmo.BarCode = record.BarCode;
dmo.Goods_ID = record.Goods_ID;
dmo.Goods_Name = record.Goods_Name;
dmo.Weight = record.JingWeight;
dmo.Goods_Spec = record.Goods_Spec;
dmo.ProductTime = record.CreateTime;
return dmo;
}
}
}

+ 15
- 0
B3ClientService/Rpcs/BillRpc/SegmentationWeightRecordRpc.cs View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using BWP.B3ClientService.BO;
using BWP.B3ClientService.Utils;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.JsonRpc;
@ -22,11 +23,25 @@ namespace BWP.B3ClientService.Rpcs.BillRpc
using (var session=Dmo.NewSession())
{
session.Insert(record);
var segmentationByPproductTrace = GetSegmentationByPproductTrace(record);
SegmentationByPproductTraceBL.Insert(session, segmentationByPproductTrace);
session.Commit();
}
return record.ID;
}
private static SegmentationByPproductTrace GetSegmentationByPproductTrace(SegmentationWeightRecord record)
{
var dmo = new SegmentationByPproductTrace();
dmo.BarCode = record.BarCode;
dmo.Goods_ID = record.Goods_ID;
dmo.Goods_Name = record.Goods_Name;
dmo.Weight = record.JingWeight;
dmo.Goods_Spec = record.Goods_Spec;
dmo.ProductTime = record.CreateTime;
return dmo;
}
/// <summary>
/// 获取为入库的
/// </summary>


+ 64
- 8
B3ClientService/Rpcs/BillRpc/TrunksIousOutInStoreRecord_/TrunksIousOutInStoreRecordRpc.cs View File

@ -4,20 +4,59 @@ using BWP.B3Frameworks.Utils;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.JsonRpc;
using Forks.EnterpriseServices.SqlDoms;
using Newtonsoft.Json;
using TSingSoft.WebPluginFramework;
namespace BWP.B3ClientService.Rpcs.BillRpc.TrunksIousOutInStoreRecord_
{
//todo 这里需要维护大表
[Rpc]
public static class TrunksIousOutInStoreRecordRpc
{
[Rpc]
public static string GetUnSubmitList()
{
var query = new DQueryDom(new JoinAlias(typeof(TrunksIousOutInStoreRecord)));
query.Where.Conditions.Add(DQCondition.Or(DQCondition.IsNull(DQExpression.Field("IsSubmited")), DQCondition.EQ("IsSubmited", false)));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true));
var list = query.EExecuteDmoList<TrunksIousOutInStoreRecord>("ID", "BarCode", "Goods_Name", "Number", "Weight", "LossWeight");
return JsonConvert.SerializeObject(list);
}
[Rpc]
public static string GetSubmitedList()
{
var query = new DQueryDom(new JoinAlias(typeof(TrunksIousOutInStoreRecord)));
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<TrunksIousOutInStoreRecord>("ID", "BarCode", "Goods_Name", "Number", "Weight", "LossWeight");
return JsonConvert.SerializeObject(list);
}
[Rpc]
public static long SetWeight(long id,decimal weight)
{
var query = new DQUpdateDom(typeof(TrunksIousOutInStoreRecord));
query.Columns.Add(new DQUpdateColumn("Weight", weight));
query.Columns.Add(new DQUpdateColumn("IsSubmited", true));
// query.Columns.Add(new DQUpdateColumn("LossWeight", ));
//todo 这里要算损耗
query.Where.Conditions.Add(DQCondition.EQ("ID", id));
query.EExecute();
return id;
}
[Rpc]
public static long Insert(string json)
{
var clientRecord = JsonConvert.DeserializeObject<TrunksIousOutInStoreRecordDto>(json);
using (var session=Dmo.NewSession())
using (var session = Dmo.NewSession())
{
var record = new TrunksIousOutInStoreRecord();
DmoUtil.CopyDmoFields(clientRecord, record, "ID", "B3_ID");
@ -25,17 +64,34 @@ namespace BWP.B3ClientService.Rpcs.BillRpc.TrunksIousOutInStoreRecord_
session.Commit();
return record.ID;
}
}
[Rpc]
public static long SimpleInsert(long goodsId,string goodsName,string barCode)
{
using (var session = Dmo.NewSession())
{
var record = new TrunksIousOutInStoreRecord();
record.Goods_ID = goodsId;
record.Goods_Name = goodsName;
record.BarCode = barCode;
record.IsSubmited = false;
session.Insert(record);
session.Commit();
return record.ID;
}
}
[Rpc]
public static int Update(string json)
{
var clientRecord = JsonConvert.DeserializeObject<TrunksIousOutInStoreRecordDto>(json);
using (var session=Dmo.NewSession())
using (var session = Dmo.NewSession())
{
var record = session.Load(new DmoIdentity(typeof(TrunksIousOutInStoreRecord), clientRecord.Service_ID??0));
DmoUtil.CopyDmoFields(clientRecord,record,"ID", "B3_ID");
var record = session.Load(new DmoIdentity(typeof(TrunksIousOutInStoreRecord), clientRecord.Service_ID ?? 0));
DmoUtil.CopyDmoFields(clientRecord, record, "ID", "B3_ID");
session.Update(record);
}
return 1;
@ -45,8 +101,8 @@ namespace BWP.B3ClientService.Rpcs.BillRpc.TrunksIousOutInStoreRecord_
public static int Delete(long id)
{
var delDom = new DQDeleteDom(typeof(TrunksIousOutInStoreRecord));
delDom.Where.Conditions.Add(DQCondition.EQ("ID",id));
using (var session=Dmo.NewSession())
delDom.Where.Conditions.Add(DQCondition.EQ("ID", id));
using (var session = Dmo.NewSession())
{
session.Update(delDom);
}


+ 71
- 0
B3ClientService/Tasks/SyncInfoFromServer.cs View File

@ -57,11 +57,82 @@ namespace BWP.B3ClientService.Tasks
SyncClientGoodsSet();
SyncCustomer();
SyncDeliverGoodsLine();
SyncWorkShop();
SyncWorkUnit();
SyncProductBatch();
SyncStore();
}
//catch
{ }
}
private void SyncStore()
{
var json = RpcFacade.Call<string>("/MainSystem/B3ButcherManageForClient/Rpcs/BaseInfoRpc/SyncStoreList");
var list = JsonConvert.DeserializeObject<List<BO.Store>>(json);
using (var context = new TransactionContext())
{
var sql1 = @"truncate table [B3ClientService_Store];";
context.Session.ExecuteSqlNonQuery(sql1);
foreach (BO.Store dmo in list)
{
context.Session.Insert(dmo);
}
context.Commit();
}
}
private void SyncProductBatch()
{
var json = RpcFacade.Call<string>("/MainSystem/B3ButcherManage/Rpcs/TouchScreenRpcs/SyncProductBatch");
var list = JsonConvert.DeserializeObject<List<ProductBatch>>(json);
using (var context = new TransactionContext())
{
var sql1 = @"truncate table [B3ClientService_ProductBatch];";
context.Session.ExecuteSqlNonQuery(sql1);
foreach (ProductBatch dmo in list)
{
// var dmo = new ProductBatch();
// dmo.Name = name;
context.Session.Insert(dmo);
}
context.Commit();
}
}
private void SyncWorkUnit()
{
var json = RpcFacade.Call<string>("/MainSystem/B3ButcherManageForClient/Rpcs/BaseInfoRpc/SyncWorkUnitList");
var list = JsonConvert.DeserializeObject<List<WorkUnit>>(json);
using (var context = new TransactionContext())
{
var sql1 = @"truncate table [B3ClientService_WorkUnit];";
context.Session.ExecuteSqlNonQuery(sql1);
foreach (WorkUnit dmo in list)
{
context.Session.Insert(dmo);
}
context.Commit();
}
}
private void SyncWorkShop()
{
var json = RpcFacade.Call<string>("/MainSystem/B3ButcherManageForClient/Rpcs/BaseInfoRpc/SyncWorkShopList");
var list = JsonConvert.DeserializeObject<List<WorkShop>>(json);
using (var context = new TransactionContext())
{
var sql1 = @"truncate table [B3ClientService_WorkShop];";
context.Session.ExecuteSqlNonQuery(sql1);
foreach (WorkShop dmo in list)
{
context.Session.Insert(dmo);
}
context.Commit();
}
}
private void SyncDeliverGoodsLine()
{
var json = RpcFacade.Call<string>("/MainSystem/B3Sale/Rpcs/OffLineRpc/OffLineBaseInfo/OffLineBaseInfoRpc/SyncDeliverGoodsLineList");


+ 62
- 0
B3ClientService/Utils/SegmentationByPproductTraceBL.cs View File

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BWP.B3ClientService.BO;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using TSingSoft.WebPluginFramework;
namespace BWP.B3ClientService.Utils
{
public class SegmentationByPproductTraceBL
{
public static long Insert(IDmoSession session, SegmentationByPproductTrace dmo)
{
session.Insert(dmo);
return dmo.ID;
}
public static void SetInStoreTime(string barCode, DateTime inStoreTime)
{
using (var session = Dmo.NewSession())
{
var id = CheckIsExistByBarCode(session, barCode);
var dqupdateDom = new DQUpdateDom(typeof(SegmentationByPproductTrace));
dqupdateDom.Where.Conditions.Add(DQCondition.EQ("ID", id));
dqupdateDom.Columns.Add(new DQUpdateColumn("InStoreTime", inStoreTime));
session.ExecuteNonQuery(dqupdateDom);
session.Commit();
}
}
public static void SetSendInfo(string barCode, DateTime sendTime,string customerName,string carNumber,long? saleOutStoreId=null)
{
using (var session = Dmo.NewSession())
{
var id = CheckIsExistByBarCode(session, barCode);
var dqupdateDom = new DQUpdateDom(typeof(SegmentationByPproductTrace));
dqupdateDom.Where.Conditions.Add(DQCondition.EQ("ID", id));
dqupdateDom.Columns.Add(new DQUpdateColumn("SendTime", sendTime));
dqupdateDom.Columns.Add(new DQUpdateColumn("CarNumber", carNumber));
dqupdateDom.Columns.Add(new DQUpdateColumn("Customer_Name", customerName));
dqupdateDom.Columns.Add(new DQUpdateColumn("B3SaleOutStore_ID", saleOutStoreId));
session.ExecuteNonQuery(dqupdateDom);
session.Commit();
}
}
private static long CheckIsExistByBarCode(IDmoSessionWithTransaction session, string barCode)
{
var query = new DQueryDom(new JoinAlias(typeof(SegmentationByPproductTrace)));
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode));
query.Columns.Add(DQSelectColumn.Field("ID"));
var res = query.EExecuteScalar<long?>(session);
if (res == null)
{
throw new Exception("不存在条码为:" + barCode + " 的记录");
}
return res.Value;
}
}
}

Loading…
Cancel
Save