Browse Source

TB_PRICE 去掉 State/VendAmt

添加订单导入并且自动创建要货看板传接口共呢
master
lvzb 4 years ago
parent
commit
d0463e8535
  1. 67
      Controller/SCP_BILLCODE_CONTROLLER.cs
  2. 364
      Controller/SCP_DC_UNI_CONTROLLER.cs
  3. 614
      Controller/SCP_PO_CONTROLLER.cs
  4. 2
      Models/AppBoxEntity/User.cs
  5. 18
      Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs
  6. 4
      Models/ScpEntity/TB_PRICE.cs
  7. 2
      SCP/Business/PageBase.cs
  8. 4
      SCP/Properties/AssemblyInfo.cs
  9. 6
      SCP/VersionUpdateInfo.txt
  10. 6
      SCP/Views/PlanData/SCP_PO.aspx
  11. 58
      SCP/Views/PlanData/SCP_PO.aspx.cs
  12. 18
      SCP/Views/PlanData/SCP_PO.aspx.designer.cs
  13. 6
      SCP/Views/PlanData/SCP_PO_EXTEND.aspx
  14. 59
      SCP/Views/PlanData/SCP_PO_EXTEND.aspx.cs
  15. 27
      SCP/Views/PlanData/SCP_PO_EXTEND.aspx.designer.cs

67
Controller/SCP_BILLCODE_CONTROLLER.cs

