|
|
@ -543,13 +543,24 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no); |
|
|
|
if (createMacCol) |
|
|
|
{ |
|
|
|
for (int m = 0; m < esun_table.Rows.Count; m++) |
|
|
|
{ |
|
|
|
if (dtItem.Rows.Count == 1) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
dtBarcode.Columns.Add("KP_MB" + (k + 1).ToString() + "_MAC" + (m + 1).ToString()); |
|
|
|
dtBarcode.Columns.Add("KP_" + kp_no + "_MAC" + (m + 1).ToString()); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
dtBarcode.Columns.Add("KP_" + kp_no + "_" + (k + 1).ToString() + "_MAC" + (m + 1).ToString()); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
} |
|
|
|
dtBarcode.AcceptChanges(); |
|
|
|
createMacCol = false; |
|
|
|
} |
|
|
@ -558,7 +569,14 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no); |
|
|
|
for (int m = 0; m < esun_table.Rows.Count; m++) |
|
|
|
{ |
|
|
|
mac = esun_table.Rows[m]["part_barcode"].ToString().Trim(); |
|
|
|
dtBarcode.Rows[i]["KP_MB" + (k + 1).ToString() + "_MAC" + (m + 1).ToString()] = mac; |
|
|
|
if (dtItem.Rows.Count == 1) |
|
|
|
{ |
|
|
|
dtBarcode.Rows[i]["KP_" + kp_no + "_MAC" + (m + 1).ToString()] = mac; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
dtBarcode.Rows[i]["KP_" + kp_no + "_" + (k + 1).ToString() + "_MAC" + (m + 1).ToString()] = mac; |
|
|
|
} |
|
|
|
dtBarcode.AcceptChanges(); |
|
|
|
} |
|
|
|
} |
|
|
@ -610,6 +628,271 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 查詢工單KeyParts資料QRS017
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="wipNO"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[Route("[action]")]
|
|
|
|
[HttpGet] |
|
|
|
public async Task<ResultModel<dynamic>> GetWipInfo4QRS017(string wipNO) |
|
|
|
{ |
|
|
|
ResultModel<dynamic> result = new ResultModel<dynamic>(); |
|
|
|
Helper helper = new Helper(_context); |
|
|
|
|
|
|
|
DbConnection conn = _context.Database.GetDbConnection(); |
|
|
|
if (conn.State != ConnectionState.Open) |
|
|
|
{ |
|
|
|
await conn.OpenAsync(); |
|
|
|
} |
|
|
|
|
|
|
|
string kp_sql = "select kp_no, count(kp_seq) as kp_qty from jhames.wip_kp where wip_no = '" + wipNO + "' group by kp_no"; |
|
|
|
|
|
|
|
DataTable dtKp = new DataTable(); |
|
|
|
|
|
|
|
using (var cmd = conn.CreateCommand()) |
|
|
|
{ |
|
|
|
cmd.CommandText = kp_sql; |
|
|
|
|
|
|
|
using (var reader = await cmd.ExecuteReaderAsync()) |
|
|
|
{ |
|
|
|
if (reader.HasRows) |
|
|
|
{ |
|
|
|
dtKp = DataReaderToDataTable(reader); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
string sql = @" select c.wip_no as WipNo,b.barcode_no as BarcodeNo,b.extra_barcode_no as ExtraBarcodeNo,d.model_no as ModelNO,d.item_no as ItemNO"; |
|
|
|
sql = sql + " from jhames.barcode_info b,jhames.wip_info c,jhames.wip_att d"; |
|
|
|
sql = sql + " where b.wip_id = c.wip_id and c.wip_no = d.wip_no"; |
|
|
|
sql = sql + " and c.wip_no = '" + wipNO + "'"; |
|
|
|
|
|
|
|
using (var barcode_cmd = conn.CreateCommand()) |
|
|
|
{ |
|
|
|
barcode_cmd.CommandText = sql; |
|
|
|
|
|
|
|
using (var barcode_reader = await barcode_cmd.ExecuteReaderAsync()) |
|
|
|
{ |
|
|
|
if (barcode_reader.HasRows) |
|
|
|
{ |
|
|
|
List<dynamic> list = new List<dynamic>(); |
|
|
|
DataTable dtBarcode = new DataTable(); |
|
|
|
|
|
|
|
dtBarcode = DataReaderToDataTable(barcode_reader); |
|
|
|
|
|
|
|
if (dtKp.Rows.Count > 0) |
|
|
|
{ |
|
|
|
for (int i = 0; i < dtKp.Rows.Count; i++) |
|
|
|
{ |
|
|
|
int kp_qty = int.Parse(dtKp.Rows[i]["KP_QTY"].ToString()); |
|
|
|
string kp_no = dtKp.Rows[i]["KP_NO"].ToString(); |
|
|
|
if (kp_qty > 1) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
dtBarcode.Columns.Add("KP_" + kp_no); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
|
|
|
|
for (int j = 1; j < kp_qty; j++) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
dtBarcode.Columns.Add("KP_" + kp_no + "#" + j.ToString()); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
dtBarcode.Columns.Add("KP_" + kp_no); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
} |
|
|
|
dtBarcode.AcceptChanges(); |
|
|
|
|
|
|
|
for (int i = 0; i < dtBarcode.Rows.Count; i++) |
|
|
|
{ |
|
|
|
string barcode_no = dtBarcode.Rows[i]["BarcodeNo"].ToString(); |
|
|
|
|
|
|
|
//读取组件
|
|
|
|
for (int j = 0; j < dtKp.Rows.Count; j++) |
|
|
|
{ |
|
|
|
string kp_no = dtKp.Rows[j]["KP_NO"].ToString(); |
|
|
|
|
|
|
|
string barcode_item_sql = string.Format(@"select part_no from jhames.barcode_info a,jhames.barcode_item b where a.barcode_id = b.barcode_id
|
|
|
|
and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
|
|
|
|
|
|
|
|
using (var item_cmd = conn.CreateCommand()) |
|
|
|
{ |
|
|
|
item_cmd.CommandText = barcode_item_sql; |
|
|
|
|
|
|
|
using (var item_reader = await item_cmd.ExecuteReaderAsync()) |
|
|
|
{ |
|
|
|
if (item_reader.HasRows) |
|
|
|
{ |
|
|
|
DataTable dtItem = new DataTable(); |
|
|
|
dtItem = DataReaderToDataTable(item_reader); |
|
|
|
|
|
|
|
for (int k = 0; k < dtItem.Rows.Count; k++) |
|
|
|
{ |
|
|
|
string part_no = dtItem.Rows[k]["PART_NO"].ToString(); |
|
|
|
try |
|
|
|
{ |
|
|
|
dtBarcode.Rows[i]["KP_" + kp_no + "#" + k.ToString()] = part_no; |
|
|
|
} |
|
|
|
catch |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
dtBarcode.Rows[i]["KP_" + kp_no] = part_no; |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
|
|
|
|
dtBarcode.AcceptChanges(); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
if (kp_no.StartsWith("MB") && !kp_no.StartsWith("MB_MAC")) |
|
|
|
{ |
|
|
|
ESUNContext _esun_context = new ESUNContext(); |
|
|
|
|
|
|
|
//读取MAC
|
|
|
|
DbConnection esun_conn = _esun_context.Database.GetDbConnection(); |
|
|
|
if (esun_conn.State != ConnectionState.Open) |
|
|
|
{ |
|
|
|
await esun_conn.OpenAsync(); |
|
|
|
} |
|
|
|
|
|
|
|
bool createMacCol = true; |
|
|
|
|
|
|
|
|
|
|
|
//part_no = "91000237320038";
|
|
|
|
|
|
|
|
string mac_sql = string.Format(@"select distinct a.工單編號 as mo_id,e.客戶工單編號 as customer_moid,a.工單序號 as product_sn,
|
|
|
|
case substring(f.avalue_kp_typeid, 1, 3) when 'MAC' then isnull(z.item_prefix,'')+b.SUB_ITEM_SN else b.SUB_ITEM_SN end as part_barcode, |
|
|
|
f.avalue_kp_typeid as class,c.material_id,d.r_stn as routeid,'' as workerid,rtrim(g.sn_date) + ' ' + rtrim(g.sn_time) as create_date |
|
|
|
from or_sn_story a |
|
|
|
left join sub_item_db b on a.工單編號 = b.or_sn and a.工單序號 = b.or_sal |
|
|
|
left join jh_sub_item c on a.工單編號 = c.mo_id and b.class = c.part_typeid |
|
|
|
left join jh_sub_item_prefix z on c.mo_id = z.mo_id |
|
|
|
left join or_sub_db d on a.工單編號 = d.or_sn and b.class = d.class |
|
|
|
join or_list e on a.工單編號 = e.工單編號 and e.[客戶] = 'EV' |
|
|
|
left join jh_sub_item_mapping f on b.class = f.eversun_kp_typeid |
|
|
|
join jh_sn_list g on a.工單序號 = g.sn |
|
|
|
where g.sn_result = 'OK' |
|
|
|
AND a.工單序號 = '{0}' |
|
|
|
AND c.material_id LIKE 'MAC%'", part_no);
|
|
|
|
|
|
|
|
using (var esun_cmd = esun_conn.CreateCommand()) |
|
|
|
{ |
|
|
|
esun_cmd.CommandText = mac_sql; |
|
|
|
esun_cmd.CommandTimeout = 0; |
|
|
|
|
|
|
|
using (var esun_reader = await esun_cmd.ExecuteReaderAsync()) |
|
|
|
{ |
|
|
|
if (esun_reader.HasRows) |
|
|
|
{ |
|
|
|
List<dynamic> esun_list = new List<dynamic>(); |
|
|
|
DataTable esun_table = new DataTable(); |
|
|
|
|
|
|
|
esun_table = DataReaderToDataTable(esun_reader); |
|
|
|
|
|
|
|
if (esun_table.Rows.Count > 0) |
|
|
|
{ |
|
|
|
if (createMacCol) |
|
|
|
{ |
|
|
|
for (int m = 0; m < esun_table.Rows.Count; m++) |
|
|
|
{ |
|
|
|
if (dtItem.Rows.Count == 1) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
dtBarcode.Columns.Add("KP_" + kp_no + "#MAC" + (m + 1).ToString()); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
dtBarcode.Columns.Add("KP_" + kp_no + "#" + (k + 1).ToString() + "_MAC" + (m + 1).ToString()); |
|
|
|
} |
|
|
|
catch { } |
|
|
|
} |
|
|
|
} |
|
|
|
dtBarcode.AcceptChanges(); |
|
|
|
createMacCol = false; |
|
|
|
} |
|
|
|
|
|
|
|
string mac = ""; |
|
|
|
for (int m = 0; m < esun_table.Rows.Count; m++) |
|
|
|
{ |
|
|
|
mac = esun_table.Rows[m]["part_barcode"].ToString().Trim(); |
|
|
|
if (dtItem.Rows.Count == 1) |
|
|
|
{ |
|
|
|
dtBarcode.Rows[i]["KP_" + kp_no + "#MAC" + (m + 1).ToString()] = mac; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
dtBarcode.Rows[i]["KP_" + kp_no + "#" + (k + 1).ToString() + "_MAC" + (m + 1).ToString()] = mac; |
|
|
|
} |
|
|
|
dtBarcode.AcceptChanges(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e1) |
|
|
|
{ |
|
|
|
string err = e1.Message; |
|
|
|
} |
|
|
|
} |
|
|
|
dtBarcode.AcceptChanges(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
foreach (DataRow row in dtBarcode.Rows) |
|
|
|
{ |
|
|
|
dynamic dyn = new ExpandoObject(); |
|
|
|
list.Add(dyn); |
|
|
|
foreach (DataColumn column in dtBarcode.Columns) |
|
|
|
{ |
|
|
|
var dic = (IDictionary<string, object>)dyn; |
|
|
|
dic[column.ColumnName] = row[column]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
result.DataTotal = list.Count(); |
|
|
|
result.Data = list; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
result.Msg = "查無資料"; |
|
|
|
result.Success = false; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
result.Success = true; |
|
|
|
result.Msg = "OK"; |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 查詢工單KeyParts資料QRS013
|
|
|
|
/// </summary>
|
|
|
|