Browse Source

批次加批次类型,以及相关的调整。加自动创建B3产出单逻辑。

master
yibo 7 years ago
parent
commit
444f142232
12 changed files with 202 additions and 4 deletions
  1. +1
    -0
      B3ClientService.Web/Pages/B3ClientService/BaseInfos/ProductBatch_/ProductBatchEdit.cs
  2. +4
    -0
      B3ClientService.Web/Pages/B3ClientService/BaseInfos/ProductBatch_/ProductBatchList.cs
  3. +4
    -0
      B3ClientService.Web/Pages/B3ClientService/BaseInfos/ProductBatch_/ProductBatchList.xml
  4. +1
    -0
      B3ClientService/B3ClientService.csproj
  5. +1
    -1
      B3ClientService/B3ClientServiceOnLineConfig.cs
  6. +8
    -0
      B3ClientService/BO/BaseInfo/ProductBatch.cs
  7. +15
    -0
      B3ClientService/BO/Bill/SegmentProductionInfo.cs
  8. +6
    -0
      B3ClientService/NamedValueTemplate.cs
  9. +15
    -2
      B3ClientService/OfflinRpc/BaseInfoRpc.cs
  10. +11
    -1
      B3ClientService/Tasks/AutoCreateProductBatchTask.cs
  11. +132
    -0
      B3ClientService/Tasks/CreateB3OutputTask.cs
  12. +4
    -0
      WebFolder/config/NamedValue/B3ClientService.xml

+ 1
- 0
B3ClientService.Web/Pages/B3ClientService/BaseInfos/ProductBatch_/ProductBatchEdit.cs View File

@ -16,6 +16,7 @@ namespace BWP.Web.Pages.B3ClientService.BaseInfos.ProductBatch_
var config = new AutoLayoutConfig() { Cols = 8 };
config.Add("Name");
config.Add("Date");
config.Add("BatchType");
config.Add("Remark");
layoutManager.Config = config;
parent.Controls.Add(layoutManager.CreateLayout());


+ 4
- 0
B3ClientService.Web/Pages/B3ClientService/BaseInfos/ProductBatch_/ProductBatchList.cs View File

@ -15,6 +15,7 @@ namespace BWP.Web.Pages.B3ClientService.BaseInfos.ProductBatch_
vPanel.Add(CreateDefaultBaseInfoQueryControls((panel, config) =>
{
config.AddAfter("Date", "Name");
config.AddAfter("BatchType", "Date");
}));
}
@ -22,7 +23,10 @@ namespace BWP.Web.Pages.B3ClientService.BaseInfos.ProductBatch_
{
base.AddDFBrowseGridColumn(grid, field);
if (field == "Name")
{
AddDFBrowseGridColumn(grid, "Date");
AddDFBrowseGridColumn(grid, "BatchType");
}
}
}
}

+ 4
- 0
B3ClientService.Web/Pages/B3ClientService/BaseInfos/ProductBatch_/ProductBatchList.xml View File

@ -25,6 +25,10 @@
<EQ>
<Field name="Stopped"/>
<QBE paramName="Stopped"/>
</EQ>
<EQ>
<Field name="BatchType"/>
<QBE paramName="BatchType"/>
</EQ>
<GreaterThanOrEqual>
<Field name="Date"/>


+ 1
- 0
B3ClientService/B3ClientService.csproj View File

@ -258,6 +258,7 @@
<Compile Include="Rpcs\SupplierScreen.cs" />
<Compile Include="Rpcs\UserInfoRpc.cs" />
<Compile Include="Tasks\AutoCreateProductBatchTask.cs" />
<Compile Include="Tasks\CreateB3OutputTask.cs" />
<Compile Include="Tasks\SyncCarcassInStoreToTrackBack.cs" />
<Compile Include="Tasks\SyncInfoFromServer.cs" />
<Compile Include="Tasks\SyncBillFromServer.cs" />


+ 1
- 1
B3ClientService/B3ClientServiceOnLineConfig.cs View File

