1
duhe
2025-03-03 773e65fc78cd6300aaa706efdcb5756db9ad59a4
WebAPI/Controllers/ÌõÂë¹ÜÀí/WEBSController.cs
@@ -3871,6 +3871,92 @@
        #endregion
        #region é”€å”®é€€è´§    ä¸Šä¼ ç”Ÿå•
        #region é”€å”®é€€è´§    æ–°å¢žæ¨¡å¼
        /// <summary>
        /// é”€å”®é€€è´§æ–°å¢žä¸Šä¼ 
        /// </summary>
        /// <returns></returns>
        [Route("WEBSController/set_SaveSellOutBackBill_Json")]
        [HttpPost]
        public object set_SaveSellOutBackBill_Json([FromBody] JObject oMain)
        {
            var _value = oMain["oMain"].ToString();
            string msg1 = _value.ToString();
            try
            {
                List<Model.ClsKf_ICStockBillMain> lsmain = new List<Model.ClsKf_ICStockBillMain>();
                ListModels oListModels = new ListModels();
                lsmain = oListModels.getICStockBillMainByJson(msg1);
                WebS.ClsKf_ICStockBillMain websLsmain = new WebS.ClsKf_ICStockBillMain();
                string sSourceType = lsmain[0].HMainSourceBillType;
                websLsmain.HInterID = lsmain[0].HInterID;
                websLsmain.HBillNo = lsmain[0].HBillNo;
                websLsmain.HBillType = lsmain[0].HBillType;
                websLsmain.HDate = lsmain[0].HDate;
                websLsmain.HDeptID = lsmain[0].HDeptID;
                websLsmain.HWHID = lsmain[0].HWHID;
                websLsmain.HSCWHID = lsmain[0].HSCWHID;
                websLsmain.HSupID = lsmain[0].HSupID;
                websLsmain.HKeeperID = lsmain[0].HKeeperID;
                websLsmain.HSecManagerID = lsmain[0].HSecManagerID;
                websLsmain.HEmpID = lsmain[0].HEmpID;
                websLsmain.HManagerID = lsmain[0].HManagerID;
                websLsmain.HRemark = lsmain[0].HRemark;
                websLsmain.HExplanation = lsmain[0].HExplanation;
                websLsmain.HInnerBillNo = lsmain[0].HInnerBillNo;
                websLsmain.HRedBlueFlag = lsmain[0].HRedBlueFlag;
                websLsmain.HBillSubType = lsmain[0].HBillSubType;
                if (lsmain[0].HMainSourceBillType == "1403")
                {
                    websLsmain.HMainSourceBillType = "退货通知单";
                }
                else if (lsmain[0].HMainSourceBillType == "1401")
                {
                    websLsmain.HMainSourceBillType = "销售订单";
                }
                else
                {
                    websLsmain.HMainSourceBillType = "手工录入";
                }
                websLsmain.HMaker = lsmain[0].HMaker;
                websLsmain.HBillerID = lsmain[0].HBillerID;
                websLsmain.HSTOCKORGID = lsmain[0].HSTOCKORGID;
                websLsmain.HOWNERID = lsmain[0].HSTOCKORGID;
                if (oWebs.set_SaveSellOutBackBill_New(websLsmain, sSourceType, ref DBUtility.ClsPub.sErrInfo))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //成功!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;  //失败!
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "销售退货单上传失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region ç”Ÿäº§ç»„托单    ä¸Šä¼ ç”Ÿå•
        /// <summary>
@@ -4690,6 +4776,48 @@
            try
            {
                WebSoBar = oWebs.get_SourceBarCode_MateOutBack(HInterID, HBillNo, HBillType, HSourceBillNo, HSourceBillType, HMaker, HStockOrgID, ref DBUtility.ClsPub.sErrInfo);
                if (WebSoBar == null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功";
                    objJsonResult.data = WebSoBar;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "扫描源单条码失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region é”€å”®é€€è´§    æ‰«ææºå•条码
        /// <summary>
        /// é”€å”®é€€è´§    æ‰«ææºå•条码
        /// </summary>
        /// <returns></returns>
        [Route("WEBSController/Get_SourceBarCode_SellOutBack_Json")]
        [HttpGet]
        public object Get_SourceBarCode_SellOutBack_Json(Int64 HInterID, string HBillNo, string HBillType, string HSourceBillNo, string HSourceBillType, string HMaker, Int64 HStockOrgID)
        {
            try
            {
                WebSoBar = oWebs.get_SourceBarCode_SellOutBack(HInterID, HBillNo, HBillType, HSourceBillNo, HSourceBillType, HMaker, HStockOrgID, ref DBUtility.ClsPub.sErrInfo);
                if (WebSoBar == null)
                {
                    objJsonResult.code = "0";
@@ -10360,7 +10488,7 @@
                    HSourceBillNo_TB = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HSourceBillNo"]);
                    HSourceInterID = DBUtility.ClsPub.isInt(ds.Tables[0].Rows[0]["HSourceInterID"]);
                    //根据入库申请单单号判断单据信息是否已经同步到金蝶
                    sql = string.Format(@"select FID,FBILLNO from {0}..TFKO_t_Cust100009 with(nolock) where FBILLNO = '" + HSourceBillNo_TB + "'", HDataBaseName);
                    sql = string.Format(@"select FID,FBILLNO,FDOCUMENTSTATUS from {0}..TFKO_t_Cust100009 with(nolock) where FBILLNO = '" + HSourceBillNo_TB + "'", HDataBaseName);
                    ds = oCn.RunProcReturn(sql, "TFKO_t_Cust100009");
                    //入库申请单没有同步到金蝶则进行同步
@@ -10506,10 +10634,7 @@
                                LogService.Write("发生异常,入库申请单同步获取登录账号密码失败!:" + sBarCode + "," + HSourceBillNo_TB + "," + HSourceInterID);
                                return "发生异常,入库申请单同步获取登录账号密码失败!";
                            }
                            LogService.Write("其他入库,即将登录金蝶");
                            var loginRet = InvokeHelper.Login();
                            LogService.Write("其他入库,登录金蝶结果1:" + loginRet);
                            LogService.Write("其他入库,登录金蝶结果2:" + JObject.Parse(loginRet)["LoginResultType"].Value<int>());
                            var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                            if (isSuccess == 0)
@@ -10563,11 +10688,88 @@
                        }
                        //更新条码源单id信息
                        sql = string.Format($@"update a set HSourceInterID = isnull(b.FID,0),HSourceEntryID = isnull(c.FEntryID,0) from Gy_BarCodeBill a left join AIS20220609121235..TFKO_t_Cust100009 b on a.HSourceBillNo = b.FBillNo left join AIS20220609121235..TFKO_t_Cust_Entry100065 c on b.FID = C.FID and a.HBarcodeNo = c.FSEQ where HSourceBillNo = '{HSourceBillNo_TB}'");
                        sql = string.Format($@"update a set HSourceInterID = isnull(b.FID,0),HSourceEntryID = isnull(c.FEntryID,0) from Gy_BarCodeBill a with(nolock) left join AIS20220609121235..TFKO_t_Cust100009 b with(nolock) on a.HSourceBillNo = b.FBillNo left join AIS20220609121235..TFKO_t_Cust_Entry100065 c with(nolock) on b.FID = C.FID and a.HBarcodeNo = c.FSEQ where HSourceBillNo = '{HSourceBillNo_TB}'");
                        //执行更新语句
                        oCn.RunProc(sql);
                    }
                    //判断生产入库申请单是否是审核状态,若未审核则执行提交审核方法
                    else
                    {
                        //--Z æš‚存,A åˆ›å»ºï¼ŒB å®¡æ ¸ä¸­ï¼ŒC å·²å®¡æ ¸ï¼ŒD é‡æ–°å®¡æ ¸
                        //获取入库申请单单据号
                        string HBillNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["FBILLNO"]);
                        //包装线生成的生产入库申请单参与自动审核
                        if (HBillNo.Substring(0,2) == "RK" )
                        {
                            //获取入库申请单单据状态
                            string HBillStatus = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["FDOCUMENTSTATUS"]);
                            //获取入库申请单ID
                            var json = new
                            {
                                Ids = ds.Tables[0].Rows[0]["FID"].ToString(),
                            };
                            LogService.Write("提交审核ID:" + DBUtility.ClsPub.isInt(ds.Tables[0].Rows[0]["FID"]));
                            //从配置文件获取 CLOUD网址、账套信息、登录用户、登录密码
                            if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
                            {
                                LogService.Write("发生异常,入库申请单同步获取登录账号密码失败!:" + sBarCode + "," + HSourceBillNo_TB + "," + HSourceInterID);
                                return "发生异常,入库申请单同步获取登录账号密码失败!";
                            }
                            //登录金蝶
                            var loginRet = InvokeHelper.Login();
                            //判断是否登录成功
                            var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                            if (isSuccess == 0)
                            {
                                LogService.Write("其他入库,登录金蝶失败!" + sBarCode + "," + HSourceBillNo_TB + "," + HSourceInterID);
                                return "发生异常,登录金蝶失败!";
                            }
                            //提交审核
                            string result1 = string.Empty;
                            string result2 = string.Empty;
                            //创建,重新审核状态调用提交,审核按钮
                            if (HBillStatus == "A" || HBillStatus == "D")
                            {
                                LogService.Write("生产入库申请单号:" + HBillNo + ",重新进行提交审核");
                                result1 = InvokeHelper.Submit("k18d2ab4f14034c569576ec8e0835a80c", JsonConvert.SerializeObject(json));//提交
                                result2 = InvokeHelper.Audit("k18d2ab4f14034c569576ec8e0835a80c", JsonConvert.SerializeObject(json));//审核
                                if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                                {
                                    LogService.Write("入库申请单单号:" + ",提交失败" + result1);
                                    return "发生异常,入库申请单单号:" + ",提交失败" + result1;
                                }
                                if (JObject.Parse(result2)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                                {
                                    LogService.Write("入库申请单单号:" + ",审核失败" + result2);
                                    return "发生异常,入库申请单单号:" + ",审核失败" + result2;
                                }
                            }
                            //审核中状态调用审核按钮
                            else if (HBillStatus == "B")
                            {
                                LogService.Write("生产入库申请单号:" + HBillNo + ",重新进行审核");
                                result2 = InvokeHelper.Audit("k18d2ab4f14034c569576ec8e0835a80c", JsonConvert.SerializeObject(json));//审核
                                if (JObject.Parse(result2)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                                {
                                    LogService.Write("入库申请单单号:" + ",审核失败" + result2);
                                    return "发生异常,入库申请单单号:" + ",审核失败" + result2;
                                }
                            }
                            //更新条码源单id信息
                            sql = string.Format($@"update a set HSourceInterID = isnull(b.FID,0),HSourceEntryID = isnull(c.FEntryID,0) from Gy_BarCodeBill a with(nolock) left join AIS20220609121235..TFKO_t_Cust100009 b with(nolock) on a.HSourceBillNo = b.FBillNo left join AIS20220609121235..TFKO_t_Cust_Entry100065 c with(nolock) on b.FID = C.FID and a.HBarcodeNo = c.FSEQ where HSourceBillNo = '{HSourceBillNo_TB}'");
                            //执行更新语句
                            oCn.RunProc(sql);
                        }
                    }
                }
                HReturnResult = sBarCode;