Browse Source

白条分段领用调整。

master
yibo 7 years ago
parent
commit
615e4b09ff
11 changed files with 403 additions and 7 deletions
  1. +3
    -0
      B3ClientService.Web/B3ClientService.Web.csproj
  2. +113
    -0
      B3ClientService.Web/Pages/B3ClientService/Bills/SectionConfigPage.cs
  3. +3
    -0
      B3ClientService/B3ClientService.csproj
  4. +33
    -0
      B3ClientService/BO/Bill/SectionStore/SectionGoodsConfig.cs
  5. +40
    -0
      B3ClientService/BO/Bill/SectionStore/SectionStoreDetail.cs
  6. +1
    -0
      B3ClientService/NamedValueTemplate.cs
  7. +20
    -7
      B3ClientService/OfflinRpc/CarcassSaleOutStoreRpc.cs
  8. +2
    -0
      B3ClientService/OfflinRpc/CarcassTakeOutRpc.cs
  9. +185
    -0
      B3ClientService/OfflinRpc/SectionStoreDetailRpc.cs
  10. +1
    -0
      WebFolder/config/NamedValue/B3ClientService.xml
  11. +2
    -0
      WebFolder/config/plugins/B3ClientService.plugin

+ 3
- 0
B3ClientService.Web/B3ClientService.Web.csproj View File

@ -116,6 +116,9 @@
<Compile Include="Pages\B3ClientService\Bills\CarcassInventory_\CarcassInventoryList.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Pages\B3ClientService\Bills\SectionConfigPage.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Pages\B3ClientService\Dialogs\SelectGoodsDialogs.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>


+ 113
- 0
B3ClientService.Web/Pages/B3ClientService/Bills/SectionConfigPage.cs View File

@ -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<string, Unit> { { "×", 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();
}
}
}
}

+ 3
- 0
B3ClientService/B3ClientService.csproj View File

@ -155,6 +155,8 @@
<Compile Include="BO\Bill\SaleOutStore_\SaleOutStore.cs" />
<Compile Include="BO\Bill\SecondOrder\SecondOrder.cs" />
<Compile Include="BO\Bill\SecondOrder\SecondOrder_Detail.cs" />
<Compile Include="BO\Bill\SectionStore\SectionGoodsConfig.cs" />
<Compile Include="BO\Bill\SectionStore\SectionStoreDetail.cs" />
<Compile Include="BO\Bill\SyncCarcassInStoreLog.cs" />
<Compile Include="BO\Bill\WeightBill\WeightBill.cs" />
<Compile Include="BO\Bill\WeightBill\WeightBillCheck.cs" />
@ -198,6 +200,7 @@
<Compile Include="OfflinRpc\ExtensionObj.cs" />
<Compile Include="OfflinRpc\GradeAndWeightBL.cs" />
<Compile Include="OfflinRpc\LoginRpc.cs" />
<Compile Include="OfflinRpc\SectionStoreDetailRpc.cs" />
<Compile Include="Rpcs\BillRpc\BaseInfoRpc.cs" />
<Compile Include="Rpcs\BillRpc\BeforeDeathRpc.cs" />
<Compile Include="Rpcs\BillRpc\ByProductWeightRecordRpc.cs" />


+ 33
- 0
B3ClientService/BO/Bill/SectionStore/SectionGoodsConfig.cs View File

@ -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; }
}
}

+ 40
- 0
B3ClientService/BO/Bill/SectionStore/SectionStoreDetail.cs View File

@ -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; }
}
}

+ 1
- 0
B3ClientService/NamedValueTemplate.cs View File

@ -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);
}
}

+ 20
- 7
B3ClientService/OfflinRpc/CarcassSaleOutStoreRpc.cs View File

@ -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<long, NamedValue<>?> 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<long?>(session);
return query.EExecuteScalar<long, NamedValue<>?>(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


+ 2
- 0
B3ClientService/OfflinRpc/CarcassTakeOutRpc.cs View File

@ -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; }
}
}

+ 185
- 0
B3ClientService/OfflinRpc/SectionStoreDetailRpc.cs View File

@ -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<List<SectionInfo>>(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<Tuple<long, long>> 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<long, long>(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<long, string>().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<List<CarcassTakeOutObj>>(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<long> 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<long>(session);
}
[Rpc(RpcFlags.SkipAuth)]
public static string GetTestJson()
{
var list = new List<SectionInfo>();
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; }
}
}

+ 1
- 0
WebFolder/config/NamedValue/B3ClientService.xml View File

@ -21,5 +21,6 @@
<NamedValue type="BWP.B3ClientService.NamedValueTemplate.领用类型, B3ClientService">
<Word name="分割领用" value="0"/>
<Word name="白条销售" value="1"/>
<Word name="条转段" value="2"/>
</NamedValue>
</NamedValueSettings>

+ 2
- 0
WebFolder/config/plugins/B3ClientService.plugin View File

@ -37,6 +37,7 @@
</FunctionGroup>
<FunctionGroup name="系统管理" roleSchemas="default">
<Function index="0" name="服务器设置"/>
<Function index="1" name="条段配置"/>
</FunctionGroup>
<FunctionGroup name="报表展示" roleSchemas="default">
<Function index="0" name="白条库存"/>
@ -123,6 +124,7 @@
<Menu id="0010" name="MES系统/基础信息/工作单元" roles="B3ClientService.工作单元.访问" url="B3ClientService/BaseInfos/WorkUnit_/WorkUnitList.aspx"/>
<Menu id="0011" name="MES系统/基础信息/生产批次" roles="B3ClientService.生产批次.访问" url="B3ClientService/BaseInfos/ProductBatch_/ProductBatchList.aspx"/>
<Menu id="0012" name="MES系统/系统管理/存货配置" roles="B3ClientService.客户端存货配置.访问" url="B3ClientService/BaseInfos/ClientGoodsSet_/ClientGoodsSetList.aspx"/>
<Menu id="0013" name="MES系统/系统管理/条段配置" roles="B3ClientService.系统管理.条段配置" url="B3ClientService/Bills/SectionConfigPage.aspx"/>
<Menu id="0020" name="MES系统/业务单据/盘点单" roles="B3ClientService.盘点单.访问" url="B3ClientService/Bills/CarcassInventory_/CarcassInventoryList.aspx"/>


Loading…
Cancel
Save