@ -54,6 +54,19 @@ namespace CK.SCP.Controller
return GetTablePK_QD("G", "TB_PALLETS", "PalletNum", "yyMMdd", 4,num); return GetTablePK_QD("G", "TB_PALLETS", "PalletNum", "yyMMdd", 4,num);
} }
/// <summary>
/// 生成订单编号
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
public static string MakePoNum(int num = 1)
{
return GetTablePO("P", "TB_PO", "PoBillNum", 7, num);
}
public static string MakeASKCodeByNum(int num)
{
return GetTablePKByNum("K", "TB_ASK", "AskBillNum", "yyMMdd", 4, num);
}
public static string MakeASKCode() public static string MakeASKCode()
{ {
@ -107,6 +120,60 @@ namespace CK.SCP.Controller
return GetTablePK(p_Header, p_TableName, p_ColumnName, "yyMMdd",4); return GetTablePK(p_Header, p_TableName, p_ColumnName, "yyMMdd",4);
} }
public static string GetTablePO(string Ext, string TableName, string ColName, int len, int num)
{
var _result = string.Empty;
try
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
string sql = "select max(right(" + ColName + "," + len.ToString() + ")+" + num + ") from " + TableName + " where " + ColName + " like '%P[0-9]%' ";
DbRawSqlQuery<int?> result = db.Database.SqlQuery<int?>(sql);
var obj = result.FirstOrDefault();
if (obj == null)
{
_result = Ext + num.ToString().PadLeft(len, '0');
}
else
{
_result = Ext + result.FirstOrDefault().ToString().PadLeft(len, '0');
}
}
}
catch (Exception e)
{
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BILLCODE_CONTROLLER), "GetTablePK", e.Message);
}
return _result;
}
public static string GetTablePKByNum(string Ext, string TableName, string ColName, string Format, int len, int num)
{
var _result = string.Empty;
try
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
string time = Ext + DateTime.Now.ToString(Format);
string sql = "select max(right(" + ColName + "," + len.ToString() + ")+" + num + ") from " + TableName + " where " + ColName + " like '" + time + "%'";
DbRawSqlQuery<int?> result = db.Database.SqlQuery<int?>(sql);
var obj = result.FirstOrDefault();
if (obj == null)
{
_result = time + num.ToString().PadLeft(len, '0');
}
else
{
_result = time + result.FirstOrDefault().ToString().PadLeft(len, '0');
}
}
}
catch (Exception e)
{
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BILLCODE_CONTROLLER), "GetTablePK", e.Message);
}
return _result;
}
public static string GetTablePK(string Ext, string TableName, string ColName, string Format, int len) public static string GetTablePK(string Ext, string TableName, string ColName, string Format, int len)
{ {
var _result = string.Empty; var _result = string.Empty;

364
Controller/SCP_DC_UNI_CONTROLLER.cs

@ -1897,7 +1897,363 @@ namespace CK.SCP.Controller
return _ret; return _ret;
} }
public static ResultObject<bool> WritePo(List<SCP_PO_EXPORT_IMPORT_MODEL> p_order_list, string site, string p_creator, DateTime p_time, BillModType p_modtype, string subsite, string p_chineseName, string p_buyerPhone)
{
ResultObject<bool> _ret = new ResultObject<bool>();
using (var scope =
new TransactionScope(TransactionScopeOption.Required, new TransactionOptions()
{
IsolationLevel = System.Transactions.IsolationLevel.Serializable,
Timeout = new TimeSpan(0, 20, 0)
}))
{
try
{
ScpEntities scpdb = EntitiesFactory.CreateScpInstance();
ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance();
var OrderList = p_order_list.GroupBy(p => p.).ToList();
string _polist = "";
int _num = 1;
OrderList.ForEach((p) =>
{
Guid taskid = Guid.NewGuid();
var list = p.ToList();
if (list.Count > 0)
{
#region 日程单
if (p_modtype == BillModType.Contract)
{
var _entity = list.FirstOrDefault();
var _po = scpdb.TB_PO.SingleOrDefault(t => t.PoBillNum == _entity./* && t.State == state*/ && t.Site == site && t.SubSite == subsite && t.VendId == _entity..ToUpper());
if (_po == null)
{
_po = new TB_PO { GUID = Guid.NewGuid(), PoBillNum = _entity..ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite, VendId = _entity..Trim().ToUpper() };
}
_po.ErpBillNum = _entity..Trim().ToUpper(); ;
_po.ModType = (int)p_modtype;
_po.Contacter = p_chineseName;// _entity.联系人;
_po.Buyer = p_chineseName;// _entity.联系人;
_po.Site = site.Trim().ToUpper();
_po.BuyerPhone = p_buyerPhone;
_po.Remark = _entity.;
_po.IsDeleted = false;
_po.CreateTime = DateTime.Now;
_po.CreateUser = p_creator;
_po.BeginTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
_po.EndTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.);
scpdb.TB_PO.AddOrUpdate(_po);
TED_PO_MSTR _po_mstr = new TED_PO_MSTR();
_po_mstr.GUID = Guid.NewGuid();
_po_mstr.PurchaseOrder = _entity..Trim().ToUpper();
_po_mstr.Supplier = _entity..Trim().ToUpper();
_po_mstr.Contact = p_chineseName;// _entity.联系人;
_po_mstr.ShipTo = subsite.Trim().ToUpper();//发往
_po_mstr.OrderDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
_po_mstr.DueDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
_po_mstr.StartDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);//订单日期
_po_mstr.EndDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.);
_po_mstr.MadeIn = "";
_po_mstr.Confirm = true;
_po_mstr.Buyer = p_chineseName;//_entity.采购员;
_po_mstr.BuyerPhone = p_buyerPhone;// _entity.采购员电话;
_po_mstr.Status = (int)PoState.Open;
_po_mstr.ScheduledOrder = true;
_po_mstr.CreateUser = p_creator;
_po_mstr.CreateTime = p_time;
_po_mstr.Remark = _entity.; ;
_po_mstr.TaskID = taskid;
_po_mstr.Domain = site.Trim().ToUpper();
_po_mstr.ModeType = ((int)p_modtype).ToString();
_po_mstr.Site = subsite.Trim().ToUpper();
_po_mstr.DataID = Guid.NewGuid();
_po_mstr.Pricelist = _entity..ToUpper().Trim() + subsite.Trim().Substring(1, 1) + subsite.Substring(3, 1).Trim();
_po_mstr.Taxclass = _entity.;
_po_mstr.CommandType = "A";
db.TED_PO_MSTR.Add(_po_mstr);
list.ForEach((itm) =>
{
int _poline = Int32.Parse(itm.);
var _PO_Detail = scpdb.TB_PO_DETAIL.FirstOrDefault(t => t.PartCode == itm. && t.PoLine == _poline && t.PoBillNum == itm. /*&& t.State == state*/ && t.Site == site && t.SubSite == subsite);
TED_PO_DET _PO_Detail_Det = new TED_PO_DET();
_PO_Detail_Det.GUID = Guid.NewGuid();
_PO_Detail_Det.PurchaseOrder = itm..Trim().ToUpper();
_PO_Detail_Det.Line = Int32.Parse(itm.);
_PO_Detail_Det.Currency = "CNY";
_PO_Detail_Det.PoType = itm.;
_PO_Detail_Det.PartCode = itm..Trim().ToUpper();
_PO_Detail_Det.Qty = decimal.Parse(itm.);
_PO_Detail_Det.QtyOpen = 0;
_PO_Detail_Det.PackQty = 1;
_PO_Detail_Det.Currency = itm.;
_PO_Detail_Det.Price = string.IsNullOrEmpty(itm.) ? 0 : decimal.Parse(itm.);
var _part = scpdb.TA_PART.FirstOrDefault(part => part.PartCode == itm..Trim().ToUpper());
if (_part == null)
{
_PO_Detail_Det.PoUm = itm.;
_PO_Detail_Det.LocUm = itm.;
}
else
{
_PO_Detail_Det.PoUm = _part.Unit;
_PO_Detail_Det.LocUm = _part.Unit;
}
_PO_Detail_Det.Conv = 1;
_PO_Detail_Det.DueDate = string.IsNullOrEmpty(itm.) ? DateTime.Now : DateTime.Parse(itm.);
_PO_Detail_Det.Status = (int)PoState.Open;
_PO_Detail_Det.CreateTime = DateTime.Parse(itm.);
_PO_Detail_Det.StartDate = string.IsNullOrEmpty(itm.) ? p_time : DateTime.Parse(itm.);
_PO_Detail_Det.EndDate = string.IsNullOrEmpty(itm.) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.);
_PO_Detail_Det.CreateUser = p_creator;
_PO_Detail_Det.TaskID = taskid;
if (_PO_Detail != null)
{
_PO_Detail_Det.CommandType = "U";
}
else
{
_PO_Detail = new TB_PO_DETAIL { GUID = Guid.NewGuid(), PartCode = itm..Trim().ToUpper(), PoLine = _poline, PoBillNum = itm..Trim().ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite };
_PO_Detail_Det.CommandType = "A";
}
_PO_Detail_Det.DataID = Guid.NewGuid();
_PO_Detail_Det.Domain = site.Trim().ToUpper();
_PO_Detail_Det.Site = subsite.Trim().ToUpper();
_PO_Detail_Det.Workorderlot = itm.;
_PO_Detail_Det.PoType = itm.;
_PO_Detail_Det.Operation = string.IsNullOrEmpty(itm.) ? 0 : int.Parse(itm.);
_PO_Detail_Det.Location = itm.;
_PO_Detail_Det.Firmdays = string.IsNullOrEmpty(itm.) ? 7 : int.Parse(itm.);
_PO_Detail_Det.Scheduledays = string.IsNullOrEmpty(itm.) ? 7 : int.Parse(itm.);
_PO_Detail_Det.Scheduleweeks = string.IsNullOrEmpty(itm.) ? 2 : int.Parse(itm.);
_PO_Detail_Det.Schedulemonth = string.IsNullOrEmpty(itm.) ? 1 : int.Parse(itm.);
_PO_Detail_Det.Supplieritem = itm.;
_PO_Detail_Det.Dliverypatterncode = itm.;
_PO_Detail_Det.Deliverytimecode = itm.;
_PO_Detail_Det.Transportdays = string.IsNullOrEmpty(itm.) ? 0 : int.Parse(itm.);
_PO_Detail_Det.Pricelist = _entity..Trim().ToUpper() + subsite.Substring(1, 1) + subsite.Substring(3, 1);
db.TED_POD_DET.Add(_PO_Detail_Det);
_PO_Detail.Currency = "CNY";
_PO_Detail.PoUnit = itm.;
_PO_Detail.CreateTime = DateTime.Now;
_PO_Detail.CreateUser = p_creator;
_PO_Detail.BeginTime = string.IsNullOrEmpty(itm.) ? DateTime.Now : DateTime.Parse(itm.);
_PO_Detail.EndTime = string.IsNullOrEmpty(itm.) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.);
_PO_Detail.PlanQty = decimal.Parse(itm.);
_PO_Detail.IsDeleted = false;
_PO_Detail.LocUnit = itm.;
_PO_Detail.PoUnit = itm.;
_PO_Detail.UnConv = 1;
_PO_Detail.Remark = itm.;
_PO_Detail.Price = string.IsNullOrEmpty(itm.) ? 0 : decimal.Parse(itm.);
scpdb.TB_PO_DETAIL.AddOrUpdate(_PO_Detail);
});
_polist = _polist + _po.PoBillNum + ",";
}
#endregion
#region 离散单 (离散单只增加不修改)
if (p_modtype == BillModType.Non_Contract)
{
var _entity = list.FirstOrDefault();
TB_PO _po = new TB_PO();
_po.GUID = Guid.NewGuid();
_po.PoBillNum = SCP_BILLCODE_CONTROLLER.MakePoNum(_num);
_po.State = (int)PoState.Open;
_po.Site = site.Trim().ToUpper();
_po.SubSite = subsite.Trim().ToUpper();
_po.VendId = _entity..Trim().ToUpper();
_po.ErpBillNum = _po.PoBillNum;
_po.ModType = (int)p_modtype;
_po.Contacter = p_chineseName;// _entity.联系人;
_po.Buyer = p_chineseName;// _entity.联系人;
_po.BuyerPhone = p_buyerPhone;
_po.Site = site.Trim().ToUpper();
_po.Remark = _entity.;
_po.IsDeleted = false;
_po.CreateTime = DateTime.Now;
_po.CreateUser = p_creator;
_po.BeginTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
_po.EndTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.);
scpdb.TB_PO.AddOrUpdate(_po);
TB_ASK _ask = new TB_ASK();
_ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCodeByNum(_num);
_ask.GUID = Guid.NewGuid();
_ask.PoBillNum = _po.PoBillNum;
_ask.VendId = _entity..Trim().ToUpper();
_ask.IsDeleted = false;
_ask.CreateTime = DateTime.Now;
_ask.CreateUser = p_creator;
_ask.Site = site.Trim().ToUpper();
_ask.ReceivedPort = "";//交货口
_ask.State = (int)AskState.New;
_ask.Remark = _entity.;
_ask.ModType = (int)p_modtype;
_ask.ErpBillNum = _po.PoBillNum;
_ask.BeginTime = p_time;
_ask.EndTime = DateTime.Parse(_entity.);
_ask.Buyer = p_chineseName;
_ask.BuyerPhone = p_buyerPhone;
_ask.SubSite = subsite;
scpdb.TB_ASK.Add(_ask);
TED_PO_MSTR _po_mstr = new TED_PO_MSTR();
_po_mstr.GUID = Guid.NewGuid();
_po_mstr.PurchaseOrder = _po.PoBillNum;
_po_mstr.Supplier = _entity..Trim().ToUpper();
_po_mstr.Contact = p_chineseName;// _entity.联系人;
_po_mstr.ShipTo = subsite.Trim().ToUpper();//发往
_po_mstr.OrderDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
_po_mstr.DueDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
_po_mstr.StartDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);//订单日期
_po_mstr.EndDate = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.);
_po_mstr.MadeIn = "";
_po_mstr.Confirm = true;
_po_mstr.Buyer = p_chineseName;// _entity.采购员;
_po_mstr.BuyerPhone = p_buyerPhone;// _entity.采购员电话;
_po_mstr.Status = (int)PoState.Open;
_po_mstr.ScheduledOrder = false;
_po_mstr.CreateUser = p_creator;
_po_mstr.CreateTime = p_time;
_po_mstr.Remark = _entity.; ;
_po_mstr.TaskID = taskid;
_po_mstr.CommandType = "A";
_po_mstr.Domain = site.Trim().ToUpper();
_po_mstr.ModeType = ((int)p_modtype).ToString();
_po_mstr.Site = subsite.Trim().ToUpper();
_po_mstr.DataID = Guid.NewGuid();
_po_mstr.Pricelist = _entity..ToUpper().Trim() + subsite.Substring(1, 1) + subsite.Substring(3, 1);
_po_mstr.Taxclass = _entity.;
db.TED_PO_MSTR.Add(_po_mstr);
int _number = 1;
list.ForEach((itm) =>
{
TB_PO_DETAIL _PO_Detail = new TB_PO_DETAIL();
_PO_Detail.GUID = Guid.NewGuid();
_PO_Detail.PartCode = itm..Trim().ToUpper();
_PO_Detail.PoLine = _number;
_PO_Detail.PoBillNum = _po.PoBillNum;
_PO_Detail.State = (int)PoState.Open;
_PO_Detail.Site = site.Trim().ToUpper();
_PO_Detail.SubSite = subsite.Trim().ToUpper();
_PO_Detail.Currency = "CNY";
_PO_Detail.PoUnit = itm.;
_PO_Detail.Remark = itm.;
_PO_Detail.CreateTime = DateTime.Now;
_PO_Detail.CreateUser = p_creator;
_PO_Detail.BeginTime = string.IsNullOrEmpty(itm.) ? DateTime.Now : DateTime.Parse(itm.);
_PO_Detail.EndTime = string.IsNullOrEmpty(itm.) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.);
_PO_Detail.PlanQty = decimal.Parse(itm.);
_PO_Detail.IsDeleted = false;
_PO_Detail.LocUnit = itm.;
_PO_Detail.PoUnit = itm.;
_PO_Detail.UnConv = 1;
_PO_Detail.Price = string.IsNullOrEmpty(itm.) ? 0 : decimal.Parse(itm.);
_PO_Detail.TempQty = decimal.Parse(itm.);
TB_ASK_DETAIL _tDetail = new TB_ASK_DETAIL();
_tDetail.Remark = itm.;
_tDetail.PoBillNum = _po.PoBillNum;
_tDetail.AskBillNum = _ask.AskBillNum;
_tDetail.PoLine = _number;
_tDetail.PoUnit = itm.;
_tDetail.CreateTime = DateTime.Now;
_tDetail.CreateUser = p_creator;
_tDetail.PartCode = itm..ToUpper().Trim();
_tDetail.ReceivedPort = "";
_tDetail.BeginTime = p_time;
_tDetail.EndTime = Convert.ToDateTime(itm.);
_tDetail.TempQty = 0;
_tDetail.AskQty = Decimal.Parse(itm.);
_tDetail.IsDeleted = false;
_tDetail.LocUnit = itm.;
_tDetail.UnConv = 1;
_tDetail.State = (int)PoState.Open;
_tDetail.SubSite = subsite.Trim().ToUpper();
_tDetail.Site = site.Trim().ToUpper();
_tDetail.Price = Decimal.Parse(itm.);
_tDetail.GUID = Guid.NewGuid();
_tDetail.Currency = itm.;
scpdb.TB_ASK_DETAIL.Add(_tDetail);
scpdb.TB_PO_DETAIL.AddOrUpdate(_PO_Detail);
TED_PO_DET _PO_Detail_Det = new TED_PO_DET();
_PO_Detail_Det.GUID = Guid.NewGuid();
_PO_Detail_Det.PurchaseOrder = _po.PoBillNum;
_PO_Detail_Det.Line = _number;
_PO_Detail_Det.Currency = "CNY";
_PO_Detail_Det.PoType = itm.;
_PO_Detail_Det.PartCode = itm..Trim().ToUpper();
_PO_Detail_Det.Qty = decimal.Parse(itm.);
_PO_Detail_Det.QtyOpen = 0;
_PO_Detail_Det.PackQty = 1;
_PO_Detail_Det.Currency = itm.;
_PO_Detail_Det.Price = string.IsNullOrEmpty(itm.) ? 0 : decimal.Parse(itm.);
_PO_Detail_Det.PoUm = itm.;
_PO_Detail_Det.LocUm = itm.;
_PO_Detail_Det.Conv = 1;
_PO_Detail_Det.DueDate = string.IsNullOrEmpty(itm.) ? DateTime.Now : DateTime.Parse(itm.);
_PO_Detail_Det.Status = (int)PoState.Open;
_PO_Detail_Det.CreateTime = DateTime.Parse(itm.);
_PO_Detail_Det.StartDate = string.IsNullOrEmpty(itm.) ? p_time : DateTime.Parse(itm.);
_PO_Detail_Det.EndDate = string.IsNullOrEmpty(itm.) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.);
_PO_Detail_Det.CreateUser = p_creator;
_PO_Detail_Det.TaskID = taskid;
_PO_Detail_Det.CommandType = "A";
_PO_Detail_Det.DataID = Guid.NewGuid();
_PO_Detail_Det.Domain = site.Trim().ToUpper();
_PO_Detail_Det.Site = subsite.Trim().ToUpper();
_PO_Detail_Det.Workorderlot = itm.;
_PO_Detail_Det.PoType = itm.;
_PO_Detail_Det.Operation = string.IsNullOrEmpty(itm.) ? 0 : int.Parse(itm.);
_PO_Detail_Det.Location = itm.;
_PO_Detail_Det.Firmdays = string.IsNullOrEmpty(itm.) ? 7 : int.Parse(itm.);
_PO_Detail_Det.Scheduledays = string.IsNullOrEmpty(itm.) ? 7 : int.Parse(itm.);
_PO_Detail_Det.Scheduleweeks = string.IsNullOrEmpty(itm.) ? 2 : int.Parse(itm.);
_PO_Detail_Det.Schedulemonth = string.IsNullOrEmpty(itm.) ? 1 : int.Parse(itm.);
_PO_Detail_Det.Supplieritem = itm.;
_PO_Detail_Det.Dliverypatterncode = itm.;
_PO_Detail_Det.Deliverytimecode = itm.;
_PO_Detail_Det.Transportdays = string.IsNullOrEmpty(itm.) ? 0 : int.Parse(itm.);
_PO_Detail_Det.Pricelist = _entity..ToUpper() + subsite.Substring(1, 1) + subsite.Substring(3, 1);
db.TED_POD_DET.Add(_PO_Detail_Det);
_number++;
});
_polist = _polist + _po.PoBillNum + ",";
}
#endregion
}
var ret = CREATE_TEA_TASK_SUB(db, true, new TEA_TASK_SUB()
{
DataCount = 1,
TaskID = taskid,
TableName = "TED_PO_MSTR",
Site = subsite.Trim().ToUpper(),
Domain = site.Trim().ToUpper(),
CreateTime = p_time,
CreateUser = p_creator,
Creator = "SCP",
});
_num++;
Thread.Sleep(10);
}
);
EntitiesFactory.SaveDb(scpdb);
EntitiesFactory.SaveDb(db);
scope.Complete();
_ret.State = ReturnStatus.Succeed;
_ret.Result = true;
_ret.Message = _polist;
}
catch (Exception e)
{
_ret.State = ReturnStatus.Failed;
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "InsterPo", e.Message);
_ret.Result = false;
_ret.Message = e.InnerException.Message;
scope.Dispose();
}
}
return _ret;
}
//public static ResultObject<bool> UpdateTES_PURCHASE_PRICE(List<long> p_list, string domain, string site, string name, bool flag,int ConfirmState) //public static ResultObject<bool> UpdateTES_PURCHASE_PRICE(List<long> p_list, string domain, string site, string name, bool flag,int ConfirmState)
@ -2068,7 +2424,7 @@ namespace CK.SCP.Controller
// } // }
// db.TED_PO_MSTR.Add(_po_mstr); // db.TED_PO_MSTR.Add(_po_mstr);
// _po.ErpBillNum = _entity.订单编号.Trim().ToUpper();; // _po.ErpBillNum = _entity.订单编号.Trim().ToUpper(); ;
// _po.ModType = (int)p_modtype; // _po.ModType = (int)p_modtype;
// _po.Contacter = p_chineseName;// _entity.联系人; // _po.Contacter = p_chineseName;// _entity.联系人;
// _po.Buyer = p_chineseName;// _entity.联系人; // _po.Buyer = p_chineseName;// _entity.联系人;
@ -2111,7 +2467,7 @@ namespace CK.SCP.Controller
// else // else
// { // {
// _PO_Detail_Det.PoUm = _part.Unit; // _PO_Detail_Det.PoUm = _part.Unit;
// _PO_Detail_Det.LocUm =_part.Unit; // _PO_Detail_Det.LocUm = _part.Unit;
// } // }
// _PO_Detail_Det.Conv = 1; // _PO_Detail_Det.Conv = 1;
// _PO_Detail_Det.DueDate = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now : DateTime.Parse(itm.要求到货日期); // _PO_Detail_Det.DueDate = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now : DateTime.Parse(itm.要求到货日期);
@ -2161,7 +2517,7 @@ namespace CK.SCP.Controller
// _PO_Detail.Remark = itm.备注; // _PO_Detail.Remark = itm.备注;
// _PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); // _PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价);
// _PO_Detail.Workorderlot = string.IsNullOrEmpty(itm.加工单号) ? 0 : int.Parse(itm.加工单号); // _PO_Detail.Workorderlot = string.IsNullOrEmpty(itm.加工单号) ? 0 : int.Parse(itm.加工单号);
// _PO_Detail.PoType =itm.订单类型; // _PO_Detail.PoType = itm.订单类型;
// _PO_Detail.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序); // _PO_Detail.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序);
// _PO_Detail.Location = itm.库位; // _PO_Detail.Location = itm.库位;
// _PO_Detail.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数); // _PO_Detail.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数);
@ -2380,7 +2736,7 @@ namespace CK.SCP.Controller
// scope.Complete(); // scope.Complete();
// _ret.State = ReturnStatus.Succeed; // _ret.State = ReturnStatus.Succeed;
// _ret.Result = true; // _ret.Result = true;
// _ret.Message= _polist; // _ret.Message = _polist;
// } // }
// catch (Exception e) // catch (Exception e)

