Browse Source

销售出库关联扫码销售的调整。

master
yibo 7 years ago
parent
commit
378ed89b9b
5 changed files with 191 additions and 15 deletions
  1. +1
    -0
      B3QingDaoWanFu.Web/PluginClass.cs
  2. +10
    -0
      B3QingDaoWanFu/B3QingDaoWanFu.csproj
  3. +17
    -0
      B3QingDaoWanFu/BO/SaleOutStoreBarCodeToMESLog.cs
  4. +121
    -0
      B3QingDaoWanFu/Tasks/SyncSaleOutStoreInfoToMES.cs
  5. +42
    -15
      B3QingDaoWanFu/TypeIOCs/SaleOutStoreBLTypeIoc.cs

+ 1
- 0
B3QingDaoWanFu.Web/PluginClass.cs View File

@ -25,6 +25,7 @@ namespace BWP.B3QingDaoWanFu
GlobalFlags.On(B3SaleConsts.Flags.SendOutStoreNoAvailableStorage);
GlobalFlags.On(B3SaleConsts.Flags.CustAcceptAnalyseHasFactoryPrice);
GlobalFlags.On(B3ButcherManageConsts.GlobalFlags.);
GlobalFlags.On(B3SaleConsts.Flags.SaleOutStoreEnableScan);
}
}
}

+ 10
- 0
B3QingDaoWanFu/B3QingDaoWanFu.csproj View File

@ -86,11 +86,19 @@
<HintPath>D:\BwpB3Project\tsref\Debug\Forks.EnterpriseServices.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Forks.JsonRpc.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.JsonRpc.Client.dll</HintPath>
</Reference>
<Reference Include="Forks.Utils, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\BwpB3Project\tsref\Debug\Forks.Utils.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.0.3.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System">
<SpecificVersion>False</SpecificVersion>
</Reference>
@ -141,9 +149,11 @@
<Compile Include="BO\Bill\CostRecord\CostRecord.cs" />
<Compile Include="BO\Bill\CostRecord\CostRecord_Detail.cs" />
<Compile Include="BO\CustomerDeviceSet.cs" />
<Compile Include="BO\SaleOutStoreBarCodeToMESLog.cs" />
<Compile Include="DataPatchs\StatPaySetBillNeedValue20171123.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rpc\GatheringRpc.cs" />
<Compile Include="Tasks\SyncSaleOutStoreInfoToMES.cs" />
<Compile Include="TypeIOCs\SaleOutStoreBLTypeIoc.cs" />
<Compile Include="TypeIOCs\StatPayBLTypeIoc.cs" />
<Compile Include="Utils\WanFuOnlineConfig.cs" />


+ 17
- 0
B3QingDaoWanFu/BO/SaleOutStoreBarCodeToMESLog.cs View File

@ -0,0 +1,17 @@
using Forks.EnterpriseServices.DomainObjects2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TSingSoft.WebPluginFramework;
namespace BWP.B3QingDaoWanFu.BO
{
[BOClass]
[KeyField("ScanBar_ID", KeyGenType.assigned)]
public class SaleOutStoreBarCodeToMESLog
{
public long ScanBar_ID { get; set; }
}
}

+ 121
- 0
B3QingDaoWanFu/Tasks/SyncSaleOutStoreInfoToMES.cs View File

@ -0,0 +1,121 @@
using BWP.B3ProcurementInterface.Utils;
using BWP.B3QingDaoWanFu.BO;
using BWP.B3Sale.BO;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.SqlDoms;
using Forks.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using TSingSoft.WebPluginFramework.TimerTasks;
using TSingSoft.WebPluginFramework;
using Forks.JsonRpc.Client;
using Newtonsoft.Json;
using BWP.B3Frameworks.BO.NamedValueTemplate;
namespace BWP.B3QingDaoWanFu.Tasks
{
public class SyncSaleOutStoreInfoToMES : ITimerTask
{
volatile static object _lockObj = new object();
public void Execute()
{
if (!Monitor.TryEnter(_lockObj))
{
throw new SameTaskNotFinishException(this);
}
try
{
DoExecute();
}
finally
{
Monitor.Exit(_lockObj);
}
}
private void DoExecute()
{
if (!ClientServerFacedRpcFacadeUtil.InitRpcFacade())
return;
var main = new JoinAlias(typeof(SaleOutStore));
var detail = new JoinAlias(typeof(SaleOutStore_Detail));
var weight = new JoinAlias(typeof(WeightingInfor));
var scan = new JoinAlias(typeof(WeightingInfo_ScanDetail));
var relate = new JoinAlias(typeof(SaleOutStoreBarCodeToMESLog));
var query = new DQueryDom(main);
query.From.AddJoin(JoinType.Left, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "SaleOutStore_ID"));
query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.And(DQCondition.EQ(detail, "ID", weight, "DetailID"), DQCondition.EQ("BillType", DmoTypeIDAttribute.GetID(typeof(SaleOutStore)))));
query.From.AddJoin(JoinType.Left, new DQDmoSource(scan), DQCondition.And(DQCondition.EQ(detail, "ID", scan, "Detail_ID"), DQCondition.EQ(weight, "ID", scan, "WeightingInfo_ID")));
query.From.AddJoin(JoinType.Left, new DQDmoSource(relate), DQCondition.EQ(scan, "ID", relate, "ScanBar_ID"));
query.Columns.Add(DQSelectColumn.Field("ID", scan));
query.Columns.Add(DQSelectColumn.Field("BarCode", scan));
query.Columns.Add(DQSelectColumn.Field("NetWeight", weight));
query.Columns.Add(DQSelectColumn.Field("LoadTime", main));
query.Columns.Add(DQSelectColumn.Field("ID", weight));
query.Columns.Add(DQSelectColumn.Field("Goods_Code", detail));
query.Where.Conditions.Add(DQCondition.And(DQCondition.GreaterThanOrEqual("BillState", .), DQCondition.IsNull(DQExpression.Field(relate, "ScanBar_ID")), DQCondition.IsNotNull(DQExpression.Field(scan, "ID"))));
using (var session = Dmo.NewSession())
{
var list = new List<CarcassSaleOutStoreObj>();
var ids = new List<long>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var entity = new CarcassSaleOutStoreObj();
entity.BarCode = (string)reader[1];
entity.Weight = ((Money<decimal>?)reader[2]).EToDecimal();
entity.Time = (DateTime?)reader[3];
entity.GroupID = (long)reader[4];
entity.SaleGoods_Code = (string)reader[5];
list.Add(entity);
ids.Add((long)reader[0]);
}
}
if (list.Count == 0)
return;
foreach (var g in list.GroupBy(x => x.GroupID))
{
var first = true;
foreach (var item in g)
{
if (first)
first = false;
else
item.Weight = 0;
}
}
var par = JsonConvert.SerializeObject(list);
var json = RpcFacade.Call<int>("/MainSystem/B3ClientService/Rpcs/CarcassSaleOutStoreRpc/UploadCarcassInfo", par);
foreach (var item in ids)
session.Insert(new SaleOutStoreBarCodeToMESLog { ScanBar_ID = item });
session.Commit();
}
}
public string Name
{
get { return "上传审核的销售出库扫码信息到MES"; }
}
}
class CarcassSaleOutStoreObj
{
public string BarCode { get; set; }
public decimal? Weight { get; set; }
public DateTime? Time { get; set; }
public long? GroupID { get; set; }
public string SaleGoods_Code { get; set; }
}
}

+ 42
- 15
B3QingDaoWanFu/TypeIOCs/SaleOutStoreBLTypeIoc.cs View File

