|
|
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
|
|
|
{
|
|
|
/**
|
|
|
* 客户产线对应关系
|
|
|
*
|
|
|
* NOAH
|
|
|
*
|
|
|
*/
|
|
|
public class SRMDefineService
|
|
|
{
|
|
|
private SRMDefineDal dal = new SRMDefineDal(RemotingProxyProvider._remotingProxy);
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取菜单列表
|
|
|
/// </summary>
|
|
|
/// <param name="sqlWhere"></param>
|
|
|
/// <param name="orderBy"></param>
|
|
|
/// <returns></returns>
|
|
|
public List<TreeNode> getMenuList(string sqlWhere, string orderBy, String rootPath)
|
|
|
{
|
|
|
DataTable ds = dal.getList(sqlWhere, orderBy);
|
|
|
List<TreeNode> treeNodes = new List<TreeNode>();
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据分页条件获取分页菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="partNo"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
public ArrayList getSRMListByPage(String VIN, String txtStartTime, String txtEndTime, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
String strWhere = " where 1=1 AND del ='N' ";
|
|
|
if (VIN != null && !VIN.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and VIN like '%" + VIN.Trim() + "%'";
|
|
|
}
|
|
|
if ((txtStartTime != null && !txtStartTime.Trim().Equals("")) && (txtEndTime != null && !txtEndTime.Trim().Equals("")))
|
|
|
{
|
|
|
strWhere += " and create_ymd+' '+create_hms BETWEEN '" + txtStartTime + "' AND '" + txtEndTime + "'";
|
|
|
}
|
|
|
DataTable dt = dal.getListByPage(pager.pageSize, pager.pageNo, strWhere, sort + " ");
|
|
|
|
|
|
return DataTypeConvert.NewObject.DataTableToArrayList(dt);
|
|
|
}
|
|
|
//获取发运信息
|
|
|
public ArrayList getShipByPage(String VIN, String txtStartTime, String txtEndTime, String type, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
String strWhere = " where 1=1 AND del ='N' ";
|
|
|
if (VIN != null && !VIN.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and VIN like '%" + VIN.Trim() + "%'";
|
|
|
}
|
|
|
if ((txtStartTime != null && !txtStartTime.Trim().Equals("")) && (txtEndTime != null && !txtEndTime.Trim().Equals("")))
|
|
|
{
|
|
|
strWhere += " and inTime BETWEEN '" + txtStartTime + "' AND '" + txtEndTime + "'";
|
|
|
}
|
|
|
if (type != null && !type.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and status = '" + type + "'";
|
|
|
}
|
|
|
DataTable dt = dal.getListByPage(pager.pageSize, pager.pageNo, strWhere, sort + " ");
|
|
|
|
|
|
return DataTypeConvert.NewObject.DataTableToArrayList(dt);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取分页总数量
|
|
|
/// </summary>
|
|
|
/// <param name="partNo"></param>
|
|
|
/// <returns></returns>
|
|
|
public int getMenuCount(String VIN, String txtStartTime, String txtEndTime)
|
|
|
{
|
|
|
String strWhere = " where 1=1 AND del ='N' ";
|
|
|
if (VIN != null && !VIN.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and VIN like '%" + VIN.Trim() + "%'";
|
|
|
}
|
|
|
if ((txtStartTime != null && !txtStartTime.Trim().Equals("")) && (txtEndTime != null && !txtEndTime.Trim().Equals("")))
|
|
|
{
|
|
|
strWhere += " and create_ymd+' '+create_hms BETWEEN '" + txtStartTime + "' AND '" + txtEndTime + "'";
|
|
|
}
|
|
|
return dal.getCountWhere(strWhere);
|
|
|
}
|
|
|
//获取发运信息
|
|
|
public int getShipCount(String VIN, String txtStartTime, String txtEndTime, String type)
|
|
|
{
|
|
|
String strWhere = " where 1=1 AND del ='N' ";
|
|
|
if (VIN != null && !VIN.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and VIN like '%" + VIN.Trim() + "%'";
|
|
|
}
|
|
|
if ((txtStartTime != null && !txtStartTime.Trim().Equals("")) && (txtEndTime != null && !txtEndTime.Trim().Equals("")))
|
|
|
{
|
|
|
strWhere += " and inTime BETWEEN '" + txtStartTime + "' AND '" + txtEndTime + "'";
|
|
|
}
|
|
|
if (type != null && !type.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and status = '" + type + "'";
|
|
|
}
|
|
|
return dal.getCountWhere(strWhere);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int saveModelType(Hashtable htParams)
|
|
|
{
|
|
|
return dal.saveModelType(htParams);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int updateModelType(Hashtable htParams)
|
|
|
{
|
|
|
return dal.updateModelType(htParams);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看菜单详情
|
|
|
/// </summary>
|
|
|
/// <param name="type_id"></param>
|
|
|
/// <returns></returns>
|
|
|
public Hashtable getModelTypeDetail(String type_id)
|
|
|
{
|
|
|
type_id = " type_id = " + type_id;
|
|
|
DataTable dt = dal.getList(type_id, "");
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
result.Add("type_id", dt.Rows[0]["type_id"]);
|
|
|
result.Add("type_code", dt.Rows[0]["type_code"]);
|
|
|
result.Add("type_name", dt.Rows[0]["type_name"]);
|
|
|
result.Add("type_alias", dt.Rows[0]["type_alias"]);
|
|
|
result.Add("type_desc", dt.Rows[0]["type_desc"]);
|
|
|
result.Add("cust_pdline_name", dt.Rows[0]["cust_pdline_name"]);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int deleteSRM(String ids)
|
|
|
{
|
|
|
String[] idArray = ids.Split(',');
|
|
|
int count = 0;
|
|
|
foreach (String id in idArray)
|
|
|
{
|
|
|
if (!"".Equals(id))
|
|
|
{
|
|
|
count += this.dal.deleteSRM(id);
|
|
|
}
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据分页条件获取分页菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="menuName">查询条件</param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction">排序方式</param>
|
|
|
/// <param name="sort">排序字段</param>
|
|
|
/// <returns></returns>
|
|
|
public DataTable getTableListByPage(String vin, String txtStartTime, String txtEndTime, Pager pager, String direction, String sort, Boolean isPage)
|
|
|
{
|
|
|
DataTable result = null;
|
|
|
int rowCount = 0;
|
|
|
|
|
|
String strWhere = " where 1=1 AND del ='N' ";
|
|
|
if (vin != null && !vin.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and VIN like '%" + vin.Trim() + "%'";
|
|
|
}
|
|
|
if ((txtStartTime != null && !txtStartTime.Trim().Equals("")) && (txtEndTime != null && !txtEndTime.Trim().Equals("")))
|
|
|
{
|
|
|
strWhere += " and create_ymd+' '+create_hms BETWEEN '" + txtStartTime + "' AND '" + txtEndTime + "'";
|
|
|
}
|
|
|
|
|
|
if (isPage)
|
|
|
{
|
|
|
rowCount = pager.pageSize;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
rowCount = pager.pageSize;
|
|
|
}
|
|
|
result = dal.getListByPage(rowCount, pager.pageNo, strWhere, sort + " ");
|
|
|
return result;
|
|
|
}
|
|
|
//获取发运信息
|
|
|
public DataTable getShipByPage(String vin, String txtStartTime, String txtEndTime, String type, Pager pager, String direction, String sort, Boolean isPage)
|
|
|
{
|
|
|
DataTable result = null;
|
|
|
int rowCount = 0;
|
|
|
|
|
|
String strWhere = " where 1=1 AND del ='N' ";
|
|
|
if (vin != null && !vin.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and VIN like '%" + vin.Trim() + "%'";
|
|
|
}
|
|
|
if ((txtStartTime != null && !txtStartTime.Trim().Equals("")) && (txtEndTime != null && !txtEndTime.Trim().Equals("")))
|
|
|
{
|
|
|
strWhere += " and inTime BETWEEN '" + txtStartTime + "' AND '" + txtEndTime + "'";
|
|
|
}
|
|
|
if (type != null && !type.Trim().Equals(""))
|
|
|
{
|
|
|
strWhere += " and status = '" + type + "'";
|
|
|
}
|
|
|
|
|
|
|
|
|
if (isPage)
|
|
|
{
|
|
|
rowCount = pager.pageSize;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
rowCount = pager.pageSize;
|
|
|
}
|
|
|
result = dal.getListByPage(rowCount, pager.pageNo, strWhere, sort + " ");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 读取文件并更新至数据库
|
|
|
/// </summary>
|
|
|
/// <param name="inputStream">文件全路径</param>
|
|
|
/// <param name="userInfo">登录用户信息</param>
|
|
|
public Hashtable ReadExcelFile(Stream inputStream, int userId, string pdlineOff)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
Hashtable Cache = new Hashtable();
|
|
|
|
|
|
DataTable dt = AsposeExcelTools.ExcelFileToDataTable(inputStream);
|
|
|
|
|
|
DataView dv = new DataView(dt);
|
|
|
|
|
|
//去除第一行&重新排序
|
|
|
|
|
|
dv.AllowDelete = true;
|
|
|
dv[0].Delete();
|
|
|
|
|
|
dv.Sort = "Column1";
|
|
|
dt = dv.ToTable();
|
|
|
int importNo = 0;
|
|
|
if (dt == null)
|
|
|
{
|
|
|
result.Add("message", "导入数据为空,请重新导入");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
StringBuilder ErrorMessage = new StringBuilder(1024);
|
|
|
|
|
|
// 验证数据
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
|
|
|
string VIN = dt.Rows[i][31].ToString().Trim();
|
|
|
if (!VIN.Equals("") && VIN != null)
|
|
|
{
|
|
|
if (dal.GetVIN(VIN) != null)
|
|
|
{
|
|
|
result.Add("message", string.Format("第 {0} 行的VIN号:{1}已存在系统中,请检查后重新导入!", i + 1, VIN));
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Add("message", string.Format("第 {0} 行的VIN号数据为空,请检查后重新导入!", i + 1));
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
string _partNo = dt.Rows[i][9].ToString().Trim();
|
|
|
if (dal.GetCustPart(_partNo) == null)
|
|
|
{
|
|
|
result.Add("message", string.Format("第 {0} 行的客户零件号{1}不存在,请检查后重新导入!", i + 1, _partNo));
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
//获取最大导入序号
|
|
|
importNo = dal.GetImportNo() + 1;
|
|
|
if (importNo == 0)
|
|
|
{
|
|
|
result.Add("message", string.Format("导入序号有误!导入失败!"));
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
int abc = dal.InsertData(dt, importNo, userId, pdlineOff);
|
|
|
// 处理表身数据
|
|
|
if (abc == 1)
|
|
|
{
|
|
|
result.Add("message", "导入成功,已将SRM释放到生产线!");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
else if (abc == 2)
|
|
|
{
|
|
|
result.Add("message", "释放到生产线失败!");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
else if (abc == 3)
|
|
|
{
|
|
|
result.Add("message", "SRM导入失败!");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
else if (abc == 4)
|
|
|
{
|
|
|
result.Add("message", "SRM导入成功,只导入了SRM发运计划!");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.Add("message", "未提交成功!请联系管理员!");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |