Browse Source

需求单No.142065 白条入库创建B3成品入库。

master
yibo 7 years ago
parent
commit
c4349e4078
3 changed files with 141 additions and 0 deletions
  1. +1
    -0
      B3ClientService/B3ClientService.csproj
  2. +6
    -0
      B3ClientService/BO/Bill/CarcassFullInfo.cs
  3. +134
    -0
      B3ClientService/Tasks/CreateB3InStoreTask.cs

+ 1
- 0
B3ClientService/B3ClientService.csproj View File

@ -260,6 +260,7 @@
<Compile Include="Rpcs\SupplierScreen.cs" /> <Compile Include="Rpcs\SupplierScreen.cs" />
<Compile Include="Rpcs\UserInfoRpc.cs" /> <Compile Include="Rpcs\UserInfoRpc.cs" />
<Compile Include="Tasks\AutoCreateProductBatchTask.cs" /> <Compile Include="Tasks\AutoCreateProductBatchTask.cs" />
<Compile Include="Tasks\CreateB3InStoreTask.cs" />
<Compile Include="Tasks\CreateB3OutputTask.cs" /> <Compile Include="Tasks\CreateB3OutputTask.cs" />
<Compile Include="Tasks\InStoreCombineCreateB3Bills.cs" /> <Compile Include="Tasks\InStoreCombineCreateB3Bills.cs" />
<Compile Include="Tasks\SyncCarcassInStoreToTrackBack.cs" /> <Compile Include="Tasks\SyncCarcassInStoreToTrackBack.cs" />


+ 6
- 0
B3ClientService/BO/Bill/CarcassFullInfo.cs View File

@ -80,6 +80,9 @@ namespace BWP.B3ClientService.BO
[DbColumn(DbType = SqlDbType.DateTime)] [DbColumn(DbType = SqlDbType.DateTime)]
public DateTime? InStoreTime { get; set; } public DateTime? InStoreTime { get; set; }
[DbColumn(DefaultValue = 0)]
public bool InStoreIsCreate { get; set; }
#endregion #endregion
#region 领用信息 #region 领用信息
@ -109,6 +112,9 @@ namespace BWP.B3ClientService.BO
[LogicName("领用组标识")] [LogicName("领用组标识")]
public long? PickGroupID { get; set; } public long? PickGroupID { get; set; }
[LogicName("领用仓库")]
public long? PickStore_ID { get; set; }
#endregion #endregion
} }
} }

+ 134
- 0
B3ClientService/Tasks/CreateB3InStoreTask.cs View File

@ -0,0 +1,134 @@
using BWP.B3ClientService.BO;
using Forks.EnterpriseServices.BusinessInterfaces;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.SqlDoms;
using Forks.JsonRpc.Client;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using TSingSoft.WebPluginFramework.TimerTasks;
namespace BWP.B3ClientService.Tasks
{
public class CreateB3InStoreTask : ITimerTask
{
private static volatile object _lockObj = new object();
public void Execute()
{
if (!Monitor.TryEnter(_lockObj))
{
throw new SameTaskNotFinishException(this);
}
var serverUri = ServerHost.GetServerUrl();
if (string.IsNullOrEmpty(serverUri))
throw new Exception("请配置服务器地址");
try
{
RpcFacade.Init(serverUri, "B3ClientServer");
}
catch (Exception ex)
{
if (ex.Message != "Can only start once")
throw;
}
try
{
DoExecute();
}
catch (Exception e)
{
throw new ApplicationException(e.ToString());
}
finally
{
Monitor.Exit(_lockObj);
}
}
string method = "/MainSystem/B3ButcherManage/Rpcs/ProductInStoreRpc/InsertCarcassInstore";
private void DoExecute()
{
using (var context = new TransactionContext())
{
var list = GetUnSyncdList(context.Session);
if (list.Count == 0)
return;
RpcFacade.Call<int>(method, JsonConvert.SerializeObject(list));
SetAsSyncd(context.Session, list.Select(x => x.ID));
context.Commit();
}
}
private void SetAsSyncd(IDmoSession session, IEnumerable<long> ids)
{
var update = new DQUpdateDom(typeof(CarcassFullInfo));
update.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("ID"), ids.Select(x => DQExpression.Value(x)).ToArray()));
update.Columns.Add(new DQUpdateColumn("InStoreIsCreate", true));
session.ExecuteNonQuery(update);
}
private List<SelfTemp> GetUnSyncdList(IDmoSession session)
{
var main = new JoinAlias(typeof(CarcassFullInfo));
var goods = new JoinAlias(typeof(Goods));
var batch = new JoinAlias(typeof(ProductBatch));
var worker = new JoinAlias(typeof(Worker));
var query = new DQueryDom(main);
query.From.AddJoin(JoinType.Inner, new DQDmoSource(goods), DQCondition.EQ(main, "InStoreGoods_ID", goods, "ID"));
query.From.AddJoin(JoinType.Inner, new DQDmoSource(batch), DQCondition.EQ(main, "ProductBatch_ID", batch, "ID"));
query.From.AddJoin(JoinType.Inner, new DQDmoSource(worker), DQCondition.EQ(main, "InStoreWorker_ID", worker, "ID"));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("Code", goods));
query.Columns.Add(DQSelectColumn.Field("Name", batch));
query.Columns.Add(DQSelectColumn.Field("Date", batch));
query.Columns.Add(DQSelectColumn.Field("Name", worker));
query.Columns.Add(DQSelectColumn.Field("InStoreWeight"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field("InStoreGoods_ID")), DQCondition.EQ("InStoreIsCreate", false)));
query.Where.Conditions.Add(DQCondition.GreaterThan("InStoreTime", new DateTime(2018, 12, 24)));
query.Range = SelectRange.Top(100);
var list = new List<SelfTemp>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var entity = new SelfTemp();
entity.ID = (long)reader[0];
entity.Goods_Code = (string)reader[1];
entity.ProductBatch_Name = (string)reader[2];
entity.BatchDate = (DateTime)reader[3];
entity.Worker_Name = (string)reader[4];
entity.Weight = (decimal)reader[5];
list.Add(entity);
}
}
return list;
}
public string Name
{
get { return "白条入库生成成品入库"; }
}
class SelfTemp
{
public long ID { get; set; }
public string Goods_Code { get; set; }
public string ProductBatch_Name { get; set; }
public DateTime BatchDate { get; set; }
public string Worker_Name { get; set; }
public decimal Weight { get; set; }
}
}
}

Loading…
Cancel
Save