Before refactor
This commit is contained in:
@@ -8,6 +8,7 @@ export class Record extends Base {
|
|||||||
value4?: number;
|
value4?: number;
|
||||||
value5?: number;
|
value5?: number;
|
||||||
value6?: number;
|
value6?: number;
|
||||||
|
value7?: number;
|
||||||
value8?: number;
|
value8?: number;
|
||||||
value9?: number;
|
value9?: number;
|
||||||
value10?: number;
|
value10?: number;
|
||||||
@@ -32,6 +33,7 @@ export class Record extends Base {
|
|||||||
value29?: number;
|
value29?: number;
|
||||||
value30?: number;
|
value30?: number;
|
||||||
value31?: number;
|
value31?: number;
|
||||||
|
value32?: number;
|
||||||
desc1?: string;
|
desc1?: string;
|
||||||
desc2?: string;
|
desc2?: string;
|
||||||
desc3?: string;
|
desc3?: string;
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
@if (document?.records) {
|
||||||
|
<div>{{shortRecords | json}}</div>
|
||||||
|
}
|
||||||
<form [formGroup]="form" novalidate>
|
<form [formGroup]="form" novalidate>
|
||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-header style="display: block;">
|
<mat-card-header style="display: block;">
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ export class LayerDetailComponent implements OnInit {
|
|||||||
|
|
||||||
LayerType = LayerType;
|
LayerType = LayerType;
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
shortRecords: any = null;
|
||||||
|
|
||||||
@ViewChild(MatSort) sort!: MatSort;
|
@ViewChild(MatSort) sort!: MatSort;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -59,6 +62,8 @@ export class LayerDetailComponent implements OnInit {
|
|||||||
this.document.modified = `${this.datePipe.transform(this.document.modifiedAt?.toDate(), 'short')}, ${this.document.modifiedBy?.userName}`;
|
this.document.modified = `${this.datePipe.transform(this.document.modifiedAt?.toDate(), 'short')}, ${this.document.modifiedBy?.userName}`;
|
||||||
this.valueSum = this.document.records.map(t => t.value1 || 0).reduce((acc, value) => acc + value, 0);
|
this.valueSum = this.document.records.map(t => t.value1 || 0).reduce((acc, value) => acc + value, 0);
|
||||||
this.createColumns();
|
this.createColumns();
|
||||||
|
|
||||||
|
this.prepareDataForAI();
|
||||||
}
|
}
|
||||||
private async load(): Promise<Layer> {
|
private async load(): Promise<Layer> {
|
||||||
return await Layer.getById(this.route$.snapshot.paramMap.get('id') || "", this.http$);
|
return await Layer.getById(this.route$.snapshot.paramMap.get('id') || "", this.http$);
|
||||||
@@ -105,4 +110,45 @@ export class LayerDetailComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async prepareDataForAI() {
|
||||||
|
const codes = this.document.records.map(x => x.code);
|
||||||
|
const weatherURL = 'https://archive-api.open-meteo.com/v1/archive?latitude=54.36685&longitude=18.692&start_date=2023-12-01&end_date=2023-12-31&daily=temperature_2m_mean,rain_sum,snowfall_sum,wind_speed_10m_max&timezone=Europe%2FBerlin';
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
this.http$.get(weatherURL).subscribe((data: any) => {
|
||||||
|
console.log('pogoda', data);
|
||||||
|
|
||||||
|
// loop throught all days in december 2023
|
||||||
|
const days = data['daily']['time'].length;
|
||||||
|
console.log(days);
|
||||||
|
this.shortRecords = [];
|
||||||
|
for (let i = 0; i < days; i++) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const res: any = {};
|
||||||
|
res.day = i+1;
|
||||||
|
res.code = 600;
|
||||||
|
res.temperature = data['daily']['temperature_2m_mean'][i];
|
||||||
|
res.rain = data['daily']['rain_sum'][i];
|
||||||
|
res.snow = data['daily']['snowfall_sum'][i];
|
||||||
|
res.wind = data['daily']['wind_speed_10m_max'][i];
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const codeValues: any[] = [];
|
||||||
|
codes.forEach(code => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const res: any = { code: code };
|
||||||
|
res.value = this.getRecordValue(this.document.records.find(x => x.code === code)!, i+1);
|
||||||
|
codeValues.push(res);
|
||||||
|
});
|
||||||
|
res.sell = codeValues.filter(x => x.value > 0);
|
||||||
|
//= codes.map(code => this.getRecordValue(this.document.records.find(x => x.code === code)!, i+1));
|
||||||
|
this.shortRecords.push(res);
|
||||||
|
}
|
||||||
|
console.log('shortRecords', this.shortRecords);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getRecordValue(record: Record, index: number) {
|
||||||
|
const propertyName = `value${index}` as keyof typeof record;
|
||||||
|
return record[propertyName];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ export const environment = {
|
|||||||
appName: "LOCAL_DiunaBI",
|
appName: "LOCAL_DiunaBI",
|
||||||
production: false,
|
production: false,
|
||||||
api: {
|
api: {
|
||||||
url: "http://localhost:5400/api"
|
//url: "http://localhost:5400/api"
|
||||||
//url: "https://diunabi-morska.bim-it.pl/api"
|
url: "https://diunabi-morska.bim-it.pl/api"
|
||||||
},
|
},
|
||||||
google: {
|
google: {
|
||||||
clientId: "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com"
|
clientId: "107631825312-bkfe438ehr9k9ecb2h76g802tj6advma.apps.googleusercontent.com"
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ namespace WebAPI.Controllers
|
|||||||
.Where(x =>
|
.Where(x =>
|
||||||
x.Records!.Any(x => x.Code == "Type" && x.Desc1 == "ImportWorker") &&
|
x.Records!.Any(x => x.Code == "Type" && x.Desc1 == "ImportWorker") &&
|
||||||
x.Records!.Any(x => x.Code == "IsEnabled" && x.Desc1 == "True")
|
x.Records!.Any(x => x.Code == "IsEnabled" && x.Desc1 == "True")
|
||||||
|
&& x.Number == 539
|
||||||
)
|
)
|
||||||
.OrderBy(x => x.CreatedAt)
|
.OrderBy(x => x.CreatedAt)
|
||||||
.ToList();
|
.ToList();
|
||||||
@@ -184,7 +185,7 @@ namespace WebAPI.Controllers
|
|||||||
}
|
}
|
||||||
var startDateParsed = DateTime.ParseExact(startDate!, "yyyy.MM.dd", null);
|
var startDateParsed = DateTime.ParseExact(startDate!, "yyyy.MM.dd", null);
|
||||||
var endDateParsed = DateTime.ParseExact(endDate!, "yyyy.MM.dd", null);
|
var endDateParsed = DateTime.ParseExact(endDate!, "yyyy.MM.dd", null);
|
||||||
if (startDateParsed.Date <= DateTime.UtcNow.Date && endDateParsed.Date >= DateTime.UtcNow.Date)
|
if (startDateParsed.Date <= DateTime.UtcNow.Date && endDateParsed.Date >= DateTime.UtcNow.Date || true)
|
||||||
{
|
{
|
||||||
MorskaImporter importer = new MorskaImporter(db, googleSheetValues, this);
|
MorskaImporter importer = new MorskaImporter(db, googleSheetValues, this);
|
||||||
importer.import(importWorker);
|
importer.import(importWorker);
|
||||||
@@ -259,6 +260,7 @@ namespace WebAPI.Controllers
|
|||||||
x.Records!.Any(x => x.Code == "Type" && x.Desc1 == "ProcessWorker") &&
|
x.Records!.Any(x => x.Code == "Type" && x.Desc1 == "ProcessWorker") &&
|
||||||
x.Records!.Any(x => x.Code == "IsEnabled" && x.Desc1 == "True") &&
|
x.Records!.Any(x => x.Code == "IsEnabled" && x.Desc1 == "True") &&
|
||||||
x.Records!.Any(x => x.Code == "ProcessType" && x.Desc1 == type)
|
x.Records!.Any(x => x.Code == "ProcessType" && x.Desc1 == type)
|
||||||
|
&& x.Number == 800
|
||||||
)
|
)
|
||||||
.OrderBy(x => x.CreatedAt)
|
.OrderBy(x => x.CreatedAt)
|
||||||
.ToList();
|
.ToList();
|
||||||
@@ -279,7 +281,7 @@ namespace WebAPI.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProcessLayer(processWorker);
|
ProcessLayer(processWorker, true);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace WebAPI.Models
|
namespace WebAPI.Models
|
||||||
{
|
{
|
||||||
public class Record
|
public class Record
|
||||||
{
|
{
|
||||||
#region Properties
|
#region Properties
|
||||||
[Key]
|
[Key]
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string? Code { get; set; }
|
public string? Code { get; set; }
|
||||||
public float? Value1 { get; set; }
|
public float? Value1 { get; set; }
|
||||||
public float? Value2 { get; set; }
|
public float? Value2 { get; set; }
|
||||||
public float? Value3 { get; set; }
|
public float? Value3 { get; set; }
|
||||||
public float? Value4 { get; set; }
|
public float? Value4 { get; set; }
|
||||||
@@ -42,23 +42,23 @@ namespace WebAPI.Models
|
|||||||
public float? Value31 { get; set; }
|
public float? Value31 { get; set; }
|
||||||
public float? Value32 { get; set; }
|
public float? Value32 { get; set; }
|
||||||
//Description fields
|
//Description fields
|
||||||
public string? Desc1 { get; set; }
|
public string? Desc1 { get; set; }
|
||||||
public string? Desc2 { get; set; }
|
public string? Desc2 { get; set; }
|
||||||
public string? Desc3 { get; set; }
|
public string? Desc3 { get; set; }
|
||||||
public string? Desc4 { get; set; }
|
public string? Desc4 { get; set; }
|
||||||
public string? Desc5 { get; set; }
|
public string? Desc5 { get; set; }
|
||||||
public DateTime CreatedAt { get; set; }
|
public DateTime CreatedAt { get; set; }
|
||||||
public DateTime ModifiedAt { get; set; }
|
public DateTime ModifiedAt { get; set; }
|
||||||
public bool IsDeleted { get; set; }
|
public bool IsDeleted { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
#region Relations
|
#region Relations
|
||||||
[Required]
|
[Required]
|
||||||
public Guid CreatedById { get; set; }
|
public Guid CreatedById { get; set; }
|
||||||
public User? CreatedBy { get; set; }
|
public User? CreatedBy { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public Guid ModifiedById { get; set; }
|
public Guid ModifiedById { get; set; }
|
||||||
public User? ModifiedBy { get; set; }
|
public User? ModifiedBy { get; set; }
|
||||||
public Guid LayerId { get; set; }
|
public Guid LayerId { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ namespace DiunaBIWebAPI.dataImporters
|
|||||||
for (int i = 0; i < data[1].Count; i++)
|
for (int i = 0; i < data[1].Count; i++)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
double test;
|
||||||
|
double.TryParse(data[1][5].ToString(), CultureInfo.GetCultureInfo("pl-PL"), out test);
|
||||||
if (
|
if (
|
||||||
data[0][i].ToString()?.Length > 0 &&
|
data[0][i].ToString()?.Length > 0 &&
|
||||||
float.TryParse(data[1][i].ToString(), CultureInfo.GetCultureInfo("pl-PL"), out value))
|
float.TryParse(data[1][i].ToString(), CultureInfo.GetCultureInfo("pl-PL"), out value))
|
||||||
@@ -115,9 +117,9 @@ namespace DiunaBIWebAPI.dataImporters
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
db.Layers.Add(layer);
|
//db.Layers.Add(layer);
|
||||||
controller.SaveRecords(layer.Id, newRecords, Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D"));
|
//controller.SaveRecords(layer.Id, newRecords, Guid.Parse("F392209E-123E-4651-A5A4-0B1D6CF9FF9D"));
|
||||||
db.SaveChanges();
|
//db.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ namespace WebAPI.dataProcessors
|
|||||||
{
|
{
|
||||||
Values = new List<IList<object>> { marchValues }
|
Values = new List<IList<object>> { marchValues }
|
||||||
};
|
};
|
||||||
SpreadsheetsResource.ValuesResource.UpdateRequest updateMarch = googleSheetValues.Update(marchValueRange, sheetId, $"{sheetName}!C14:CH1");
|
SpreadsheetsResource.ValuesResource.UpdateRequest updateMarch = googleSheetValues.Update(marchValueRange, sheetId, $"{sheetName}!C14:CH14");
|
||||||
updateMarch.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.USERENTERED;
|
updateMarch.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.USERENTERED;
|
||||||
updateMarch.Execute();
|
updateMarch.Execute();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user