614
Controller/SCP_PO_CONTROLLER.cs

@ -12,6 +12,7 @@ using CK.SCP.Utils;
using System.Data.Entity.Core; using System.Data.Entity.Core;
using CK.SCP.Models.ScpEntity.ExcelExportEnttity; using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading;
namespace CK.SCP.Controller namespace CK.SCP.Controller
{ {
@ -634,9 +635,622 @@ namespace CK.SCP.Controller
return ErrorList; return ErrorList;
} }
public static ResultObject<bool> Save_EXCEL_PO_MOD(List<SCP_PO_EXPORT_IMPORT_MODEL> p_order_list, string site, string p_creator, DateTime p_time, BillModType p_modtype, string subsite, string p_chineseName, string p_buyerPhone)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
List<string> lineError = new List<string>();
List<string> ErrorList = new List<string>();
var _lst = p_order_list;
string _polist = "";
int _num = 1;
var OrderList = _lst.GroupBy(p => p.).ToList();
OrderList.ForEach((p) =>
{
var list = p.ToList();
if (list.Count > 0)
{
#region 日程单
if (p_modtype == BillModType.Contract)
{
var _entity = list.FirstOrDefault();
var _po = db.TB_PO.SingleOrDefault(t => t.PoBillNum == _entity./* && t.State == state*/ && t.Site == site && t.SubSite == subsite && t.VendId == _entity..ToUpper()) ??
new TB_PO { GUID = Guid.NewGuid(), PoBillNum = _entity..ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite, VendId = _entity..ToUpper() };
_po.ErpBillNum = _entity..ToUpper();
_po.ModType = (int)p_modtype;
_po.Contacter = p_chineseName;// _entity.联系人;
_po.Buyer = p_chineseName;// _entity.联系人;
_po.BuyerPhone = p_buyerPhone;
_po.Site = site;
_po.Remark = _entity.;
_po.IsDeleted = false;
_po.CreateTime = DateTime.Parse(_entity.);
_po.CreateUser = p_creator;
_po.BeginTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
_po.EndTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(30) : DateTime.Parse(_entity.);
db.TB_PO.AddOrUpdate(_po);
list.ForEach((itm) =>
{
int _poline = Int32.Parse(itm.);
var _PO_Detail = db.TB_PO_DETAIL.FirstOrDefault(t => t.PartCode == itm. && t.PoLine == _poline && t.PoBillNum == itm. /*&& t.State == state*/ && t.Site == site && t.SubSite == subsite) ??
new TB_PO_DETAIL { GUID = Guid.NewGuid(), PartCode = itm..ToUpper(), PoLine = _poline, PoBillNum = itm..ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite };
_PO_Detail.Currency = "CNY";
_PO_Detail.PoUnit = itm.;
_PO_Detail.CreateTime = DateTime.Parse(itm.);
_PO_Detail.CreateUser = p_creator;
_PO_Detail.BeginTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
_PO_Detail.EndTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(30) : DateTime.Parse(_entity.);
_PO_Detail.PlanQty = decimal.Parse(itm.);
_PO_Detail.IsDeleted = false;
_PO_Detail.LocUnit = itm.;
_PO_Detail.PoUnit = itm.;
_PO_Detail.UnConv = 1;
_PO_Detail.Price = string.IsNullOrEmpty(itm.) ? 0 : decimal.Parse(itm.);
db.TB_PO_DETAIL.AddOrUpdate(_PO_Detail);
});
_polist = _polist + _po.PoBillNum + ",";
}
#endregion
#region 离散单
if (p_modtype == BillModType.Non_Contract)
{
var _entity = list.FirstOrDefault();
TB_PO _po = new TB_PO();
_po.GUID = Guid.NewGuid();
_po.PoBillNum = SCP_BILLCODE_CONTROLLER.MakePoNum(_num);
_po.State = (int)PoState.Open;
_po.Site = site;
_po.SubSite = subsite;
_po.VendId = _entity..ToUpper();
_po.ErpBillNum = _po.PoBillNum;
_po.ModType = (int)p_modtype;
_po.Contacter = p_chineseName;// _entity.联系人;
_po.Buyer = p_chineseName;// _entity.联系人;
_po.BuyerPhone = p_buyerPhone;
_po.Site = site;
_po.Remark = _entity.;
_po.IsDeleted = false;
_po.CreateTime = DateTime.Parse(_entity.);
_po.CreateUser = p_creator;
_po.BeginTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
_po.EndTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(30) : DateTime.Parse(_entity.);
db.TB_PO.AddOrUpdate(_po);
TB_ASK _ask = new TB_ASK();
_ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCodeByNum(_num);
_ask.GUID = Guid.NewGuid();
_ask.PoBillNum = _po.PoBillNum;
_ask.VendId = _entity..ToUpper();
_ask.IsDeleted = false;
_ask.CreateTime = DateTime.Now;
_ask.CreateUser = p_creator;
_ask.Site = site;
_ask.ReceivedPort = "";//交货口
_ask.State = (int)AskState.New;
_ask.Remark = _entity.;
_ask.ModType = (int)p_modtype;
_ask.ErpBillNum = _po.PoBillNum;
_ask.BeginTime = p_time;
_ask.EndTime = DateTime.Parse(_entity.);
_ask.Buyer = p_chineseName;
_ask.BuyerPhone = p_buyerPhone;
_ask.SubSite = subsite;
db.TB_ASK.Add(_ask);
int _number = 1;
list.ForEach((itm) =>
{
TB_PO_DETAIL _PO_Detail = new TB_PO_DETAIL();
_PO_Detail.GUID = Guid.NewGuid();
_PO_Detail.PartCode = itm..Trim().ToUpper();
_PO_Detail.PoLine = _number;
_PO_Detail.PoBillNum = _po.PoBillNum;
_PO_Detail.State = (int)PoState.Open;
_PO_Detail.Site = site;
_PO_Detail.SubSite = subsite;
_PO_Detail.Currency = "CNY";
_PO_Detail.PoUnit = itm.;
_PO_Detail.CreateTime = DateTime.Parse(itm.);
_PO_Detail.CreateUser = p_creator;
_PO_Detail.BeginTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now : DateTime.Parse(_entity.);
_PO_Detail.EndTime = string.IsNullOrEmpty(_entity.) ? DateTime.Now.AddYears(30) : DateTime.Parse(_entity.);
_PO_Detail.PlanQty = decimal.Parse(itm.);
_PO_Detail.IsDeleted = false;
_PO_Detail.LocUnit = itm.;
_PO_Detail.PoUnit = itm.;
_PO_Detail.UnConv = 1;
_PO_Detail.Price = string.IsNullOrEmpty(itm.) ? 0 : decimal.Parse(itm.);
_PO_Detail.TempQty = decimal.Parse(itm.);
TB_ASK_DETAIL _tDetail = new TB_ASK_DETAIL();
_tDetail.Remark = itm.;
_tDetail.PoBillNum = _po.PoBillNum;
_tDetail.AskBillNum = _ask.AskBillNum;
_tDetail.PoLine = _number;
_tDetail.PoUnit = itm.;
_tDetail.CreateTime = DateTime.Now;
_tDetail.CreateUser = p_creator;
_tDetail.PartCode = itm..Trim().ToUpper();
_tDetail.ReceivedPort = "";
_tDetail.BeginTime = p_time;
_tDetail.EndTime = Convert.ToDateTime(itm.);
_tDetail.TempQty = 0;
_tDetail.AskQty = Decimal.Parse(itm.);
_tDetail.IsDeleted = false;
_tDetail.LocUnit = itm.;
_tDetail.UnConv = 1;
_tDetail.State = (int)PoState.Open;
_tDetail.SubSite = subsite;
_tDetail.Site = site;
_tDetail.Price = Decimal.Parse(itm.);
_tDetail.GUID = Guid.NewGuid();
_tDetail.Currency = itm.;
db.TB_ASK_DETAIL.Add(_tDetail);
db.TB_PO_DETAIL.AddOrUpdate(_PO_Detail);
_number++;
});
_polist = _polist + _po.PoBillNum + "</br>";
}
#endregion
}
else
{
_ret.MessageList.Add("订单导入有误!");
return;
}
_num++;
Thread.Sleep(10);
}
);
if (_ret.MessageList.Count == 0)
{
int state = db.SaveChanges();
if (state != -1)
{
_ret.State = ReturnStatus.Succeed;
_ret.Result = true;
_ret.Message = _polist;
}
else
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
}
}
else
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
}
}
}
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
{
var sb = new StringBuilder();
foreach (var error in dbEx.EntityValidationErrors.ToList())
{
error.ValidationErrors.ToList().ForEach(i =>
{
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
});
}
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(dbEx);
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", sb.ToString());
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", ex.ToString());
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
}
catch (ScpException ex)
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", ex.ToString());
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
{
var inner = (UpdateException)ex.InnerException;
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
}
else
{
if (ex.InnerException != null) throw ex.InnerException;
}
}
catch (Exception e)
{
_ret.State = ReturnStatus.Failed;
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
throw e;
}
return _ret;
}
public static ResultObject<bool> Check_EXCEL_PO_MOD(List<SCP_PO_EXPORT_IMPORT_MODEL> p_order_list, BillModType p_modtype, string site, string subsite)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
int number = 1;
List<string> lineError = new List<string>();
List<string> ErrorList = new List<string>();
var _lst = p_order_list;
p_order_list.ForEach(p =>
{
var _count1 = _lst.Count(itm => itm. == p. && itm. == p.);
var _count2 = _lst.Count(itm => itm. == p. && itm. == p.);
if (_count1 > 1 && p_modtype == BillModType.Contract)
{
lineError.Add(string.Format("导入订单编号【{0}】行号【{1}】有重复", p., p.));
ErrorList = lineError;
}
if (_count2 > 1)
{
lineError.Add(string.Format("导入订单编号【{0}】零件编码【{1}】有重复", p., p.));
ErrorList = lineError;
}
});
p_order_list.ForEach
(p =>
{
var _ls = CheckExcelMode_Po(db, p, p_modtype, site, subsite);
if (_ls.Count > 0)
{
lineError.Add(number.ToString());
ErrorList.Add(string.Join("<br>", _ls.ToArray()));
}
number++;
});
if (lineError.Count > 0)
{
_ret.State = ReturnStatus.Failed;
_ret.MessageList.AddRange(ErrorList);
_ret.Result = false;
}
else
{
_ret.State = ReturnStatus.Succeed;
_ret.Result = true;
}
}
}
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
{
var sb = new StringBuilder();
foreach (var error in dbEx.EntityValidationErrors.ToList())
{
error.ValidationErrors.ToList().ForEach(i =>
{
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
});
}
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(dbEx);
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", sb.ToString());
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
}
catch (OptimisticConcurrencyException ex)//并发冲突异常
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", ex.ToString());
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
}
catch (ScpException ex)
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(ex);
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", ex.ToString());
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
{
var inner = (UpdateException)ex.InnerException;
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
}
else
{
if (ex.InnerException != null) throw ex.InnerException;
}
}
catch (Exception e)
{
_ret.State = ReturnStatus.Failed;
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
throw e;
}
return _ret;
}
/// <summary>
/// 订单导入检查
/// </summary>
/// <param name="db"></param>
/// <param name="p_excel"></param>
/// <returns></returns>
private static List<string> CheckExcelMode_Po(ScpEntities db, SCP_PO_EXPORT_IMPORT_MODEL p_excel, BillModType p_modtype, string site = null, string subsite = null)
{
List<string> ErrorList = new List<string>();
decimal _result = 0;
if (!decimal.TryParse(p_excel., out _result))
{
ErrorList.Add(string.Format("订单编号【{0}】零件编号【{1}】数量填写有问题", p_excel., p_excel.));
}
var _checkpart = db.TA_PART.FirstOrDefault(p => p.PartCode == p_excel.);
if (_checkpart != null)
{
if (_checkpart.State.ToUpper() != "SP")
{
p_excel. = _checkpart.Unit;
}
else
{
ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表零件停用,无法导入!", p_excel., p_excel.));
}
}
else
{
ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel., p_excel.));
}
DateTime _d = DateTime.Now;
#region 日程单验证
if (p_modtype == BillModType.Contract)
{
if (string.IsNullOrEmpty(p_excel.) || string.IsNullOrEmpty(p_excel.) || string.IsNullOrEmpty(p_excel.) ||
string.IsNullOrEmpty(p_excel.) || string.IsNullOrEmpty(p_excel.) || string.IsNullOrEmpty(p_excel.))
{
ErrorList.Add(string.Format("分组【{1}】零件名称【{0}】有填写为空!", p_excel., p_excel.));
}
else
{
if (!string.IsNullOrEmpty(p_excel.))
{
DateTime year = DateTime.Parse(p_excel.);
if (year.Year > 2049)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的零件截止日期必须大于等于2049年!", p_excel., p_excel., p_excel.));
}
}
if (!string.IsNullOrEmpty(p_excel.))
{
DateTime year = DateTime.Parse(p_excel.);
if (year.Year > 2049)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单截止日期必须大于等于2049年!", p_excel., p_excel., p_excel.));
}
}
string _ponumber = p_excel..ToUpper() + subsite.Substring(1, 1) + subsite.Substring(3, 1);
if (p_excel..ToUpper() != _ponumber.ToUpper())
{
ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】零件号【{2}】的订单编号不正确,请更换订单编号!", p_excel., p_excel., p_excel.));
}
int _polinr = Int32.Parse(p_excel.);
var _partlist = db.TB_PO_DETAIL.Where(p => p.PoBillNum == p_excel. && p.PartCode == p_excel. && p.PoLine != _polinr).ToList();
if (_partlist.Count > 0)
{
ErrorList.Add(string.Format("订单编号【{0}】零件号【{1}】已经存在(系统:行号-【{2}】),请更换零件号!", p_excel., p_excel., _partlist[0].PoLine));
}
int linecount = db.TB_PO_DETAIL.Count(p => p.PoBillNum == p_excel. && p.PoLine == _polinr && p.PartCode != p_excel.);
if (linecount > 0)
{
ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】已经存在,请更换行号!", p_excel., p_excel.));
}
var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel. && p.Site == site && p.VendId == p_excel. && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList();
if (checkcount.Count == 0)
{
ErrorList.Add(string.Format("零件名称【{0}】供应编码【{1}】价格表没有维护信息!", p_excel., p_excel.));
}
else
{
p_excel. = checkcount[0].Amt.ToString();
p_excel. = checkcount[0].Unit;
p_excel. = checkcount[0].Curr;
}
if (p_excel. != "0")
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的要货数量应该为零!", p_excel., p_excel., p_excel.));
}
if (DateTime.TryParse(p_excel., out _d) && DateTime.TryParse(p_excel., out _d))
{
if (DateTime.Parse(p_excel.) < DateTime.Parse(p_excel.))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】要求到货日期不能小于订单创建时间日期!", p_excel., p_excel., p_excel.));
}
}
else
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单创建日期或要求到货日期要求为文本格式!", p_excel., p_excel., p_excel.));
}
if (!Regex.IsMatch(p_excel., "^[0-9]{1,2}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】税率最大应为2位整数!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.))
{
if (p_excel..ToUpper() == "S")
{
if (string.IsNullOrEmpty(p_excel.) || !Regex.IsMatch(p_excel., "^[0-9]{1,8}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】加工单最大8位整数!", p_excel., p_excel., p_excel.));
}
if (string.IsNullOrEmpty(p_excel.) || !Regex.IsMatch(p_excel., "^[0-9]{1,6}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】工序最大6位整数!", p_excel., p_excel., p_excel.));
}
}
else
{
ErrorList.Add(string.Format("{0}订单类型必须填写为S为转包订单,不填写为正常订单", p_excel.));
}
//注释结束
}
if (!string.IsNullOrEmpty(p_excel.) && p_excel..Length > 8)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】库位最大8位字符!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.) && !Regex.IsMatch(p_excel., "^[0-9]{1,4}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】固定天数最大4位整数!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.) && !Regex.IsMatch(p_excel., "^[0-9]{1,3}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】日程天数最大3位整数!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.) && !Regex.IsMatch(p_excel., "^[0-9]{1,3}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】日程周数最大3位整数!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.) && !Regex.IsMatch(p_excel., "^[0-9]{1,3}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】日程月数最大3位整数!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.) && p_excel..Length > 2)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】发货样式最大2位字符!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.) && p_excel..Length > 2)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】发货时间样式最大2位字符!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.) && !Regex.IsMatch(p_excel., "^[0-9]{1,3}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】运输周期最大3位整数!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.) && p_excel..Length > 8)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】库位最大8位字符!", p_excel., p_excel., p_excel.));
}
}
}
#endregion
#region 离散单验证
if (p_modtype == BillModType.Non_Contract)
{
if (/*string.IsNullOrEmpty(p_excel.订单编号) ||string.IsNullOrEmpty(p_excel.行号) ||*/ string.IsNullOrEmpty(p_excel.) ||
string.IsNullOrEmpty(p_excel.) || string.IsNullOrEmpty(p_excel.) || string.IsNullOrEmpty(p_excel.) ||
string.IsNullOrEmpty(p_excel.)/* || string.IsNullOrEmpty(p_excel.税率)*/)
{
ErrorList.Add(string.Format("分组【{1}】零件名称【{0}】有填写为空!", p_excel., p_excel.));
}
else
{
decimal a = decimal.Parse(p_excel.);
if (a <= 0)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的数量不能小于等于0", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.))
{
DateTime year = DateTime.Parse(p_excel.);
if (year.Year > 2049)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的零件截止日期必须大于等于2049年!", p_excel., p_excel., p_excel.));
}
}
if (!string.IsNullOrEmpty(p_excel.))
{
DateTime year = DateTime.Parse(p_excel.);
if (year.Year > 2049)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单截止日期必须大于等于2049年!", p_excel., p_excel., p_excel.));
}
}
var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel. && p.Site == site&& p.VendId == p_excel. && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList();
if (checkcount.Count == 0)
{
ErrorList.Add(string.Format("零件名称【{0}】供应编码【{1}】价格表没有维护信息!", p_excel., p_excel.));
}
else
{
p_excel. = checkcount[0].Amt.ToString();
p_excel. = checkcount[0].Unit;
p_excel. = checkcount[0].Curr;
}
//if (!Regex.IsMatch(p_excel.税率, "^[0-9]{1,2}$"))
//{
// ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】税率最大2位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号));
//}
if (DateTime.TryParse(p_excel., out _d) && DateTime.TryParse(p_excel., out _d))
{
if (DateTime.Parse(p_excel.) < DateTime.Parse(p_excel.))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】要求到货日期不能小于订单创建时间日期!", p_excel., p_excel., p_excel.));
}
}
else
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单创建日期或要求到货日期要求为文本格式!", p_excel., p_excel., p_excel.));
}
if (!string.IsNullOrEmpty(p_excel.))
{
if (p_excel..ToUpper() != "S" && p_excel..ToUpper() != "M")
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单类型只能为M或S!", p_excel., p_excel., p_excel.));
}
//注释结束
if (p_excel..ToUpper() == "S")
{
if (string.IsNullOrEmpty(p_excel.) || !Regex.IsMatch(p_excel., "^[0-9]{1,8}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】加工单最大8位整数!", p_excel., p_excel., p_excel.));
}
if (string.IsNullOrEmpty(p_excel.) || !Regex.IsMatch(p_excel., "^[0-9]{1,6}$"))
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】工序最大6位整数!", p_excel., p_excel., p_excel.));
}
}
}
if (!string.IsNullOrEmpty(p_excel.) && p_excel..Length > 8)
{
ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】库位最大8位字符!", p_excel., p_excel., p_excel.));
}
}
}
#endregion
return ErrorList;
}
private static List<string> CheckExcelMode(ScpEntities db, SCP_PO_DETAIL_EXPORT_MODEL p_excel) private static List<string> CheckExcelMode(ScpEntities db, SCP_PO_DETAIL_EXPORT_MODEL p_excel)
{ {
List<string> ErrorList = new List<string>(); List<string> ErrorList = new List<string>();

2
Models/AppBoxEntity/User.cs

@ -98,7 +98,7 @@ namespace CK.SCP.Models.AppBoxEntity
public Dictionary<string,string> ConfigList { set; get; } public Dictionary<string,string> ConfigList { set; get; }
[NotMapped] [NotMapped]
public List<string> SiteList { set; get; } public List<string> SubSiteList { set; get; }
[NotMapped] [NotMapped]
public string UsedDomain { set; get; } public string UsedDomain { set; get; }

18
Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs

@ -81,6 +81,22 @@ namespace CK.SCP.Models.ScpEntity.ExcelExportEnttity
public string { get; set; } public string { get; set; }
public string { get; set; } public string { get; set; }
public string { set; get; } public string { set; get; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
public string { get; set; }
} }
} }

