Ejemplo n.º 1
0
        private int GetVanOrder(string plant, string sapOrderNo, string prodlLine, bool isNextOrder)
        {
            log.DebugFormat("开始获取整车生产订单,工厂{0},生产订单号{1},生产线{2},重复获取标识{3}", plant, sapOrderNo, prodlLine, isNextOrder);
            ZHEAD[] orderHeadAry = null;
            com.Sconit.Service.SAP.MI_PO_LES.ZITEM_LX[] orderOpAry = null;
            ZITEM_ZJ[] orderBomAry = null;
            try
            {
                MI_PO_LESService soService = new MI_PO_LESService();
                soService.Credentials = base.Credentials;
                soService.Timeout = base.TimeOut;
                soService.Url = ReplaceSAPServiceUrl(soService.Url);

                ZRANGE_AUFNR[] AUFNR = new ZRANGE_AUFNR[1];
                AUFNR[0] = new ZRANGE_AUFNR();
                AUFNR[0].SIGN = "I";
                AUFNR[0].OPTION = "EQ";
                AUFNR[0].LOW = sapOrderNo;

                ZRANGE_DAUAT[] DAUAT = new ZRANGE_DAUAT[1];
                DAUAT[0] = new ZRANGE_DAUAT();
                DAUAT[0].SIGN = "I";
                DAUAT[0].OPTION = "EQ";
                DAUAT[0].LOW = "Z901";
                ZRANGE_DISPO[] DISPO = new ZRANGE_DISPO[0];
                ZRANGE_GSTRS[] GSTRS = new ZRANGE_GSTRS[0];

                string returnMessage = null;
                log.DebugFormat("连接WebService获取整车订单,工厂代码{0},生产订单号{1},生产线{2},重复获取标识{3}", plant, sapOrderNo, prodlLine, isNextOrder);
                orderHeadAry = soService.MI_PO_LES(AUFNR, DAUAT, DISPO, GSTRS, plant, isNextOrder ? "" : "X", prodlLine, out orderOpAry, out orderBomAry, out returnMessage);

                if (!string.IsNullOrWhiteSpace(returnMessage))
                {
                    throw new BusinessException("连接SAP获取整车生产单失败,失败信息:{0}。", returnMessage);
                }
            }
            catch (BusinessException ex)
            {
                log.ErrorFormat("连接SAP获取整车生产单失败,工厂代码{0},生产订单号{1},生产线{2},重复获取标识{3}。", plant, sapOrderNo, prodlLine, isNextOrder);
                log.Error(ex);

                throw ex;
            }
            catch (Exception ex)
            {
                log.ErrorFormat("连接SAP获取整车生产单出现异常,工厂代码{0},生产订单号{1},生产线{2},重复获取标识{3}。", plant, sapOrderNo, prodlLine, isNextOrder);
                log.Error(ex);

                throw new BusinessException("连接SAP获取整车生产单出现异常,异常信息:{0}。", ex.Message);
            }

            if (orderHeadAry == null || orderHeadAry.Length == 0)
            {
                log.ErrorFormat("没有获取到整车生产单,工厂代码{0},生产订单号{1},生产线{2},重复获取标识{3}。", plant, sapOrderNo, prodlLine, isNextOrder);

                throw new BusinessException("没有获取到整车生产单。");
            }
            else if (orderHeadAry.Length > 1)
            {
                //log.ErrorFormat("获取到多个SAP整车生产单,工厂代码{0},生产订单号{1},生产线{2},获取下一台{3}。", plant, sapOrderNo, prodlLine, isNextOrder);

                ////todo
                ////发送短消息

                //throw new BusinessException("获取到多个SAP整车生产单。");
            }
            else
            {
                log.DebugFormat("成功获取整车生产订单{0}", orderHeadAry[0].AUFNR);
            }

            int batchNo = InsertTmpTable(orderHeadAry, orderOpAry, orderBomAry);
            this.genericMgr.UpdateWithNativeQuery("exec USP_Busi_OffsetNegativeBom ?", batchNo);

            return batchNo;
        }
Ejemplo n.º 2
0
        private IList<int> GetProductOrder(string plant, IList<string> sapOrderNoList, IList<string> sapOrderTypeList, DateOption dateOption, DateTime? dateFrom, DateTime? dateTo, IList<string> mrpCtrlList)
        {
            log.DebugFormat("开始获取非整车生产订单,工厂{0}", plant);
            ZHEAD[] orderHeadAry = null;
            com.Sconit.Service.SAP.MI_PO_LES.ZITEM_LX[] orderOpAry = null;
            ZITEM_ZJ[] orderBomAry = null;
            try
            {
                MI_PO_LESService soService = new MI_PO_LESService();
                soService.Credentials = base.Credentials;
                soService.Timeout = base.TimeOut;
                soService.Url = ReplaceSAPServiceUrl(soService.Url);

                #region 生产订单号
                ZRANGE_AUFNR[] AUFNR = new ZRANGE_AUFNR[sapOrderNoList != null ? sapOrderNoList.Count() : 0];
                if (sapOrderNoList != null && sapOrderNoList.Count() > 0)
                {
                    for (int i = 0; i < sapOrderNoList.Count(); i++)
                    {
                        string sapOrderNo = sapOrderNoList[i];
                        AUFNR[i] = new ZRANGE_AUFNR();
                        AUFNR[i].SIGN = "I";
                        AUFNR[i].OPTION = "EQ";
                        AUFNR[i].LOW = sapOrderNo;
                    }
                }
                #endregion

                #region 订单类型
                ZRANGE_DAUAT[] DAUAT = new ZRANGE_DAUAT[sapOrderTypeList != null ? sapOrderTypeList.Count() : 0];
                if (sapOrderTypeList != null && sapOrderTypeList.Count() > 0)
                {
                    for (int i = 0; i < sapOrderTypeList.Count(); i++)
                    {
                        string sapOrderType = sapOrderTypeList[i];
                        DAUAT[i] = new ZRANGE_DAUAT();
                        DAUAT[i].SIGN = "I";
                        DAUAT[i].OPTION = "EQ";
                        DAUAT[i].LOW = sapOrderType;
                    }
                }
                #endregion

                #region 计划开始日期
                ZRANGE_GSTRS[] GSTRS = new ZRANGE_GSTRS[dateFrom.HasValue || dateTo.HasValue ? 1 : 0];

                if (dateFrom.HasValue || dateTo.HasValue)
                {
                    GSTRS[0] = new ZRANGE_GSTRS();
                    GSTRS[0].SIGN = "I";
                    switch (dateOption)
                    {
                        case DateOption.EQ:
                            GSTRS[0].OPTION = "EQ";
                            break;
                        case DateOption.GT:
                            GSTRS[0].OPTION = "GT";
                            break;
                        case DateOption.GE:
                            GSTRS[0].OPTION = "GE";
                            break;
                        case DateOption.LT:
                            GSTRS[0].OPTION = "LT";
                            break;
                        case DateOption.LE:
                            GSTRS[0].OPTION = "LE";
                            break;
                        case DateOption.BT:
                            GSTRS[0].OPTION = "BT";
                            break;
                    }
                    if (dateFrom.HasValue)
                    {
                        GSTRS[0].LOW = dateFrom.Value.ToString("yyyyMMdd");
                    }
                    if (dateTo.HasValue)
                    {
                        GSTRS[0].HIGH = dateTo.Value.ToString("yyyyMMdd");
                    }
                }
                #endregion

                #region MRP控制者
                ZRANGE_DISPO[] DISPO = new ZRANGE_DISPO[mrpCtrlList != null ? mrpCtrlList.Count() : 0];
                if (mrpCtrlList != null && mrpCtrlList.Count() > 0)
                {
                    for (int i = 0; i < mrpCtrlList.Count(); i++)
                    {
                        string mrpCtrl = mrpCtrlList[i];
                        DISPO[i] = new ZRANGE_DISPO();
                        DISPO[i].SIGN = "I";
                        DISPO[i].OPTION = "EQ";
                        DISPO[i].LOW = mrpCtrl;
                    }
                }
                #endregion

                string returnMessage = null;
                log.DebugFormat("连接WebService获取非整车订单,工厂{0}。", plant);
                orderHeadAry = soService.MI_PO_LES(AUFNR, DAUAT, DISPO, GSTRS, plant, "", "", out orderOpAry, out orderBomAry, out returnMessage);

                if (!string.IsNullOrWhiteSpace(returnMessage))
                {
                    log.ErrorFormat("获取非整车生产单失败,失败信息:{0}。", returnMessage);

                    throw new BusinessException(returnMessage);
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.InnerException != null ? (ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : ex.InnerException.Message) : ex.Message;
                log.ErrorFormat("获取非整车生产单出现异常,异常信息:{0}。", errorMessage);
                log.Error(ex);

                throw new BusinessException("获取非整车生产单出现异常,异常信息:{0}。", errorMessage);
            }

            var aufnrCollection = orderHeadAry.Select(oh => oh.AUFNR);
            IList<int> batchNoList = new List<int>();
            foreach (string AUFNR in aufnrCollection)
            {
                int batchNo = 0;
                //如果是试制订单要用batchno来比较,2013-10-14
                ZHEAD[] toInsertedAry = orderHeadAry.Where(oh => oh.AUFNR == AUFNR).ToArray();

                if (toInsertedAry[0].DAUAT == "ZP01" || toInsertedAry[0].DAUAT == "ZP02")
                    batchNo = InsertTmpTable(toInsertedAry, orderOpAry.Where(oo => oo.AUFNR == AUFNR).ToArray(), orderBomAry.Where(ob => ob.BATCH == AUFNR.Substring(2, AUFNR.Length - 2)).ToArray());
                else
                    batchNo = InsertTmpTable(toInsertedAry, orderOpAry.Where(oo => oo.AUFNR == AUFNR).ToArray(), orderBomAry.Where(ob => ob.AUFNR == AUFNR).ToArray());
                batchNoList.Add(batchNo);
            }

            return batchNoList;
        }
Ejemplo n.º 3
0
        private int DoGetCKDProductOrder(string plant, string sapOrderNo, string sapProdLine, string sapOrderType)
        {
            log.DebugFormat("开始获取CKD生产单,工厂{0},产线{1},订单类型{2}。", plant, sapProdLine, sapOrderType);
            ZHEAD[] orderHeadAry = null;
            com.Sconit.Service.SAP.MI_PO_LES.ZITEM_LX[] orderOpAry = null;
            ZITEM_ZJ[] orderBomAry = null;
            try
            {
                MI_PO_LESService soService = new MI_PO_LESService();
                soService.Credentials = base.Credentials;
                soService.Timeout = base.TimeOut;
                soService.Url = ReplaceSAPServiceUrl(soService.Url);

                #region 生产订单号
                ZRANGE_AUFNR[] AUFNR = new ZRANGE_AUFNR[1];
                AUFNR[0] = new ZRANGE_AUFNR();
                AUFNR[0].SIGN = "I";
                AUFNR[0].OPTION = "EQ";
                AUFNR[0].LOW = sapOrderNo;
                #endregion

                #region 订单类型
                ZRANGE_DAUAT[] DAUAT = new ZRANGE_DAUAT[1];
                DAUAT[0] = new ZRANGE_DAUAT();
                DAUAT[0].SIGN = "I";
                DAUAT[0].OPTION = "EQ";
                DAUAT[0].LOW = sapOrderType;
                #endregion

                #region 计划开始日期
                ZRANGE_GSTRS[] GSTRS = new ZRANGE_GSTRS[0];
                #endregion

                #region MRP控制者
                ZRANGE_DISPO[] DISPO = new ZRANGE_DISPO[0];
                #endregion

                string returnMessage = null;
                log.DebugFormat("连接WebService获取CKD生产单,工厂{0},产线{1},订单类型{2}。", plant, sapProdLine, sapOrderType);
                orderHeadAry = soService.MI_PO_LES(AUFNR, DAUAT, DISPO, GSTRS, plant, "", sapProdLine, out orderOpAry, out orderBomAry, out returnMessage);

                if (!string.IsNullOrWhiteSpace(returnMessage))
                {
                    log.ErrorFormat("获取CKD生产单失败,失败信息:{0}。", returnMessage);

                    throw new BusinessException(returnMessage);
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.InnerException != null ? (ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : ex.InnerException.Message) : ex.Message;
                log.ErrorFormat("获取CKD生产单出现异常,异常信息:{0}。", errorMessage);
                log.Error(ex);

                throw new BusinessException("获取CKD生产单出现异常,异常信息:{0}。", errorMessage);
            }

            #region 批量设置生产单头的SAP生产订单号,因为SAP返回生产订单号分为子母订单
            if (orderHeadAry != null && orderHeadAry.Count() > 0)
            {
                foreach (com.Sconit.Service.SAP.MI_PO_LES.ZHEAD orderHead in orderHeadAry)
                {
                    orderHead.AUFNR = sapOrderNo;
                }
            }
            #endregion

            #region 批量设置Op的SAP生产订单号,因为SAP返回生产订单号分为子母订单
            if (orderOpAry != null && orderOpAry.Count() > 0)
            {
                foreach (com.Sconit.Service.SAP.MI_PO_LES.ZITEM_LX orderOp in orderOpAry)
                {
                    orderOp.AUFNR = sapOrderNo;
                }
            }
            #endregion

            #region 批量设置Bom的SAP生产订单号,因为SAP返回生产订单号分为子母订单
            if (orderBomAry != null && orderBomAry.Count() > 0)
            {
                foreach (com.Sconit.Service.SAP.MI_PO_LES.ZITEM_ZJ orderBom in orderBomAry)
                {
                    orderBom.AUFNR = sapOrderNo;
                }
            }
            #endregion

            int batchNo = InsertTmpTable(orderHeadAry, orderOpAry, orderBomAry);
            this.genericMgr.UpdateWithNativeQuery("exec USP_Busi_OffsetNegativeBom ?", batchNo);
            return batchNo;
        }