Browse Source

分割品称重计数调整。

master
yibo 7 years ago
parent
commit
b3213dd851
10 changed files with 138 additions and 18 deletions
  1. +4
    -0
      ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs
  2. +4
    -0
      ButcherFactory.BO/BaseInfo/Goods.cs
  3. +4
    -0
      ButcherFactory.BO/Bill/SegmentProduction.cs
  4. +3
    -1
      ButcherFactory.BO/LocalBL/CarcassInStoreBL.cs
  5. +3
    -1
      ButcherFactory.BO/LocalBL/CarcassTakeOutBL.cs
  6. +2
    -0
      ButcherFactory.BO/LocalBL/FormClientGoodsSetBL.cs
  7. +92
    -1
      ButcherFactory.BO/LocalBL/SegmentProductionBL.cs
  8. +2
    -0
      ButcherFactory.BO/Utils/AppContext.cs
  9. +18
    -13
      ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs
  10. +6
    -2
      ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs

+ 4
- 0
ButcherFactory.BO/BaseInfo/ClientGoodsSet.cs View File

@ -35,6 +35,10 @@ namespace ButcherFactory.BO
[Join("Goods_ID", "ID")]
public string Goods_Name { get; set; }
[ReferenceTo(typeof(Goods), "Spec")]
[Join("Goods_ID", "ID")]
public string Goods_Spec { get; set; }
public decimal? StandardWeight { get; set; }
public decimal? StandardWeightUp { get; set; }


+ 4
- 0
ButcherFactory.BO/BaseInfo/Goods.cs View File

@ -11,6 +11,10 @@ namespace ButcherFactory.BO
[KeyField("ID", KeyGenType.assigned)]
public class Goods : BaseInfo
{
public string Code { get; set; }
public string Spec { get; set; }
public string MainUnit { get; set; }
public decimal? Standard { get; set; }


+ 4
- 0
ButcherFactory.BO/Bill/SegmentProduction.cs View File

@ -27,6 +27,10 @@ namespace ButcherFactory.BO
[Join("Goods_ID", "ID")]
public string Goods_Name { get; set; }
[ReferenceTo(typeof(Goods), "Spec")]
[Join("Goods_ID", "ID")]
public string Goods_Spec { get; set; }
public long? GroupID { get; set; }
public bool Submited { get; set; }


+ 3
- 1
ButcherFactory.BO/LocalBL/CarcassInStoreBL.cs View File

@ -218,8 +218,10 @@ namespace ButcherFactory.BO.LocalBL
class CarcassInStoreObj
{
[JsonIgnore]
public long ID { get; set; }
public int RowVersion { get; set; }
[JsonIgnore]
public long RowVersion { get; set; }
public string BarCode { get; set; }
public long? InStoreWorker_ID { get; set; }
public long? WorkUnit_ID { get; set; }


+ 3
- 1
ButcherFactory.BO/LocalBL/CarcassTakeOutBL.cs View File

@ -306,8 +306,10 @@ namespace ButcherFactory.BO.LocalBL
class CarcassTakeOutObj
{
[JsonIgnore]
public long ID { get; set; }
public int RowVersion { get; set; }
[JsonIgnore]
public long RowVersion { get; set; }
public string BarCode { get; set; }
public long? TakeOutWorker_ID { get; set; }
public long? WorkUnit_ID { get; set; }


+ 2
- 0
ButcherFactory.BO/LocalBL/FormClientGoodsSetBL.cs View File

@ -65,6 +65,7 @@ namespace ButcherFactory.BO.LocalBL
query.Columns.Add(DQSelectColumn.Field("StandardWeight", detail));
query.Columns.Add(DQSelectColumn.Field("StandardWeightUp", detail));
query.Columns.Add(DQSelectColumn.Field("StandardWeightLow", detail));
query.Columns.Add(DQSelectColumn.Field("Goods_Spec", detail));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(main, "ID"));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(detail, "ID"));
@ -83,6 +84,7 @@ namespace ButcherFactory.BO.LocalBL
entity.StandardWeight = (decimal?)reader[3];
entity.StandardWeightUp = (decimal?)reader[4];
entity.StandardWeightLow = (decimal?)reader[5];
entity.Goods_Spec = (string)reader[6];
if (result.ContainsKey(key))
result[key].Add(entity);
else


+ 92
- 1
ButcherFactory.BO/LocalBL/SegmentProductionBL.cs View File

@ -2,6 +2,8 @@
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.ComponentModel;
@ -25,6 +27,7 @@ namespace ButcherFactory.BO.LocalBL
query.Columns.Add(DQSelectColumn.Field("Goods_Name"));
query.Columns.Add(DQSelectColumn.Field("GroupID"));
query.Columns.Add(DQSelectColumn.Field("TrunOutID"));
query.Columns.Add(DQSelectColumn.Field("Goods_Spec"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Delete", false), DQCondition.EQ("Submited", submited)));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID", true));
if (submited)
@ -44,6 +47,7 @@ namespace ButcherFactory.BO.LocalBL
entity.Goods_Name = (string)reader[4];
entity.GroupID = (long?)reader[5];
entity.TrunOutID = (long?)reader[6];
entity.Goods_Spec = (string)reader[7];
entity.Submited = submited;
list.Add(entity);
}
@ -64,7 +68,7 @@ namespace ButcherFactory.BO.LocalBL
entity.WorkUnit_ID = workUnitID;
entity.ProductBatch_ID = productBatchID;
entity.RowIndex = GenerateRowIndex(productBatchID, session);
entity.BarCode = string.Format("A26091201{0:yyyyMMdd}{1:00000}", batchDate, entity.RowIndex);
entity.BarCode = string.Format("260912011{0:yyyyMMdd}{1:00000}", batchDate, entity.RowIndex);
session.Insert(entity);
session.Commit();
return entity;
@ -125,5 +129,92 @@ namespace ButcherFactory.BO.LocalBL
delete.Where.Conditions.Add(DQCondition.EQ("ID", id));
delete.EExecute();
}
public static void UploadSegmentInfo()
{
try
{
using (var session = DmoSession.New())
{
var needUpload = GetUnSyncData(session);
if (needUpload.Count == 0)
return;
var json = JsonConvert.SerializeObject(needUpload);
RpcFacade.Call<int>(RpcPath + "Insert", json);
foreach (var item in needUpload)
SetLocalAsSyncd(item, session);
session.Commit();
}
}
catch
{
#if DEBUG
throw;
#endif
}
}
static List<SegmentProductionMin> GetUnSyncData(IDmoSession session)
{
var query = new DQueryDom(new JoinAlias("_main", typeof(SegmentProduction)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("RowVersion"));
query.Columns.Add(DQSelectColumn.Field("BarCode"));
query.Columns.Add(DQSelectColumn.Field("UserID"));
query.Columns.Add(DQSelectColumn.Field("WorkUnit_ID"));
query.Columns.Add(DQSelectColumn.Field("ProductBatch_ID"));
query.Columns.Add(DQSelectColumn.Field("Goods_ID"));
query.Columns.Add(DQSelectColumn.Field("Weight"));
query.Columns.Add(DQSelectColumn.Field("CreateTime"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Submited", true), DQCondition.EQ("Sync", false)));
query.Range = SelectRange.Top(10);
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
var upload = new List<SegmentProductionMin>();
using (var reader = session.ExecuteReader(query))
{
while (reader.Read())
{
var obj = new SegmentProductionMin();
obj.ID = (long)reader[0];
obj.RowVersion = (int)reader[1];
obj.BarCode = (string)reader[2];
obj.Worker_ID = (long)reader[3];
obj.WorkUnit_ID = (long?)reader[4];
obj.ProductBatch_ID = (long?)reader[5];
obj.Goods_ID = (long)reader[6];
obj.Weight = (decimal)reader[7];
obj.ProductTime = (DateTime)reader[8];
upload.Add(obj);
}
}
return upload;
}
static void SetLocalAsSyncd(SegmentProductionMin obj, IDmoSession session)
{
var update = new DQUpdateDom(typeof(SegmentProduction));
update.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("ID", obj.ID), DQCondition.EQ("RowVersion", obj.RowVersion)));
update.Columns.Add(new DQUpdateColumn("Sync", true));
session.ExecuteNonQuery(update);
}
}
class SegmentProductionMin
{
[JsonIgnore]
public long ID { get; set; }
[JsonIgnore]
public long RowVersion { get; set; }
public string BarCode { get; set; }
public DateTime? ProductTime { get; set; }
public long? Worker_ID { get; set; }
public long? WorkUnit_ID { get; set; }
public long? ProductBatch_ID { get; set; }
public long? Goods_ID { get; set; }
public decimal? Weight { get; set; }
public DateTime? InStoreTime { get; set; }
}
}

+ 2
- 0
ButcherFactory.BO/Utils/AppContext.cs View File

@ -37,6 +37,8 @@ namespace ButcherFactory.BO.Utils
public string SqlConnection { get; set; }
public string TraceBackUrl { get; set; }
public void Save()
{
XmlUtil.SerializerObjToFile(this);


+ 18
- 13
ButcherFactory.Form/SegmentProduction_/SegmentProductionForm.cs View File

@ -152,6 +152,7 @@ namespace ButcherFactory.SegmentProduction_
Start(true);
var entity = SegmentProductionBL.Insert(detail.Goods_ID, weight, workUnitID, batchID.Value, batchDate.Value);
entity.Goods_Name = detail.Goods_Name;
entity.Goods_Spec = detail.Goods_Spec;
GoodsLabel.Text = entity.Goods_Name;
unSubmitList.Insert(0, entity);
historyList.Insert(0, entity);
@ -185,18 +186,18 @@ namespace ButcherFactory.SegmentProduction_
void UpLoadLocalData()
{
//while (true)
//{
// if (this.IsHandleCreated)
// {
// this.Invoke(new Action(() =>
// {
// if (netStateWatch1.NetState)
// CarcassInStoreBL.UploadCarcassInfo();
// }));
// }
// Thread.Sleep(2000);
//}
while (true)
{
if (this.IsHandleCreated)
{
this.Invoke(new Action(() =>
{
if (netStateWatch1.NetState)
SegmentProductionBL.UploadSegmentInfo();
}));
}
Thread.Sleep(2000);
}
}
private void closeBtn_Click(object sender, EventArgs e)
@ -215,11 +216,15 @@ namespace ButcherFactory.SegmentProduction_
if (arr.Any())
{
var groupID = SegmentProductionBL.SetListGroupID(arr.Select(x => x.ID));
var bk = new List<SegmentProduction>();
foreach (var item in arr)
{
item.GroupID = groupID;
bk.Add(item);
}
Start(false);
if (barPrintCheck.Checked)
SegmentProductionPrint.PrintEnd(arr);
SegmentProductionPrint.PrintEnd(bk);
}
else
throw new Exception("本次开始之后未生产任何商品");


+ 6
- 2
ButcherFactory.Form/SegmentProduction_/SegmentProductionPrint.cs View File

@ -1,4 +1,5 @@
using ButcherFactory.BO;
using ButcherFactory.BO.Utils;
using System;
using System.Collections.Generic;
using System.IO;
@ -20,15 +21,18 @@ namespace ButcherFactory.SegmentProduction_
dt = DateTime.Today;
var dic = new Dictionary<string, string>();
dic.Add("$Goods_Name", entity.Goods_Name);
dic.Add("$Goods_Spec", entity.Goods_Spec);
dic.Add("$Weight", entity.Weight.ToString("#0.######"));
dic.Add("$Date", dt.Value.ToString("yyyy/MM/dd"));
var imgUrl = string.Format(IMGFILE, id);
BwpClientPrint.BwpClientWebPrint.Create2DPic(entity.BarCode, imgUrl, 120);
var url = string.Format(AppContext.ConnectInfo.TraceBackUrl + "?code={0}", entity.BarCode);
BwpClientPrint.BwpClientWebPrint.Create2DPic(url, imgUrl, 120);
dic.Add("$ImageUrl", imgUrl);
BwpClientPrint.BwpClientWebPrint.Print(PRINTFILE, dic);
AfterPrint();
}
public static void PrintEnd(IEnumerable<SegmentProduction> list)
public static void PrintEnd(List<SegmentProduction> list)
{
string firstRow = "<tr><td><span>{0}:</span></td><td>{1}</td><td>{2}</td><td rowspan='{3}' style='width:120px'><img src='$ImageUrl' style='width:120px;height:120px;margin-top:-5px;'/></td></tr>";
string template = "<tr><td><span>{0}:</span></td><td>{1}</td><td>{2}</td></tr>";


Loading…
Cancel
Save