ch
2021-11-21 552c3e5bf3bf0f78e3b3d971e0cae407bafbcaa2
WebAPI/Controllers/POStockInBillController.cs
@@ -26,14 +26,14 @@
        public Int64 HWhID;//仓库ID
        public Int64 HSPID;//仓位ID
        public string HSupName=string.Empty;
        public string HDeptName=string.Empty;
        public string HWhName=string.Empty;
        public string HSPName=string.Empty;
        public string HSupName = string.Empty;
        public string HDeptName = string.Empty;
        public string HWhName = string.Empty;
        public string HSPName = string.Empty;
        public Int64 HInterID;//本单ID
        public string HBillNo;
        public string HSourceBillNo=string.Empty;
        public string HSourceBillNo = string.Empty;
        public string HBillType = "1201";//单据类型
        public string sBillCode = "ICStockBill";
        public string sTranType = "1";
@@ -43,16 +43,17 @@
        public string sSourceTypeName = "采购订单";
        public string sRedBlue2 = "蓝字";
        //public bool sRedBlue = false;
        public WebServer webserver =new WebServer();
        public DataSet ds =new DataSet();
        public ClsGy_BarCodeBill_WMS_Model_View oView =new ClsGy_BarCodeBill_WMS_Model_View();
        public ClsKF_PonderationBillMain_Temp model =new ClsKF_PonderationBillMain_Temp();
        public WebServer webserver = new WebServer();
        public DataSet ds = new DataSet();
        public ClsGy_BarCodeBill_WMS_Model_View oView = new ClsGy_BarCodeBill_WMS_Model_View();
        public ClsKF_PonderationBillMain_Temp model = new ClsKF_PonderationBillMain_Temp();
        public ClsKf_ICStockBill_WMS oBar = new Model.ClsKf_ICStockBill_WMS();
        public double sRelQty = 0;
       // private DataBaseServices objDataBaseServices = new DataBaseServices();
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        // private DataBaseServices objDataBaseServices = new DataBaseServices();
        private JsonResult objJsonResult = new JsonResult();
       // private string msgModel = "{{\"count\":{0},\"code\":{0},\"message\":\"{1}\",\"result\":{2}}}";
        // private string msgModel = "{{\"count\":{0},\"code\":{0},\"message\":\"{1}\",\"result\":{2}}}";
        public static string GetSession(string sMsg)
        {
@@ -113,7 +114,7 @@
            {
                HBillType = "1239";
            }
            oBar = webserver.get_CheckTypeByBarCode_All(sCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID,sExpressNumber, ref DBUtility.ClsPub.sErrInfo);
            oBar = webserver.get_CheckTypeByBarCode_All(sCode, sInterID, HBillType, sBillNo, sMaker, WhID, SPID, sQty, sRedBlue, SourceFlag, sSourceBillNo, sSourceType, HOWNERID, sExpressNumber, ref DBUtility.ClsPub.sErrInfo);
            if (oBar == null)
            {
                objJsonResult.code = "0";
@@ -168,16 +169,16 @@
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!" + HSourceBillType;
                    objJsonResult.data = null;
                    return objJsonResult;
                    return objJsonResult;
                }
                else
                {
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception ex)
@@ -199,12 +200,12 @@
        /// <returns></returns>
        [Route("POStockInBill/set_SavePonderationBillMain_Temp_Source_Fast_Json")]
        [HttpGet]
        public object set_SavePonderationBillMain_Temp_Source_Fast_Json(string HSourceBillType,string HSourceBillNo, Int64 sInterID, string sBillNo)
        public object set_SavePonderationBillMain_Temp_Source_Fast_Json(string HSourceBillType, string HSourceBillNo, Int64 sInterID, string sBillNo)
        {
            try
            {
               // DataSet ds = new DataSet();
               // WebServer webserver = new WebServer();
                // DataSet ds = new DataSet();
                // WebServer webserver = new WebServer();
                string sWhere = " Where 单据号 like '%" + HSourceBillNo.Trim() + "'";
                //根据源单类型来调用不同的WEBS方法 new 
                if (HSourceBillType == "1102")
@@ -213,7 +214,7 @@
                }
                else if (HSourceBillType == "1103")
                {
                    ds = webserver.GetCg_PoInStockBillList(sWhere + "  and isnull(HBillSubType,0)=12510 ");
                    ds = webserver.GetCg_PoInStockBillList(sWhere + "");
                }
                else
                {
@@ -259,14 +260,88 @@
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!"+ex.ToString();
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 写入临时表  扫源单的方法
        /// </summary>
        /// <param name="HSourceBillNo"></param>
        /// <returns></returns>
        [Route("ICMOReportBill/set_SaveICMOReportBill")]
        [HttpGet]
        public object set_SaveICMOReportBill(string HSourceBillType, string HSourceBillNo, Int64 sInterID, string sBillNo)
        {
            try
            {
                // DataSet ds = new DataSet();
                // WebServer webserver = new WebServer();
                string sWhere = " Where 单据号 like '%" + HSourceBillNo.Trim() + "'";
                //根据源单类型来调用不同的WEBS方法 new
                if (HSourceBillType == "3710")
                {
                    ds = webserver.GetSc_ICMOBillList(sWhere + "  ");
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录,源单类型有错误!";
                    objJsonResult.data = null;
                    return objJsonResult; ;
                }
                //
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!" + HSourceBillType;
                    objJsonResult.data = null;
                    return objJsonResult;
                    //DBUtility.ClsPub.MessageBeep((int)DBUtility.ClsPub.BeepType.Warning);
                }
                else
                {
                    HDeptID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HDeptID"]);
                    HDeptName = Convert.ToString(ds.Tables[0].Rows[0]["HDeptName"]);
                    if (webserver.set_SavePonderationBillMain_Temp_Source_Fast(sInterID, sBillNo, HBillType, HSourceBillNo, HSourceBillType, "蓝字", ref DBUtility.ClsPub.sErrInfo))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "返回记录成功!";
                        objJsonResult.data = ds.Tables[0];
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "写入临时表失败!" + DBUtility.ClsPub.sErrInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 返回出入库条码临时表     
        /// </summary>
@@ -299,12 +374,12 @@
            }
            catch (Exception e)
            {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!"+e.ToString();
                    objJsonResult.data = null;
                    return objJsonResult;
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
@@ -327,7 +402,7 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message ="";
                objJsonResult.Message = "";
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -335,7 +410,7 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "失败!"+DBUtility.ClsPub.sErrInfo;
                objJsonResult.Message = "失败!" + DBUtility.ClsPub.sErrInfo;
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -363,7 +438,7 @@
            else
            {
                if (webserver.set_SavePonderationBillMain_Temp_Source_SourceBillType(sInterID, sBillNo, HBillType, sBarCode, sRedBlue2, ref HSourceBillNo, ref sSourceTypeName, ref HSupID, ref  HSupName, ref HDeptID, ref HDeptName, ref DBUtility.ClsPub.sErrInfo))
                if (webserver.set_SavePonderationBillMain_Temp_Source_SourceBillType(sInterID, sBillNo, HBillType, sBarCode, sRedBlue2, ref HSourceBillNo, ref sSourceTypeName, ref HSupID, ref HSupName, ref HDeptID, ref HDeptName, ref DBUtility.ClsPub.sErrInfo))
                {
                    //----------创建虚表------------------------
                    DataTable dt_Main = new DataTable("Json");
@@ -424,7 +499,7 @@
        [HttpGet]
        public object get_InfoByBarCode_Source_Json(string sBarCode, Int64 sInterID, string sBillNo, Double sQty, Int64 HWHID, Int64 HSPID)
        {
           // string sRedBlue = "蓝字";
            // string sRedBlue = "蓝字";
            try
            {
                string sErrMsg = "";
@@ -473,12 +548,12 @@
            }
            catch (Exception e)
            {
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "扫码失败,此条码不存在!"+e.ToString();
                 objJsonResult.data = null;
                 return objJsonResult;
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "扫码失败,此条码不存在!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
@@ -487,7 +562,7 @@
        /// <returns></returns>
        [Route("POStockInBill/set_SavePOStockInBackBill_Json")]
        [HttpPost]
        public object set_SavePOStockInBackBill_Json([FromBody]JObject oMain)
        public object set_SavePOStockInBackBill_Json([FromBody] JObject oMain)
        {
            var _value = oMain["oMain"].ToString();
            string msg1 = _value.ToString();
@@ -543,7 +618,7 @@
        /// <returns></returns>
        [Route("POStockInBill/set_SavePOStockInBill_Json")]
        [HttpPost]
        public object set_SavePOStockInBill_Json([FromBody]JObject oMain)
        public object set_SavePOStockInBill_Json([FromBody] JObject oMain)
        {
            var _value = oMain["oMain"].ToString();
            string msg1 = _value.ToString();
@@ -572,10 +647,10 @@
                websLsmain.HManagerID = 0;
                websLsmain.HBillerID = lsmain[0].HBillerID;
                websLsmain.HRemark = "";
                websLsmain.HExplanation = "";
                websLsmain.HInnerBillNo = "";
                websLsmain.HRedBlueFlag = false;//false蓝字 true红字
                websLsmain.HMainSourceBillType = lsmain[0].HBillType;
                websLsmain.HExplanation = lsmain[0].HExplanation;
                if (webserver.set_SavePOStockInBill_New(websLsmain, sSourceBillType, ref DBUtility.ClsPub.sErrInfo))
@@ -605,9 +680,69 @@
            }
        }
        /// <summary>
        /// 生产汇报单/提交/直接调webservice
        /// </summary>
        /// <returns></returns>
        [Route("ICMOReportBill/set_SaveICMOReportBill_Json")]
        [HttpPost]
        public object set_SaveICMOReportBill_Json([FromBody] JObject oMain)
        {
            var _value = oMain["oMain"].ToString();
            string msg1 = _value.ToString();
            try
            {
                List<Model.ClsSc_ICMOReportBillMain> lsmain = new List<Model.ClsSc_ICMOReportBillMain>();
                ListModels oListModels = new ListModels();
                lsmain = oListModels.getICMOReportBillMainByJson(msg1);
                lsmain[0].HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                lsmain[0].HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));
                string sSourceBillType = lsmain[0].HBillType;
                WebAPI.WebS.ClsSc_ICMOReportBillMain websLsmain = new WebS.ClsSc_ICMOReportBillMain();
                websLsmain.HInterID = lsmain[0].HInterID;
                websLsmain.HBillNo = lsmain[0].HBillNo;
                websLsmain.HBillType = "1201";//固定值
                websLsmain.HDate = lsmain[0].HDate;
                websLsmain.HDeptID = lsmain[0].HDeptID;
                websLsmain.HEmpID = 0;
                websLsmain.HBillerID = lsmain[0].HBillerID;
                websLsmain.HRemark = "";
                websLsmain.HMainSourceBillType = lsmain[0].HBillType;
                if (webserver.set_SaveICMOReportBill_Json(websLsmain, sSourceBillType, ref DBUtility.ClsPub.sErrInfo))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功!单据号为:";
                    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;
            }
        }
        [Route("POStockInBill/GetSpName_Json")]
        [HttpGet]
        public object GetSpName_Json(long HSpID, long HWHID,long HStockOrgID, ref string sErrMsg)
        public object GetSpName_Json(long HSpID, long HWHID, long HStockOrgID, ref string sErrMsg)
        {
            try
            {
@@ -650,7 +785,7 @@
            string sErrMsg = string.Empty;
            try
            {
                if (webserver.set_DelPonderationBillMain_Temp_InterIDAndSource(HInterID, HMaterID,HAuxPropID,HMTONo,HSourceInterID,HSourceEntryID,sHBillType,ref sErrMsg))
                if (webserver.set_DelPonderationBillMain_Temp_InterIDAndSource(HInterID, HMaterID, HAuxPropID, HMTONo, HSourceInterID, HSourceEntryID, sHBillType, ref sErrMsg))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
@@ -719,7 +854,7 @@
        [Route("POStockInBillList/DisBillEntryList_Mate_Webs_Json")]
        [HttpGet]
        public object DisBillEntryList_Webs_Json(string HBillType,string sWhere)
        public object DisBillEntryList_Webs_Json(string HBillType, string sWhere)
        {
            try
            {
@@ -789,5 +924,125 @@
        }
        #region 到货点数
        [Route("POStockInBillList/get_InfoByBillNo")]
        [HttpGet]
        public object get_InfoByBillNo(string HBillno)
        {
            try
            {
                string sqlwhere = " where 1=1 ";
                if (!String.IsNullOrEmpty(HBillno))
                    sqlwhere += "and 单据号='" + HBillno + "'";
                string sql = $"select * from h_v_Cg_POInStockBillList {sqlwhere} ";
                ds = oCn.RunProcReturn(sql, "h_v_Cg_POInStockBillList");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "失败 !";
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        //[Route("POStockInBillList/confirm")]
        //public object confirm(string hmainid)
        //{
        //    try
        //    {
        //        JObject model = new JObject();
        //        model.Add("FBILLTYPEID", new JObject() { ["Fnumber"] = "SLD01_SYS" }); //单据类型
        //        model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //通知日期
        //        model.Add("FStockOrgId", new JObject() { ["Fnumber"] = (this.Model.GetValue("FHPURCHASEORGID") as DynamicObject)?["Number"].ToString() ?? "" }); // 收料组织
        //        model.Add("FPurOrgId", new JObject() { ["Fnumber"] = (this.Model.GetValue("FHPURCHASEORGID") as DynamicObject)?["Number"].ToString() ?? "" }); //采购组织
        //        model.Add("FSupplierId", new JObject() { ["Fnumber"] = (this.Model.GetValue("FSupplierID") as DynamicObject)?["Number"].ToString() ?? "" }); //供应商
        //        model.Add("FOwnerTypeIdHead", "BD_OwnerOrg");//  货主类型
        //        model.Add("FOwnerIdHead", new JObject() { ["Fnumber"] = (this.Model.GetValue("FHPURCHASEORGID") as DynamicObject)?["Number"].ToString() ?? "" });//货主
        //                                                                                                                                                     //子表 数据模型
        //        JArray Fentity = new JArray();
        //        foreach (var item in entityRows)
        //        {
        //            if (Convert.ToBoolean(item["FCloseStatus"]))
        //                continue;
        //            JObject FentityModel = new JObject();
        //            FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = (item["FHMaterID"] as DynamicObject)?["Number"].ToString() ?? "" }); // 物料编码
        //            FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = (item["FUnitID"] as DynamicObject)?["Number"].ToString() ?? "" }); // 单位
        //            FentityModel.Add("FPreDeliveryDate", this.Model.GetValue("FHDate").ToString()); //预计到货日期
        //            FentityModel.Add("FPriceUnitId", new JObject() { ["Fnumber"] = (item["FUnitID"] as DynamicObject)?["Number"].ToString() ?? "" }); // 计价单位
        //            FentityModel.Add("FStockUnitID", new JObject() { ["Fnumber"] = (item["FUnitID"] as DynamicObject)?["Number"].ToString() ?? "" }); //  库存单位
        //            FentityModel.Add("FActReceiveQty", Convert.ToDecimal(item["FHQty"]) - Convert.ToDecimal(item["FReciveCount"])); // 供应商送货数量(提料计划数量 - 已生成送货单数量)
        //            FentityModel.Add("FOwnerTypeId", "BD_OwnerOrg");//货主类型
        //            FentityModel.Add("FOwnerID", new JObject() { ["Fnumber"] = (this.Model.GetValue("FHPURCHASEORGID") as DynamicObject)?["Number"].ToString() ?? "" });//货主
        //            FentityModel.Add("FSrcId", item["FHPOOrderInterID"].ToString());//源单内码
        //            FentityModel.Add("FSRCFORMID", "PUR_PurchaseOrder");//源单类型
        //            FentityModel.Add("FSrcBillNo", item["FHPOOrderBillNo"].ToString());//源单单号
        //            FentityModel.Add("FSRCENTRYID", item["FHPOOrderEntryID"].ToString());//源单分录内码
        //            FentityModel.Add("FORDERBILLNO", item["FHPOOrderBillNo"].ToString());//源单单号
        //            FentityModel.Add("FPOORDERENTRYID", item["FHPOOrderEntryID"].ToString());//源单分录内码
        //            JArray Fentity2 = new JArray();
        //            JObject FentityModel2 = new JObject();
        //            FentityModel2.Add("FDetailEntity_Link_FRULEID", "a8c6b6e5-a8c0-4fc1-8592-6b76c2136cf9");
        //            FentityModel2.Add("FDetailEntity_Link_FSTableName", "t_PUR_POOrderEntry");
        //            FentityModel2.Add("FDetailEntity_Link_FSBillId", item["FHPOOrderInterID"].ToString());
        //            FentityModel2.Add("FDetailEntity_Link_FSId", item["FHPOOrderEntryID"].ToString());
        //            Fentity2.Add(FentityModel2);
        //            FentityModel.Add("FDetailEntity_Link", Fentity2);
        //            Fentity.Add(FentityModel);
        //        }
        //        model.Add("FDetailEntity", Fentity); //明细信息
        //        JObject _FentityModel = new JObject();
        //        _FentityModel.Add("FSettleOrgId", new JObject() { ["Fnumber"] = (this.Model.GetValue("FHPURCHASEORGID") as DynamicObject)?["Number"].ToString() ?? "" }); //  结算组织
        //        _FentityModel.Add("FSettleCurrId", new JObject() { ["Fnumber"] = (this.Model.GetValue("FSettleCurrId") as DynamicObject)?["Number"].ToString() ?? "" }); //  结算币别
        //        _FentityModel.Add("FPricePoint", 0); //  定价时点
        //        model.Add("FinanceEntity ", _FentityModel);//财务信息
        //        JObject jsonRoot = new JObject()
        //        {
        //            ["Creator"] = "",
        //            ["NeedUpDateFields"] = new JArray(),
        //            ["NeedReturnFields"] = new JArray(),
        //            ["IsDeleteEntry"] = "false",
        //            ["SubSystemId"] = "",
        //            ["IsVerifyBaseDataField"] = "false",
        //            //["IsAutoSubmitAndAudit"] = true,//自动调用提交和审核功能
        //            ["Model"] = model
        //        };
        //        var result = cloudClient.Save("PUR_ReceiveBill", jsonRoot.ToString());
        //        JObject saveObj = JObject.Parse(result);
        //        string saveIsSuc = saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper();
        //    }
        //    catch (Exception)
        //    {
        //        objJsonResult.code = "0";
        //        objJsonResult.count = 0;
        //        objJsonResult.Message = "失败 !";
        //        objJsonResult.data = null;
        //        return objJsonResult;
        //    }
        //}
        #endregion
    }
}