4
Models/ScpEntity/TB_PRICE.cs

@ -27,7 +27,7 @@ namespace CK.SCP.Models.ScpEntity
public string Extend1 { get; set; } public string Extend1 { get; set; }
public string Extend2 { get; set; } public string Extend2 { get; set; }
public string Extend3 { get; set; } public string Extend3 { get; set; }
public int State { get; set; } //public int State { get; set; }
public decimal? VendAmt { get; set; } //public decimal? VendAmt { get; set; }
} }
} }

2
SCP/Business/PageBase.cs

@ -615,7 +615,7 @@ namespace SCP
_currentUser.RoleList = _currentUser.Roles.Select(p => p.Name).ToList(); _currentUser.RoleList = _currentUser.Roles.Select(p => p.Name).ToList();
var _userVerders = DB.VenderUsers.Where(p => p.UserId == _currentUser.ID).Select(p => p.VenderId).ToList(); var _userVerders = DB.VenderUsers.Where(p => p.UserId == _currentUser.ID).Select(p => p.VenderId).ToList();
_currentUser.FactoryList = _factoryList; _currentUser.FactoryList = _factoryList;
_currentUser.SiteList = _siteList; _currentUser.SubSiteList = _siteList;
_currentUser.VenderList = _userVerders; _currentUser.VenderList = _userVerders;
_currentUser.ConfigList = new Dictionary<string, string>(); _currentUser.ConfigList = new Dictionary<string, string>();
if (_currentUser.FactoryList.Count > 0) if (_currentUser.FactoryList.Count > 0)

