Browse Source

修改。

master
yibo 8 years ago
parent
commit
4867e9fe4d
12 changed files with 282 additions and 543 deletions
  1. +6
    -4
      B3ClientService/B3ClientService.csproj
  2. +0
    -166
      B3ClientService/MapBO/WeightBill/WeighBill.cs
  3. +0
    -50
      B3ClientService/MapBO/WeightBill/Weigh_AbnormalRecording.cs
  4. +0
    -41
      B3ClientService/MapBO/WeightBill/Weigh_FarmerDetail.cs
  5. +0
    -91
      B3ClientService/MapBO/WeightBill/Weigh_Record.cs
  6. +27
    -0
      B3ClientService/RpcBO/Bill/WeightBill/RpcWeightBill.cs
  7. +49
    -0
      B3ClientService/RpcBO/Bill/WeightBill/SWeightBill.cs
  8. +24
    -0
      B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_Detail.cs
  9. +20
    -0
      B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_FarmerDetail.cs
  10. +23
    -0
      B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_SanctionDetail.cs
  11. +131
    -150
      B3ClientService/Tasks/UpdateLoad/UpLoadWeightBill.cs
  12. +2
    -41
      B3ClientService/Tasks/UpdateLoad/UploadTest.cs

+ 6
- 4
B3ClientService/B3ClientService.csproj View File

@ -87,11 +87,12 @@
<Compile Include="BO\SyncBO\MinEmployee.cs" />
<Compile Include="BO\SyncBO\MinWPF_User.cs" />
<Compile Include="BO\ServerHost.cs" />
<Compile Include="MapBO\WeightBill\WeighBill.cs" />
<Compile Include="MapBO\WeightBill\Weigh_AbnormalRecording.cs" />
<Compile Include="MapBO\WeightBill\Weigh_FarmerDetail.cs" />
<Compile Include="MapBO\WeightBill\Weigh_Record.cs" />
<Compile Include="RpcBO\Bill\WeightBill\RpcWeightBill.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RpcBO\Bill\WeightBill\SWeightBill_Detail.cs" />
<Compile Include="RpcBO\Bill\WeightBill\SWeightBill.cs" />
<Compile Include="RpcBO\Bill\WeightBill\SWeightBill_FarmerDetail.cs" />
<Compile Include="RpcBO\Bill\WeightBill\SWeightBill_SanctionDetail.cs" />
<Compile Include="Rpcs\BackRpcObj.cs" />
<Compile Include="Rpcs\BaseInfoRpc.cs" />
<Compile Include="Rpcs\BillRpc\WeightBillRpc.cs" />
@ -103,6 +104,7 @@
<Compile Include="WordPair.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="RpcBO\BaseInfo\" />
<Folder Include="Tasks\DownLoad\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />


+ 0
- 166
B3ClientService/MapBO/WeightBill/WeighBill.cs View File

@ -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<decimal>? BuyWeigh1 { get; set; }
[LogicName("棚前单价")]
public Money<decimal>? ShackPrice { get; set; }
[LogicName("棚前重量")]
public Money<decimal>? 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; }
}
}

+ 0
- 50
B3ClientService/MapBO/WeightBill/Weigh_AbnormalRecording.cs View File

@ -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<decimal>? UnitPrice { get; set; }
[LogicName("金额")]
public Money<decimal>? 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<Weigh_AbnormalRecording>
{
}
}

+ 0
- 41
B3ClientService/MapBO/WeightBill/Weigh_FarmerDetail.cs View File

@ -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<Weigh_FarmerDetail>
{ }
}

+ 0
- 91
B3ClientService/MapBO/WeightBill/Weigh_Record.cs View File

@ -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<decimal>? MaoWeight { get; set; }
[LogicName("皮重")]
public Money<decimal>? PiWeight { get; set; }
[LogicName("重量")]
public Money<decimal>? 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<Weigh_Record>
{
}
}

