|
|
using BO.BO;
|
|
|
using Forks.JsonRpc.Client;
|
|
|
using Forks.JsonRpc.Client.Data;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace BO.Utils.BillRpc
|
|
|
{
|
|
|
public static class WeightBillRpc
|
|
|
{
|
|
|
public static bool Send(WeightBill bo)
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/UploadBill";
|
|
|
var obj = new RpcObject("/MainSystem/B3ClientService/BO/WeightBill");
|
|
|
if (bo.ID == 0)
|
|
|
{
|
|
|
obj.Set("Creator", ButcherAppContext.Context.UserConfig.UserName);
|
|
|
obj.Set("AccountingUnit_ID", ButcherAppContext.Context.UserConfig.AccountingUnit_ID);
|
|
|
obj.Set("Department_ID", ButcherAppContext.Context.UserConfig.Department_ID);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
obj.Set("Creator", bo.Creator);
|
|
|
obj.Set("AccountingUnit_ID", bo.AccountingUnit_ID);
|
|
|
obj.Set("Department_ID", bo.Department_ID);
|
|
|
}
|
|
|
//base
|
|
|
obj.Set("ID", bo.ID);
|
|
|
obj.Set("B3ID", bo.B3ID);
|
|
|
obj.Set("DeleteState", bo.DeleteState);
|
|
|
|
|
|
//bill
|
|
|
obj.Set("FinishCreate", bo.FinishCreate);
|
|
|
obj.Set("Sync", false);
|
|
|
obj.Set("ModifyTime", DateTime.Now);
|
|
|
|
|
|
//bill
|
|
|
obj.Set("Employee_ID", bo.Employee_ID);
|
|
|
obj.Set("Employee_Name", bo.Employee_Name);
|
|
|
obj.Set("WeighTime", bo.WeighTime);
|
|
|
obj.Set("Supplier_ID", bo.Supplier_ID);
|
|
|
obj.Set("Supplier_Name", bo.Supplier_Name);
|
|
|
obj.Set("Zone_ID", bo.Zone_ID);
|
|
|
obj.Set("Zone_Name", bo.Zone_Name);
|
|
|
obj.Set("PurchaseType_ID", bo.PurchaseType_ID);
|
|
|
obj.Set("PurchaseType_Name", bo.PurchaseType_Name);
|
|
|
obj.Set("Car_ID", bo.Car_ID);
|
|
|
obj.Set("Car_Name", bo.Car_Name);
|
|
|
obj.Set("LiveVarieties_ID", bo.LiveVarieties_ID);
|
|
|
obj.Set("LiveVarieties_Name", bo.LiveVarieties_Name);
|
|
|
obj.Set("HogGrade_ID", bo.HogGrade_ID);
|
|
|
obj.Set("HogGrade_Name", bo.HogGrade_Name);
|
|
|
obj.Set("ShackWeight", bo.ShackWeight);
|
|
|
obj.Set("ShackPrice", bo.ShackPrice);
|
|
|
obj.Set("AnimalTestNumber", bo.AnimalTestNumber);
|
|
|
obj.Set("AnimalTestDate", bo.AnimalTestDate);
|
|
|
obj.Set("AnimalTestMan", bo.AnimalTestMan);
|
|
|
obj.Set("Remark", bo.Remark);
|
|
|
obj.Set("Inspector_ID", bo.Inspector_ID);
|
|
|
obj.Set("Inspector_Name", bo.Inspector_Name);
|
|
|
|
|
|
const string detailErtPath = "/MainSystem/B3ClientService/BO/WeightBill_Detail";
|
|
|
|
|
|
var details = new ManyList(detailErtPath);
|
|
|
foreach (var detail in bo.Details)
|
|
|
{
|
|
|
var objDetail = new RpcObject(detailErtPath);
|
|
|
objDetail.Set("ID", detail.ID);
|
|
|
objDetail.Set("B3ID", detail.B3ID);
|
|
|
objDetail.Set("DeleteState", detail.DeleteState);
|
|
|
objDetail.Set("WeightBill_ID", detail.WeightBill_ID);
|
|
|
objDetail.Set("Index", detail.Index);
|
|
|
objDetail.Set("MaoWeight", detail.MaoWeight);
|
|
|
objDetail.Set("PiWeight", detail.PiWeight);
|
|
|
objDetail.Set("Weight", detail.Weight);
|
|
|
objDetail.Set("Number", detail.Number);
|
|
|
details.Add(objDetail);
|
|
|
}
|
|
|
|
|
|
obj.Set("Details", details);
|
|
|
|
|
|
const string farmerDetailErtPath = "/MainSystem/B3ClientService/BO/WeightBill_FarmerDetail";
|
|
|
|
|
|
var farmerDetils = new ManyList(farmerDetailErtPath);
|
|
|
foreach (var detail in bo.FarmerDetails)
|
|
|
{
|
|
|
var objDetail = new RpcObject(farmerDetailErtPath);
|
|
|
objDetail.Set("ID", detail.ID);
|
|
|
objDetail.Set("B3ID", detail.B3ID);
|
|
|
objDetail.Set("DeleteState", detail.DeleteState);
|
|
|
objDetail.Set("WeightBill_ID", detail.WeightBill_ID);
|
|
|
objDetail.Set("Index", detail.Index);
|
|
|
objDetail.Set("Farmer_ID", detail.Farmer_ID);
|
|
|
objDetail.Set("Farmer_Name", detail.Farmer_Name);
|
|
|
objDetail.Set("Number", detail.Number);
|
|
|
farmerDetils.Add(objDetail);
|
|
|
}
|
|
|
|
|
|
obj.Set("FarmerDetails", farmerDetils);
|
|
|
|
|
|
var result = RpcFacade.Call<RpcObject>(method, obj);
|
|
|
bo.ID = result.Get<long>("ID");
|
|
|
var detailReturns = result.Get<List<RpcObject>>("DetailBack");
|
|
|
var rDetails = detailReturns[0].Get<List<RpcObject>>("DetailBack");
|
|
|
foreach (var item in rDetails)
|
|
|
{
|
|
|
var idx = Convert.ToInt32(item.Get<string>("Flag"));
|
|
|
bo.Details.First(x => x.Index == idx).ID = item.Get<long>("ID");
|
|
|
}
|
|
|
var rFarmerDetails = detailReturns[1].Get<List<RpcObject>>("DetailBack");
|
|
|
foreach (var item in rFarmerDetails)
|
|
|
{
|
|
|
var idx = Convert.ToInt32(item.Get<string>("Flag"));
|
|
|
bo.FarmerDetails.First(x => x.Index == idx).ID = item.Get<long>("ID");
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
public static bool Delete(long id)
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/DeleteBill";
|
|
|
return RpcFacade.Call<bool>(method, id);
|
|
|
}
|
|
|
|
|
|
public static List<WeightBill> GetWeightBillList()
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/GetWeightBillList";
|
|
|
var list = RpcFacade.Call<List<RpcObject>>(method, DateTime.Today);
|
|
|
var result = new List<WeightBill>();
|
|
|
foreach (var obj in list)
|
|
|
{
|
|
|
var entity = new WeightBill();
|
|
|
result.Add(entity);
|
|
|
entity.Creator = obj.Get<string>("Creator");
|
|
|
entity.AccountingUnit_ID = obj.Get<long?>("AccountingUnit_ID");
|
|
|
entity.Department_ID = obj.Get<long?>("Department_ID");
|
|
|
entity.ID = obj.Get<long>("ID");
|
|
|
entity.B3ID = obj.Get<long?>("B3ID");
|
|
|
entity.DeleteState = false;
|
|
|
entity.FinishCreate = obj.Get<bool>("FinishCreate");
|
|
|
entity.Employee_ID = obj.Get<long?>("Employee_ID");
|
|
|
entity.Employee_Name = obj.Get<string>("Employee_Name");
|
|
|
entity.WeighTime = obj.Get<DateTime?>("WeighTime");
|
|
|
entity.Supplier_ID = obj.Get<long?>("Supplier_ID");
|
|
|
entity.Supplier_Name = obj.Get<string>("Supplier_Name");
|
|
|
entity.Zone_ID = obj.Get<long?>("Zone_ID");
|
|
|
entity.Zone_Name = obj.Get<string>("Zone_Name");
|
|
|
entity.PurchaseType_ID = obj.Get<short?>("PurchaseType_ID");
|
|
|
entity.PurchaseType_Name = obj.Get<string>("PurchaseType_Name");
|
|
|
entity.Car_ID = obj.Get<long?>("Car_ID");
|
|
|
entity.Car_Name = obj.Get<string>("Car_Name");
|
|
|
entity.LiveVarieties_ID = obj.Get<long?>("LiveVarieties_ID");
|
|
|
entity.LiveVarieties_Name = obj.Get<string>("LiveVarieties_Name");
|
|
|
entity.HogGrade_ID = obj.Get<long?>("HogGrade_ID");
|
|
|
entity.HogGrade_Name = obj.Get<string>("HogGrade_Name");
|
|
|
entity.ShackWeight = obj.Get<decimal?>("ShackWeight");
|
|
|
entity.ShackPrice = obj.Get<decimal?>("ShackPrice");
|
|
|
entity.AnimalTestNumber = obj.Get<string>("AnimalTestNumber");
|
|
|
entity.AnimalTestDate = obj.Get<DateTime?>("AnimalTestDate");
|
|
|
entity.AnimalTestMan = obj.Get<string>("AnimalTestMan");
|
|
|
entity.Remark = obj.Get<string>("Remark");
|
|
|
entity.Inspector_ID = obj.Get<long?>("Inspector_ID");
|
|
|
entity.Inspector_Name = obj.Get<string>("Inspector_Name");
|
|
|
var details = obj.Get<ManyList>("Details");
|
|
|
foreach (var detail in details)
|
|
|
{
|
|
|
var d = new WeightBill_Detail();
|
|
|
d.DeleteState = detail.Get<bool>("DeleteState");
|
|
|
if (d.DeleteState)
|
|
|
continue;
|
|
|
entity.Details.Add(d);
|
|
|
d.ID = detail.Get<long>("ID");
|
|
|
d.B3ID = detail.Get<long?>("B3ID");
|
|
|
d.Index = detail.Get<int>("Index");
|
|
|
d.MaoWeight = detail.Get<decimal?>("MaoWeight");
|
|
|
d.PiWeight = detail.Get<decimal?>("PiWeight");
|
|
|
d.Number = detail.Get<int?>("Number");
|
|
|
d.Weight = detail.Get<decimal?>("Weight");
|
|
|
d.WeightBill_ID = detail.Get<long>("WeightBill_ID");
|
|
|
}
|
|
|
|
|
|
var farmers = obj.Get<ManyList>("FarmerDetails");
|
|
|
foreach (var detail in farmers)
|
|
|
{
|
|
|
var d = new WeightBill_FarmerDetail();
|
|
|
d.DeleteState = detail.Get<bool>("DeleteState");
|
|
|
if (d.DeleteState)
|
|
|
continue;
|
|
|
entity.FarmerDetails.Add(d);
|
|
|
d.ID = detail.Get<long>("ID");
|
|
|
d.B3ID = detail.Get<long?>("B3ID");
|
|
|
d.Index = detail.Get<int>("Index");
|
|
|
d.Farmer_ID = detail.Get<long?>("Farmer_ID");
|
|
|
d.Farmer_Name = detail.Get<string>("Farmer_Name");
|
|
|
d.Number = detail.Get<int?>("Number");
|
|
|
d.WeightBill_ID = detail.Get<long>("WeightBill_ID");
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
}
|