yusijie
2024-10-04 f0a0aaf5af0b2c952120a3d0b9f273bf93dd1dee
WebAPI/Controllers/WebAPIController.cs
@@ -18,6 +18,10 @@
using WebAPI.Controllers.SCGL.日计划管理;
using WebAPI.Models;
using WebAPI.Service;
using System.Web;
using WebAPI.Controllers.SCGL.日计划管理;
using System.IO;
using SyntacticSugar.constant;
namespace WebAPI.Controllers
{
@@ -108,6 +112,68 @@
        [Route("Web/GetMAXNumPDA")]
        [HttpGet]
        public object GetMAXNumPDA(string HBillType)
        {
            try
            {
                string HBillNo = "";
                string sErrMsg = "";
                Int64 HInterID = 0;//显示的字段
                HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref sErrMsg);
                HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref sErrMsg, true);
                DataSet ds;
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                ds = oCN.RunProcReturn("exec h_p_IF_CheckBillIDExists_WMS  " + HInterID + ",'" + HBillNo + "'", "h_p_IF_CheckBillIDExists_WMS");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    sErrMsg = "存在重复单据内码或单据号的单据,不允许新增,请退出后重新登录!";
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = sErrMsg;
                    objjson.data = null;
                    return objjson;
                }
                else if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0][0]) == "1")
                {
                    sErrMsg = "存在重复单据内码或单据号的单据,不允许新增,请退出后重新登录!";
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = sErrMsg;
                    objjson.data = null;
                    return objjson;
                }
                else
                {
                    //----------创建虚表------------------------
                    DataTable dt_Main = new DataTable("Json");
                    dt_Main.Columns.Add("HBillNo", typeof(string));
                    dt_Main.Columns.Add("HInterID", typeof(Int64));
                    //---------创建新行------------------------
                    DataRow dr_main = dt_Main.NewRow();//创建新行
                    dt_Main.Rows.Add(dr_main);//将新行加入到表中
                    dr_main["HBillNo"] = DBUtility.ClsPub.isStrNull(HBillNo);
                    dr_main["HInterID"] = DBUtility.ClsPub.isLong(HInterID);
                    //返回数据
                    objjson.code = "0";
                    objjson.count = 1;
                    objjson.Message = "获取成功";
                    objjson.data = dt_Main;
                    return objjson;
                }
            }
            catch (Exception e)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "获取失败" + e.ToString();
                objjson.data = null;
                return objjson;
            }
        }
        [Route("Web/GetMAXNum_ProcExchange")]
        [HttpGet]
        public object GetMAXNum_ProcExchange(string HBillType)
        {
            try
            {
@@ -369,47 +435,57 @@
        /// <returns></returns>
        [Route("Web/GetXGPassword")]
        [HttpGet]
        public object GetXGPassword(string UserName, string oldPassword, string PassWord, string Repassword)
        public object GetXGPassword(string UserName, string oldPassword, string PassWord, string Repassword,string HCloudUserName,string HCloudUserPsd)
        {
            try
            {
                ClsCN oCn = new ClsCN();
                DataSet oDs = new DataSet();
                //==========
                oDs = oCn.RunProcReturn("select Czmm from  Gy_Czygl where Czybm='" + UserName + "'", "Gy_Czygl");
                if (PassWord.Trim() != Repassword.Trim())
                if(PassWord!=null)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "2次密码不一致!";
                    objjson.data = oDs.Tables[0];
                    return objjson; ;
                }
                //===========
                if (oDs == null || oDs.Tables[0].Rows.Count == 0)
                {
                    objjson.code = "0";
                    objjson.count = 0;
                    objjson.Message = "没有这个用户,不能修改密码!";
                    objjson.data = null;
                    return objjson; ;
                }
                else
                {
                    oCn.RunProc("update  Gy_Czygl set Czmm='" + ClsPub.StrToPsd(PassWord.Trim()) + "' where Czybm='" + UserName.Trim() + "'");
                    oDs = oCn.RunProcReturn("select Czmm from  Gy_Czygl where Czybm='" + UserName + "'", "Gy_Czygl");
                    if (PassWord.Trim() != Repassword.Trim())
                    {
                        objjson.code = "0";
                        objjson.count = 0;
                        objjson.Message = "2次密码不一致!";
                        objjson.data = oDs.Tables[0];
                        return objjson; ;
                    }
                    //===========
                    if (oDs == null || oDs.Tables[0].Rows.Count == 0)
                    {
                        objjson.code = "0";
                        objjson.count = 0;
                        objjson.Message = "没有这个用户,不能修改密码!";
                        objjson.data = null;
                        return objjson; ;
                    }
                    oCn.RunProc("update  Gy_Czygl set Czmm='" + ClsPub.StrToPsd(PassWord.Trim()) + "',HCloudUserName = '" + HCloudUserName+ "',HCloudUserPsd = '" + HCloudUserPsd+ "' where Czybm='" + UserName.Trim() + "'");
                    objjson.code = "0";
                    objjson.count = 1;
                    objjson.Message = "* 密码修改成功!";
                    objjson.data = null;
                    return objjson;
                }
                else
                {
                    oCn.RunProc("update  Gy_Czygl set HCloudUserName = '" + HCloudUserName + "',HCloudUserPsd = '" + HCloudUserPsd + "' where Czybm='" + UserName.Trim() + "'");
                    objjson.code = "0";
                    objjson.count = 1;
                    objjson.Message = "* 金蝶云账号修改成功!";
                    objjson.data = null;
                    return objjson; ;
                }
            }
            catch (Exception)
            catch (Exception e)
            {
                objjson.code = "0";
                objjson.count = 0;
                objjson.Message = "修改密码异常!";
                objjson.Message = "修改密码异常!" + e.ToString();
                objjson.data = null;
                return objjson; ;
            }
@@ -3096,6 +3172,263 @@
        }
        #endregion
        #region 异常类型 文件导入保存
        #region 异常类型 文件上传
        [Route("Gy_ErrType/Gy_ErrType_Excel")]
        [HttpPost]
        public object Gy_ErrType_Excel()
        {
            try
            {
                //获取文件名称
                var file = HttpContext.Current.Request.Files[0];
                //获取文件物理路径
                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
                //保存文件
                file.SaveAs(ExcelPath);
                NpoiHelper np = new NpoiHelper();
                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
                //删除文件
                File.Delete(ExcelPath);
                //创建临时表
                DataTable tb2 = new DataTable("dt2");
                //添加列名
                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
                {
                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
                }
                //模板缺少列 但需要从数据库中查询出来显示在页面的字段
                tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID
                //添加数据
                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
                {
                    DataRow row = tb2.NewRow();
                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
                    {
                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
                    }
                    tb2.Rows.Add(row);
                }
                var error = "";
                //查询工艺路线没有的列
                if (!tb2.Columns.Contains("组织代码"))
                    error += "没有找到【组织代码】的标题,";
                if (!tb2.Columns.Contains("组织名称"))
                    error += "没有找到【组织名称】的标题,";
                if (!tb2.Columns.Contains("异常类型"))
                    error += "没有找到【异常类型名称】的标题,";
                if (!tb2.Columns.Contains("异常类型代码"))
                    error += "没有找到【异常类型代码】的标题,";
                if (error.Length > 0)
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = $"Excel模板存在错误,{error}\r\n";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
                {
                    string HProcessName = "";
                    string HProcessNum = "";
                    string HORGNumber = "";
                    string HORGName = "";
                    HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["异常类型"].ToString());
                    HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["异常类型代码"].ToString());
                    HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString());
                    HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString());
                    //检查物料
                    int index = i + 1;
                    if (HORGNumber != "")
                    {
                        //查询组织
                        ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where  HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,组织不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        //异常类型名称
                        if (HProcessName == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,异常类型名称不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //异常类型代码
                        if (HProcessNum == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,异常类型代码不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "第" + index + "行,组织代码为空";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = error;
                objJsonResult.data = tb2;
                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("Gy_ErrType/Gy_ErrType_btnSave")]
        [HttpPost]
        public object Gy_ErrType_btnSave([FromBody] JObject sMainSub)
        {
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string user = sArray[1].ToString();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Gy_ErrType_Edit", 1, false, user))
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = "无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
                foreach (JObject item in Excel)
                {
                    Dictionary<string, string> dic = new Dictionary<string, string>();
                    foreach (var itm in item.Properties())
                    {
                        dic.Add(itm.Name, itm.Value.ToString());
                    }
                    list.Add(dic);
                }
                oCN.BeginTran();
                int i = 1;
                foreach (Dictionary<string, string> item in list)
                {
                    string HOrgID = item["HOrgID"].ToString();//组织ID
                    string HProcessName = item["异常类型"].ToString();
                    string HProcessNum = item["异常类型代码"].ToString();
                    string HRemark = item["备注"].ToString();
                    string sShortNumber;
                    sShortNumber = DBUtility.ClsPub.GetShortNumber(HProcessNum);//短代码
                    if (sShortNumber.Trim() == "")
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!短代码为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    int HEndFlag = 1;//末级标志
                    int HLevel = DBUtility.ClsPub.GetLevel(HProcessNum); //等级
                    if (!DBUtility.ClsPub.AllowNumber(HProcessNum.Trim()))
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    ds = oCN.RunProcReturn("select * from Gy_ErrType where HNumber='" + HProcessNum + "'", "Gy_ErrType");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        oCN.RunProc("Insert into " + "Gy_ErrType" +
                        " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                        ",HLevel,HEndFlag,HStopflag,HRemark,HBarCode,HUSEORGID,HCREATEORGID,HUseFlag) " +
                        " Values('" + HProcessNum + "','" + HProcessName + "','" + "','" + sShortNumber + "'," + 0 +
                        "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + "'," + HOrgID + "," + HOrgID + ",'" + "未检测" + "')");
                    }
                    else
                    {
                        oCN.RunProc("update  Gy_ErrType set HUSEORGID=" + HOrgID + ",HRemark='" + HRemark + "'  where HNumber='" + HProcessNum + "'");
                    }
                    i++;
                }
                oCN.Commit();
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = "导入成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                LogService.Write(e);
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        /// <summary>
        /// 不良类型获取信息
        /// </summary>
@@ -5486,6 +5819,309 @@
        #endregion
        #region 岗位技能 文件导入保存
        #region 岗位技能 文件上传
        [Route("Gy_PostSkill/Gy_PostSkill_Excel")]
        [HttpPost]
        public object Gy_PostSkill_Excel()
        {
            try
            {
                //获取文件名称
                var file = HttpContext.Current.Request.Files[0];
                //获取文件物理路径
                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
                //保存文件
                file.SaveAs(ExcelPath);
                NpoiHelper np = new NpoiHelper();
                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
                //删除文件
                File.Delete(ExcelPath);
                //创建临时表
                DataTable tb2 = new DataTable("dt2");
                //添加列名
                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
                {
                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
                }
                //模板缺少列 但需要从数据库中查询出来显示在页面的字段
                tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID
                tb2.Columns.Add("HPostID", typeof(Int32));//岗位id
                //添加数据
                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
                {
                    DataRow row = tb2.NewRow();
                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
                    {
                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
                    }
                    tb2.Rows.Add(row);
                }
                var error = "";
                //查询没有的列
                if (!tb2.Columns.Contains("组织代码"))
                    error += "没有找到【组织代码】的标题,";
                if (!tb2.Columns.Contains("组织名称"))
                    error += "没有找到【组织名称】的标题,";
                if (!tb2.Columns.Contains("岗位技能"))
                    error += "没有找到【岗位技能】的标题,";
                if (!tb2.Columns.Contains("岗位技能代码"))
                    error += "没有找到【岗位技能代码】的标题,";
                if (!tb2.Columns.Contains("岗位"))
                    error += "没有找到【岗位】的标题,";
                if (!tb2.Columns.Contains("岗位代码"))
                    error += "没有找到【岗位代码】的标题,";
                if (!tb2.Columns.Contains("备注"))
                    error += "没有找到【备注】的标题,";
                if (!tb2.Columns.Contains("助记码"))
                    error += "没有找到【助记码】的标题,";
                if (error.Length > 0)
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = $"Excel模板存在错误,{error}\r\n";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
                {
                    string HProcessName = "";
                    string HProcessNum = "";
                    string HORGNumber = "";
                    string HORGName = "";
                    string HPostName = "";
                    string HPostNumber = "";
                    HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位技能"].ToString());
                    HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位技能代码"].ToString());
                    HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString());
                    HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString());
                    HPostName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位"].ToString());
                    HPostNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位代码"].ToString());
                    //检查物料
                    int index = i + 1;
                    if (HORGNumber != "")
                    {
                        //查询组织
                        ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where  HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,组织不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        //查询岗位
                        ds = oCN.RunProcReturn("select * from Gy_Post where  HNumber='" + HPostNumber + "' and Hname='" + HPostName + "' and HUSEORGID = "+ HORGid, "Gy_Post");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,岗位不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HPostID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                        //岗位技能名称
                        if (HProcessName == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,岗位技能不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //岗位技能代码
                        if (HProcessNum == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,岗位技能代码不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "第" + index + "行,组织代码为空";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = error;
                objJsonResult.data = tb2;
                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("Gy_PostSkill/Gy_PostSkill_btnSave")]
        [HttpPost]
        public object Gy_PostSkill_btnSave([FromBody] JObject sMainSub)
        {
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string user = sArray[1].ToString();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Gy_PostSkill_Edit", 1, false, user))
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = "无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
                foreach (JObject item in Excel)
                {
                    Dictionary<string, string> dic = new Dictionary<string, string>();
                    foreach (var itm in item.Properties())
                    {
                        dic.Add(itm.Name, itm.Value.ToString());
                    }
                    list.Add(dic);
                }
                oCN.BeginTran();
                int i = 1;
                foreach (Dictionary<string, string> item in list)
                {
                    string HOrgID = item["HOrgID"].ToString();//组织ID
                    string HPostID = item["HPostID"].ToString();//组织ID
                    string HName = item["岗位技能"].ToString();
                    string HNumber = item["岗位技能代码"].ToString();
                    string HRemark = item["备注"].ToString();
                    string HHelpCode = item["助记码"].ToString();
                    string HUseFlag = "未检测";
                    string HShortNumber;
                    HShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码
                    if (HShortNumber.Trim() == "")
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!短代码为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    int HEndFlag = 1;//末级标志
                    int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级
                    if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim()))
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    ds = oCN.RunProcReturn("select * from Gy_PostSkill where HNumber='" + HNumber + "'", "Gy_PostSkill");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        oCN.RunProc("Insert into " + "Gy_PostSkill" +
                        " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                        ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID,HPostID,HProcID) " +
                        " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + 0 +
                        "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + HUseFlag + "','" + user + "','" + HOrgID + "','" + HPostID + "','" + 0 + "')");
                    }
                    else
                    {
                        oCN.RunProc("Update " + "Gy_PostSkill" + " set " +
                        "HName='" + HName + "'" +
                        ",HShortNumber='" + HShortNumber + "'" +
                        ",HHelpCode='" + HHelpCode + "'" +
                        ",HModifyTime='" + DateTime.Now + "'" +
                        ",HUSEORGID='" + HOrgID + "'" +
                        ",HModifyEmp ='" + user + "'" +
                         ",HPostID ='" + HPostID + "'" +
                        ",HRemark= '" + HRemark + "' Where HNumber='" + HNumber + "'");
                    }
                    i++;
                }
                oCN.Commit();
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = "导入成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                LogService.Write(e);
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region  岗位 设置列表/保存/编辑/删除方法
        /// <summary>
        /// 保存岗位
@@ -5764,6 +6400,279 @@
                return objJsonResult;
            }
        }
        #endregion
        #region 岗位 文件导入保存
        #region 岗位 文件上传
        [Route("Gy_Post/Gy_Post_Excel")]
        [HttpPost]
        public object Gy_Post_Excel()
        {
            try
            {
                //获取文件名称
                var file = HttpContext.Current.Request.Files[0];
                //获取文件物理路径
                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
                //保存文件
                file.SaveAs(ExcelPath);
                NpoiHelper np = new NpoiHelper();
                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
                //删除文件
                File.Delete(ExcelPath);
                //创建临时表
                DataTable tb2 = new DataTable("dt2");
                //添加列名
                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
                {
                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
                }
                //模板缺少列 但需要从数据库中查询出来显示在页面的字段
                tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID
                //添加数据
                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
                {
                    DataRow row = tb2.NewRow();
                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
                    {
                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
                    }
                    tb2.Rows.Add(row);
                }
                var error = "";
                //查询没有的列
                if (!tb2.Columns.Contains("组织代码"))
                    error += "没有找到【组织代码】的标题,";
                if (!tb2.Columns.Contains("组织名称"))
                    error += "没有找到【组织名称】的标题,";
                if (!tb2.Columns.Contains("岗位"))
                    error += "没有找到【岗位名称】的标题,";
                if (!tb2.Columns.Contains("岗位代码"))
                    error += "没有找到【岗位代码】的标题,";
                if (!tb2.Columns.Contains("备注"))
                    error += "没有找到【备注】的标题,";
                if (!tb2.Columns.Contains("助记码"))
                    error += "没有找到【助记码】的标题,";
                if (error.Length > 0)
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = $"Excel模板存在错误,{error}\r\n";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
                {
                    string HProcessName = "";
                    string HProcessNum = "";
                    string HORGNumber = "";
                    string HORGName = "";
                    HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位"].ToString());
                    HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位代码"].ToString());
                    HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString());
                    HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString());
                    //检查物料
                    int index = i + 1;
                    if (HORGNumber != "")
                    {
                        //查询组织
                        ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where  HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,组织不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        //岗位名称
                        if (HProcessName == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,岗位名称不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //岗位代码
                        if (HProcessNum == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,岗位代码不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "第" + index + "行,组织代码为空";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = error;
                objJsonResult.data = tb2;
                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("Gy_Post/Gy_Post_btnSave")]
        [HttpPost]
        public object Gy_Post_btnSave([FromBody] JObject sMainSub)
        {
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string user = sArray[1].ToString();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Gy_Post_Edit", 1, false, user))
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = "无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
                foreach (JObject item in Excel)
                {
                    Dictionary<string, string> dic = new Dictionary<string, string>();
                    foreach (var itm in item.Properties())
                    {
                        dic.Add(itm.Name, itm.Value.ToString());
                    }
                    list.Add(dic);
                }
                oCN.BeginTran();
                int i = 1;
                foreach (Dictionary<string, string> item in list)
                {
                    string HOrgID = item["HOrgID"].ToString();//组织ID
                    string HName = item["岗位"].ToString();
                    string HNumber = item["岗位代码"].ToString();
                    string HRemark = item["备注"].ToString();
                    string HHelpCode = item["助记码"].ToString();
                    string HUseFlag = "未检测";
                    string HShortNumber;
                    HShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码
                    if (HShortNumber.Trim() == "")
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!短代码为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    int HEndFlag = 1;//末级标志
                    int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级
                    if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim()))
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    ds = oCN.RunProcReturn("select * from Gy_Post where HNumber='" + HNumber + "'", "Gy_Post");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        oCN.RunProc("Insert into " + "Gy_Post" +
                    " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                    ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " +
                    " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + 0 +
                    "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + HUseFlag + "','" + user + "','" + HOrgID + "')");
                    }
                    else
                    {
                        oCN.RunProc("Update " + "Gy_Post" + " set " +
                        "HName='" + HName + "'" +
                        ",HShortNumber='" + HShortNumber + "'" +
                        ",HHelpCode='" + HHelpCode + "'" +
                        ",HModifyTime='" + DateTime.Now + "'" +
                        ",HUSEORGID='" + HOrgID + "'" +
                        ",HModifyEmp ='" + user + "'" +
                        ",HRemark= '" + HRemark + "' Where HNumber='" + HNumber + "'");
                    }
                    i++;
                }
                oCN.Commit();
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = "导入成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                LogService.Write(e);
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region  调拨类型  设置列表/保存/编辑/删除方法
@@ -9170,6 +10079,262 @@
        }
        #endregion
        #region 异常反馈类型 文件导入保存
        #region 异常反馈类型 文件上传
        [Route("Gy_ErrMsgBackType/Gy_ErrMsgBackType_Excel")]
        [HttpPost]
        public object Gy_ErrMsgBackType_Excel()
        {
            try
            {
                //获取文件名称
                var file = HttpContext.Current.Request.Files[0];
                //获取文件物理路径
                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
                //保存文件
                file.SaveAs(ExcelPath);
                NpoiHelper np = new NpoiHelper();
                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
                //删除文件
                File.Delete(ExcelPath);
                //创建临时表
                DataTable tb2 = new DataTable("dt2");
                //添加列名
                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
                {
                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
                }
                //模板缺少列 但需要从数据库中查询出来显示在页面的字段
                tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID
                //添加数据
                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
                {
                    DataRow row = tb2.NewRow();
                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
                    {
                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
                    }
                    tb2.Rows.Add(row);
                }
                var error = "";
                //查询工艺路线没有的列
                if (!tb2.Columns.Contains("组织代码"))
                    error += "没有找到【组织代码】的标题,";
                if (!tb2.Columns.Contains("组织名称"))
                    error += "没有找到【组织名称】的标题,";
                if (!tb2.Columns.Contains("异常反馈类型"))
                    error += "没有找到【异常反馈类型名称】的标题,";
                if (!tb2.Columns.Contains("异常反馈类型代码"))
                    error += "没有找到【异常反馈类型代码】的标题,";
                if (error.Length > 0)
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = $"Excel模板存在错误,{error}\r\n";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
                {
                    string HProcessName = "";
                    string HProcessNum = "";
                    string HORGNumber = "";
                    string HORGName = "";
                    HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["异常反馈类型"].ToString());
                    HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["异常反馈类型代码"].ToString());
                    HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString());
                    HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString());
                    //检查物料
                    int index = i + 1;
                    if (HORGNumber != "")
                    {
                        //查询组织
                        ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where  HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,组织不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        //异常类型名称
                        if (HProcessName == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,异常反馈类型名称不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //异常类型代码
                        if (HProcessNum == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,异常反馈类型代码不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "第" + index + "行,组织代码为空";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = error;
                objJsonResult.data = tb2;
                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("Gy_ErrMsgBackType/Gy_ErrMsgBackType_btnSave")]
        [HttpPost]
        public object Gy_ErrMsgBackType_btnSave([FromBody] JObject sMainSub)
        {
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string user = sArray[1].ToString();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Gy_ErrType_Edit", 1, false, user))
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = "无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
                foreach (JObject item in Excel)
                {
                    Dictionary<string, string> dic = new Dictionary<string, string>();
                    foreach (var itm in item.Properties())
                    {
                        dic.Add(itm.Name, itm.Value.ToString());
                    }
                    list.Add(dic);
                }
                oCN.BeginTran();
                int i = 1;
                foreach (Dictionary<string, string> item in list)
                {
                    string HOrgID = item["HOrgID"].ToString();//组织ID
                    string HProcessName = item["异常反馈类型"].ToString();
                    string HProcessNum = item["异常反馈类型代码"].ToString();
                    string HRemark = item["备注"].ToString();
                    string sShortNumber;
                    sShortNumber = DBUtility.ClsPub.GetShortNumber(HProcessNum);//短代码
                    if (sShortNumber.Trim() == "")
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!短代码为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    int HEndFlag = 1;//末级标志
                    int HLevel = DBUtility.ClsPub.GetLevel(HProcessNum); //等级
                    if (!DBUtility.ClsPub.AllowNumber(HProcessNum.Trim()))
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    ds = oCN.RunProcReturn("select * from Gy_ErrMsgBackType where HNumber='" + HProcessNum + "'", "Gy_ErrMsgBackType");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        oCN.RunProc("Insert into "  + "Gy_ErrMsgBackType " +
                    " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                    ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " +
                    " Values('" + HProcessNum + "','" + HProcessName + "','" +  "','" + sShortNumber + "'," + 0 +
                    "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + HOrgID + "')");
                    }
                    else
                    {
                        oCN.RunProc("update  Gy_ErrMsgBackType set HUSEORGID=" + HOrgID + ",HRemark='" + HRemark + "'  where HNumber='" + HProcessNum + "'");
                    }
                    i++;
                }
                oCN.Commit();
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = "导入成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                LogService.Write(e);
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region  不良现象  设置列表/保存/编辑/删除方法
        /// <summary>
        ///  不良现象 保存
@@ -10073,6 +11238,274 @@
        }
        #endregion
        #region 防错装置 文件导入保存
        #region 防错装置 文件上传
        [Route("Gy_PreventErrMould/Gy_PreventErrMould_Excel")]
        [HttpPost]
        public object Gy_PreventErrMould_Excel()
        {
            try
            {
                //获取文件名称
                var file = HttpContext.Current.Request.Files[0];
                //获取文件物理路径
                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
                //保存文件
                file.SaveAs(ExcelPath);
                NpoiHelper np = new NpoiHelper();
                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
                //删除文件
                File.Delete(ExcelPath);
                //创建临时表
                DataTable tb2 = new DataTable("dt2");
                //添加列名
                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
                {
                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
                }
                //模板缺少列 但需要从数据库中查询出来显示在页面的字段
                tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID
                //添加数据
                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
                {
                    DataRow row = tb2.NewRow();
                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
                    {
                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
                    }
                    tb2.Rows.Add(row);
                }
                var error = "";
                //查询没有的列
                if (!tb2.Columns.Contains("组织代码"))
                    error += "没有找到【组织代码】的标题,";
                if (!tb2.Columns.Contains("组织名称"))
                    error += "没有找到【组织名称】的标题,";
                if (!tb2.Columns.Contains("防错装置名称"))
                    error += "没有找到【防错装置名称】的标题,";
                if (!tb2.Columns.Contains("防错装置代码"))
                    error += "没有找到【防错装置代码】的标题,";
                if (!tb2.Columns.Contains("备注"))
                    error += "没有找到【备注】的标题,";
                if (!tb2.Columns.Contains("助记码"))
                    error += "没有找到【助记码】的标题,";
                if (error.Length > 0)
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = $"Excel模板存在错误,{error}\r\n";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
                {
                    string HProcessName = "";
                    string HProcessNum = "";
                    string HORGNumber = "";
                    string HORGName = "";
                    HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["防错装置名称"].ToString());
                    HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["防错装置代码"].ToString());
                    HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString());
                    HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString());
                    //检查物料
                    int index = i + 1;
                    if (HORGNumber != "")
                    {
                        //查询组织
                        ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where  HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,组织不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        //防错装置名称
                        if (HProcessName == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,防错装置名称不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //防错装置代码
                        if (HProcessNum == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,防错装置代码不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "第" + index + "行,组织代码为空";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = error;
                objJsonResult.data = tb2;
                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("Gy_PreventErrMould/Gy_PreventErrMould_btnSave")]
        [HttpPost]
        public object Gy_PreventErrMould_btnSave([FromBody] JObject sMainSub)
        {
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string user = sArray[1].ToString();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Gy_PreventErrMould_Edit", 1, false, user))
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = "无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
                foreach (JObject item in Excel)
                {
                    Dictionary<string, string> dic = new Dictionary<string, string>();
                    foreach (var itm in item.Properties())
                    {
                        dic.Add(itm.Name, itm.Value.ToString());
                    }
                    list.Add(dic);
                }
                oCN.BeginTran();
                int i = 1;
                foreach (Dictionary<string, string> item in list)
                {
                    string HOrgID = item["HOrgID"].ToString();//组织ID
                    string HName = item["防错装置名称"].ToString();
                    string HNumber = item["防错装置代码"].ToString();
                    string HRemark = item["备注"].ToString();
                    string HHelpCode = item["助记码"].ToString();
                    string HShortNumber;
                    HShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码
                    if (HShortNumber.Trim() == "")
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!短代码为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    int HEndFlag = 1;//末级标志
                    int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级
                    if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim()))
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    ds = oCN.RunProcReturn("select * from Gy_PreventErrMould where HNumber='" + HNumber + "'", "Gy_PreventErrMould");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        oCN.RunProc("Insert into " + "Gy_PreventErrMould" +
                    " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                    ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " +
                    " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + 0 +
                    "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + HOrgID + "')");
                    }
                    else
                    {
                        oCN.RunProc("Update " + "Gy_PreventErrMould" + " set " +
                        "HName='" + HName + "'" +
                        ",HShortNumber='" + HShortNumber + "'" +
                        ",HHelpCode='" + HHelpCode + "'" +
                        ",HModifyTime='" + DateTime.Now + "'" +
                        ",HUSEORGID='" + HOrgID + "'" +
                        ",HModifyEmp ='" + user + "'" +
                        ",HRemark= '" + HRemark + "' Where HNumber='" + HNumber + "'");
                    }
                    i++;
                }
                oCN.Commit();
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = "导入成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                LogService.Write(e);
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region  防错装置  设置列表/保存/编辑/删除方法
        /// <summary>
        ///  防错装置 保存
@@ -10844,7 +12277,7 @@
            try
            {
                //删除权限
                if (!DBUtility.ClsPub.Security_Log("Gy_CheckNoteItem_Drop", 1, false, user))
                if (!DBUtility.ClsPub.Security_Log("Gy_CheckNoteItem_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
@@ -10883,6 +12316,279 @@
                return objJsonResult;
            }
        }
        #endregion
        #region 启动检查项目 文件导入保存
        #region 启动检查项目 文件上传
        [Route("Gy_CheckNoteItem/Gy_CheckNoteItem_Excel")]
        [HttpPost]
        public object Gy_CheckNoteItem_Excel()
        {
            try
            {
                //获取文件名称
                var file = HttpContext.Current.Request.Files[0];
                //获取文件物理路径
                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
                //保存文件
                file.SaveAs(ExcelPath);
                NpoiHelper np = new NpoiHelper();
                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
                //删除文件
                File.Delete(ExcelPath);
                //创建临时表
                DataTable tb2 = new DataTable("dt2");
                //添加列名
                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
                {
                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
                }
                //模板缺少列 但需要从数据库中查询出来显示在页面的字段
                tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID
                //添加数据
                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
                {
                    DataRow row = tb2.NewRow();
                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
                    {
                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
                    }
                    tb2.Rows.Add(row);
                }
                var error = "";
                //查询没有的列
                if (!tb2.Columns.Contains("组织代码"))
                    error += "没有找到【组织代码】的标题,";
                if (!tb2.Columns.Contains("组织名称"))
                    error += "没有找到【组织名称】的标题,";
                if (!tb2.Columns.Contains("启动检查项目名称"))
                    error += "没有找到【启动检查项目名称】的标题,";
                if (!tb2.Columns.Contains("启动检查项目代码"))
                    error += "没有找到【启动检查项目代码】的标题,";
                if (!tb2.Columns.Contains("备注"))
                    error += "没有找到【备注】的标题,";
                if (!tb2.Columns.Contains("助记码"))
                    error += "没有找到【助记码】的标题,";
                if (error.Length > 0)
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = $"Excel模板存在错误,{error}\r\n";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
                {
                    string HProcessName = "";
                    string HProcessNum = "";
                    string HORGNumber = "";
                    string HORGName = "";
                    HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["启动检查项目名称"].ToString());
                    HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["启动检查项目代码"].ToString());
                    HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString());
                    HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString());
                    //检查物料
                    int index = i + 1;
                    if (HORGNumber != "")
                    {
                        //查询组织
                        ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where  HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,组织不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        //启动检查项目名称
                        if (HProcessName == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,启动检查项目名称不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //启动检查项目代码
                        if (HProcessNum == "")
                        {
                            objJsonResult.code = CodeConstant.FAIL;
                            objJsonResult.count = CountConstant.FAIL;
                            objJsonResult.Message = "第" + index + "行,启动检查项目代码不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "第" + index + "行,组织代码为空";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = error;
                objJsonResult.data = tb2;
                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("Gy_CheckNoteItem/Gy_CheckNoteItem_btnSave")]
        [HttpPost]
        public object Gy_CheckNoteItem_btnSave([FromBody] JObject sMainSub)
        {
            var _value = sMainSub["sMainSub"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string user = sArray[1].ToString();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Gy_CheckNoteItem_Edit", 1, false, user))
                {
                    objJsonResult.code = CodeConstant.FAIL;
                    objJsonResult.count = CountConstant.FAIL;
                    objJsonResult.Message = "无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
                foreach (JObject item in Excel)
                {
                    Dictionary<string, string> dic = new Dictionary<string, string>();
                    foreach (var itm in item.Properties())
                    {
                        dic.Add(itm.Name, itm.Value.ToString());
                    }
                    list.Add(dic);
                }
                oCN.BeginTran();
                int i = 1;
                foreach (Dictionary<string, string> item in list)
                {
                    string HOrgID = item["HOrgID"].ToString();//组织ID
                    string HName = item["启动检查项目名称"].ToString();
                    string HNumber = item["启动检查项目代码"].ToString();
                    string HRemark = item["备注"].ToString();
                    string HHelpCode = item["助记码"].ToString();
                    string HShortNumber;
                    HShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码
                    if (HShortNumber.Trim() == "")
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!短代码为空!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    int HEndFlag = 1;//末级标志
                    int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级
                    string HUseFlag = "未检测";
                    if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim()))
                    {
                        objJsonResult.code = CodeConstant.FAIL;
                        objJsonResult.count = CountConstant.FAIL;
                        objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    ds = oCN.RunProcReturn("select * from Gy_CheckNoteItem where HNumber='" + HNumber + "'", "Gy_CheckNoteItem");
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        oCN.RunProc("Insert into " + "Gy_CheckNoteItem" +
                    " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                    ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID,HCheckPostID) " +
                    " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + 0 +
                    "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + HUseFlag + "','" + user + "','" + HOrgID + "','" + 0 + "')");
                    }
                    else
                    {
                        oCN.RunProc("Update " + "Gy_CheckNoteItem" + " set " +
                        "HName='" + HName + "'" +
                        ",HShortNumber='" + HShortNumber + "'" +
                        ",HHelpCode='" + HHelpCode + "'" +
                        ",HModifyTime='" + DateTime.Now + "'" +
                        ",HUSEORGID='" + HOrgID + "'" +
                        ",HModifyEmp ='" + user + "'" +
                        ",HRemark= '" + HRemark + "' Where HNumber='" + HNumber + "'");
                    }
                    i++;
                }
                oCN.Commit();
                objJsonResult.code = CodeConstant.SUCCEED;
                objJsonResult.count = CountConstant.SUCCEED;
                objJsonResult.Message = "导入成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                LogService.Write(e);
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region  休息日  设置列表/保存/编辑/删除方法
@@ -13173,6 +14879,14 @@
                    objjson.data = null;
                    return objjson;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    objjson.code = "0";
                    objjson.count = 1;
                    objjson.Message = "该设备有多个计划单或点检规程,手动选着" ;
                    objjson.data = null;
                    return objjson;
                }
                else
                {
                    objjson.code = "1";
@@ -13214,19 +14928,22 @@
                switch (Type)
                {
                    case "DJ":
                        HView = "h_v_QJ_GetDotCheckItemList";
                        HView = "h_v_Sc_MouldDotCheckPlanBillList";
                        break;
                    case "BY":
                        HView = "h_v_Sc_MouldMaintainPlanBillList";
                        break;
                    default:
                        objjson.code = "0";
                        objjson.count = 0;
                        objjson.Message = "设备模块类型错误!";
                        objjson.Message = "模具模块类型错误!";
                        objjson.data = null;
                        return objjson;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                //string sql = string.Format(@"select * from " + HView + " where HInterID = " + EquipProjectID);
                string sql = string.Format(@"Exec h_p_Sb_GetCheckItem_PDA '" + MouldProjectID + "','" + Type + "','" + HDate + "'");
                string sql = string.Format(@"Exec h_p_Sb_GetCheckItemMouldFile_PDA '" + MouldProjectID + "','" + Type + "','" + HDate + "'");
                ds = oCN.RunProcReturn(sql, HView);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
@@ -13236,6 +14953,14 @@
                    objjson.data = null;
                    return objjson;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    objjson.code = "0";
                    objjson.count = 1;
                    objjson.Message = "该模具有多个计划单,手动选着";
                    objjson.data = null;
                    return objjson;
                }
                else
                {
                    objjson.code = "1";