Browse Source

调整。

master
yibo 7 years ago
parent
commit
28a9b7a572
4 changed files with 84 additions and 83 deletions
  1. +6
    -0
      B3ClientService/BO/Bill/SegmentProductionInfo.cs
  2. +48
    -43
      B3ClientService/OfflinRpc/SegmentInStoreRpc.cs
  3. +1
    -37
      B3ClientService/OfflinRpc/SegmentProductionRpc.cs
  4. +29
    -3
      B3ClientService/Tasks/CreateB3OutputTask.cs

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

@ -101,6 +101,9 @@ namespace BWP.B3ClientService.BO
public bool IsSync { get; set; }
[DbColumn(DefaultValue = false)]
public bool Delete { get; set; }
[DbColumn(DefaultValue = 0)]
public int RowVersion { get; set; }
@ -111,6 +114,9 @@ namespace BWP.B3ClientService.BO
[DbColumn(DefaultValue = false)]
public bool CreateOutput { get; set; }
[DbColumn(DefaultValue = false)]
public bool Added { get; set; }
[ReferenceTo(typeof(Goods), "Name")]
[Join("Goods_ID", "ID")]
public string Goods_Name { get; set; }


+ 48
- 43
B3ClientService/OfflinRpc/SegmentInStoreRpc.cs View File

