| | |
| | | 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 |
| | |
| | | string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; |
| | | |
| | | /// <summary> |
| | | /// 送货单表头信息 |
| | | /// 获取单据号与单据内码 |
| | | /// </summary> |
| | | /// <param name="sMsg"></param> |
| | | /// <returns></returns> |
| | |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | //判断用户数是否大于客户账号数 |
| | | DataSet ds1 = oCN.RunProcReturn("Exec h_p_Xt_BaseInfo ", "h_p_Xt_BaseInfo"); |
| | | if (DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HBack"]) != "0") |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = ds1.Tables[0].Rows[0]["HBackRemark"].ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | string sql = string.Format(@" select a.* from Gy_UserByOrgRelation a |
| | | where a.HUserID = '{0}' and a.HOrgID = '{1}'", UserName, HOrgName); |
| | | DataSet _ds = oCnLoc.RunProcReturn(sql, "h_p_Xt_UserRelationOrg_Check"); |
| | |
| | | return objjson; ; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 登录根据ic卡获取信息 |
| | | /// </summary> |
| | | /// <param name="HBarCode"></param> |
| | | /// <returns></returns> |
| | | [Route("Web/GetUserByICCard")] |
| | | [HttpGet] |
| | | public object GetUserByICCard(string HBarCode) |
| | | { |
| | | try |
| | | { |
| | | DataSet ds = null; |
| | | ClsCN oCnLoc = new ClsCN(); |
| | | DAL.ClsUser oUser = new DAL.ClsUser(); |
| | | string sql = string.Format(@" select a.* from h_v_Gy_Czygl_Login a |
| | | where a.HICNumber = '{0}'", HBarCode); |
| | | ds = oCnLoc.RunProcReturn(sql, "h_v_Gy_Czygl_Login"); |
| | | |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "无此ic卡对应员工信息!"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | |
| | | objjson.code = "1"; |
| | | objjson.count = 1; |
| | | objjson.Message = "信息获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "登录异常!" + e.Message; |
| | | objjson.data = null; |
| | | return objjson; ; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 菜单栏 |
| | | /// </summary> |
| | |
| | | } |
| | | } |
| | | |
| | | #region 不良原因 文件导入保存 |
| | | #region 不良原因 文件上传 |
| | | [Route("Gy_BadReason/Gy_BadReason_Excel")] |
| | | [HttpPost] |
| | | public object Gy_BadReason_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("HDeptID", typeof(Int32));//部门ID |
| | | tb2.Columns.Add("HProcID", 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 (!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 HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | string HDeptNumber = ""; |
| | | string HDeptName = ""; |
| | | string HProcNumber = ""; |
| | | string HProcName = ""; |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良原因"].ToString()); |
| | | HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良原因代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | HDeptNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认部门代码"].ToString()); |
| | | HDeptName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认部门"].ToString()); |
| | | HProcNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认工序代码"].ToString()); |
| | | HProcName = 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(); |
| | | } |
| | | if (HDeptNumber != "") |
| | | { |
| | | //查询部门 |
| | | ds = oCN.RunProcReturn("select * from Gy_Department where HNumber='" + HDeptNumber + "' and Hname='" + HDeptName + "'", "Gy_Department"); |
| | | |
| | | 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]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HDeptID"] = 0; |
| | | } |
| | | if (HProcNumber != "") |
| | | { |
| | | //查询部门 |
| | | ds = oCN.RunProcReturn("select * from Gy_Process where HNumber='" + HProcNumber + "' and Hname='" + HProcName + "'", "Gy_Process"); |
| | | |
| | | 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]["HProcID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HProcID"] = 0; |
| | | } |
| | | |
| | | //不良原因名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良原因名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //不良原因代码 |
| | | if (HNum == "") |
| | | { |
| | | 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_BadReason/Gy_BadReason_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_BadReason_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_BadReason_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 HDeptID = item["HDeptID"].ToString();//部门ID |
| | | string HProcID = item["HProcID"].ToString();//工序ID |
| | | string HName = item["不良原因"].ToString(); |
| | | string HNumber = item["不良原因代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | 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(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_BadReason where HNumber='" + HNumber + "'", "Gy_BadReason"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + "Gy_BadReason " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HDeptID,HProcID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HBadTypeID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HDeptID.ToString() + "," + HProcID.ToString() + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "'," + 0 + ")", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update Gy_BadReason"+ " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + sShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HLevel=" + HLevel.ToString() + |
| | | ",HDeptID=" + HDeptID.ToString() + |
| | | ",HProcID=" + HProcID.ToString() + |
| | | ",HRemark= '" + HRemark + "' Where HNumber='" + HNumber + "'", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | |
| | | 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> |
| | | /// 保存不良类型 |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #region 不良类型 文件导入保存 |
| | | #region 不良类型 文件上传 |
| | | [Route("Gy_BadType/Gy_BadType_Excel")] |
| | | [HttpPost] |
| | | public object Gy_BadType_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("HGroupID", 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 HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | string HGroupNumber = ""; |
| | | string HGroupName = ""; |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良类型"].ToString()); |
| | | HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良类型代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | HGroupNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认班组代码"].ToString()); |
| | | HGroupName = 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(); |
| | | } |
| | | if(HGroupNumber != "") |
| | | { |
| | | //查询班组 |
| | | ds = oCN.RunProcReturn("select * from Gy_Group where HNumber='" + HGroupNumber + "' and Hname='" + HGroupName + "'", "Gy_Group"); |
| | | |
| | | 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]["HGroupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HGroupID"] = 0; |
| | | } |
| | | |
| | | |
| | | //不良类型名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良类型名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //不良类型代码 |
| | | if (HNum == "") |
| | | { |
| | | 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_BadType/Gy_BadType_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_BadType_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_BadType_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 HGroupID = item["HGroupID"].ToString();//班组ID |
| | | string HName = item["不良类型"].ToString(); |
| | | string HNumber = item["不良类型代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | 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(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_BadType where HNumber='" + HNumber + "'", "Gy_BadType"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into Gy_BadType" + " " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HGroupID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HUSEORGID,HCREATEORGID,HUseFlag,HMakeEmp,HMakeTime) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HGroupID.ToString() + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "'," + HOrgID + "," + HOrgID + ",'" + "未检测" + "','" + user + "',getdate())", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_BadType " + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HRemark= '" + HRemark + "'" + |
| | | ",HGroupID= '" + HGroupID + "'" + |
| | | ",HModifyEmp= '" + user + "'" + |
| | | ",HModifyTime=getdate()" + |
| | | ",HUSEORGID=" + HOrgID + |
| | | " 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 |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #region 不良后果 文件导入保存 |
| | | #region 不良后果 文件上传 |
| | | [Route("Gy_BadResult/Gy_BadResult_Excel")] |
| | | [HttpPost] |
| | | public object Gy_BadResult_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 HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良后果"].ToString()); |
| | | HNum = 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(); |
| | | } |
| | | |
| | | //不良后果名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良后果名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //不良后果代码 |
| | | if (HNum == "") |
| | | { |
| | | 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_BadResult/Gy_BadResult_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_BadResult_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_BadResult_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 sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | 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(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_BadResult where HNumber='" + HNumber + "'", "Gy_BadResult"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into Gy_BadResult" + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HISsystemSet,HCREATEORGID,HERPItemID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + 0 + "','" + HOrgID + "','" + 0 + "')", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_BadResult " + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HRemark= '" + HRemark + "'" + |
| | | ",HModifyEmp= '" + user + "'" + |
| | | ",HModifyTime=getdate()" + |
| | | ",HUSEORGID=" + HOrgID + |
| | | " 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 |
| | | |
| | | #endregion |
| | | |
| | | |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #region 供应商分类 文件导入保存 |
| | | #region 供应商分类 文件上传 |
| | | [Route("Gy_SupType/Gy_SupType_Excel")] |
| | | [HttpPost] |
| | | public object Gy_SupType_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 HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["供应商分类"].ToString()); |
| | | HNum = 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(); |
| | | } |
| | | |
| | | //供应商分类名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,供应商分类名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //供应商分类代码 |
| | | if (HNum == "") |
| | | { |
| | | 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_SupType/Gy_SupType_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_SupType_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_SupType_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 sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | 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(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_SupType where HNumber='" + HNumber + "'", "Gy_SupType"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + "Gy_SupType " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_SupType " + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + sShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HRemark= '" + HRemark + "'" + |
| | | ",HModifyEmp= '" + user + "'" + |
| | | ",HModifyTime=getdate()" + |
| | | ",HUSEORGID=" + HOrgID + |
| | | " 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 |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region 工艺参数分类 设置列表/保存/编辑/删除方法 |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | |
| | | #region 客户分类 文件导入保存 |
| | | #region 客户分类 文件上传 |
| | | [Route("Gy_CusType/Gy_CusType_Excel")] |
| | | [HttpPost] |
| | | public object Gy_CusType_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 HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户分类"].ToString()); |
| | | HNum = 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(); |
| | | } |
| | | |
| | | //客户分类名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,客户分类名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //客户分类代码 |
| | | if (HNum == "") |
| | | { |
| | | 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_CusType/Gy_CusType_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_CusType_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_CusType_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 sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | 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(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_CusType where HNumber='" + HNumber + "'", "Gy_CusType"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + " Gy_CusType" + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_CusType " + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + sShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HRemark= '" + HRemark + "'" + |
| | | ",HModifyEmp= '" + user + "'" + |
| | | ",HModifyTime=getdate()" + |
| | | ",HUSEORGID=" + HOrgID + |
| | | " 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 |
| | | |
| | | #endregion |
| | | |
| | | #region 盘点方案 设置列表/保存/编辑/删除方法 |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #region 不良现象 文件导入保存 |
| | | #region 不良现象 文件上传 |
| | | [Route("Gy_BadPhenomena/Gy_BadPhenomena_Excel")] |
| | | [HttpPost] |
| | | public object Gy_BadPhenomena_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 HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良现象"].ToString()); |
| | | HNum = 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(); |
| | | } |
| | | |
| | | //不良现象名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良现象名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //不良现象代码 |
| | | if (HNum == "") |
| | | { |
| | | 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_BadPhenomena/Gy_BadPhenomena_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_BadPhenomena_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_BadPhenomena_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 sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | 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(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_BadPhenomena where HNumber='" + HNumber + "'", "Gy_BadPhenomena"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + "Gy_BadPhenomena " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_BadPhenomena " + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + sShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HRemark= '" + HRemark + "'" + |
| | | ",HModifyEmp= '" + user + "'" + |
| | | ",HModifyTime=getdate()" + |
| | | ",HUSEORGID=" + HOrgID + |
| | | " 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 |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region 项目类别 设置列表/保存/编辑/删除方法 |
| | |
| | | /// <returns></returns> |
| | | [Route("Web/GetCheckItemID")] |
| | | [HttpGet] |
| | | public object GetCheckItemID(string HName,string HProName) |
| | | public object GetCheckItemID(string HName,string HProName,string HSourceID) |
| | | { |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCCheckProjectList_Main where 物料名称='"+HName+ "' and 工序名称='" + HProName + "' order by 日期 desc ", "h_v_Gy_QCCheckProjectList_Main"); |
| | | ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCCheckProjectList_Main where 物料名称='"+HName+ "' and 工序名称='" + HProName + "' and HSourceID='" + HSourceID + "' order by 日期 desc ", "h_v_Gy_QCCheckProjectList_Main"); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCCheckProjectList_Main where 物料名称='" + HName + "' and 工序名称='" + HProName + "' order by 日期 desc ", "h_v_Gy_QCCheckProjectList_Main"); |
| | | } |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | |
| | | public int HLevel { get; set; } |
| | | public string Hurl { get; set; } |
| | | public string HPicNum { get; set; } |
| | | public string HShowMode { get; set; } |
| | | public List<MenuLoad> childMenus { get; set; } |
| | | } |
| | | |
| | |
| | | { |
| | | List<MenuLoad> mu = new List<MenuLoad>(); //以父子级结构存放菜单清单信息 |
| | | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //数据库操作工具 |
| | | string sql = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum from Gy_MenuDefineSet where HMakeName = '" + HMakeName + "' and HType = '" + HType + "' order by HPosition"; |
| | | string sql = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum,HShowMode from Gy_MenuDefineSet where HMakeName = '" + HMakeName + "' and HType = '" + HType + "' order by HPosition"; |
| | | ds = oCn.RunProcReturn(sql, "Gy_MenuDefineSet"); //查询当前用户的自定义菜单数据 |
| | | if (ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0) //判断当前用户是否有设置过自定义信息,若记录数为0,则没有设置过,加载所有的菜单信息 |
| | | { |
| | | string sql1 = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum from Gy_MenuDefineSet where HMakeName=" + |
| | | string sql1 = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum,HShowMode from Gy_MenuDefineSet where HMakeName=" + |
| | | "(select top 1 c.GroupName from Gy_Czygl a left join System_UserGroupInfo b on a.Czybm = b.UserId " + |
| | | "left join System_UserGroup c on b.GroupId = c.GroupID where a.Czymc ='"+HMakeName+"' order by len(c.GroupName ))"; |
| | | ds = oCn.RunProcReturn(sql1, "Gy_MenuDefineSet"); //查询用户绑定的角色 是否设置菜单信息 取角色名称最短的一个 |
| | | if ((ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0)) |
| | | { |
| | | sql = "Select * from Gy_Menu_1 where HType = '" + HType + "' Order by HPosition,len(HitemID),HitemID "; |
| | | ds = oCn.RunProcReturn(sql, "Gy_Menu"); |
| | | ds = oCn.RunProcReturn(sql, "Gy_Menu_1"); |
| | | } |
| | | } |
| | | |
| | |
| | | tbj.HPartentID = ds.Tables[0].Rows[i]["HPartentID"].ToString(); |
| | | tbj.HLevel = int.Parse(ds.Tables[0].Rows[i]["HLevel"].ToString()); |
| | | tbj.Hurl = ds.Tables[0].Rows[i]["Hurl"].ToString(); |
| | | tbj.HShowMode = ds.Tables[0].Rows[i]["HShowMode"].ToString(); |
| | | if (ds.Tables[0].Rows[i]["HPicNum"] != null) |
| | | { |
| | | tbj.HPicNum = ds.Tables[0].Rows[i]["HPicNum"].ToString(); |
| | |
| | | tbjson.HName = dt.Rows[i]["HName"].ToString(); |
| | | tbjson.HLevel = tree[m].HLevel; |
| | | tbjson.Hurl = dt.Rows[i]["Hurl"].ToString(); |
| | | tbjson.HShowMode = dt.Rows[i]["HShowMode"].ToString(); |
| | | if (dt.Rows[i]["HPicNum"] != null) |
| | | { |
| | | tbjson.HPicNum = dt.Rows[i]["HPicNum"].ToString(); |
| | |
| | | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); |
| | | string sql = "select a.HSubFuncID, a.HCaption,a.HPicNum,b.Hurl from Xt_UserFastMenu as a join Gy_Menu_1 as b on a.HSubFuncID = b.HItemID where a.HUserID = '" + HMakeName + "' and b.HType = '" + HType + "' Order by a.HItemID"; |
| | | ds = oCn.RunProcReturn(sql, "Xt_UserFastMenu"); //获取Xt_UserFastMenu中该用户设置的自定义菜单信息,用于在前端加载 |
| | | |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | sql = "select a.HSubFuncID, a.HCaption,a.HPicNum,b.Hurl from Xt_UserFastMenu as a join Gy_Menu_1 as b on a.HSubFuncID = b.HItemID where a.HUserID = 'admin' and b.HType = '" + HType + "' Order by a.HItemID"; |
| | | ds = oCn.RunProcReturn(sql, "Xt_UserFastMenu"); //获取Xt_UserFastMenu中该用户设置的自定义菜单信息,用于在前端加载 |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 金帅WMS接口 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Web/WMSBarcodeQuery")] |
| | | [HttpGet] |
| | | public object WMSBarcodeQuery(DateTime dateTime, string UserName, string PassWord) |
| | | { |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | //权限判定 |
| | | DAL.ClsUser oUser = new DAL.ClsUser(); |
| | | DataSet DS; |
| | | DS = oCN.RunProcReturn("select * from Gy_Czygl where Czymc='" + UserName.Trim() + "' and Czmm='" + DBUtility.ClsPub.StrToPsd(PassWord.Trim()) + "' ", "Gy_Czygl"); |
| | | if (UserName == "" || UserName != "售后条码查询") |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "用户不对!"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | if (DS == null || DS.Tables[0].Rows.Count == 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "密码错误!"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | ds = oCN.RunProcReturn("exec h_p_WMSBarcodeQuery '" + dateTime + "'", "h_p_WMSBarcodeQuery"); |
| | | |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | objjson.code = "1"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + ex.ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |