1
wangbin
2024-07-08 4548e24916ac5f63eef736cabdcd634864f8de16
WebAPI/Controllers/LookingForBillController.cs
@@ -186,19 +186,25 @@
                ListModels oListModels = new ListModels();
                List<LookingForBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LookingForBill>>(oMainData);
                oCN.BeginTran();
                var mainSql = "Insert Into LookingForBillMain " +
                    "(HInterID,HBillNo,HSourceInterID,HSourceBillNo,HCreateBy)" +
                //var mainSql1 = "Insert Into Kf_LookingForReturnBillMain " +
                //    "(HInterID,HBillNo,HSourceInterID,HSourceBillNo,HCreateBy)" +
                //    " values" +
                //    "(" + list[0].HInterID + ",'" + list[0].HBillNo + "'," + list[0].HSourceInterID + ",'" + list[0].HSourceBillNo + "','" + list[0].HMaker + "')";
                var mainSql = "Insert Into Kf_LookingForBillMain " +
                    "(HInterID,HBillNo,HSourceInterID,HSourceBillNo,HWhID,HWhName,HSPID,HSPName,HGroupID,HGroup" +
                    ",HSourceID,HSource,HCreateBy)" +
                    " values" +
                    "(" + list[0].HInterID + ",'" + list[0].HBillNo + "'," + list[0].HSourceInterID + ",'" + list[0].HSourceBillNo + "','" + list[0].HMaker + "')";
                    "(" + list[0].HInterID + ",'" + list[0].HBillNo + "'," + list[0].HSourceInterID+ ",'" + list[0].HSourceBillNo + "'," + list[0].HWHID + ",'" + list[0].HWHName + "'," + list[0].HSPID + ",'" + list[0].HSPName + "'," + list[0].HGroupID + ",'" + list[0].HGroup + "',"
                    + list[0].HSourceID + ",'" + list[0].HSource + "','" + list[0].HMaker + "')";
                oCN.RunProc(mainSql);
                for (int i = 0; i < list.Count; i++)
                {
                    var subSql = "Insert Into LookingForBillSub " +
                    "(HWHID,HWHName,HSPID,HSPName,HBillType,HMTONo,HQty,HMaterID,HMaterName,HMaterNumber,HMaterModel,HBarCode,HGroupID,HGroup,HSourceID,HSource,HIsStatus,HStatus,HCreateBy,HMainItemID)" +
                    var subSql = "Insert Into Kf_LookingForBillSub " +
                    "(HWHID,HWHName,HSPID,HSPName,HMTONo,HQty,HMaterID,HMaterName,HMaterNumber,HMaterModel,HBarCode,HGroupID,HGroup,HSourceID,HSource,HCreateBy,HMainItemID)" +
                    " values" +
                    "(" + list[i].HWHID + ",'" + list[i].HWHName + "'," + list[i].HSPID + ",'" + list[i].HSPName + "','1253','" + list[i].HMTONo + "',"+ list[i].HQty + ","
                    "(" + list[i].HWHID + ",'" + list[i].HWHName + "'," + list[i].HSPID + ",'" + list[i].HSPName + "','" + list[i].HMTONo + "',"+ list[i].HQty + ","
                    + list[i].HMaterID + ",'"+ list[i].HMaterName + "','"+ list[i].HMaterNumber + "','"+ list[i].HMaterModel + "','" + list[i].HBarCode + "',"
                    + list[i].HGroupID + ",'"+ list[i].HGroup + "',"+ list[i].HSourceID + ",'" + list[i].HSource + "',' ',' ','"+ list[i].HMaker + "',(select HItemID from LookingForBillMain where HBillNo = '"+ list[i].HBillNo + "'))";
                    + list[i].HGroupID + ",'"+ list[i].HGroup + "',"+ list[i].HSourceID + ",'" + list[i].HSource + "','"+ list[i].HMaker + "',(select HItemID from Kf_LookingForBillMain where HBillNo = '" + list[i].HBillNo + "'))";
                    oCN.RunProc(subSql);
                    var barCodeSql = "update Gy_BarCodeBill set HStatus='裁切中-" + list[i].HSource + "' where HBarCode = '"+ list[i].HBarCode + "'";
                    oCN.RunProc(barCodeSql);
@@ -237,23 +243,40 @@
                List<LookingForBill> lsmain = new List<LookingForBill>();
                ListModels oListModels = new ListModels();
                List<LookingForBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LookingForBill>>(oMainData);
                string flag = "";
                oCN.BeginTran();
                var mainSql = "Insert Into LookingForBillMain " +
                    "(HInterID,HBillNo,HSourceInterID,HSourceBillNo,HCreateBy)" +
                var mainSql = "Insert Into Kf_LookingForReturnBillMain " +
                    "(HInterID,HBillNo,HWhID,HWhName,HSPID,HSPName,HGroupID,HGroup" +
                    ",HSourceID,HSource,HCreateBy)" +
                    " values" +
                    "(" + list[0].HInterID + ",'" + list[0].HBillNo + "'," + list[0].HSourceInterID + ",'" + list[0].HSourceBillNo + "','" + list[0].HMaker + "')";
                    "(" + list[0].HInterID + ",'" + list[0].HBillNo + "'," + list[0].HWHID + ",'" + list[0].HWHName + "'," + list[0].HSPID + ",'" + list[0].HSPName + "'," + list[0].HGroupID + ",'" + list[0].HGroup + "',"
                    + list[0].HSourceID + ",'" + list[0].HSource + "','" + list[0].HMaker + "')";
                oCN.RunProc(mainSql);
                for (int i = 0; i < list.Count; i++)
                {
                    var subSql = "Insert Into LookingForBillSub " +
                    "(HWHID,HWHName,HSPID,HSPName,HBillType,HMTONo,HQty,HMaterID,HMaterName,HMaterNumber,HMaterModel,HBarCode,HGroupID,HGroup,HSourceID,HSource,HIsStatus,HStatus,HCreateBy,HMainItemID)" +
                    var subSql = "Insert Into Kf_LookingForReturnBillSub " +
                    "(HWHID,HWHName,HSPID,HSPName,HMTONo,HQty,HMaterID,HMaterName,HMaterNumber,HMaterModel,HBarCode,HGroupID,HGroup,HSourceID,HSource,HCreateBy,HMainItemID)" +
                    " values" +
                    "(" + list[i].HWHID + ",'" + list[i].HWHName + "'," + list[i].HSPID + ",'" + list[i].HSPName + "','1252','" + list[i].HMTONo + "'," + list[i].HQty + ","
                    "(" + list[i].HWHID + ",'" + list[i].HWHName + "'," + list[i].HSPID + ",'" + list[i].HSPName + "','" + list[i].HMTONo + "'," + list[i].HQty + ","
                    + list[i].HMaterID + ",'" + list[i].HMaterName + "','" + list[i].HMaterNumber + "','" + list[i].HMaterModel + "','" + list[i].HBarCode + "',"
                    + list[i].HGroupID + ",'" + list[i].HGroup + "'," + list[i].HSourceID + ",'" + list[i].HSource + "',' ',' ','" + list[i].HMaker + "',(select HItemID from LookingForBillMain where HBillNo = '" + list[i].HBillNo + "'))";
                    + list[i].HGroupID + ",'" + list[i].HGroup + "'," + list[i].HSourceID + ",'" + list[i].HSource + "','" + list[i].HMaker + "',(select HItemID from Kf_LookingForReturnBillMain where HBillNo = '" + list[i].HBillNo + "'))";
                    oCN.RunProc(subSql);
                    var barCodeSql = "update Gy_BarCodeBill set HStatus='在库' where HBarCode = '" + list[i].HBarCode + "'";
                    var barCodeSql = "update Gy_BarCodeBill set HStatus='" + list[i].HSPName + "-" + list[i].HWHName + "' where HBarCode = '" + list[i].HBarCode + "'";
                    oCN.RunProc(barCodeSql);
                    //判断是否是托条码
                    if (JudgeIsBarCode_s(list[i].HBarCode))
                    {
                        //如果是托条码更新托条码中的实物条码
                        //返回托条码中的实物条码
                        ds = GetHBarCode_s(list[i].HBarCode);
                        int HCount = Pub_Class.ClsPub.isInt(ds.Tables[0].Rows.Count);
                        for (int j = 0; j < HCount; j++)
                        {
                            string HSonBarCode = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[j][0]);
                            var SonBarCodeSql = "update Gy_BarCodeBill set HStatus='" + list[i].HSPName + "-" + list[i].HWHName + "' where HBarCode = '" + HSonBarCode + "'";
                            oCN.RunProc(SonBarCodeSql);
                        }
                    }
                }
                oCN.Commit();
                objJsonResult.code = "1";
