WebAPI/Controllers/BaseSet/Gy_QCCheckClassController.cs
@@ -182,9 +182,55 @@
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    oCN.BeginTran();
                    //
                    //删除前控制=========================================
                    ds = oCN.RunProcReturn("Exec h_p_Gy_QCCheckClass_BeforeDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_QCCheckClass_BeforeDelCtrl");
                    if (ds == null)
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除前判断失败!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //=========================================================
                    if (oDept.DeleteByID(HItemID))
                    {
                        //删除后控制=========================================
                        DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_QCCheckClass_AfterDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_QCCheckClass_AfterDelCtrl");
                        if (ds2 == null)
                        {
                            oCN.RollBack();
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "删除后判断失败!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                        {
                            oCN.RollBack();
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //=========================================================
                        oCN.Commit();
                        //写入日志
                        ClsPub.Add_Log("", "删除项目,代码:" + oDeptHlp.omodel.HNumber + ",名称:" + oDeptHlp.omodel.HName, ClsPub.CurUserName);
                        //更新上级为 末级
@@ -196,6 +242,7 @@
                    }
                    else
                    {
                        oCN.RollBack();
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "删除失败";
@@ -268,8 +315,11 @@
                string HHelpCode = list[0].HHelpCode;
                string HRemark = list[0].HRemark;
                bool HStopflag = list[0].HStopflag;
                bool HUseFlag = list[0].HUseFlag;
                string HUseFlag = list[0].HUseFlag;
                long HQCCheckClassID = list[0].HQCCheckClassID;
                string HMakeEmp = list[0].HMakeEmp;
                long HUSEORGID = list[0].HUSEORGID;
                long HCREATEORGID = list[0].HCREATEORGID;
                if (!DBUtility.ClsPub.AllowNumber(HNumber))
                {
@@ -282,17 +332,66 @@
                //若MAINDI重复则重新获取
                oCN.BeginTran();
                //保存前控制=========================================
                DataSet ds = oCN.RunProcReturn("Exec h_p_Gy_QCCheckClass_BeforeSaveCtrl " + msg4 + ",'1'", "h_p_Gy_QCCheckClass_BeforeSaveCtrl");
                if (ds == null)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存前判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //=========================================================
                //主表
                oCN.RunProc("Insert Into Gy_QCCheckClass " +
                "(HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                ",HLevel,HEndFlag,HStopflag,HRemark,HUseFlag) " +
                ",HLevel,HEndFlag,HStopflag,HRemark" +
                 ",HMakeEmp,HMakeTime,HUSEORGID,HCREATEORGID,HUseFlag) " +
                " values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "','" + HItemID + "'" +
                ",'1',0,'" + Convert.ToString(HStopflag ? 1 : 0) + "','" + HRemark + "','未使用')");
                ",'1',0,'" + Convert.ToString(HStopflag ? 1 : 0) + "','" + HRemark + "'" +
                ",'" + HMakeEmp + "',getdate()," + HUSEORGID + "," + HCREATEORGID + ",'" + HUseFlag + "')");
                //修改上级为非末级代码
                if (list[0].HItemID.ToString() != "")
                {
                    oCN.RunProc("Update Gy_QCCheckClass set HEndflag=0 where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                }
                //保存后控制=========================================
                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_QCCheckClass_AfterSaveCtrl " + msg4 + ",'1'", "h_p_Gy_QCCheckClass_AfterSaveCtrl");
                if (ds2 == null)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存后判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //=========================================================
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
@@ -348,7 +447,7 @@
                //反序列化
                msg2 = "[" + msg2.ToString() + "]";
                List<MaintenanceAcceptItem> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MaintenanceAcceptItem>>(msg2);
                List<CheckItem> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<CheckItem>>(msg2);
                long HItemID = int.Parse(msg3);
                string HNumber = list[0].HNumber;
@@ -357,8 +456,10 @@
                long HParentID = list[0].HParentID.ToString() == "" ? 0 : list[0].HParentID;
                string HHelpCode = list[0].HHelpCode;
                string HRemark = list[0].HRemark;
                string HStopflag = list[0].HStopflag;
                bool HStopflag = list[0].HStopflag;
                string HUseFlag = list[0].HUseFlag;
                string HModifyEmp = msg4;
                long HUSEORGID = list[0].HUSEORGID;
                if (!DBUtility.ClsPub.AllowNumber(HNumber))
                {
@@ -381,10 +482,36 @@
                //若MAINDI重复则重新获取
                oCN.BeginTran();
                //保存前控制=========================================
                DataSet ds = oCN.RunProcReturn("Exec h_p_Gy_QCCheckClass_BeforeSaveCtrl " + msg4 + ",'1'", "h_p_Gy_QCCheckClass_BeforeSaveCtrl");
                if (ds == null)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存前判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //=========================================================
                //主表
                oCN.RunProc("Update Gy_QCCheckClass set " +
                    " HNumber='" + HNumber + "'" +
                    ",HName='" + HName + "'" +
                    ",HModifyEmp='" + HModifyEmp + "'" +
                    ",HModifyTime=getdate()" +
                     ",HUSEORGID='" + HUSEORGID + "'" +
                    ",HShortNumber='" + HShortNumber + "'" +
                    ",HHelpCode='" + HHelpCode + "'" +
                    ",HParentID=" + HParentID +
@@ -395,6 +522,30 @@
                //将上级 为非末级
                oCN.RunProc("Update Gy_QCCheckClass set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                //
                //保存后控制=========================================
                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_QCCheckClass_AfterSaveCtrl " + msg4 + ",'1'", "h_p_Gy_QCCheckClass_AfterSaveCtrl");
                if (ds2 == null)
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存后判断失败!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //=========================================================
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
@@ -463,10 +614,10 @@
        }
        #endregion
        #region 校验项目列表 文件上传
        [Route("Gy_QCCheckClass/Gy_Process_Excel")]
        #region 校验项目分类列表 文件上传
        [Route("Gy_QCCheckClass/Gy_QCCheckClass_Excel")]
        [HttpPost]
        public json Gy_Process_Excel()
        public json Gy_QCCheckClass_Excel()
        {
            json res = new json();
            try
@@ -492,7 +643,8 @@
                {
                    provisional.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
                }
                //模板缺少列 但需要从数据库中查询出来显示在页面的字段
                provisional.Columns.Add("HOrgID", typeof(Int32));//组织ID
                //添加数据
                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
                {
@@ -517,12 +669,39 @@
                for (int i = 0; i <= provisional.Rows.Count - 1; i++)
                {
                    string HNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["代码"].ToString());
                    string HName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["名称"].ToString());
                    string HHelpCode = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["助记码"]);
                    string HRemark = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["备注"].ToString());
                    string HQCCheckClassName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["检验项目分类"].ToString());
                    string HQCCheckClassNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["检验项目分类代码"].ToString());
                    string HORGNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["组织代码"].ToString());
                    string HORGName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["组织名称"].ToString());
                    //获取真实行数
                    int line = 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)
                        {
                            res.code = "0";
                            res.count = 0;
                            res.Message = "第" + line + "行,组织不存在!";
                            res.data = null;
                            return res;
                        }
                        else
                        {
                            provisional.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
                    }
                    else
                    {
                        res.code = CodeConstant.FAIL;
                        res.count = CountConstant.FAIL;
                        res.Message = "第" + line + "行,组织代码为空";
                        res.data = null;
                        return res;
                    }
                }
                res.code = "1";
