Browse Source

需求单No.140932

master
wugang 7 years ago
parent
commit
f690371b4f
4 changed files with 111 additions and 0 deletions
  1. +11
    -0
      B3CowButcherManageToSale.Web/B3CowButcherManageToSale.Web.csproj
  2. +58
    -0
      B3CowButcherManageToSale.Web/Pages/TypeIOCs/AddDetailByBarCode.cs
  3. +1
    -0
      B3CowButcherManageToSale/B3CowButcherManageToSale.csproj
  4. +41
    -0
      B3CowButcherManageToSale/Utils/CommonQuery.cs

+ 11
- 0
B3CowButcherManageToSale.Web/B3CowButcherManageToSale.Web.csproj View File

@ -50,6 +50,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\BwpB3Project\tsref\Debug\B3Sale.dll</HintPath>
</Reference>
<Reference Include="B3Sale.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3a973053c7ebf11c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\B3Sale.Web.dll</HintPath>
</Reference>
<Reference Include="B3System, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a04fa581c0f74d43, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\BwpB3Project\tsref\Debug\B3System.dll</HintPath>
@ -96,12 +100,19 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Pages\TypeIOCs\AddDetailByBarCode.cs" />
<Compile Include="PluginClass.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Pages\B3CowButcherManageToSale\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\B3CowButcherManageToSale\B3CowButcherManageToSale.csproj">
<Project>{27FC9D6F-C1C5-434B-BB34-262528819ECB}</Project>
<Name>B3CowButcherManageToSale</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.


+ 58
- 0
B3CowButcherManageToSale.Web/Pages/TypeIOCs/AddDetailByBarCode.cs View File

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BWP.B3CowButcherManage.BO;
using BWP.B3CowButcherManageToSale.Utils;
using BWP.B3Frameworks;
using BWP.B3Frameworks.Utils;
using BWP.B3Sale.BO;
using BWP.Web.Pages.B3Sale.Bills.ReturnInStore_;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.SqlDoms;
namespace BWP.Web.Pages.TypeIOCs
{
[TypeIOC(typeof(ReturnInStoreEdit), typeof(ReturnInStoreEdit.IAddDetailByBarCode))]
public class AddDetailByBarCode : ReturnInStoreEdit.IAddDetailByBarCode
{
public void Invoke(string barCode,ReturnInStore inStore)
{
var left = new JoinAlias("_l", typeof(BarCodeProductionInfo));
var right = new JoinAlias("_r", typeof(BarCodeProductionInfo));
var query = new DQueryDom(left);
query.From.AddJoin(JoinType.Left, new DQDmoSource(right), DQCondition.EQ(left, "ID", right, "PackageID"));
query.Where.Conditions.Add(DQCondition.EQ(left, "BarCode", barCode));
var arr = new string[] { "Goods_ID", "Weight", "Product_Batch" };
foreach (var f in arr)
query.Columns.Add(DQSelectColumn.Create(DQExpression.LogicCase(DQCondition.EQ(left, "BarType", 3), DQExpression.Field(right, f), DQExpression.Field(left, f)), f));
var list = new List<Tuple<long,decimal,string>>();
using (var session = Dmo.NewSession())
{
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var tuple = new Tuple<long, decimal, string>((long)reader[0], (decimal)reader[1], (string)reader[2]);
list.Add(tuple);
}
}
}
foreach (var goodsGroup in list.GroupBy(x=>x.Item1))
{
foreach (var batchGroup in goodsGroup.GroupBy(x=>x.Item3))
{
var detail = new ReturnInStore_Detail();
detail.SaleGoods_ID = goodsGroup.Key;
var tuple = CommonQuery.GetGoodsBatch(batchGroup.Key, goodsGroup.Key);
if (tuple != null)
detail.GoodsBatch_ID = tuple.Item1;
detail.UnitNum = batchGroup.Sum(x=>x.Item2);
DmoUtil.RefreshDependency(detail, "SaleGoods_ID");
inStore.Details.Add(detail);
}
}
}
}
}

+ 1
- 0
B3CowButcherManageToSale/B3CowButcherManageToSale.csproj View File

@ -81,6 +81,7 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TypeIOCs\SaleOutStoreBLTypeIoc.cs" />
<Compile Include="Utils\CommonQuery.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Rpcs\" />


+ 41
- 0
B3CowButcherManageToSale/Utils/CommonQuery.cs View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BWP.B3Frameworks;
using Forks.EnterpriseServices.BusinessInterfaces;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
namespace BWP.B3CowButcherManageToSale.Utils
{
public static class CommonQuery
{
public static Tuple<long, bool, string> GetGoodsBatch(string batch, long goodsId)
{
var query = new DQueryDom(new JoinAlias(typeof(BWP.B3UnitedInfos.BO.GoodsBatch)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("Stopped"));
query.Columns.Add(DQSelectColumn.Field("Goods_Name"));
query.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID));
query.Where.Conditions.Add(DQCondition.EQ("Goods_ID", goodsId));
query.Where.Conditions.Add(DQCondition.EQ("Name", batch));
Tuple<long, bool, string> tuple = null;
using (var context2 = new TransactionContext())
{
using (var reader = context2.Session.ExecuteReader(query))
{
while (reader.Read())
{
tuple = new Tuple<long, bool, string>((long)reader[0], (bool)reader[1], (string)reader[2]);
}
}
}
if (tuple != null && tuple.Item2)
{
throw new ApplicationException(string.Format("【" + tuple.Item3 + "】的存货批次{0}已停用", batch));
}
return tuple;
}
}
}

Loading…
Cancel
Save