@@ -286,7 +309,7 @@
                string[] sArray = HBarCode.Remove(0, 3).Split(';');
                long HSpID = DBUtility.ClsPub.isLong(sArray[1]);
                long HWHID = DBUtility.ClsPub.isLong(sArray[0]);
                string sWhere = " Where HWHID = " + HWHID + " and HItemID = "+ HSpID + "";
                string sWhere = " Where HWHID = " + HWHID + " and HItemID = " + HSpID + "";
                ds = getSpName_Json_s(sWhere);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
@@ -316,17 +339,178 @@
        }
        /// <summary>
        /// 待发区找货根据实物条码 返回相关信息
        /// 根据仓库二维码仓库相关信息
        /// </summary>
        /// <returns></returns>
        [Route("LookingFor/getWaitingLookingFor")]
        [Route("LookingFor/getWHName_Json")]
        [HttpGet]
        public object GetWaitingLookingFor(string HBarCode)
        public object getWHName_Json(string HBarCode)
        {
            try
            {
                string sWhere = " Where HBarCode = '" + HBarCode.Trim() + "'";
                ds = GetWaitingLookingFor_s(sWhere);
                long HWHID = int.Parse(HBarCode.Remove(0, 3));
                string sWhere = " Where HItemID = " + HWHID + "";
                ds = getWhName_Json_s(sWhere);
                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 = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 启用mes仓位,根据老仓库转换成新仓库
        /// </summary>
        /// <returns></returns>
        [Route("LookingFor/GetSpNameMES_Json")]
        [HttpGet]
        public object GetSpNameMES_Json(string HERPWHID)
        {
            try
            {
                ds = GetSpNameMES_Json_s(HERPWHID);
                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 = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 待发区找货根据源单号 返回相关信息
        /// </summary>
        /// <returns></returns>
        //[Route("LookingFor/getWaitingLookingFor")]
        //[HttpGet]
        //public object GetWaitingLookingFor(string HBillType,string HBillNo,string HSourceBillNo,string HCreateBy,string BenginHCreateDate,string EndHCreateDate)
        //{
        //    try
        //    {
        //        ds = GetWaitingLookingFor_s(HBillType, HBillNo, HSourceBillNo, HCreateBy, BenginHCreateDate, EndHCreateDate);
        //        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 = "1";
        //            objJsonResult.count = 1;
        //            objJsonResult.Message = "返回记录成功!";
        //            objJsonResult.data = ds.Tables[0];
        //            return objJsonResult;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        objJsonResult.code = "0";
        //        objJsonResult.count = 0;
        //        objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
        //        objJsonResult.data = null;
        //        return objJsonResult;
        //    }
        //}
        /// <summary>
        /// 上下架单列表
        /// </summary>
        /// <returns></returns>
        [Route("LookingFor/GetLookingForBillList")]
        [HttpGet]
        public object GetLookingForBillList(string HBillType, string sWhere)
        {
            try
            {
                if (HBillType == "ZHXJ")
                {
                    ds = GetLookingForBillListXJ_s(sWhere);
                }
                else if (HBillType == "ZHSJ")
                {
                    ds = GetLookingForBillListSJ_s(sWhere);
                }
                else
                {
                    ds = GetLookingForBillList_s(sWhere);
                }
                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 = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        //销售出库源单查货-根据销售订单查找实物所在库位
        [Route("LookingFor/GetSellOutFindSP")]
        [HttpGet]
        public object GetSellOutFindSP(string HbillNo)//h_p_Xs_SellOutFindSP
        {
            try
            {
                ds = GetSellOutFindSP_s(HbillNo);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
@@ -369,6 +553,7 @@
        public static DataSet getSellOrderList_s(string HSourceBillNo)
        {
            //同步销售订单
            new SQLHelper.ClsCN().RunProcReturn("EXEC h_p_IFCLD_ERPSourceBillToLocal_SEOrderToICMO '" + HSourceBillNo+ "'", "h_p_IFCLD_ERPSourceBillToLocal_SEOrderToICMO");
            string sWhere = " Where HSourceBillNo = '" + HSourceBillNo.Trim() + "'";
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_getSellOrderList_s " + sWhere, "h_v_getSellOrderList_s");
@@ -379,15 +564,95 @@
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_getBarCodeDetails_s " + sWhere, "h_v_getBarCodeDetails_s");
        }
        //根据仓位二维码带出仓库仓位相关信息
        public static DataSet getSpName_Json_s(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_StockPlace " + sWhere, "h_v_IF_StockPlace");
            return new SQLHelper.ClsCN().RunProcReturn("select HWHID,* from h_v_IF_StockPlace " + sWhere, "h_v_IF_StockPlace");
        }
        public static DataSet GetWaitingLookingFor_s(string sWhere)
        //根据仓库二维码带出仓库相关信息
        public static DataSet getWhName_Json_s(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_getWaitingLookingFor " + sWhere, "h_v_getWaitingLookingFor");
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_Warehouse " + sWhere, "h_v_IF_Warehouse");
        }
        //启用mes仓位,根据老仓库转换成新仓库
        public static DataSet GetSpNameMES_Json_s(string HERPWHID)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select HMESWHID,HMESWHNAME from Gy_ERPWHRelationMESWH where HERPWHID = " + HERPWHID + "", "Gy_ERPWHRelationMESWH");
        }
        //下架找货单列表
        public static DataSet GetLookingForBillListXJ_s(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_lookForBillListXJ ", "h_v_lookForBillListXJ");
        }
        //上架归还单列表
        public static DataSet GetLookingForBillListSJ_s(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_lookForBillListSJ ", "h_v_lookForBillListSJ");
        }
        //上下架单列表
        public static DataSet GetLookingForBillList_s(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_lookForBillList where 1 = 1 " + sWhere, "h_v_lookForBillList");
        }
        //判断是否是托条码
        public static bool JudgeIsBarCode_s(string HBarCode)
        {
            DataSet ds;
            ds = new SQLHelper.ClsCN().RunProcReturn("Select HBarCodeType from Gy_BarCodeBill WITH (NOLOCK) Where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
            if (Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][0]) == "托盘条码")
                return true;
            else
            {
                return false;
            }
        }
        //返回托条码中的实物条码
        public static DataSet GetHBarCode_s(string HBarCode)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select HBarCode from Sc_PackUnionBillMain a inner join Sc_PackUnionBillSub b on a.HInterID = b.HInterID Where a.HBarCode_Pack = '" + HBarCode + "'", "Sc_PackUnionBillMain");
        }
        //根据销售订单查找实物所在库位
        public static DataSet GetSellOutFindSP_s(string HbillNo)
        {
            return new SQLHelper.ClsCN().RunProcReturn("EXEC h_p_Xs_SellOutFindSP '" + HbillNo + "'", "h_p_Xs_SellOutFindSP");
        }
        //测试专用接口
        [Route("LookingFor/Test")]
        [HttpGet]
        public object Test(string HbillNo)//h_p_Xs_SellOutFindSP
        {
            DataSet ds;
            ds = new SQLHelper.ClsCN().RunProcReturn("EXEC h_p_Xs_SellOutFindSP '" + HbillNo + "'", "h_p_Xs_SellOutFindSP");
            if (Pub_Class.ClsPub.isLong(ds.Tables[0].Rows.Count) >= 0 )
            {
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "true!";
                objJsonResult.data = ds.Tables[0];//ds.Tables[0].Rows[1][0]
                return objJsonResult;
            }
            else
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "false!";
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }