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.

1613 lines
82 KiB

4 years ago
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;
using System.Text;
using System.Data.Entity.Core;
using System.Text.RegularExpressions;
using CK.SCP.Models.AppBoxEntity;
using System.ComponentModel;
using CK.SCP.Common;
using System.Configuration;
1 year ago
using ChangKeTec.Wms.Controller.Report;
using System.Data;
using ChangKeTec.Wms.Controller.Bill;
using System.Reflection;
using CK.SCP.UniApi.Controller;
using System.Windows.Documents;
using System.Web.UI.MobileControls;
using static ChangKeTec.Wms.Controller.Bill.QmStockController;
using static CK.SCP.UniApi.Controller.PriceController;
using static CK.SCP.UniApi.Controller.Vendercontroller;
using static CK.SCP.UniApi.Controller.vendidpartcontroller;
using static CK.SCP.UniApi.Controller.PoBillNumcontroller;
using static CK.SCP.UniApi.Controller.NetPriceController;
4 years ago
namespace CK.SCP.GrupUniApi.Controller
{
public class TP_TB_PO_PLAN
{
public string Domain { get; set; }
public Nullable<System.DateTime> EndTime { get; set; }
public string PoBillNum { get; set; }
1 year ago
public string Site { get; set; }
4 years ago
public string VendId { get; set; }
public string ProjectId { get; set; }
}
1 year ago
4 years ago
public static class OdbcApiQadController
{
public static void GetNewCtrlList()
{
1 year ago
4 years ago
UniApiEntities idb = EntitiesFactory.CreateUniApiInstance();
idb.Database.CommandTimeout = 60 * 20;
var tableNameList = EnumHelper.EnumToList<QadTableName>();
1 year ago
//DataTable b = QmStockController.GetInvBatchStock();
4 years ago
// var qadCtrlList = idb.xxqad_ctrl.Where(p => p.xxqad_domain == ScpCache.Config.QAD�� && p.xxqad_scm == "0").ToList();
1 year ago
var qadCtrlList = idb.xxerp_MaxbatchNO.ToList();
4 years ago
foreach (var qadCtrl in qadCtrlList)
{
1 year ago
try
4 years ago
{
1 year ago
ScpEntities wdb = EntitiesFactory.CreateScpInstance();
var authdb = EntitiesFactory.CreateAppBoxInstance();
switch (qadCtrl.tablename)
{
case "part": //����
4 years ago
if (GlobalVar.ApiConfig.Qad)
{
1 year ago
// Console.WriteLine($"���� QAD �ӿ����ݣ�{qadCtrl.xxqad_table}:{qadCtrl.xxqad_table_qty}");
UpdateParts(idb, wdb, qadCtrl);
4 years ago
EntitiesFactory.SaveDb(wdb);
EntitiesFactory.SaveDb(authdb);
}
else
continue;
break;
1 year ago
case "price": //�۸�
if (GlobalVar.ApiConfig.Qad۸)
4 years ago
{
1 year ago
// Console.WriteLine($"���� QAD �ӿ����ݣ�{qadCtrl.xxqad_table}:{qadCtrl.xxqad_table_qty}");
UpdatePrice(idb, wdb, qadCtrl);
// qadCtrl.xxqad_scm = ((int)UniApiState.�ɹ�).ToString();
4 years ago
EntitiesFactory.SaveDb(wdb);
EntitiesFactory.SaveDb(authdb);
}
else
continue;
break;
1 year ago
case "Netprice": //����
if (GlobalVar.ApiConfig.Qad)
4 years ago
{
1 year ago
// Console.WriteLine($"���� QAD �ӿ����ݣ�{qadCtrl.xxqad_table}:{qadCtrl.xxqad_table_qty}");
UpdatePrice1(idb, wdb, qadCtrl);
// qadCtrl.xxqad_scm = ((int)UniApiState.�ɹ�).ToString();
4 years ago
EntitiesFactory.SaveDb(wdb);
EntitiesFactory.SaveDb(authdb);
}
else
continue;
break;
1 year ago
case "vendid": //��Ӧ��
if (GlobalVar.ApiConfig.QadӦ)
4 years ago
{
1 year ago
//Console.WriteLine($"���� QAD �ӿ����ݣ�{qadCtrl.xxqad_table}:{qadCtrl.xxqad_table_qty}");
UpdateVender(idb, wdb, authdb, qadCtrl);
qadCtrl.Remark = ((int)UniApiState.ɹ).ToString();
4 years ago
EntitiesFactory.SaveDb(wdb);
EntitiesFactory.SaveDb(authdb);
1 year ago
var qadDataList = wdb.TA_VENDER.Where(p => p.UID > (qadCtrl.MaxdibatchNO - 100)).ToList();
UpdateVenderExtend(idb, wdb, authdb, qadDataList);
EntitiesFactory.SaveDb(authdb);
4 years ago
}
else
continue;
break;
1 year ago
case "vendidpart": //����
if (GlobalVar.ApiConfig.QadӦ)
{
1 year ago
// Console.WriteLine($"���� QAD �ӿ����ݣ�{qadCtrl.xxqad_table}:{qadCtrl.xxqad_table_qty}");
UpdateVendParts(idb, wdb, qadCtrl);
// qadCtrl.xxqad_scm = ((int)UniApiState.�ɹ�).ToString();
EntitiesFactory.SaveDb(wdb);
EntitiesFactory.SaveDb(authdb);
}
else
continue;
break;
4 years ago
1 year ago
case "PoBillNum": //�ɹ�����
if (GlobalVar.ApiConfig.Qadɹ)
{
//Console.WriteLine($"���� QAD �ӿ����ݣ�{qadCtrl.xxqad_table}:{qadCtrl.xxqad_table_qty}");
// UpdatePurchaseOrders(idb, wdb, qadCtrl.xxqad_seq);
UpdatePurchaseOrders(idb, wdb, qadCtrl);
//qadCtrl.xxqad_scm = ((int)UniApiState.�ɹ�).ToString();
EntitiesFactory.SaveDb(wdb);
EntitiesFactory.SaveDb(authdb);
}
else
continue;
4 years ago
break;
1 year ago
4 years ago
}
1 year ago
}
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//����ʵ����֤�쳣
4 years ago
{
1 year ago
var sb = new StringBuilder();
foreach (var error in dbEx.EntityValidationErrors.ToList())
4 years ago
{
1 year ago
error.ValidationErrors.ToList().ForEach(i =>
{
sb.AppendFormat("����{0}���ֶΣ�{1}����Ϣ��{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
});
}
//qadCtrl.xxqad_scm = ((int)UniApiState.ʧ��).ToString();
//qadCtrl.xxqad_rmks += " SCM:" + sb.ToString();
4 years ago
}
1 year ago
catch (OptimisticConcurrencyException ex)//������ͻ�쳣
{
//qadCtrl.xxqad_scm = ((int)UniApiState.ʧ��).ToString();
//qadCtrl.xxqad_rmks += " SCM:" + ex.Message+ex.InnerException.Message;
4 years ago
1 year ago
}
catch (Exception ex)
{
//qadCtrl.xxqad_scm = ((int)UniApiState.ʧ��).ToString();
//qadCtrl.xxqad_rmks += " SCM:" + ex.Message + ex.InnerException.Message;
4 years ago
1 year ago
}
finally
{
EntitiesFactory.SaveDb(idb);
}
4 years ago
}
1 year ago
UpdatePlanToAsk();
}
4 years ago
private static void UpdatePlanToAsk()
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
try
{
var _ls = db.Database.SqlQuery<TP_TB_PO_PLAN>(
"SELECT\n" +
" [Domain]\n" +
" ,[EndTime]\n" +
" ,[PoBillNum]\n" +
" ,[Site]\n" +
" ,[VendId]\n" +
1 year ago
4 years ago
"FROM [V_TB_PO_PLAN]\n" +
"where ISPLAN = 'P' and ASKBillNum is null\n" +
"GROUP BY EndTime, PoBillNum,VendId,[Site],[Domain]"
).ToList();
1 year ago
Console.WriteLine($"����MRP�ӿ����ݣ�" + _ls.Count().ToString());
4 years ago
List<string> _vendList = new List<string>();
var _detail = db.Database.SqlQuery<V_TB_PO_PLAN>("select * from v_tb_po_plan where ISPLAN = 'p' and askbillnum is null").ToList();
1 year ago
var _first = _detail.FirstOrDefault();
4 years ago
foreach (var itm in _ls)
{
TB_ASK _ask = new TB_ASK();
_ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakePLAN_ASKCode();
_ask.VendId = itm.VendId;
_ask.State = (int)AskState.Release;
_ask.PoBillNum = itm.PoBillNum;
_ask.ModType = (int)BillModType.Contract;
_ask.Site = itm.Domain;
_ask.Remark = string.Empty;
1 year ago
4 years ago
_ask.BeginTime = DateTime.Now;
1 year ago
_ask.Buyer = "MRP";
4 years ago
_ask.BuyerPhone = string.Empty;
_ask.ErpBillNum = itm.ProjectId;
_ask.EndTime = itm.EndTime;
_ask.CreateTime = DateTime.Now;
_ask.CreateUser = "MRP";
_ask.GUID = Guid.NewGuid();
_ask.ReceivedPort = string.Empty;
_ask.IsDeleted = false;
db.TB_ASK.Add(_ask);
_vendList.Add(_ask.VendId);
1 year ago
var _askDetail = _detail.Where(p => p.EndTime == itm.EndTime && p.PoBillNum == itm.PoBillNum && p.VendId == itm.VendId && p.Domain == itm.Domain).ToList();
4 years ago
List<long> _lst = new List<long>();
foreach (var detail in _askDetail)
1 year ago
{
4 years ago
TB_ASK_DETAIL _t_ASK_Detail = new TB_ASK_DETAIL();
_t_ASK_Detail.PoLine = detail.PoLine;
_t_ASK_Detail.Currency = string.Empty;
_t_ASK_Detail.AskBillNum = _ask.AskBillNum;
_t_ASK_Detail.PoBillNum = _ask.PoBillNum;
_t_ASK_Detail.PoUnit = detail.PoUnit;
_t_ASK_Detail.CreateTime = DateTime.Now;
_t_ASK_Detail.CreateUser = _ask.CreateUser;
_t_ASK_Detail.PartCode = detail.PartCode;
_t_ASK_Detail.BeginTime = _ask.BeginTime;
_t_ASK_Detail.EndTime = _ask.EndTime;
_t_ASK_Detail.TempQty = 0;
_t_ASK_Detail.AskQty = detail.PlanQty;
_t_ASK_Detail.IsDeleted = false;
_t_ASK_Detail.LocUnit = detail.PoUnit;
_t_ASK_Detail.UnConv = 1;
_t_ASK_Detail.DockCode = string.Empty;
_t_ASK_Detail.State = _ask.State;
_t_ASK_Detail.Price = 0;
_t_ASK_Detail.GUID = Guid.NewGuid();
_t_ASK_Detail.Remark = _ask.Site;
_lst.Add(detail.UID);
db.TB_ASK_DETAIL.Add(_t_ASK_Detail);
}
1 year ago
var _planList = db.TB_PO_PLAN.Where(p => _lst.Contains(p.UID)).ToList();
_planList.ForEach(p =>
{
4 years ago
p.Extend2 = "F";
});
db.TB_PO_PLAN.AddOrUpdate(_planList.ToArray());
EntitiesFactory.SaveDb(db);
}
BackgroundWorker _sendMail = new BackgroundWorker();
1 year ago
_sendMail.DoWork += (sender, e) =>
{
4 years ago
foreach (var itm in _vendList)
{
1 year ago
SendMail(itm, "�¿������ɳɹ�", "��ȥSCPϵͳ�鿴�¿���", _first.Site);
4 years ago
}
};
1 year ago
_sendMail.RunWorkerCompleted += (sender, e) =>
{
4 years ago
Console.WriteLine($"�ʼ��ѷ���!");
};
Console.WriteLine($"����MRP�ӿ����ݣ�" + _ls.Count().ToString());
}
catch (Exception e)
{
Console.WriteLine($"����MRP������{e.Message}");
1 year ago
4 years ago
}
}
}
1 year ago
4 years ago
public static void SendMail(string p_VendId, string p_Content, string p_title, string p_site)
{
try
{
using (AppBoxContext db = EntitiesFactory.CreateAppBoxInstance())
{
StringBuilder _buffer = new StringBuilder();
_buffer.Append("SELECT b.Email ");
_buffer.Append(" FROM VenderUsers AS a INNER JOIN ");
_buffer.Append(" Users AS b ON a.UserId = b.ID INNER JOIN ");
_buffer.Append(" FactoryUsers AS c ON a.UserId = c.UserID INNER JOIN ");
_buffer.Append(" TA_FACTORY AS d ON c.FACTORY_ID = d.ID INNER JOIN ");
_buffer.Append(" Users AS f ON c.UserID = f.ID INNER JOIN ");
_buffer.Append(" RoleUsers AS g ON a.UserId = g.UserID INNER JOIN ");
_buffer.Append(" Roles AS h ON g.RoleID = h.ID ");
_buffer.AppendFormat(" WHERE(h.Name = '��Ӧ��' and a.VenderId='{0}' and d.FactoryId='{1}' ) ", p_VendId, p_site);
var _userList = db.Database.SqlQuery<string>(_buffer.ToString()).ToList();
if (_userList != null && _userList.Count > 0)
{
foreach (var itm in _userList)
{
string mails = "";
mails += itm + ",";
if (mails != "")
{
mails = mails.Substring(0, mails.Length - 1);
}
string mailbody = "";
mailbody += "�𾴵Ĺ�Ӧ��<br>";
mailbody += "���ã�<br><br>";
mailbody += "<b>" + p_Content + "</b> ,�뵽��Ӧ��Эͬ��վ" + ConfigurationManager.AppSettings["ResetPassWord"] + "�򿪲鿴��<br>";
mailbody += "<br><br><br><br>���ڣ�" + DateTime.Now;
MyWebSmtpMail webmail = new MyWebSmtpMail();
webmail.Send(mails, mailbody, p_title);
}
}
}
}
catch (Exception e)
{
LogHelper.Writlog(LogHelper.LogType.Error, typeof(MyWebSmtpMail), "MailManager", e.Message);
}
}
1 year ago
4 years ago
/// <summary>
///�����ջ���
/// </summary>
/// <param name="idb"></param>
/// <param name="wdb"></param>
/// <param name="seq">��ˮ��</param>
/// <param name="billtype">0:�ջ�,1:�˻�</param>
private static void AddReceive(UniApiEntities idb, ScpEntities wdb, string seq, int billtype)
{
string _rec = "SELECT * FROM [xxqad_prh_det] WHERE xxqad_prh_uid IN\n" +
"(\n" +
"SELECT\n" +
" MAX(xxqad_prh_uid)\n" +
" FROM [xxqad_prh_det] where xxqad_prh_seq='{0}' and xxqad_prh_qty_rcvd>=0\n" +
" GROUP BY\n" +
" [xxqad_prh_receiver]\n" +
4 years ago
" ,[xxqad_prh_po_nbr]\n" +
" ,[xxqad_prh_po_line]\n" +
" ,[xxqad_prh_part]\n" +
" ,[xxqad_prh_domain]\n" +
")";
var qadRcvDetailList = idb.Database.SqlQuery<xxqad_prh_det>(string.Format(_rec, seq)).ToList();
var scpRcvList = new List<TB_RECEIVE_QAD>();
var scpRcveDetailList = new List<TB_RECEIVE_DETAIL_QAD>();
//����xxwms_rc_po_nbr�ɹ����ֶ�ȥ��
var qadReceiveNbrList = qadRcvDetailList.Select(p => p.xxqad_prh_receiver.ToUpper()).DistinctBy(p => p).ToList();
4 years ago
int j = 0;
foreach (var qadReceiveNbr in qadReceiveNbrList)
4 years ago
{
1 year ago
4 years ago
//qadRcvDetailListͬһxxqad_prh_receiver���м�¼
var qadDataList = qadRcvDetailList.Where(p => p.xxqad_prh_receiver == qadReceiveNbr).ToList();
4 years ago
if (qadDataList.Count == 0)
{
continue;
}
var firstqadData = qadDataList[0];
var scpRcv = wdb.TB_RECEIVE_QAD.SingleOrDefault(p => p.ErpRecvBillNum != null && p.ErpRecvBillNum == qadReceiveNbr && p.Site == firstqadData.xxqad_prh_domain);
4 years ago
//�ж�0100�������ջ��Զ������Ƿ�Ϊ����
if (scpRcv == null)
{
scpRcv = new TB_RECEIVE_QAD
{
ErpRecvBillNum = qadReceiveNbr,//�ջ�����
4 years ago
State = (int)FormState.,
Remark = "",
CreateTime = firstqadData.xxqad_prh_createdt == null ? DateTime.Now : (DateTime)firstqadData.xxqad_prh_createdt,//��������
CreateUser = firstqadData.xxqad_prh_createur,//�����û�
IsDeleted = false,
GUID = System.Guid.NewGuid(),
1 year ago
BillType = billtype,
Site = firstqadData.xxqad_prh_domain,
SubSite = firstqadData.xxqad_prh_site,
};
4 years ago
}
scpRcv.PoBillNum = firstqadData.xxqad_prh_po_nbr;//�ɹ���
1 year ago
//��������
// scpRcv.Site = firstqadData.xxqad_prh_domain;//�ص�
//scpRcv.SubSite = firstqadData.xxqad_prh_site;
4 years ago
scpRcv.VendId = firstqadData.xxqad_prh_vend;//����������
scpRcv.ShipTime = firstqadData.xxqad_prh_date_ship;//�ջ�����
scpRcv.RecvBillNum = firstqadData.xxqad_prh_psnbr;
4 years ago
if (scpRcvList.Count(p =>
p.ErpRecvBillNum == scpRcv.ErpRecvBillNum &&
4 years ago
p.Site == scpRcv.Site
) == 0)
{
scpRcvList.Add(scpRcv);
}
1 year ago
int i = 0;
scpRcv.Tax = firstqadData.xxqad_prh_taxc;
4 years ago
foreach (var qadData in qadDataList)
{
try
{
var poLineNum = Convert.ToInt32(qadData.xxqad_prh_po_line);
var scpRcvDetail =
wdb.TB_RECEIVE_DETAIL_QAD.FirstOrDefault(
p => p.ErpRecvBillNum == qadReceiveNbr &&
4 years ago
p.PoBillNum == qadData.xxqad_prh_po_nbr &&
p.PoLine == poLineNum &&
p.PartCode == qadData.xxqad_prh_part &&
1 year ago
p.Site == qadData.xxqad_prh_domain
&& p.Qty >= 0
4 years ago
);
if (scpRcvDetail == null)
{
scpRcvDetail = new TB_RECEIVE_DETAIL_QAD
{
ErpRecvBillNum = qadReceiveNbr,
RecvBillNum = qadData.xxqad_prh_psnbr,//�ջ�����
4 years ago
PoBillNum = qadData.xxqad_prh_po_nbr,//�ɹ���
PoLine = poLineNum,//������
PartCode = qadData.xxqad_prh_part,//������
Batch = qadData.xxqad_prh_vend_batch,//����
VendBatch = qadData.xxqad_prh_vend_batch,//��Ӧ������
PoUnit = qadData.xxqad_prh_po_um,//�ɹ���λ
LocUnit = qadData.xxqad_prh_loc_um,//������λ
Qty = qadData.xxqad_prh_qty_rcvd,//�ջ�����
CurAmt = qadData.xxqad_prh_curr_amt != null ? qadData.xxqad_prh_curr_amt.Value : 0,
DockCode = qadData.xxqad_prh_loc,//�ջ���
4 years ago
State = (int)FormState.,// (int)FormState.�ر�,
CreateTime = qadData.xxqad_prh_createdt == null ? DateTime.Now : (DateTime)qadData.xxqad_prh_createdt,//��������
CreateUser = qadData.xxqad_prh_createur,//�����û�
IsDeleted = false,
GUID = System.Guid.NewGuid(),
BillType = billtype,
PurCost = qadData.xxqad_prh_pur_cost,
StdCost = qadData.xxqad_prh_std_cost != null ? qadData.xxqad_prh_std_cost.Value : 0,
Rate = qadData.xxqad_prh_curr_rate != null ? qadData.xxqad_prh_curr_rate.Value : 1,
Site = qadData.xxqad_prh_domain,
Tax = firstqadData.xxqad_prh_taxc,
1 year ago
SubSite = qadData.xxqad_prh_site,
4 years ago
};
}
scpRcvDetail.RecvBillNum = !string.IsNullOrEmpty(qadData.xxqad_prh_psnbr) ? qadData.xxqad_prh_psnbr : string.Empty;
4 years ago
scpRcvDetail.CurAmt = qadData.xxqad_prh_curr_amt != null ? qadData.xxqad_prh_curr_amt.Value : 0;
scpRcvDetail.PurCost = qadData.xxqad_prh_pur_cost;
scpRcvDetail.StdCost = qadData.xxqad_prh_std_cost != null ? qadData.xxqad_prh_std_cost.Value : 0;
scpRcvDetail.Rate = qadData.xxqad_prh_curr_rate != null ? qadData.xxqad_prh_curr_rate.Value : 1;
//scpRcvDetail.Site = qadData.xxqad_prh_domain;
//scpRcvDetail.SubSite = qadData.xxqad_prh_site;
4 years ago
scpRcvDetail.Tax = firstqadData.xxqad_prh_taxc;
if (scpRcveDetailList.Count(p =>
p.RecvBillNum == scpRcvDetail.RecvBillNum &&
p.ErpRecvBillNum == scpRcvDetail.ErpRecvBillNum &&
p.PoBillNum == scpRcvDetail.PoBillNum &&
p.PoLine == scpRcvDetail.PoLine &&
1 year ago
p.PartCode == scpRcvDetail.PartCode &&
p.Site == scpRcvDetail.Site
4 years ago
) == 0)
{
scpRcveDetailList.Add(scpRcvDetail);
}
i++;
qadData.xxqad_prh_scmread = ((int)UniApiState.ɹ).ToString();
}
catch (Exception ex)
1 year ago
{
4 years ago
qadData.xxqad_prh_scmread = ((int)UniApiState.ʧ).ToString();
1 year ago
qadData.xxqad_prh_rmks += " SCM:" + ex.Message + i.ToString() + "," + j.ToString();
4 years ago
}
qadData.xxqad_prh_updateur = ScpCache.Config.SCPû;
qadData.xxqad_prh_updatedt = DateTime.Now;
}
}
wdb.TB_RECEIVE_QAD.AddOrUpdate(scpRcvList.ToArray());
wdb.TB_RECEIVE_DETAIL_QAD.AddOrUpdate(scpRcveDetailList.ToArray());
Console.WriteLine($"���� �ջ��� ���ݣ�{qadRcvDetailList.Count}");
}
private static void AddReject(UniApiEntities idb, ScpEntities wdb, string seq, int billtype)
{
string _rec = "SELECT * FROM [xxqad_prh_det] WHERE xxqad_prh_uid IN\n" +
"(\n" +
"SELECT\n" +
" MAX(xxqad_prh_uid)\n" +
" FROM [xxqad_prh_det] where xxqad_prh_seq='{0}' and xxqad_prh_qty_rcvd<0 \n" +
" GROUP BY\n" +
" [xxqad_prh_receiver]\n" +
4 years ago
" ,[xxqad_prh_po_nbr]\n" +
" ,[xxqad_prh_po_line]\n" +
" ,[xxqad_prh_part]\n" +
" ,[xxqad_prh_domain]\n" +
")";
var qadRcvDetailList = idb.Database.SqlQuery<xxqad_prh_det>(string.Format(_rec, seq)).ToList();
var scpRcvList = new List<TB_RECEIVE_QAD>();
var scpRcveDetailList = new List<TB_RECEIVE_DETAIL_QAD>();
//����xxwms_rc_po_nbr�ɹ����ֶ�ȥ��
var qadReceiveNbrList = qadRcvDetailList.Select(p => p.xxqad_prh_receiver.ToUpper()).DistinctBy(p => p).ToList();
4 years ago
foreach (var qadReceiveNbr in qadReceiveNbrList)
4 years ago
{
//qadRcvDetailListͬһxxqad_prh_receiver���м�¼
var qadDataList = qadRcvDetailList.Where(p => p.xxqad_prh_receiver == qadReceiveNbr).ToList();
4 years ago
if (qadDataList.Count == 0)
{
continue;
}
var firstqadData = qadDataList[0];
var scpRcv = wdb.TB_RECEIVE_QAD.FirstOrDefault(p => p.ErpRecvBillNum != null && p.ErpRecvBillNum == qadReceiveNbr && p.Site == firstqadData.xxqad_prh_domain);
4 years ago
//�ж�0100�������ջ��Զ������Ƿ�Ϊ����
if (scpRcv == null)
{
scpRcv = new TB_RECEIVE_QAD
{
ErpRecvBillNum = qadReceiveNbr,//�ջ�����
4 years ago
State = (int)FormState.,
Remark = "",
CreateTime = firstqadData.xxqad_prh_createdt == null ? DateTime.Now : (DateTime)firstqadData.xxqad_prh_createdt,//��������
CreateUser = firstqadData.xxqad_prh_createur,//�����û�
IsDeleted = false,
GUID = System.Guid.NewGuid(),
BillType = billtype,
1 year ago
Site = firstqadData.xxqad_prh_domain,
SubSite = firstqadData.xxqad_prh_site,
};
4 years ago
}
scpRcv.PoBillNum = firstqadData.xxqad_prh_po_nbr;//�ɹ��� //��������
//scpRcv.Site = firstqadData.xxqad_prh_domain;//�ص�
//scpRcv.SubSite = firstqadData.xxqad_prh_site;//�ص�
4 years ago
scpRcv.VendId = firstqadData.xxqad_prh_vend;//����������
scpRcv.ShipTime = firstqadData.xxqad_prh_date_ship;//�ջ�����
scpRcv.RecvBillNum = firstqadData.xxqad_prh_psnbr;
4 years ago
scpRcvList.Add(scpRcv);
scpRcv.Tax = firstqadData.xxqad_prh_taxc;
foreach (var qadData in qadDataList)
{
try
{
var poLineNum = Convert.ToInt32(qadData.xxqad_prh_po_line);
var scpRcvDetail =
wdb.TB_RECEIVE_DETAIL_QAD.SingleOrDefault(
p => p.ErpRecvBillNum == qadReceiveNbr &&
4 years ago
p.PoBillNum == qadData.xxqad_prh_po_nbr &&
p.PoLine == poLineNum &&
p.PartCode == qadData.xxqad_prh_part
1 year ago
&& p.Site == qadData.xxqad_prh_domain
4 years ago
);
if (scpRcvDetail == null)
{
scpRcvDetail = new TB_RECEIVE_DETAIL_QAD
{
ErpRecvBillNum = qadReceiveNbr,
RecvBillNum = qadData.xxqad_prh_psnbr,//�ջ�����
4 years ago
PoBillNum = qadData.xxqad_prh_po_nbr,//�ɹ���
PoLine = poLineNum,//������
PartCode = qadData.xxqad_prh_part,//������
Batch = qadData.xxqad_prh_vend_batch,//����
VendBatch = qadData.xxqad_prh_vend_batch,//��Ӧ������
PoUnit = qadData.xxqad_prh_po_um,//�ɹ���λ
LocUnit = qadData.xxqad_prh_loc_um,//������λ
Qty = qadData.xxqad_prh_qty_rcvd,//�ջ�����
CurAmt = qadData.xxqad_prh_curr_amt != null ? qadData.xxqad_prh_curr_amt.Value : 0,
DockCode = qadData.xxqad_prh_loc,//�ջ���
4 years ago
State = (int)FormState.,// (int)FormState.�ر�,
CreateTime = qadData.xxqad_prh_createdt == null ? DateTime.Now : (DateTime)qadData.xxqad_prh_createdt,//��������
CreateUser = qadData.xxqad_prh_createur,//�����û�
IsDeleted = false,
GUID = System.Guid.NewGuid(),
BillType = billtype,
PurCost = qadData.xxqad_prh_pur_cost,
StdCost = qadData.xxqad_prh_std_cost != null ? qadData.xxqad_prh_std_cost.Value : 0,
Rate = qadData.xxqad_prh_curr_rate != null ? qadData.xxqad_prh_curr_rate.Value : 1,
Site = qadData.xxqad_prh_domain,
1 year ago
SubSite = qadData.xxqad_prh_site,
4 years ago
Tax = firstqadData.xxqad_prh_taxc
};
1 year ago
4 years ago
}
scpRcvDetail.RecvBillNum = !string.IsNullOrEmpty(qadData.xxqad_prh_psnbr) ? qadData.xxqad_prh_psnbr : string.Empty;
4 years ago
scpRcvDetail.PurCost = qadData.xxqad_prh_pur_cost;
scpRcvDetail.StdCost = qadData.xxqad_prh_std_cost != null ? qadData.xxqad_prh_std_cost.Value : 0;
scpRcvDetail.Rate = qadData.xxqad_prh_curr_rate != null ? qadData.xxqad_prh_curr_rate.Value : 1;
scpRcvDetail.CurAmt = qadData.xxqad_prh_curr_amt != null ? qadData.xxqad_prh_curr_amt.Value : 0;
//scpRcvDetail.Site = qadData.xxqad_prh_domain;
//scpRcvDetail.SubSite = qadData.xxqad_prh_domain;
4 years ago
scpRcveDetailList.Add(scpRcvDetail);
qadData.xxqad_prh_scmread = ((int)UniApiState.ɹ).ToString();
}
catch (Exception ex)
{
qadData.xxqad_prh_scmread = ((int)UniApiState.ʧ).ToString();
qadData.xxqad_prh_rmks += " SCM:" + ex.Message;
}
qadData.xxqad_prh_updateur = ScpCache.Config.SCPû;
qadData.xxqad_prh_updatedt = DateTime.Now;
}
}
wdb.TB_RECEIVE_QAD.AddOrUpdate(scpRcvList.ToArray());
wdb.TB_RECEIVE_DETAIL_QAD.AddOrUpdate(scpRcveDetailList.ToArray());
Console.WriteLine($"���� �˻��� ���ݣ�{qadRcvDetailList.Count}");
4 years ago
}
/// <summary>
/// ���²ɹ�����
/// </summary>
/// <param name="idb"></param>
/// <param name="wdb"></param>
/// <param name="seq"></param>
private static void UpdatePPod(UniApiEntities idb, ScpEntities wdb, string seq)
{
string _sql = "select * from\n" +
"(SELECT [xxqad_ppod_uid]\n" +
" ,[xxqad_ppod_seq]\n" +
" ,[xxqad_ppod_nbr]\n" +
" ,[xxqad_ppod_line]\n" +
" ,case\n" +
" LEN(replace([xxqad_ppod_rev],'-',''))\n" +
" when 8 then replace([xxqad_ppod_rev],'-','')+'000'\n" +
" when 11 then replace([xxqad_ppod_rev],'-','') end as xxqad_ppod_rev\n" +
" ,[xxqad_ppod_site]\n" +
" ,[xxqad_ppod_domain]\n" +
" ,[xxqad_ppod_part]\n" +
" ,[xxqad_ppod_desc]\n" +
" ,[xxqad_ppod_type]\n" +
" ,[xxqad_ppod_wolot]\n" +
" ,[xxqad_ppod_pricum]\n" +
" ,[xxqad_ppod_reccum]\n" +
" ,[xxqad_ppod_qty_ord]\n" +
" ,[xxqad_ppod_qty_std]\n" +
" ,[xxqad_ppod_due_date]\n" +
" ,[xxqad_ppod_loc_um]\n" +
" ,[xxqad_ppod_um]\n" +
" ,[xxqad_ppod_um_conv]\n" +
" ,[xxqad_ppod_vend]\n" +
" ,[xxqad_ppod_buyer]\n" +
" ,[xxqad_ppod_buyer_phone]\n" +
" ,[xxqad_ppod_status]\n" +
" ,[xxqad_ppod_qadread]\n" +
" ,[xxqad_ppod_wmsread]\n" +
" ,[xxqad_ppod_scmread]\n" +
" ,[xxqad_ppod_mesread]\n" +
" ,[xxqad_ppod_rmks]\n" +
" ,[xxqad_ppod_createdt]\n" +
" ,[xxqad_ppod_createur]\n" +
" ,[xxqad_ppod_updatedt]\n" +
" ,[xxqad_ppod_prj]\n" + //��������ע�ʹ���
" ,[xxqad_ppod_plan]\n" + //��������ע�ʹ���
" ,[xxqad_ppod_updateur] from xxqad_ppod_det\n" +
" where xxqad_ppod_seq = '{0}' and xxqad_ppod_scmread = '0'\n" +
" ) as a\n" +
"inner join\n" +
"(\n" +
"SELECT\n" +
" xxqad_ppod_seq\n" +
" ,[xxqad_ppod_nbr]\n" +
" ,[xxqad_ppod_line]\n" +
" ,[xxqad_ppod_domain]\n" +
" ,[xxqad_ppod_part]\n" +
" ,[xxqad_ppod_due_date]\n" +
" ,[xxqad_ppod_vend]\n" +
" ,max(\n" +
" case\n" +
" LEN(replace([xxqad_ppod_rev],'-',''))\n" +
" when 8 then replace([xxqad_ppod_rev],'-','')+'000'\n" +
" when 11 then replace([xxqad_ppod_rev],'-','') end\n" +
" ) as xxqad_ppod_rev\n" +
" FROM [xxqad_ppod_det]\n" +
" where xxqad_ppod_seq = '{0}' and xxqad_ppod_scmread = '0'\n" +
" group by\n" +
" xxqad_ppod_seq\n" +
" ,[xxqad_ppod_nbr]\n" +
" ,[xxqad_ppod_line]\n" +
" ,[xxqad_ppod_domain]\n" +
" ,[xxqad_ppod_part]\n" +
" ,[xxqad_ppod_due_date]\n" +
" ,[xxqad_ppod_vend]) as b\n" +
" on\n" +
" a.xxqad_ppod_seq=b.xxqad_ppod_seq\n" +
" and a.xxqad_ppod_domain=b.xxqad_ppod_domain\n" +
" and a.xxqad_ppod_due_date=b.xxqad_ppod_due_date\n" +
" and a.xxqad_ppod_line=b.xxqad_ppod_line\n" +
" and a.xxqad_ppod_nbr=b.xxqad_ppod_nbr\n" +
" and a.xxqad_ppod_vend=b.xxqad_ppod_vend\n" +
" and a.xxqad_ppod_part=b.xxqad_ppod_part\n" +
" and a.xxqad_ppod_rev=b.xxqad_ppod_rev";
_sql = string.Format(_sql, seq);
1 year ago
var _ppodList = idb.Database.SqlQuery<xxqad_ppod_det>(_sql).ToList();
4 years ago
List<TB_PO_PLAN> _list = new List<TB_PO_PLAN>();
try
{
1 year ago
4 years ago
foreach (var itm in _ppodList)
{
1 year ago
var _plan = wdb.TB_PO_PLAN.Where(p => p.PoBillNum == itm.xxqad_ppod_nbr && p.PartCode == itm.xxqad_ppod_part && p.EndTime == itm.xxqad_ppod_due_date && p.Domain == itm.xxqad_ppod_domain && p.Site == itm.xxqad_ppod_site && p.Version == itm.xxqad_ppod_rev).FirstOrDefault();
if (_plan != null)
4 years ago
{
_plan.PlanQty = itm.xxqad_ppod_qty_ord.Value;
continue;
}
1 year ago
_plan = new TB_PO_PLAN();
4 years ago
_plan.PoBillNum = itm.xxqad_ppod_nbr;
_plan.VendId = itm.xxqad_ppod_vend;
_plan.IsDeleted = false;//����Ա
_plan.CreateTime = itm.xxqad_ppod_createdt == null ? DateTime.Now : itm.xxqad_ppod_createdt.Value;
_plan.CreateUser = itm.xxqad_ppod_createur;
_plan.Domain = itm.xxqad_ppod_domain;
_plan.Site = itm.xxqad_ppod_site;
_plan.PlanType = (int)PoPlanType.New;
_plan.ErpBillNum = itm.xxqad_ppod_nbr;
_plan.BeginTime = itm.xxqad_ppod_createdt == null ? DateTime.Now : itm.xxqad_ppod_createdt.Value;
_plan.EndTime = itm.xxqad_ppod_due_date;
_plan.Buyer = itm.xxqad_ppod_buyer;
_plan.BuyerPhone = itm.xxqad_ppod_buyer_phone;
_plan.PoLine = itm.xxqad_ppod_line;
_plan.PoUnit = itm.xxqad_ppod_um;
_plan.CreateTime = itm.xxqad_ppod_createdt == null ? DateTime.Now : itm.xxqad_ppod_createdt.Value;
_plan.CreateUser = itm.xxqad_ppod_createur;
_plan.PartCode = itm.xxqad_ppod_part;
_plan.EndTime = itm.xxqad_ppod_due_date;
_plan.PlanQty = itm.xxqad_ppod_qty_ord.Value;
_plan.IsDeleted = false;
_plan.LocUnit = itm.xxqad_ppod_um;
_plan.UnConv = itm.xxqad_ppod_um_conv;
_plan.State = (int)AskState.New;
_plan.GUID = Guid.NewGuid();
_plan.Version = itm.xxqad_ppod_rev;
_plan.Extend1 = itm.xxqad_ppod_prj;
_plan.Extend2 = itm.xxqad_ppod_plan;
_list.Add(_plan);
}
List<TB_PO_PLAN> _ls = new List<TB_PO_PLAN>();
foreach (var itm in _list)
{
1 year ago
var _count = _ls.Count(p => p.PoBillNum == itm.PoBillNum && p.PartCode == itm.PartCode && p.EndTime == itm.EndTime && p.Domain == p.Domain && p.Site == itm.Site && p.Version == itm.Version);
4 years ago
if (_count == 0)
{
_ls.Add(itm);
}
}
wdb.TB_PO_PLAN.AddOrUpdate(_ls.ToArray());
}
catch (Exception e)
{
throw e;
}
1 year ago
Console.WriteLine($"���¿������ݣ�{_ppodList.Count}");
4 years ago
}
/// <summary>
/// ���²ɹ�����
/// </summary>
/// <param name="idb"></param>
/// <param name="wdb"></param>
/// <param name="seq"></param>
1 year ago
private static void UpdatePurchaseOrders(UniApiEntities idb, ScpEntities wdb, xxerp_MaxbatchNO item)
{
try
4 years ago
{
1 year ago
var max = idb.xxDiMaxes_Po.OrderByDescending(r => r.Di_Batchno).FirstOrDefault();
int a = max.Di_Batchno;
var FATCTORY = wdb.TB_FACTORY.FirstOrDefault();
DataTable b = PoBillNumcontroller.GetInvBatchStock(a, FATCTORY.FactoryId);
List<PURStockBill> list = ChangKeTec.Utils.ListHelper.DataTableToList<PURStockBill>(b);
var wmsPoList = new List<TB_PO>();
var wmsPoDetailList = new List<TB_PO_DETAIL>();
var wmsAskList = new List<TB_ASK>();
var wmsAskDetailList = new List<TB_ASK_DETAIL>();
var xxMaxbath = new List<xxDiMaxes_Po>();
var Dlist = list.Where(p=>p.ctype=="D");
var Ilist = list.Where(p => p.ctype != "D");
var _li = Dlist.GroupBy(p=>p.purDocNO);
foreach (var _lii in _li)
4 years ago
{
1 year ago
var _liii = _lii.ToList();
var _entity = _liii.First();
var _askdetail = wdb.TB_ASK_DETAIL.Count(p => p.PoBillNum == _entity.purDocNO && p.State > -1);
if(_askdetail== _liii.Count())
{
var ask = wdb.TB_ASK.FirstOrDefault(p=>p.PoBillNum==_entity.purDocNO);
ask.State = -1;
ask.IsDeleted = true;
wmsAskList.Add(ask);
var askdetaill=wdb.TB_ASK_DETAIL.Where(p => p.PoBillNum == _entity.purDocNO).ToList();
askdetaill.ForEach(p =>
{
p.State = -1;
p.IsDeleted = true;
wmsAskDetailList.Add(p);
});
}
else
{
var askdetaill = wdb.TB_ASK_DETAIL.Where(p => p.PoBillNum == _entity.purDocNO).ToList();
askdetaill.ForEach(p =>
{
p.State = -1;
p.IsDeleted = true;
wmsAskDetailList.Add(p);
});
}
4 years ago
}
1 year ago
foreach (var qadPoNbr in Ilist)
{
var qadDataList = wmsPoList.Count(p => p.PoBillNum == qadPoNbr.purDocNO);
var wmsPo1 = wdb.TB_PO.Count(p => p.PoBillNum == qadPoNbr.purDocNO);
if ( qadDataList == 0&& wmsPo1==0)
{
TB_PO wmsPo = new TB_PO
{
PoBillNum = qadPoNbr.purDocNO,//������
ErpBillNum = qadPoNbr.purDocNO,
VendId = qadPoNbr.vendorNO,//��Ӧ�̱���
ModType = 2,
CreateUser = "W21-LIUST",
Site = "W21",//�ص�
State = (int)FormState.,//״̬
CreateTime = qadPoNbr.createdDate == null ? DateTime.Now : (DateTime)qadPoNbr.createdDate,//��������
IsDeleted = false,
GUID = System.Guid.NewGuid(),
BeginTime = qadPoNbr.createdDate == null ? DateTime.Now : (DateTime)qadPoNbr.createdDate,//��������
EndTime = qadPoNbr.itemDeliveryDate,//�ջ�����ʱ��
Buyer = qadPoNbr.CREATEDBY,
BuyerPhone = "17304315968",
};
wmsPoList.Add(wmsPo);
}
4 years ago
1 year ago
var qadAskList = wmsAskList.Count(p => p.PoBillNum == qadPoNbr.purDocNO);
var wmsAs1 = wdb.TB_ASK.Count(p => p.PoBillNum == qadPoNbr.purDocNO);
if ( qadAskList == 0&& wmsAs1==0)
4 years ago
{
1 year ago
int cnt = 1;
String str = "k";
TB_ASK wmsAs = new TB_ASK
4 years ago
{
1 year ago
AskBillNum = str + qadPoNbr.purDocNO.Substring(2, 12),
PoBillNum = qadPoNbr.purDocNO,//������
VendId = qadPoNbr.vendorNO,//��Ӧ�̱���
Site = "W21",
CreateTime = qadPoNbr.createdDate == null ? DateTime.Now : (DateTime)qadPoNbr.createdDate,//��������
CreateUser = "W21-LIUST",//�����û�
GUID = System.Guid.NewGuid(),
ModType = 2,
BeginTime = qadPoNbr.createdDate == null ? DateTime.Now : (DateTime)qadPoNbr.createdDate,//��������
EndTime = qadPoNbr.itemDeliveryDate,//�ջ�����ʱ��
Buyer = qadPoNbr.CREATEDBY,
BuyerPhone = "17304315968",
ErpBillNum = qadPoNbr.purDocNO,//������
SubSite = "W21",
};
if (qadPoNbr.returnsItem =="Y")
{
wmsAs.State = -1;
}
else
{
wmsAs.State = 1;
}
wmsAskList.Add(wmsAs);
4 years ago
1 year ago
}
4 years ago
1 year ago
var qadASKList = wmsAskDetailList.Count(p => p.PoBillNum == qadPoNbr.purDocNO && p.PartCode == qadPoNbr.mtlNO);
var wmsAskDetail1 = wdb.TB_ASK_DETAIL.Count(p => p.PoBillNum == qadPoNbr.purDocNO && p.PartCode == qadPoNbr.mtlNO);
if (qadASKList == 0&& wmsAskDetail1==0)
{
String str = "k";
TB_ASK_DETAIL wmsAskDetail = new TB_ASK_DETAIL
{
AskBillNum = str + qadPoNbr.purDocNO.Substring(2, 12),
PoBillNum = qadPoNbr.purDocNO,//������
PoLine = int.Parse(qadPoNbr.purDocItemNO),
Site = "W21",
CreateTime = qadPoNbr.createdDate == null ? DateTime.Now : (DateTime)qadPoNbr.createdDate,//��������
CreateUser = "W21-LIUST",//�����û�
GUID = System.Guid.NewGuid(),
PartCode = qadPoNbr.mtlNO.ToUpper(),//������-���Ϻ�
BeginTime = qadPoNbr.createdDate == null ? DateTime.Now : (DateTime)qadPoNbr.createdDate,//��������
EndTime = qadPoNbr.itemDeliveryDate,//�ջ�����ʱ��
Price = 0,
AskQty = qadPoNbr.quantity,
DockCode = "YC",
PoUnit = qadPoNbr.baseUnitMeasure,
Currency = qadPoNbr.sizecoL,
};
if (qadPoNbr.returnsItem == "Y")
{
wmsAskDetail.State = -1;
}
else
{
wmsAskDetail.State = 1;
}
wmsAskDetailList.Add(wmsAskDetail);
4 years ago
}
1 year ago
var maxlist1 = new xxDiMaxes_Po
4 years ago
{
1 year ago
Di_Batchno = qadPoNbr.DI_BATCHNO,
};
xxMaxbath.Add(maxlist1);
var qadDataList1 = wmsPoDetailList.Count(p => p.PoBillNum == qadPoNbr.purDocNO && p.PartCode == qadPoNbr.mtlNO);
var wmsPoDetail1 =
wdb.TB_PO_DETAIL.Count(p => p.PoBillNum == qadPoNbr.purDocNO && p.PartCode == qadPoNbr.mtlNO);
if ( qadDataList1 == 0&& wmsPoDetail1==0)
{
TB_PO_DETAIL wmsPoDetail = new TB_PO_DETAIL
{
PoBillNum = qadPoNbr.purDocNO,//������
PoLine = int.Parse(qadPoNbr.purDocItemNO),
PartCode = qadPoNbr.mtlNO.ToUpper(),//������-���Ϻ�
PlanQty = qadPoNbr.quantity,//��������-�ɹ���
BeginTime = qadPoNbr.createdDate == null ? DateTime.Now : (DateTime)qadPoNbr.createdDate,//�ջ���ʼʱ��
EndTime = qadPoNbr.itemDeliveryDate,//�ջ�����ʱ��
PoUnit = qadPoNbr.baseUnitMeasure,//�ɹ���λ
Price = 0,
Site = "W21",//��ע
SubSite = "W21",
CreateTime = qadPoNbr.createdDate == null ? DateTime.Now : (DateTime)qadPoNbr.createdDate,//��������
CreateUser = qadPoNbr.CREATEDBY,//�����û�
//if (wmsPoDetail.BillQty != 0 && wmsPoDetail.BillQty <= wmsPoDetail.ReceivedQty)
// wmsPoDetail.State = (int)FormState.�ر�;
State = (int)FormState.,
IsDeleted = false,
GUID = System.Guid.NewGuid(),
};
wmsPoDetailList.Add(wmsPoDetail);
// }
4 years ago
1 year ago
}
//wmsPo.State = qadDataList.All(p => p.xxqad_pod_status == ((int)FormState.�ر�).ToString())
// ? (int)FormState.�ر�
// : (int)FormState.����;
4 years ago
}
1 year ago
if (wmsPoList.Count == 0)
{
Console.WriteLine("���� ERP�ɹ����� ����:" + "������");
return;
}
item.Remark = ((int)UniApiState.ɹ).ToString();
//item.MaxdibatchNO = item.MaxdibatchNO + list.Count;
idb.xxDiMaxes_Po.AddOrUpdate(xxMaxbath.ToArray());
4 years ago
wdb.TB_PO.AddOrUpdate(wmsPoList.ToArray());
1 year ago
wdb.TB_ASK.AddOrUpdate(wmsAskList.ToArray());
4 years ago
wdb.TB_PO_DETAIL.AddOrUpdate(wmsPoDetailList.ToArray());
1 year ago
wdb.TB_ASK_DETAIL.AddOrUpdate(wmsAskDetailList.ToArray());
Console.WriteLine($"���� �ɹ����� ���ݣ�{list.Count}");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
4 years ago
}
1 year ago
4 years ago
1 year ago
private static void UpdatePurchaseOrders(UniApiEntities idb, ScpEntities wdb, string seq, string p_flag)
4 years ago
{
var _ls = wdb.TB_FACTORY.Select(p => p.FactoryId).ToList();
var wmsPoList = new List<TB_PO>();
var wmsPoDetailList = new List<TB_PO_DETAIL>();
var _askList = new List<TB_ASK>();
var _askDetailList = new List<TB_ASK_DETAIL>();
1 year ago
var qadPoDetailList = idb.xxqad_pod_det.Where(p => p.xxqad_pod_seq == seq && p.xxqad_pod_scmread == "0").ToList();
4 years ago
List<xxqad_pod_det> _lst = new List<xxqad_pod_det>();
foreach (var itm in qadPoDetailList)
{
1 year ago
var _cnt = _lst.Where(p => p.xxqad_pod_nbr == itm.xxqad_pod_nbr && p.xxqad_pod_domain == itm.xxqad_pod_domain).Count();
if (_cnt == 0)
4 years ago
{
_lst.Add(itm);
}
}
foreach (var po in _lst)
{
var firstqadData = po;
1 year ago
var qadDataList = qadPoDetailList.Where(p => p.xxqad_pod_nbr == po.xxqad_pod_nbr && p.xxqad_pod_domain == po.xxqad_pod_domain).ToList();
var wmsPo = wdb.TB_PO.SingleOrDefault(p => p.PoBillNum == po.xxqad_pod_nbr && p.Site == po.xxqad_pod_domain);
4 years ago
if (wmsPo == null)
{
int temp;
wmsPo = new TB_PO
{
PoBillNum = po.xxqad_pod_nbr,//������
ErpBillNum = po.xxqad_pod_prj,//ERP������
VendId = firstqadData.xxqad_pod_vend.ToUpper(),//��Ӧ�̱���
ModType = Int32.TryParse(firstqadData.xxqad_pod_modtype, out temp) ? temp : (int?)null, //��������(1:�ճ̵�,2:��ɢ����)
Contacter = firstqadData.xxqad_pod_attn,//��ϵ��
Site = firstqadData.xxqad_pod_domain,//�ص�
1 year ago
SubSite = firstqadData.xxqad_pod_site,
4 years ago
State = (int)FormState.,//״̬
CreateTime = firstqadData.xxqad_pod_createdt == null ? DateTime.Now : (DateTime)firstqadData.xxqad_pod_createdt,//��������
CreateUser = firstqadData.xxqad_pod_createur,//�����û�
IsDeleted = false,
GUID = System.Guid.NewGuid(),
BeginTime = firstqadData.xxqad_pod_createdt == null ? DateTime.Now : (DateTime)firstqadData.xxqad_pod_createdt,//��������
EndTime = firstqadData.xxqad_pod_due_date//�ջ�����ʱ��
};
wmsPoList.Add(wmsPo);
}
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;//�����û�
wmsPo.State = qadDataList.All(p => p.xxqad_pod_status == ((int)FormState.ر).ToString())
? (int)FormState.ر
: (int)FormState.;
foreach (var qadData in qadDataList)
{
try
{
var lineNum = Convert.ToInt32(qadData.xxqad_pod_line);
var wmsPoDetail =
wdb.TB_PO_DETAIL.SingleOrDefault(
1 year ago
p => p.PoBillNum == qadData.xxqad_pod_nbr && p.PoLine == lineNum && p.Site == qadData.xxqad_pod_domain);
4 years ago
if (wmsPoDetail == null)
{
wmsPoDetail = new TB_PO_DETAIL
{
PoBillNum = qadData.xxqad_pod_nbr,//������
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.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.DockCode = qadData.xxqad_pod_loc;
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 = qadData.xxqad_pod_loc;
wmsPoDetail.State = Convert.ToInt32(qadData.xxqad_pod_status);//״̬
4 years ago
wmsPoDetail.Site = qadData.xxqad_pod_domain;//��ע
wmsPoDetail.SubSite = qadData.xxqad_pod_site;
4 years ago
wmsPoDetail.CreateTime = firstqadData.xxqad_pod_createdt == null ? DateTime.Now : (DateTime)firstqadData.xxqad_pod_createdt;//��������
wmsPoDetail.CreateUser = firstqadData.xxqad_pod_buyer;//�����û�
wmsPoDetail.UpdateTime = firstqadData.xxqad_pod_updatedt;//��������
wmsPoDetail.UpdateUser = firstqadData.xxqad_pod_updateur;//�����û�
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;
}
1 year ago
if (firstqadData.xxqad_pod_modtype == "2")
4 years ago
{
1 year ago
if (firstqadData.xxqad_pod_domain == "CNH")
4 years ago
{
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
var _first = db.TA_CONFIG.Where(p => p.ParamName == "�Զ����ɿ���" && p.ParamValue == "����").FirstOrDefault();
if (_first != null)
{
try
{
var _task = wdb.TB_ASK.FirstOrDefault(p => p.ErpBillNum == po.xxqad_pod_nbr && p.Site == po.xxqad_pod_domain);
if (_task == null)
{
_task = new TB_ASK()
{
AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCode(),
PoBillNum = po.xxqad_pod_nbr,//������
ErpBillNum = po.xxqad_pod_prj,//ERP������
VendId = firstqadData.xxqad_pod_vend.ToUpper(),//��Ӧ�̱���
Buyer = firstqadData.xxqad_pod_attn,//��ϵ��
Site = firstqadData.xxqad_pod_domain,//�ص�
1 year ago
SubSite = firstqadData.xxqad_pod_site,
4 years ago
State = (int)AskState.New,//״̬
CreateTime = firstqadData.xxqad_pod_createdt == null ? DateTime.Now : (DateTime)firstqadData.xxqad_pod_createdt,//��������
CreateUser = firstqadData.xxqad_pod_buyer,//�����û�
IsDeleted = false,
GUID = System.Guid.NewGuid(),
BeginTime = firstqadData.xxqad_pod_createdt == null ? DateTime.Now : (DateTime)firstqadData.xxqad_pod_createdt,//��������
EndTime = firstqadData.xxqad_pod_due_date,//�ջ�����ʱ��
ModType = (int)BillModType.Non_Contract,
};
_askList.Add(_task);
}
if (_task.State == 0)
{
_task.Buyer = firstqadData.xxqad_pod_buyer;
_task.BuyerPhone = firstqadData.xxqad_pod_buyer_phone;
_task.UpdateTime = firstqadData.xxqad_pod_updatedt;//��������
_task.UpdateUser = firstqadData.xxqad_pod_updateur;//�����û�
_task.State = (int)AskState.New;
}
foreach (var qadData in qadDataList)
{
try
{
var lineNum = Convert.ToInt32(qadData.xxqad_pod_line);
var _taskDetail =
wdb.TB_ASK_DETAIL.SingleOrDefault(
p => p.PoBillNum == qadData.xxqad_pod_nbr && p.PoLine == lineNum && p.Remark == qadData.xxqad_pod_domain);
if (_taskDetail == null)
{
_taskDetail = new TB_ASK_DETAIL
{
AskBillNum = _task.AskBillNum,
PoBillNum = qadData.xxqad_pod_nbr,//������
PoLine = lineNum,//������
IsDeleted = false,
GUID = System.Guid.NewGuid()
};
_askDetailList.Add(_taskDetail);
}
if (_task.State == 0)
{
_taskDetail.PartCode = qadData.xxqad_pod_part.ToUpper();//������-���Ϻ�
_taskDetail.AskQty = qadData.xxqad_pod_qty_ord;//��������-�ɹ���
_taskDetail.BeginTime = firstqadData.xxqad_pod_createdt;//�ջ���ʼʱ��
_taskDetail.EndTime = qadData.xxqad_pod_due_date;//�ջ�����ʱ��
_taskDetail.PoUnit = qadData.xxqad_pod_um;//�ɹ���λ
_taskDetail.LocUnit = qadData.xxqad_pod_loc_um.ToUpper();//�洢��λ
_taskDetail.DockCode = qadData.xxqad_pod_loc;
_taskDetail.Price = qadData.xxqad_pod_price;
_taskDetail.Currency = qadData.xxqad_pod_curr;//����
_taskDetail.PackQty = qadData.xxqad_pod_qty_std;//��������
_taskDetail.UnConv = qadData.xxqad_pod_um_conv;//ת����
_taskDetail.DockCode = qadData.xxqad_pod_loc;
_taskDetail.State = Convert.ToInt32(qadData.xxqad_pod_status);//״̬
4 years ago
_taskDetail.SubSite = qadData.xxqad_pod_site;//��ע
_taskDetail.Site = qadData.xxqad_pod_domain;
4 years ago
_taskDetail.CreateTime = firstqadData.xxqad_pod_createdt == null ? DateTime.Now : (DateTime)firstqadData.xxqad_pod_createdt;//��������
_taskDetail.CreateUser = firstqadData.xxqad_pod_buyer;//�����û�
_taskDetail.UpdateTime = firstqadData.xxqad_pod_updatedt;//��������
_taskDetail.UpdateUser = firstqadData.xxqad_pod_updateur;//�����û�
_taskDetail.State = _task.State;
}
}
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;
}
db.TB_ASK.AddOrUpdate(_askList.ToArray());
db.TB_ASK_DETAIL.AddOrUpdate(_askDetailList.ToArray());
if (db.SaveChanges() != 1)
{ }
}
catch (Exception e)
{
Console.WriteLine($"���´�����{e.Message}");
}
}
}
}
1 year ago
4 years ago
}
}
wdb.TB_PO.AddOrUpdate(wmsPoList.ToArray());
wdb.TB_PO_DETAIL.AddOrUpdate(wmsPoDetailList.ToArray());
Console.WriteLine($"���� �ɹ����� ���ݣ�{qadPoDetailList.Count}");
}
/// <summary>
1 year ago
/// ���¾���
/// </summary>
/// <param name="idb"></param>
/// <param name="wdb"></param>
/// <param name="seq"></param>
private static void UpdatePrice1(UniApiEntities idb, ScpEntities scpdb, xxerp_MaxbatchNO item)
{
var max = idb.xxDiMaxes.OrderByDescending(r => r.Di_Batchno_NETprice).FirstOrDefault();
int a = max.Di_Batchno_NETprice;
var FATCTORY = scpdb.TB_FACTORY.FirstOrDefault();
DataTable b = NetPriceController.GetInvBatchNetPrice(a, FATCTORY.FactoryId);
//DataTable b = NetPriceController.GetInvBatchNetPrice(item.MaxdibatchNO);
List<PURSubcontractorInfoRecMid> list = ChangKeTec.Utils.ListHelper.DataTableToList<PURSubcontractorInfoRecMid>(b);
var PriceList = new List<TB_NetPrice>();
var xxMaxbath = new List<xxDiMaxes>();
foreach (var itm in list)
{
var maxlist1 = new xxDiMaxes
{
Di_Batchno_part = 0,
Di_Batchno=0,
Di_Batchno_price=0,
Di_Batchno_NETprice = itm.DI_BATCHNO,
};
xxMaxbath.Add(maxlist1);
var _part = scpdb.TB_NetPrice.Count(p => p.PartCode == itm.MTLNO.ToUpper() && p.VendId == itm.vendorNO
&& p.StartTime == itm.validityStartPeriod && p.EndTime == itm.validityEndPeriod);
if (_part == 0)
{
var _price = new TB_NetPrice
{
VendId = itm.vendorNO,
Remarks = itm.purOrg,
PartCode = itm.MTLNO,
Site = itm.plant,
StartTime = itm.validityStartPeriod,
EndTime = itm.validityEndPeriod,
};
_price.Amt = itm.netPrice;
PriceList.Add(_price);
}
}
if (PriceList.Count == 0)
{
Console.WriteLine("���� ���� ����:" + "������");
return;
}
idb.xxDiMaxes.AddOrUpdate(xxMaxbath.ToArray());
item.MaxdibatchNO = item.MaxdibatchNO + list.Count;
item.Remark = ((int) UniApiState.ʧ).ToString();
scpdb.TB_NetPrice.AddOrUpdate(PriceList.ToArray());
Console.WriteLine($"���²ɹ��������ݣ�{PriceList.Count}");
}
/// <summary>
/// ���¼۸�
4 years ago
/// </summary>
/// <param name="idb"></param>
/// <param name="wdb"></param>
/// <param name="seq"></param>
1 year ago
private static void UpdatePrice(UniApiEntities idb, ScpEntities scpdb, xxerp_MaxbatchNO item)
4 years ago
{
1 year ago
var max = idb.xxDiMaxes.OrderByDescending(r => r.Di_Batchno_NETprice).FirstOrDefault();
int a = max.Di_Batchno_price;
var FATCTORY = scpdb.TB_FACTORY.FirstOrDefault();
DataTable b = PriceController.GetInvBatchPrice(a,FATCTORY.FactoryId);
List<PURPriceDealMidTab> list = ChangKeTec.Utils.ListHelper.DataTableToList<PURPriceDealMidTab>(b);
var xxMaxbath = new List<xxDiMaxes>();
4 years ago
var PriceList = new List<TB_PRICE>();
1 year ago
foreach (var itm in list)
4 years ago
{
1 year ago
var maxlist1 = new xxDiMaxes
4 years ago
{
1 year ago
Di_Batchno_part = 0,
Di_Batchno = 0,
Di_Batchno_price = itm.DI_BATCHNO,
Di_Batchno_NETprice =0,
4 years ago
};
1 year ago
xxMaxbath.Add(maxlist1);
var _part = scpdb.TB_PRICE.Count(p => p.PartCode == itm.MTLNO.ToUpper() && p.VendId == itm.vendorNO
&& p.StartTime == itm.validityStartPeriod && p.EndTime == itm.validityEndPeriod);
if (_part == 0)
{
var _price = new TB_PRICE
{
VendId = itm.vendorNO,
Unit = itm.ordUnit,
PartCode = itm.MTLNO,
Site = itm.plant,
StartTime =itm.validityStartPeriod,
EndTime = itm.validityEndPeriod,
};
_price.Amt = decimal.Parse(itm.purchasePrice);
PriceList.Add(_price);
}
}
if (PriceList.Count == 0)
{
Console.WriteLine("���� �ɹ��۸� ����:" + "������");
return;
4 years ago
}
1 year ago
idb.xxDiMaxes.AddOrUpdate(xxMaxbath.ToArray());
item.MaxdibatchNO = item.MaxdibatchNO + list.Count;
//item.Remark = ((int)UniApiState.ʧ��).ToString();
4 years ago
scpdb.TB_PRICE.AddOrUpdate(PriceList.ToArray());
Console.WriteLine($"���²ɹ��۸����ݣ�{PriceList.Count}");
}
/// <summary>
/// ���¹�Ӧ������
/// </summary>
/// <param name="idb"></param>
/// <param name="wdb"></param>
/// <param name="seq"></param>
1 year ago
private static void UpdateVendParts(UniApiEntities idb, ScpEntities wdb,xxerp_MaxbatchNO item)
4 years ago
{
1 year ago
DataTable b = vendidpartcontroller.GetInvBatchStock(item.MaxdibatchNO.ToString());
List<PURVendorpartMid> list = ChangKeTec.Utils.ListHelper.DataTableToList<PURVendorpartMid>(b);
4 years ago
var wmsDataList = new List<TA_VEND_PART>();
1 year ago
foreach (var qadData in list)
4 years ago
{
try
{
1 year ago
if (string.IsNullOrEmpty(qadData.MTLNO))
qadData.MTLNO = qadData.MTLNO;
4 years ago
var wmsData =
wdb.TA_VEND_PART.SingleOrDefault(
1 year ago
p => p.VendId == qadData.VENDORNO.ToUpper()
&& p.PartCode == qadData.MTLNO.ToUpper()
&& p.Site == qadData.PLANT
4 years ago
) ??
new TA_VEND_PART
{
1 year ago
VendId = qadData.VENDORNO.ToUpper(),//��Ӧ�̱���
PartCode = qadData.MTLNO.ToUpper(),//��Ӧ���Ϻ�
//VendPartCode = qadData.xxqad_vp_vend_part.ToUpper(),//��Ӧ�����Ϻ�
//VendPackQty = qadData.xxqad_vp_comment,//��Ӧ�����Ϻ�
4 years ago
//PoUnit = qadData.,//�ɹ���λ
State = 1,//״̬��0��ʧЧ 1:��Ч��
Remark = "",
1 year ago
CreateTime = qadData.created == null ? DateTime.Now : DateTime.Parse(qadData.created),//��������
CreateUser = qadData.createdBy,//�����û�
UpdateTime = DateTime.Now,//��������
//UpdateUser = qadData.xxqad_vp_updateur,//�����û�
//TransportationTime = qadData.memo,
4 years ago
IsDeleted = false,
GUID = new Guid()
1 year ago
};
wmsData.Site = string.IsNullOrEmpty(wmsData.Site) ? qadData.PLANT : wmsData.Site;
// wmsData.VendPartCode = qadData.xxqad_vp_vend_part?.ToUpper() ?? qadData.ToUpper.ToUpper();
//wmsData.VendPackQty = qadData.xxqad_vp_comment;
//wmsData.TransportationTime = qadData.xxqad_vp_vend_lead;
4 years ago
wmsDataList.Add(wmsData);
1 year ago
item.Remark = ((int)UniApiState.ɹ).ToString();
item.MaxdibatchNO = Convert.ToInt32(qadData.DI_BATCHNO);
4 years ago
}
catch (Exception ex)
{
1 year ago
item.Remark = ((int)UniApiState.ʧ).ToString();
//qadData.xxqad_vp_rmks += " SCM:" + ex.Message;
4 years ago
}
1 year ago
//qadData.xxqad_vp_updateur = ScpCache.Config.SCP�û���;
//qadData.xxqad_vp_updatedt = DateTime.Now;
4 years ago
}
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>
1 year ago
private static void UpdateVender(UniApiEntities idb, ScpEntities wdb, AppBoxContext authdb, xxerp_MaxbatchNO item)
4 years ago
{
1 year ago
var max = idb.xxDiMaxes.OrderByDescending(r => r.Di_Batchno).FirstOrDefault();
int a = max.Di_Batchno;
var FATCTORY = wdb.TB_FACTORY.FirstOrDefault();
DataTable b = Vendercontroller.GetInvBatchStock(item.MaxdibatchNO, a,FATCTORY.FactoryId);
//DataTable b = Vendercontroller.GetInvBatchStock(item.MaxdibatchNO);
List<PURVendorMid> list = ChangKeTec.Utils.ListHelper.DataTableToList<PURVendorMid>(b);
4 years ago
var wmsDataList = new List<TA_VENDER>();
1 year ago
var xxMaxbath = new List<xxDiMaxes>();
foreach (var qadData in list)
4 years ago
{
try
{
1 year ago
var maxlist1 = new xxDiMaxes
{
Di_Batchno_NETprice=0,
Di_Batchno_price=0,
Di_Batchno_part = 0,
Di_Batchno = qadData.DI_BATCHNO,
};
xxMaxbath.Add(maxlist1);
var wmsData = wdb.TA_VENDER.FirstOrDefault(p => p.VendId == qadData.VENDORNO.ToUpper() && p.Site == ScpCache.Config.QAD) ??
new TA_VENDER { VendId = qadData.VENDORNO.ToUpper(), VendAbbCode = "0", State = 1 };
wmsData.VendName = string.IsNullOrEmpty(qadData.NAME1) ? qadData.VENDORNO : qadData.NAME1;
wmsData.VendType = qadData.providerType.ToUpper().ToString();
wmsData.Country = qadData.country;
wmsData.Phone = qadData.firstTelNO;
wmsData.Fax = qadData.FAXNUMBER;
wmsData.Site = ScpCache.Config.QAD;
4 years ago
wmsDataList.Add(wmsData);
1 year ago
item.Remark = ((int)UniApiState.ɹ).ToString();
// item.MaxdibatchNO = Convert.ToInt32(qadData.DI_BATCHNO);
var vendname = string.Format("{0}@{1}", qadData.VENDORNO.ToUpper(), ScpCache.Config.QAD);
var _first = authdb.Users.Where(p => p.Name == vendname).FirstOrDefault();
var _vend = authdb.Roles.Where(p => p.Name == "��Ӧ��").FirstOrDefault();
var _factory = authdb.TA_FACTORY.Where(p => p.ErpDomain == ScpCache.Config.QAD).FirstOrDefault();
//_first == null && _vend != null &&
if (_factory != null&& _first==null)
4 years ago
{
User _entity = new User();
_entity.Name = vendname;
1 year ago
_entity.Remark = qadData.COMMUADDRESS.ToUpper();
4 years ago
_entity.Password = PasswordUtil.CreateDbPassword("555555");
_entity.Email = wmsData.VendId + "@163.com";
_entity.Gender = "��";
_entity.Enabled = true;
_entity.Roles = new List<Role>();
1 year ago
authdb.Users.Add(_entity);
4 years ago
Role t = authdb.Set<Role>().Local.Where(x => x.ID == _vend.ID).FirstOrDefault();
if (t == null)
{
1 year ago
t = new Role { ID = _vend.ID };
4 years ago
authdb.Set<Role>().Attach(t);
}
_entity.Roles.Add(t);
_entity.TA_FACTORY = new List<TA_FACTORY>();
TA_FACTORY f = authdb.Set<TA_FACTORY>().Local.Where(x => x.ID == _factory.ID).FirstOrDefault();
if (f == null)
{
1 year ago
f = new TA_FACTORY { ID = _factory.ID };
4 years ago
authdb.Set<TA_FACTORY>().Attach(f);
}
_entity.TA_FACTORY.Add(f);
1 year ago
item.Remark = ((int)UniApiState.ɹ).ToString();
4 years ago
1 year ago
//}
}
4 years ago
}
catch (Exception ex)
{
1 year ago
item.Remark = ((int)UniApiState.ʧ).ToString();
4 years ago
}
1 year ago
//qadData.xxqad_vd_updateur = ScpCache.Config.SCP�û���;
//qadData.xxqad_vd_updatedt = DateTime.Now;
4 years ago
}
if (wmsDataList.Count == 0)
{
1 year ago
Console.WriteLine("���� ��Ӧ�� ����:" + "������");
4 years ago
return;
}
1 year ago
wdb.TA_VENDER.AddOrUpdate(p => new { p.VendId, p.Site }, wmsDataList.ToArray());
idb.xxDiMaxes.AddOrUpdate(xxMaxbath.ToArray());
item.MaxdibatchNO = item.MaxdibatchNO +list.Count;
Console.WriteLine($"���� ��Ӧ�� ���ݣ�{list.Count}");
4 years ago
}
1 year ago
public static DataTable GetInvBatchStock()
{
string Sql = $"Select * form MMRSendMtlData";
var dt_Part = DBControllerByOracle.GetDataTable(Sql);
4 years ago
1 year ago
return dt_Part;
}
private static void UpdateVenderExtend(UniApiEntities idb, ScpEntities wdb, AppBoxContext authdb, List<TA_VENDER> qadDataList)
4 years ago
{
1 year ago
var _ls = new List<VenderUsers>();
4 years ago
foreach (var qadData in qadDataList)
{
try
{
1 year ago
var vendname = string.Format("{0}@{1}", qadData.VendId.ToUpper(), ScpCache.Config.QAD);
var _first = authdb.Users.Where(p => p.Name == vendname).FirstOrDefault();
4 years ago
if (_first != null)
{
1 year ago
var _ef = authdb.VenderUsers.FirstOrDefault(p => p.VenderId == qadData.VendId && p.UserId == _first.ID) ?? new VenderUsers()
{
UserId = _first.ID,
VenderId = qadData.VendId.ToUpper()
};
4 years ago
_ls.Add(_ef);
}
1 year ago
4 years ago
}
1 year ago
catch
4 years ago
{
1 year ago
4 years ago
}
1 year ago
4 years ago
}
authdb.VenderUsers.AddOrUpdate(_ls.ToArray());
}
/// <summary>
/// ��������
/// </summary>
/// <param name="idb"></param>
/// <param name="wdb"></param>
/// <param name="seq"></param>
1 year ago
private static void UpdateParts(UniApiEntities idb, ScpEntities wdb, xxerp_MaxbatchNO item )
4 years ago
{
1 year ago
var max = idb.xxDiMaxes.OrderByDescending(r => r.Di_Batchno_part).FirstOrDefault();
int a = max.Di_Batchno_part;
var FATCTORY = wdb.TB_FACTORY.FirstOrDefault();
DataTable b = QmStockController.GetInvBatchStock(item.MaxdibatchNO,a, FATCTORY.FactoryId);
List<MMRSENDMTLDATA> list= ChangKeTec.Utils.ListHelper.DataTableToList<MMRSENDMTLDATA>(b);
var wmsDataList = new List<TA_PART>();
var xxMaxbath = new List<xxDiMaxes>();
foreach (var qadData in list)
4 years ago
{
1 year ago
var maxlist1 = new xxDiMaxes
4 years ago
{
1 year ago
Di_Batchno_NETprice=0,
Di_Batchno_price=0,
Di_Batchno_part = qadData.DI_BATCHNO,
Di_Batchno = 0
};
xxMaxbath.Add(maxlist1);
var wmsData = wdb.TA_PART.SingleOrDefault(p => p.ErpPartCode == qadData.MTLNO.ToString() && p.Site == qadData.plant) ??
4 years ago
new TA_PART
{
1 year ago
PartCode = qadData.MTLNO.ToString(),
ErpPartCode = qadData.MTLNO.ToString(),
};
wmsData.PartDesc1 = qadData.MTLNODES.ToString();
wmsData.PartDesc2 = qadData.sizes.ToString();
wmsData.ReceivePort = qadData.grossWeight.ToString();
wmsData.PalletSize = qadData.netWeight.ToString();
wmsData.PartGroup = qadData.MTLTYPE.ToString();
wmsData.ProjectId = qadData.MATBRAND;
wmsData.Unit = !string.IsNullOrEmpty(qadData.MEASUREBASEUNIT) ? qadData.MEASUREBASEUNIT.ToUpper() : "EA";
wmsData.Remark = qadData.stdPrice.ToString();
wmsData.ValidityDays = qadData.loadQuantity;
wmsData.State = !string.IsNullOrEmpty(qadData.SpMtlStatus) ? qadData.SpMtlStatus.ToUpper() : "A";
wmsData.Site = qadData.plant;
wmsDataList.Add(wmsData);
}
if (wmsDataList.Count == 0)
{
Console.WriteLine("���� ���� ����:" + "������");
return;
4 years ago
}
1 year ago
item.Remark = ((int)UniApiState.ɹ).ToString();
item.MaxdibatchNO = item.MaxdibatchNO + list.Count;
idb.xxDiMaxes.AddOrUpdate(xxMaxbath.ToArray());
wdb.TA_PART.AddOrUpdate(p => new { p.PartCode, p.Site }, wmsDataList.ToArray());
Console.WriteLine($"���� ������Ϣ ���ݣ�{list.Count}");
4 years ago
}
}
1 year ago
}