|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Web;
|
|
|
using Estsh.Web.Dal;
|
|
|
using Estsh.Web.Util;
|
|
|
using System.Collections;
|
|
|
using System.Data;
|
|
|
using System.IO;
|
|
|
using System.Text;
|
|
|
|
|
|
namespace Estsh.Core.Services
|
|
|
{
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 作者:张茂忠
|
|
|
* 创建时间:2013.05.13
|
|
|
* 描述:零件关键数据Service层
|
|
|
* 修改日志:
|
|
|
*
|
|
|
*
|
|
|
* *************************************************************************************************/
|
|
|
public class EDIKeyDataDefineService
|
|
|
{
|
|
|
EDIKeyDataDefineDal dal = new EDIKeyDataDefineDal(RemotingProxyProvider._remotingProxy);
|
|
|
/// 根据查询条件得出结果集
|
|
|
/// </summary>
|
|
|
/// <param name="aWhere">查询条件</param>
|
|
|
/// <returns>符合条件的结果集</returns>
|
|
|
//public ArrayList GetQuery(string aWhere, ref DataTable dt)
|
|
|
//{
|
|
|
// return dal.GetQuery(aWhere, ref dt);
|
|
|
//}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据分页条件获取分页菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="AdjustOrderName"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
public Hashtable GetQuery(String where, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
|
|
|
|
|
|
|
|
result = dal.GetQuery(where, pager.pageSize, pager.pageNo);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断数据是否存在
|
|
|
/// </summary>
|
|
|
/// <param name="aPartID">零件ID</param>
|
|
|
/// <param name="aProcessID">制程ID</param>
|
|
|
/// <param name="aKeyDataID">关键数据ID</param>
|
|
|
/// <returns></returns>
|
|
|
public bool GetEDICSN(string CSN)
|
|
|
{
|
|
|
return dal.GetEDICSN(CSN);
|
|
|
}
|
|
|
public bool GetEDIVIN(string VIN)
|
|
|
{
|
|
|
return dal.GetEDIVIN(VIN);
|
|
|
}
|
|
|
public bool GetEDIBillId(string BillID)
|
|
|
{
|
|
|
return dal.GetEDIBillId(BillID);
|
|
|
}
|
|
|
|
|
|
///// <summary>
|
|
|
///// 获取零件号信息
|
|
|
///// </summary>
|
|
|
///// <returns></returns>
|
|
|
//public ArrayList GetPartID()
|
|
|
//{
|
|
|
// return dal.GetPartID();
|
|
|
//}
|
|
|
|
|
|
///// <summary>
|
|
|
///// 获取制程信息
|
|
|
///// </summary>
|
|
|
///// <returns></returns>
|
|
|
//public ArrayList GetProcessID()
|
|
|
//{
|
|
|
// return dal.GetProcessID();
|
|
|
//}
|
|
|
|
|
|
public ArrayList GetModelID()
|
|
|
{
|
|
|
return dal.GetModelID();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取关键数据信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ArrayList GetKeyDataID()
|
|
|
{
|
|
|
return dal.GetKeyDataID();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
///更改可用状态
|
|
|
/// </summary>
|
|
|
/// <param name="status">true or false</param>
|
|
|
/// <param name="dr">当前行</param>
|
|
|
/// <returns></returns>
|
|
|
public bool ChangeDetailStatus(bool status, DataRow dr)
|
|
|
{
|
|
|
return dal.ChangeDetailStatus(status, dr);
|
|
|
|
|
|
}
|
|
|
|
|
|
public int DeleteDetail(string csn)
|
|
|
{
|
|
|
return dal.DeleteDetail(csn);
|
|
|
}
|
|
|
public DataTable GetRow(string aWhere)
|
|
|
{
|
|
|
return dal.GetRow(aWhere);
|
|
|
}
|
|
|
|
|
|
public string insert(string csn, string vin, string billid, string modelname,string isProduction, string isShipping)
|
|
|
{
|
|
|
return dal.inEdiData(csn, vin, billid, modelname, isProduction, isShipping);
|
|
|
}
|
|
|
|
|
|
public string UpdateKeyData(string csn, string vin, string billID, string model_id, string isProduction, string isShipping)
|
|
|
{
|
|
|
return dal.UpdateKeyData(csn, vin, billID, model_id, isProduction, isShipping);
|
|
|
}
|
|
|
|
|
|
public DataTable GetEDIData(string aWhere, Pager pager, ref int totalCount)
|
|
|
{
|
|
|
return dal.GetEDIData(aWhere, pager, ref totalCount);
|
|
|
}
|
|
|
|
|
|
///// <summary>
|
|
|
///// 根据分页条件获取分页菜单数据
|
|
|
///// </summary>
|
|
|
///// <param name="menuName">查询条件</param>
|
|
|
///// <param name="pager"></param>
|
|
|
///// <param name="direction">排序方式</param>
|
|
|
///// <param name="sort">排序字段</param>
|
|
|
///// <returns></returns>
|
|
|
//public DataTable getTableListByPage(String where , String enabled_search, Pager pager, String direction, String sort, Boolean isPage)
|
|
|
//{
|
|
|
// DataTable result = null;
|
|
|
// int rowCount = 0;
|
|
|
|
|
|
|
|
|
// if (isPage)
|
|
|
// {
|
|
|
// rowCount = pager.pageSize;
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// rowCount = pager.pageSize;
|
|
|
// }
|
|
|
// result = dal.getListByPage(rowCount, pager.pageNo, where, sort + " ");
|
|
|
// return result;
|
|
|
//}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 读取文件并更新至数据库
|
|
|
/// </summary>
|
|
|
/// <param name="inputStream">文件全路径</param>
|
|
|
/// <param name="userInfo">登录用户信息</param>
|
|
|
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 csn = string.Empty;
|
|
|
string vin = string.Empty;
|
|
|
string billid = string.Empty;
|
|
|
string model_name = string.Empty;
|
|
|
string isProduction = string.Empty;
|
|
|
string isShipping = string.Empty;
|
|
|
StringBuilder ErrorMessage = new StringBuilder(1024);
|
|
|
// 验证数据
|
|
|
try
|
|
|
{
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
csn = dt.Rows[i][0].ToString().Trim();
|
|
|
|
|
|
// 跳过空行
|
|
|
if (string.IsNullOrEmpty(csn))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 判断零件号是否存在
|
|
|
//int partID = dal.GetCSN(csn);
|
|
|
//if (partID != 0)
|
|
|
//{
|
|
|
// ErrorMessage.Append("CSN: " + csn + " 已存在!" + Environment.NewLine);
|
|
|
//}
|
|
|
|
|
|
// 判断制程名称是否存在
|
|
|
vin = dt.Rows[i][1].ToString().Trim();
|
|
|
int processID = dal.GetVIN(vin);
|
|
|
if (processID != 0)
|
|
|
{
|
|
|
ErrorMessage.Append("vin: " + vin + " 已存在!" + Environment.NewLine);
|
|
|
}
|
|
|
|
|
|
// 判断工位名称是否存在
|
|
|
billid = dt.Rows[i][2].ToString().Trim();
|
|
|
int terminalID = dal.GetBillID(billid);
|
|
|
if (terminalID != 0)
|
|
|
{
|
|
|
ErrorMessage.Append("排序单号: " + billid + " 已存在!" + Environment.NewLine);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 判断关键数据名称是否存在
|
|
|
model_name = dt.Rows[i][3].ToString().Trim();
|
|
|
int ModelID = dal.GetModel(model_name);
|
|
|
if (ModelID == 0)
|
|
|
{
|
|
|
ErrorMessage.Append("配置信息: " + model_name + " 不存在!" + Environment.NewLine);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
ErrorMessage.Append("数据检查失败,数据中不能有公式或宏等,或用格式刷把所有数据格式同一后再试!");
|
|
|
}
|
|
|
|
|
|
if (ErrorMessage.Length != 0)
|
|
|
{
|
|
|
result.Add("message", ErrorMessage.ToString());
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < dt.Rows.Count; j++)
|
|
|
{
|
|
|
csn= dt.Rows[j][0].ToString().Trim();
|
|
|
vin=dt.Rows[j][1].ToString().Trim();
|
|
|
billid=dt.Rows[j][2].ToString().Trim();
|
|
|
model_name=dt.Rows[j][3].ToString().Trim();
|
|
|
isProduction = dt.Rows[j][4].ToString().Trim();
|
|
|
isShipping = dt.Rows[j][5].ToString().Trim();
|
|
|
int mode_ID=dal.GetModel(model_name);
|
|
|
try
|
|
|
{
|
|
|
dal.inEdiData(csn, vin, billid, mode_ID.ToString(), isProduction,isShipping);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
result.Add("message", "导入失败,请检查数据完整性!");
|
|
|
result.Add("flag", "error");
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
result.Add("message", "导入成功");
|
|
|
result.Add("flag", "error");
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
} |