Aggiunta funzionalità importFile x SAIM/Centerfrigo
This commit is contained in:
@@ -84,8 +84,8 @@
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.1.9, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SharpZipLib.1.3.1\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MapoSDK, Version=6.14.2211.3010, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MapoSDK.6.14.2211.3010\lib\MapoSDK.dll</HintPath>
|
||||
<Reference Include="MapoSDK, Version=6.14.2211.3016, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MapoSDK.6.14.2211.3016\lib\MapoSDK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
|
||||
@@ -815,4 +815,5 @@ namespace IOB_UT_NEXT
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<packages>
|
||||
<package id="ExcelDataReader" version="3.6.0" targetFramework="net462" />
|
||||
<package id="ExcelDataReader.DataSet" version="3.6.0" targetFramework="net462" />
|
||||
<package id="MapoSDK" version="6.14.2211.3010" targetFramework="net462" />
|
||||
<package id="MapoSDK" version="6.14.2211.3016" targetFramework="net462" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" targetFramework="net462" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
|
||||
<package id="NLog" version="4.7.13" targetFramework="net462" />
|
||||
|
||||
@@ -137,8 +137,8 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>ExtLib\krcc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MapoSDK, Version=6.14.2211.3010, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MapoSDK.6.14.2211.3010\lib\MapoSDK.dll</HintPath>
|
||||
<Reference Include="MapoSDK, Version=6.14.2211.3016, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MapoSDK.6.14.2211.3016\lib\MapoSDK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MathNet.Numerics, Version=4.15.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MathNet.Numerics.4.15.0\lib\net461\MathNet.Numerics.dll</HintPath>
|
||||
|
||||
+137
-15
@@ -3,6 +3,7 @@ using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using MathNet.Numerics.Statistics;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections;
|
||||
@@ -44,8 +45,9 @@ namespace IOB_WIN_NEXT
|
||||
/// Procedura di import file...
|
||||
/// </summary>
|
||||
/// <param name="fileItem"></param>
|
||||
protected virtual void importFile(string fileItem)
|
||||
protected virtual bool importFile(string fileItem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Effettua eventuale file import, archiviando file importati
|
||||
@@ -59,6 +61,12 @@ namespace IOB_WIN_NEXT
|
||||
// verifico esistenza folders...
|
||||
if (Directory.Exists(fileImportFolder))
|
||||
{
|
||||
// verifico archivio
|
||||
string dirArchive = $"{fileImportFolder}/archive";
|
||||
if (!Directory.Exists(dirArchive))
|
||||
{
|
||||
Directory.CreateDirectory(dirArchive);
|
||||
}
|
||||
// cerco files
|
||||
var listFiles = Directory.GetFiles(fileImportFolder, fileImportType);
|
||||
// se li trovo --> chiamo import!
|
||||
@@ -66,7 +74,40 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
foreach (var fileItem in listFiles)
|
||||
{
|
||||
importFile(fileItem);
|
||||
string errore = "";
|
||||
answ = importFile(fileItem);
|
||||
if (!answ)
|
||||
{
|
||||
errore = $"Errore in fase di importFile x {fileItem}";
|
||||
}
|
||||
else
|
||||
{
|
||||
// provo forzare send...
|
||||
answ = svuotaCodaRawTransf(true);
|
||||
if (!answ)
|
||||
{
|
||||
errore = $"Errore in fase di invio dati svuotaCodaRawTransf x {fileItem}";
|
||||
}
|
||||
else
|
||||
{
|
||||
// sposto file...
|
||||
File.Move(fileItem, $"{dirArchive}/{Path.GetFileName(fileItem)}");
|
||||
}
|
||||
}
|
||||
// log eventuali errori
|
||||
if (!answ)
|
||||
{
|
||||
string dirError = $"{fileImportFolder}/errors";
|
||||
if (!Directory.Exists(dirError))
|
||||
{
|
||||
Directory.CreateDirectory(dirError);
|
||||
}
|
||||
// sposto file...
|
||||
File.Move(fileItem, $"{dirError}/{Path.GetFileName(fileItem)}");
|
||||
// segno errore!
|
||||
string fileError = $"{fileImportFolder}/errors.log";
|
||||
File.AppendAllText(fileError, errore);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -941,6 +982,44 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// URL per recupero dati ODL alla data...
|
||||
/// </summary>
|
||||
public string urlGetOdlAtDate(DateTime dtRif)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/getOdlAtDate/{cIobConf.codIOB}?dateRif={dtRif:yyyyMMdd}";
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, $"Errore in composizione urlGetOdlAtDate per {dtRif}{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// URL per chiamata generazione ODL giornalieri alla data
|
||||
/// </summary>
|
||||
public string urlFixDailyOdl
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = $@"{cIobConf.serverData.TRANSP}://{cIobConf.serverData.MPIP}{cIobConf.serverData.MPURL}{cIobConf.serverData.CMDALIVE}/fixDailyOdl/{cIobConf.codIOB}";
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Errore in composizione urlFixDailyOdl");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// URL per recupero PODL correnti x macchina...
|
||||
/// </summary>
|
||||
@@ -1575,7 +1654,17 @@ namespace IOB_WIN_NEXT
|
||||
* */
|
||||
|
||||
// serializzo il valore...
|
||||
BaseRawTransf newVal = new BaseRawTransf(DateTime.Now, (Newtonsoft.Json.Linq.JObject)mesContent, mesType);
|
||||
JObject njObj;
|
||||
if (mesType == rawTransfType.IcoelBatch || mesType == rawTransfType.IcoelVarInfo)
|
||||
{
|
||||
njObj = (JObject)mesContent;
|
||||
}
|
||||
else
|
||||
{
|
||||
njObj = (JObject)JToken.FromObject(mesContent);
|
||||
}
|
||||
BaseRawTransf newVal = new BaseRawTransf(DateTime.Now, njObj, mesType);
|
||||
|
||||
string encodedVal = JsonConvert.SerializeObject(newVal);
|
||||
// --> accodo (valore già formattato)!
|
||||
QueueRawTransf.Enqueue(encodedVal);
|
||||
@@ -2149,6 +2238,15 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
else
|
||||
{
|
||||
// anche se NON connesso alcuni task di bassa freq li eseguo...
|
||||
if (ciclo == gatherCycle.LF)
|
||||
{
|
||||
// verifico se devo gestire cambio ODL in modo automatico
|
||||
processAutoOdl();
|
||||
// effettua gestione import file se configurato...
|
||||
processFileImport();
|
||||
}
|
||||
|
||||
// provo a riconnettere SE abilitato tryRestart...
|
||||
if (adpTryRestart && !connectionOk)
|
||||
{
|
||||
@@ -2460,7 +2558,9 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
rawResult = rawResult.Substring(0, rawResult.Length - 1);
|
||||
}
|
||||
answ = "{" + $"\"rawTransfData\":[{rawResult}]" + "}";
|
||||
answ = $"[{rawResult}]";
|
||||
|
||||
//answ = "{" + $"\"rawTransfData\":[{rawResult}]" + "}";
|
||||
|
||||
break;
|
||||
|
||||
@@ -2640,6 +2740,11 @@ namespace IOB_WIN_NEXT
|
||||
lgInfo($"isRunning: {isRunning} | pzCountResetted: {pzCountResetted} | forceResetInRun: {forceResetInRun} | contapezziIOB: {contapezziIOB} | contapezziPLC: {contapezziPLC}");
|
||||
}
|
||||
}
|
||||
else if (CHANGE_ODL_MODE == "DAILY")
|
||||
{
|
||||
// chiamo stored x creare ODL giornalieri alla data...
|
||||
string autoOdlRes = utils.callUrl(urlFixDailyOdl);
|
||||
}
|
||||
else if (CHANGE_ODL_MODE == "TIME")
|
||||
{
|
||||
// carico i parametri di configurazione x reset ODL...
|
||||
@@ -3437,8 +3542,9 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
/// <param name="tipoUrl"></param>
|
||||
/// <param name="queueVal"></param>
|
||||
public void sendDataBlock(urlType tipoUrl, List<string> listQueueVal)
|
||||
public bool sendDataBlock(urlType tipoUrl, List<string> listQueueVal, bool force = false)
|
||||
{
|
||||
bool fatto = false;
|
||||
// init obj display
|
||||
newDisplayData currDispData = new newDisplayData();
|
||||
if (listQueueVal != null)
|
||||
@@ -3455,7 +3561,7 @@ namespace IOB_WIN_NEXT
|
||||
if (!DemoOut)
|
||||
{
|
||||
// SE server alive...
|
||||
if (checkServerAlive)
|
||||
if (checkServerAlive || false)
|
||||
{
|
||||
// chiamo URL!
|
||||
string answ = callUrlWithPayload(lastUrl, payload, doAsync);
|
||||
@@ -3466,6 +3572,7 @@ namespace IOB_WIN_NEXT
|
||||
// se "OK" verde, altrimenti errore --> ROSSO
|
||||
if (answ.Contains("OK"))
|
||||
{
|
||||
fatto = true;
|
||||
currDispData.semOut = Semaforo.SV;
|
||||
// se oltre 1 min NON era online --> check pezzi!
|
||||
if (DateTime.Now.Subtract(lastIobOnline).TotalMinutes > 1 && !isMulti)
|
||||
@@ -3503,6 +3610,7 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
raiseRefresh(currDispData);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -5720,7 +5828,16 @@ namespace IOB_WIN_NEXT
|
||||
FileDecod = memMap.fileDecod;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Cleanup stringa x impiego tipo ident da char dubbi
|
||||
/// </summary>
|
||||
/// <param name="origData"></param>
|
||||
/// <returns></returns>
|
||||
protected string strFixId(string origData)
|
||||
{
|
||||
return origData.Replace(".", "").Replace(" ", "_");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua chiamata MP-IO per tentare chiusura ODL corrente della macchina
|
||||
@@ -6572,8 +6689,9 @@ namespace IOB_WIN_NEXT
|
||||
/// <summary>
|
||||
/// Processo la coda RawTransf...
|
||||
/// </summary>
|
||||
private void svuotaCodaRawTransf()
|
||||
private bool svuotaCodaRawTransf(bool force = false)
|
||||
{
|
||||
bool fatto = false;
|
||||
// verifico SE la coda abbia dei valori...
|
||||
if (QueueRawTransf.Count > 0)
|
||||
{
|
||||
@@ -6584,9 +6702,9 @@ namespace IOB_WIN_NEXT
|
||||
if (QueueRawTransf.Count > 0)
|
||||
{
|
||||
string currVal = "";
|
||||
if (MPOnline)
|
||||
if (MPOnline || force)
|
||||
{
|
||||
if (IobOnline)
|
||||
if (IobOnline || force)
|
||||
{
|
||||
List<string> listaValori = new List<string>();
|
||||
// se ho + di maxJsonData elementi --> invio un set di dati alla volta
|
||||
@@ -6598,16 +6716,19 @@ namespace IOB_WIN_NEXT
|
||||
QueueRawTransf.TryDequeue(out currVal);
|
||||
listaValori.Add(currVal);
|
||||
}
|
||||
sendDataBlock(urlType.RawTransf, listaValori);
|
||||
fatto = sendDataBlock(urlType.RawTransf, listaValori, force);
|
||||
}
|
||||
else
|
||||
{
|
||||
// invio in blocco
|
||||
listaValori = QueueRawTransf.ToList();
|
||||
// invio
|
||||
sendDataBlock(urlType.RawTransf, listaValori);
|
||||
// svuoto!
|
||||
QueueRawTransf = new ConcurrentQueue<string>();
|
||||
fatto = sendDataBlock(urlType.RawTransf, listaValori, force);
|
||||
if (fatto)
|
||||
{
|
||||
// svuoto se ha fatto!
|
||||
QueueRawTransf = new ConcurrentQueue<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -6626,6 +6747,7 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -6690,7 +6812,7 @@ namespace IOB_WIN_NEXT
|
||||
/// <summary>
|
||||
/// Cerca di inviare su un altro thread i vari dati accumulati...
|
||||
/// </summary>
|
||||
private void trySendValues()
|
||||
protected void trySendValues()
|
||||
{
|
||||
// init obj display
|
||||
newDisplayData currDispData = new newDisplayData();
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
using EasyModbus;
|
||||
using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using static MapoSDK.WharehouseData;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
@@ -98,6 +102,139 @@ namespace IOB_WIN_NEXT
|
||||
B_input = byteSignals;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Procedura di import file... formato excel Giacovelli
|
||||
/// </summary>
|
||||
/// <param name="fileItem"></param>
|
||||
protected override bool importFile(string fileItem)
|
||||
{
|
||||
bool fatto = false;
|
||||
int numErr = 0;
|
||||
// test procedura di import files excel x Giacovelli...
|
||||
var currExcel = new ExcelMan(fileItem);
|
||||
// creo lista dati in formato RegGiacenze...
|
||||
Dictionary<string, BatchRec> listaGiac = new Dictionary<string, BatchRec>();
|
||||
var dtSet = currExcel.getDataSet();
|
||||
if (dtSet != null && dtSet.Tables != null && dtSet.Tables.Count > 0)
|
||||
{
|
||||
string nomeFile = Path.GetFileName(fileItem);
|
||||
nomeFile = nomeFile.Substring(0, nomeFile.LastIndexOf("."));
|
||||
var elSheet = dtSet.Tables;
|
||||
int idxTab = 0;
|
||||
//cerco lo sheet corretto se > 1
|
||||
if (dtSet.Tables.Count > 1)
|
||||
{
|
||||
for (int i = 0; i < dtSet.Tables.Count; i++)
|
||||
{
|
||||
if (nomeFile.Contains(dtSet.Tables[i].TableName))
|
||||
{
|
||||
idxTab = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
var tabella = dtSet.Tables[idxTab];
|
||||
int numRighe = tabella.Rows.Count;
|
||||
int idxODL = 0;
|
||||
DateTime dataDoc = DateTime.Today;
|
||||
DateTime.TryParse(nomeFile, out dataDoc);
|
||||
// cerco lotto x giornata...
|
||||
string sIdxODL = utils.callUrl(urlGetOdlAtDate(dataDoc));
|
||||
int.TryParse(sIdxODL, out idxODL);
|
||||
for (int i = 0; i < numRighe; i++)
|
||||
{
|
||||
if (numErr < 5)
|
||||
{
|
||||
try
|
||||
{
|
||||
// variabili di appoggio...
|
||||
DateTime dtRif = DateTime.Today;
|
||||
double qtyTot = 0;
|
||||
int numPack = 0;
|
||||
string ddt = tabella.Rows[i].ItemArray[FileDecod["ExtDoc"]].ToString().Trim();
|
||||
string prod = tabella.Rows[i].ItemArray[FileDecod["Product"]].ToString().Trim();
|
||||
string variety = tabella.Rows[i].ItemArray[FileDecod["Variety"]].ToString().Trim();
|
||||
string suppl = tabella.Rows[i].ItemArray[FileDecod["Supplier"]].ToString().Trim();
|
||||
string sDate = tabella.Rows[i].ItemArray[FileDecod["DateRif"]].ToString().Trim();
|
||||
string sQty = tabella.Rows[i].ItemArray[FileDecod["QtyTot"]].ToString().Trim();
|
||||
string sNum = tabella.Rows[i].ItemArray[FileDecod["NumPack"]].ToString().Trim();
|
||||
string numPed = tabella.Rows[i].ItemArray[FileDecod["NumPed"]].ToString().Trim();
|
||||
string packPed = tabella.Rows[i].ItemArray[FileDecod["PackPed"]].ToString().Trim();
|
||||
string pesoPack = tabella.Rows[i].ItemArray[FileDecod["PesoPack"]].ToString().Trim();
|
||||
DateTime.TryParse(sDate, out dtRif);
|
||||
int.TryParse(sNum, out numPack);
|
||||
double.TryParse(sQty, out qtyTot);
|
||||
string identRG = ddt.Length > 2 ? $"{strFixId(ddt)}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}" : $"{dtRif:yyyyMMdd}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}";
|
||||
string notes = $"{numPed}x{packPed}x{pesoPack}";
|
||||
// verifico di avere dati per proseguire...
|
||||
bool checkIdent = !string.IsNullOrEmpty($"{prod}{variety}{suppl}");
|
||||
bool checkHeaderKo = (ddt == "DDT" || prod == "PRODOTTO");
|
||||
if (checkIdent && !checkHeaderKo)
|
||||
{
|
||||
BatchRec newRow = new BatchRec()
|
||||
{
|
||||
IdxODL = idxODL,
|
||||
IdentRG = identRG,
|
||||
DateRif = dtRif,
|
||||
ExtDoc = ddt,
|
||||
Product = prod,
|
||||
Variety = variety,
|
||||
Supplier = suppl,
|
||||
NumPack = numPack,
|
||||
QtyTot = qtyTot,
|
||||
Notes = notes
|
||||
};
|
||||
// verifico: se manca aggiungo
|
||||
if (!listaGiac.ContainsKey(identRG))
|
||||
{
|
||||
listaGiac.Add(identRG, newRow);
|
||||
}
|
||||
else
|
||||
{
|
||||
// altrimenti aggiorno giacenza con valori numerici
|
||||
listaGiac[identRG].NumPack += newRow.NumPack;
|
||||
listaGiac[identRG].QtyTot += newRow.QtyTot;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
numErr++;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
numErr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (listaGiac.Count > 0)
|
||||
{
|
||||
// converto in una nuova lista...
|
||||
int rCounter = 1;
|
||||
Dictionary<int, BatchRec> list2Send = new Dictionary<int, BatchRec>();
|
||||
foreach (var item in listaGiac)
|
||||
{
|
||||
list2Send.Add(rCounter, item.Value);
|
||||
rCounter++;
|
||||
}
|
||||
// ora invio i file con json...
|
||||
accodaRawData(rawTransfType.RegGiacenze, list2Send);
|
||||
fatto = true;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua sync dati
|
||||
/// </summary>
|
||||
protected override void processDataSync()
|
||||
{
|
||||
// richiesta check autoODL
|
||||
processAutoOdl();
|
||||
// effettua gestione import file...
|
||||
processFileImport();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
using EasyModbus;
|
||||
using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using static MapoSDK.WharehouseData;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
@@ -43,7 +47,6 @@ namespace IOB_WIN_NEXT
|
||||
lgError($"Eccezione in processDynData iniziale x ModBus TCP SAIM:{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
@@ -51,23 +54,13 @@ namespace IOB_WIN_NEXT
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce status di WORK (auto + lavora), hard coded
|
||||
/// Restituisce controllo IN ALLARME
|
||||
/// </summary>
|
||||
protected bool WorkState
|
||||
protected bool AlarmState
|
||||
{
|
||||
get
|
||||
{
|
||||
return testIntCondition("WorkIntCond");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Restituisce status di Manuale, hard coded
|
||||
/// </summary>
|
||||
protected bool ManualState
|
||||
{
|
||||
get
|
||||
{
|
||||
return testIntCondition("ManualIntCond");
|
||||
return testIntCondition("AlarmIntCond");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,15 +76,16 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce controllo IN ALLARME
|
||||
/// Restituisce status di Manuale, hard coded
|
||||
/// </summary>
|
||||
protected bool AlarmState
|
||||
protected bool ManualState
|
||||
{
|
||||
get
|
||||
{
|
||||
return testIntCondition("AlarmIntCond");
|
||||
return testIntCondition("ManualIntCond");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce status di LAVORA, hard coded
|
||||
/// </summary>
|
||||
@@ -103,6 +97,17 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce status di WORK (auto + lavora), hard coded
|
||||
/// </summary>
|
||||
protected bool WorkState
|
||||
{
|
||||
get
|
||||
{
|
||||
return testIntCondition("WorkIntCond");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
@@ -169,10 +174,139 @@ namespace IOB_WIN_NEXT
|
||||
B_input = byteSignals;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Procedura di import file... formato excel Giacovelli
|
||||
/// </summary>
|
||||
/// <param name="fileItem"></param>
|
||||
protected override bool importFile(string fileItem)
|
||||
{
|
||||
bool fatto = false;
|
||||
int numErr = 0;
|
||||
// test procedura di import files excel x Giacovelli...
|
||||
var currExcel = new ExcelMan(fileItem);
|
||||
// creo lista dati in formato RegGiacenze...
|
||||
Dictionary<string, BatchRec> listaGiac = new Dictionary<string, BatchRec>();
|
||||
var dtSet = currExcel.getDataSet();
|
||||
if (dtSet != null && dtSet.Tables != null && dtSet.Tables.Count > 0)
|
||||
{
|
||||
string nomeFile = Path.GetFileName(fileItem);
|
||||
nomeFile = nomeFile.Substring(0, nomeFile.LastIndexOf("."));
|
||||
var elSheet = dtSet.Tables;
|
||||
int idxTab = 0;
|
||||
//cerco lo sheet corretto se > 1
|
||||
if (dtSet.Tables.Count > 1)
|
||||
{
|
||||
for (int i = 0; i < dtSet.Tables.Count; i++)
|
||||
{
|
||||
if (nomeFile.Contains(dtSet.Tables[i].TableName))
|
||||
{
|
||||
idxTab = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
var tabella = dtSet.Tables[idxTab];
|
||||
int numRighe = tabella.Rows.Count;
|
||||
int idxODL = 0;
|
||||
DateTime dataDoc = DateTime.Today;
|
||||
DateTime.TryParse(nomeFile, out dataDoc);
|
||||
// cerco lotto x giornata...
|
||||
string sIdxODL = utils.callUrl(urlGetOdlAtDate(dataDoc));
|
||||
int.TryParse(sIdxODL, out idxODL);
|
||||
for (int i = 0; i < numRighe; i++)
|
||||
{
|
||||
if (numErr < 5)
|
||||
{
|
||||
try
|
||||
{
|
||||
// variabili di appoggio...
|
||||
DateTime dtRif = DateTime.Today;
|
||||
double qtyTot = 0;
|
||||
int numPack = 0;
|
||||
string ddt = tabella.Rows[i].ItemArray[FileDecod["ExtDoc"]].ToString().Trim();
|
||||
string prod = tabella.Rows[i].ItemArray[FileDecod["Product"]].ToString().Trim();
|
||||
string variety = tabella.Rows[i].ItemArray[FileDecod["Variety"]].ToString().Trim();
|
||||
string suppl = tabella.Rows[i].ItemArray[FileDecod["Supplier"]].ToString().Trim();
|
||||
string sDate = tabella.Rows[i].ItemArray[FileDecod["DateRif"]].ToString().Trim();
|
||||
string sQty = tabella.Rows[i].ItemArray[FileDecod["QtyTot"]].ToString().Trim();
|
||||
string sNum = tabella.Rows[i].ItemArray[FileDecod["NumPack"]].ToString().Trim();
|
||||
string numPed = tabella.Rows[i].ItemArray[FileDecod["NumPed"]].ToString().Trim();
|
||||
string packPed = tabella.Rows[i].ItemArray[FileDecod["PackPed"]].ToString().Trim();
|
||||
string pesoPack = tabella.Rows[i].ItemArray[FileDecod["PesoPack"]].ToString().Trim();
|
||||
DateTime.TryParse(sDate, out dtRif);
|
||||
int.TryParse(sNum, out numPack);
|
||||
double.TryParse(sQty, out qtyTot);
|
||||
string identRG = ddt.Length > 2 ? $"{strFixId(ddt)}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}" : $"{dtRif:yyyyMMdd}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}";
|
||||
string notes = $"{numPed}x{packPed}x{pesoPack}";
|
||||
// verifico di avere dati per proseguire...
|
||||
bool checkIdent = !string.IsNullOrEmpty($"{prod}{variety}{suppl}");
|
||||
bool checkHeaderKo = (ddt == "DDT" || prod == "PRODOTTO");
|
||||
if (checkIdent && !checkHeaderKo)
|
||||
{
|
||||
BatchRec newRow = new BatchRec()
|
||||
{
|
||||
IdxODL = idxODL,
|
||||
IdentRG = identRG,
|
||||
DateRif = dtRif,
|
||||
ExtDoc = ddt,
|
||||
Product = prod,
|
||||
Variety = variety,
|
||||
Supplier = suppl,
|
||||
NumPack = numPack,
|
||||
QtyTot = qtyTot,
|
||||
Notes = notes
|
||||
};
|
||||
// verifico: se manca aggiungo
|
||||
if (!listaGiac.ContainsKey(identRG))
|
||||
{
|
||||
listaGiac.Add(identRG, newRow);
|
||||
}
|
||||
else
|
||||
{
|
||||
// altrimenti aggiorno giacenza con valori numerici
|
||||
listaGiac[identRG].NumPack += newRow.NumPack;
|
||||
listaGiac[identRG].QtyTot += newRow.QtyTot;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
numErr++;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
numErr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (listaGiac.Count > 0)
|
||||
{
|
||||
// converto in una nuova lista...
|
||||
int rCounter = 1;
|
||||
Dictionary<int, BatchRec> list2Send = new Dictionary<int, BatchRec>();
|
||||
foreach (var item in listaGiac)
|
||||
{
|
||||
list2Send.Add(rCounter, item.Value);
|
||||
rCounter++;
|
||||
}
|
||||
// ora invio i file con json...
|
||||
accodaRawData(rawTransfType.RegGiacenze, list2Send);
|
||||
fatto = true;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua sync dati
|
||||
/// </summary>
|
||||
protected override void processDataSync()
|
||||
{
|
||||
// richiesta check autoODL
|
||||
processAutoOdl();
|
||||
// effettua gestione import file...
|
||||
processFileImport();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
+107
-44
@@ -3,6 +3,7 @@ using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using static IOB_UT_NEXT.CustomObj;
|
||||
using static MapoSDK.WharehouseData;
|
||||
@@ -519,65 +520,122 @@ namespace IOB_WIN_NEXT
|
||||
/// Procedura di import file... formato excel Giacovelli
|
||||
/// </summary>
|
||||
/// <param name="fileItem"></param>
|
||||
protected override void importFile(string fileItem)
|
||||
protected override bool importFile(string fileItem)
|
||||
{
|
||||
bool fatto = false;
|
||||
int numErr = 0;
|
||||
// test procedura di import files excel x Giacovelli...
|
||||
var currExcel = new ExcelMan(fileItem);
|
||||
|
||||
// creo lista dati in formato RegGiacenze...
|
||||
Dictionary<string, BatchRec> listaGiac = new Dictionary<string, BatchRec>();
|
||||
|
||||
var dtSet = currExcel.getDataSet();
|
||||
|
||||
if (dtSet != null && dtSet.Tables != null && dtSet.Tables.Count > 0)
|
||||
{
|
||||
var tabella = dtSet.Tables[0];
|
||||
string nomeFile = Path.GetFileName(fileItem);
|
||||
nomeFile = nomeFile.Substring(0, nomeFile.LastIndexOf("."));
|
||||
var elSheet = dtSet.Tables;
|
||||
int idxTab = 0;
|
||||
//cerco lo sheet corretto se > 1
|
||||
if (dtSet.Tables.Count > 1)
|
||||
{
|
||||
for (int i = 0; i < dtSet.Tables.Count; i++)
|
||||
{
|
||||
if (nomeFile.Contains(dtSet.Tables[i].TableName))
|
||||
{
|
||||
idxTab = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
var tabella = dtSet.Tables[idxTab];
|
||||
int numRighe = tabella.Rows.Count;
|
||||
int idxODL = 0;
|
||||
DateTime dataDoc = DateTime.Today;
|
||||
DateTime.TryParse(nomeFile, out dataDoc);
|
||||
// cerco lotto x giornata...
|
||||
string sIdxODL = utils.callUrl(urlGetOdlAtDate(dataDoc));
|
||||
int.TryParse(sIdxODL, out idxODL);
|
||||
for (int i = 0; i < numRighe; i++)
|
||||
{
|
||||
// variabili di appoggio...
|
||||
DateTime dtRif = DateTime.Today;
|
||||
double qtyTot = 0;
|
||||
int numPack = 0;
|
||||
string ddt = tabella.Rows[i].ItemArray[FileDecod["ExtDoc"]].ToString();
|
||||
string prod = tabella.Rows[i].ItemArray[FileDecod["Product"]].ToString();
|
||||
string variety = tabella.Rows[i].ItemArray[FileDecod["Variety"]].ToString();
|
||||
string suppl = tabella.Rows[i].ItemArray[FileDecod["Supplier"]].ToString();
|
||||
string sDate = tabella.Rows[i].ItemArray[FileDecod["DateRif"]].ToString();
|
||||
string sQty = tabella.Rows[i].ItemArray[FileDecod["QtyTot"]].ToString();
|
||||
string sNum = tabella.Rows[i].ItemArray[FileDecod["NumPack"]].ToString();
|
||||
DateTime.TryParse(sDate, out dtRif);
|
||||
int.TryParse(sNum, out numPack);
|
||||
double.TryParse(sQty, out qtyTot);
|
||||
BatchRec newRow = new BatchRec()
|
||||
if (numErr < 5)
|
||||
{
|
||||
DateRif = dtRif,
|
||||
ExtDoc = ddt,
|
||||
Ident = $"{ddt}.{prod}.{variety}.{suppl}",
|
||||
Product = prod,
|
||||
Supplier = suppl,
|
||||
Variety = variety,
|
||||
NumPack = numPack,
|
||||
QtyTot = qtyTot
|
||||
};
|
||||
//newRow.Product = tabella.Rows[i].ItemArray[FileDecod["Product"]].ToString();
|
||||
//newRow.ExtDoc = tabella.Rows[i].ItemArray[FileDecod["ExtDoc"]].ToString();
|
||||
// verifico: se manca aggiungo
|
||||
if (!listaGiac.ContainsKey(newRow.Ident))
|
||||
{
|
||||
listaGiac.Add(newRow.Ident, newRow);
|
||||
try
|
||||
{
|
||||
// variabili di appoggio...
|
||||
DateTime dtRif = DateTime.Today;
|
||||
double qtyTot = 0;
|
||||
int numPack = 0;
|
||||
string ddt = tabella.Rows[i].ItemArray[FileDecod["ExtDoc"]].ToString().Trim();
|
||||
string prod = tabella.Rows[i].ItemArray[FileDecod["Product"]].ToString().Trim();
|
||||
string variety = tabella.Rows[i].ItemArray[FileDecod["Variety"]].ToString().Trim();
|
||||
string suppl = tabella.Rows[i].ItemArray[FileDecod["Supplier"]].ToString().Trim();
|
||||
string sDate = tabella.Rows[i].ItemArray[FileDecod["DateRif"]].ToString().Trim();
|
||||
string sQty = tabella.Rows[i].ItemArray[FileDecod["QtyTot"]].ToString().Trim();
|
||||
string sNum = tabella.Rows[i].ItemArray[FileDecod["NumPack"]].ToString().Trim();
|
||||
string numPed = tabella.Rows[i].ItemArray[FileDecod["NumPed"]].ToString().Trim();
|
||||
string packPed = tabella.Rows[i].ItemArray[FileDecod["PackPed"]].ToString().Trim();
|
||||
string pesoPack = tabella.Rows[i].ItemArray[FileDecod["PesoPack"]].ToString().Trim();
|
||||
DateTime.TryParse(sDate, out dtRif);
|
||||
int.TryParse(sNum, out numPack);
|
||||
double.TryParse(sQty, out qtyTot);
|
||||
string identRG = ddt.Length > 2 ? $"{strFixId(ddt)}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}" : $"{dtRif:yyyyMMdd}.{strFixId(prod)}.{strFixId(variety)}.{strFixId(suppl)}";
|
||||
string notes = $"{numPed}x{packPed}x{pesoPack}";
|
||||
// verifico di avere dati per proseguire...
|
||||
bool checkIdent = !string.IsNullOrEmpty($"{prod}{variety}{suppl}");
|
||||
bool checkHeaderKo = (ddt == "DDT" || prod == "PRODOTTO");
|
||||
if (checkIdent && !checkHeaderKo)
|
||||
{
|
||||
BatchRec newRow = new BatchRec()
|
||||
{
|
||||
IdxODL = idxODL,
|
||||
IdentRG = identRG,
|
||||
DateRif = dtRif,
|
||||
ExtDoc = ddt,
|
||||
Product = prod,
|
||||
Variety = variety,
|
||||
Supplier = suppl,
|
||||
NumPack = numPack,
|
||||
QtyTot = qtyTot,
|
||||
Notes = notes
|
||||
};
|
||||
// verifico: se manca aggiungo
|
||||
if (!listaGiac.ContainsKey(identRG))
|
||||
{
|
||||
listaGiac.Add(identRG, newRow);
|
||||
}
|
||||
else
|
||||
{
|
||||
// altrimenti aggiorno giacenza con valori numerici
|
||||
listaGiac[identRG].NumPack += newRow.NumPack;
|
||||
listaGiac[identRG].QtyTot += newRow.QtyTot;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
numErr++;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
numErr++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// altrimenti aggiorno giacenza con valori numerici
|
||||
listaGiac[newRow.Ident].NumPack += newRow.NumPack;
|
||||
listaGiac[newRow.Ident].QtyTot += newRow.QtyTot;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// ora invio i file con json...
|
||||
|
||||
if (listaGiac.Count > 0)
|
||||
{
|
||||
// converto in una nuova lista...
|
||||
int rCounter = 1;
|
||||
Dictionary<int, BatchRec> list2Send = new Dictionary<int, BatchRec>();
|
||||
foreach (var item in listaGiac)
|
||||
{
|
||||
list2Send.Add(rCounter, item.Value);
|
||||
rCounter++;
|
||||
}
|
||||
// ora invio i file con json...
|
||||
accodaRawData(rawTransfType.RegGiacenze, list2Send);
|
||||
fatto = true;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -760,6 +818,11 @@ namespace IOB_WIN_NEXT
|
||||
var taskGet = iobGetDataFromServer();
|
||||
var taskWrite = iobWriteLocalCSV();
|
||||
var taskSend = iobSendFTP("");
|
||||
|
||||
// richiesta check autoODL
|
||||
processAutoOdl();
|
||||
// effettua gestione import file...
|
||||
processFileImport();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<package id="EgwProxy.OsaiCncLib" version="3.6.2205.2015" targetFramework="net462" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net462" />
|
||||
<package id="FluentFTP" version="41.0.0" targetFramework="net462" />
|
||||
<package id="MapoSDK" version="6.14.2211.3010" targetFramework="net462" />
|
||||
<package id="MapoSDK" version="6.14.2211.3016" targetFramework="net462" />
|
||||
<package id="MathNet.Numerics" version="4.15.0" targetFramework="net462" />
|
||||
<package id="Microsoft.CodeAnalysis.NetAnalyzers" version="6.0.0" targetFramework="net462" developmentDependency="true" />
|
||||
<package id="Microsoft.Extensions.Logging.Abstractions" version="2.1.0" targetFramework="net462" />
|
||||
|
||||
Reference in New Issue
Block a user