/// <summary> /// Создание нового заказа (Требуется дальнейшая реализация) /// </summary> /// <param name="QryData">Модель таблицы L4_L3_SO_HEADER для обработки</param> /// <param name="l4MsgInfo">Модель таблицы L4L3Event для обработки кода</param> public void CreateNewOrder(L4L3SoHeader QryData, TL4MsgInfo l4MsgInfo) { tsoHeader = new TSoHeader(); string sNumeration = auxConstant.GetStringAuxConstant("SO_NUMERATION"); TL4EngineInterfaceMngRepo eimOrderEntry = new TL4EngineInterfaceMngRepo(QryData, l4MsgInfo); try { Int32.TryParse(eimOrderEntry.GetCreateUserId(), out int iUserId); } catch { eimOrderEntry.NotifyErrorMessage("Ошибка при возвращении ID пользователя"); } int iShipToCode = ManageShipTo(l4MsgInfo, eimOrderEntry); if (iShipToCode >= 0) { tsoHeader = tSo.Create(QryData, l4MsgInfo, iShipToCode, true); eimOrderEntry.l4MsgInfo.msgReport = new TMessageResult(); eimOrderEntry.l4MsgInfo.msgReport.status = L4L3InterfaceServiceConst.MSG_STATUS_SUCCESS; if (eimOrderEntry.l4MsgInfo.msgReport.status == L4L3InterfaceServiceConst.MSG_STATUS_SUCCESS) { logger.Info("Заказ создан"); } } }
/// <summary> /// Конструктор создания модели Customer_catalog_credit /// </summary> /// <param name="interfaceMng"></param> public CCreditEngine(TL4EngineInterfaceMngRepo interfaceMng) { this.catCredit = new CustomerCatCredit(); }
/// <summary> /// Создание и заполнение модели таблицы SO_HEADER /// </summary> /// <param name="l4l3soheader">Модель таблицы L4L3SoHeader для обработки</param> /// <param name="l4MsgInfo">Модель таблицы L4L3Event для обработки содержимого кода</param> /// <param name="iShipToCode">Код отгрузки</param> /// <param name="bVerifyData">Пометка об актуальности данных</param> /// <param name="bisUpdate">Пометка об обновлении данных</param> /// <returns></returns> public TSoHeader Create(L4L3SoHeader l4l3soheader, TL4MsgInfo l4MsgInfo, int iShipToCode, bool bVerifyData, bool bisUpdate = false) { TL4EngineInterfaceMngRepo mngRepo = new TL4EngineInterfaceMngRepo(l4MsgInfo); bool bIsValid = true; try { soHeader.m_iLinesCount = 0; if (bIsValid) { soHeader.m_iCustSoldDescrID = CheckValue(bIsValid, l4MsgInfo); } if (!ExistCustomer(soHeader.m_iCustSoldDescrID.ToString())) { mngRepo.NotifyErrorMessage($"Заказчик САП {l4l3soheader.customerId} неверен или срок валидности закончился"); bIsValid = false; } if (bIsValid) { if (oneToSeveralOrderFromSap == 'Y') { soHeader.m_sSoDescrID = l4l3soheader.soID + "_" + m_strSO_Line_Id_MET; } else { soHeader.m_sSoDescrID = l4l3soheader.soID; } if (l4l3soheader.customerPo.Length > 0) { soHeader.m_strCustPO = l4l3soheader.customerPo; } else { mngRepo.NotifyErrorMessage("'CUSTOMER_PO' поле не может быть пустым"); bIsValid = false; } if (l4l3soheader.customerPoDate.ToString().Length > 0) { soHeader.m_dCustPODate = l4l3soheader.customerPoDate; } else { soHeader.m_dCustPODate = l4l3soheader.insertDate; } if (l4l3soheader.inquiryRefNumber.Length > 0) { soHeader.m_strInquirtNumber = l4l3soheader.inquiryRefNumber; } else { soHeader.m_strInquirtNumber = soHeader.m_strCustPO; } if (l4l3soheader.inquiryRefDate.ToString().Length > 0) { soHeader.m_dInquiryDate = l4l3soheader.inquiryRefDate; } else { soHeader.m_dInquiryDate = soHeader.m_dCustPODate; } } if (bIsValid) { soHeader.m_iInsertUser = mngRepo.GetCreateUserId(); if (soHeader.m_iInsertUser == "") { bIsValid = false; } } if (bIsValid) { if (l4l3soheader.insertDate.ToString().Length > 0) { soHeader.m_dInsertDate = l4l3soheader.insertDate; } } if (bIsValid) { soHeader.m_iUpdateUser = mngRepo.GetModUserId(); if (soHeader.m_iUpdateUser == "") { bIsValid = false; } } if (bIsValid) { if (l4MsgInfo.opCode > 0) { soHeader.m_iOpCode = l4MsgInfo.opCode; } } if (bIsValid) { switch (som.DecodeContractType(soHeader.m_sSoDescrID, l4l3soheader.customerId.ToString())) { case TContractType.coInternal: if (som.IsCustomerInternal(soHeader.m_iCustSoldDescrID)) { mngRepo.NotifyErrorMessage("Заказ обозначен как внутренний, но имеет внешнего заказчика"); bIsValid = false; } break; } } if (bIsValid) { List <LinesCom> lines = new List <LinesCom>(); string str = "SELECT L4SOL.* " + "L4EVE.MSG_STATUS " + "L4EVE.MSG_REMARK, " + "L4SOL.SO_LINE_ID/10 AS SO_LINE_MET, " + "PTC.PRODUCT_TYPE AS PROD_MET, " + "L4EVE.OP_CODE, " + "L4SOL.LINE_NOTE " + "FROM L4_L3_SO_LINE L4SOL, " + "PRODUCT_TYPE_CATALOGUE PTC " + "L4_L3_EVENT L4EVE " + $"WHERE L4SOL.MSG_COUNTER = :{l4MsgInfo.msgCounter}" + "AND L4SOL.MSG_COUNTER = L4EVE.MSG_COUNTER " + "AND ptc.SAP_CODE = l4sol.PRODUCT_TYPE"; if (oneToSeveralOrderFromSap == 'Y') { str += $"AND L4SOL.SO_LINE_ID = '{m_strSO_Line_Id_Params}'"; } str += "ORDER BY L4SOL.SO_LINE_ID "; using (OracleConnection connection = GetConnection()) { lines = connection.Query <LinesCom>(str, null).AsList(); } foreach (LinesCom line in lines) { templine = lineRepo.Create(line, l4MsgInfo, soHeader.m_iCustSoldDescrID, iShipToCode, bisUpdate); templine.m_strDescription = line.lineNote; if (!bVerifyData) { mngRepo.NotifyErrorMessage($"Ошибка в строке {templine.m_iSoLineID} {templine.m_L4MsgInfoLine.tL4MsgInfo.msgReport.remark}"); templine.m_L4MsgInfoLine.tL4MsgInfo.msgReport.status = L4L3InterfaceServiceConst.MSG_STATUS_ERROR; Add(templine); break; } Add(templine); } } } catch (Exception e) { logger.Error($"Ошибка создания SoHeader: {e.Message}"); } return(soHeader); }
/// <summary> /// Конструктор создания модели Customer_catalog /// </summary> /// <param name="interfaceMng"></param> public CCatalEngine(TL4EngineInterfaceMngRepo interfaceMng) { this.customerCat = new CustomerCat(); }
/// <summary> /// Конструктор создания модели Address_catalogue /// </summary> /// <param name="interfaceMng"></param> public AddressEngine(TL4EngineInterfaceMngRepo interfaceMng) { interf = interfaceMng; this.adressCatalog = new AddresCat(); }
/// <summary> /// Требуется дальнейшая реализация /// </summary> /// <param name="l4MsgInfo">Модель таблицы L4L3Event для обработки кода</param> /// <param name="tL4Engine"></param> /// <returns></returns> public int ManageShipTo(TL4MsgInfo l4MsgInfo, TL4EngineInterfaceMngRepo tL4Engine) { return(1); }
/// <summary> /// Обработчик события для кода заказчиков /// </summary> /// <param name="l4MsgInfo">Модель таблицы L4L3Event для обработки кода</param> /// <returns>Результат обработки</returns> public TCheckResult CustomerMng(TL4MsgInfo l4MsgInfo) { L4L3Customer customer = customerRepo.GetData(l4MsgInfo); TCheckResult checkres = new TCheckResult(); checkres.rejType = 0; TL4EngineInterfaceMngRepo engInterf = new TL4EngineInterfaceMngRepo(customer, l4MsgInfo); AddressEngine addressEngine = new AddressEngine(engInterf); CCatalEngine catalEngine = new CCatalEngine(engInterf); CCreditEngine creditEngine = new CCreditEngine(engInterf); bool res = true; float el4CustomerId; string l4CustomerId = "", customerIdForL4m = "", sAddressIdBillTo = "", l4CreateUserId = "", l4ModUserId = ""; logger.Info("Init 'CustomerMng' function"); l4MsgInfo.msgReport.status = L4L3InterfaceServiceConst.MSG_STATUS_SUCCESS; try { l4CustomerId = customer.customerId.ToString(); el4CustomerId = customer.customerId; l4CreateUserId = engInterf.GetCreateUserId(); customerIdForL4m = l4CustomerId; logger.Info("'CustomerIdForL4':" + customerIdForL4m + "'l4CustomerId':" + l4CustomerId); if (l4MsgInfo.opCode == L4L3InterfaceServiceConst.OP_CODE_DEL) { if (catalEngine.LoadData(l4CustomerId) > 0) { if (catalEngine.IsCustomerDeletable(catalEngine.GetCustomerID())) { catalEngine.DeleteCustomer(catalEngine.GetCustomerID()); } } else { checkres.isOK = engInterf.NotifyErrorMessage($"Заказчик {l4CustomerId} не существует"); logger.Error($"Заказчик {l4CustomerId} не существует"); } } else { customerIdForL4m = engInterf.GetCreateUserId(); if (l4CustomerId == "") { res = false; } l4ModUserId = engInterf.GetModUserId(); if (l4ModUserId == "") { res = false; } if (res) { if (catalEngine.LoadData(l4CustomerId) > 0) { if (addressEngine.LoadData(catalEngine.GetAddressIdCatalog()) != 1) { checkres.isOK = engInterf.NotifyErrorMessage($"Ошибка при обработке заказчика - Фатальная ошибка - поле ADDRESS_ID={catalEngine.GetAddressIdCatalog().ToString() } не найдено"); logger.Error($"Ошибка при обработке заказчика - Фатальная ошибка - поле ADDRESS_ID ={ catalEngine.GetAddressIdCatalog().ToString() } не найдено"); res = false; } if (res) { catalEngine.SetCustomerDescrId(l4CustomerId); } } if (creditEngine.LoadData(catalEngine.GetCustomerID()) > 0) { if (addressEngine.LoadData(creditEngine.GetAddressIdBillTo()) != 1) { try { sAddressIdBillTo = creditEngine.GetAddressIdBillTo().ToString(); } catch { sAddressIdBillTo = ""; } checkres.isOK = engInterf.NotifyErrorMessage($"Ошибка при обработке заказчика - Фатальная ошибка - поле ADDRESS_ID={sAddressIdBillTo} не найдено"); res = false; } } } if (res) { res = FillAddressEngine(customer, addressEngine, l4ModUserId); } logger.Info("'CustomerMng - Load Customer Catalog data'"); if (res) { catalEngine.SetCustomerDescrId(l4CustomerId); catalEngine.SetAddressIdCatalog(addressEngine.GetAddressId().ToString()); catalEngine.SetInternalCustomerFlag(customer.internalCustomerFlag); catalEngine.SetInquiryValidityDays(30); catalEngine.SetCustomerCurrencyCode(customer.customerCurrencyCode); catalEngine.SetClassificationType(CheckClassificationType(customer.customerClassificationType)); catalEngine.SetWeightUnit("<NULL>"); if (customer.customerName.Length > 80) { catalEngine.SetCustomerShortName(customer.customerName.Substring(0, 80)); } else { catalEngine.SetCustomerShortName(customer.customerName); } catalEngine.SetCreationUserId(l4CreateUserId); if (customer.inn.Length > 40) { catalEngine.SetInn(customer.inn.Substring(0, 40)); } else { catalEngine.SetInn(customer.inn); } if (customer.kpp.Length > 40) { catalEngine.SetKpp(customer.kpp.Substring(0, 40)); } else { catalEngine.SetKpp(customer.kpp); } if (customer.rwstationCode.Length > 40) { catalEngine.SetRwStationCode(customer.rwstationCode.Substring(0, 40)); } else { catalEngine.SetRwStationCode(customer.rwstationCode); } if (customer.region.Length > 40) { catalEngine.SetRegion(customer.region.Substring(0, 40)); } else { catalEngine.SetRegion(customer.region); } catalEngine.SetLevel4CustomerId(customerIdForL4m); DateTime date = new DateTime(); if (customer.vailityFlag.ToString() == "Y") { if (catalEngine.GetExpirationDate() != date) { catalEngine.SetExpirationDate(date); } } else { if (catalEngine.GetExpirationDate() == date) { catalEngine.SetExpirationDate(DateTime.Now); } } catalEngine.ForceModUserDatetime(l4ModUserId); res = catalEngine.SaveData(); } logger.Info("'CustomerMng - Load Customer Catalog Credit Data'"); if (res) { creditEngine.SetCustomerID(GetCustIDFromDescr(l4CustomerId)); creditEngine.SetAddressIdBillTo(addressEngine.GetAddressId()); creditEngine.SetCreditStatus(1); creditEngine.ForceModUserDatetime(l4ModUserId); creditEngine.SetInvoiceType("Y"); creditEngine.SetDirectPaymnt("Y"); creditEngine.SetCustomerCode(Convert.ToInt32(customer.customerCurrencyCode)); res = creditEngine.SaveData(); } if (!res && l4MsgInfo.msgReport.status == L4L3InterfaceServiceConst.MSG_STATUS_SUCCESS) { engInterf.NotifyErrorMessage("CistomerMng - Unknown fatal error."); checkres.data = "CistomerMng - Unknown fatal error."; checkres.isOK = false; } if (res && l4MsgInfo.msgReport.status == L4L3InterfaceServiceConst.MSG_STATUS_SUCCESS) { checkres.data = "CistomerMng - SUCCESS."; checkres.isOK = true; } } logger.Info("End ''CustomerMng'' function"); return(checkres); } catch { return(checkres); } }
/// <summary> /// Создание и заполнение таблицы SO_LINE /// </summary> /// <param name="line">Модель таблицы</param> /// <param name="l4MsgInfo">Модель таблицы событий для обработки сообщения </param> /// <param name="iCustomerID">ИД заказчика</param> /// <param name="iShipToCode">Код разгрузки</param> /// <param name="lbIsUpdate">Пометка об обновлении</param> /// <returns>Заполненая модель SO_LINE</returns> public TSoLine Create(LinesCom line, TL4MsgInfo l4MsgInfo, int iCustomerID, int iShipToCode, bool lbIsUpdate) { L4L3InterfaceUtility inter = new L4L3InterfaceUtility(); bool bVerifyData = true; int iSysDatePeriodNumID = 0; try { TL4MsgInfoLine m_L4MsgInfoLine = new TL4MsgInfoLine(); m_L4MsgInfoLine.tL4MsgInfo.msgCounter = line.msgCounter; m_L4MsgInfoLine.tL4MsgInfo.msgReport.status = line.msgStatus; m_L4MsgInfoLine.tL4MsgInfo.msgReport.remark = ""; newData.m_iSoLineID = line.soLineMet; TL4EngineInterfaceMngRepo m_eimOELineInterface = new TL4EngineInterfaceMngRepo(m_L4MsgInfoLine.tL4MsgInfo); newData.m_sSoDescrID = line.soId; if (lbIsUpdate) { newData.m_iSoID = inter.GetSoIdFromDescr(newData.m_sSoDescrID); } m_L4MsgInfoLine.sSoDescrIDInfoLine = newData.m_sSoDescrID; switch (som.DecodeContractType(newData.m_sSoDescrID, iCustomerID.ToString())) { case TContractType.coInternal: if (!som.IsCustomerInternal(iCustomerID)) { m_eimOELineInterface.NotifyErrorMessage("Заказ обозначен как внутренний, но имеет внешнего заказчика"); bVerifyData = false; } break; } newData.m_iShipToCode = iShipToCode; if (bVerifyData) { newData.m_iSoTypeCode = CheckValueType(bVerifyData, m_L4MsgInfoLine); } if (newData.m_iSoTypeCode == 2) { newData.m_iSoTypeCode = 4; } if (bVerifyData) { newData.m_iCreditStatus = CheckValueCredit(bVerifyData, m_L4MsgInfoLine); } if (bVerifyData) { newData.m_iOrderLineStatus = -1; if (line.soLineStatus.ToString().Length > 0) { newData.m_iOrderLineStatus = line.soLineStatus; } if (!(newData.m_iOrderLineStatus > 0)) { m_eimOELineInterface.NotifyErrorMessage("Неверный статус строки заказа"); bVerifyData = false; } if (line.dueDeliveryDate.ToString().Length > 0) { newData.m_dDueDelivery = line.dueDeliveryDate; } newData.m_iDeliveryPeriodNumID = som.RetrievePeriodNumID(newData.m_dDueDelivery, 1); if (GetLineStatus(newData.m_iOrderLineStatus) != TLineStatus.IsClosed) { iSysDatePeriodNumID = som.RetrievePeriodNumID(DateTime.Now, 1); } if (bVerifyData) { if (line.productType.Length > 0) { newData.m_strProductCode = CheckValueProductType(bVerifyData, m_L4MsgInfoLine).ToString(); newData.m_strProductCode = ProductTypeCheck(newData.m_strProductCode); } } if (bVerifyData) { newData.m_iInsertUser = m_eimOELineInterface.GetCreateUserId(); if (newData.m_iInsertUser == "") { bVerifyData = false; } } if (bVerifyData) { newData.m_iUpdateUser = m_eimOELineInterface.GetModUserId(); if (newData.m_iUpdateUser == "") { bVerifyData = false; } } if (l4MsgInfo.opCode > 0) { newData.m_iOpCode = l4MsgInfo.opCode; } } if (bVerifyData) { som.LoadAttrb(newData.m_L4MsgInfoLine, newData.m_strProductCode, newData.m_iSoID, newData.m_iSoLineID, attributesOfLine, slArrayofAttributes); } return(newData); } catch (Exception e) { logger.Trace($"TSOLine.Create - Exception - Message:{e.Message}"); return(newData); } }