using System; using System.Collections.Generic; using System.Linq; using System.Web; using Estsh.Web.Util; using System.Data; using Estsh.Web.Dal; using System.Collections; using System.IO; using System.Text; namespace Estsh.Core.Services { /** * 客户零件号关系管理 * * Fred * */ public class SysPartExtGroupService { private SysPartExtGroupDal dal = new SysPartExtGroupDal(RemotingProxyProvider._remotingProxy); /// /// 获取菜单列表 /// /// /// /// public List getMenuList(string sqlWhere, string orderBy,String rootPath) { DataTable ds = dal.getList(sqlWhere, orderBy); List treeNodes = new List(); for (int i = 0; i < ds.Rows.Count; i++) { TreeNode node = new TreeNode(); node.id = ds.Rows[i]["RUID"].ToString(); node.icon = ds.Rows[i]["MenuPicLink"].ToString(); node.name = ds.Rows[i]["MenuName"].ToString(); if (ds.Rows[i]["ParentMenuID"] == null || "0".Equals(ds.Rows[i]["ParentMenuID"].ToString().Trim())) { node.parentId = "0"; node.iconSkin = "diy01"; } else { node.parentId = ds.Rows[i]["ParentMenuID"].ToString(); node.url = rootPath + ds.Rows[i]["MenuLink"].ToString(); node.target = "frmright"; } treeNodes.Add(node); } return treeNodes; } /// /// 根据分页条件获取分页菜单数据 /// /// /// /// /// /// public ArrayList getDataListByPage(String part_no_search, Pager pager, String direction, String sort) { Hashtable result = new Hashtable(); String strWhere = " where 1=1 "; if (part_no_search != null && !part_no_search.Trim().Equals("")) { strWhere += " and b.part_no like '%" + part_no_search.Trim() + "%'"; } DataTable dt = dal.getListByPage(pager.pageSize, pager.pageNo, strWhere, sort + " " ); return DataTypeConvert.NewObject.DataTableToArrayList(dt); } /// /// 获取分页总数量 /// /// /// public int getMenuCount(String part_no_search) { String strWhere = " where 1=1 "; if (part_no_search != null && !part_no_search.Trim().Equals("")) { strWhere += " and b.part_no like '%" + part_no_search.Trim() + "%'"; } return dal.getCountWhere(strWhere); } /// /// 保存菜单数据 /// /// /// public int saveData(Hashtable htParams) { return dal.saveData(htParams); } /// /// 更新菜单数据 /// /// /// public int updateData(Hashtable htParams) { return dal.updateData(htParams); } /// /// 获取配置ID /// /// /// public int getModelID(string modelName) { return dal.GetModelID(modelName); } /// /// 查看信息是否存在 /// /// /// /// /// public DataTable checkExist(int partID) { return dal.checkExist(partID); } /// /// 获取总成零件ID /// /// /// public int getpartID(string partNo) { return dal.GetPartID(partNo); } /// /// 查看菜单详情 /// /// /// public Hashtable getDataDetail(String ruid) { ruid = " ruid = " + ruid; DataTable dt = dal.getList(ruid, ""); Hashtable result = new Hashtable(); result.Add("ruid", dt.Rows[0]["ruid"]); result.Add("part_no", dt.Rows[0]["part_no"]); result.Add("torque_job_no", dt.Rows[0]["torque_job_no"]); result.Add("torque_robot_no", dt.Rows[0]["torque_robot_no"]); result.Add("robot_offline_no", dt.Rows[0]["robot_offline_no"]); return result; } /// /// 删除菜单 /// /// /// public int deleteData(String ids) { String[] idArray = ids.Split(','); int count = 0; foreach (String id in idArray) { if (!"".Equals(id)) { count += this.dal.deleteData(id); } } return count; } /// /// 获取 站点 信息 /// BY NOAH /// /// public ArrayList getTerminalName() { Hashtable result = new Hashtable(); DataTable dt = dal.getTerminalName(); return DataTypeConvert.NewObject.DataTableToArrayList(dt); } /// /// 获取 产线 信息 /// BY NOAH /// /// public ArrayList getBoardName() { Hashtable result = new Hashtable(); DataTable dt = dal.getBoardName(); return DataTypeConvert.NewObject.DataTableToArrayList(dt); } /// /// 判断是否存在 用户输入的零件号 /// BY NOAH /// /// /// public String isExsitPart_no(String part_no) { return this.dal.isExsitPart_no(part_no); } /// /// 根据分页条件获取分页菜单数据 /// /// 查询条件 /// /// 排序方式 /// 排序字段 /// public DataTable getTableListByPage(String part_no_search, Pager pager, String direction, String sort, Boolean isPage) { DataTable result = null; int rowCount = 0; String strWhere = " where 1=1 "; if (part_no_search != null && !part_no_search.Trim().Equals("")) { strWhere += " and b.part_no like '%" + part_no_search.Trim() + "%'"; } if (isPage) { rowCount = pager.pageSize; } else { rowCount = pager.pageSize; } result = dal.getListByPage(rowCount, pager.pageNo, strWhere, sort + " " ); return result; } /// /// 读取文件并更新至数据库 /// /// 文件全路径 /// 登录用户信息 public Hashtable ReadExcelFile(Stream inputStream, int userId) { Hashtable result = new Hashtable(); Hashtable Cache = new Hashtable(); DataTable dt = AsposeExcelTools.ExcelFileToDataTable(inputStream); dt.Rows[0].Delete(); if (dt == null) { result.Add("message", "导入数据为空,请重新导入"); result.Add("flag", "error"); return result; } string partNo = string.Empty; string torque_job_no = string.Empty; string torque_robot_no = string.Empty; string robot_offline_no = string.Empty; StringBuilder ErrorMessage = new StringBuilder(1024); for (int i = 0; i < dt.Rows.Count; i++) { partNo = dt.Rows[i][0].ToString().Trim(); int partID = getpartID(partNo); torque_job_no = dt.Rows[i][2].ToString().Trim(); torque_robot_no = dt.Rows[i][3].ToString().Trim(); robot_offline_no = dt.Rows[i][4].ToString().Trim(); // 跳过空行 if (string.IsNullOrEmpty(partNo)) { continue; } if (partID == 0) { ErrorMessage.Append("零件号" + partNo + "不存在!" + Environment.NewLine); } if (torque_job_no.Length != 2) { ErrorMessage.Append("扭矩Job编号必须是两位(如1,可以写成01)!" + Environment.NewLine); } if (torque_robot_no.Length != 2) { ErrorMessage.Append("扭矩机器人轨迹编号必须是两位(如1,可以写成01)!" + Environment.NewLine); } if (robot_offline_no.Length != 2) { ErrorMessage.Append("下线机器人轨迹编号必须是两位(如1,可以写成01)!" + Environment.NewLine); } } if (ErrorMessage.Length != 0) { result.Add("message", ErrorMessage.ToString()); result.Add("flag", "error"); return result; } // 处理表身数据 if (dal.InsertData(dt)) { result.Add("message", "导入成功"); result.Add("flag", "error"); return result; } else { result.Add("message", "导入失败"); result.Add("flag", "error"); return result; } } } }