4
SCP/Properties/AssemblyInfo.cs

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// //
// 可以指定所有值,也可以使用“修订号”和“内部版本号”的默认值, // 可以指定所有值,也可以使用“修订号”和“内部版本号”的默认值,
// 方法是按如下所示使用 "*": // 方法是按如下所示使用 "*":
[assembly: AssemblyVersion("1.21.0128.1")] [assembly: AssemblyVersion("1.21.0204.1")]
[assembly: AssemblyFileVersion("1.21.0128.1")] [assembly: AssemblyFileVersion("1.21.0204.1")]

6
SCP/VersionUpdateInfo.txt

@ -8,3 +8,9 @@ Version: 1.21.0128.1
登陆界面添加版本号 登陆界面添加版本号
TA_VENDER 添加 SubSite TA_VENDER 添加 SubSite
//////////// ////////////
////////////
Version: 1.21.0204.1
Info: TB_PRICE 去掉 State/VendAmt
添加订单导入并且自动创建要货看板传接口共呢
////////////

6
SCP/Views/PlanData/SCP_PO.aspx

@ -48,7 +48,11 @@
</f:RadioButtonList> </f:RadioButtonList>
<f:ToolbarSeparator runat="server" /> <f:ToolbarSeparator runat="server" />
<f:FileUpload runat="server" ID="FileUp" EmptyText="请选择要货单据" Required="true" Width="200" ButtonIcon="Add" ShowRedStar="true" > </f:FileUpload> <f:FileUpload runat="server" ID="FileUp" EmptyText="请选择要货单据" Required="true" Width="200" ButtonIcon="Add" ShowRedStar="true" > </f:FileUpload>
<f:Button ID="btnInput" runat="server" Text="导入" Icon="PageExcel" OnClick="btnInput_Click" > <f:Button ID="btnInput_Contract" runat="server" Text="日程单导入" Hidden="true" Icon="PageExcel" OnClick="btnInput_Click_Contract" >
</f:Button>
<f:Button ID="btnInput_Non_Contract" runat="server" Text="离散单导入" Hidden="true" Icon="PageExcel" OnClick="btnInput_Click_Non_Contract" >
</f:Button>
<f:Button ID="btnInput" runat="server" Text="导入" Icon="PageExcel" OnClick="btnInput_Click" Hidden="true" >
</f:Button> </f:Button>
</Items> </Items>
</f:Toolbar> </f:Toolbar>

