public void Notify(params object[] args)
 {
     if (args != null && args.Length != 0 && args[0] is EntityEvent)
     {
         BusinessEntity.EntityKey key = ((EntityEvent)args[0]).EntityKey;
         if (!(key == null))
         {
             PrdEndChkBill prdendChkBill = key.GetEntity() as PrdEndChkBill;
             if (PubHelper.SaleOrg2DMS.Contains(Context.LoginOrg.Code))
             {
                 bool flag = PubHelper.IsUsedDMSAPI();
                 if (flag)
                 {
                     if (prdendChkBill.OriginalData.State == CheckStatus.Approving && prdendChkBill.State == CheckStatus.Approved && prdendChkBill.ItemInfo.ItemID.StockCategory.Code == "26")
                     {
                         try
                         {
                             //PI07ImplService service = new PI07ImplService();
                             //DMSAsync_PI07.PI07Client service = new DMSAsync_PI07.PI07Client();
                             //DMSAsync_PI07.PI07Client service = PubExtend.GetPI07Async();
                             // 异步总会有返回结果丢失,改为同步了
                             PI07ImplService service = new PI07ImplService();
                             // service.Url = PubHelper.GetAddress(service.Url);
                             //System.Collections.Generic.List<DMSAsync_PI07.stockDTO> list = new System.Collections.Generic.List<DMSAsync_PI07.stockDTO>();
                             //DMSAsync_PI07.stockDTO dto = new DMSAsync_PI07.stockDTO();
                             System.Collections.Generic.List <stockDTO> list = new System.Collections.Generic.List <stockDTO>();
                             stockDTO dto = new stockDTO();
                             dto.itemMaster = prdendChkBill.ItemInfo.ItemID.Code;
                             if (prdendChkBill.Supplier != null && prdendChkBill.Supplier.Supplier != null)
                             {
                                 dto.supplier = prdendChkBill.Supplier.Supplier.Code;
                             }
                             dto.number = ((prdendChkBill.AdjQtySU == 0) ? 0 : System.Convert.ToInt32(prdendChkBill.AdjQtySU));
                             if (prdendChkBill.Lot != null)
                             {
                                 dto.lot = prdendChkBill.Lot.LotCode;
                             }
                             if (prdendChkBill.Wh != null)
                             {
                                 dto.WH = prdendChkBill.Wh.Code;
                             }
                             dto.actionType = 2;
                             list.Add(dto);
                             //DMSAsync_PI07.stockDTO[] t = service.Do(list.ToArray());
                             stockDTO[] t = service.Do(list.ToArray());
                             // 改为异步调用了
                             //if (t != null && t.Length > 0 && t[0].flag == 0)
                             //{
                             //    throw new BusinessException(t[0].errMsg);
                             //}
                         }
                         catch (System.Exception e)
                         {
                             throw new BusinessException("调用DMS接口错误:" + e.Message);
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
 public void Notify(params object[] args)
 {
     if (args != null && args.Length != 0 && args[0] is EntityEvent)
     {
         BusinessEntity.EntityKey key = ((EntityEvent)args[0]).EntityKey;
         if (!(key == null))
         {
             SalePriceAdjustment SalepriceAdjustment = key.GetEntity() as SalePriceAdjustment;
             if (PubHelper.IsOrg_SalePriceList2DMS(SalepriceAdjustment))
             {
                 bool flag = PubHelper.IsUsedDMSAPI();
                 if (flag)
                 {
                     PI06ImplService service = new PI06ImplService();
                     // service.Url = PubHelper.GetAddress(service.Url);
                     System.Collections.Generic.List <partBaseDto> lines = new System.Collections.Generic.List <partBaseDto>();
                     foreach (SalePriceAdjustLine line in SalepriceAdjustment.SalePriceAdjustLines)
                     {
                         if (
                             //line.SysState == 2
                             line.SysState == UFSoft.UBF.PL.Engine.ObjectState.Inserted
                             //|| (line.SysState == 4
                             || (line.SysState == UFSoft.UBF.PL.Engine.ObjectState.Updated &&
                                 line.NewPrice != line.OriginalData.NewPrice
                                 ))
                         {
                             partBaseDto linedto = new partBaseDto();
                             linedto.suptCode = string.Empty;
                             if (line.ItemInfo != null && line.ItemInfo.ItemIDKey != null)
                             {
                                 linedto.partCode = line.ItemInfo.ItemID.Code;
                                 linedto.partName = line.ItemInfo.ItemID.Name;
                                 if (line.ItemInfo.ItemID.InventoryUOM != null)
                                 {
                                     linedto.unit = line.ItemInfo.ItemID.InventoryUOM.Name;
                                 }
                                 if (line.ItemInfo.ItemID.PurchaseInfo != null)
                                 {
                                     linedto.miniPack = ((line.ItemInfo.ItemID.PurchaseInfo.MinRcvQty > 0) ? System.Convert.ToInt32(line.ItemInfo.ItemID.PurchaseInfo.MinRcvQty) : 1);
                                 }
                             }
                             linedto.salePrice   = float.Parse(line.NewPrice.ToString());
                             linedto.unitPrace   = linedto.salePrice;
                             linedto.isDanger    = "0";
                             linedto.isReturn    = "1";
                             linedto.isSale      = "1";
                             linedto.isFlag      = "1";
                             linedto.isEffective = line.Lapse.ToString();
                             linedto.actionType  = 1;
                             lines.Add(linedto);
                         }
                     }
                     try
                     {
                         if (lines.Count > 0)
                         {
                             partBaseDto d = service.Do(lines.ToArray());
                             if (d != null && d.flag == 0)
                             {
                                 throw new BusinessException(d.errMsg);
                             }
                         }
                     }
                     catch (System.Exception e)
                     {
                         throw new BusinessException("调用DMS接口错误:" + e.Message);
                     }
                 }
             }
         }
     }
 }
        public void Notify(params object[] args)
        {
            if (args != null && args.Length != 0 && args[0] is EntityEvent)
            {
                BusinessEntity.EntityKey key = ((EntityEvent)args[0]).EntityKey;
                if (!(key == null))
                {
                    Voucher voucher = key.GetEntity() as Voucher;
                    //if (voucher.Org.Code == "20")
                    if (PubHelper.IsOrg_Finance2DMS())
                    {
                        bool flag = PubHelper.IsUsedDMSAPI();
                        if (flag)
                        {
                            if ((voucher.OriginalData.VoucherStatus == VoucherStatus.Approving ||
                                 voucher.OriginalData.VoucherStatus == VoucherStatus.Open
                                 ) &&
                                voucher.VoucherStatus == VoucherStatus.Approved)
                            {
                                SI04ImplService service = new SI04ImplService();
                                // service.Url = PubHelper.GetAddress(service.Url);
                                foreach (Entry entry in voucher.Entries)
                                {
                                    //if(entry.AccountKey != null && (entry.Account.Segment1.StartsWith("22410401") || entry.Account.Segment1.StartsWith("1122010303") || entry.Account.Segment1.StartsWith("1122010101") || entry.Account.Segment1.StartsWith("1122010301") || entry.Account.Segment1.StartsWith("2241030801") || entry.Account.Segment1 == "2241030803" || entry.Account.Segment1 == "1122010302" || entry.Account.Segment1 == "2241030901"))

                                    // 这里只处理打款(回款) 业务(即,账号增加;减少 在应收应付里做)

                                    // operaTionType账户类型;现金、三包
                                    // 现金,DJ(定金);三包,CBXY(三包信用)
                                    string dmsOperationType = GetDMSOperationType(entry);

                                    //if (IsUpdateDMS(entry))
                                    if (dmsOperationType.IsNotNullOrWhiteSpace())
                                    {
                                        //if (entry.AccountedCr != 0)
                                        // Cr贷、Dr借
                                        if (entry.AccountedCr != 0
                                            // || entry.AccountedDr != 0
                                            )
                                        {
                                            Customer cust = Customer.Finder.Find(string.Format("Org={0} and Code='{1}'", Context.LoginOrg.ID.ToString(), entry.Account.Segment3), new OqlParam[0]);

                                            if (PubHelper.IsUpdateDMS(cust))
                                            {
                                                try
                                                {
                                                    accountInfoDto dto = new accountInfoDto();
                                                    dto.dealerCode      = entry.Account.Segment3;
                                                    dto.creadNo         = voucher.VoucherDisplayCode;
                                                    dto.invokeTime      = System.DateTime.Now;
                                                    dto.UNineCreateUser = voucher.CreatedBy;
                                                    dto.remark          = entry.Abstracts;
                                                    dto.changeType      = ((entry.AccountedCr > 0) ? 1 : 0);
                                                    // operaTionType账户类型;现金、三包
                                                    // 现金,DJ(定金);三包,SBXY(三包信用)
                                                    //if (entry.Account.Segment1.StartsWith("22410401") || entry.Account.Segment1 == "1122010302")
                                                    //{
                                                    //    dto.operaTionType = "DJ";
                                                    //}
                                                    //else if (entry.Account.Segment1.StartsWith("1122010101"))
                                                    //{
                                                    //    dto.operaTionType = "FCK";
                                                    //}
                                                    //else if (entry.Account.Segment1 == "1122010301")
                                                    //{
                                                    //    dto.operaTionType = "CBXY";
                                                    //}
                                                    //else if (entry.Account.Segment1 == "2241030801" || entry.Account.Segment1 == "2241030803")
                                                    //{
                                                    //    dto.operaTionType = "BZJ";
                                                    //}
                                                    //else if (entry.Account.Segment1 == "12210203")
                                                    //{
                                                    //    dto.operaTionType = "SBXY";
                                                    //}
                                                    //else
                                                    //{
                                                    //    dto.operaTionType = "FL";
                                                    //}
                                                    dto.operaTionType = dmsOperationType;

                                                    dto.amount = double.Parse(System.Math.Abs(entry.AccountedCr).ToString());

                                                    if (Context.LoginOrg.Code == PubHelper.Const_OrgCode_Electric)
                                                    {
                                                        // 电动车只有服务站
                                                        dto.customerType = "101006";
                                                    }
                                                    else
                                                    {
                                                        if (cust != null && cust.CustomerCategoryKey != null)
                                                        {
                                                            dto.customerType = cust.CustomerCategory.Code;
                                                        }
                                                    }
                                                    ILogger logger = LoggerManager.GetLogger(typeof(Voucher));
                                                    logger.Info(string.Format("审核 dealerCode={0},creadNo={1},invokeTime={2},UNineCreateUser={3},remark={4},changeType={5},operaTionType={6},amount={7},customerType={8}", new object[]
                                                    {
                                                        dto.dealerCode,
                                                        dto.creadNo,
                                                        dto.invokeTime,
                                                        dto.UNineCreateUser,
                                                        dto.remark,
                                                        dto.changeType,
                                                        dto.operaTionType,
                                                        dto.amount.ToString(),
                                                        dto.customerType
                                                    }), new object[0]);
                                                    accountInfoDto c = service.Do(dto);
                                                    if (c != null && c.flag == 0)
                                                    {
                                                        throw new BusinessException(c.errMsg);
                                                    }
                                                }
                                                catch (System.Exception e)
                                                {
                                                    throw new BusinessException("调用DMS接口错误:" + e.Message);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else if (voucher.OriginalData.VoucherStatus == VoucherStatus.Approved &&
                                     (voucher.VoucherStatus == VoucherStatus.Approving ||
                                      voucher.VoucherStatus == VoucherStatus.Open
                                     )
                                     )
                            {
                                SI04ImplService service = new SI04ImplService();
                                // service.Url = PubHelper.GetAddress(service.Url);
                                foreach (Entry entry in voucher.Entries)
                                {
                                    //if (entry.AccountKey != null && (entry.Account.Segment1.StartsWith("22410401") || entry.Account.Segment1.StartsWith("1122010303") || entry.Account.Segment1.StartsWith("1122010101") || entry.Account.Segment1.StartsWith("1122010301") || entry.Account.Segment1.StartsWith("2241030801") || entry.Account.Segment1 == "2241030803" || entry.Account.Segment1 == "1122010302" || entry.Account.Segment1 == "2241030901"))

                                    // 这里只处理打款(回款) 业务(即,账号增加;减少 在应收应付里做)

                                    // operaTionType账户类型;现金、三包
                                    // 现金,DJ(定金);三包,CBXY(三包信用)
                                    string dmsOperationType = GetDMSOperationType(entry);

                                    //if (IsUpdateDMS(entry))
                                    if (dmsOperationType.IsNotNullOrWhiteSpace())
                                    {
                                        if (entry.AccountedCr != 0)
                                        {
                                            Customer cust = Customer.Finder.Find(string.Format("Org={0} and Code='{1}'", Context.LoginOrg.ID.ToString(), entry.Account.Segment3), new OqlParam[0]);

                                            if (PubHelper.IsUpdateDMS(cust))
                                            {
                                                try
                                                {
                                                    accountInfoDto dto = new accountInfoDto();
                                                    dto.dealerCode      = entry.Account.Segment3;
                                                    dto.creadNo         = voucher.VoucherDisplayCode;
                                                    dto.invokeTime      = System.DateTime.Now;
                                                    dto.UNineCreateUser = voucher.CreatedBy;
                                                    dto.remark          = entry.Abstracts;
                                                    dto.changeType      = ((entry.AccountedCr > 0) ? 0 : 1);
                                                    //if (entry.Account.Segment1.StartsWith("22410401") || entry.Account.Segment1 == "1122010302")
                                                    //{
                                                    //    dto.operaTionType = "DJ";
                                                    //}
                                                    //else if (entry.Account.Segment1.StartsWith("1122010101"))
                                                    //{
                                                    //    dto.operaTionType = "FCK";
                                                    //}
                                                    //else if (entry.Account.Segment1 == "1122010301")
                                                    //{
                                                    //    dto.operaTionType = "CBXY";
                                                    //}
                                                    //else if (entry.Account.Segment1 == "2241030801" || entry.Account.Segment1 == "2241030803")
                                                    //{
                                                    //    dto.operaTionType = "BZJ";
                                                    //}
                                                    //else if (entry.Account.Segment1 == "12210203")
                                                    //{
                                                    //    dto.operaTionType = "SBXY";
                                                    //}
                                                    //else
                                                    //{
                                                    //    dto.operaTionType = "FL";
                                                    //}
                                                    dto.operaTionType = dmsOperationType;
                                                    dto.amount        = double.Parse(System.Math.Abs(entry.AccountedCr).ToString());
                                                    //Customer cust = Customer.Finder.Find(string.Format("Org={0} and Code='{1}'", Context.LoginOrg.ID.ToString(), entry.Account.Segment3), new OqlParam[0]);
                                                    //if (cust != null && cust.CustomerCategoryKey != null)
                                                    //{
                                                    //    dto.customerType = cust.CustomerCategory.Code;
                                                    //}

                                                    if (Context.LoginOrg.Code == PubHelper.Const_OrgCode_Electric)
                                                    {
                                                        // 电动车只有服务站
                                                        dto.customerType = "101006";
                                                    }
                                                    else
                                                    {
                                                        if (cust != null && cust.CustomerCategoryKey != null)
                                                        {
                                                            dto.customerType = cust.CustomerCategory.Code;
                                                        }
                                                    }
                                                    ILogger logger = LoggerManager.GetLogger(typeof(Voucher));
                                                    logger.Info(string.Format("弃审 dealerCode={0},creadNo={1},invokeTime={2},UNineCreateUser={3},remark={4},changeType={5},operaTionType={6},amount={7},customerType={8}", new object[]
                                                    {
                                                        dto.dealerCode,
                                                        dto.creadNo,
                                                        dto.invokeTime,
                                                        dto.UNineCreateUser,
                                                        dto.remark,
                                                        dto.changeType,
                                                        dto.operaTionType,
                                                        dto.amount.ToString(),
                                                        dto.customerType
                                                    }), new object[0]);
                                                    accountInfoDto c = service.Do(dto);
                                                    if (c != null && c.flag == 0)
                                                    {
                                                        throw new BusinessException(c.errMsg);
                                                    }
                                                }
                                                catch (System.Exception e)
                                                {
                                                    throw new BusinessException("调用DMS接口错误:" + e.Message);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        public void Notify(params object[] args)
        {
            if (args != null && args.Length != 0 && args[0] is EntityEvent)
            {
                BusinessEntity.EntityKey key = ((EntityEvent)args[0]).EntityKey;
                if (!(key == null))
                {
                    CompleteRptRcvLine entity = key.GetEntity() as CompleteRptRcvLine;
                    CompleteRpt        rpt    = entity.CompleteRpt;

                    // 改为在完工报告单上判断,审核、最终检验,关闭、总装入库;
                    return;

                    if (entity == null ||
                        rpt == null
                        )
                    {
                        return;
                    }

                    bool flag = PubHelper.IsUsedDMSAPI();
                    if (flag)
                    {
                        // 制造组织(成都)的才做完工报告
                        if (Context.LoginOrg.Code == PubHelper.Const_OrgCode_Chengdu)
                        {
                            if (rpt.ProjectKey != null)
                            {
                                Project project = Project.Finder.Find("Code='" + rpt.Project.Code.ToString() + "' and org=" + rpt.Project.MasterOrg.ID.ToString(), new OqlParam[0]);
                                if (project != null)
                                {
                                    SOLine soline = SOLine.Finder.Find(string.Format("Project={0}", project.ID.ToString()), new OqlParam[0]);
                                    if (soline != null && !string.IsNullOrEmpty(soline.SO.DescFlexField.PubDescSeg5))
                                    {
                                        if (((rpt.MOKey != null && rpt.MO.MODocType.Code != "MO02") ||
                                             rpt.PLSKey != null
                                             )
                                            // 物料一样,说明是整车完工
                                            && soline.ItemInfo.ItemID.Code == rpt.Item.Code
                                            )
                                        {
                                            //CompleteRpt rpt = entity.CompleteRpt;
                                            if (rpt.DocState == CompleteRptStateEnum.Received && rpt.OriginalData.DocState == CompleteRptStateEnum.Approved)
                                            {
                                                try
                                                {
                                                    SI03ImplService service = new SI03ImplService();
                                                    // service.Url = PubHelper.GetAddress(service.Url);
                                                    vehicleInfoDto dto = new vehicleInfoDto();
                                                    if (rpt.ProjectKey != null)
                                                    {
                                                        dto.dmsSaleNo = rpt.Project.Code;
                                                    }
                                                    dto.vin             = rpt.DescFlexField.PubDescSeg12;
                                                    dto.erpMaterialCode = rpt.Item.Code;
                                                    // 等待上线0,上线1,下线滞留2,下线调试3,最终检验4,总装入库5,调试检验6,车辆整改7
                                                    dto.nodeStatus  = "5";
                                                    dto.oldVin      = string.Empty;
                                                    dto.flowingCode = ((rpt.DescFlexField.PubDescSeg12.Length >= 8) ? rpt.DescFlexField.PubDescSeg12.Substring(rpt.DescFlexField.PubDescSeg12.Length - 8, 8) : rpt.DescFlexField.PubDescSeg12);
                                                    vehicleInfoDto resultdto = service.Do(dto);
                                                    if (resultdto != null && resultdto.flag == 0)
                                                    {
                                                        throw new BusinessException(resultdto.errMsg);
                                                    }
                                                }
                                                catch (System.Exception e)
                                                {
                                                    throw new BusinessException("调用DMS接口错误:" + e.Message);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }