屠宰场管理服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.5 KiB

using BWP.B3ClientService.BO;
using BWP.B3Frameworks.Utils;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
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.Rpcs
{
[Rpc]
public static class ButcherOrderRpc
{
[Rpc]
public static List<ButcherOrder> GetButcherOrder(DateTime date)
{
var query = new DmoQuery(typeof(ButcherOrder));
query.Where.Conditions.Add(DQCondition.EQ("Date", date));
return query.EExecuteList().Cast<ButcherOrder>().ToList();
}
[Rpc]
public static List<ButcherOrder_Detail> GetOrderDetail(long orderID)
{
var query = new DmoQuery(typeof(ButcherOrder_Detail));
query.Where.Conditions.Add(DQCondition.EQ("ButcherOrder_ID", orderID));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
return query.EExecuteList().Cast<ButcherOrder_Detail>().ToList();
}
static void UpdateButcherOrder(IDmoSession session, long id, int hotFadeNumber)
{
var order = InnerBLUtil.GetSingleDmo<ButcherOrder>(session, "ID", id, "HotFadeNumber", "Sync");
order.HotFadeNumber += hotFadeNumber;
if (hotFadeNumber < 0 && order.Sync)
order.Sync = false;
var update = new DQUpdateDom(typeof(ButcherOrder));
update.Where.Conditions.Add(DQCondition.EQ("HotFadeNumber", order.HotFadeNumber));
update.Where.Conditions.Add(DQCondition.EQ("Sync", order.Sync));
update.Where.Conditions.Add(DQCondition.EQ("ID", id));
session.ExecuteNonQuery(update);
}
[Rpc]
public static void InsertOrderDetail(long orderID, int number)
{
using (var session = Dmo.NewSession())
{
var detail = new ButcherOrder_Detail();
detail.Number = number;
detail.Date = DateTime.Now;
detail.ButcherOrder_ID = orderID;
session.Insert(detail);
UpdateButcherOrder(session, orderID, detail.Number);
session.Commit();
}
}
[Rpc]
public static void DeleteOrderDetail(long id)
{
using (var session = Dmo.NewSession())
{
var detail = InnerBLUtil.GetSingleDmo<ButcherOrder_Detail>(session, "ID", id, "ButcherOrder_ID", "Number");
UpdateButcherOrder(session, detail.ButcherOrder_ID, -detail.Number);
session.Commit();
}
}
}
}