58
SCP/Views/PlanData/SCP_PO.aspx.cs

@ -202,6 +202,64 @@ namespace SCP.PlanData
} }
} }
protected void btnInput_Click_Contract(object sender, EventArgs e)
{
Excel_Input(BillModType.Contract);
}
protected void btnInput_Click_Non_Contract(object sender, EventArgs e)
{
Excel_Input(BillModType.Non_Contract);
}
protected void Excel_Input(BillModType p_modtype)
{
ResultObject<bool> saveret = new ResultObject<bool>();
string _fileName = FileUp.FileName;
if (string.IsNullOrEmpty(_fileName))
{
Alert.Show("选择文件为空!");
return;
}
string _lx = _fileName.Split('.')[1];
Stream _stream = FileUp.PostedFile.InputStream;
DataTable _dt = new DataTable();
if (_lx == "xls")
{
_dt = ExcelHelper.GetDataTable(_stream);
}
else
{
_dt = ExcelHelper.GetDataTableOfXlsx(_stream);
}
var list = ConvertHelper.ToList<SCP_PO_EXPORT_IMPORT_MODEL>(ExcelHelper.RemoveEmpty(_dt)).ToList();
var checkret = SCP_PO_CONTROLLER.Check_EXCEL_PO_MOD(list, p_modtype, CurrentUser.FactoryList[0], CurrentUser.SubSiteList[0]);
if (checkret.State == ReturnStatus.Failed && checkret.Result == false)
{
Alert.Show(string.Join("<br>", checkret.MessageList));
return;
}
if (CurrentUser.ConfigList.ContainsKey("数据中心接口"))
{
saveret = SCP_DC_UNI_CONTROLLER.WritePo(list, CurrentUser.FactoryList[0], CurrentUser.Name, DateTime.Now, p_modtype, CurrentUser.SubSiteList[0], CurrentUser.ChineseName, CurrentUser.CellPhone);
}
else
{
saveret = SCP_PO_CONTROLLER.Save_EXCEL_PO_MOD(list, CurrentUser.FactoryList[0], CurrentUser.Name, DateTime.Now, p_modtype, CurrentUser.SubSiteList[0], CurrentUser.ChineseName, CurrentUser.CellPhone);
}
if (saveret.State == ReturnStatus.Succeed && saveret.Result == true)
{
BindOrder();
Alert.Show("订单编号" + saveret.Message + "导入成功!");
return;
}
else
{
//Alert.Show(string.Join("<br>", saveret.MessageList));
Alert.Show(saveret.Message);
return;
}
}
protected void BTN_CREATE_Click(object sender, EventArgs e) protected void BTN_CREATE_Click(object sender, EventArgs e)
{ {
if (Grid_V_TB_PO.SelectedRowIndexArray.Count() == 0) if (Grid_V_TB_PO.SelectedRowIndexArray.Count() == 0)

18
SCP/Views/PlanData/SCP_PO.aspx.designer.cs

@ -122,6 +122,24 @@ namespace SCP.PlanData
/// </remarks> /// </remarks>
protected global::FineUI.FileUpload FileUp; protected global::FineUI.FileUpload FileUp;
/// <summary>
/// btnInput_Contract 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUI.Button btnInput_Contract;
/// <summary>
/// btnInput_Non_Contract 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUI.Button btnInput_Non_Contract;
/// <summary> /// <summary>
/// btnInput 控件。 /// btnInput 控件。
/// </summary> /// </summary>

6
SCP/Views/PlanData/SCP_PO_EXTEND.aspx

@ -63,6 +63,12 @@
<f:RadioItem Text="日程单" Value="1" /> <f:RadioItem Text="日程单" Value="1" />
<f:RadioItem Text="离散单" Value="2"/> <f:RadioItem Text="离散单" Value="2"/>
</f:RadioButtonList> </f:RadioButtonList>
<f:ToolbarSeparator runat="server" />
<f:FileUpload runat="server" ID="FileUp" EmptyText="请选择要货单据" Required="true" Width="200" ButtonIcon="Add" ShowRedStar="true" > </f:FileUpload>
<f:Button ID="btnInput_Contract" runat="server" Text="日程单导入" Icon="PageExcel" OnClick="btnInput_Click_Contract" >
</f:Button>
<f:Button ID="btnInput_Non_Contract" runat="server" Text="离散单导入" Icon="PageExcel" OnClick="btnInput_Click_Non_Contract" >
</f:Button>
</Items> </Items>
</f:Toolbar> </f:Toolbar>
</Toolbars> </Toolbars>

59
SCP/Views/PlanData/SCP_PO_EXTEND.aspx.cs

@ -14,6 +14,7 @@ using CK.SCP.Models.ScpEntity.ExcelImportEntity;
using CK.SCP.Models.Enums; using CK.SCP.Models.Enums;
using CK.SCP.Common; using CK.SCP.Common;
using System.Text; using System.Text;
using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
namespace SCP.PlanData namespace SCP.PlanData
{ {
@ -243,5 +244,63 @@ namespace SCP.PlanData
}); });
} }
protected void btnInput_Click_Contract(object sender, EventArgs e)
{
Excel_Input(BillModType.Contract);
}
protected void btnInput_Click_Non_Contract(object sender, EventArgs e)
{
Excel_Input(BillModType.Non_Contract);
}
protected void Excel_Input(BillModType p_modtype)
{
ResultObject<bool> saveret = new ResultObject<bool>();
string _fileName = FileUp.FileName;
if (string.IsNullOrEmpty(_fileName))
{
Alert.Show("选择文件为空!");
return;
}
string _lx = _fileName.Split('.')[1];
Stream _stream = FileUp.PostedFile.InputStream;
DataTable _dt = new DataTable();
if (_lx == "xls")
{
_dt = ExcelHelper.GetDataTable(_stream);
}
else
{
_dt = ExcelHelper.GetDataTableOfXlsx(_stream);
}
var list = ConvertHelper.ToList<SCP_PO_EXPORT_IMPORT_MODEL>(ExcelHelper.RemoveEmpty(_dt)).ToList();
var checkret = SCP_PO_CONTROLLER.Check_EXCEL_PO_MOD(list, p_modtype, CurrentUser.FactoryList[0], CurrentUser.SubSiteList[0]);
if (checkret.State == ReturnStatus.Failed && checkret.Result == false)
{
Alert.Show(string.Join("<br>", checkret.MessageList));
return;
}
if (CurrentUser.ConfigList.ContainsKey("数据中心接口"))
{
saveret = SCP_DC_UNI_CONTROLLER.WritePo(list, CurrentUser.FactoryList[0], CurrentUser.Name, DateTime.Now, p_modtype, CurrentUser.SubSiteList[0], CurrentUser.ChineseName, CurrentUser.CellPhone);
}
else
{
saveret = SCP_PO_CONTROLLER.Save_EXCEL_PO_MOD(list, CurrentUser.FactoryList[0], CurrentUser.Name, DateTime.Now, p_modtype, CurrentUser.SubSiteList[0], CurrentUser.ChineseName, CurrentUser.CellPhone);
}
if (saveret.State == ReturnStatus.Succeed && saveret.Result == true)
{
BindOrder();
Alert.Show("订单编号" + saveret.Message + "导入成功!");
return;
}
else
{
//Alert.Show(string.Join("<br>", saveret.MessageList));
Alert.Show(saveret.Message);
return;
}
}
} }
} }

27
SCP/Views/PlanData/SCP_PO_EXTEND.aspx.designer.cs

@ -113,6 +113,33 @@ namespace SCP.PlanData
/// </remarks> /// </remarks>
protected global::FineUI.RadioButtonList rblist; protected global::FineUI.RadioButtonList rblist;
/// <summary>
/// FileUp 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUI.FileUpload FileUp;
/// <summary>
/// btnInput_Contract 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUI.Button btnInput_Contract;
/// <summary>
/// btnInput_Non_Contract 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUI.Button btnInput_Non_Contract;
/// <summary> /// <summary>
/// gp1 控件。 /// gp1 控件。
/// </summary> /// </summary>

Loading…
Cancel
Save