@@ -551,17 +730,29 @@
            var error = "";
            //查询没有的列
            if (!provisional.Columns.Contains("代码"))
                error += "没有找到【代码】的标题,";
            if (!provisional.Columns.Contains("组织代码"))
                error += "没有找到【组织代码】的标题,";
            if (!provisional.Columns.Contains("名称"))
                error += "没有找到【名称】的标题,";
            if(!provisional.Columns.Contains("检验项目分类代码"))
                error += "没有找到【检验项目分类代码】的标题,";
            if (!provisional.Columns.Contains("组织名称"))
                error += "没有找到【组织名称】的标题,";
            if (!provisional.Columns.Contains("检验项目分类"))
                error += "没有找到【检验项目分类】的标题,";
            if (!provisional.Columns.Contains("助记码"))
                error += "没有找到【助记码】的标题,";
            if (!provisional.Columns.Contains("备注"))
                error += "没有找到【备注】的标题,";
            return error;
        }
        #endregion
        #region 校验项目列表 导入(保存)
        [Route("Gy_QCCheckClass/Gy_Process_btnSave")]
        #region 校验项目分类列表 导入(保存)
        [Route("Gy_QCCheckClass/Gy_QCCheckClass_btnSave")]
        [HttpPost]
        public object Gy_Group_btnSave([FromBody] JObject sMainSub)
        {
@@ -573,7 +764,7 @@
            string organ = sArray[2].ToString();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Gy_Group_Edit", 1, false, user))
                if (!DBUtility.ClsPub.Security_Log("Gy_QCCheckClass_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
@@ -599,8 +790,9 @@
                int i = 1;
                foreach (Dictionary<string, string> item in list)
                {
                    string HNumber = item["代码"].ToString();
                    string HName = item["名称"].ToString();
                    string HNumber = item["检验项目分类代码"].ToString();
                    string HUSEORGID = item["HOrgID"].ToString();
                    string HName = item["检验项目分类"].ToString();
                    string HHelpCode = item["助记码"];
                    string HRemark = item["备注"].ToString();
@@ -633,12 +825,12 @@
                    {
                        string sql = "insert into Gy_QCCheckClass (HName,HNumber,HShortNumber,HLevel,HHelpCode,HParentID,HStopflag,HEndFlag,HRemark,HUseFlag, HUSEORGID, HCREATEORGID, HMakeTime,HMakeEmp)" +
                            $"values('{HName}', '{HNumber}', '{sShortNumber}',{HLevel},'',0,'0','0','{HRemark}', '未使用', '{organ}', '{organ}', '{System.DateTime.Now.ToString("G")}', '{user}')";
                            $"values('{HName}', '{HNumber}', '{sShortNumber}',{HLevel},'',0,'0','0','{HRemark}', '未使用', '{HUSEORGID}', '{HUSEORGID}', '{System.DateTime.Now.ToString("G")}', '{user}')";
                        oCN.RunProc(sql);
                    }
                    else
                    {
                        oCN.RunProc("update  Gy_QCCheckClass  set  HName='" + HName + "', HHelpCode='" + HHelpCode + "', HModifyEmp = '" + user + "', HModifyTime = '" + System.DateTime.Now.ToString("G") + "'where HNumber='" + HNumber + "'");
                        oCN.RunProc("update  Gy_QCCheckClass  set  HName='" + HName + "', HHelpCode='" + HHelpCode + "', HModifyEmp = '" + user + "', HModifyTime = '" + System.DateTime.Now.ToString("G") + "',HUSEORGID="+ HUSEORGID + ",HRemark='"+HRemark+"' where HNumber='" + HNumber + "'");
                    }
                    i++;