+ 27
- 0
B3ClientService/RpcBO/Bill/WeightBill/RpcWeightBill.cs View File

@ -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; }
}
}

+ 49
- 0
B3ClientService/RpcBO/Bill/WeightBill/SWeightBill.cs View File

@ -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; }
}
}

+ 24
- 0
B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_Detail.cs View File

@ -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; }
}
}

+ 20
- 0
B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_FarmerDetail.cs View File

@ -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; }
}
}

+ 23
- 0
B3ClientService/RpcBO/Bill/WeightBill/SWeightBill_SanctionDetail.cs View File

@ -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; }
/// <summary>
/// 异常项目ID
/// </summary>
public long? AbnormalItem_ID { get; set; }
public int? Number { get; set; }
}
}

+ 131
- 150
B3ClientService/Tasks/UpdateLoad/UpLoadWeightBill.cs View File

@ -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<WeightBill>(session);
DeleteEntity<WeightBill_Detail>(session);
DeleteEntity<WeightBill_FarmerDetail>(session);
DeleteEntity<WeightBill_HouseDetail>(session);
DeleteEntity<WeightBill_SanctionDetail>(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<int>("/MainSystem/B3ButcherManage/Rpcs/WeighBillRpc/Delete", item.B3ID.Value);
context.Session.Delete(item);
context.Commit();
continue;
}
#endregion
var sync = CreateRpcWeightBill(item);
var back = bwpClient.Call<BackRpcObj>("/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<WeightBill_Detail>(bItem, context.Session);
break;
case "FarmerDetails":
ExecuteSimpleDetail<WeightBill_FarmerDetail>(bItem, context.Session);
break;
case "SanctionDetails":
ExecuteSimpleDetail<WeightBill_SanctionDetail>(bItem, context.Session);
break;
default:
break;
}
}
//栋舍明细在B3系统不存在,所以无返回信息
ExecuteHouseDetial(item.ID, context.Session);
#endregion
context.Commit();
}
}
}
static void DeleteEntity<T>(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<WeightBill> GetAllNeedSyncBill()
{
var query = new DmoQuery(typeof(WeightBill));
@ -70,128 +84,95 @@ namespace BWP.B3ClientService.Tasks.UpdateLoad
return query.EExecuteList().Cast<WeightBill>();
}
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<WeighBill>("/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<WeightBill_Detail>(bill.ID, session);
var f = bill.FarmerDetails.Where(x => x.DeleteState).ToArray();
foreach (var fd in f)
bill.FarmerDetails.Remove(fd);
DeleteDetail<WeightBill_FarmerDetail>(bill.ID, session);
var h = bill.HouseDetails.Where(x => x.DeleteState).ToArray();
foreach (var hd in h)
bill.HouseDetails.Remove(hd);
DeleteDetail<WeightBill_HouseDetail>(bill.ID, session);
var s = bill.SanctionDetails.Where(x => x.DeleteState).ToArray();
foreach (var sd in s)
bill.SanctionDetails.Remove(sd);
DeleteDetail<WeightBill_SanctionDetail>(bill.ID, session);
//var farmerDic = new Dictionary<string, object>();
//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<T>(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<string, object>();
//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<T>(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);
}
}
}

+ 2
- 41
B3ClientService/Tasks/UpdateLoad/UploadTest.cs View File

@ -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<long>("/MainSystem/B3ButcherManage/Rpcs/TouchScreenUploadRpc/InsertWeighBill", obj);
using (var dmo = Dmo.NewSession())
{
}
}
}
IEnumerable<WeightBill> GetWeightBill()
{
var query = new DmoQuery(typeof(WeightBill));
query.Where.Conditions.Add(DQCondition.EQ("Sync", false));
return query.EExecuteList().Cast<WeightBill>();
}
Dictionary<string, object> ConvertToRpcObject(WeightBill bill)
{
var dic = new Dictionary<string, object>();
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


Loading…
Cancel
Save