diff --git a/AMESCoreStudio.WebApi/AMESCoreStudio.WebApi.csproj b/AMESCoreStudio.WebApi/AMESCoreStudio.WebApi.csproj
index 89ea82d4..4716d647 100644
--- a/AMESCoreStudio.WebApi/AMESCoreStudio.WebApi.csproj
+++ b/AMESCoreStudio.WebApi/AMESCoreStudio.WebApi.csproj
@@ -46,6 +46,7 @@
+
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs
index 293eded0..b03fc921 100644
--- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs
+++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs
@@ -265,6 +265,96 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES
}
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ [Route("[action]")]
+ [HttpGet]
+ public async Task> ESUNConnectTest(string barcodeNo)
+ {
+ ResultModel result = new ResultModel();
+
+ result.Msg = "OK";
+ result.Success = true;
+
+ ESUNContext _esun_context = new ESUNContext();
+
+ try
+ {
+ //读取MAC
+ DbConnection esun_conn = _esun_context.Database.GetDbConnection();
+ if (esun_conn.State != System.Data.ConnectionState.Open)
+ {
+ await esun_conn.OpenAsync();
+ }
+
+ 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%'", barcodeNo);
+
+ try
+ {
+ 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 esun_list = new List();
+ 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);
+ result.Msg = "OK:" + mac;
+ result.Success = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e2)
+ {
+ result.Msg = "NG:" + e2.Message;
+ result.Success = false;
+ }
+ }
+ catch (Exception e1)
+ {
+ result.Msg = "NG:" + e1.Message;
+ result.Success = false;
+
+ }
+
+ return result;
+ }
+
///
/// 查詢工單KeyParts資料QRS013
///