|
|
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)
|
|
|
{
|
|
|
bo.Creator = ButcherAppContext.Context.UserConfig.UserName;
|
|
|
bo.AccountingUnit_ID = ButcherAppContext.Context.UserConfig.AccountingUnit_ID;
|
|
|
bo.Department_ID = ButcherAppContext.Context.UserConfig.Department_ID;
|
|
|
}
|
|
|
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);
|
|
|
|
|
|
//bill
|
|
|
obj.Set("FinishCreate", bo.FinishCreate);
|
|
|
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);
|
|
|
if (bo.ID == 0)
|
|
|
bo.ID = result.Get<long>("ID");
|
|
|
var detailReturns = result.Get<List<RpcObject>>("DetailBack");
|
|
|
foreach (var d in detailReturns)
|
|
|
{
|
|
|
var dFlag = d.Get<string>("Flag");
|
|
|
switch (dFlag)
|
|
|
{
|
|
|
case "Details":
|
|
|
var rdetails = d.Get<List<RpcObject>>("DetailBack");
|
|
|
foreach (var rd in rdetails)
|
|
|
{
|
|
|
var idx = Convert.ToInt32(rd.Get<string>("Flag"));
|
|
|
var first = bo.Details.First(x => x.Index == idx);
|
|
|
if (first.ID == 0)
|
|
|
{
|
|
|
first.ID = rd.Get<long>("ID");
|
|
|
first.WeightBill_ID = bo.ID;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case "FarmerDetails":
|
|
|
var rfarmerDetails = d.Get<List<RpcObject>>("DetailBack");
|
|
|
foreach (var rd in rfarmerDetails)
|
|
|
{
|
|
|
var idx = Convert.ToInt32(rd.Get<string>("Flag"));
|
|
|
var first = bo.FarmerDetails.First(x => x.Index == idx);
|
|
|
if (first.ID == 0)
|
|
|
{
|
|
|
first.ID = rd.Get<long>("ID");
|
|
|
first.WeightBill_ID = bo.ID;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
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(long? carID, long? supplierID)
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/GetWeightBillList";
|
|
|
var list = RpcFacade.Call<List<RpcObject>>(method, DateTime.Today, carID, supplierID);
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
public static List<WeightBill> GetUnHousedBill(DateTime date)
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/GetNoHouseInfoWeightBills";
|
|
|
var list = RpcFacade.Call<List<RpcObject>>(method, date);
|
|
|
var result = new List<WeightBill>();
|
|
|
foreach (var obj in list)
|
|
|
{
|
|
|
var entity = new WeightBill();
|
|
|
result.Add(entity);
|
|
|
var bill = obj.Get<RpcObject>("Bill");
|
|
|
entity.ID = bill.Get<long>("ID");
|
|
|
entity.B3ID = bill.Get<long?>("B3ID");
|
|
|
entity.Employee_Name = bill.Get<string>("Employee_Name");
|
|
|
entity.Supplier_Name = bill.Get<string>("Supplier_Name");
|
|
|
entity.AlreadyHouse = bill.Get<bool>("AlreadyHouse");
|
|
|
entity.FirstWeightNumber = bill.Get<int?>("FirstWeightNumber");
|
|
|
var details = obj.Get<List<RpcObject>>("Detail");
|
|
|
//明细接收的数据不全,所以不能全量保存.
|
|
|
foreach (var detail in details)
|
|
|
{
|
|
|
var d = new WeightBill_HouseDetail();
|
|
|
entity.HouseDetails.Add(d);
|
|
|
d.LiveColonyHouse_Name = detail.Get<string>("LiveColonyHouse_Name");
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static int UpdateInsertHouseAndSanctionInfo(WeightBill bo)
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/UpdateInsertWeightBillHouseDetail";
|
|
|
var obj = new RpcObject("/MainSystem/B3ClientService/BO/WeightBill");
|
|
|
obj.Set("ID", bo.ID);
|
|
|
obj.Set("HogGrade_ID", bo.HogGrade_ID);
|
|
|
obj.Set("HogGrade_Name", bo.HogGrade_Name);
|
|
|
obj.Set("AlreadyHouse", bo.AlreadyHouse);
|
|
|
obj.Set("FirstWeightNumber", bo.FirstWeightNumber);
|
|
|
obj.Set("Inspector_ID", ButcherAppContext.Context.UserConfig.Employee_ID);
|
|
|
obj.Set("Inspector_Name", ButcherAppContext.Context.UserConfig.Employee_Name);
|
|
|
|
|
|
const string houseErtPath = "/MainSystem/B3ClientService/BO/WeightBill_HouseDetail";
|
|
|
|
|
|
var houseDetails = new ManyList(houseErtPath);
|
|
|
foreach (var detail in bo.HouseDetails)
|
|
|
{
|
|
|
var objDetail = new RpcObject(houseErtPath);
|
|
|
objDetail.Set("WeightBill_ID", detail.WeightBill_ID);
|
|
|
objDetail.Set("Index", detail.Index);
|
|
|
objDetail.Set("LiveColonyHouse_ID", detail.LiveColonyHouse_ID);
|
|
|
objDetail.Set("LiveColonyHouse_Name", detail.LiveColonyHouse_Name);
|
|
|
objDetail.Set("Number", detail.Number);
|
|
|
houseDetails.Add(objDetail);
|
|
|
}
|
|
|
|
|
|
obj.Set("HouseDetails", houseDetails);
|
|
|
|
|
|
const string sanctionsErtPath = "/MainSystem/B3ClientService/BO/WeightBill_SanctionDetail";
|
|
|
|
|
|
var sanctionDetails = new ManyList(sanctionsErtPath);
|
|
|
foreach (var detail in bo.SanctionDetails)
|
|
|
{
|
|
|
var objDetail = new RpcObject(sanctionsErtPath);
|
|
|
objDetail.Set("WeightBill_ID", detail.WeightBill_ID);
|
|
|
objDetail.Set("Index", detail.Index);
|
|
|
objDetail.Set("Sanction_ID", detail.Sanction_ID);
|
|
|
objDetail.Set("AbnormalItem_ID", detail.AbnormalItem_ID);
|
|
|
objDetail.Set("AbnormalItem_Name", detail.AbnormalItem_Name);
|
|
|
objDetail.Set("Number", detail.Number);
|
|
|
sanctionDetails.Add(objDetail);
|
|
|
}
|
|
|
|
|
|
obj.Set("SanctionDetails", sanctionDetails);
|
|
|
return RpcFacade.Call<int>(method, obj);
|
|
|
}
|
|
|
|
|
|
public static int GetDetailTotalNumber(DateTime date)
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/GetDetailTotalNumber";
|
|
|
return RpcFacade.Call<int>(method, date);
|
|
|
}
|
|
|
|
|
|
public static List<Tuple<long?, long?>> SyncBillB3Ids(List<long?> ids)
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/SyncBillB3Ids";
|
|
|
return RpcFacade.Call<List<Tuple<long?, long?>>>(method, ids.ToArray());
|
|
|
}
|
|
|
|
|
|
public static List<Tuple<long?, long?>> SyncWeightDetailB3Ids(List<long?> ids)
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/SyncWeightDetailB3Ids";
|
|
|
return RpcFacade.Call<List<Tuple<long?, long?>>>(method, ids);
|
|
|
}
|
|
|
|
|
|
public static List<Tuple<long?, long?>> SyncFarmerDetailB3Ids(List<long?> ids)
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/SyncFarmerDetailB3Ids";
|
|
|
return RpcFacade.Call<List<Tuple<long?, long?>>>(method, ids);
|
|
|
}
|
|
|
|
|
|
public static List<Tuple<long?, long?, int?>> SyncWeightDetailFirstNumber(List<long?> ids)
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/SyncWeightDetailFirstNumber";
|
|
|
return RpcFacade.Call<List<Tuple<long?, long?, int?>>>(method, ids);
|
|
|
}
|
|
|
|
|
|
public static WeightBill GetWeightBillOnHousePage(long id)
|
|
|
{
|
|
|
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/WeightBillRpc/GetWeightBillOnHousePage";
|
|
|
var obj = RpcFacade.Call<RpcObject>(method, id);
|
|
|
var entity = new WeightBill();
|
|
|
var bill = obj.Get<RpcObject>("Bill");
|
|
|
entity.FirstWeightNumber = bill.Get<int?>("FirstWeightNumber");
|
|
|
entity.HogGrade_ID = bill.Get<long?>("HogGrade_ID");
|
|
|
var details = obj.Get<List<RpcObject>>("Detail");
|
|
|
//明细接收的数据不全,所以不能全量保存.
|
|
|
foreach (var detail in details)
|
|
|
{
|
|
|
var d = new WeightBill_HouseDetail();
|
|
|
entity.HouseDetails.Add(d);
|
|
|
d.ID = detail.Get<long>("ID");
|
|
|
d.LiveColonyHouse_ID = detail.Get<long?>("LiveColonyHouse_ID");
|
|
|
}
|
|
|
var sanctionDetail = obj.Get<List<RpcObject>>("SanctionDetail");
|
|
|
//明细接收的数据不全,所以不能全量保存.
|
|
|
foreach (var detail in sanctionDetail)
|
|
|
{
|
|
|
var d = new WeightBill_SanctionDetail();
|
|
|
entity.SanctionDetails.Add(d);
|
|
|
d.ID = detail.Get<long>("ID");
|
|
|
d.AbnormalItem_ID = detail.Get<long?>("AbnormalItem_ID");
|
|
|
d.Number = detail.Get<int?>("Number");
|
|
|
}
|
|
|
return entity;
|
|
|
}
|
|
|
}
|
|
|
}
|