王 垚
2022-09-26 e4e1d2b2c1f13cd89514e59eb42fc50f1332262e
WebAPI/Controllers/ProductInController.cs
@@ -37,16 +37,17 @@
        public bool sRedBlueFlag = false;
        public bool SourceFlag = false;
        //public string sSourceType = "3710";
        public WebServer webserver =new WebServer();
        public DataSet ds =new DataSet();
        public ClsGy_BarCodeBill_WMS_Model_View oView =new ClsGy_BarCodeBill_WMS_Model_View();
        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 ClsKf_ICStockBill_WMS oBar = new ClsKf_ICStockBill_WMS();
        public double sRelQty = 0;
       // private DataBaseServices objDataBaseServices = new DataBaseServices();
        // private DataBaseServices objDataBaseServices = new DataBaseServices();
        private json objJsonResult = new json();
       // 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)
        {
            try
@@ -106,7 +107,7 @@
            {
                HBillType = "1245";
            }
            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";
@@ -212,8 +213,8 @@
        {
            try
            {
               // DataSet ds = new DataSet();
               // WebServer webserver = new WebServer();
                // DataSet ds = new DataSet();
                // WebServer webserver = new WebServer();
                string sWhere = " Where 单据号 like '%" + HSourceBillNo.Trim() + "%'";
                if (HSourceBillType == "3710")
                {
@@ -265,7 +266,7 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!"+ex.ToString();
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -356,115 +357,107 @@
//        /// <summary>
//        /// 扫描物料条码,将物料条码信息写入条码临时表
//        /// </summary>
//        /// <param name="sBarCode"></param>
//        /// <param name="sInterID"></param>
//        /// <param name="sBillNo"></param>
//        /// <param name="sQty"></param>
//        /// <returns></returns>
//        [Route("ProductIn/SetMaterBarCode_Webs_Json")]
//        [HttpGet]
//        public object SetMaterBarCode_Webs_Json(string sBarCode, Int64 HBillID, string HBillNo, string HMaker, Int64 HWhID, Int64 HSPID, Double HQty, bool SourceFlag, string HSourceBillNo, string HSourceBillType, Int64 HOWNERID, ref string sErrMsg)
//        {
//            ClsKf_ICStockBill_WMS oBar = new ClsKf_ICStockBill_WMS();
//            try
//            {
//                if (sBarCode.Trim() == "")
//                {
//                    objJsonResult.code = "0";
//                    objJsonResult.count = 0;
//                    objJsonResult.Message = "条码为空!";
//                    objJsonResult.data = null;
//                    return objJsonResult;
//                }
        //        /// <summary>
        //        /// 扫描物料条码,将物料条码信息写入条码临时表
        //        /// </summary>
        //        /// <param name="sBarCode"></param>
        //        /// <param name="sInterID"></param>
        //        /// <param name="sBillNo"></param>
        //        /// <param name="sQty"></param>
        //        /// <returns></returns>
        //        [Route("ProductIn/SetMaterBarCode_Webs_Json")]
        //        [HttpGet]
        //        public object SetMaterBarCode_Webs_Json(string sBarCode, Int64 HBillID, string HBillNo, string HMaker, Int64 HWhID, Int64 HSPID, Double HQty, bool SourceFlag, string HSourceBillNo, string HSourceBillType, Int64 HOWNERID, ref string sErrMsg)
        //        {
        //            ClsKf_ICStockBill_WMS oBar = new ClsKf_ICStockBill_WMS();
        //            try
        //            {
        //                if (sBarCode.Trim() == "")
        //                {
        //                    objJsonResult.code = "0";
        //                    objJsonResult.count = 0;
        //                    objJsonResult.Message = "条码为空!";
        //                    objJsonResult.data = null;
        //                    return objJsonResult;
        //                }
//                //根据条码前缀走 不同方法(仓库、仓位、部门)(源单、物料条码)
//                oBar = webserver.get_CheckTypeByBarCode(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, sRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, ref DBUtility.ClsPub.sErrInfo);
//                if (oBar == null)
//                {
//                    objJsonResult.code = "0";
//                    objJsonResult.count = 0;
//                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
//                    objJsonResult.data = null;
//                    return objJsonResult;
//                }
//                else
//                {
//                    //----------创建虚表------------------------
//                    DataTable dt_Main = new DataTable("Json");
//                    dt_Main.Columns.Add("HBarType", typeof(string));
//                    dt_Main.Columns.Add("HSourceBillType", typeof(string));
//                    dt_Main.Columns.Add("HSourceBillNo", typeof(string));
//                    dt_Main.Columns.Add("HSupID", typeof(int));
//                    dt_Main.Columns.Add("HSupName", typeof(string));
//                    dt_Main.Columns.Add("HDeptID", typeof(int));
//                    dt_Main.Columns.Add("HDeptNumber", typeof(string));
//                    dt_Main.Columns.Add("HDeptName", typeof(string));
//                    dt_Main.Columns.Add("HWhID", typeof(int));
//                    dt_Main.Columns.Add("HWhNumber", typeof(string));
//                    dt_Main.Columns.Add("HWhName", typeof(string));
//                    dt_Main.Columns.Add("HSPFlag", typeof(bool));
//                    dt_Main.Columns.Add("HSPID", typeof(int));
//                    dt_Main.Columns.Add("HSPNumber", typeof(string));
//                    dt_Main.Columns.Add("HSPName", typeof(string));
//                    dt_Main.Columns.Add("SourceFlag", typeof(bool));
//                    //---------创建新行------------------------
//                    DataRow dr_main = dt_Main.NewRow();//创建新行
//                    dt_Main.Rows.Add(dr_main);//将新行加入到表中
//                    dr_main["HBarType"] = oBar.HBarType;
//                    dr_main["HSourceBillType"] = oBar.HSourceBillType;
//                    dr_main["HSourceBillNo"] = oBar.HSourceBillNo;
//                    dr_main["HSupID"] = oBar.HSupID;
//                    dr_main["HSupName"] = oBar.HSupName;
//                    dr_main["HDeptID"] = oBar.HDeptID;
//                    dr_main["HDeptNumber"] = oBar.HDeptNumber;
//                    dr_main["HDeptName"] = oBar.HDeptName;
//                    dr_main["HWhID"] = oBar.HWhID;
//                    dr_main["HWhNumber"] = oBar.HWhNumber;
//                    dr_main["HWhName"] = oBar.HWhName;
//                    dr_main["HSPFlag"] = oBar.HSPFlag;
//                    dr_main["HSPID"] = oBar.HSPID;
//                    dr_main["HSPNumber"] = oBar.HSPNumber;
//                    dr_main["HSPName"] = oBar.HSPName;
//                    dr_main["SourceFlag"] = true;
        //                //根据条码前缀走 不同方法(仓库、仓位、部门)(源单、物料条码)
        //                oBar = webserver.get_CheckTypeByBarCode(sBarCode, HBillID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, sRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HOWNERID, ref DBUtility.ClsPub.sErrInfo);
        //                if (oBar == null)
        //                {
        //                    objJsonResult.code = "0";
        //                    objJsonResult.count = 0;
        //                    objJsonResult.Message = DBUtility.ClsPub.sErrInfo;
        //                    objJsonResult.data = null;
        //                    return objJsonResult;
        //                }
        //                else
        //                {
        //                    //----------创建虚表------------------------
        //                    DataTable dt_Main = new DataTable("Json");
        //                    dt_Main.Columns.Add("HBarType", typeof(string));
        //                    dt_Main.Columns.Add("HSourceBillType", typeof(string));
        //                    dt_Main.Columns.Add("HSourceBillNo", typeof(string));
        //                    dt_Main.Columns.Add("HSupID", typeof(int));
        //                    dt_Main.Columns.Add("HSupName", typeof(string));
        //                    dt_Main.Columns.Add("HDeptID", typeof(int));
        //                    dt_Main.Columns.Add("HDeptNumber", typeof(string));
        //                    dt_Main.Columns.Add("HDeptName", typeof(string));
        //                    dt_Main.Columns.Add("HWhID", typeof(int));
        //                    dt_Main.Columns.Add("HWhNumber", typeof(string));
        //                    dt_Main.Columns.Add("HWhName", typeof(string));
        //                    dt_Main.Columns.Add("HSPFlag", typeof(bool));
        //                    dt_Main.Columns.Add("HSPID", typeof(int));
        //                    dt_Main.Columns.Add("HSPNumber", typeof(string));
        //                    dt_Main.Columns.Add("HSPName", typeof(string));
        //                    dt_Main.Columns.Add("SourceFlag", typeof(bool));
        //                    //---------创建新行------------------------
        //                    DataRow dr_main = dt_Main.NewRow();//创建新行
        //                    dt_Main.Rows.Add(dr_main);//将新行加入到表中
        //                    dr_main["HBarType"] = oBar.HBarType;
        //                    dr_main["HSourceBillType"] = oBar.HSourceBillType;
        //                    dr_main["HSourceBillNo"] = oBar.HSourceBillNo;
        //                    dr_main["HSupID"] = oBar.HSupID;
        //                    dr_main["HSupName"] = oBar.HSupName;
        //                    dr_main["HDeptID"] = oBar.HDeptID;
        //                    dr_main["HDeptNumber"] = oBar.HDeptNumber;
        //                    dr_main["HDeptName"] = oBar.HDeptName;
        //                    dr_main["HWhID"] = oBar.HWhID;
        //                    dr_main["HWhNumber"] = oBar.HWhNumber;
        //                    dr_main["HWhName"] = oBar.HWhName;
        //                    dr_main["HSPFlag"] = oBar.HSPFlag;
        //                    dr_main["HSPID"] = oBar.HSPID;
        //                    dr_main["HSPNumber"] = oBar.HSPNumber;
        //                    dr_main["HSPName"] = oBar.HSPName;
        //                    dr_main["SourceFlag"] = true;
//                    objJsonResult.code = "0";
//                    objJsonResult.count = 1;
//                    objJsonResult.Message = "扫码成功!";
//                    objJsonResult.data = dt_Main;
//                    return objJsonResult;
//                }
//            }
//            catch (Exception e)
//            {
//                objJsonResult.code = "0";
//                objJsonResult.count = 0;
//                objJsonResult.Message = "写入临时表信息失败!" + e.Message + DBUtility.ClsPub.sErrInfo;
//                objJsonResult.data = null;
//                return objJsonResult;
//            }
//        }
        //                    objJsonResult.code = "0";
        //                    objJsonResult.count = 1;
        //                    objJsonResult.Message = "扫码成功!";
        //                    objJsonResult.data = dt_Main;
        //                    return objJsonResult;
        //                }
        //            }
        //            catch (Exception e)
        //            {
        //                objJsonResult.code = "0";
        //                objJsonResult.count = 0;
        //                objJsonResult.Message = "写入临时表信息失败!" + e.Message + DBUtility.ClsPub.sErrInfo;
        //                objJsonResult.data = null;
        //                return objJsonResult;
        //            }
        //        }
        /// <summary>
        /// 生成产品入库单
        /// 生成产品入库单(产品入库提交)
        /// </summary>
        /// <returns></returns>
        [Route("ProductIn/set_SaveProductInBill_Json")]
        [HttpPost]
        public object set_SaveProductInBill_Json([FromBody]JObject oMain)
        public object set_SaveProductInBill_Json([FromBody] JObject oMain)
        {
            var _value = oMain["oMain"].ToString();
            string msg1 = _value.ToString();
            //List<Model.ClsKf_ProductInBillMain> lsmain = new List<Model.ClsKf_ProductInBillMain>();
            //ListModels oListModels = new ListModels();
            //lsmain = oListModels.getProductInBillMainByJson(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;
            //BLL.ClsKf_ProductInBill bll = new BLL.ClsKf_ProductInBill();
            //return bll.set_SaveProductInBill_New(lsmain[0], sSourceBillType, ref DBUtility.ClsPub.sErrInfo);
            try
            {
                List<Model.ClsKf_ProductInBillMain> lsmain = new List<Model.ClsKf_ProductInBillMain>();
@@ -475,7 +468,6 @@
                string sSourceBillType = lsmain[0].HBillType;
                WebAPI.WebS.ClsKf_ProductInBillMain websLsmain = new WebS.ClsKf_ProductInBillMain();
                websLsmain.HInterID = lsmain[0].HInterID;
                websLsmain.HDate = lsmain[0].HDate;
                websLsmain.HBillNo = lsmain[0].HBillNo;
@@ -486,7 +478,14 @@
                websLsmain.HWHID = lsmain[0].HWHID;
                websLsmain.HSupID = lsmain[0].HSupID;
                websLsmain.HExplanation = lsmain[0].HExplanation;
                websLsmain.HGroupID = lsmain[0].HGroupID;
                websLsmain.HJiaYe = lsmain[0].HJiaYe;
                //保存人员
                SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                string saveGroupEmpsql = $"exec h_p_saveGroupEmp '{lsmain[0].HMaker}','{lsmain[0].HGroupID}',{lsmain[0].HJiaYe.Split(',')[0]},{lsmain[0].HJiaYe.Split(',')[1]},'{lsmain[0].HJiaYe}'";
                oCn.RunProc(saveGroupEmpsql);
                if (webserver.set_SaveProductInBill_New(websLsmain, sSourceBillType, ref DBUtility.ClsPub.sErrInfo))
                {