Browse Source

1.修改工单KeyParts查询

1.1.增加MB组件对应MAC查询(从昶亨数据库查询)
PTD
Marvin 2 years ago
parent
commit
63f50e27d4
  1. 11
      AMESCoreStudio.Web/Views/QRS/QRS013.cshtml
  2. 92
      AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs
  3. 27
      AMESCoreStudio.WebApi/Models/ESUNContext.cs
  4. 1
      AMESCoreStudio.WebApi/appsettings.json

11
AMESCoreStudio.Web/Views/QRS/QRS013.cshtml

@ -147,8 +147,7 @@
{
field: 'kP_98',
title: '組件98'
}
,
} ,
{
field: 'kP_BA',
title: '組件BA'
@ -156,6 +155,14 @@
{
field: 'kP_CPU',
title: '組件CPU'
},
{
field: 'kP_MB',
title: '組件MB'
},
{
field: 'kP_MAC',
title: '組件MAC'
}
]
];

92
AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs

@ -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();

27
AMESCoreStudio.WebApi/Models/ESUNContext.cs

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace AMESCoreStudio.WebApi
{
/// <summary>
///
/// </summary>
public class ESUNContext : DbContext
{
/// <summary>
///
/// </summary>
/// <param name="optionsBuilder"></param>
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
IConfiguration _config;
_config = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("appsettings.json").Build();
optionsBuilder.UseSqlServer(_config.GetConnectionString("ESUNContext"));
base.OnConfiguring(optionsBuilder);
}
}
}

1
AMESCoreStudio.WebApi/appsettings.json

@ -8,6 +8,7 @@
},
"ConnectionStrings": {
"AMESContext2": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=gdb)));User Id=JHAMES;Password=AMES666;",
"ESUNContext": "Data Source=localhost;Initial Catalog=SFIS_ESUN;User Id=sa;Password=20000123;",
"AMESContext": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=61.216.68.18)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=jhdb)));User Id=JHSYS;Password=ASYS666;"
//"AMESContext": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=61.216.68.18)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=jhdb)));User Id=system;Password=admin;"
//"AMESContextO": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=61.216.68.18)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=cpadb)));User Id=JHSYS;Password=ASYS666;"

Loading…
Cancel
Save