diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj
index 4fde668..3bf2568 100644
--- a/B3ClientService/B3ClientService.csproj
+++ b/B3ClientService/B3ClientService.csproj
@@ -246,6 +246,7 @@
+
diff --git a/B3ClientService/BO/BaseInfo/Car.cs b/B3ClientService/BO/BaseInfo/Car.cs
index 15a85c7..900fc98 100644
--- a/B3ClientService/BO/BaseInfo/Car.cs
+++ b/B3ClientService/BO/BaseInfo/Car.cs
@@ -9,5 +9,6 @@ namespace BWP.B3ClientService.BO
[Serializable]
public class Car : BaseInfo
{
+ public string Driver_IDCard { get; set; }
}
}
diff --git a/B3ClientService/BO/BaseInfo/Supplier.cs b/B3ClientService/BO/BaseInfo/Supplier.cs
index e1d63d4..fd0f294 100644
--- a/B3ClientService/BO/BaseInfo/Supplier.cs
+++ b/B3ClientService/BO/BaseInfo/Supplier.cs
@@ -11,5 +11,7 @@ namespace BWP.B3ClientService.BO
public class Supplier : BaseInfo
{
public string BankAccount { get; set; }
+
+ public string IDCardNumber { get; set; }
}
}
diff --git a/B3ClientService/BO/MiniProgram/SendPigRecord.cs b/B3ClientService/BO/MiniProgram/SendPigRecord.cs
index ee7cfe1..7a8a59b 100644
--- a/B3ClientService/BO/MiniProgram/SendPigRecord.cs
+++ b/B3ClientService/BO/MiniProgram/SendPigRecord.cs
@@ -10,24 +10,50 @@ namespace BWP.B3ClientService.BO
public class SendPigRecord : Base
{
public long userID { get; set; }
+
public string date { get; set; }
+
public string time { get; set; }
+
public int bType { get; set; }
+
+ public long carID { get; set; }
+
+ [ReferenceTo(typeof(Car), "Name")]
+ [Join("carID", "ID")]
public string carNum { get; set; }
+
+ [ReferenceTo(typeof(Car), "Driver_IDCard")]
+ [Join("carID", "ID")]
public string carIDCard { get; set; }
+
+ public long supplierID { get; set; }
+
+ [ReferenceTo(typeof(Supplier), "Name")]
+ [Join("supplierID", "ID")]
public string supplier { get; set; }
+
+ [ReferenceTo(typeof(Supplier), "IDCardNumber")]
+ [Join("supplierID", "ID")]
public string supplierIDCard { get; set; }
- public string receive { get; set; }
- public string bank { get; set; }
+
+ [ReferenceTo(typeof(Supplier), "BankAccount")]
+ [Join("supplierID", "ID")]
public string bankNum { get; set; }
- public int num { get; set; }
- public decimal weight { get; set; }
- public decimal price { get; set; }
- public decimal money { get; set; }
- public decimal? pweight { get; set; }
- public decimal? pprice { get; set; }
- public decimal? pmoney { get; set; }
+
+ public long? employeeID { get; set; }
+
+ [ReferenceTo(typeof(MinEmployee), "Name")]
+ [Join("employeeID", "ID")]
+ public string employee { get; set; }
+
public decimal? jjf { get; set; }
+ public decimal? discont { get; set; }
+ public string testNo { get; set; }
+ public string testMan { get; set; }
+ public string testDate { get; set; }
+ public DateTime? BillTime { get; set; }
+ public long? WeightBill_ID { get; set; }
[NonDmoProperty]
public FarmerRecord[] farmers { get; set; }
@@ -36,10 +62,35 @@ namespace BWP.B3ClientService.BO
public class FarmerRecord : Base
{
public long SendPigRecord_ID { get; set; }
+
public int fidx { get; set; }
+
+ [ReferenceTo(typeof(Farmer),"Name")]
+ [Join("farmerID","ID")]
public string fName { get; set; }
+
+ public long farmerID { get; set; }
+
+ public int number { get; set; }
+
+ public decimal? weight { get; set; }
+
+ public decimal? money { get; set; }
+
+ [ReferenceTo(typeof(Farmer), "IDCard")]
+ [Join("farmerID", "ID")]
+ public string fIDCard { get; set; }
+
+ [ReferenceTo(typeof(Farmer), "BankAccount")]
+ [Join("farmerID", "ID")]
+ public string bankNum { get; set; }
+
+ [ReferenceTo(typeof(Farmer), "Tel")]
+ [Join("farmerID", "ID")]
public string fTel { get; set; }
+
+ [ReferenceTo(typeof(Farmer), "Address")]
+ [Join("farmerID", "ID")]
public string fAddress { get; set; }
- public string fIDCard { get; set; }
}
}
diff --git a/B3ClientService/BO/SyncBO/MinEmployee.cs b/B3ClientService/BO/SyncBO/MinEmployee.cs
index 4145587..dd2017f 100644
--- a/B3ClientService/BO/SyncBO/MinEmployee.cs
+++ b/B3ClientService/BO/SyncBO/MinEmployee.cs
@@ -32,5 +32,7 @@ namespace BWP.B3ClientService.BO
public DateTime CreateTime { get; set; }
public DateTime ModifyTime { get; set; }
+
+ public string IDCardNumber { get; set; }
}
}
diff --git a/B3ClientService/OfflinRpc/MiniProgramRpc.cs b/B3ClientService/OfflinRpc/MiniProgramRpc.cs
index 8ac8c5f..6747859 100644
--- a/B3ClientService/OfflinRpc/MiniProgramRpc.cs
+++ b/B3ClientService/OfflinRpc/MiniProgramRpc.cs
@@ -61,17 +61,19 @@ namespace BWP.B3ClientService.Rpcs
{
var query = new DQueryDom(new JoinAlias(typeof(SendPigRecord)));
query.Columns.Add(DQSelectColumn.Field("bType"));
+ query.Columns.Add(DQSelectColumn.Field("carID"));
query.Columns.Add(DQSelectColumn.Field("carNum"));
query.Columns.Add(DQSelectColumn.Field("carIDCard"));
+ query.Columns.Add(DQSelectColumn.Field("supplierID"));
query.Columns.Add(DQSelectColumn.Field("supplier"));
query.Columns.Add(DQSelectColumn.Field("supplierIDCard"));
- query.Columns.Add(DQSelectColumn.Field("receive"));
- query.Columns.Add(DQSelectColumn.Field("bank"));
query.Columns.Add(DQSelectColumn.Field("bankNum"));
+ query.Columns.Add(DQSelectColumn.Field("employeeID"));
+ query.Columns.Add(DQSelectColumn.Field("employee"));
query.Where.Conditions.Add(DQCondition.EQ("userID", id));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true));
query.Range = SelectRange.Top(1);
- var entity = new MinDmo() { bType = 0 };
+ var entity = new MinDmo();
using (var session = Dmo.NewSession())
{
using (var reader = session.ExecuteReader(query))
@@ -79,13 +81,15 @@ namespace BWP.B3ClientService.Rpcs
if (reader.Read())
{
entity.bType = (int)reader[0];
- entity.carNum = (string)reader[1];
- entity.carIDCard = (string)reader[2];
- entity.supplier = (string)reader[3];
- entity.supplierIDCard = (string)reader[4];
- entity.receive = (string)reader[5];
- entity.bank = (string)reader[6];
+ entity.carID = (long)reader[1];
+ entity.carNum = (string)reader[2];
+ entity.carIDCard = (string)reader[3];
+ entity.supplierID = (long)reader[4];
+ entity.supplier = (string)reader[5];
+ entity.supplierIDCard = (string)reader[6];
entity.bankNum = (string)reader[7];
+ entity.employeeID = (long?)reader[8];
+ entity.employee = (string)reader[9];
}
}
}
@@ -96,6 +100,7 @@ namespace BWP.B3ClientService.Rpcs
public static long Submit(string json)
{
var entity = JsonConvert.DeserializeObject(json);
+ entity.BillTime = DateTime.Parse(string.Format("{0} {1}:00", entity.date, entity.time));
using (var session = Dmo.NewSession())
{
session.Insert(entity);
@@ -155,6 +160,7 @@ namespace BWP.B3ClientService.Rpcs
public static long Save(string json)
{
var entity = JsonConvert.DeserializeObject(json);
+ entity.BillTime = DateTime.Parse(string.Format("{0} {1}:00", entity.date, entity.time));
using (var session = Dmo.NewSession())
{
var dids = entity.farmers.Select(x => x.ID).Where(x => x > 0);
@@ -184,6 +190,72 @@ namespace BWP.B3ClientService.Rpcs
delete.Where.Conditions.Add(DQCondition.NotInList(DQExpression.Field("ID"), exist.Select(x => DQExpression.Value(x)).ToArray()));
session.ExecuteNonQuery(delete);
}
+
+ [Rpc(RpcFlags.SkipAuth)]
+ public static string GetCarInfo(string name)
+ {
+ name = name.ToUpper();
+ var query = new DQueryDom(new JoinAlias(typeof(Car)));
+ query.Columns.Add(DQSelectColumn.Field("ID"));
+ query.Columns.Add(DQSelectColumn.Field("Driver_IDCard"));
+ query.Where.Conditions.Add(DQCondition.EQ("Name", name));
+ var rst = query.EExecuteScalar();
+ if (rst == null)
+ return null;
+ return JsonConvert.SerializeObject(new Car { ID = rst.Item1, Driver_IDCard = rst.Item2 });
+ }
+
+ [Rpc(RpcFlags.SkipAuth)]
+ public static long? GetEmployeeID(string name)
+ {
+ var query = new DQueryDom(new JoinAlias(typeof(MinEmployee)));
+ query.Columns.Add(DQSelectColumn.Field("ID"));
+ query.Where.Conditions.Add(DQCondition.EQ("Name", name));
+ return query.EExecuteScalar();
+ }
+
+ [Rpc(RpcFlags.SkipAuth)]
+ public static string GetSupplierInfo(string name)
+ {
+ var query = new DQueryDom(new JoinAlias(typeof(Supplier)));
+ query.Columns.Add(DQSelectColumn.Field("ID"));
+ query.Columns.Add(DQSelectColumn.Field("BankAccount"));
+ query.Columns.Add(DQSelectColumn.Field("IDCardNumber"));
+ query.Where.Conditions.Add(DQCondition.EQ("Name", name));
+ var rst = query.EExecuteScalar();
+ if (rst == null)
+ return null;
+ return JsonConvert.SerializeObject(new Supplier { ID = rst.Item1, BankAccount = rst.Item2, IDCardNumber = rst.Item3 });
+ }
+
+ [Rpc(RpcFlags.SkipAuth)]
+ public static string GetFarmerInfo(string name)
+ {
+ var query = new DQueryDom(new JoinAlias(typeof(Farmer)));
+ query.Columns.Add(DQSelectColumn.Field("ID"));
+ query.Columns.Add(DQSelectColumn.Field("IDCard"));
+ query.Columns.Add(DQSelectColumn.Field("Tel"));
+ query.Columns.Add(DQSelectColumn.Field("Address"));
+ query.Columns.Add(DQSelectColumn.Field("BankAccount"));
+ query.Where.Conditions.Add(DQCondition.EQ("Name", name));
+ using (var session = Dmo.NewSession())
+ {
+ using (var reader = session.ExecuteReader(query))
+ {
+ if (reader.Read())
+ {
+ var far = new Farmer();
+ far.ID = (long)reader[0];
+ far.IDCard = (string)reader[1];
+ far.Tel = (string)reader[2];
+ far.Address = (string)reader[3];
+ far.BankAccount = (string)reader[4];
+ return JsonConvert.SerializeObject(far);
+ }
+ }
+ }
+ return null;
+ }
}
class HistoryObj
@@ -201,19 +273,23 @@ namespace BWP.B3ClientService.Rpcs
{
public int bType { get; set; }
+ public long carID { get; set; }
+
public string carNum { get; set; }
public string carIDCard { get; set; }
+ public long supplierID { get; set; }
+
public string supplier { get; set; }
public string supplierIDCard { get; set; }
- public string receive { get; set; }
+ public string bankNum { get; set; }
- public string bank { get; set; }
+ public long? employeeID { get; set; }
- public string bankNum { get; set; }
+ public string employee { get; set; }
}
class WeiSer
diff --git a/B3ClientService/Rpcs/SelfHelpRpc.cs b/B3ClientService/Rpcs/SelfHelpRpc.cs
new file mode 100644
index 0000000..2f603f4
--- /dev/null
+++ b/B3ClientService/Rpcs/SelfHelpRpc.cs
@@ -0,0 +1,220 @@
+using BWP.B3ClientService.BO;
+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 System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TSingSoft.WebPluginFramework;
+
+namespace BWP.B3ClientService.Rpcs
+{
+ [Rpc]
+ public static class SelfHelpRpc
+ {
+ [Rpc(RpcFlags.SkipAuth)]
+ public static string GetViewEntity(string idCard)
+ {
+ var q1 = GetWeightQueryDom(idCard);
+ q1.UnionNext.Select = GetSendPigQueryDom(idCard);
+ var lst = new List();
+ using (var session = Dmo.NewSession())
+ {
+ using (var reader = session.ExecuteReader(q1))
+ {
+ while (reader.Read())
+ {
+ var id = (long)reader[0];
+ var typeID = Convert.ToInt32(reader[1]);
+ var first = lst.FirstOrDefault(x => x.ID == id && x.BillType == typeID);
+ if (first == null)
+ {
+ first = new ViewEntity() { ID = id, BillType = typeID };
+ first.CarNumber = (string)reader[2];
+ first.Date = (DateTime)reader[4];
+ lst.Add(first);
+ }
+ first.Number += (int?)reader[3] ?? 0;
+ }
+ }
+ }
+
+ return JsonConvert.SerializeObject(lst);
+ }
+
+ static DQueryDom GetWeightQueryDom(string idCard)
+ {
+ var m1 = new JoinAlias(typeof(WeightBill));
+ var d1 = new JoinAlias(typeof(WeightBill_FarmerDetail));
+ var car1 = new JoinAlias("car1", typeof(Car));
+ var supper1 = new JoinAlias("supper1", typeof(Supplier));
+ var employee1 = new JoinAlias("emp1", typeof(MinEmployee));
+ var q1 = new DQueryDom(m1);
+ q1.From.AddJoin(JoinType.Left, new DQDmoSource(d1), DQCondition.EQ(m1, "ID", d1, "WeightBill_ID"));
+ q1.From.AddJoin(JoinType.Left, new DQDmoSource(car1), DQCondition.EQ(car1, "ID", m1, "Car_ID"));
+ q1.From.AddJoin(JoinType.Left, new DQDmoSource(supper1), DQCondition.EQ(supper1, "ID", m1, "Supplier_ID"));
+ q1.From.AddJoin(JoinType.Left, new DQDmoSource(employee1), DQCondition.EQ(employee1, "ID", m1, "Employee_ID"));
+ q1.Columns.Add(DQSelectColumn.Field("ID"));
+ q1.Columns.Add(DQSelectColumn.Create(DQExpression.Value(1), "BillType"));
+ q1.Columns.Add(DQSelectColumn.Field("Name",car1));
+ q1.Columns.Add(DQSelectColumn.Field("Number", d1));
+ q1.Columns.Add(DQSelectColumn.Field("WeighTime"));
+ q1.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("PrintNumber", 0), DQCondition.EQ("DeleteState", false)));
+ q1.Where.Conditions.Add(DQCondition.Or(DQCondition.EQ(car1, "Driver_IDCard", idCard), DQCondition.EQ(supper1, "IDCardNumber", idCard), DQCondition.EQ(employee1, "IDCardNumber", idCard)));
+ return q1;
+ }
+
+ static DQueryDom GetSendPigQueryDom(string idCard)
+ {
+ var m1 = new JoinAlias(typeof(SendPigRecord));
+ var d1 = new JoinAlias(typeof(FarmerRecord));
+ var car2 = new JoinAlias("car2", typeof(Car));
+ var supper2 = new JoinAlias("supper2", typeof(Supplier));
+ var employee2 = new JoinAlias("emp2", typeof(MinEmployee));
+ var q1 = new DQueryDom(m1);
+ q1.From.AddJoin(JoinType.Left, new DQDmoSource(d1), DQCondition.EQ(m1, "ID", d1, "SendPigRecord_ID"));
+ q1.From.AddJoin(JoinType.Left, new DQDmoSource(car2), DQCondition.EQ(m1, "carID", car2, "ID"));
+ q1.From.AddJoin(JoinType.Left, new DQDmoSource(supper2), DQCondition.EQ(m1, "supplierID", supper2, "ID"));
+ q1.From.AddJoin(JoinType.Left, new DQDmoSource(employee2), DQCondition.EQ(m1, "employeeID", employee2, "ID"));
+ q1.Columns.Add(DQSelectColumn.Field("ID"));
+ q1.Columns.Add(DQSelectColumn.Create(DQExpression.Value(0), "BillType"));
+ q1.Columns.Add(DQSelectColumn.Field("Name",car2));
+ q1.Columns.Add(DQSelectColumn.Field("number", d1));
+ q1.Columns.Add(DQSelectColumn.Field("BillTime"));
+ q1.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("WeightBill_ID")));
+ q1.Where.Conditions.Add(DQCondition.Or(DQCondition.EQ(car2, "Driver_IDCard", idCard), DQCondition.EQ(supper2, "IDCardNumber", idCard), DQCondition.EQ(employee2, "IDCardNumber", idCard)));
+ return q1;
+ }
+
+ [Rpc(RpcFlags.SkipAuth)]
+ public static string CreateWeightBill(long id)
+ {
+ using (var session = Dmo.NewSession())
+ {
+ var entity = Load(session, new Tuple("ID", id));
+ var details = LoadList(session, new Tuple("SendPigRecord_ID", id));
+ var weight = new WeightBill();
+ weight.ModifyTime = DateTime.Now;
+ weight.AccountingUnit_ID = 1;
+ weight.Department_ID = 2;
+ weight.Employee_Name = entity.employee;
+ weight.Employee_ID = entity.employeeID;
+ weight.WeighTime = DateTime.Now;
+ weight.Supplier_ID = entity.supplierID;
+ weight.Supplier_Name = entity.supplier;
+ weight.BankAccount = entity.supplierIDCard;
+ weight.PurchaseType_ID = entity.bType + 1;
+ weight.PurchaseType_Name = entity.bType == 0 ? "社会" : "业务";
+ weight.Car_Name = entity.carNum;
+ weight.Car_ID = entity.carID;
+ weight.JingJianFee = entity.jjf;
+ weight.DiscontMoney = entity.discont;
+ weight.ShackWeight = details.Sum(x => x.weight ?? 0);
+ weight.ShackMoney = details.Sum(x => x.money ?? 0);
+ if (weight.ShackWeight != 0)
+ {
+ weight.ShackPrice = (weight.ShackMoney + (weight.JingJianFee ?? 0) - (weight.DiscontMoney ?? 0)) / weight.ShackWeight;
+ if (weight.ShackPrice.HasValue)
+ weight.ShackPrice = decimal.Round(weight.ShackPrice.Value, 2);
+ }
+ weight.AnimalTestNumber = entity.testNo;
+ weight.AnimalTestMan = entity.testMan;
+ if (!string.IsNullOrEmpty(entity.testDate))
+ weight.AnimalTestDate = DateTime.Parse(entity.testDate);
+ if (details.Any())
+ weight.Farmer_ID = details.First().farmerID;
+ session.Insert(weight);
+ foreach (var item in details)
+ {
+ var d = new WeightBill_FarmerDetail();
+ d.WeightBill_ID = weight.ID;
+ d.Index = item.fidx;
+ d.Farmer_ID = item.farmerID;
+ d.Farmer_Name = item.fName;
+ d.Number = item.number;
+ d.Weight = item.weight;
+ d.Money = item.money;
+ d.Farmer_IDCard = item.fIDCard;
+ d.Farmer_Tel = item.fTel;
+ d.Farmer_BankAccount = item.bankNum;
+ d.Farmer_Address = item.fAddress;
+ session.Insert(d);
+ weight.FarmerDetails.Add(d);
+ }
+ FillSendPigWeightID(session, id, weight.ID);
+ session.Commit();
+ return JsonConvert.SerializeObject(weight);
+ }
+ }
+
+ private static void FillSendPigWeightID(IDmoSession session, long id, long weightID)
+ {
+ var update = new DQUpdateDom(typeof(SendPigRecord));
+ update.Columns.Add(new DQUpdateColumn("WeightBill_ID", weightID));
+ update.Where.Conditions.Add(DQCondition.EQ("ID", id));
+ session.ExecuteNonQuery(update);
+ }
+
+ static T Load(IDmoSession session, params Tuple[] parameters)
+ where T : class
+ {
+ var query = new DmoQuery(typeof(T));
+ foreach (var item in parameters)
+ query.Where.Conditions.Add(DQCondition.EQ(item.Item1, item.Item2));
+ query.Range = SelectRange.Top(1);
+ var r = session.ExecuteScalar(query);
+ if (r != null)
+ return r as T;
+ return null;
+ }
+
+ static IEnumerable LoadList(IDmoSession session, params Tuple[] parameters)
+ {
+ var query = new DmoQuery(typeof(T));
+ foreach (var item in parameters)
+ query.Where.Conditions.Add(DQCondition.EQ(item.Item1, item.Item2));
+ return session.ExecuteList(query).Cast();
+ }
+
+ [Rpc(RpcFlags.SkipAuth)]
+ public static string GetWeightBill(long id)
+ {
+ using (var session = Dmo.NewSession())
+ {
+ var dmo = Load(session, new Tuple("ID", id));
+ var w = LoadList(session, new Tuple("WeightBill_ID", id), new Tuple("DeleteState", false));
+ var f = LoadList(session, new Tuple("WeightBill_ID", id), new Tuple("DeleteState", false));
+ dmo.Details.AddRange(w);
+ dmo.FarmerDetails.AddRange(f);
+ return JsonConvert.SerializeObject(dmo);
+ }
+ }
+
+ [Rpc(RpcFlags.SkipAuth)]
+ public static string GetWeightDetail(long id)
+ {
+ using (var session = Dmo.NewSession())
+ {
+ var f = LoadList(session, new Tuple("WeightBill_ID", id), new Tuple("DeleteState", false));
+ return JsonConvert.SerializeObject(f);
+ }
+ }
+
+ class ViewEntity
+ {
+ public long ID { get; set; }
+
+ public int BillType { get; set; }
+
+ public string CarNumber { get; set; }
+
+ public int Number { get; set; }
+
+ public DateTime Date { get; set; }
+ }
+ }
+}
diff --git a/B3ClientService/Tasks/SyncInfoFromServer.cs b/B3ClientService/Tasks/SyncInfoFromServer.cs
index cb18343..0f05416 100644
--- a/B3ClientService/Tasks/SyncInfoFromServer.cs
+++ b/B3ClientService/Tasks/SyncInfoFromServer.cs
@@ -242,6 +242,7 @@ namespace BWP.B3ClientService.Tasks
entity.Code = o.Get("Code");
entity.Stopped = o.Get("Stopped");
entity.Domain_ID = o.Get("Domain_ID");
+ entity.IDCardNumber = o.Get("IDCardNumber");
entity.IsLocked = false;
entity.CreateTime = DateTime.Today;
entity.ModifyTime = entity.CreateTime;
@@ -353,6 +354,7 @@ namespace BWP.B3ClientService.Tasks
entity.ID = o.Get("ID");
entity.Name = o.Get("Name");
entity.Spell = o.Get("Spell");
+ entity.IDCardNumber = o.Get("Card_ID");
entity.BankAccount = o.Get("BankAccount");
context.Session.Insert(entity);
}
@@ -439,7 +441,14 @@ namespace BWP.B3ClientService.Tasks
entity.ID = o.Get("ID");
entity.Name = o.Get("Name");
entity.Spell = o.Get("Spell");
- context.Session.Insert(entity);
+ if (entity is Car)
+ {
+ var car = entity as Car;
+ car.Driver_IDCard = o.Get("Driver_IDCard");
+ context.Session.Insert(car);
+ }
+ else
+ context.Session.Insert(entity);
}
context.Commit();
}