@ -31,7 +31,7 @@ namespace BWP.B3ClientService
[LogicName("自动生成批次模板")]
[ConfigurationItemGroup("MES系统")]
[ConfigurationItemDescription("自动生成批次 日期追加部分用英文半角逗号分开")]
[ConfigurationItemDescription("自动生成批次 日期追加部分用英文半角逗号分开,内部再用|把类型和附加部分加上。例如0|A,0|B,1|")]
public StringConfigRef ProductBatchRole
{
get { return _productBatchRole; }


+ 8
- 0
B3ClientService/BO/BaseInfo/ProductBatch.cs View File

@ -6,6 +6,8 @@ using Forks.EnterpriseServices.DomainObjects2;
using TSingSoft.WebPluginFramework;
using Forks.EnterpriseServices.DataForm;
using Forks.EnterpriseServices;
using BWP.B3ClientService.NamedValueTemplate;
using Forks.Utils;
namespace BWP.B3ClientService.BO
{
@ -16,5 +18,11 @@ namespace BWP.B3ClientService.BO
{
[LogicName("日期")]
public DateTime? Date { get; set; }
private NamedValue<> mBatchType = .;
[LogicName("批次类型")]
[DbColumn(DefaultValue = 0)]
public NamedValue<> BatchType { get { return mBatchType; } set { mBatchType = value; } }
}
}

+ 15
- 0
B3ClientService/BO/Bill/SegmentProductionInfo.cs View File

@ -104,8 +104,23 @@ namespace BWP.B3ClientService.BO
public long? DetailID { get; set; }
[DbColumn(DefaultValue = false)]
public bool CreateOutput { get; set; }
[ReferenceTo(typeof(Goods), "Name")]
[Join("Goods_ID", "ID")]
public string Goods_Name { get; set; }
[ReferenceTo(typeof(Goods), "Code")]
[Join("Goods_ID", "ID")]
public string Goods_Code { get; set; }
[ReferenceTo(typeof(Worker), "Name")]
[Join("Worker_ID", "ID")]
public string Worker_Name { get; set; }
[ReferenceTo(typeof(ProductBatch), "Name")]
[Join("ProductBatch_ID", "ID")]
public string ProductBatch_Name { get; set; }
}
}

+ 6
- 0
B3ClientService/NamedValueTemplate.cs View File

@ -44,4 +44,10 @@ namespace BWP.B3ClientService.NamedValueTemplate
public static readonly NamedValue<> = new NamedValue<>(1);
public static readonly NamedValue<> = new NamedValue<>(2);
}
public sealed class
{
public static readonly NamedValue<> = new NamedValue<>(0);
public static readonly NamedValue<> = new NamedValue<>(1);
}
}

+ 15
- 2
B3ClientService/OfflinRpc/BaseInfoRpc.cs View File

@ -23,12 +23,18 @@ namespace BWP.B3ClientService.Rpcs
[Rpc(RpcFlags.SkipAuth)]
public static string SyncProductBatch()
{
return SyncProductBatchByType(0);
}
[Rpc(RpcFlags.SkipAuth)]
public static string SyncProductBatchByType(int type)
{
var query = new DQueryDom(new JoinAlias(typeof(ProductBatch)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("Name"));
query.Columns.Add(DQSelectColumn.Field("Date"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsLocked", false), DQCondition.EQ("Stopped", false)));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("BatchType", type), DQCondition.EQ("IsLocked", false), DQCondition.EQ("Stopped", false)));
var list = query.EExecuteList<long, string, DateTime?>().Select(x => new MinProductBatch { ID = x.Item1, Name = x.Item2, Date = x.Item3 });
return JsonConvert.SerializeObject(list);
}
@ -119,18 +125,25 @@ namespace BWP.B3ClientService.Rpcs
[Rpc(RpcFlags.SkipAuth)]
public static string GetProductBatch(int range)
{
return GetProductBatchByType(range, 0);
}
[Rpc(RpcFlags.SkipAuth)]
public static string GetProductBatchByType(int range, int type)
{
var query = new DQueryDom(new JoinAlias(typeof(ProductBatch)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("Name"));
query.Columns.Add(DQSelectColumn.Field("Date"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("IsLocked", false), DQCondition.EQ("Stopped", false)));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("BatchType", type), DQCondition.EQ("IsLocked", false), DQCondition.EQ("Stopped", false)));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true));
query.Range = SelectRange.Top(range);
var list = query.EExecuteList<long, string, DateTime?>().Select(x => new MinProductBatch { ID = x.Item1, Name = x.Item2, Date = x.Item3 });
return JsonConvert.SerializeObject(list);
}
[Rpc(RpcFlags.SkipAuth)]
public static string SyncStore()
{


+ 11
- 1
B3ClientService/Tasks/AutoCreateProductBatchTask.cs View File

@ -25,11 +25,21 @@ namespace BWP.B3ClientService.Tasks
var bl = BIFactory.Create<IProductBatchBL>(session);
foreach (var item in arr)
{
var name = DateTime.Today.ToString("yyyyMMdd") + item;
var append = item;
short type = 0;
var inner = item.Split(new char[] { '|' });
if (inner.Length == 2)
{
type = short.Parse(inner[0]);
append = inner[1];
}
var name = DateTime.Today.ToString("yyyyMMdd") + append;
if (Exist(session, name))
continue;
var entity = new ProductBatch();
bl.InitNewDmo(entity);
entity.BatchType = type;
entity.Name = name;
entity.Date = DateTime.Today;
bl.Insert(entity);


+ 132
- 0
B3ClientService/Tasks/CreateB3OutputTask.cs View File

@ -0,0 +1,132 @@
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 CreateB3OutputTask : 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/OutputRpc/CreateOutput";
private void DoExecute()
{
using (var context = new TransactionContext())
{
var list = GetUnSyncdList(context.Session);
if (list.Count == 0)
return;
TransferToB3(list);
SetAsSyncd(context.Session, list.Select(x => x.ID));
context.Commit();
}
}
void TransferToB3(List<Temp> list)
{
var arr = list.GroupBy(x => new { x.Date, x.UserName, x.ProductBatch, x.Goods_Code }).Select(x => new
{
Date = x.Key.Date,
UserName = x.Key.UserName,
ProductBatch = x.Key.ProductBatch,
Goods_Code = x.Key.Goods_Code,
Weight = x.Sum(y => y.Weight),
Number = x.Count()
});
RpcFacade.Call<int>(method, JsonConvert.SerializeObject(arr));
}
private void SetAsSyncd(IDmoSession session, IEnumerable<long> ids)
{
var update = new DQUpdateDom(typeof(SegmentProductionInfo));
update.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("ID"), ids.Select(x => DQExpression.Value(x)).ToArray()));
update.Columns.Add(new DQUpdateColumn("CreateOutput", true));
session.ExecuteNonQuery(update);
}
private List<Temp> GetUnSyncdList(IDmoSession session)
{
var query = new DQueryDom(new JoinAlias(typeof(SegmentProductionInfo)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("ProductTime"));
query.Columns.Add(DQSelectColumn.Field("Goods_Code"));
query.Columns.Add(DQSelectColumn.Field("Worker_Name"));
query.Columns.Add(DQSelectColumn.Field("ProductBatch_Name"));
query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("CreateOutput", false), DQCondition.IsNotNull(DQExpression.Field("Worker_ID")), DQCondition.IsNotNull(DQExpression.Field("ProductTime"))));
query.Range = SelectRange.Top(100);
var list = new List<Temp>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var entity = new Temp();
entity.ID = (long)reader[0];
entity.Date = ((DateTime)reader[1]).Date;
entity.Goods_Code = (string)reader[2];
entity.UserName = (string)reader[3];
entity.ProductBatch = (string)reader[4];
entity.Weight = (decimal)reader[5];
list.Add(entity);
}
}
return list;
}
}
class Temp
{
public long ID { get; set; }
public DateTime Date { get; set; }
public string Goods_Code { get; set; }
public string UserName { get; set; }
public string ProductBatch { get; set; }
public decimal Weight { get; set; }
}
}

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

@ -29,4 +29,8 @@
<Word name="白条销售" value="1"/>
<Word name="条转段" value="2"/>
</NamedValue>
<NamedValue type="BWP.B3ClientService.NamedValueTemplate.批次类型, B3ClientService">
<Word name="屠宰" value="0"/>
<Word name="分割" value="1"/>
</NamedValue>
</NamedValueSettings>

Loading…
Cancel
Save