@ -12,13 +12,12 @@ using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.SqlDoms;
using Forks.Utils;
using TSingSoft.WebPluginFramework;
using BWP.B3ButcherManage.BO;
namespace BWP.B3QingDaoWanFu.TypeIOCs
{
[TypeIOC(typeof(SaleOutStoreBL), typeof(SaleOutStoreBL.BaseBLIOCs.BeforeSave))]
public class SaleOutStoreBLTypeIoc:SaleOutStoreBL.BaseBLIOCs.BeforeSave
public class SaleOutStoreBLTypeIoc : SaleOutStoreBL.BaseBLIOCs.BeforeSave
{
public void Invoke(IDmoContext context, SaleOutStore dmo)
{
@ -30,29 +29,57 @@ namespace BWP.B3QingDaoWanFu.TypeIOCs
private Money<decimal>? GetFactoryPrice(IDmoContext context, SaleOutStore dmo, long detailSaleGoodsId)
{
var detail=new JoinAlias(typeof(DynamicPrice_Detail));
var query=new DQueryDom(detail);
var detail = new JoinAlias(typeof(DynamicPrice_Detail));
var query = new DQueryDom(detail);
query.Where.Conditions.Add(DQCondition.EQ("SaleGoods_ID", detailSaleGoodsId));
query.Where.Conditions.Add(DQCondition.InSubQuery(DQExpression.Field("DynamicPrice_ID"),GetSubQueryDom(dmo)));
query.Where.Conditions.Add(DQCondition.InSubQuery(DQExpression.Field("DynamicPrice_ID"), GetSubQueryDom(dmo)));
query.Columns.Add(DQSelectColumn.Field("Price"));
return query.EExecuteScalar<Money<decimal>?>(context.Session);
}
private DQueryDom GetSubQueryDom( SaleOutStore dmo)
private DQueryDom GetSubQueryDom(SaleOutStore dmo)
{
var bill=new JoinAlias("bill",typeof(DynamicPrice));
var detail=new JoinAlias("detail",typeof(DynamicPrice_AccountingUnitDetail));
var query=new DQueryDom(bill);
query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail),DQCondition.EQ(bill,"ID",detail, "DynamicPrice_ID") );
var bill = new JoinAlias("bill", typeof(DynamicPrice));
var detail = new JoinAlias("detail", typeof(DynamicPrice_AccountingUnitDetail));
var query = new DQueryDom(bill);
query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "DynamicPrice_ID"));
query.AddBillStateCondition(bill);
query.Where.Conditions.Add(DQCondition.EQ(detail, "AccountingUnit_ID",dmo.AccountingUnit_ID));
query.Where.Conditions.Add(DQCondition.EQ(detail, "AccountingUnit_ID", dmo.AccountingUnit_ID));
query.Where.Conditions.Add(DQCondition.LessThanOrEqual(bill, "StartPriceDate", dmo.LoadTime));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(bill,"ID",true));
query.Columns.Add(DQSelectColumn.Field("ID",bill));
query.Range=SelectRange.Top(1);
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(bill, "ID", true));
query.Columns.Add(DQSelectColumn.Field("ID", bill));
query.Range = SelectRange.Top(1);
return query;
}
}
[TypeIOC(typeof(SaleOutStoreBL), typeof(SaleOutStoreBL.BillBLIOCs.AfterCheck))]
public class SaleOutStoreCheckBLTypeIoc : SaleOutStoreBL.BillBLIOCs.AfterCheck
{
public void Invoke(IDmoContext context, SaleOutStore dmo)
{
var config = new B3ButcherManageOnlineConfiguration();
if (string.IsNullOrEmpty(config.TraceBackServerUrl))
return;
var detail = new JoinAlias(typeof(SaleOutStore_Detail));
var weight = new JoinAlias(typeof(WeightingInfor));
var scan = new JoinAlias(typeof(WeightingInfo_ScanDetail));
var query = new DQueryDom(detail);
query.From.AddJoin(JoinType.Left, new DQDmoSource(weight), DQCondition.And(DQCondition.EQ(detail, "ID", weight, "DetailID"), DQCondition.EQ("BillType", DmoTypeIDAttribute.GetID(typeof(SaleOutStore)))));
query.From.AddJoin(JoinType.Left, new DQDmoSource(scan), DQCondition.And(DQCondition.EQ(detail, "ID", scan, "Detail_ID"), DQCondition.EQ(weight, "ID", scan, "WeightingInfo_ID")));
query.Columns.Add(DQSelectColumn.Field("BarCode", scan));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ(detail, "SaleOutStore_ID", dmo.ID), DQCondition.IsNotNull(DQExpression.Field(scan, "ID"))));
var list = query.EExecuteList<string>(context.Session);
if (!list.Any())
return;
var letList = list.Select(x => new TraceBackInfo { Code = x, SendCustomer = dmo.Customer_Name, CarNo = dmo.Car_Name, SendDate = dmo.LoadTime.Value.ToString("yyyyMMdd") });
TraceBackInfoUtil.Insert(config.TraceBackServerUrl, letList.ToList());
}
}
}

Loading…
Cancel
Save