/// <summary>
        /// Обработчик события кода на погрузку
        /// </summary>
        /// <param name="l4MsgInfo">Модель таблицы L4L3Event для обработки кода</param>
        /// <returns>Результат обработки</returns>
        public TCheckResult ShippingMng(TL4MsgInfo l4MsgInfo)
        {
            TCheckResult result      = new TCheckResult();
            TForShipping forShipping = TForShipping.NOShipped;
            L4L3InterfaceServiceGlobalCheck global = new L4L3InterfaceServiceGlobalCheck();

            logger.Error($"ShippingMng - STARTED -> MsgId: {l4MsgInfo.msgCounter}");
            L4L3ShippingRepo    shippingRepo = new L4L3ShippingRepo();
            List <L4L3Shipping> ship         = shippingRepo.GetListData(l4MsgInfo);

            if (ship == null)
            {
                result.isOK = false;
                result.data = $"В таблице {l4l3unterfacetable} поле {l4MsgInfo.msgCounter} запись не найдена";
                global.SetMsgResult(l4MsgInfo, L4L3InterfaceServiceConst.MSG_STATUS_ERROR, result.data);
                return(result);
            }
            L4L3ServiceCheckShipping checkship = new L4L3ServiceCheckShipping();

            result = checkship.ShippingCheck(ship, l4MsgInfo);
            foreach (L4L3Shipping sship in ship)
            {
                if (result.isOK)
                {
                    if (l4MsgInfo.opCode == L4L3InterfaceServiceConst.OP_CODE_NEW && sship.bolStatus == L4L3InterfaceServiceConst.BOL_NOT_SENT)
                    {
                        CreateBolIfNotEx(sship.bolId);
                        forShipping = TForShipping.NOShipped;
                    }
                    else if (l4MsgInfo.opCode == L4L3InterfaceServiceConst.OP_CODE_UPD && sship.bolStatus == L4L3InterfaceServiceConst.BOL_NOT_SENT)
                    {
                        forShipping = TForShipping.NOShipped;
                    }
                    else if (l4MsgInfo.opCode == L4L3InterfaceServiceConst.OP_CODE_UPD && sship.bolStatus == L4L3InterfaceServiceConst.BOL_SENT)
                    {
                        forShipping = TForShipping.YESShipped;
                    }
                    else if (l4MsgInfo.opCode == L4L3InterfaceServiceConst.OP_CODE_NEW && sship.bolStatus == L4L3InterfaceServiceConst.BOL_SENT)
                    {
                        forShipping = TForShipping.YESShipped;
                    }
                    else if (l4MsgInfo.opCode == L4L3InterfaceServiceConst.OP_CODE_DEL && sship.bolStatus == L4L3InterfaceServiceConst.BOL_SENT)
                    {
                        forShipping = TForShipping.YESShipped;
                    }
                    result = LocalSetPiece(l4MsgInfo, sship, TPieceAction.paAssign, forShipping);
                }
            }
            if (!result.isOK)
            {
                global.SetMsgResult(l4MsgInfo, L4L3InterfaceServiceConst.MSG_STATUS_ERROR, result.data);
                logger.Error(result.data);
            }
            else
            {
                global.SetMsgResult(l4MsgInfo, L4L3InterfaceServiceConst.MSG_STATUS_SUCCESS, result.data);
            }
            logger.Error($"ShippingMng - STOPPED -> MsgId:{l4MsgInfo.msgCounter}");
            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Обработчик кода перемещения материала
        /// </summary>
        /// <param name="l4MsgInfo">Модель L4L3Event для обработки кода</param>
        /// <returns>Результат обработки</returns>
        public TCheckResult L4L3MaterialMovement(TL4MsgInfo l4MsgInfo)
        {
            L4L3InterfaceServiceGlobalCheck global = new L4L3InterfaceServiceGlobalCheck();
            TCheckResult            checkResult    = global.InitResultWithFalse();
            List <L4L3RmAndMatCat>  l4L3Rms        = new List <L4L3RmAndMatCat>();
            OracleDynamicParameters odp            = new OracleDynamicParameters();
            string str = "select  l4.material_id as sap_code, " +
                         "M.MATERIAL_CODE," +
                         "m.material_name," +
                         "m.actual_qty l3_qty," +
                         "l4.material_amount*1000 as material_amount," +
                         "case" +
                         "when (m.actual_qty < l4.material_amount*1000) then" +
                         "(-1)*(m.actual_qty - l4.material_amount*1000)" +
                         "else" +
                         "(m.actual_qty - l4.material_amount*10000)" +
                         "end as movement_qty" +
                         "l4.movement_datetime" +
                         "from    L4_L3_RAW_MATERIAL l4," +
                         "mat_catalog m " +
                         "where trim(L4.MATERIAL_ID) = trim(M.MATERIAL_CODE_L4) " +
                         "and l4.msg_counter = :Counter";

            odp.Add("Counter", l4MsgInfo.msgCounter);
            using (OracleConnection connection = GetConnection())
            {
                l4L3Rms = connection.Query <L4L3RmAndMatCat>(str, odp).AsList();
            }
            if (l4L3Rms.Count == 0)
            {
                l4MsgInfo.msgReport.status = L4L3InterfaceServiceConst.MSG_STATUS_ERROR;
                l4MsgInfo.msgReport.remark = "Код материала не найдена в БД МЕТ2000";
            }
            else
            {
                foreach (L4L3RmAndMatCat l4L3Rm in l4L3Rms)
                {
                    if (InsertNewMovement(l4L3Rm.materialCode, "MT_RECONCILIATION", l4L3Rm.movementdatetime, l4L3Rm.movmetnqty, 1123, 0, "Корректировка остатков от SAP"))
                    {
                        check.SetMsgResult(l4MsgInfo, L4L3InterfaceServiceConst.MSG_STATUS_SUCCESS, "Материал перемещен");
                    }
                    else
                    {
                        check.SetMsgResult(l4MsgInfo, L4L3InterfaceServiceConst.MSG_STATUS_ERROR, "Ошибка добавления материала");
                    }
                }
            }
            return(checkResult);
        }