diff --git a/B3ClientService.Web/B3ClientService.Web.csproj b/B3ClientService.Web/B3ClientService.Web.csproj
index c3fc747..c43fe72 100644
--- a/B3ClientService.Web/B3ClientService.Web.csproj
+++ b/B3ClientService.Web/B3ClientService.Web.csproj
@@ -116,6 +116,9 @@
ASPXCodeBehind
+
+ ASPXCodeBehind
+
ASPXCodeBehind
diff --git a/B3ClientService.Web/Pages/B3ClientService/Bills/SectionConfigPage.cs b/B3ClientService.Web/Pages/B3ClientService/Bills/SectionConfigPage.cs
new file mode 100644
index 0000000..a833f64
--- /dev/null
+++ b/B3ClientService.Web/Pages/B3ClientService/Bills/SectionConfigPage.cs
@@ -0,0 +1,113 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security;
+using System.Text;
+using System.Web.UI.HtmlControls;
+using TSingSoft.WebPluginFramework.Controls;
+using TSingSoft.WebPluginFramework.Pages;
+using TSingSoft.WebControls2;
+using Forks.EnterpriseServices.DomainObjects2.DQuery;
+using Forks.EnterpriseServices.DomainObjects2;
+using BWP.B3ClientService.BO;
+using BWP.B3ClientService;
+using System.Web.UI.WebControls;
+using TSingSoft.WebPluginFramework;
+using BWP.B3Frameworks.Utils;
+using Forks.Utils.Collections;
+using Forks.EnterpriseServices.DataForm;
+
+namespace BWP.Web.Pages.B3ClientService.Bills
+{
+ class SectionConfigPage : ServerPage
+ {
+ protected override void OnInit(EventArgs e)
+ {
+ if (!User.IsInRole("B3ClientService.系统管理.条段配置"))
+ throw new SecurityException();
+ base.OnInit(e);
+ }
+
+ DFBrowseGrid _browseGrid;
+ protected override void InitForm(HtmlForm form)
+ {
+ form.EAdd(new PageTitle("白条损耗"));
+ AddToolBar(form);
+ _browseGrid = form.EAdd(new DFBrowseGrid(new DFDataTableEditor()) { Width = Unit.Percentage(100) }); _browseGrid.Columns.EAdd(new DFGridCustomExtColumn((obj, cell, rowIndex) =>
+ {
+ var row = obj as DFDataRow;
+ var link = new LinkButton();
+ link.Text = "×";
+ link.OnClientClick = "if(!confirm('" + AspUtil.ConvertToJSAlertString("确认删除?") + "')) return false;";
+ link.Click += delegate
+ {
+ var delete = new DQDeleteDom(typeof(SectionGoodsConfig));
+ delete.Where.Conditions.Add(DQCondition.EQ("Goods_ID", (long)row["Goods_ID"]));
+ delete.EExecute();
+ _browseGrid.DataBind();
+ };
+ cell.Controls.Add(link);
+ })).HeaderText = "×";
+ _browseGrid.Columns.Add(new DFBrowseGridColumn("Goods_Name"));
+ _browseGrid.Columns.Add(new DFBrowseGridColumn("RelateGoods_Name"));
+ _browseGrid.PreferWidthGridSet = new Dictionary { { "×", Unit.Pixel(20) } };
+ }
+
+ private void AddToolBar(HtmlForm form)
+ {
+ var hPanel = form.EAdd(new HLayoutPanel());
+ hPanel.Add(new SimpleLabel("主条段"));
+ var main = hPanel.Add(new ChoiceBox(B3ClientServiceConsts.DataSources.存货) { Width = Unit.Pixel(160), EnableInputArgument = true, EnableTopItem = true });
+ hPanel.Add(new SimpleLabel("辅条段"));
+ var refer = hPanel.Add(new ChoiceBox(B3ClientServiceConsts.DataSources.存货) { Width = Unit.Pixel(160), EnableInputArgument = true, EnableTopItem = true });
+ hPanel.Add(new TSButton("添加", delegate
+ {
+ if (main.IsEmpty || refer.IsEmpty)
+ return;
+ var mainID = long.Parse(main.Value);
+ CheckExist(mainID);
+ using (var session = Dmo.NewSession())
+ {
+ var entity = new SectionGoodsConfig
+ {
+ Goods_ID = mainID,
+ RelateGoods_ID = long.Parse(refer.Value)
+ };
+ session.Insert(entity);
+ session.Commit();
+ }
+ main.Clear();
+ refer.Clear();
+ _browseGrid.DataBind();
+ }));
+ }
+
+ void CheckExist(long id)
+ {
+ var query = new DQueryDom(new JoinAlias(typeof(SectionGoodsConfig)));
+ query.Where.Conditions.Add(DQCondition.EQ("Goods_ID", id));
+ if (query.EExists())
+ throw new Exception("不允许重复添加主条段");
+ }
+
+ DQueryDom GetQueryDom()
+ {
+ var query = new DQueryDom(new JoinAlias(typeof(SectionGoodsConfig)));
+ query.Columns.Add(DQSelectColumn.Field("Goods_ID"));
+ query.Columns.Add(DQSelectColumn.Field("Goods_Name"));
+ query.Columns.Add(DQSelectColumn.Field("RelateGoods_Name"));
+ query.OrderBy.Expressions.Add(DQOrderByExpression.Create("Goods_ID"));
+ return query;
+ }
+
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+ if (!IsPostBack)
+ {
+ _browseGrid.Query = GetQueryDom();
+ _browseGrid.DataBind();
+ }
+ }
+ }
+}
diff --git a/B3ClientService/B3ClientService.csproj b/B3ClientService/B3ClientService.csproj
index 8f82816..fab28fc 100644
--- a/B3ClientService/B3ClientService.csproj
+++ b/B3ClientService/B3ClientService.csproj
@@ -155,6 +155,8 @@
+
+
@@ -198,6 +200,7 @@
+
diff --git a/B3ClientService/BO/Bill/SectionStore/SectionGoodsConfig.cs b/B3ClientService/BO/Bill/SectionStore/SectionGoodsConfig.cs
new file mode 100644
index 0000000..baef185
--- /dev/null
+++ b/B3ClientService/BO/Bill/SectionStore/SectionGoodsConfig.cs
@@ -0,0 +1,33 @@
+using Forks.EnterpriseServices;
+using Forks.EnterpriseServices.DataForm;
+using Forks.EnterpriseServices.DomainObjects2;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TSingSoft.WebPluginFramework;
+
+namespace BWP.B3ClientService.BO
+{
+ [BOClass, Serializable, DFClass]
+ [LogicName("条段配置表")]
+ [KeyField("Goods_ID", KeyGenType.assigned)]
+ public class SectionGoodsConfig
+ {
+ [LogicName("主条段")]
+ public long Goods_ID { get; set; }
+
+ [LogicName("辅条段")]
+ public long RelateGoods_ID { get; set; }
+
+ [LogicName("主条段")]
+ [ReferenceTo(typeof(Goods), "Name")]
+ [Join("Goods_ID", "ID")]
+ public string Goods_Name { get; set; }
+
+ [LogicName("辅条段")]
+ [ReferenceTo(typeof(Goods), "Name")]
+ [Join("RelateGoods_ID", "ID")]
+ public string RelateGoods_Name { get; set; }
+ }
+}
diff --git a/B3ClientService/BO/Bill/SectionStore/SectionStoreDetail.cs b/B3ClientService/BO/Bill/SectionStore/SectionStoreDetail.cs
new file mode 100644
index 0000000..5b78b48
--- /dev/null
+++ b/B3ClientService/BO/Bill/SectionStore/SectionStoreDetail.cs
@@ -0,0 +1,40 @@
+using BWP.B3ClientService.NamedValueTemplate;
+using BWP.B3Frameworks.BO;
+using Forks.EnterpriseServices;
+using Forks.EnterpriseServices.DataForm;
+using Forks.EnterpriseServices.DomainObjects2;
+using Forks.Utils;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BWP.B3ClientService.BO
+{
+ [DFClass]
+ [LogicName("条段数据表")]
+ public class SectionStoreDetail : Base
+ {
+ public string BarCode { get; set; }
+
+ public decimal? Weight { get; set; }
+
+ public long? ProductBatch_ID { get; set; }
+
+ public long? Goods_ID { get; set; }
+
+ public DateTime InStoreTime { get; set; }
+
+ public DateTime? OutStoreTime { get; set; }
+
+ public NamedValue<领用类型>? PickType { get; set; }
+
+ public long Worker_ID { get; set; }
+
+ public bool TakeOutCreate { get; set; }
+
+ [ReferenceTo(typeof(Goods),"Name")]
+ [Join("Goods_ID", "ID")]
+ public string Goods_Name { get; set; }
+ }
+}
diff --git a/B3ClientService/NamedValueTemplate.cs b/B3ClientService/NamedValueTemplate.cs
index 4c47d2e..a592223 100644
--- a/B3ClientService/NamedValueTemplate.cs
+++ b/B3ClientService/NamedValueTemplate.cs
@@ -34,5 +34,6 @@ namespace BWP.B3ClientService.NamedValueTemplate
{
public static readonly NamedValue<领用类型> 分割领用 = new NamedValue<领用类型>(0);
public static readonly NamedValue<领用类型> 白条销售 = new NamedValue<领用类型>(1);
+ public static readonly NamedValue<领用类型> 条转段 = new NamedValue<领用类型>(2);
}
}
diff --git a/B3ClientService/OfflinRpc/CarcassSaleOutStoreRpc.cs b/B3ClientService/OfflinRpc/CarcassSaleOutStoreRpc.cs
index ceed17f..6001a0c 100644
--- a/B3ClientService/OfflinRpc/CarcassSaleOutStoreRpc.cs
+++ b/B3ClientService/OfflinRpc/CarcassSaleOutStoreRpc.cs
@@ -6,6 +6,7 @@ using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.JsonRpc;
using Forks.EnterpriseServices.SqlDoms;
+using Forks.Utils;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -26,25 +27,28 @@ namespace BWP.B3ClientService.Rpcs
{
foreach (var item in list)
{
- var id = GetID(item.BarCode, session);
- if (id.HasValue)
- Update(id.Value, item, session);
- else
+ var carcassInfo = GetCarcassInfo(item.BarCode, session);
+ if (carcassInfo == null)
Insert(item, session);
+ else if (carcassInfo.Item2 == 领用类型.条转段)
+ FillSectionStoreWeight(item, session);
+ else
+ Update(carcassInfo.Item1, item, session);
}
session.Commit();
}
return 1;
}
- static long? GetID(string code, IDmoSession session)
+ static Tuple?> GetCarcassInfo(string code, IDmoSession session)
{
if (string.IsNullOrEmpty(code))
return null;
var query = new DQueryDom(new JoinAlias(typeof(CarcassFullInfo)));
query.Columns.Add(DQSelectColumn.Field("ID"));
+ query.Columns.Add(DQSelectColumn.Field("PickType"));
query.Where.Conditions.Add(DQCondition.EQ("BarCode", code));
- return query.EExecuteScalar(session);
+ return query.EExecuteScalar?>(session);
}
static void Update(long id, CarcassSaleOutStoreObj obj, IDmoSession session)
@@ -86,6 +90,16 @@ namespace BWP.B3ClientService.Rpcs
return GoodsCodeToID[code];
}
+ static void FillSectionStoreWeight(CarcassSaleOutStoreObj item, IDmoSession session)
+ {
+ var update = new DQUpdateDom(typeof(SectionStoreDetail));
+ update.Columns.Add(new DQUpdateColumn("Weight", item.Weight));
+ update.Columns.Add(new DQUpdateColumn("OutStoreTime", item.Time));
+ update.Columns.Add(new DQUpdateColumn("PickType", 领用类型.白条销售));
+ update.Where.Conditions.Add(DQCondition.EQ("BarCode", item.BarCode));
+ session.ExecuteNonQuery(update);
+ }
+
[Rpc(RpcFlags.SkipAuth)]
public static string GetCarcassInstoreInfo(string barCode)
{
@@ -106,7 +120,6 @@ namespace BWP.B3ClientService.Rpcs
}
return JsonConvert.SerializeObject(entity);
}
-
}
class CarcassSaleOutStoreObj
diff --git a/B3ClientService/OfflinRpc/CarcassTakeOutRpc.cs b/B3ClientService/OfflinRpc/CarcassTakeOutRpc.cs
index 3b48752..ac715d4 100644
--- a/B3ClientService/OfflinRpc/CarcassTakeOutRpc.cs
+++ b/B3ClientService/OfflinRpc/CarcassTakeOutRpc.cs
@@ -104,5 +104,7 @@ namespace BWP.B3ClientService.Rpcs
public decimal? Weight { get; set; }
public DateTime? Time { get; set; }
public long? GroupID { get; set; }
+ public int Number { get; set; }
+ public long Worker_ID { get; set; }
}
}
diff --git a/B3ClientService/OfflinRpc/SectionStoreDetailRpc.cs b/B3ClientService/OfflinRpc/SectionStoreDetailRpc.cs
new file mode 100644
index 0000000..65e6357
--- /dev/null
+++ b/B3ClientService/OfflinRpc/SectionStoreDetailRpc.cs
@@ -0,0 +1,185 @@
+using BWP.B3ClientService.BO;
+using BWP.B3ClientService.NamedValueTemplate;
+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 SectionStoreDetailRpc
+ {
+ [Rpc(RpcFlags.SkipAuth)]
+ public static int Insert(string json)
+ {
+ var arr = JsonConvert.DeserializeObject>(json);
+ if (arr.Count == 0)
+ return 0;
+ using (var session = Dmo.NewSession())
+ {
+ var query = new DQueryDom(new JoinAlias(typeof(CarcassFullInfo)));
+ query.Columns.Add(DQSelectColumn.Field("BarCode"));
+ query.Columns.Add(DQSelectColumn.Field("ProductBatch_ID"));
+ query.Columns.Add(DQSelectColumn.Field("ID"));
+ query.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("BarCode"), arr.Select(x => DQExpression.Value(x.BarCode)).ToArray()));
+
+ var config = GetSectionConfig(session);
+ using (var reader = session.ExecuteReader(query))
+ {
+ while (reader.Read())
+ {
+ var entity = new SectionStoreDetail();
+ entity.BarCode = (string)reader[0];
+ var f = arr.First(x => x.BarCode == entity.BarCode);
+ entity.InStoreTime = f.InStoreTime;
+ entity.ProductBatch_ID = (long?)reader[1];
+ entity.Goods_ID = f.Goods_ID;
+ entity.Worker_ID = f.Worker_ID;
+
+ var e2 = new SectionStoreDetail();
+ e2.InStoreTime = entity.InStoreTime;
+ e2.ProductBatch_ID = entity.ProductBatch_ID;
+ var c = config.FirstOrDefault(x => x.Item1 == entity.Goods_ID.Value);
+ if (c == null)
+ throw new Exception("未配置条段对应关系");
+ e2.Goods_ID = c.Item2;
+ e2.Worker_ID = entity.Worker_ID;
+
+ session.Insert(entity);
+ session.Insert(e2);
+
+ SetCarcassTakeOut(session, (long)reader[2], entity.InStoreTime, entity.Worker_ID);
+ }
+ }
+
+ session.Commit();
+ }
+ return arr.Count;
+ }
+
+ static void SetCarcassTakeOut(IDmoSession session, long id, DateTime time, long worker_ID)
+ {
+ var update = new DQUpdateDom(typeof(CarcassFullInfo));
+ update.Columns.Add(new DQUpdateColumn("PickWeight", DQExpression.Field("InStoreWeight")));
+ update.Columns.Add(new DQUpdateColumn("PickWorker_ID", worker_ID));
+ update.Columns.Add(new DQUpdateColumn("PickTime", time));
+ update.Columns.Add(new DQUpdateColumn("PickType", 领用类型.条转段));
+ update.Where.Conditions.Add(DQCondition.EQ("ID", id));
+ session.ExecuteNonQuery(update);
+ }
+
+ static List> GetSectionConfig(IDmoSession session)
+ {
+ var query = new DQueryDom(new JoinAlias(typeof(SectionGoodsConfig)));
+ query.Columns.Add(DQSelectColumn.Field("Goods_ID"));
+ query.Columns.Add(DQSelectColumn.Field("RelateGoods_ID"));
+ return query.EExecuteList(session);
+ }
+
+ [Rpc(RpcFlags.SkipAuth)]
+ public static string GetSectionConfig()
+ {
+ var query = new DQueryDom(new JoinAlias(typeof(SectionGoodsConfig)));
+ query.Columns.Add(DQSelectColumn.Field("Goods_ID"));
+ query.Columns.Add(DQSelectColumn.Field("Goods_Name"));
+ var list = query.EExecuteList().Select(x => new ExtensionObj { LongExt1 = x.Item1, StringExt1 = x.Item2 });
+ return JsonConvert.SerializeObject(list);
+ }
+
+ [Rpc(RpcFlags.SkipAuth)]
+ public static int FillWeight(string json)
+ {
+ var list = JsonConvert.DeserializeObject>(json);
+ using (var session = Dmo.NewSession())
+ {
+ foreach (var item in list)
+ {
+ var ids = GetIDs(session, item);
+ for (var i = 0; i < item.Number; i++)
+ {
+ var id = ids.FirstOrDefault();
+ if (id == 0)
+ {
+ Insert(session, item);
+ }
+ else
+ {
+ Update(session, id, item);
+ ids.Remove(id);
+ }
+ }
+ }
+ session.Commit();
+ }
+ return 1;
+ }
+
+ private static void Insert(IDmoSession session, CarcassTakeOutObj item)
+ {
+ var entity = new SectionStoreDetail();
+ entity.BarCode = item.BarCode;
+ entity.Goods_ID = item.Goods_ID;
+ entity.InStoreTime = item.Time.Value;
+ entity.OutStoreTime = entity.InStoreTime;
+ entity.PickType = 领用类型.分割领用;
+ entity.ProductBatch_ID = item.ProductBatch_ID;
+ entity.TakeOutCreate = true;
+ entity.Weight = item.Weight;
+ entity.Worker_ID = item.Worker_ID;
+ session.Insert(entity);
+ }
+
+ private static void Update(IDmoSession session, long id, CarcassTakeOutObj item)
+ {
+ var update = new DQUpdateDom(typeof(SectionStoreDetail));
+ update.Columns.Add(new DQUpdateColumn("Weight", item.Weight));
+ update.Columns.Add(new DQUpdateColumn("OutStoreTime", item.Time));
+ update.Columns.Add(new DQUpdateColumn("PickType", 领用类型.分割领用));
+ update.Where.Conditions.Add(DQCondition.EQ("ID", id));
+ session.ExecuteNonQuery(update);
+ }
+
+ static List GetIDs(IDmoSession session, CarcassTakeOutObj item)
+ {
+ var query = new DQueryDom(new JoinAlias(typeof(SectionStoreDetail)));
+ query.Columns.Add(DQSelectColumn.Field("ID"));
+ query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("OutStoreTime")));
+ if (string.IsNullOrEmpty(item.BarCode))
+ {
+ query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Goods_ID", item.Goods_ID), DQCondition.EQ("ProductBatch_ID", item.ProductBatch_ID)));
+ query.Range = SelectRange.Top(item.Number);
+ query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
+ }
+ else
+ query.Where.Conditions.Add(DQCondition.EQ("BarCode", item.BarCode));
+ return query.EExecuteList(session);
+ }
+
+ [Rpc(RpcFlags.SkipAuth)]
+ public static string GetTestJson()
+ {
+ var list = new List();
+ list.Add(new SectionInfo { Worker_ID = 5, BarCode = "2609234234234009009", Goods_ID = 45, InStoreTime = DateTime.Now });
+ list.Add(new SectionInfo { Worker_ID = 5, BarCode = "2609234234234011012", Goods_ID = 47, InStoreTime = DateTime.Now });
+ return JsonConvert.SerializeObject(list);
+ }
+ }
+
+ class SectionInfo
+ {
+ public long Worker_ID { get; set; }
+
+ public string BarCode { get; set; }
+
+ public long Goods_ID { get; set; }
+
+ public DateTime InStoreTime { get; set; }
+ }
+}
diff --git a/WebFolder/config/NamedValue/B3ClientService.xml b/WebFolder/config/NamedValue/B3ClientService.xml
index 128b884..254c1e4 100644
--- a/WebFolder/config/NamedValue/B3ClientService.xml
+++ b/WebFolder/config/NamedValue/B3ClientService.xml
@@ -21,5 +21,6 @@
+
\ No newline at end of file
diff --git a/WebFolder/config/plugins/B3ClientService.plugin b/WebFolder/config/plugins/B3ClientService.plugin
index c99838d..c28c092 100644
--- a/WebFolder/config/plugins/B3ClientService.plugin
+++ b/WebFolder/config/plugins/B3ClientService.plugin
@@ -37,6 +37,7 @@
+
@@ -123,6 +124,7 @@
+