log time no commit
This commit is contained in:
@@ -24,13 +24,12 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
|
||||
|
||||
|
||||
[Route("GetLeakDataFull")]
|
||||
public async Task<HttpResponseMessage> GetLeakDataFull(String PcbId = "" , string Auftrag = "")
|
||||
[Route("GetMTExport")]
|
||||
public async Task<HttpResponseMessage> GetMTExport(string Auftrag = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
var returnPw = "Not assigned";
|
||||
var resDic = new List<Tuple<string, string>>();
|
||||
|
||||
using (var dataAccess = new SqlDataAccess(GlobalConfig.connectionString.Value))
|
||||
{
|
||||
|
||||
@@ -40,10 +39,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
query.AppendLine(" inner join Cordonel_PressureTest_He he on pt.CordonelPressureTest_Id = he.CordonelPressureTestHe_TestID ");
|
||||
query.AppendLine(" left outer join Druckpruefung c on pt.[CordonelPressureTest_PcbId] = c.FabNr ");
|
||||
query.AppendLine(" where 1 = 1 ");
|
||||
if (!string.IsNullOrEmpty(PcbId))
|
||||
{
|
||||
query.AppendLine($" and pt.[CordonelPressureTest_PcbId] = {PcbId} ");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Auftrag))
|
||||
{
|
||||
query.AppendLine($" and pt.[CordonelPressureTest_FertigungsAuftragsNr] = {Auftrag} ");
|
||||
@@ -54,7 +50,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
var dt = dataAccess.ExecuteQuery(query.ToString());
|
||||
foreach (var item in dt.Select())
|
||||
{
|
||||
|
||||
|
||||
var sb = new StringBuilder();
|
||||
try
|
||||
{
|
||||
@@ -84,7 +80,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
sb.Append("keine Kottmann Prüfung gefunden;;;;;;;");
|
||||
}
|
||||
|
||||
retDic.Add( new Tuple<string,string>(item["CordonelPressureTest_Id"].ToString(), sb.ToString()));
|
||||
retDic.Add(new Tuple<string, string>(item["CordonelPressureTest_Id"].ToString(), sb.ToString()));
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -92,7 +88,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -152,7 +148,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -161,8 +157,120 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
}
|
||||
|
||||
|
||||
[Route("GetCordonelCalibrationData")]
|
||||
public async Task<HttpResponseMessage> GetCordonelCalibrationData(String PcbId = "", string Auftrag = "", DateTime? Start = null, DateTime? End = null, int? Testbench = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var returnPw = "Not assigned";
|
||||
var resDic = new List<Tuple<string, string>>();
|
||||
|
||||
if (!Start.HasValue)
|
||||
{
|
||||
Start = new DateTime(2010, 01, 01);
|
||||
}
|
||||
if (!End.HasValue)
|
||||
{
|
||||
End = new DateTime(2050, 01, 01);
|
||||
}
|
||||
using (var dataAccess = new SqlDataAccess(GlobalConfig.connectionString.Value))
|
||||
{
|
||||
StringBuilder query = new StringBuilder();
|
||||
query.AppendLine(" select ");
|
||||
query.AppendLine(" m.Seriennummer ");
|
||||
query.AppendLine(" , aps.AuftragNr ");
|
||||
query.AppendLine(" , aps.PositionNr ");
|
||||
query.AppendLine(" ,zDate.[PcbId] ");
|
||||
query.AppendLine(" ,[MeterSize] ");
|
||||
query.AppendLine(" ,zDate.Id as PreadjustmentID ");
|
||||
query.AppendLine(" ,[ZeroOffset1] ");
|
||||
query.AppendLine(" ,[ZeroOffset2] ");
|
||||
query.AppendLine(" ,[ZeroOffset3] ");
|
||||
query.AppendLine(" ,[FirstHitUpdatePeriod] ");
|
||||
query.AppendLine(" ,[FirstHitShift] ");
|
||||
query.AppendLine(" ,[FirstHitPercent1] ");
|
||||
query.AppendLine(" ,[FirstHitPercent2] ");
|
||||
query.AppendLine(" ,[FirstHitPercent3] ");
|
||||
query.AppendLine(" ,[ToFTempOffset1] ");
|
||||
query.AppendLine(" ,[ToFTempOffset2] ");
|
||||
query.AppendLine(" ,[ToFTempOffset3] ");
|
||||
query.AppendLine(" ,zDate.[date] as ZeroflowDate ");
|
||||
query.AppendLine(" ,[successful] ");
|
||||
query.AppendLine(" , qc.Date as Q3CalibrationDate ");
|
||||
query.AppendLine(" , qc.P1Cal ");
|
||||
query.AppendLine(" , qc.P1Offset ");
|
||||
query.AppendLine(" , qc.P2Cal ");
|
||||
query.AppendLine(" , qc.P2Offset ");
|
||||
query.AppendLine(" , qc.P3Cal ");
|
||||
query.AppendLine(" , qc.P3Offset ");
|
||||
query.AppendLine(" FROM Genesis_Meter m ");
|
||||
query.AppendLine(" inner join MapPcbIdToSerialNumber map on m.Seriennummer = map.MapPcbIdToSerialNumber_SerialNumber ");
|
||||
query.AppendLine(" inner join AuftragPositionSerienNr aps on aps.SerienNr = m.Seriennummer and aps.Wiederholungen = -1 ");
|
||||
query.AppendLine(" inner join ( ");
|
||||
query.AppendLine(" SELECT t1.* , t1.DATE AS STARTDATE, case when t2.DATE is null then CURRENT_TIMESTAMP else t2.DATE end AS ENDDATE ");
|
||||
query.AppendLine(" FROM [Auftrag].[dbo].[CordonelMeterCalibrationResults] t1 ");
|
||||
query.AppendLine(" LEFT JOIN [Auftrag].[dbo].[CordonelMeterCalibrationResults] t2 ON t2.PcbId = t1.PcbId and t2.DATE = ");
|
||||
query.AppendLine(" (SELECT MIN(DATE) FROM [Auftrag].[dbo].[CordonelMeterCalibrationResults] t3 WHERE t3.DATE > t1.DATE and t3.PcbId = t1.PcbId) ");
|
||||
query.AppendLine(" ) as zDate on zDate.PcbId = map.MapPcbIdToSerialNumber_PcbId ");
|
||||
query.AppendLine(" left outer join Cordonel_Q3Calibration qc on qc.PcbId = zDate.PcbId and qc.Date between zDate.STARTDATE and zDate.ENDDATE ");
|
||||
query.AppendLine(" order by zDate.[date] desc ");
|
||||
var dt = dataAccess.ExecuteQuery(query.ToString());
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
|
||||
sb.Append("Seriennummer;AuftragNr;PositionNr;PcbId;MeterSize;PreadjustmentID;ZeroOffset1;ZeroOffset2;ZeroOffset3;FirstHitUpdatePeriod;FirstHitShift;FirstHitPercent1;FirstHitPercent2;FirstHitPercent3;ToFTempOffset1;ToFTempOffset2;ToFTempOffset3;ZeroflowDate;successful;Q3CalibrationDate;P1Cal;P1Offset;P2Cal;P2Offset;P3Cal;P3Offset");
|
||||
|
||||
sb.AppendLine();
|
||||
foreach (var item in dt.Select())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
foreach (var cell in item.ItemArray)
|
||||
{
|
||||
sb.Append(cell).Append(";");
|
||||
}
|
||||
sb.AppendLine();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
|
||||
|
||||
|
||||
result.Content = new StringContent(sb.ToString());
|
||||
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.ms-excel");
|
||||
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); //attachment will force download
|
||||
result.Content.Headers.ContentDisposition.FileName = "CordonelCalibrationData.csv";
|
||||
|
||||
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.ToString() + "<br >" + ex.InnerException.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Route("GetTestDataFull")]
|
||||
public async Task<HttpResponseMessage> GetTestDataFull(String PcbId = "", string Auftrag = "", DateTime? Start = null, DateTime? End = null)
|
||||
public async Task<HttpResponseMessage> GetTestDataFull(String PcbId = "", string Auftrag = "", DateTime? Start = null, DateTime? End = null, int? Testbench = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -194,7 +302,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
query.AppendLine(" pg.Nennweite, ");
|
||||
query.AppendLine(" idt.Baulaenge, ");
|
||||
query.AppendLine(" pg.Pruefzeit, ");
|
||||
|
||||
|
||||
query.AppendLine(" PP1_Soll,PP1_Ist,PP1_Ist_V, ");
|
||||
query.AppendLine(" pf.PP1_Fehler, ");
|
||||
query.AppendLine(" PP2_Soll,PP2_Ist,PP2_Ist_V, ");
|
||||
@@ -219,12 +327,12 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
|
||||
for (int p = 1; p <= 3; p++)
|
||||
{
|
||||
for (int f = 1; f <= 10 ; f++)
|
||||
for (int f = 1; f <= 10; f++)
|
||||
{
|
||||
query.AppendLine($",pf{p}.PP{f}_Fehler");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
query.AppendLine(" from [Auftrag].[dbo].[AuftragPositionSerienNr] apsn ");
|
||||
query.AppendLine(" inner join [Auftrag].[dbo].[AuftragPosition_Gesamt] apg on apg.AuftragNr = apsn.AuftragNr and apg.PositionNr = apsn.PositionNr and apg.Ort = 'L2' ");
|
||||
@@ -257,19 +365,26 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
query.AppendLine(" inner join [Auftrag].[dbo].[AuftragPositionSerienNr] apsn on apsn.SerienNr = [MapPcbIdToSerialNumber_SerialNumber] and apsn.SerienNr not in (20702497,20702499,20717438) ");
|
||||
query.AppendLine(" ");
|
||||
query.AppendLine(" inner join[Auftrag].[dbo].[AuftragPosition_Gesamt] apg on apg.AuftragNr = apsn.AuftragNr and apg.PositionNr = apsn.PositionNr and apg.Ort = 'L2' ");
|
||||
query.AppendLine(" inner join[Auftrag].[dbo].[Pruefgang] pg on apsn.[Pruefgangnr] = pg.PruefgangNr and pg.PruefstationNr in (2016,2015) ");
|
||||
query.AppendLine(" inner join[Auftrag].[dbo].[Pruefgang] pg on apsn.[Pruefgangnr] = pg.PruefgangNr ");
|
||||
|
||||
if (Testbench.HasValue)
|
||||
{
|
||||
query.AppendLine($" and pg.PruefstationNr in ({Testbench.Value}) ");
|
||||
}
|
||||
|
||||
|
||||
query.AppendLine(" inner join[Auftrag].[dbo].Prueffehler pf on pg.[Pruefgangnr] = pf.PruefgangNr and pf.SerienNr = [MapPcbIdToSerialNumber_SerialNumber] ");
|
||||
query.AppendLine(" ");
|
||||
query.AppendLine($" where pg.Datum >= '{Start}' and pg.Datum <= '{End}' ");
|
||||
query.AppendLine(" group by [MapPcbIdToSerialNumber_SerialNumber] ");
|
||||
query.AppendLine(" ) ");
|
||||
query.AppendLine(" ");
|
||||
// query.AppendLine(" and pf.PP3_Fehler is not null ");
|
||||
// query.AppendLine(" and pf.PP3_Fehler is not null ");
|
||||
query.AppendLine(" ");
|
||||
query.AppendLine(" order by apsn.SerienNr desc, apsn.Wiederholungen asc ");
|
||||
|
||||
|
||||
|
||||
|
||||
var dt = dataAccess.ExecuteQuery(query.ToString());
|
||||
|
||||
var sb = new StringBuilder();
|
||||
@@ -304,7 +419,7 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
{
|
||||
sb.Append(cell).Append(";");
|
||||
}
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1335,6 +1335,64 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
|
||||
return this.NotFound();
|
||||
}
|
||||
|
||||
if (result.CalFactor1 == 15625 && result.CalFactor2 == 15625 && result.CalFactor3 == 15625)
|
||||
{
|
||||
|
||||
using (var dataacces = new SqlDataAccess(GlobalConfig.ConnectionString.Value))
|
||||
{
|
||||
|
||||
var sbCal = new StringBuilder();
|
||||
sbCal.AppendLine(" select map.MapPcbIdToSerialNumber_PcbId, v1.Value as Cal1, v2.Value as Cal2, v3.Value as Cal3 from MapPcbIdToSerialNumber map ");
|
||||
sbCal.AppendLine(" ");
|
||||
sbCal.AppendLine(" inner join ");
|
||||
sbCal.AppendLine(" ( ");
|
||||
sbCal.AppendLine(" select map.MapPcbIdToSerialNumber_PcbId as mPcbid, max(c1.ID)as M1,max(c2.ID) as M2, max(c3.ID) as m3 from MapPcbIdToSerialNumber map ");
|
||||
sbCal.AppendLine(" left outer join GenesisMeterRegisterHistory c1 on c1.Address = '0F-0D' and map.MapPcbIdToSerialNumber_PcbId =c1.PcbId ");
|
||||
sbCal.AppendLine(" left outer join GenesisMeterRegisterHistory c2 on c2.Address = '0F-0E' and map.MapPcbIdToSerialNumber_PcbId =c2.PcbId ");
|
||||
sbCal.AppendLine(" left outer join GenesisMeterRegisterHistory c3 on c3.Address = '0F-0F' and map.MapPcbIdToSerialNumber_PcbId =c3.PcbId ");
|
||||
sbCal.AppendLine($" where map.MapPcbIdToSerialNumber_PcbId = '{pcbId}' ");
|
||||
sbCal.AppendLine(" group by MapPcbIdToSerialNumber_PcbId ) as maxT ");
|
||||
sbCal.AppendLine(" on mPcbid = map.MapPcbIdToSerialNumber_PcbId ");
|
||||
sbCal.AppendLine(" ");
|
||||
sbCal.AppendLine(" inner join GenesisMeterRegisterHistory v1 on v1.ID = M1 ");
|
||||
sbCal.AppendLine(" inner join GenesisMeterRegisterHistory v2 on v2.ID = M2 ");
|
||||
sbCal.AppendLine(" inner join GenesisMeterRegisterHistory v3 on v3.ID = M3 ");
|
||||
|
||||
|
||||
var dt = dataacces.ExecuteQuery(sbCal.ToString());
|
||||
foreach (var item in dt.Select())
|
||||
{
|
||||
var strC1 = item["Cal1"].ToString();
|
||||
string strc1Coor = "";
|
||||
foreach (String hex in strC1.Split('-').Reverse().ToArray())
|
||||
{
|
||||
strc1Coor += hex;
|
||||
}
|
||||
result.CalFactor1 = Convert.ToUInt16(strc1Coor, 16);
|
||||
|
||||
var strC2 = item["Cal2"].ToString();
|
||||
string strc2Coor = "";
|
||||
foreach (String hex in strC2.Split('-').Reverse().ToArray())
|
||||
{
|
||||
strc2Coor += hex;
|
||||
}
|
||||
result.CalFactor2 = Convert.ToUInt16(strc2Coor, 16);
|
||||
|
||||
var strC3 = item["Cal3"].ToString();
|
||||
string strc3Coor = "";
|
||||
foreach (String hex in strC3.Split('-').Reverse().ToArray())
|
||||
{
|
||||
strc3Coor += hex;
|
||||
}
|
||||
result.CalFactor3 = Convert.ToUInt16(strc3Coor, 16);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return this.Json(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,47 @@
|
||||
return this.BadRequest("Invalid data.");
|
||||
}
|
||||
|
||||
[Route("SetCalibrationValues"), HttpPost]
|
||||
public IHttpActionResult SetCalibrationValues([FromBody] JustageResults val)
|
||||
{
|
||||
var rowsAffected = SQLConnection
|
||||
.CreateSQLConnection(ConnectionString.Value)
|
||||
.CreateCommand($@"
|
||||
|
||||
INSERT INTO[dbo].[Cordonel_Q3Calibration]
|
||||
([PcbId]
|
||||
,[P1Offset]
|
||||
,[P1Cal]
|
||||
,[P2Offset]
|
||||
,[P2Cal]
|
||||
,[P3Offset]
|
||||
,[P3Cal]
|
||||
,[Date])
|
||||
VALUES (@{nameof(JustageResults.pcbId)}
|
||||
, @{nameof(JustageResults.p1Target)}
|
||||
, @{nameof(JustageResults.p1Value)}
|
||||
, @{nameof(JustageResults.p2Target)}
|
||||
, @{nameof(JustageResults.p2Value)}
|
||||
, @{nameof(JustageResults.p3Target)}
|
||||
, @{nameof(JustageResults.p3Value)}
|
||||
, @{nameof(JustageResults.dt)})")
|
||||
.SetParameter(nameof(JustageResults.pcbId), int.Parse(val.pcbId))
|
||||
.SetParameter(nameof(JustageResults.p1Target), val.p1Target)
|
||||
.SetParameter(nameof(JustageResults.p1Value), ((Int32)val.p1Value))
|
||||
.SetParameter(nameof(JustageResults.p2Target), val.p2Target)
|
||||
.SetParameter(nameof(JustageResults.p2Value), ((Int32)val.p2Value))
|
||||
.SetParameter(nameof(JustageResults.p3Target), val.p3Target)
|
||||
.SetParameter(nameof(JustageResults.p3Value), ((Int32)val.p3Value))
|
||||
.SetParameter(nameof(JustageResults.dt), val.dt)
|
||||
.ExecuteNonQuery();
|
||||
|
||||
if (rowsAffected == 1)
|
||||
{
|
||||
return this.Ok();
|
||||
}
|
||||
|
||||
return this.BadRequest("Invalid data.");
|
||||
}
|
||||
/// <summary>
|
||||
/// Get SerialNumber from PcbID
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user