chenhaozhe
2025-10-26 1948124877478db58b27841f9398aed97ef13053
WebAPI/Controllers/WebAPIController.cs
@@ -6,6 +6,7 @@
using Newtonsoft.Json.Linq;
using SQLHelper;
using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using System.IO;
@@ -18334,6 +18335,229 @@
        }
        #endregion
        #region 白标基础信息表 设置列表/保存/编辑/删除方法
        /// <summary>
        /// 保存白标基础信息表
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        [Route("SaveSc_PackUnionBillBarCode_tempList")]
        [HttpPost]
        public object SaveSc_PackUnionBillBarCode_tempList([FromBody] JObject msg)
        {
            DataSet ds;
            var _value = msg["msg"].ToString();
            string msg3 = _value.ToString();
            string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg1 = sArray[0].ToString();
            string msg2 = sArray[1].ToString();
            //查看权限
            if (!DBUtility.ClsPub.Security_Log("Sc_PackUnionBillBarCode_temp_Edit", 1, false, msg2))
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "无保存权限!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            Int64 HItemID = 0;
            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
            ListModels oListModels = new ListModels();
            try
            {
                WebAPI.DLL.ClsSc_PackUnionBillBarCode_temp_Ctl oBill = new WebAPI.DLL.ClsSc_PackUnionBillBarCode_temp_Ctl();
                List<Model.ClsSc_PackUnionBillBarCode_temp_Model> lsmain = new List<Model.ClsSc_PackUnionBillBarCode_temp_Model>();
                msg1 = msg1.Replace("\\", "");
                msg1 = msg1.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Sc_PackUnionBillBarCode_temp(msg1);
                foreach (Model.ClsSc_PackUnionBillBarCode_temp_Model oItem in lsmain)
                {
                    if (oItem.HMaterNumber.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!代码不能为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    if (oItem.HMaterName.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!名称不能为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    if (!DBUtility.ClsPub.AllowNumber(oItem.HMaterNumber.Trim()))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    //查询数据中是否存在重复代码
                    ds = oCN.RunProcReturn("select * from  Sc_PackUnionBillBarCode_temp where   HMaterNumber='" + oItem.HMaterNumber.Trim() + "' and HUSEORGID= '" + oItem.HUSEORGID + "'  ", "Sc_PackUnionBillBarCode_temp");
                    if (oItem.HMaterNumber.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!代码为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    //已审核的不允许保存
                    if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已审核!不能进行保存!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    oItem.HMakeEmp = msg2; //创建人
                    oBill.oModel = oItem;
                }
                //保存
                //保存完毕后处理
                bool bResult;
                if (oBill.oModel.HInterID == 0)
                {
                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else
                {
                    bResult = oBill.ModifyByID(oBill.oModel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                }
                if (bResult)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 白标基础信息表获取信息
        /// </summary>
        /// <returns></returns>
        [Route("GetSc_PackUnionBillBarCode_tempDetail")]
        [HttpGet]
        public ApiResult<DataSet> GetSc_PackUnionBillBarCode_tempDetail(string HID)
        {
            var model = LuBaoSevice.GetSc_PackUnionBillBarCode_tempBillDetail(HID);
            return model;
        }
        /// <summary>
        /// 白标基础信息表 删除功能
        /// </summary>
        /// <returns></returns>
        [Route("DeltetSc_PackUnionBillBarCode_temp")]
        [HttpGet]
        public object DeltetSc_PackUnionBillBarCode_temp(string HItemID, string user)
        {
            DataSet ds;
            try
            {
                //删除权限
                if (!DBUtility.ClsPub.Security_Log("Sc_PackUnionBillBarCode_temp_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无删除权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (string.IsNullOrWhiteSpace(HItemID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HItemID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();//开始事务
                ds = oCN.RunProcReturn("select * from Sc_PackUnionBillBarCode_temp where HInterID=" + HItemID, "Sc_PackUnionBillBarCode_temp");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有数据,无法删除!";
                    objJsonResult.data = null;
                    return objJsonResult; ;
                }
                if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据已审核!不能进行删除!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据已禁用!不能进行删除!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.RunProc("delete from Sc_PackUnionBillBarCode_temp where HInterID=" + HItemID);
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "数据删除成功!";
                objJsonResult.data = null;
                return objJsonResult; ;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "删除失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        /// <summary>
        /// 用关联工序获取信息
@@ -18652,7 +18876,8 @@
                    objjson.data = ds.Tables[0];
                    return objjson;
                }
            }catch(Exception e)
            }
            catch (Exception e)
            {
                objjson.code = "0";
                objjson.count = 0;
@@ -19954,6 +20179,7 @@
            }
        }
        /// <summary>
        /// 根据物料+工序获取检验方案
        /// </summary>
@@ -20278,6 +20504,7 @@
                }
                else
                {
                    sWhere = sWhere.Replace("\"", "''");
                    ds = oCN.RunProcReturn("exec h_p_IF_BarCodeBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_IF_BarCodeBillList");
                }
@@ -21066,6 +21293,50 @@
        /// <summary>
        /// 获取选单号的源单类型 通过选单号单据类型
        /// </summary>
        /// <returns></returns>
        [Route("Web/GetHSourceBillTypeByBillType")]
        [HttpGet]
        public object GetHSourceBillTypeByBillType(string HBillType, int Num)
        {
            try
            {
                ClsCN oCn = new ClsCN();
                DataSet oDs = new DataSet();
                //有的单子源单分为红蓝单  0代表蓝单  1代表红单
                if (Num == 0)
                {           //源单为蓝单
                    oDs = oCn.RunProcReturn("select * from  Xt_BillSourceSet where HNumber='" + HBillType + "'and  HRedBlueFlag ='" + Num + "' ", "Xt_BillSourceSet");
                }
                else if (Num == 1)
                {          //源单为红单
                    oDs = oCn.RunProcReturn("select * from  Xt_BillSourceSet where HNumber='" + HBillType + "' and  HRedBlueFlag ='" + Num + "' ", "Xt_BillSourceSet");
                }
                else if (Num == 2)
                {       //不分红蓝单
                    oDs = oCn.RunProcReturn("select * from  Xt_BillSourceSet where HNumber='" + HBillType + "'", "Xt_BillSourceSet");
                }
                objjson.code = "1";
                objjson.count = 1;
                objjson.Message = "获取成功!";
                objjson.data = oDs.Tables[0];
                return objjson; ;
            }
            catch (Exception e)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "获取失败!异常" + e.ToString();
                objjson.data = null;
                return objjson; ;
            }
        }
        /// <summary>
        /// 获取选单号的源单类型
        /// </summary>
        /// <returns></returns>
@@ -21095,6 +21366,120 @@
                return objjson; ;
            }
        }
        #region [从数据库加载菜单 APP]
        public class AppMenuLoad
        {
            public string HitemID { get; set; } // 主键
            public string HPartentID { get; set; } = "0"; // 父节点ID
            public string HEntryID { get; set; } // 菜单节点id
            public string HIndex { get; set; }
            public string HName { get; set; }
            public string HMenuName { get; set; }
            public string HPicNum { get; set; }
            public string HShowMode { get; set; }
            public string HTranslationText_English { get; set; }
            public string HTranslationText_Spain { get; set; }
            public string HMaker { get; set; }
            public List<MenuLoad> childMenus { get; set; }
        }
        [Route("Web/MenuList_APP")]
        [HttpGet]
        public object MenuList_APP(string HMaker, string HType, string HMenuListName)
        {
            try
            {
                DataSet ds = oCN.RunProcReturn("exec [h_p_Gy_MenuDefineSet_APP_Get] " +
                    "@HMaker = N'" + HMaker + "'," +
                    "@HType = N'" + HType + "'," +
                    "@HMenuListName = N'" + HMenuListName + "'"
                    , "h_p_Gy_MenuDefineSet_APP_Get");
                if ((bool)ds.Tables[0].Rows[0]["returnType"] == true)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = ds.Tables[0].Rows[0]["mesg"].ToString();
                    objJsonResult.data = ds.Tables[1];
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = ds.Tables[0].Rows[0]["mesg"].ToString();
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        [Route("Web/SetMenuList_APP")]
        [HttpPost]
        public object SetMenuList_APP([FromBody] JObject oMain)
        {
            var _value = oMain["oMain"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            try
            {
                string msg2 = sArray[0];
                string user = sArray[1].ToString();
                string MenuName = sArray[2].ToString();
                string type = sArray[3].ToString();
                if (String.Equals(type, "APP", StringComparison.InvariantCultureIgnoreCase))
                {
                    oCN.BeginTran();
                    List<AppMenuLoad> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AppMenuLoad>>(msg2);
                    string sql1 = "delete from Gy_MenuDefineSet_APP where HMenuName = '" + MenuName + "' and HMaker = '" + user + "'";
                    oCN.RunProcReturn(sql1, "Gy_MenuDefineSet_APP");
                    list.ForEach(one =>
                    {
                        string sql2 = "insert into Gy_MenuDefineSet_APP( HEntryID, HIndex, HName, HMenuName, HPicNum, HShowMode, HMaker)" +
                       "Values('" + one.HEntryID + "','" + one.HIndex + "','" + one.HName + "','" + MenuName + "','"
                       + one.HPicNum + "','" + one.HShowMode + "','" + user + "')";
                        oCN.RunProcReturn(sql2, "Gy_MenuDefineSet_APP");
                    });
                    oCN.Commit();
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "设置成功!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "暂不支持该平台设置自定义菜单!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region [从数据库加载菜单]
        public class MenuLoad
@@ -22059,6 +22444,116 @@
            }
        }
        #region 通过单据类型、单据号查询单据信息
        /// <summary>
        /// 通过单据类型获取对应视图并通过单据号查询单据信息
        /// </summary>
        /// <param name="HBillNo"></param>
        /// <param name="HBillType"></param>
        /// <param name="HStoreOrgID"></param>
        /// <returns></returns>
        [Route("Web/GetBillInfo")]
        [HttpGet]
        public object GetBillInfo(string HBillNo, string HBillType, int HStockOrgID)
        {
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn("exec h_p_Gy_GetBillInfoByHBillTypeAndHBillNo N'" + HBillType + "',N'" + HBillNo +
                    "'," + HStockOrgID, "h_p_Gy_GetBillInfoByHBillTypeAndHBillNo");
                if (ds == null)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo;
                    objjson.data = null;
                    return objjson;
                }
                else if ((bool)ds.Tables[1].Rows[0]["returnType"] == false)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "获取失败" + ds.Tables[1].Rows[1]["payload"];
                    objjson.data = null;
                    return objjson;
                }
                else
                {
                    objjson.code = "1";
                    objjson.count = 1;
                    objjson.Message = "获取成功!";
                    objjson.data = ds.Tables[0];
                    return objjson;
                }
            }
            catch (Exception ex)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "获取失败" + ex.ToString();
                objjson.data = null;
                return objjson;
            }
        }
        #endregion
        #region 通过单据类型、单据内码、子内码查询单据信息
        /// <summary>
        /// 通过单据类型获取对应视图并通过单据号查询单据信息
        /// </summary>
        /// <param name="HBillNo"></param>
        /// <param name="HBillType"></param>
        /// <param name="HStoreOrgID"></param>
        /// <returns></returns>
        [Route("Web/GetBillInfo_GenerateBillCode")]
        [HttpGet]
        public object GetBillInfo_GenerateBillCode(string HBillType, string HInterID, int HEntryID)
        {
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn("exec h_p_Gy_GetBillInfo_GenerateCode N'" + HBillType + "'," + HInterID +
                    "," + HEntryID, "h_p_Gy_GetBillInfo_GenerateCode");
                if (ds == null)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo;
                    objjson.data = null;
                    return objjson;
                }
                else if ((bool)ds.Tables[1].Rows[0]["returnType"] == false)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "获取失败" + ds.Tables[1].Rows[1]["payload"];
                    objjson.data = null;
                    return objjson;
                }
                else
                {
                    objjson.code = "1";
                    objjson.count = 1;
                    objjson.Message = "获取成功!";
                    objjson.data = ds.Tables[0];
                    return objjson;
                }
            }
            catch (Exception ex)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "获取失败" + ex.ToString();
                objjson.data = null;
                return objjson;
            }
        }
        #endregion
        /// <summary>
        /// 金帅WMS接口
@@ -22120,6 +22615,51 @@
            }
        }
        #region 小卫电器获取物料条码对应单据
        /// <summary>
        /// 小卫电器获取物料条码对应单据
        /// </summary>
        /// <param name="sWhere">自定义过滤条件</param>
        /// <param name="HBillType">单据号</param>
        /// <param name="HSourceBillType">源单号</param>
        /// <returns></returns>
        [Route("web/XiaoWeiBarCodeQuery")]
        [HttpGet]
        public object XiaoWeiBarCodeQuery(string sWhere, int HBillType, int HSourceBillType)
        {
            try
            {
                ds = oCN.RunProcReturn("exec h_p_XiaoWeiBarCodeQuery '" + sWhere + "'," + HBillType + "," + HSourceBillType, "h_p_XiaoWeiBarCodeQuery");
                if(ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "该物料条码无对应的单据";
                    objjson.data = null;
                    return objjson;
                }else
                {
                    objjson.code = "1";
                    objjson.count = 1;
                    objjson.Message = "获取成功!";
                    objjson.data = ds.Tables[0];
                    return objjson;
                }
            }
            catch (Exception ex)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "获取失败" + ex.ToString();
                objjson.data = null;
                return objjson;
            }
    }
        #endregion
    }
}