1
yangle
2025-02-26 8931bbf58bfe3565d1367977e3c74f98bac8d23c
WebAPI/Controllers/ÌõÂë¹ÜÀí/WEBSController.cs
@@ -10488,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");
                    //入库申请单没有同步到金蝶则进行同步
@@ -10634,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)
@@ -10691,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;