duhe
2024-10-16 380127b84c3fa9cfc8c9753d8ffed5b20e927720
WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs
@@ -9,12 +9,15 @@
using System.Data.SqlClient;
using System.Web.Http;
using WebAPI.Models;
using SyntacticSugar.constant;
namespace WebAPI.Controllers
{
    //采购入库单Controller
    public class Kf_POStockInBillController : ApiController
    {
        //获取系统参数
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        //public DAL.ClsCg_POInStockBill BillOld = new DAL.ClsCg_POInStockBill();
        public DAL.ClsKf_POStockInBill BillOld = new DAL.ClsKf_POStockInBill();
@@ -276,6 +279,30 @@
                //采购入库单新增回填收料通知单关联数量
                oCN.RunProc("exec h_p_Cg_UpDateRelation_POInStockToPOStockIn_Add " + HInterID);
                //自动审核设置
                if ((OperationType == 1 || OperationType == 2 || OperationType == 4))
                {
                    objJsonResult.HInterID = HInterID.ToString(); //返回主ID
                    //系统参数  自动审核
                    string sReturn = "";
                    if (oSystemParameter.ShowBill(ref sReturn) == true)
                    {
                        if (oSystemParameter.omodel.Kf_POStockInBill_AutoCheck == "Y") //系统参数  自动审核
                        {
                            objJsonResult.Verify = "Y";
                        }
                        else
                        {
                            objJsonResult.Verify = "N";
                        }
                    }
                }
                else if (OperationType == 3)
                {
                    objJsonResult.HInterID = HInterID.ToString(); //返回主ID
                    objJsonResult.Verify = "N";
                }
                if (objJsonResult.code == "0")
@@ -1819,5 +1846,159 @@
        }
        #endregion
        #region 采购入库单下推查询列表
        [Route("Kf_POStockInBill/PushList")]
        [HttpGet]
        public object PushList(string HBillNo, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                string sql = "select * from h_v_Kf_POStockInBillList where 单据号 = '" + HBillNo + "' and 状态 = '已审核' and 实收数量 - 关联数量 > 0";
                ds = oCN.RunProcReturn(sql, "h_v_Kf_POStockInBillList");
                if (ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = "找不到符合条件单据!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 采购入库单查询列表
        [Route("Kf_POStockInBill/QueryList")]
        [HttpGet]
        public object QueryList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Kf_POStockInBillQuery", 1, false, user))
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = "无权限查看!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string sql = "select * from h_v_Kf_POStockInBillQuery where 1 = 1 ";
                if (sWhere == "" || sWhere == null)
                {
                    ds = oCN.RunProcReturn("select * from h_v_Kf_POStockInBillQuery  order by hmainid desc", "h_v_Kf_POStockInBillQuery");
                }
                else
                {
                    ds = oCN.RunProcReturn(sql + sWhere + " order by hmainid desc", "h_v_Kf_POStockInBillQuery");
                }
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 采购入库单查询子列表
        [Route("Kf_POStockInBill/QuerySubList")]
        [HttpGet]
        public object QuerySubList(string hmainid, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Kf_POStockInBillQuery", 1, false, user))
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = "无权限查看!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string sql = "select * from h_v_Kf_POStockInBillQuerySub where hmainid =  " + hmainid;
                ds = oCN.RunProcReturn(sql + " order by hsubid desc", "h_v_Kf_POStockInBillQuerySub");
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}