@ -21,39 +21,6 @@ namespace BWP.B3ClientService.Rpcs
[Rpc]
public static class SegmentInStoreRpc
{
[Rpc(RpcFlags.SkipAuth)]
public static string GetSegmentProductInfo(string barCode)
{
var main = new JoinAlias(typeof(SegmentProductionInfo));
var goods = new JoinAlias(typeof(Goods));
var query = new DQueryDom(main);
query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(main, "Goods_ID", goods, "ID"));
query.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode));
query.Columns.Add(DQSelectColumn.Field("Code", goods));
query.Columns.Add(DQSelectColumn.Field("Name", goods));
query.Columns.Add(DQSelectColumn.Field("Spec", goods));
query.Columns.Add(DQSelectColumn.Field("ProductTime"));
query.Columns.Add(DQSelectColumn.Field("Weight"));
using (var session = Dmo.NewSession())
{
using (var reader = session.ExecuteReader(query))
{
if (reader.Read())
{
var entity = new SegmentProductObj();
entity.Goods_Code = (string)reader[0];
entity.Goods_Name = (string)reader[1];
entity.Goods_Spec = (string)reader[2];
entity.ProductTime = (DateTime?)reader[3];
entity.Weight = (decimal?)reader[4];
return JsonConvert.SerializeObject(entity);
}
}
}
return string.Empty;
}
[Rpc(RpcFlags.SkipAuth)]
public static int UploadSegmentInStoreInfo(string json)
{
@ -102,21 +69,26 @@ namespace BWP.B3ClientService.Rpcs
}
[Rpc(RpcFlags.SkipAuth)]
public static string GetUnInStoreList()
public static string GetUnInStoreList(int range, long? maxID, string expression)
{
var main = new JoinAlias(typeof(SegmentProductionInfo));
var goods = new JoinAlias(typeof(Goods));
var goods = new JoinAlias("_goods", typeof(Goods));
var query = new DQueryDom(main);
query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(main, "Goods_ID", goods, "ID"));
query.Where.Conditions.Add(DQCondition.IsNull(DQExpression.Field("InStoreTime")));
query.Where.Conditions.Add(DQCondition.EQ("Delete", false));
query.Columns.Add(DQSelectColumn.Field("BarCode"));
query.Columns.Add(DQSelectColumn.Field("Code", goods));
query.Columns.Add(DQSelectColumn.Field("Name", goods));
query.Columns.Add(DQSelectColumn.Field("Spec", goods));
query.Columns.Add(DQSelectColumn.Field("ProductTime"));
query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
query.Range = SelectRange.Top(50);
if (maxID.HasValue)
query.Where.Conditions.Add(DQCondition.GreaterThan("ID", maxID));
query.Range = SelectRange.Top(range);
if (!string.IsNullOrEmpty(expression))
query.Where.Conditions.Add(DQExpression.Snippet(expression));
var list = new List<SegmentProductObj>();
using (var session = Dmo.NewSession())
{
@ -126,11 +98,11 @@ namespace BWP.B3ClientService.Rpcs
{
var obj = new SegmentProductObj();
obj.BarCode = (string)reader[0];
obj.Goods_Code = (string)reader[1];
obj.Goods_Name = (string)reader[2];
obj.Goods_Spec = (string)reader[3];
obj.ProductTime = (DateTime?)reader[4];
obj.Weight = (decimal?)reader[5];
obj.Goods_Name = (string)reader[1];
obj.Goods_Spec = (string)reader[2];
obj.ProductTime = (DateTime?)reader[3];
obj.Weight = (decimal?)reader[4];
obj.SID = (long)reader[5];
list.Add(obj);
}
}
@ -138,6 +110,37 @@ namespace BWP.B3ClientService.Rpcs
return JsonConvert.SerializeObject(list);
}
[Rpc(RpcFlags.SkipAuth)]
public static string GetBarInfoByCode(string code)
{
var main = new JoinAlias(typeof(SegmentProductionInfo));
var goods = new JoinAlias(typeof(Goods));
var query = new DQueryDom(main);
query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(main, "Goods_ID", goods, "ID"));
query.Columns.Add(DQSelectColumn.Field("Name", goods));
query.Columns.Add(DQSelectColumn.Field("Spec", goods));
query.Columns.Add(DQSelectColumn.Field("ProductTime"));
query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Where.Conditions.Add(DQCondition.EQ("BarCode", code));
query.Where.Conditions.Add(DQCondition.EQ("Delete", false));
using (var session = Dmo.NewSession())
{
using (var reader = session.ExecuteReader(query))
{
if (reader.Read())
{
var obj = new SegmentProductObj();
obj.Goods_Name = (string)reader[0];
obj.Goods_Spec = (string)reader[1];
obj.ProductTime = (DateTime?)reader[2];
obj.Weight = (decimal?)reader[3];
return JsonConvert.SerializeObject(obj);
}
}
}
return string.Empty;
}
[Rpc(RpcFlags.SkipAuth)]
public static string StockUpScan(string barCode)
{
@ -149,6 +152,7 @@ namespace BWP.B3ClientService.Rpcs
query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Columns.Add(DQSelectColumn.Field("StandardPic"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("BarCode", barCode), DQCondition.IsNotNull(DQExpression.Field("InStoreTime")), DQCondition.IsNull(DQExpression.Field("BackTime"))));
query.Where.Conditions.Add(DQCondition.EQ("Delete", false));
var result = query.EExecuteScalar<string, decimal?, bool>();
if (result == null)
return string.Empty;
@ -160,7 +164,7 @@ namespace BWP.B3ClientService.Rpcs
{
public string BarCode { get; set; }
public DateTime InStoreTime { get; set; }
public DateTime? InStoreTime { get; set; }
public long? Store_ID { get; set; }
@ -175,5 +179,6 @@ namespace BWP.B3ClientService.Rpcs
public string Goods_Spec { get; set; }
public decimal? Weight { get; set; }
public DateTime? ProductTime { get; set; }
public long? SID { get; set; }
}
}

+ 1
- 37
B3ClientService/OfflinRpc/SegmentProductionRpc.cs View File

@ -14,7 +14,7 @@ namespace BWP.B3ClientService.Rpcs
[Rpc]
public static class SegmentProductionRpc
{
static string[] ProductInfoFields = new string[] { "ProductTime", "Worker_ID", "WorkUnit_ID", "ProductBatch_ID", "Goods_ID", "Weight", "StandardPic" };
static string[] ProductInfoFields = new string[] { "ProductTime", "Worker_ID", "WorkUnit_ID", "ProductBatch_ID", "Goods_ID", "Weight", "StandardPic", "Delete" };
static Type MinDmoType = typeof(SegmentProductionMin);
[Rpc(RpcFlags.SkipAuth)]
@ -26,11 +26,6 @@ namespace BWP.B3ClientService.Rpcs
{
foreach (var item in list)
{
if(item.Delete)
{
Delete(session, item.BarCode);
continue;
}
var id = Exist(session, item.BarCode);
if (id == null)
{
@ -48,13 +43,6 @@ namespace BWP.B3ClientService.Rpcs
return list.Count;
}
static void Delete(IDmoSession session, string barCode)
{
var delete = new DQDeleteDom(typeof(SegmentProductionInfo));
delete.Where.Conditions.Add(DQCondition.EQ("BarCode", barCode));
session.ExecuteNonQuery(delete);
}
private static void Update(IDmoSession session, long id, SegmentProductionMin entity, params string[] fields)
{
var update = new DQUpdateDom(typeof(SegmentProductionInfo));
@ -64,30 +52,6 @@ namespace BWP.B3ClientService.Rpcs
session.ExecuteNonQuery(update);
}
[Rpc(RpcFlags.SkipAuth)]
public static int SetInStoreTime(string json)
{
var list = JsonConvert.DeserializeObject<List<SegmentProductionMin>>(json);
using (var session = Dmo.NewSession())
{
foreach (var item in list)
{
var id = Exist(session, item.BarCode);
if (id.HasValue)
{
var entity = new SegmentProductionInfo();
entity.BarCode = item.BarCode;
entity.InStoreTime = item.InStoreTime;
session.Insert(entity);
}
else
Update(session, id.Value, item, "InStoreTime");
}
session.Commit();
}
return list.Count;
}
static long? Exist(IDmoSession session, string barCode)
{
var query = new DQueryDom(new JoinAlias(typeof(SegmentProductionInfo)));


+ 29
- 3
B3ClientService/Tasks/CreateB3OutputTask.cs View File

@ -66,14 +66,14 @@ namespace BWP.B3ClientService.Tasks
void TransferToB3(List<Temp> list)
{
var arr = list.GroupBy(x => new { x.Date, x.UserName, x.ProductBatch, x.Goods_Code }).Select(x => new
var arr = list.Where(x => x.NeedUpload).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()
Number = x.Sum(y => y.Number)
});
RpcFacade.Call<int>(method, JsonConvert.SerializeObject(arr));
}
@ -83,6 +83,7 @@ namespace BWP.B3ClientService.Tasks
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));
update.Columns.Add(new DQUpdateColumn("Added", DQExpression.LogicCase(DQCondition.EQ("Delete", true), DQExpression.Value(true), DQExpression.Value(false))));
session.ExecuteNonQuery(update);
}
@ -95,7 +96,11 @@ namespace BWP.B3ClientService.Tasks
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.Columns.Add(DQSelectColumn.Field("Delete"));
query.Columns.Add(DQSelectColumn.Field("Added"));
query.Columns.Add(DQSelectColumn.Field("CreateOutput"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.IsNotNull(DQExpression.Field("Worker_ID")), DQCondition.IsNotNull(DQExpression.Field("ProductTime"))));
query.Where.Conditions.Add(DQCondition.Or(DQCondition.EQ("CreateOutput", false), DQCondition.And(DQCondition.EQ("Delete", true), DQCondition.EQ("Added", false))));
query.Range = SelectRange.Top(100);
var list = new List<Temp>();
using (var reader = session.ExecuteReader(query))
@ -103,12 +108,27 @@ namespace BWP.B3ClientService.Tasks
while (reader.Read())
{
var entity = new Temp();
entity.Number = 1;
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];
entity.Delete = (bool)reader[6];
entity.Added = (bool)reader[7];
entity.NeedUpload = true;
if ((bool)reader[8])
{
if (entity.Delete && !entity.Added)
{
entity.Weight = -1 * entity.Weight;
entity.Number = -1 * entity.Number;
}
}
else if (entity.Delete)
entity.NeedUpload = false;
list.Add(entity);
}
}
@ -116,6 +136,8 @@ namespace BWP.B3ClientService.Tasks
}
public string Name
{
get { return "分割生产生成屠宰产出单"; }
@ -134,5 +156,9 @@ namespace BWP.B3ClientService.Tasks
public string ProductBatch { get; set; }
public decimal Weight { get; set; }
public int Number { get; set; }
public bool Delete { get; set; }
public bool Added { get; set; }
public bool NeedUpload { get; set; }
}
}

Loading…
Cancel
Save