Browse Source

master
yibo 8 years ago
parent
commit
cfc67fc2ec
3 changed files with 137 additions and 32 deletions
  1. +65
    -27
      BO/Utils/BillRpc/GradeAndWeightRpc.cs
  2. +2
    -2
      WeighAndGrading/AbnormalModifyForm.cs
  3. +70
    -3
      WeighAndGrading/GradeFrom.cs

+ 65
- 27
BO/Utils/BillRpc/GradeAndWeightRpc.cs View File

@ -51,15 +51,12 @@ namespace BO.Utils.BillRpc
{ {
static JavaScriptSerializer serializer = new JavaScriptSerializer(); static JavaScriptSerializer serializer = new JavaScriptSerializer();
public static void ClearWeightBySID(long sid) public static void ClearWeightBySID(long sid)
{ {
var updateDom = new DQUpdateDom(typeof(GradeAndWeight_Detail)); var updateDom = new DQUpdateDom(typeof(GradeAndWeight_Detail));
updateDom.Where.Conditions.Add(DQCondition.EQ("SID", sid)); updateDom.Where.Conditions.Add(DQCondition.EQ("SID", sid));
updateDom.Columns.Add(new DQUpdateColumn("Weight", DQExpression.NULL)); updateDom.Columns.Add(new DQUpdateColumn("Weight", DQExpression.NULL));
updateDom.Columns.Add(new DQUpdateColumn("Sync", false));
using (var session = LocalDmoSession.New()) using (var session = LocalDmoSession.New())
{ {
session.ExecuteNonQuery(updateDom); session.ExecuteNonQuery(updateDom);
@ -69,11 +66,13 @@ namespace BO.Utils.BillRpc
public static void DeleteBySID(long sid) public static void DeleteBySID(long sid)
{ {
var delDom = new DQDeleteDom(typeof(GradeAndWeight_Detail));
delDom.Where.Conditions.Add(DQCondition.EQ("SID", sid));
var updateDom = new DQUpdateDom(typeof(GradeAndWeight_Detail));
updateDom.Where.Conditions.Add(DQCondition.EQ("SID", sid));
updateDom.Columns.Add(new DQUpdateColumn("IsDeleted", true));
updateDom.Columns.Add(new DQUpdateColumn("Sync", false));
using (var session = LocalDmoSession.New()) using (var session = LocalDmoSession.New())
{ {
session.ExecuteNonQuery(delDom);
session.ExecuteNonQuery(updateDom);
session.Commit(); session.Commit();
} }
} }
@ -98,7 +97,7 @@ namespace BO.Utils.BillRpc
var list = new List<GradeAndWeight_Detail>(); var list = new List<GradeAndWeight_Detail>();
var query = new DmoQuery(typeof(GradeAndWeight_Detail)); var query = new DmoQuery(typeof(GradeAndWeight_Detail));
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("Date", date)));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Index", true)); query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Index", true));
query.Range = SelectRange.Top(top); query.Range = SelectRange.Top(top);
using (var session = LocalDmoSession.New()) using (var session = LocalDmoSession.New())
@ -112,11 +111,10 @@ namespace BO.Utils.BillRpc
return bindList; return bindList;
} }
public static int GetTangTuiSumNumber(DateTime date)
public static int GetSumNumber(DateTime date, short type)
{ {
var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail))); var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail)));
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
query.Where.Conditions.Add(DQCondition.EQ("Technics_Name", "烫褪"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("Technics", type), DQCondition.EQ("Date", date)));
query.Columns.Add(DQSelectColumn.Count()); query.Columns.Add(DQSelectColumn.Count());
using (var session = LocalDmoSession.New()) using (var session = LocalDmoSession.New())
{ {
@ -124,21 +122,39 @@ namespace BO.Utils.BillRpc
} }
} }
public static int GetMaoBoSumNumber(DateTime date)
{
var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail)));
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
query.Where.Conditions.Add(DQCondition.EQ("Technics_Name", "毛剥"));
query.Columns.Add(DQSelectColumn.Count());
using (var session = LocalDmoSession.New())
{
return Convert.ToInt32(session.ExecuteScalar(query));
}
}
//public static int GetSumNumber(long orderID, short type)
//{
// var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail)));
// query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("Technics", type), DQCondition.EQ("OrderDetail_ID", orderID)));
// query.Columns.Add(DQSelectColumn.Count());
// using (var session = LocalDmoSession.New())
// {
// return Convert.ToInt32(session.ExecuteScalar(query));
// }
//}
//public static List<Tuple<short, int>> GetSumNumber(long orderID)
//{
// var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail)));
// query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("OrderDetail_ID", orderID)));
// query.Columns.Add(DQSelectColumn.Field("Technics"));
// query.Columns.Add(DQSelectColumn.Count());
// query.GroupBy.Expressions.Add(DQExpression.Field("Technics"));
// var list = new List<Tuple<short, int>>();
// using (var session = LocalDmoSession.New())
// {
// using (var reader = session.ExecuteReader(query))
// {
// list.Add(new Tuple<short, int>((short)reader[0], Convert.ToInt32(reader[1])));
// }
// return list;
// }
//}
public static decimal GetSumWeight(DateTime date) public static decimal GetSumWeight(DateTime date)
{ {
var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail))); var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail)));
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("Date", date)));
query.Columns.Add(DQSelectColumn.Sum("Weight")); query.Columns.Add(DQSelectColumn.Sum("Weight"));
using (var session = LocalDmoSession.New()) using (var session = LocalDmoSession.New())
@ -151,8 +167,7 @@ namespace BO.Utils.BillRpc
public static List<GradeAndWeight_Detail> GetLostWeightDetails(DateTime date) public static List<GradeAndWeight_Detail> GetLostWeightDetails(DateTime date)
{ {
var query = new DmoQuery(typeof(GradeAndWeight_Detail)); var query = new DmoQuery(typeof(GradeAndWeight_Detail));
query.Where.Conditions.Add(DQCondition.EQ("IsLostWeight", true));
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("IsLostWeight", true), DQCondition.EQ("Date", date)));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Index", true)); query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Index", true));
using (var session = LocalDmoSession.New()) using (var session = LocalDmoSession.New())
@ -202,13 +217,36 @@ namespace BO.Utils.BillRpc
public static void Sync() public static void Sync()
{ {
ClearUnSyncDelete();
var syncs = GetAllNeedSyncDetails(); var syncs = GetAllNeedSyncDetails();
foreach (var detail in syncs) foreach (var detail in syncs)
{ {
const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc/UpdateOrInsertDetailOrDelete"; const string method = "/MainSystem/B3ClientService/Rpcs/BillRpc/GradeAndWeightRpc/UpdateOrInsertDetailOrDelete";
var id = RpcFacade.Call<long>(method, serializer.Serialize(detail)); var id = RpcFacade.Call<long>(method, serializer.Serialize(detail));
if (detail.IsDeleted)
Delete(detail.SID);
else
SetDetailSynced(detail, id);
}
}
SetDetailSynced(detail, id);
static void ClearUnSyncDelete()
{
using (var session = LocalDmoSession.New())
{
var delete = new DQDeleteDom(typeof(GradeAndWeight_Detail));
delete.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", true), DQCondition.EQ("ID", 0)));
session.ExecuteNonQuery(delete);
}
}
static void Delete(long sid)
{
using (var session = LocalDmoSession.New())
{
var delete = new DQDeleteDom(typeof(GradeAndWeight_Detail));
delete.Where.Conditions.Add(DQCondition.EQ("SID", sid));
session.ExecuteNonQuery(delete);
} }
} }
@ -256,7 +294,7 @@ namespace BO.Utils.BillRpc
{ {
var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail))); var query = new DQueryDom(new JoinAlias(typeof(GradeAndWeight_Detail)));
query.Columns.Add(DQSelectColumn.Count()); query.Columns.Add(DQSelectColumn.Count());
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsDeleted", false), DQCondition.EQ("Date", date)));
using (var session = LocalDmoSession.New()) using (var session = LocalDmoSession.New())
{ {
return Convert.ToInt32(session.ExecuteScalar(query)); return Convert.ToInt32(session.ExecuteScalar(query));


+ 2
- 2
WeighAndGrading/AbnormalModifyForm.cs View File

@ -44,8 +44,8 @@ namespace WeighAndGrading
lblPaiZaiMB.Text = maoboList.Sum(x => x.Number).ToString(); lblPaiZaiMB.Text = maoboList.Sum(x => x.Number).ToString();
var tangtui = LocalGradeAndWeightBL.GetTangTuiSumNumber(mDate);
var maobo = LocalGradeAndWeightBL.GetMaoBoSumNumber(mDate);
var tangtui = LocalGradeAndWeightBL.GetSumNumber(mDate,0);
var maobo = LocalGradeAndWeightBL.GetSumNumber(mDate, 1);
var weight = LocalGradeAndWeightBL.GetSumWeight(mDate); var weight = LocalGradeAndWeightBL.GetSumWeight(mDate);
lblWeightTT.Text = tangtui.ToString(); lblWeightTT.Text = tangtui.ToString();


+ 70
- 3
WeighAndGrading/GradeFrom.cs View File

@ -143,14 +143,52 @@ namespace WeighAndGrading
} }
else else
{ {
var needUpdate = modifyDetail.Technics != livestockTag.Item3;
StartPrintEntity(tech, modifyDetail.Index); StartPrintEntity(tech, modifyDetail.Index);
modifyDetail.Livestock_ID = livestockTag.Item1; modifyDetail.Livestock_ID = livestockTag.Item1;
modifyDetail.Livestock_Name = livestockTag.Item2; modifyDetail.Livestock_Name = livestockTag.Item2;
modifyDetail.Technics = livestockTag.Item3; modifyDetail.Technics = livestockTag.Item3;
modifyDetail.Technics_Name = livestockTag.Item3 == TANG_TECH ? "烫褪" : "毛剥"; modifyDetail.Technics_Name = livestockTag.Item3 == TANG_TECH ? "烫褪" : "毛剥";
LocalGradeAndWeightBL.Update(modifyDetail, "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name"); LocalGradeAndWeightBL.Update(modifyDetail, "Livestock_ID", "Livestock_Name", "Technics", "Technics_Name");
if (needUpdate)
{
//因为工艺被修改 所以这里取相反
var currentRow = modifyDetail.Technics == 0 ? maoEntity : tangEntity;
if (currentRow != null)
{
currentRow.Already -= 1;
orderLabel.Text = currentRow.Order.ToString();
alreadyLabel.Text = currentRow.Already.ToString();
if (modifyDetail.Technics == 0)
{
maoGridView.Refresh();
foreach (DataGridViewRow row in tangGridView.Rows)
{
if ((long)row.Cells["T_OrderDetail_ID"].Value == modifyDetail.OrderDetail_ID)
{
var r = row.DataBoundItem as GradeAndWeight;
r.Already += 1;
tangGridView.Refresh();
break;
}
}
}
else
{
tangGridView.Refresh();
foreach (DataGridViewRow row in maoGridView.Rows)
{
if ((long)row.Cells["M_OrderDetail_ID"].Value == modifyDetail.OrderDetail_ID)
{
var r = row.DataBoundItem as GradeAndWeight;
r.Already += 1;
maoGridView.Refresh();
break;
}
}
}
}
}
noLivestockList = new ConcurrentQueue<GradeAndWeight_Detail>(); noLivestockList = new ConcurrentQueue<GradeAndWeight_Detail>();
var stack = new Stack<GradeAndWeight_Detail>(); var stack = new Stack<GradeAndWeight_Detail>();
@ -1038,7 +1076,7 @@ namespace WeighAndGrading
} }
} }
static object insertweightdetail=new object();
static object insertweightdetail = new object();
void LocalGradeAndWeightBLInsert(GradeAndWeight_Detail entity) void LocalGradeAndWeightBLInsert(GradeAndWeight_Detail entity)
{ {
//为了防止点级别和称重同时进行 //为了防止点级别和称重同时进行
@ -1147,6 +1185,35 @@ namespace WeighAndGrading
//删除选中 更新 IsDeleted 和 Sync //删除选中 更新 IsDeleted 和 Sync
lastCheckItem.IsDeleted = true; lastCheckItem.IsDeleted = true;
LocalGradeAndWeightBL.Update(lastCheckItem, "IsDeleted"); LocalGradeAndWeightBL.Update(lastCheckItem, "IsDeleted");
if (lastCheckItem.OrderDetail_ID.HasValue)
{
if (lastCheckItem.Technics == 0)
{
foreach (DataGridViewRow row in tangGridView.Rows)
{
if ((long)row.Cells["T_OrderDetail_ID"].Value == lastCheckItem.OrderDetail_ID.Value)
{
var r = row.DataBoundItem as GradeAndWeight;
r.Already -= 1;
tangGridView.Refresh();
break;
}
}
}
else
{
foreach (DataGridViewRow row in maoGridView.Rows)
{
if ((long)row.Cells["M_OrderDetail_ID"].Value == lastCheckItem.OrderDetail_ID.Value)
{
var r = row.DataBoundItem as GradeAndWeight;
r.Already -= 1;
maoGridView.Refresh();
break;
}
}
}
}
//修改本地 //修改本地
if (lastCheckItem.OrderDetail_ID.HasValue) if (lastCheckItem.OrderDetail_ID.HasValue)


Loading…
Cancel
Save