Browse Source

需求单No.142056 新增“成品入库客户端”

master
yibo 7 years ago
parent
commit
cd1c1c1420
7 changed files with 254 additions and 1 deletions
  1. +3
    -0
      B3ClientService/B3ClientService.csproj
  2. +8
    -1
      B3ClientService/BO/Bill/SegmentProductionInfo.cs
  3. +36
    -0
      B3ClientService/BO/ProductInStoreCombine_/ProductInStoreCombine.cs
  4. +1
    -0
      B3ClientService/NamedValueTemplate.cs
  5. +82
    -0
      B3ClientService/OfflinRpc/ProductInStoreCombineRpc.cs
  6. +123
    -0
      B3ClientService/Tasks/InStoreCombineCreateB3Bills.cs
  7. +1
    -0
      WebFolder/config/NamedValue/B3ClientService.xml

+ 3
- 0
B3ClientService/B3ClientService.csproj View File

@ -181,6 +181,7 @@
<Compile Include="BO\MaterialRequisitionRecord_\MaterialRequisitionRecord.cs" /> <Compile Include="BO\MaterialRequisitionRecord_\MaterialRequisitionRecord.cs" />
<Compile Include="BO\MiniProgram\SendPigRecord.cs" /> <Compile Include="BO\MiniProgram\SendPigRecord.cs" />
<Compile Include="BO\MiniProgram\WeiUserBind.cs" /> <Compile Include="BO\MiniProgram\WeiUserBind.cs" />
<Compile Include="BO\ProductInStoreCombine_\ProductInStoreCombine.cs" />
<Compile Include="BO\ProductTask_\ProductTask.cs" /> <Compile Include="BO\ProductTask_\ProductTask.cs" />
<Compile Include="BO\SectionStoreView.cs" /> <Compile Include="BO\SectionStoreView.cs" />
<Compile Include="BO\SegmentationByPproductTrace_\SegmentationByPproductTrace.cs" /> <Compile Include="BO\SegmentationByPproductTrace_\SegmentationByPproductTrace.cs" />
@ -209,6 +210,7 @@
<Compile Include="OfflinRpc\ExtensionObj.cs" /> <Compile Include="OfflinRpc\ExtensionObj.cs" />
<Compile Include="OfflinRpc\GradeAndWeightBL.cs" /> <Compile Include="OfflinRpc\GradeAndWeightBL.cs" />
<Compile Include="OfflinRpc\LoginRpc.cs" /> <Compile Include="OfflinRpc\LoginRpc.cs" />
<Compile Include="OfflinRpc\ProductInStoreCombineRpc.cs" />
<Compile Include="OfflinRpc\SectionStoreDetailRpc.cs" /> <Compile Include="OfflinRpc\SectionStoreDetailRpc.cs" />
<Compile Include="OfflinRpc\SegmentInStoreRpc.cs" /> <Compile Include="OfflinRpc\SegmentInStoreRpc.cs" />
<Compile Include="OfflinRpc\SegmentPickUpRpc.cs" /> <Compile Include="OfflinRpc\SegmentPickUpRpc.cs" />
@ -259,6 +261,7 @@
<Compile Include="Rpcs\UserInfoRpc.cs" /> <Compile Include="Rpcs\UserInfoRpc.cs" />
<Compile Include="Tasks\AutoCreateProductBatchTask.cs" /> <Compile Include="Tasks\AutoCreateProductBatchTask.cs" />
<Compile Include="Tasks\CreateB3OutputTask.cs" /> <Compile Include="Tasks\CreateB3OutputTask.cs" />
<Compile Include="Tasks\InStoreCombineCreateB3Bills.cs" />
<Compile Include="Tasks\SyncCarcassInStoreToTrackBack.cs" /> <Compile Include="Tasks\SyncCarcassInStoreToTrackBack.cs" />
<Compile Include="Tasks\SyncInfoFromServer.cs" /> <Compile Include="Tasks\SyncInfoFromServer.cs" />
<Compile Include="Tasks\SyncBillFromServer.cs" /> <Compile Include="Tasks\SyncBillFromServer.cs" />


+ 8
- 1
B3ClientService/BO/Bill/SegmentProductionInfo.cs View File

@ -102,6 +102,9 @@ namespace BWP.B3ClientService.BO
#endregion #endregion
[LogicName("入库合并ID")]
public long? InStoreCombine_ID { get; set; }
public bool IsSync { get; set; } public bool IsSync { get; set; }
[DbColumn(DefaultValue = false)] [DbColumn(DefaultValue = false)]
@ -128,6 +131,10 @@ namespace BWP.B3ClientService.BO
[Join("Goods_ID", "ID")] [Join("Goods_ID", "ID")]
public string Goods_Code { get; set; } public string Goods_Code { get; set; }
[ReferenceTo(typeof(Goods), "Spec")]
[Join("Goods_ID", "ID")]
public string Goods_Spec { get; set; }
[ReferenceTo(typeof(Worker), "Name")] [ReferenceTo(typeof(Worker), "Name")]
[Join("Worker_ID", "ID")] [Join("Worker_ID", "ID")]
public string Worker_Name { get; set; } public string Worker_Name { get; set; }
@ -139,7 +146,7 @@ namespace BWP.B3ClientService.BO
[ReferenceTo(typeof(ProductBatch), "Name")] [ReferenceTo(typeof(ProductBatch), "Name")]
[Join("ProductBatch_ID", "ID")] [Join("ProductBatch_ID", "ID")]
public string ProductBatch_Name { get; set; } public string ProductBatch_Name { get; set; }
[ReferenceTo(typeof(Worker), "Name")] [ReferenceTo(typeof(Worker), "Name")]
[Join("InStoreWorker_ID", "ID")] [Join("InStoreWorker_ID", "ID")]
public string InStoreWorker_Name { get; set; } public string InStoreWorker_Name { get; set; }


+ 36
- 0
B3ClientService/BO/ProductInStoreCombine_/ProductInStoreCombine.cs View File

@ -0,0 +1,36 @@
using BWP.B3Frameworks.BO;
using Forks.EnterpriseServices.DataForm;
using Forks.EnterpriseServices.DomainObjects2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BWP.B3ClientService.BO
{
[DFClass, Serializable]
public class ProductInStoreCombine : Base
{
public string CombineCode { get; set; }
public long OutStore_ID { get; set; }
[ReferenceTo(typeof(Store), "Code")]
[Join("OutStore_ID", "ID")]
public string OutStore_Code { get; set; }
public long InStore_ID { get; set; }
[ReferenceTo(typeof(Store), "Code")]
[Join("InStore_ID", "ID")]
public string InStore_Code { get; set; }
public DateTime CombineTime { get; set; }
public bool IsCreated { get; set; }
private readonly List<string> mBarCodes = new List<string>();
[NonDmoProperty]
public List<string> BarCodes { get { return mBarCodes; } }
}
}

+ 1
- 0
B3ClientService/NamedValueTemplate.cs View File

@ -22,6 +22,7 @@ namespace BWP.B3ClientService.NamedValueTemplate
public static readonly NamedValue<> = new NamedValue<>(2); public static readonly NamedValue<> = new NamedValue<>(2);
public static readonly NamedValue<> = new NamedValue<>(3); public static readonly NamedValue<> = new NamedValue<>(3);
public static readonly NamedValue<> = new NamedValue<>(4); public static readonly NamedValue<> = new NamedValue<>(4);
public static readonly NamedValue<> = new NamedValue<>(5);
//51-100供B3用 //51-100供B3用
public static readonly NamedValue<> = new NamedValue<>(103); public static readonly NamedValue<> = new NamedValue<>(103);
public static readonly NamedValue<> 线 = new NamedValue<>(104); public static readonly NamedValue<> 线 = new NamedValue<>(104);


+ 82
- 0
B3ClientService/OfflinRpc/ProductInStoreCombineRpc.cs View File

@ -0,0 +1,82 @@
using BWP.B3ClientService.BO;
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 ProductInStoreCombineRpc
{
[Rpc(RpcFlags.SkipAuth)]
public static string ScanBarCode(string barCode)
{
var query = new DQueryDom(new JoinAlias(typeof(SegmentProductionInfo)));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("BarCode", barCode), DQCondition.EQ("Delete", false), DQCondition.IsNotNull(DQExpression.Field("Weight"))));
query.Columns.Add(DQSelectColumn.Field("Goods_Name"));
query.Columns.Add(DQSelectColumn.Field("Goods_Spec"));
query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Columns.Add(DQSelectColumn.Field("InStoreTime"));
query.Range = SelectRange.Top(1);
using (var session = Dmo.NewSession())
{
using (var reader = session.ExecuteReader(query))
{
if (reader.Read())
{
var obj = new
{
Goods_Name = (string)reader[0],
Goods_Spec = (string)reader[1],
Weight = (decimal)reader[2],
InStoreTime = (DateTime?)reader[3]
};
return JsonConvert.SerializeObject(obj);
}
}
}
return JsonConvert.SerializeObject(new { });
}
[Rpc(RpcFlags.SkipAuth)]
public static int InsertCombine(string json)
{
var list = JsonConvert.DeserializeObject<List<ProductInStoreCombine>>(json);
using (var session = Dmo.NewSession())
{
foreach (var item in list)
{
if ((Exist(session, item.CombineCode)))
continue;
session.Insert(item);
UpdateProductInfo(session, item);
}
session.Commit();
}
return 1;
}
static bool Exist(IDmoSession session, string code)
{
var query = new DQueryDom(new JoinAlias(typeof(ProductInStoreCombine)));
query.Where.Conditions.Add(DQCondition.EQ("CombineCode", code));
return query.EExists(session);
}
static void UpdateProductInfo(IDmoSession session, ProductInStoreCombine item)
{
var update = new DQUpdateDom(typeof(SegmentProductionInfo));
update.Columns.Add(new DQUpdateColumn("InStoreCombine_ID", item.ID));
update.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("BarCode"), item.BarCodes.Select(x => DQExpression.Value(x)).ToArray()));
session.ExecuteNonQuery(update);
}
}
}

+ 123
- 0
B3ClientService/Tasks/InStoreCombineCreateB3Bills.cs View File

@ -0,0 +1,123 @@
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 InStoreCombineCreateB3Bills : 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/InStoreCombineRpc/CreateInOutStore";
private void DoExecute()
{
using (var context = new TransactionContext())
{
List<long> ids;
var list = GetUnSyncdList(context.Session, out ids);
if (list.Count == 0)
return;
RpcFacade.Call<int>(method, JsonConvert.SerializeObject(list));
SetAsSyncd(context.Session, ids);
context.Commit();
}
}
private void SetAsSyncd(IDmoSession session, List<long> ids)
{
var update = new DQUpdateDom(typeof(ProductInStoreCombine));
update.Where.Conditions.Add(DQCondition.InList(DQExpression.Field("ID"), ids.Select(x => DQExpression.Value(x)).ToArray()));
update.Columns.Add(new DQUpdateColumn("IsCreated", true));
session.ExecuteNonQuery(update);
}
private List<object> GetUnSyncdList(IDmoSession session, out List<long> ids)
{
var main = new JoinAlias(typeof(ProductInStoreCombine));
var detail = new JoinAlias(typeof(SegmentProductionInfo));
var query = new DQueryDom(main);
query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "InStoreCombine_ID"));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("CombineTime"));
query.Columns.Add(DQSelectColumn.Field("OutStore_Code"));
query.Columns.Add(DQSelectColumn.Field("InStore_Code"));
query.Columns.Add(DQSelectColumn.Field("Goods_Code", detail));
foreach (var c in query.Columns)
query.GroupBy.Expressions.Add(c.Expression);
query.Columns.Add(DQSelectColumn.Sum("Weight"));
query.Columns.Add(DQSelectColumn.Count("C"));
query.Where.Conditions.Add(DQCondition.EQ("IsCreated", false));
query.Range = SelectRange.Top(100);
var list = new List<object>();
ids = new List<long>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var id = (long)reader[0];
ids.Add(id);
list.Add(new
{
ID = id,
CombineTime = (DateTime)reader[1],
OutStore_Code = (string)reader[2],
InStore_Code = (string)reader[3],
Goods_Code = (string)reader[4],
Weight = (decimal)reader[5],
Count = Convert.ToInt32(reader[6])
});
}
}
return list;
}
public string Name
{
get { return "成品入库创建产出入库单"; }
}
}
}

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

@ -13,6 +13,7 @@
<Word name="分割生产" value="2"/> <Word name="分割生产" value="2"/>
<Word name="扫码入库" value="3"/> <Word name="扫码入库" value="3"/>
<Word name="分割领用" value="4"/> <Word name="分割领用" value="4"/>
<Word name="成品入库" value="5"/>
<Word name="赶猪确认" value="103"/> <Word name="赶猪确认" value="103"/>
<Word name="上线确认" value="104"/> <Word name="上线确认" value="104"/>
<Word name="烫毛分线" value="105"/> <Word name="烫毛分线" value="105"/>


Loading…
Cancel
Save