From 4867e9fe4d23420d51d425281874852a6aa9c082 Mon Sep 17 00:00:00 2001
From: yibo <361071264@qq.com>
Date: Wed, 13 Sep 2017 21:34:27 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
B3ClientService/B3ClientService.csproj | 10 +-
B3ClientService/MapBO/WeightBill/WeighBill.cs | 166 -----------
.../WeightBill/Weigh_AbnormalRecording.cs | 50 ----
.../MapBO/WeightBill/Weigh_FarmerDetail.cs | 41 ---
.../MapBO/WeightBill/Weigh_Record.cs | 91 ------
.../RpcBO/Bill/WeightBill/RpcWeightBill.cs | 27 ++
.../RpcBO/Bill/WeightBill/SWeightBill.cs | 49 +++
.../Bill/WeightBill/SWeightBill_Detail.cs | 24 ++
.../WeightBill/SWeightBill_FarmerDetail.cs | 20 ++
.../WeightBill/SWeightBill_SanctionDetail.cs | 23 ++
.../Tasks/UpdateLoad/UpLoadWeightBill.cs | 281 ++++++++----------
.../Tasks/UpdateLoad/UploadTest.cs | 43 +--
12 files changed, 282 insertions(+), 543 deletions(-)
delete mode 100644 B3ClientService/MapBO/WeightBill/WeighBill.cs
delete mode 100644 B3ClientService/MapBO/WeightBill/Weigh_AbnormalRecording.cs
delete mode 100644 B3ClientService/MapBO/WeightBill/Weigh_FarmerDetail.cs
delete mode 100644 B3ClientService/MapBO/WeightBill/Weigh_Record.cs
create mode 100644 B3ClientService/RpcBO/Bill/WeightBill/RpcWeightBill.cs
create mode 100644 B3ClientService/RpcBO/Bill/WeightBill/SWeightBill.cs
create mode 100644 B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_Detail.cs
create mode 100644 B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_FarmerDetail.cs
create mode 100644 B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_SanctionDetail.cs
diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj
index 1535a70..9b0a91b 100644
--- a/B3ClientService/B3ClientService.csproj
+++ b/B3ClientService/B3ClientService.csproj
@@ -87,11 +87,12 @@
-
-
-
-
+
+
+
+
+
@@ -103,6 +104,7 @@
+
diff --git a/B3ClientService/MapBO/WeightBill/WeighBill.cs b/B3ClientService/MapBO/WeightBill/WeighBill.cs
deleted file mode 100644
index 64881b8..0000000
--- a/B3ClientService/MapBO/WeightBill/WeighBill.cs
+++ /dev/null
@@ -1,166 +0,0 @@
-using BWP.B3Frameworks;
-using BWP.B3Frameworks.BO;
-using Forks.EnterpriseServices;
-using Forks.EnterpriseServices.DataForm;
-using Forks.EnterpriseServices.DomainObjects2;
-using System;
-using Forks.Utils;
-using TSingSoft.WebControls2;
-using BWP.B3Frameworks.Utils;
-using BWP.B3Frameworks.BO.MoneyTemplate;
-using TSingSoft.WebPluginFramework;
-
-
-namespace BWP.B3ClientService.MapBO
-{
- [Serializable]
- [LogicName("过磅单")]
- [BOClass(Exclude = true)]
-
- public class WeighBill : DomainBill
- {
- [LogicName("会计单位")]
- public long? AccountingUnit_ID { get; set; }
-
- [LogicName("来源地")]
- public long? Zone_ID { get; set; }
-
- //[ReferenceTo(typeof(Zone1), "Depth")]
- //[Join("Zone_ID", "ID")]
- //public int? Zone_Depth { get; set; }
-
- //[ReferenceTo(typeof(Zone1), "Name")]
- //[Join("Zone_ID", "ID")]
- //[LogicName("区域")]
- //public string Zone_Name { get; set; }
-
- //[ReferenceTo(typeof(Zone1), "TreeDeep1_Name")]
- //[Join("Zone_ID", "ID")]
- //[LogicName("一级区域")]
- //public string TreeDeep1_Name { get; set; }
-
- //[ReferenceTo(typeof(Zone1), "TreeDeep2_Name")]
- //[Join("Zone_ID", "ID")]
- //[LogicName("二级区域")]
- //public string TreeDeep2_Name { get; set; }
-
- //[NonDmoProperty]
- //[DFPrompt("区域树形名称")]
- //public string Zone_TreeName
- //{
- // get { return TreeUtil.GetTreePrefix(Zone_Depth) + Zone_Name; }
- //}
-
- [LogicName("部门")]
- public long? Department_ID { get; set; }
-
- [LogicName("供应商")]
- public long? Supplier_ID { get; set; }
-
- DateTime dt = DateTime.Now;
- [LogicName("过磅时间")]
- public DateTime? WeighTime { get { return dt; } set { dt = (DateTime)value; } }
-
- //[LogicName("收购头数")]
- //[DFExtProperty("WebControlType", DFEditControl.StaticText)]
- //public int? BuyNum { get; set; }
-
- //[LogicName("收购重量")]
- //[DFExtProperty("WebControlType", DFEditControl.StaticText)]
- //public Money? BuyWeigh1 { get; set; }
-
- [LogicName("棚前单价")]
- public Money? ShackPrice { get; set; }
-
- [LogicName("棚前重量")]
- public Money? ShackWeight { get; set; }
-
- [LogicName("棚前金额")]
- //[DFExtProperty("WebControlType", DFEditControl.StaticText)]
- public Money<金额>? ShackMoney { get; set; }
-
- [LogicName("收购类型")]
- public short? PurchaseType { get; set; }
-
- [LogicName("定价单")]
- public long? FixedPrice_ID { get; set; }
-
- [LogicName("车辆")]
- public long? Car_ID { get; set; }
-
- [LogicName("验质员")]
- public long? Inspector_ID { get; set; }
-
- [LogicName("动检号")]
- public string AnimalTestNumber { get; set; }
-
- [LogicName("动检日期")]
- public DateTime? AnimalTestDate { get; set; }
-
- [LogicName("动检员")]
- public string AnimalTestMan { get; set; }
-
- //[ReferenceTo(typeof(AccountingUnit), "Name")]
- //[Join("AccountingUnit_ID", "ID")]
- //[DFPrompt("会计单位")]
- //public string AccountingUnit_Name { get; set; }
-
- //[Join("Department_ID", "ID")]
- //[LogicName("部门名称")]
- //[ReferenceTo(typeof(Department), "Name")]
- //public string Department_Name { get; set; }
-
- //[Join("Supplier_ID", "ID")]
- //[LogicName("供应商")]
- //[ReferenceTo(typeof(Supplier), "Name")]
- //public string Supplier_Name { get; set; }
-
- //[Join("Supplier_ID", "ID")]
- //[LogicName("联系方式")]
- //[ReferenceTo(typeof(Supplier), "Tel")]
- //public string Supplier_Tel { get; set; }
-
- [LogicName("车牌号")]
- public string CarNo { get; set; }
-
- //[ReferenceTo(typeof(Car), "Name")]
- //[Join("Car_ID", "ID")]
- //[DFPrompt("车辆")]
- //public string Car_Name { get; set; }
-
- //[Join("Inspector_ID", "ID")]
- //[LogicName("验质员")]
- //[ReferenceTo(typeof(Employee), "Name")]
- //public string Inspector_Name { get; set; }
-
- private Weigh_RecordCollection mWeighRecord = new Weigh_RecordCollection();
- [OneToMany(typeof(Weigh_Record), "ID")]
- [Join("ID", "Weigh_ID")]
- public Weigh_RecordCollection WeighRecord
- {
- get { return mWeighRecord; }
- set { mWeighRecord = value; }
- }
-
- private Weigh_AbnormalRecordingCollection mWeighAbnormalRecording = new Weigh_AbnormalRecordingCollection();
- [OneToMany(typeof(Weigh_AbnormalRecording), "ID")]
- [Join("ID", "Weigh_ID")]
- public Weigh_AbnormalRecordingCollection WeighAbnormalRecording
- {
- get { return mWeighAbnormalRecording; }
- set { mWeighAbnormalRecording = value; }
- }
-
- private Weigh_FarmerDetailCollection mFarmerDetails = new Weigh_FarmerDetailCollection();
- [OneToMany(typeof(Weigh_FarmerDetail), "ID")]
- [Join("ID", "Weigh_ID")]
- public Weigh_FarmerDetailCollection FarmerDetails
- {
- get { return mFarmerDetails; }
- set { mFarmerDetails = value; }
- }
-
- [LogicName("外部ID")]
- public long? CID { get; set; }
- }
-}
diff --git a/B3ClientService/MapBO/WeightBill/Weigh_AbnormalRecording.cs b/B3ClientService/MapBO/WeightBill/Weigh_AbnormalRecording.cs
deleted file mode 100644
index 02fd648..0000000
--- a/B3ClientService/MapBO/WeightBill/Weigh_AbnormalRecording.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-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.Linq;
-using System.Text;
-using TSingSoft.WebPluginFramework;
-
-namespace BWP.B3ClientService.MapBO
-{
-
- [LogicName("过磅记录")]
- [Serializable]
- [BOClass(Exclude = true)]
- public class Weigh_AbnormalRecording : Base
- {
- public long? Weigh_ID { get; set; }
-
- [LogicName("奖罚设置")]
- public long? Sanction_ID { get; set; }
-
- [LogicName("头数")]
- public int Num { get; set; }
-
- [LogicName("单价")]
- public Money? UnitPrice { get; set; }
-
- [LogicName("金额")]
- public Money? Abnormal_Money { get; set; }
-
- //[LogicName("异常项目")]
- //public string Abnormal_Name { get; set; }
-
- [LogicName("异常项目ID")]
- public long? AbnormalItem_ID { get; set; }
-
- [LogicName("外部ID")]
- public long? CID { get; set; }
- }
-
- [Serializable]
- public class Weigh_AbnormalRecordingCollection : DmoCollection
- {
-
- }
-}
diff --git a/B3ClientService/MapBO/WeightBill/Weigh_FarmerDetail.cs b/B3ClientService/MapBO/WeightBill/Weigh_FarmerDetail.cs
deleted file mode 100644
index 7090708..0000000
--- a/B3ClientService/MapBO/WeightBill/Weigh_FarmerDetail.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using BWP.B3Frameworks.BO;
-using Forks.EnterpriseServices;
-using Forks.EnterpriseServices.DataDictionary;
-using Forks.EnterpriseServices.DataForm;
-using Forks.EnterpriseServices.DomainObjects2;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using TSingSoft.WebPluginFramework;
-
-namespace BWP.B3ClientService.MapBO
-{
- [LogicName("过磅单_养殖户信息")]
- [Serializable]
- [BOClass(Exclude = true)]
- public class Weigh_FarmerDetail : Base
- {
- [LogicName("过磅记录ID")]
- public long Weigh_ID { get; set; }
-
- [LogicName("养殖户")]
- public long? Farmer_ID { get; set; }
-
- //[LogicName("养殖户")]
- //public string Farmer_Name { get; set; }
-
- [LogicName("头数")]
- public int? Number { get; set; }
-
- [LogicName("重量")]
- public decimal? Weight { get; set; }
-
- [LogicName("外部ID")]
- public long? CID { get; set; }
- }
-
- [Serializable]
- public class Weigh_FarmerDetailCollection : DmoCollection
- { }
-}
diff --git a/B3ClientService/MapBO/WeightBill/Weigh_Record.cs b/B3ClientService/MapBO/WeightBill/Weigh_Record.cs
deleted file mode 100644
index 829743c..0000000
--- a/B3ClientService/MapBO/WeightBill/Weigh_Record.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-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.Linq;
-using System.Text;
-using BWP.B3Frameworks.BO.MoneyTemplate;
-using TSingSoft.WebPluginFramework;
-
-namespace BWP.B3ClientService.MapBO
-{
- [LogicName("过磅记录")]
- [Serializable]
- [BOClass(Exclude = true)]
- public class Weigh_Record : Base
- {
- [LogicName("过磅记录ID")]
- public long Weigh_ID { get; set; }
-
- [LogicName("活体品种")]
- public long? LiveVarieties_ID { get; set; }
-
- //[LogicName("活体品种")]
- //public string LiveVarieties_Name { get; set; }
-
- [LogicName("等级")]
- public long? HogGrade_ID { get; set; }
-
- //[LogicName("等级")]
- //public string HogGrade_Name { get; set; }
-
- [LogicName("活体标识")]
- public string LiveMark { get; set; }
-
- [LogicName("头数")]
- public int Number { get; set; }
-
- [LogicName("毛重")]
- public Money? MaoWeight { get; set; }
-
- [LogicName("皮重")]
- public Money? PiWeight { get; set; }
-
- [LogicName("重量")]
- public Money? Weight { get; set; }
-
- //[LogicName("均重")]
- //[NonDmoProperty]
- //public Money<一位小数>? AvgWeight {
- // get { return Weight / Number; }
- //}
-
- short? nv = 0;
- [LogicName("建议工艺")]
- public short? SuggestedProcess1
- {
- get { return nv; }
- set { nv = value; }
- }
-
-
- [LogicName("活体圈舍")]
- public string LiveColonyHouse_Name { get; set; }
-
- [LogicName("剩余头数")]
- public int? RemainNumber { get; set; }
-
- [LogicName("已计划头数")]
- public int? PlanNumber { get; set; }
-
- [LogicName("已屠宰头数")]
- public int? ButcherNumber { get; set; }
-
- [LogicName("备注")]
- public string Remark { get; set; }
-
- [LogicName("外部ID")]
- public long? CID { get; set; }
- }
-
- [Serializable]
- public class Weigh_RecordCollection : DmoCollection
- {
-
- }
-
-}
diff --git a/B3ClientService/RpcBO/Bill/WeightBill/RpcWeightBill.cs b/B3ClientService/RpcBO/Bill/WeightBill/RpcWeightBill.cs
new file mode 100644
index 0000000..827dff4
--- /dev/null
+++ b/B3ClientService/RpcBO/Bill/WeightBill/RpcWeightBill.cs
@@ -0,0 +1,27 @@
+using Forks.EnterpriseServices.JsonRpc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BWP.B3ClientService.RpcBO
+{
+ [RpcObject]
+ public class RpcWeightBill
+ {
+ public SWeightBill Bill { get; set; }
+
+ public SWeightBill_Detail[] Details { get; set; }
+
+ public long[] D_Details { get; set; }
+
+ public SWeightBill_FarmerDetail[] FarmerDetails { get; set; }
+
+ public long[] D_FarmerDetails { get; set; }
+
+ public SWeightBill_SanctionDetail[] SanctionDetails { get; set; }
+
+ public long[] D_SanctionDetails { get; set; }
+ }
+}
diff --git a/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill.cs b/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill.cs
new file mode 100644
index 0000000..fb03d33
--- /dev/null
+++ b/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill.cs
@@ -0,0 +1,49 @@
+using BWP.B3ClientService.BO;
+using Forks.EnterpriseServices.JsonRpc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TSingSoft.WebPluginFramework;
+
+namespace BWP.B3ClientService.RpcBO
+{
+ [BOClass(Exclude = true)]
+ public class SWeightBill : SyncBase
+ {
+ public long? AccountingUnit_ID { get; set; }
+
+ public long? Department_ID { get; set; }
+
+ public long? Employee_ID { get; set; }
+
+ public DateTime? WeighTime { get; set; }
+
+ public long? Supplier_ID { get; set; }
+
+ public long? Zone_ID { get; set; }
+
+ public short? PurchaseType_ID { get; set; }
+
+ public long? Car_ID { get; set; }
+
+ public long? LiveVarieties_ID { get; set; }
+
+ public long? HogGrade_ID { get; set; }
+
+ public decimal? ShackWeight { get; set; }
+
+ public decimal? ShackPrice { get; set; }
+
+ public string AnimalTestNumber { get; set; }
+
+ public DateTime? AnimalTestDate { get; set; }
+
+ public string AnimalTestMan { get; set; }
+
+ public long? Inspector_ID { get; set; }
+
+ public string Remark { get; set; }
+ }
+}
diff --git a/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_Detail.cs b/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_Detail.cs
new file mode 100644
index 0000000..2810fac
--- /dev/null
+++ b/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_Detail.cs
@@ -0,0 +1,24 @@
+using BWP.B3ClientService.BO;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TSingSoft.WebPluginFramework;
+
+namespace BWP.B3ClientService.RpcBO
+{
+ [BOClass(Exclude = true)]
+ public class SWeightBill_Detail : SyncBase
+ {
+ public int? Number { get; set; }
+
+ public decimal? PiWeight { get; set; }
+
+ public decimal? MaoWeight { get; set; }
+
+ public decimal? Weight { get; set; }
+
+ public string LiveColonyHouse_Name { get; set; }
+ }
+}
diff --git a/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_FarmerDetail.cs b/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_FarmerDetail.cs
new file mode 100644
index 0000000..f947b7b
--- /dev/null
+++ b/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_FarmerDetail.cs
@@ -0,0 +1,20 @@
+using BWP.B3ClientService.BO;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TSingSoft.WebPluginFramework;
+
+namespace BWP.B3ClientService.RpcBO
+{
+ [BOClass(Exclude = true)]
+ public class SWeightBill_FarmerDetail : SyncBase
+ {
+ public long? Farmer_ID { get; set; }
+
+ public int? Number { get; set; }
+
+ public decimal? Weight { get; set; }
+ }
+}
diff --git a/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_SanctionDetail.cs b/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_SanctionDetail.cs
new file mode 100644
index 0000000..3d5d72b
--- /dev/null
+++ b/B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_SanctionDetail.cs
@@ -0,0 +1,23 @@
+using BWP.B3ClientService.BO;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TSingSoft.WebPluginFramework;
+
+namespace BWP.B3ClientService.RpcBO
+{
+ [BOClass(Exclude = true)]
+ public class SWeightBill_SanctionDetail : SyncBase
+ {
+ public long? Sanction_ID { get; set; }
+
+ ///
+ /// 异常项目ID
+ ///
+ public long? AbnormalItem_ID { get; set; }
+
+ public int? Number { get; set; }
+ }
+}
diff --git a/B3ClientService/Tasks/UpdateLoad/UpLoadWeightBill.cs b/B3ClientService/Tasks/UpdateLoad/UpLoadWeightBill.cs
index 2930dee..86393b3 100644
--- a/B3ClientService/Tasks/UpdateLoad/UpLoadWeightBill.cs
+++ b/B3ClientService/Tasks/UpdateLoad/UpLoadWeightBill.cs
@@ -1,6 +1,8 @@
using BWP.B3ClientService.BO;
-using BWP.B3ClientService.MapBO;
+using BWP.B3ClientService.RpcBO;
using BWP.B3ClientService.Rpcs;
+using BWP.B3Frameworks.Utils;
+using Forks.EnterpriseServices.BusinessInterfaces;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using System;
@@ -15,53 +17,65 @@ namespace BWP.B3ClientService.Tasks.UpdateLoad
{
public static class UpLoadWeightBill
{
- public static void Execute()
+ public static void Execute(string uri)
{
- //1、清理垃圾(删除且未上传的)
- ClearUnUpdateLoadAndDeleteData();
-
- //2、获取所有未上传的数据
+ //获取所有未上传的数据
var allBill = GetAllNeedSyncBill();
- //3、上传
- //{
- // 1、插入(全量)
-
-
-
- // 2、修改{1、全部修改,2、明细删除} 返回 信息后,明细该删的,要清理,然后改为已同步。
- // 3、删除的,删除,并清理本地
-
- // 修改删除注意单据状态。
- // }
-
-
- //4、并反馈ID
-
- //4、改为已上传
- }
-
- static void ClearUnUpdateLoadAndDeleteData()
- {
- using (var session = Dmo.NewSession())
+ foreach (var item in allBill)
{
- DeleteEntity(session);
- DeleteEntity(session);
- DeleteEntity(session);
- DeleteEntity(session);
- DeleteEntity(session);
- session.Commit();
+ var bwpClient = new BWPClient(uri, item.Creator);
+ using (var context = new TransactionContext())
+ {
+ #region 删除
+ if (item.DeleteState)
+ {
+ if (item.B3ID.HasValue)
+ bwpClient.Call("/MainSystem/B3ButcherManage/Rpcs/WeighBillRpc/Delete", item.B3ID.Value);
+ context.Session.Delete(item);
+ context.Commit();
+ continue;
+ }
+ #endregion
+
+ var sync = CreateRpcWeightBill(item);
+ var back = bwpClient.Call("/MainSystem/B3ButcherManage/Rpcs/WeighBillRpc/UpdateOrInsert", sync);
+
+ #region 同步完了要清理掉删除的明细(当前实体和数据库)
+ ClearDetails(item, context.Session);
+
+ #endregion
+
+ #region 反填信息
+ item.B3ID = back.ID;
+ SetBillAsSynced(item.ID, item.B3ID.Value, context.Session);
+
+ foreach (var bItem in back.DetailBack)
+ {
+ switch (bItem.Flag)
+ {
+ case "Details":
+ ExecuteSimpleDetail(bItem, context.Session);
+ break;
+ case "FarmerDetails":
+ ExecuteSimpleDetail(bItem, context.Session);
+ break;
+ case "SanctionDetails":
+ ExecuteSimpleDetail(bItem, context.Session);
+ break;
+ default:
+ break;
+ }
+ }
+ //栋舍明细在B3系统不存在,所以无返回信息
+ ExecuteHouseDetial(item.ID, context.Session);
+ #endregion
+
+ context.Commit();
+ }
}
}
- static void DeleteEntity(IDmoSession session)
- where T : SyncBase
- {
- var delete = new DQDeleteDom(typeof(T));
- delete.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("DeleteState", true), DQCondition.IsNull(DQExpression.Field("B3ID"))));
- session.ExecuteNonQuery(delete);
- }
-
static IEnumerable GetAllNeedSyncBill()
{
var query = new DmoQuery(typeof(WeightBill));
@@ -70,128 +84,95 @@ namespace BWP.B3ClientService.Tasks.UpdateLoad
return query.EExecuteList().Cast();
}
- static BackRpcObj Sync(WeightBill bill, string serverUri)
+ static RpcWeightBill CreateRpcWeightBill(WeightBill bill)
{
- var bwpClient = new BWPClient(serverUri, bill.Creator);
- WeighBill dmo = new WeighBill();
- if (bill.B3ID.HasValue)
- dmo = bwpClient.Call("/MainSystem/B3ButcherManage/Rpcs/WeighBillRpc/Load", bill.B3ID.Value);
- dmo.AccountingUnit_ID = bill.AccountingUnit_ID;
- dmo.Department_ID = bill.Department_ID;
- dmo.Zone_ID = bill.Zone_ID;
- dmo.Employee_ID = bill.Employee_ID;
- dmo.Supplier_ID = bill.Supplier_ID;
- dmo.WeighTime = bill.WeighTime;
- dmo.ShackPrice = bill.ShackPrice;
- dmo.ShackWeight = bill.ShackWeight;
- dmo.ShackMoney = bill.ShackMoney;
- dmo.PurchaseType = bill.PurchaseType_ID;
- dmo.Inspector_ID = bill.Inspector_ID;
- dmo.Car_ID = bill.Car_ID;
- dmo.AnimalTestNumber = bill.AnimalTestNumber;
- dmo.AnimalTestDate = bill.AnimalTestDate;
- dmo.AnimalTestMan = bill.AnimalTestMan;
- dmo.Remark = bill.Remark;
- dmo.CID = bill.ID;
-
- foreach (var bF in bill.FarmerDetails)
- {
- //未上传标识为删除的,已经在ClearUnUpdateLoadAndDeleteData里处理了
- var first = dmo.FarmerDetails.FirstOrDefault(x => x.ID == bF.B3ID);
- if (bF.DeleteState)
- {
- if (first != null)
- dmo.FarmerDetails.Remove(first);
- continue;
- }
- if (first == null)
- {
- first = new Weigh_FarmerDetail();
- dmo.FarmerDetails.Add(first);
- first.CID = bF.ID;
- }
- first.Farmer_ID = bF.Farmer_ID;
- first.Number = bF.Number;
- first.Weigh_ID = dmo.ID;
- first.Weight = bF.Weight;
- }
+ var result = new RpcWeightBill();
+ result.Bill = new SWeightBill();
+ DmoUtil.CopyDmoFields(bill, result.Bill);
- foreach (var bd in bill.Details)
+ var d = bill.Details.Where(x => !x.DeleteState);
+ result.Details = d.Select(x => { var y = new SWeightBill_Detail(); DmoUtil.CopyDmoFields(x, y); return y; }).ToArray();
+ if (result.Details.Any())
{
- var first = dmo.WeighRecord.FirstOrDefault(x => x.ID == bd.B3ID);
- if (bd.DeleteState)
- {
- if (first != null)
- dmo.WeighRecord.Remove(first);
- continue;
- }
- if (first == null)
- {
- first = new Weigh_Record();
- dmo.WeighRecord.Add(first);
- first.CID = bd.ID;
- }
- first.Weigh_ID = dmo.ID;
- first.LiveVarieties_ID = bill.LiveVarieties_ID;
- first.HogGrade_ID = bill.HogGrade_ID;
- first.Number = bd.Number ?? 0;
- first.MaoWeight = bd.MaoWeight;
- first.PiWeight = bd.PiWeight;
- first.Weight = bd.Weight;
- first.LiveColonyHouse_Name = string.Join(",", bill.HouseDetails.Where(x => !x.DeleteState).Select(x => x.LiveColonyHouse_Name));
+ result.Details.OrderBy(x => x.ID).First().LiveColonyHouse_Name = string.Join(",", bill.HouseDetails.Where(x => !x.DeleteState).Select(x => x.LiveColonyHouse_Name));
}
- foreach (var bs in bill.SanctionDetails)
- {
- var first = dmo.WeighAbnormalRecording.FirstOrDefault(x => x.ID == bs.B3ID);
- if (bs.DeleteState)
- {
- if (first != null)
- dmo.WeighAbnormalRecording.Remove(first);
- continue;
- }
- if (first == null)
- {
- first = new Weigh_AbnormalRecording();
- dmo.WeighAbnormalRecording.Add(first);
- first.CID = bs.ID;
- }
- first.Sanction_ID = bs.Sanction_ID;
- first.AbnormalItem_ID = bs.AbnormalItem_ID;
- first.Num = bs.Number ?? 0;
- first.Weigh_ID = dmo.ID;
- }
+ result.D_Details = bill.Details.Where(x => x.DeleteState && x.B3ID.HasValue).Select(x => x.B3ID.Value).ToArray();
+ var fd = bill.FarmerDetails.Where(x => !x.DeleteState);
+ result.FarmerDetails = fd.Select(x => { var y = new SWeightBill_FarmerDetail(); DmoUtil.CopyDmoFields(x, y); return y; }).ToArray();
+ result.D_FarmerDetails = bill.FarmerDetails.Where(x => x.DeleteState && x.B3ID.HasValue).Select(x => x.B3ID.Value).ToArray();
+
+
+ var sd = bill.SanctionDetails.Where(x => !x.DeleteState);
+ result.SanctionDetails = sd.Select(x => { var y = new SWeightBill_SanctionDetail(); DmoUtil.CopyDmoFields(x, y); return y; }).ToArray();
+
+ result.D_SanctionDetails = bill.SanctionDetails.Where(x => x.DeleteState && x.B3ID.HasValue).Select(x => x.B3ID.Value).ToArray();
+
+ return result;
+ }
+
+ private static void ClearDetails(WeightBill bill, IDmoSession session)
+ {
+ var d = bill.Details.Where(x => x.DeleteState).ToArray();
+ foreach (var dd in d)
+ bill.Details.Remove(dd);
+ DeleteDetail(bill.ID, session);
+
+ var f = bill.FarmerDetails.Where(x => x.DeleteState).ToArray();
+ foreach (var fd in f)
+ bill.FarmerDetails.Remove(fd);
+ DeleteDetail(bill.ID, session);
+
+ var h = bill.HouseDetails.Where(x => x.DeleteState).ToArray();
+ foreach (var hd in h)
+ bill.HouseDetails.Remove(hd);
+ DeleteDetail(bill.ID, session);
+
+ var s = bill.SanctionDetails.Where(x => x.DeleteState).ToArray();
+ foreach (var sd in s)
+ bill.SanctionDetails.Remove(sd);
+ DeleteDetail(bill.ID, session);
- //var farmerDic = new Dictionary();
- //foreach (var farmerDetail in bill.FarmerDetails)
- //{
- // farmerDic.Add("ID", farmerDetail.B3ID);
- // farmerDic.Add("Weigh_ID", bill.ID);
- // farmerDic.Add("Farmer_ID", farmerDetail.Farmer_ID);
- // farmerDic.Add("Number", farmerDetail.Number);
- // farmerDic.Add("Weight", farmerDetail.Weight);
- // farmerDic.Add("CID", farmerDetail.ID);
- //}
+ }
- //dic.Add("FarmerDetails", farmerDic);
+ static void DeleteDetail(long mainID, IDmoSession session)
+ where T : SyncBase
+ {
+ var delete = new DQDeleteDom(typeof(T));
+ delete.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("WeightBill_ID", mainID), DQCondition.EQ("DeleteState", true)));
+ session.ExecuteNonQuery(delete);
+ }
- //var farmerDic = new Dictionary();
- //foreach (var farmerDetail in bill.FarmerDetails)
- //{
- // farmerDic.Add("ID", farmerDetail.B3ID);
- // farmerDic.Add("Weigh_ID", bill.ID);
- // farmerDic.Add("Farmer_ID", farmerDetail.Farmer_ID);
- // farmerDic.Add("Number", farmerDetail.Number);
- // farmerDic.Add("Weight", farmerDetail.Weight);
- // farmerDic.Add("CID", farmerDetail.ID);
- //}
+ static void ExecuteHouseDetial(long mainID, IDmoSession session)
+ {
+ var update = new DQUpdateDom(typeof(WeightBill_HouseDetail));
+ update.Columns.Add(new DQUpdateColumn("B3ID", -1));
+ update.Where.Conditions.Add(DQCondition.EQ("WeightBill_ID", mainID));
+ session.ExecuteNonQuery(update);
+ }
- //dic.Add("FarmerDetails", farmerDic);
- return null;
+ static void ExecuteSimpleDetail(BackRpcObj details, IDmoSession session)
+ where T : SyncBase
+ {
+ foreach (var item in details.DetailBack)
+ {
+ var update = new DQUpdateDom(typeof(T));
+ update.Columns.Add(new DQUpdateColumn("B3ID", item.ID));
+ update.Where.Conditions.Add(DQCondition.EQ("ID", long.Parse(item.Flag)));
+ session.ExecuteNonQuery(update);
+ }
}
+ static void SetBillAsSynced(long id, long B3ID, IDmoSession session)
+ {
+ var update = new DQUpdateDom(typeof(WeightBill));
+ update.Columns.Add(new DQUpdateColumn("Sync", true));
+ update.Columns.Add(new DQUpdateColumn("B3ID", B3ID));
+ update.Where.Conditions.Add(DQCondition.EQ("ID", id));
+ session.ExecuteNonQuery(update);
+ }
}
}
diff --git a/B3ClientService/Tasks/UpdateLoad/UploadTest.cs b/B3ClientService/Tasks/UpdateLoad/UploadTest.cs
index faecd9c..a61cbdd 100644
--- a/B3ClientService/Tasks/UpdateLoad/UploadTest.cs
+++ b/B3ClientService/Tasks/UpdateLoad/UploadTest.cs
@@ -11,6 +11,7 @@ using TSingSoft.WebPluginFramework.TimerTasks;
using TSingSoft.WebPluginFramework;
using Forks.JsonRpc.Client.Data;
using Forks.EnterpriseServices.DomainObjects2;
+using BWP.B3ClientService.Tasks.UpdateLoad;
namespace BWP.B3ClientService.Tasks
{
@@ -21,47 +22,7 @@ namespace BWP.B3ClientService.Tasks
var serverUri = ServerHost.GetServerUrl();
if (string.IsNullOrEmpty(serverUri))
throw new Exception("请配置服务器地址");
-
- var list = GetWeightBill();
- foreach (var bill in list)
- {
- BWPClient bwpClient = new BWPClient(serverUri, bill.Creator);
- var obj = ConvertToRpcObject(bill);
- var id = bwpClient.Call("/MainSystem/B3ButcherManage/Rpcs/TouchScreenUploadRpc/InsertWeighBill", obj);
- using (var dmo = Dmo.NewSession())
- {
-
- }
-
- }
- }
-
- IEnumerable GetWeightBill()
- {
- var query = new DmoQuery(typeof(WeightBill));
- query.Where.Conditions.Add(DQCondition.EQ("Sync", false));
- return query.EExecuteList().Cast();
- }
-
- Dictionary ConvertToRpcObject(WeightBill bill)
- {
- var dic = new Dictionary();
- dic.Add("AccountingUnit_ID", 1);
- dic.Add("Department_ID", 5);
- dic.Add("Domain_ID", 1);
- dic.Add("Zone_ID", bill.Zone_ID);
- dic.Add("Employee_ID", bill.Employee_ID);
- dic.Add("Supplier_ID", bill.Supplier_ID);
- dic.Add("WeighTime", bill.WeighTime);
- dic.Add("ShackPrice", bill.ShackPrice);
- dic.Add("ShackWeight", bill.ShackWeight);
- dic.Add("PurchaseType", bill.PurchaseType_ID);
- dic.Add("Inspector_ID", bill.Inspector_ID);
- dic.Add("Car_ID", bill.Car_ID);
- dic.Add("AnimalTestNumber", bill.AnimalTestNumber);
- dic.Add("AnimalTestDate", bill.AnimalTestDate);
- dic.Add("AnimalTestMan", bill.AnimalTestMan);
- return dic;
+ UpLoadWeightBill.Execute(serverUri);
}
public string Name