You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
459 lines
24 KiB
459 lines
24 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.Entity.Migrations;
|
|
using System.Linq;
|
|
using CK.SCP.Models;
|
|
using CK.SCP.Models.Enums;
|
|
using CK.SCP.Models.ScpEntity;
|
|
using CK.SCP.Models.UniApiEntity;
|
|
using CK.SCP.Utils;
|
|
using CK.SCP.Controller;
|
|
|
|
namespace CK.SCP.UniApi.Controller
|
|
{
|
|
public static class OdbcApiQadController
|
|
{
|
|
|
|
public static void GetNewCtrlList()
|
|
{
|
|
UniApiEntities idb = EntitiesFactory.CreateUniApiInstance();
|
|
idb.Database.CommandTimeout = 60 * 20;
|
|
var tableNameList = EnumHelper.EnumToList<QadTableName>();
|
|
// var qadCtrlList = idb.xxqad_ctrl.Where(p => p.xxqad_domain == ScpCache.Config.QADÓò && p.xxqad_scm == "0").ToList();
|
|
var qadCtrlList = idb.xxqad_ctrl.Where(p => p.xxqad_scm == "0").ToList();
|
|
ScpEntities scpdb = EntitiesFactory.CreateScpInstance();
|
|
//foreach (V_TB_PO_DETAIL _detail in p_list)
|
|
//{
|
|
// var _ask = db.TB_ASK_DETAIL.Where(p => p.PoBillNum == _detail.PoBillNum && p.IsDeleted == false).GroupBy(p => new { p.PoBillNum, p.PoLine, p.PartCode }).Select(p => new { AskSum = p.Sum(itm => itm.AskQty), PoLine = p.Key.PoLine, PoBillNum = p.Key.PoBillNum, PartCode = p.Key.PartCode });
|
|
|
|
// var rec = db.TB_RECEIVE_DETAIL.Where(p => p.PoBillNum == _detail.PoBillNum && p.IsDeleted == false && p.State == (int)ReceiveState.Check && p.BillType == 0)
|
|
// .GroupBy(p => new { p.PoBillNum, p.PoLine, p.PartCode }).Select(p => new { ReceiveSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, PoBillNum = p.Key.PoBillNum, PartCode = p.Key.PartCode });
|
|
|
|
// var reject = db.TB_RECEIVE_DETAIL.Where(p => p.PoBillNum == _detail.PoBillNum && p.IsDeleted == false && p.State == (int)RejectState.Check && p.BillType == 1).GroupBy(p => new { p.PoBillNum, p.PoLine, p.PartCode }).Select(p => new { RejectSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, PoBillNum = p.Key.PoBillNum, PartCode = p.Key.PartCode });
|
|
|
|
// var asn = db.TB_ASN_DETAIL.Where(p => p.PoBillNum == _detail.PoBillNum && p.IsDeleted == false && p.State == (int)AsnState.Ship)
|
|
// .GroupBy(p => new { p.PoBillNum, p.PoLine, p.PartCode })
|
|
// .Select(p => new { AsSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, PoBillNum = p.Key.PoBillNum, PartCode = p.Key.PartCode });
|
|
|
|
// var arrive = db.TB_ARRIVE_DETAIL.Where(p => p.PoBillNum == _detail.PoBillNum && p.IsDeleted == false && p.State == (int)ArriveState.OK && p.BillType == (int)ArriveBillType.Receive).GroupBy(p => new { p.PoBillNum, p.PoLine, p.PartCode }).Select(p => new { ArriveSum = p.Sum(itm => itm.Qty), PoLine = p.Key.PoLine, PoBillNum = p.Key.PoBillNum, PartCode = p.Key.PartCode });
|
|
|
|
|
|
// _detail.PartDesc1 = _detail.PartDesc1 + _detail.PartDesc2;
|
|
// rec.ToList().ForEach(itm =>
|
|
// {
|
|
// if (_detail.PoBillNum == itm.PoBillNum && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode)
|
|
// {
|
|
// _detail.ReceivedQty = itm.ReceiveSum;
|
|
// }
|
|
|
|
// });
|
|
// reject.ToList().ForEach(itm =>
|
|
// {
|
|
// if (_detail.PoBillNum == itm.PoBillNum && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode)
|
|
// {
|
|
// _detail.RejectQty = itm.RejectSum.ToString();
|
|
// }
|
|
|
|
// });
|
|
// asn.ToList().ForEach(itm =>
|
|
// {
|
|
// if (_detail.PoBillNum == itm.PoBillNum && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode)
|
|
// {
|
|
// _detail.ShippedQty = itm.AsSum;
|
|
// }
|
|
|
|
// });
|
|
// _ask.ToList().ForEach(itm =>
|
|
// {
|
|
// if (_detail.PoBillNum == itm.PoBillNum && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode)
|
|
// {
|
|
// _detail.TempQty = itm.AskSum;
|
|
// }
|
|
// });
|
|
// arrive.ToList().ForEach(itm =>
|
|
// {
|
|
// if (_detail.PoBillNum == itm.PoBillNum && _detail.PoLine == itm.PoLine && _detail.PartCode == itm.PartCode)
|
|
// {
|
|
// _detail.ArriveQty = itm.ArriveSum.ToString();
|
|
// }
|
|
|
|
// });
|
|
//}
|
|
|
|
|
|
|
|
|
|
foreach (var qadCtrl in qadCtrlList)
|
|
{
|
|
if (tableNameList.All(p => p.Name != qadCtrl.xxqad_table)) continue;
|
|
try
|
|
{
|
|
ScpEntities wdb = EntitiesFactory.CreateScpInstance();
|
|
|
|
QadTableName qadTableName;
|
|
Enum.TryParse(qadCtrl.xxqad_table, false, out qadTableName);
|
|
|
|
switch (qadTableName)
|
|
{
|
|
case QadTableName.xxqad_pt_mstr: //ÎïÁÏ
|
|
if (GlobalVar.ApiConfig.QadÁã¼þ)
|
|
{
|
|
Console.WriteLine($"·¢ÏÖ QAD ½Ó¿ÚÊý¾Ý£º{qadCtrl.xxqad_table}:{qadCtrl.xxqad_table_qty}");
|
|
UpdateParts(idb, wdb, qadCtrl.xxqad_seq);
|
|
}
|
|
else
|
|
continue;
|
|
break;
|
|
case QadTableName.xxqad_vd_mstr: //¹©Ó¦ÉÌ
|
|
if (GlobalVar.ApiConfig.Qad¹©Ó¦ÉÌ)
|
|
{
|
|
Console.WriteLine($"·¢ÏÖ QAD ½Ó¿ÚÊý¾Ý£º{qadCtrl.xxqad_table}:{qadCtrl.xxqad_table_qty}");
|
|
UpdateVender(idb, wdb, qadCtrl.xxqad_seq);
|
|
}
|
|
else
|
|
continue;
|
|
break;
|
|
|
|
case QadTableName.xxqad_vp_mstr: //¹©Ó¦ÉÌÎïÁÏ
|
|
if (GlobalVar.ApiConfig.Qad¹©Ó¦ÉÌÁã¼þ)
|
|
{
|
|
Console.WriteLine($"·¢ÏÖ QAD ½Ó¿ÚÊý¾Ý£º{qadCtrl.xxqad_table}:{qadCtrl.xxqad_table_qty}");
|
|
UpdateVendParts(idb, wdb, qadCtrl.xxqad_seq);
|
|
}
|
|
else
|
|
continue;
|
|
break;
|
|
|
|
case QadTableName.xxqad_pod_det: //²É¹º¶©µ¥
|
|
if (GlobalVar.ApiConfig.Qad²É¹º¶©µ¥)
|
|
{
|
|
Console.WriteLine($"·¢ÏÖ QAD ½Ó¿ÚÊý¾Ý£º{qadCtrl.xxqad_table}:{qadCtrl.xxqad_table_qty}");
|
|
UpdatePurchaseOrders(idb, wdb, qadCtrl.xxqad_seq);
|
|
}
|
|
else
|
|
continue;
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
qadCtrl.xxqad_scm = ((int)UniApiState.³É¹¦).ToString();
|
|
EntitiesFactory.SaveDb(wdb);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
qadCtrl.xxqad_scm = ((int)UniApiState.ʧ°Ü).ToString();
|
|
qadCtrl.xxqad_rmks += " SCM:" + ex.Message;
|
|
|
|
}
|
|
finally
|
|
{
|
|
EntitiesFactory.SaveDb(idb);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// ¸üвɹº¶©µ¥
|
|
/// </summary>
|
|
/// <param name="idb"></param>
|
|
/// <param name="wdb"></param>
|
|
/// <param name="seq"></param>
|
|
private static void UpdatePurchaseOrders(UniApiEntities idb, ScpEntities wdb, string seq)
|
|
{
|
|
// var qadPoDetailList = idb.xxqad_pod_det.Where(p => p.xxqad_pod_seq == seq).ToList(); ÔÀ´µÄ xxqad_pod_modtype 1Ϊ´ó¶©µ¥
|
|
var qadPoDetailList = idb.xxqad_pod_det.Where(p => p.xxqad_pod_seq == seq && p.xxqad_pod_scmread == "0").ToList();
|
|
|
|
var wmsPoList = new List<TB_PO>();
|
|
var wmsPoDetailList = new List<TB_PO_DETAIL>();
|
|
|
|
var qadPoNbrList = qadPoDetailList.Select(p => p.xxqad_pod_nbr.ToUpper()).DistinctBy(p => p);
|
|
|
|
foreach (var qadPoNbr in qadPoNbrList)
|
|
{
|
|
var qadDataList = qadPoDetailList.Where(p => p.xxqad_pod_nbr == qadPoNbr).ToList();
|
|
if (qadDataList.Count == 0)
|
|
{
|
|
continue;
|
|
}
|
|
var firstqadData = qadDataList[0];
|
|
//var wmsPo = wdb.TF_PO.SingleOrDefault(p => p.ErpBillNum == qadPoNbr);
|
|
var wmsPo = wdb.TB_PO.SingleOrDefault(p => p.ErpBillNum == qadPoNbr);
|
|
if (wmsPo == null)
|
|
{
|
|
|
|
//wmsPo = new TF_PO
|
|
//{
|
|
// BillNum = qadPoNbr,
|
|
// ErpBillNum = qadPoNbr,
|
|
// BillTime = DateTime.Now,
|
|
// ModType = firstqadData.xxqad_pod_modtype,
|
|
// OperName = firstqadData.xxqad_pod_createur,
|
|
// State = (int)FormState.¿ª·Å,
|
|
// Remark = "",
|
|
// VendId = firstqadData.xxqad_pod_vend.ToUpper(),
|
|
// ShipToSite = firstqadData.xxqad_pod_ship,
|
|
//};
|
|
int temp;
|
|
string strPoBillNum = SCP_BILLCODE_CONTROLLER.MakePOCode();
|
|
|
|
wmsPo = new TB_PO
|
|
{
|
|
PoBillNum = qadPoNbr,//¶©µ¥ºÅ
|
|
ErpBillNum = qadPoNbr,//ERP¶©µ¥ºÅ
|
|
VendId = firstqadData.xxqad_pod_vend,//¹©Ó¦É̱àºÅ
|
|
ModType = Int32.TryParse(firstqadData.xxqad_pod_modtype, out temp) ? temp : (int?)null, //µ¥¾ÝÀàÐÍ(1:Èճ̵¥,2:ÀëÉ¢¶©µ¥)
|
|
Contacter = firstqadData.xxqad_pod_attn,//ÁªÏµÈË
|
|
Site = firstqadData.xxqad_pod_ship,//µØµã
|
|
//Buyer = firstqadData.xxqad_pod_buyer,//²É¹ºÔ±
|
|
//BuyerPhone = firstqadData.xxqad_pod_buyer_phone,//²É¹ºÔ±µç»°
|
|
State = (int)FormState.¿ª·Å,//״̬
|
|
Remark = "",//˵Ã÷
|
|
CreateTime = firstqadData.xxqad_pod_createdt == null ? DateTime.Now : (DateTime)firstqadData.xxqad_pod_createdt,//´´½¨ÈÕÆÚ
|
|
CreateUser = firstqadData.xxqad_pod_createur,//´´½¨Óû§
|
|
//UpdateTime = firstqadData.xxqad_pod_updatedt,//¸üÐÂÈÕÆÚ
|
|
//UpdateUser = firstqadData.xxqad_pod_updateur,//¸üÐÂÓû§
|
|
IsDeleted = false,
|
|
GUID = System.Guid.NewGuid(),
|
|
BeginTime = firstqadData.xxqad_pod_createdt,//´´½¨ÈÕÆÚ
|
|
EndTime = firstqadData.xxqad_pod_due_date//ÊÕ»õ½áÊøʱ¼ä
|
|
};
|
|
wmsPoList.Add(wmsPo);
|
|
}
|
|
// wmsPo.VendId = firstqadData.xxqad_pod_vend.ToUpper();
|
|
// wmsPo.ShipToSite = firstqadData.xxqad_pod_ship;
|
|
wmsPo.Contacter = firstqadData.xxqad_pod_attn;
|
|
wmsPo.Buyer = firstqadData.xxqad_pod_buyer;
|
|
wmsPo.BuyerPhone = firstqadData.xxqad_pod_buyer_phone;
|
|
|
|
wmsPo.UpdateTime = firstqadData.xxqad_pod_updatedt;//¸üÐÂÈÕÆÚ
|
|
wmsPo.UpdateUser = firstqadData.xxqad_pod_updateur;//¸üÐÂÓû§
|
|
|
|
foreach (var qadData in qadDataList)
|
|
{
|
|
try
|
|
{
|
|
var lineNum = Convert.ToInt32(qadData.xxqad_pod_line);
|
|
//var wmsPoDetail =
|
|
// wdb.TF_PO_DETAIL.SingleOrDefault(
|
|
// p => p.ErpBillNum == qadPoNbr && p.LineNum == lineNum);
|
|
var wmsPoDetail =
|
|
wdb.TB_PO_DETAIL.SingleOrDefault(
|
|
p => p.PoBillNum == qadPoNbr && p.PoLine == lineNum);
|
|
if (wmsPoDetail == null)
|
|
{
|
|
wmsPoDetail = new TB_PO_DETAIL
|
|
{
|
|
PoBillNum = qadPoNbr,//¶©µ¥ºÅ
|
|
PoLine = lineNum,//¶©µ¥ÐÐ
|
|
IsDeleted = false,
|
|
GUID = System.Guid.NewGuid()
|
|
};
|
|
wmsPoDetailList.Add(wmsPoDetail);
|
|
}
|
|
wmsPoDetail.PartCode = qadData.xxqad_pod_part.ToUpper();//Áã¼þºÅ-ÎïÁϺÅ
|
|
wmsPoDetail.PlanQty = qadData.xxqad_pod_qty_ord;//¶©»õÊýÁ¿-²É¹ºÁ¿
|
|
//wmsPoDetail.ShippedQty = qadData.xxqad_pod_qty_rct;//ÒÑ·¢ÊýÁ¿-ÒÑÊÕ»õÁ¿
|
|
//wmsPoDetail.ReceivedQty = qadData.xxqad_pod_qty_rct;//ÒÑÊÕÊýÁ¿-ÒÑÊÕ»õÁ¿
|
|
//wmsPoDetail.RejectQty = qadData.xxqad_pod_qty_rct;//ÒÑÍËÊýÁ¿-ÒÑÊÕ»õÁ¿
|
|
wmsPoDetail.BeginTime = firstqadData.xxqad_pod_createdt;//ÊÕ»õ¿ªÊ¼Ê±¼ä
|
|
wmsPoDetail.EndTime = qadData.xxqad_pod_due_date;//ÊÕ»õ½áÊøʱ¼ä
|
|
wmsPoDetail.PoUnit = qadData.xxqad_pod_um;//²É¹ºµ¥Î»
|
|
wmsPoDetail.LocUnit = qadData.xxqad_pod_loc_um.ToUpper();//´æ´¢µ¥Î»
|
|
wmsPoDetail.Price = ScpCache.Config.ÏîÄ¿Ãû³Æ == ProjectName.ÖØÇì±±ÆûÄ£ËÜ.ToString()
|
|
? 0
|
|
: qadData.xxqad_pod_price;
|
|
wmsPoDetail.Currency = qadData.xxqad_pod_curr;//±ÒÖÖ
|
|
wmsPoDetail.PackQty = qadData.xxqad_pod_qty_std;//±ê°üÊýÁ¿
|
|
wmsPoDetail.UnConv = qadData.xxqad_pod_um_conv;//ת»»ÂÊ
|
|
//wmsPoDetail.DockCode = ?;//
|
|
wmsPoDetail.State = Convert.ToInt32(qadData.xxqad_pod_status);//״̬
|
|
wmsPoDetail.Remark = qadData.xxqad_pod_rmks;//±¸×¢
|
|
wmsPoDetail.CreateTime = firstqadData.xxqad_pod_createdt == null ? DateTime.Now : (DateTime)firstqadData.xxqad_pod_createdt;//´´½¨ÈÕÆÚ
|
|
wmsPoDetail.CreateUser = firstqadData.xxqad_pod_createur;//´´½¨Óû§
|
|
wmsPoDetail.UpdateTime = firstqadData.xxqad_pod_updatedt;//¸üÐÂÈÕÆÚ
|
|
wmsPoDetail.UpdateUser = firstqadData.xxqad_pod_updateur;//¸üÐÂÓû§
|
|
|
|
//if (wmsPoDetail.BillQty != 0 && wmsPoDetail.BillQty <= wmsPoDetail.ReceivedQty)
|
|
// wmsPoDetail.State = (int)FormState.¹Ø±Õ;
|
|
|
|
if (wmsPoDetail.PlanQty != 0 && wmsPoDetail.PlanQty <= wmsPoDetail.ReceivedQty)
|
|
wmsPoDetail.State = (int)FormState.¹Ø±Õ;
|
|
|
|
qadData.xxqad_pod_scmread = ((int)UniApiState.³É¹¦).ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
qadData.xxqad_pod_scmread = ((int)UniApiState.ʧ°Ü).ToString();
|
|
qadData.xxqad_pod_rmks += " SCM:" + ex.Message;
|
|
}
|
|
qadData.xxqad_pod_updateur = ScpCache.Config.SCP̞;
|
|
qadData.xxqad_pod_updatedt = DateTime.Now;
|
|
|
|
}
|
|
wmsPo.State = qadDataList.All(p => p.xxqad_pod_status == ((int)FormState.¹Ø±Õ).ToString())
|
|
? (int)FormState.¹Ø±Õ
|
|
: (int)FormState.¿ª·Å;
|
|
}
|
|
wdb.TB_PO.AddOrUpdate(wmsPoList.ToArray());
|
|
wdb.TB_PO_DETAIL.AddOrUpdate(wmsPoDetailList.ToArray());
|
|
Console.WriteLine($"¸üР²É¹º¶©µ¥ Êý¾Ý£º{qadPoDetailList.Count}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// ¸üй©Ó¦ÉÌÁã¼þ
|
|
/// </summary>
|
|
/// <param name="idb"></param>
|
|
/// <param name="wdb"></param>
|
|
/// <param name="seq"></param>
|
|
private static void UpdateVendParts(UniApiEntities idb, ScpEntities wdb, string seq)
|
|
{
|
|
var qadDataList = idb.xxqad_vp_mstr.Where(p => p.xxqad_vp_seq == seq).ToList();
|
|
var wmsDataList = new List<TA_VEND_PART>();
|
|
foreach (var qadData in qadDataList)
|
|
{
|
|
try
|
|
{
|
|
if (qadData.xxqad_vp_vend_part == null)
|
|
qadData.xxqad_vp_vend_part = qadData.xxqad_vp_part;
|
|
var wmsData =
|
|
wdb.TA_VEND_PART.SingleOrDefault(
|
|
p => p.VendId == qadData.xxqad_vp_addr.ToUpper()
|
|
&& p.PartCode == qadData.xxqad_vp_part.ToUpper()
|
|
&& p.VendPartCode == qadData.xxqad_vp_vend_part.ToUpper()
|
|
) ??
|
|
new TA_VEND_PART
|
|
{
|
|
VendId = qadData.xxqad_vp_addr.ToUpper(),//¹©Ó¦É̱àºÅ
|
|
PartCode = qadData.xxqad_vp_part.ToUpper(),//¶ÔÓ¦ÎïÁϺÅ
|
|
VendPartCode = qadData.xxqad_vp_vend_part.ToUpper(),//¹©Ó¦ÉÌÎïÁϺÅ
|
|
VendPackQty = qadData.xxqad_vp_comment,//¹©Ó¦ÉÌÎïÁϺÅ
|
|
//PoUnit = qadData.,//²É¹ºµ¥Î»
|
|
State = 1,//״̬£¨0£ºÊ§Ð§ 1:ÓÐЧ£©
|
|
Remark = "",
|
|
CreateTime = qadData.xxqad_vp_createdt == null ? DateTime.Now : (DateTime)qadData.xxqad_vp_createdt,//´´½¨ÈÕÆÚ
|
|
CreateUser = qadData.xxqad_vp_createur,//´´½¨Óû§
|
|
UpdateTime = qadData.xxqad_vp_updatedt,//¸üÐÂÈÕÆÚ
|
|
UpdateUser = qadData.xxqad_vp_updateur,//¸üÐÂÓû§
|
|
|
|
IsDeleted = false,
|
|
GUID = new Guid()
|
|
};
|
|
// wmsData.VendPartCode = qadData.xxqad_vp_vend_part?.ToUpper() ?? qadData.xxqad_vp_part.ToUpper();
|
|
wmsData.VendPackQty = qadData.xxqad_vp_comment;
|
|
wmsDataList.Add(wmsData);
|
|
qadData.xxqad_vp_scmread = ((int)UniApiState.³É¹¦).ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
qadData.xxqad_vp_scmread = ((int)UniApiState.ʧ°Ü).ToString();
|
|
qadData.xxqad_vp_rmks += " SCM:" + ex.Message;
|
|
}
|
|
qadData.xxqad_vp_updateur = ScpCache.Config.SCP̞;
|
|
qadData.xxqad_vp_updatedt = DateTime.Now;
|
|
|
|
}
|
|
wdb.TA_VEND_PART.AddOrUpdate(wmsDataList.ToArray());
|
|
Console.WriteLine($"¸üР¹©Ó¦ÉÌÁã¼þ Êý¾Ý£º{wmsDataList.Count}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// ¸üй©Ó¦ÉÌ
|
|
/// </summary>
|
|
/// <param name="idb"></param>
|
|
/// <param name="wdb"></param>
|
|
/// <param name="seq"></param>
|
|
private static void UpdateVender(UniApiEntities idb, ScpEntities wdb, string seq)
|
|
{
|
|
var qadDataList = idb.xxqad_vd_mstr.Where(p => p.xxqad_vd_seq == seq).ToList();
|
|
var wmsDataList = new List<TA_VENDER>();
|
|
foreach (var qadData in qadDataList)
|
|
{
|
|
try
|
|
{
|
|
var wmsData = wdb.TA_VENDER.SingleOrDefault(p => p.VendId == qadData.xxqad_vd_addr.ToUpper()) ??
|
|
new TA_VENDER { VendId = qadData.xxqad_vd_addr.ToUpper(), VendAbbCode = "0", State = 1 };
|
|
wmsData.VendName = qadData.xxqad_vd_name;
|
|
wmsData.VendType = qadData.xxqad_vd_type.ToUpper().ToString();
|
|
wmsData.Country = qadData.xxqad_vd_country;
|
|
wmsData.City = qadData.xxqad_vd_city;
|
|
wmsData.Currency = qadData.xxqad_vd_curr.ToUpper();
|
|
// wmsData.Promo = qadData.xxqad_vd_promo; //¹úÄÚ¹úÍâ
|
|
wmsData.Address = qadData.xxqad_vd_line1 + qadData.xxqad_vd_line2 + qadData.xxqad_vd_line3;
|
|
wmsData.ZipCode = qadData.xxqad_vd_pst_id;
|
|
wmsData.Contacter = qadData.xxqad_vd_attn;
|
|
wmsData.Phone = qadData.xxqad_vd_phone;
|
|
wmsData.Fax = qadData.xxqad_vd_fax;
|
|
wmsData.Site = ScpCache.Config.QADµØµã;
|
|
// wmsData.Email = ""; //QADÎÞ´ËÏî
|
|
wmsData.Tax = qadData.xxqad_vd_tax;//Ë°ÂÊ
|
|
wmsDataList.Add(wmsData);
|
|
qadData.xxqad_vd_scmread = ((int)UniApiState.³É¹¦).ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
qadData.xxqad_vd_scmread = ((int)UniApiState.ʧ°Ü).ToString();
|
|
qadData.xxqad_vd_rmks += " SCM:" + ex.Message;
|
|
}
|
|
qadData.xxqad_vd_updateur = ScpCache.Config.SCP̞;
|
|
qadData.xxqad_vd_updatedt = DateTime.Now;
|
|
|
|
}
|
|
wdb.TA_VENDER.AddOrUpdate(p => p.VendId, wmsDataList.ToArray());
|
|
Console.WriteLine($"¸üР¹©Ó¦ÉÌ Êý¾Ý£º{qadDataList.Count}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// ¸üÐÂÁã¼þ
|
|
/// </summary>
|
|
/// <param name="idb"></param>
|
|
/// <param name="wdb"></param>
|
|
/// <param name="seq"></param>
|
|
private static void UpdateParts(UniApiEntities idb, ScpEntities wdb, string seq)
|
|
{
|
|
var qadDataList = idb.xxqad_pt_mstr.Where(p => p.xxqad_pt_seq == seq).ToList();
|
|
var wmsDataList = new List<TA_PART>();
|
|
foreach (var qadData in qadDataList)
|
|
{
|
|
try
|
|
{
|
|
var wmsData = wdb.TA_PART.SingleOrDefault(p => p.ErpPartCode == qadData.xxqad_pt_part.ToUpper()) ??
|
|
new TA_PART
|
|
{
|
|
PartCode = qadData.xxqad_pt_part.ToUpper(),
|
|
ErpPartCode = qadData.xxqad_pt_part.ToUpper(),
|
|
};
|
|
wmsData.PartDesc1 = qadData.xxqad_pt_desc1;
|
|
wmsData.PartDesc2 = qadData.xxqad_pt_desc2;
|
|
wmsData.ProjectId = qadData.xxqad_pt_group.ToUpper();
|
|
wmsData.Unit = qadData.xxqad_pt_um.ToUpper();
|
|
wmsData.PartGroup = qadData.xxqad_pt_dsgn_grp.ToUpper();
|
|
wmsData.State = qadData.xxqad_pt_status.ToUpper();
|
|
wmsData.Site = ScpCache.Config.QADÓò;
|
|
// wmsData.PartType = qadData.xxqad_pt_part_type.ToUpper() == PartType.M.ToString()
|
|
// ? PartType.M.ToString()
|
|
// : PartType.B.ToString();
|
|
// wmsData.PartKind = qadData.xxqad_pt_promo.ToUpper();
|
|
// wmsData.InspectType = (int)InspectType.È«¼ì;
|
|
// wmsData.SamplePercent = 1;
|
|
wmsDataList.Add(wmsData);
|
|
qadData.xxqad_pt_scmread = ((int)UniApiState.³É¹¦).ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
qadData.xxqad_pt_scmread = ((int)UniApiState.ʧ°Ü).ToString();
|
|
qadData.xxqad_pt_rmks += " SCM:" + ex.Message;
|
|
}
|
|
qadData.xxqad_pt_updateur = ScpCache.Config.SCP̞;
|
|
qadData.xxqad_pt_updatedt = DateTime.Now;
|
|
}
|
|
wdb.TA_PART.AddOrUpdate(p => p.PartCode, wmsDataList.ToArray());
|
|
Console.WriteLine($"¸üРÁã¼þÐÅÏ¢ Êý¾Ý£º{qadDataList.Count}");
|
|
}
|
|
|
|
}
|
|
}
|
|
|