|
|
@ -11,6 +11,8 @@ using AMESCoreStudio.CommonTools.Result; |
|
|
|
using System.Data.Common; |
|
|
|
using System.Data; |
|
|
|
using System.Dynamic; |
|
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
using Microsoft.EntityFrameworkCore.SqlServer; |
|
|
|
|
|
|
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
{ |
|
|
@ -22,6 +24,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
public class WipInfosController : Controller |
|
|
|
{ |
|
|
|
private readonly AMESContext _context; |
|
|
|
private readonly ESUNContext _esun_context; |
|
|
|
private readonly IConfiguration _config; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
@ -29,6 +33,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
/// <param name="context"></param>
|
|
|
|
public WipInfosController(AMESContext context) |
|
|
|
{ |
|
|
|
_config = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build(); |
|
|
|
_context = context; |
|
|
|
} |
|
|
|
|
|
|
@ -299,7 +304,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
|
|
|
|
sql = sql + " and c.wip_no = '" + wipNO + "'"; |
|
|
|
|
|
|
|
string tempName = string.Empty; |
|
|
|
DbConnection conn = _context.Database.GetDbConnection(); |
|
|
|
if (conn.State != System.Data.ConnectionState.Open) |
|
|
|
{ |
|
|
@ -319,6 +323,92 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES |
|
|
|
|
|
|
|
table = DataReaderToDataTable(reader); |
|
|
|
|
|
|
|
table.Columns.Add("KP_MAC"); |
|
|
|
table.AcceptChanges(); |
|
|
|
|
|
|
|
//判断MB组件增加查询MAC
|
|
|
|
try |
|
|
|
{ |
|
|
|
if (wip_kp.Count > 0) |
|
|
|
{ |
|
|
|
/* |
|
|
|
for (int i = 0; i < wip_kp.Count; i++) |
|
|
|
{ |
|
|
|
if (wip_kp[i].KpNo.StartsWith("MB")) |
|
|
|
{ |
|
|
|
table.Columns.Add("MAC"); |
|
|
|
table.AcceptChanges(); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
ESUNContext _esun_context = new ESUNContext(); |
|
|
|
|
|
|
|
//读取MAC
|
|
|
|
DbConnection esun_conn = _esun_context.Database.GetDbConnection(); |
|
|
|
if (esun_conn.State != System.Data.ConnectionState.Open) |
|
|
|
{ |
|
|
|
await esun_conn.OpenAsync(); |
|
|
|
} |
|
|
|
|
|
|
|
for (int j = 0; j < table.Rows.Count; j++) |
|
|
|
{ |
|
|
|
string barcode_no = table.Rows[j]["BarcodeNo"].ToString(); |
|
|
|
//barcode_no = "92000044790655";
|
|
|
|
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%'", barcode_no);
|
|
|
|
|
|
|
|
using (var esun_cmd = esun_conn.CreateCommand()) |
|
|
|
{ |
|
|
|
esun_cmd.CommandText = mac_sql; |
|
|
|
|
|
|
|
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) |
|
|
|
{ |
|
|
|
string mac_list = ""; |
|
|
|
for (int k = 0; k < esun_table.Rows.Count; k++) |
|
|
|
{ |
|
|
|
mac_list = mac_list + esun_table.Rows[k]["part_barcode"].ToString().Trim() + ","; |
|
|
|
} |
|
|
|
|
|
|
|
if (mac_list != "") |
|
|
|
{ |
|
|
|
string mac = mac_list.Substring(0, mac_list.Length - 1); |
|
|
|
table.Rows[j]["KP_MAC"] = mac; |
|
|
|
table.AcceptChanges(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch { } |
|
|
|
|
|
|
|
|
|
|
|
foreach (DataRow row in table.Rows) |
|
|
|
{ |
|
|
|
dynamic dyn = new ExpandoObject(); |
|
|
|