From d9a286f9dc28d65a042514a733d0ce8c84652b04 Mon Sep 17 00:00:00 2001 From: Marvin Date: Thu, 12 Jan 2023 11:37:25 +0800 Subject: [PATCH] =?UTF-8?q?1.WipInfoControllers=E6=96=B0=E5=A2=9EESUN?= =?UTF-8?q?=E8=BF=9E=E7=BA=BF=E6=B5=8B=E8=AF=95api=EF=BC=88ESUNConnectTest?= =?UTF-8?q?=EF=BC=89=202.WebApi=E5=A2=9E=E5=8A=A0=E5=BC=95=E7=94=A8Microso?= =?UTF-8?q?ft.Data.SqlClient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AMESCoreStudio.WebApi.csproj | 1 + .../Controllers/AMES/WipInfosController.cs | 90 +++++++++++++++++++ 2 files changed, 91 insertions(+) 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 ///