You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1522 lines
80 KiB
C#
1522 lines
80 KiB
C#
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 NPOI.HSSF.UserModel;
|
|
using Com.Estsh.MES.App;
|
|
using System.Text;
|
|
using Aspose.Cells;
|
|
using DbCommon;
|
|
|
|
/***************************************************************************************************
|
|
*
|
|
* 作者:王勇
|
|
*
|
|
* *************************************************************************************************/
|
|
namespace Estsh.Core.Services
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class ProdOrderReleaseService
|
|
{
|
|
private ProdOrderReleaseDal dal = new ProdOrderReleaseDal(RemotingProxyProvider._remotingProxy);
|
|
|
|
#region 目视单打印
|
|
|
|
public Hashtable getStockOrderListByPage(Pager pager, String direction, String sort, string cbCustPDLine)
|
|
{
|
|
string str = "";
|
|
if (string.IsNullOrEmpty(cbCustPDLine))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
Hashtable result = new Hashtable();
|
|
result = dal.getStockOrderListByPage(pager.pageSize, pager.pageNo, cbCustPDLine, str);
|
|
return result;
|
|
|
|
}
|
|
|
|
public Hashtable getStockOrderDetailByPage(Pager pager, String direction, int order_id)
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
result = dal.getStockOrderDetailByPage(pager.pageSize, pager.pageNo, order_id);
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
public Hashtable updatePrintData(string order_id)
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
result = this.dal.updatePrintData(order_id);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取客户产线列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ArrayList GetCustPDLine()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
DataTable dt = dal.GetCustPDLine();
|
|
return DataTypeConvert.NewObject.DataTableToArrayList(dt);
|
|
|
|
}
|
|
|
|
public string releaseOrder(string cbCustPDLine, string cbShift, string qty)
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
string str = dal.releaseOrder(cbCustPDLine, cbShift, qty);
|
|
return str;
|
|
|
|
}
|
|
|
|
public DataTable updatePrintData_2(string order_id, string cbCustPDLine)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
dt = this.dal.updatePrintData_2(order_id, cbCustPDLine);
|
|
|
|
return dt;
|
|
}
|
|
|
|
public DataTable getForPintData(string order_id, string cbCustPDLine)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
dt = this.dal.getForPintData(order_id, cbCustPDLine);
|
|
|
|
return dt;
|
|
}
|
|
|
|
public DataTable getTopOrderBy(string step, string cbCustPDLine)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
|
|
dt = this.dal.getTopOrderBy(step, cbCustPDLine);
|
|
|
|
return dt;
|
|
}
|
|
|
|
public DataTable getOrderByTraySeq(string traySeq, string cbCustPDLine)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
|
|
dt = this.dal.getOrderByTraySeq(traySeq, cbCustPDLine);
|
|
|
|
return dt;
|
|
|
|
}
|
|
|
|
public string getShipNo(string shipNo)
|
|
{
|
|
|
|
string _shipNo = "";
|
|
|
|
_shipNo = this.dal.getShipNo(shipNo);
|
|
|
|
return _shipNo;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 读取采购订单文件并更新至数据库
|
|
/// </summary>
|
|
/// <param name="inputStream">文件全路径</param>
|
|
/// <param name="userInfo">登录用户信息</param>
|
|
public Hashtable ReadExcelFile(Stream inputStream, string cbCustPDLine)
|
|
{
|
|
try
|
|
{
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
|
List<string> SqlStrings = new List<string>();
|
|
List<Hashtable> Parameters = new List<Hashtable>();
|
|
|
|
Hashtable Params = new Hashtable();
|
|
|
|
Hashtable Cache = new Hashtable();
|
|
|
|
DataTable dt = new DataTable();
|
|
dt = AsposeExcelTools.ExcelFileToDataTable(inputStream);
|
|
|
|
//StreamReader sr = new StreamReader(inputStream);
|
|
//string srStr = sr.ReadToEnd();
|
|
|
|
//DataSet ds = HtmlTableParser.ParseHtmlTable(srStr, 1);
|
|
//dt = ds.Tables[0];
|
|
|
|
//判断EXCEL是否存在数据
|
|
if (dt.Rows.Count <= 0)
|
|
{
|
|
result.Add("message", "导入数据为空,请重新导入!");
|
|
result.Add("flag", "error");
|
|
return result;
|
|
}
|
|
|
|
|
|
//excel排序
|
|
if (cbCustPDLine == "1006")
|
|
{
|
|
DataView dv = new DataView(dt);
|
|
|
|
dv.Sort = "Column5,Column14,Column4";
|
|
|
|
dt = dv.ToTable();
|
|
}
|
|
else if (cbCustPDLine == "1005")
|
|
{
|
|
DataView dv = new DataView(dt);
|
|
|
|
dv.Sort = "Column5,Column14,Column4";
|
|
|
|
dt = dv.ToTable();
|
|
}
|
|
else if (cbCustPDLine == "1002")
|
|
{
|
|
DataView dv = new DataView(dt);
|
|
|
|
dv.Sort = "Column25";
|
|
|
|
dt = dv.ToTable();
|
|
}
|
|
else if (cbCustPDLine == "1004")
|
|
{
|
|
DataView dv = new DataView(dt);
|
|
|
|
dv.Sort = "Column2,Column8";
|
|
|
|
dt = dv.ToTable();
|
|
}
|
|
else if (cbCustPDLine == "1007")
|
|
{
|
|
dt.Rows[0].Delete();
|
|
dt.Rows[0].Delete();
|
|
|
|
DataView dv = new DataView(dt);
|
|
|
|
dv.Sort = "Column10";
|
|
|
|
dt = dv.ToTable();
|
|
}
|
|
else if (cbCustPDLine == "1008")
|
|
{
|
|
DataView dv = new DataView(dt);
|
|
|
|
dv.Sort = "Column1";
|
|
|
|
dt = dv.ToTable();
|
|
}
|
|
|
|
StringBuilder ErrorMessage = new StringBuilder(1024);
|
|
|
|
#region DFPV
|
|
|
|
if (Convert.ToInt32(cbCustPDLine) == 1002)
|
|
{
|
|
//验证数据
|
|
for (int i = 0; i < dt.Rows.Count - 1; i++)
|
|
{
|
|
//配置ID
|
|
string partNo = dt.Rows[i]["Column20"].ToString().Trim() + "-" + dt.Rows[i]["Column22"].ToString().Trim() + "00";
|
|
int part_id = this.dal.GetPartID(partNo);
|
|
|
|
if (part_id <= 0)
|
|
{
|
|
result.Add("message", partNo + ":配置信息未维护。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
//order_seq
|
|
string orderSeq = dt.Rows[i]["Column17"].ToString().Trim();
|
|
|
|
//工厂
|
|
//string custLineNo = dt.Rows[i]["Column3"].ToString();
|
|
|
|
//汇报点
|
|
//string reportPM = dt.Rows[i]["Column4"].ToString();
|
|
//if (reportPM.ToUpper() != "Z02")
|
|
//{
|
|
// result.Add("message", reportPM + ":汇报点不正确。");
|
|
// result.Add("flag", "FAIL");
|
|
// return result;
|
|
//}
|
|
|
|
//VIN
|
|
string vin = dt.Rows[i]["Column25"].ToString();
|
|
|
|
//上线时间
|
|
string dataYMDHMS = dt.Rows[i]["Column15"].ToString();
|
|
|
|
//查询客户产线
|
|
int custPdlineId = this.dal.GetCustPdlineId(part_id);
|
|
|
|
if (custPdlineId <= 0)
|
|
{
|
|
result.Add("message", partNo + ":配置未查询到对应产线。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
//car_no
|
|
string carNo = vin.Substring(vin.Length - 8, 8);
|
|
|
|
//判断流水号是否存在
|
|
string strOrderSeq = this.dal.ifOrderSeq(orderSeq, cbCustPDLine);
|
|
if (string.IsNullOrEmpty(strOrderSeq))
|
|
{
|
|
//判断VIN号是否存在
|
|
bool Bool = this.dal.ifVin(vin, cbCustPDLine);
|
|
if (Bool == false)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order ");
|
|
strSql.Append(" ( model_part_id ,order_seq ,cust_pdline ,status ,car_no ,vin ,count ,enabled )");
|
|
strSql.Append(" VALUES ( " + part_id + ",'" + orderSeq + "'," + custPdlineId + ",0,'" + carNo + "','" + vin + "',0,'Y' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
//查询所以总成信息
|
|
DataTable dt_detail = this.dal.GetDetail(part_id);
|
|
|
|
//查询配置是否对应前后排
|
|
DataTable dtLocationType = new DataTable();
|
|
dtLocationType = this.dal.getLocationType(part_id);
|
|
|
|
if (dtLocationType.Rows.Count <= 0)
|
|
{
|
|
result.Add("message", partNo + ":未维护座椅位置。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
int orderId = this.dal.GetOrderId(custPdlineId);
|
|
//记录后排数量
|
|
int locationR = 0;
|
|
|
|
for (int z = 0; z < dt_detail.Rows.Count; z++)
|
|
{
|
|
if (dt_detail.Rows[z]["part_location"].ToString() == "01")
|
|
{
|
|
strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,cust_line_no,part_type,on_line_time)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','" + "" + "','PT11','" + dataYMDHMS + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "01");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (dt_detail.Rows[z]["part_location"].ToString() == "02")
|
|
{
|
|
strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,cust_line_no,part_type,on_line_time)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','" + "" + "','PT12','" + dataYMDHMS + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "02");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
|
|
if (dt_detail.Rows[z]["arrange_flag"].ToString() == "R" && locationR == 0)
|
|
{
|
|
locationR++;
|
|
|
|
strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,cust_line_no,part_type,on_line_time)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','" + "" + "','PT20','" + dataYMDHMS + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "03");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
}
|
|
else
|
|
{
|
|
result.Add("message", "导入失败");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
result.Add("message", "导入成功");
|
|
result.Add("flag", "OK");
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 雷诺
|
|
|
|
if (Convert.ToInt32(cbCustPDLine) == 1007)
|
|
{
|
|
//验证数据
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
//配置ID
|
|
int part_id = this.dal.GetPartID(dt.Rows[i]["Column15"].ToString());
|
|
|
|
if (part_id <= 0)
|
|
{
|
|
result.Add("message", dt.Rows[i]["Column15"].ToString() + ":配置信息未维护。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
|
|
//order_seq
|
|
string orderSeq = dt.Rows[i]["Column10"].ToString().Trim();
|
|
|
|
//VIN
|
|
string vin = dt.Rows[i]["Column9"].ToString().Trim() + dt.Rows[i]["Column10"].ToString().Trim();
|
|
|
|
//上线时间
|
|
string dataYMD = dt.Rows[i]["Column11"].ToString();
|
|
string dataHMS = dt.Rows[i]["Column13"].ToString();
|
|
string dataYMDHMS = dataYMD + " " + dataHMS;
|
|
|
|
//car_no
|
|
|
|
string carNo = dt.Rows[i]["Column10"].ToString().Trim();
|
|
|
|
//判断流水号是否存在
|
|
string strOrderSeq = this.dal.ifOrderSeq(orderSeq, cbCustPDLine);
|
|
if (string.IsNullOrEmpty(strOrderSeq))
|
|
{
|
|
//判断VIN号是否存在
|
|
bool Bool = this.dal.ifVin(vin, cbCustPDLine);
|
|
if (Bool == false)
|
|
{
|
|
|
|
//查询客户产线
|
|
int custPdlineId = this.dal.GetCustPdlineId(part_id);
|
|
|
|
if (custPdlineId <= 0)
|
|
{
|
|
result.Add("message", dt.Rows[i]["Column15"].ToString() + ":配置未查询到对应产线。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order ");
|
|
strSql.Append(" ( model_part_id ,order_seq ,cust_pdline ,status ,car_no ,vin ,count ,enabled )");
|
|
strSql.Append(" VALUES ( " + part_id + ",'" + orderSeq + "'," + custPdlineId + ",0,'" + carNo + "','" + vin + "',0,'Y' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
//查询所以总成信息
|
|
DataTable dt_detail = this.dal.GetDetail(part_id);
|
|
|
|
//查询配置是否对应前后排
|
|
DataTable dtLocationType = new DataTable();
|
|
dtLocationType = this.dal.getLocationType(part_id);
|
|
|
|
if (dtLocationType.Rows.Count <= 0)
|
|
{
|
|
result.Add("message", dt.Rows[i]["Column15"].ToString() + ":未维护座椅位置。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
int orderId = this.dal.GetOrderId(custPdlineId);
|
|
//记录后排数量
|
|
int locationR = 0;
|
|
|
|
for (int z = 0; z < dt_detail.Rows.Count; z++)
|
|
{
|
|
if (dt_detail.Rows[z]["part_location"].ToString() == "01")
|
|
{
|
|
strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,part_type,on_line_time)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','PT11','" + dataYMDHMS + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "01");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (dt_detail.Rows[z]["part_location"].ToString() == "02")
|
|
{
|
|
strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,part_type,on_line_time)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','PT12','" + dataYMDHMS + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "02");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
|
|
if (dt_detail.Rows[z]["arrange_flag"].ToString() == "R" && locationR == 0)
|
|
{
|
|
locationR++;
|
|
|
|
strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,part_type,on_line_time)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','PT20','" + dataYMDHMS + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "03");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
}
|
|
else
|
|
{
|
|
result.Add("message", "导入失败");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
result.Add("message", "导入成功");
|
|
result.Add("flag", "OK");
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 本田通用
|
|
|
|
if (Convert.ToInt32(cbCustPDLine) == 1008)
|
|
{
|
|
|
|
|
|
//验证数据
|
|
for (int i = 0; i < dt.Rows.Count - 1; i++)
|
|
{
|
|
//配置ID
|
|
int part_id = this.dal.GetPartID(dt.Rows[i]["Column2"].ToString());
|
|
|
|
if (part_id <= 0)
|
|
{
|
|
result.Add("message", dt.Rows[i]["Column2"].ToString() + ":配置信息未维护。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
|
|
//order_seq
|
|
string orderSeq = dt.Rows[i]["Column1"].ToString();
|
|
|
|
//VIN
|
|
string vin = dt.Rows[i]["Column4"].ToString();
|
|
|
|
//上线时间
|
|
string dataYMD = dt.Rows[i]["Column5"].ToString();
|
|
string dataHMS = dt.Rows[i]["Column6"].ToString();
|
|
string dataYMDHMS = dataYMD + " " + dataHMS;
|
|
|
|
//car_no
|
|
|
|
string carNo = dt.Rows[i]["Column3"].ToString();
|
|
|
|
//判断流水号是否存在
|
|
string strOrderSeq = this.dal.ifOrderSeq(orderSeq, cbCustPDLine);
|
|
if (string.IsNullOrEmpty(strOrderSeq))
|
|
{
|
|
//判断VIN号是否存在
|
|
bool Bool = this.dal.ifVin(vin, cbCustPDLine);
|
|
if (Bool == false)
|
|
{
|
|
|
|
//查询客户产线
|
|
int custPdlineId = this.dal.GetCustPdlineId(part_id);
|
|
|
|
if (custPdlineId <= 0)
|
|
{
|
|
result.Add("message", dt.Rows[i]["Column1"].ToString() + ":配置未查询到对应产线。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order ");
|
|
strSql.Append(" ( model_part_id ,order_seq ,cust_pdline ,status ,car_no ,vin ,count ,enabled )");
|
|
strSql.Append(" VALUES ( " + part_id + ",'" + orderSeq + "'," + custPdlineId + ",0,'" + carNo + "','" + vin + "',0,'Y' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
//查询所以总成信息
|
|
DataTable dt_detail = this.dal.GetDetail(part_id);
|
|
|
|
//查询配置是否对应前后排
|
|
DataTable dtLocationType = new DataTable();
|
|
dtLocationType = this.dal.getLocationType(part_id);
|
|
|
|
if (dtLocationType.Rows.Count <= 0)
|
|
{
|
|
result.Add("message", dt.Rows[i]["Column1"].ToString() + ":未维护座椅位置。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
int orderId = this.dal.GetOrderId(custPdlineId);
|
|
//记录后排数量
|
|
int locationR = 0;
|
|
|
|
for (int z = 0; z < dt_detail.Rows.Count; z++)
|
|
{
|
|
if (dt_detail.Rows[z]["part_location"].ToString() == "01")
|
|
{
|
|
strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,part_type,on_line_time)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','PT11','" + dataYMDHMS + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "01");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (dt_detail.Rows[z]["part_location"].ToString() == "02")
|
|
{
|
|
strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,part_type,on_line_time)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','PT12','" + dataYMDHMS + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "02");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
|
|
if (dt_detail.Rows[z]["arrange_flag"].ToString() == "R" && locationR == 0)
|
|
{
|
|
locationR++;
|
|
|
|
strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,part_type,on_line_time)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','PT20','" + dataYMDHMS + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "03");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
}
|
|
else
|
|
{
|
|
result.Add("message", "导入失败");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
result.Add("message", "导入成功");
|
|
result.Add("flag", "OK");
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region M3M4 & X7前后排生产线
|
|
|
|
if (Convert.ToInt32(cbCustPDLine) == 1006 || Convert.ToInt32(cbCustPDLine) == 1005)
|
|
{
|
|
//验证数据
|
|
for (int i = 1; i < dt.Rows.Count - 1; i++)
|
|
{
|
|
if (dt.Rows[i]["Column15"].ToString() == "中央扶手")
|
|
{
|
|
continue;
|
|
}
|
|
DataRow[] dr = dt.Select("Column14='" + dt.Rows[i]["Column14"].ToString() + "'");
|
|
|
|
if (dr.Length <= 0)
|
|
{
|
|
result.Add("message", dt.Rows[i]["Column14"].ToString() + ":未查询到配置明细!");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
//查询总成零件号
|
|
string partName = this.dal.getOCN(dt.Rows[i]["Column12"].ToString());
|
|
if (string.IsNullOrEmpty(partName))
|
|
{
|
|
partName = this.dal.getPartName(dt.Rows[i]["Column12"].ToString());
|
|
}
|
|
|
|
//配置ID
|
|
int part_id = this.dal.GetPartID(partName);
|
|
|
|
string orderSeq = dt.Rows[i]["Column14"].ToString();
|
|
|
|
//总装产线
|
|
string custLineNo = dt.Rows[i]["Column5"].ToString();
|
|
|
|
//VIN
|
|
string vin = dt.Rows[i]["Column14"].ToString();
|
|
|
|
//car_no
|
|
|
|
string carNo = dt.Rows[i]["Column14"].ToString();
|
|
|
|
//查询客户产线
|
|
int custPdlineId = this.dal.GetCustPdlineId(part_id);
|
|
|
|
if (custPdlineId <= 0)
|
|
{
|
|
result.Add("message", dt.Rows[i]["Column12"].ToString() + ":配置未查询到对应产线。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
//查询配置是否对应前后排
|
|
DataTable dtLocationType = new DataTable();
|
|
|
|
DataTable dtLocationType2 = new DataTable();
|
|
dtLocationType2 = this.dal.getLocationType2(part_id);
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
bool isOK = false;
|
|
|
|
//判断流水号是否存在
|
|
string strOrderSeq = this.dal.ifOrderSeq(orderSeq, custPdlineId.ToString());
|
|
if (string.IsNullOrEmpty(strOrderSeq))
|
|
{
|
|
DataRow[] dr3 = null;
|
|
|
|
dr3 = dt.Select("Column14='" + dt.Rows[i]["Column14"].ToString() + "'");
|
|
|
|
if (dtLocationType2.Rows.Count > dr3.Length)
|
|
{
|
|
result.Add("message", dt.Rows[i]["Column14"].ToString() + ":流水号对应前后排信息不完整");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order ");
|
|
strSql.Append(" ( model_part_id ,order_seq ,cust_pdline ,status ,car_no ,vin ,count ,enabled )");
|
|
strSql.Append(" VALUES ( " + part_id + ",'" + orderSeq + "'," + custPdlineId + ",0,'" + carNo + "','" + vin + "',0,'Y' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
|
|
//查询所以总成信息
|
|
DataTable dt_detail = this.dal.GetDetail(part_id);
|
|
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
int orderId = this.dal.GetOrderId(custPdlineId);
|
|
//记录后排数量
|
|
int locationR = 0;
|
|
|
|
for (int z = 0; z < dt_detail.Rows.Count; z++)
|
|
{
|
|
if (dt_detail.Rows[z]["part_location"].ToString() == "01")
|
|
{
|
|
strSql = new StringBuilder();
|
|
|
|
bool boolIfOrderDetail = this.dal.IfOrderDetail(dt.Rows[i]["Column14"].ToString(), "PT11");
|
|
if (boolIfOrderDetail == false)
|
|
{
|
|
DataRow[] dr2 = null;
|
|
string printSeq = "";
|
|
string trayNo = "";
|
|
if (custPdlineId == 1005)
|
|
{
|
|
dr2 = dt.Select("Column14='" + dt.Rows[i]["Column14"].ToString() + "' and Column4='EW10'");
|
|
if (dr2.Length > 0)
|
|
{
|
|
printSeq = dr2[0][15].ToString();
|
|
trayNo = dr2[0][1].ToString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
printSeq = dt.Rows[i]["Column16"].ToString();
|
|
trayNo = dt.Rows[i]["Column2"].ToString();
|
|
}
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,cust_line_no,part_type,tray_no,print_seq)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','" + custLineNo + "','PT11','" + trayNo + "','" + printSeq + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "01");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (dt_detail.Rows[z]["part_location"].ToString() == "02")
|
|
{
|
|
strSql = new StringBuilder();
|
|
|
|
bool boolIfOrderDetail = this.dal.IfOrderDetail(dt.Rows[i]["Column14"].ToString(), "PT12");
|
|
if (boolIfOrderDetail == false)
|
|
{
|
|
|
|
DataRow[] dr2 = null;
|
|
string printSeq = "";
|
|
string trayNo = "";
|
|
if (custPdlineId == 1005)
|
|
{
|
|
dr2 = dt.Select("Column14='" + dt.Rows[i]["Column14"].ToString() + "' and Column4='EW11'");
|
|
if (dr2.Length > 0)
|
|
{
|
|
printSeq = dr2[0][15].ToString();
|
|
trayNo = dr2[0][1].ToString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
printSeq = dt.Rows[i]["Column16"].ToString();
|
|
trayNo = dt.Rows[i]["Column2"].ToString();
|
|
}
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,cust_line_no,part_type,tray_no,print_seq)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','" + custLineNo + "','PT12','" + trayNo + "','" + printSeq + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "02");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (dt_detail.Rows[z]["arrange_flag"].ToString() == "R" && locationR == 0)
|
|
{
|
|
bool boolIfOrderDetail = this.dal.IfOrderDetail(dt.Rows[i]["Column14"].ToString(), "PT20");
|
|
if (boolIfOrderDetail == false)
|
|
{
|
|
locationR++;
|
|
|
|
DataRow[] dr2 = null;
|
|
string printSeq = "";
|
|
string trayNo = "";
|
|
if (custPdlineId == 1005)
|
|
{
|
|
dr2 = dt.Select("Column14='" + dt.Rows[i]["Column14"].ToString() + "' and Column4<>'EW10' and Column4<>'EW11'");
|
|
if (dr2.Length > 0)
|
|
{
|
|
printSeq = dr2[0][15].ToString();
|
|
trayNo = dr2[0][1].ToString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
printSeq = dt.Rows[i]["Column16"].ToString();
|
|
trayNo = dt.Rows[i]["Column2"].ToString();
|
|
}
|
|
|
|
strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,cust_line_no,part_type,tray_no,print_seq)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','" + custLineNo + "','PT20','" + trayNo + "','" + printSeq + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "03");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
//}
|
|
}
|
|
}
|
|
result.Add("message", "导入成功");
|
|
result.Add("flag", "OK");
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 神龙一厂
|
|
|
|
if (Convert.ToInt32(cbCustPDLine) == 1004)
|
|
{
|
|
//验证数据
|
|
for (int i = 0; i < dt.Rows.Count - 1; i++)
|
|
{
|
|
//查询总成零件号
|
|
string partName = this.dal.getOCN(dt.Rows[i]["Column4"].ToString());
|
|
|
|
//配置ID
|
|
int part_id = this.dal.GetPartID(partName);
|
|
|
|
string orderSeq = dt.Rows[i]["Column8"].ToString();
|
|
|
|
//总装产线
|
|
string custLineNo = dt.Rows[i]["Column7"].ToString();
|
|
|
|
if (custLineNo != "UW5L2")
|
|
{
|
|
result.Add("message", custLineNo + ":生产线号不匹配。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
//VIN
|
|
string vin = dt.Rows[i]["Column8"].ToString();
|
|
|
|
//car_no
|
|
|
|
string carNo = dt.Rows[i]["Column8"].ToString();
|
|
|
|
//查询客户产线
|
|
int custPdlineId = this.dal.GetCustPdlineId(part_id);
|
|
|
|
if (custPdlineId <= 0)
|
|
{
|
|
result.Add("message", dt.Rows[i]["Column4"].ToString() + ":配置未查询到对应产线。");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
//查询配置是否对应前后排
|
|
DataTable dtLocationType = new DataTable();
|
|
|
|
DataTable dtLocationType2 = new DataTable();
|
|
dtLocationType2 = this.dal.getLocationType2(part_id);
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
bool isOK = false;
|
|
|
|
//判断流水号是否存在
|
|
string strOrderSeq = this.dal.ifOrderSeq(orderSeq, cbCustPDLine);
|
|
if (string.IsNullOrEmpty(strOrderSeq))
|
|
{
|
|
DataRow[] dr3 = null;
|
|
|
|
dr3 = dt.Select("Column8='" + dt.Rows[i]["Column8"].ToString() + "'");
|
|
|
|
if (dtLocationType2.Rows.Count != dr3.Length)
|
|
{
|
|
result.Add("message", dt.Rows[i]["Column8"].ToString() + ":流水号对应前后排信息不完整");
|
|
result.Add("flag", "FAIL");
|
|
return result;
|
|
}
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order ");
|
|
strSql.Append(" ( model_part_id ,order_seq ,cust_pdline ,status ,car_no ,vin ,count ,enabled )");
|
|
strSql.Append(" VALUES ( " + part_id + ",'" + orderSeq + "'," + custPdlineId + ",0,'" + carNo + "','" + vin + "',0,'Y' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
|
|
//查询所以总成信息
|
|
DataTable dt_detail = this.dal.GetDetail(part_id);
|
|
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
int orderId = this.dal.GetOrderId(custPdlineId);
|
|
//记录后排数量
|
|
int locationR = 0;
|
|
|
|
for (int z = 0; z < dt_detail.Rows.Count; z++)
|
|
{
|
|
if (dt_detail.Rows[z]["part_location"].ToString() == "01")
|
|
{
|
|
strSql = new StringBuilder();
|
|
|
|
bool boolIfOrderDetail = this.dal.IfOrderDetail(dt.Rows[i]["Column8"].ToString(), "PT11");
|
|
if (boolIfOrderDetail == false)
|
|
{
|
|
string trayNo = "";
|
|
|
|
trayNo = dt.Rows[i]["Column2"].ToString();
|
|
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,cust_line_no,part_type,tray_no)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','" + custLineNo + "','PT11','" + trayNo + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "01");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (dt_detail.Rows[z]["part_location"].ToString() == "02")
|
|
{
|
|
strSql = new StringBuilder();
|
|
|
|
bool boolIfOrderDetail = this.dal.IfOrderDetail(dt.Rows[i]["Column8"].ToString(), "PT12");
|
|
if (boolIfOrderDetail == false)
|
|
{
|
|
string trayNo = "";
|
|
|
|
trayNo = dt.Rows[i]["Column2"].ToString();
|
|
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,cust_line_no,part_type,tray_no)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','" + custLineNo + "','PT12','" + trayNo + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "02");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (dt_detail.Rows[z]["arrange_flag"].ToString() == "R" && locationR == 0)
|
|
{
|
|
bool boolIfOrderDetail = this.dal.IfOrderDetail(dt.Rows[i]["Column8"].ToString(), "PT20");
|
|
if (boolIfOrderDetail == false)
|
|
{
|
|
locationR++;
|
|
string trayNo = "";
|
|
|
|
trayNo = dt.Rows[i]["Column2"].ToString();
|
|
|
|
|
|
strSql = new StringBuilder();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_detail");
|
|
strSql.Append(" ( order_id,status ,enabled,cust_line_no,part_type,tray_no)");
|
|
strSql.Append(" VALUES (" + orderId + ",0,'Y','" + custLineNo + "','PT20','" + trayNo + "' )");
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
|
|
if (dal.InsertData(SqlStrings, Parameters))
|
|
{
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
DataTable dtDetailLocation = this.dal.GetDetail(part_id, "03");
|
|
int orderDetailId = this.dal.getOrderDetailId(custPdlineId);
|
|
|
|
for (int j = 0; j < dtDetailLocation.Rows.Count; j++)
|
|
{
|
|
//零件号
|
|
strSql = new StringBuilder();
|
|
string part_no = dtDetailLocation.Rows[j]["part_no"].ToString();
|
|
string arrangeFlag = dtDetailLocation.Rows[j]["arrange_flag"].ToString();
|
|
|
|
strSql.Append(" INSERT INTO dbo.g_order_items");
|
|
strSql.Append(" ( order_id ,order_detail_id ,part_no ,status ,enabled )");
|
|
strSql.Append(" VALUES (" + orderId + "," + orderDetailId + ",'" + part_no + "',0,'Y')");
|
|
|
|
SqlStrings.Add(strSql.ToString());
|
|
Parameters.Add(Params);
|
|
dal.InsertData(SqlStrings, Parameters);
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
strSql = new StringBuilder();
|
|
//插入失败后删除主表对应数据
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
SqlStrings = new List<string>();
|
|
Parameters = new List<Hashtable>();
|
|
//}
|
|
}
|
|
}
|
|
result.Add("message", "导入成功");
|
|
result.Add("flag", "OK");
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
result.Add("message", "导入失败");
|
|
result.Add("flag", "error");
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
result.Add("message", "导入失败");
|
|
result.Add("flag", "error");
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public int UpdateCount(string order_id)
|
|
{
|
|
int count = this.dal.UpdateCount(order_id);
|
|
|
|
return count;
|
|
}
|
|
|
|
public int UpdatePrintNumber(string printNumber, string cbCustPDLine)
|
|
{
|
|
int count = this.dal.UpdatePrintNumber(printNumber, cbCustPDLine);
|
|
|
|
return count;
|
|
}
|
|
|
|
public int updateTrayNo(string HouPaiZhengYiNo, string FuJiaShiNo, string ZhengJiaShiNo, string order_id, string sum)
|
|
{
|
|
int count = this.dal.updateTrayNo(HouPaiZhengYiNo, FuJiaShiNo, ZhengJiaShiNo, order_id, sum);
|
|
|
|
return count;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |