diff --git a/Step.Database/Controllers/MaintenancesController.cs b/Step.Database/Controllers/MaintenancesController.cs index 890386f7..aea1dd86 100644 --- a/Step.Database/Controllers/MaintenancesController.cs +++ b/Step.Database/Controllers/MaintenancesController.cs @@ -79,11 +79,17 @@ namespace Step.Database.Controllers public MaintenanceModel Create(DTONewMaintenanceModel newMaint, int userId) { + int counter = 0; + + //fix the maintenance number to 1 (machine Counter) + if (newMaint.Type == MAINTENANCE_TYPE.MACHINE_INTERVAL) + counter = 1; + MaintenanceModel dbMaint = new MaintenanceModel() { MaintenanceId = GetUserMaintenanceId(dbCtx.Maintenances), CreationDate = DateTime.Now, - CounterId = 0, + CounterId = counter, Interval = newMaint.Interval, Deadline = newMaint.Deadline, Description = newMaint.Description, @@ -98,7 +104,6 @@ namespace Step.Database.Controllers dbCtx.Maintenances.Add(dbMaint); // Commit changes dbCtx.SaveChanges(); - return dbMaint; } diff --git a/Step.NC/NcAdapter.cs b/Step.NC/NcAdapter.cs index 8e4e9931..29248367 100644 --- a/Step.NC/NcAdapter.cs +++ b/Step.NC/NcAdapter.cs @@ -595,6 +595,11 @@ namespace Step.NC } } + if(performed != null && performed.ControlWord == -2) + { + performed = null; + } + dtoMaintenancesModel.Add(new DTOMaintenanceModel() { Id = currMaintenance.MaintenanceId, diff --git a/Step/Controllers/WebApi/ApiMaintenanceController.cs b/Step/Controllers/WebApi/ApiMaintenanceController.cs index 52423889..4c33a44d 100644 --- a/Step/Controllers/WebApi/ApiMaintenanceController.cs +++ b/Step/Controllers/WebApi/ApiMaintenanceController.cs @@ -53,21 +53,49 @@ namespace Step.Controllers.WebApi var identity = User.Identity as ClaimsIdentity; // Find user id from the bearer token - var userId = identity.Claims.FirstOrDefault(c => c.Type == USER_ID_KEY); - + var userId = identity.Claims.FirstOrDefault(c => c.Type == USER_ID_KEY); + using (MaintenancesController maintenancesController = new MaintenancesController()) { MaintenanceModel dbMaint = maintenancesController.Create(newMaint, Convert.ToInt32(userId.Value)); - using (NcAdapter ncAdapter = new NcAdapter()) - { - ncAdapter.Connect(); - CmsError cmsError = ncAdapter.GetMaintenanceDataById(dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel maintenance); - if (cmsError.IsError()) - return BadRequest(cmsError.localizationKey); - - return Ok(maintenance); + if(dbMaint.Type == MAINTENANCE_TYPE.MACHINE_INTERVAL) + { + + // Update data + using (NcAdapter ncAdapter = new NcAdapter()) + { + ncAdapter.Connect(); + CmsError cmsError = ncAdapter.GetMaintenanceDataById(dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel maintenance); + if (cmsError.IsError()) + { + maintenancesController.Delete(dbMaint); + return BadRequest(cmsError.localizationKey); + } + + PerformedMaintenanceModel performed = maintenancesController.PerformeMaintenance(maintenance.PlcCounter / 60, dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), -2); + if (performed == null) + { + maintenancesController.Delete(dbMaint); + return NotFound(); + } + + return Ok(maintenance); + + } } + else + { + using (NcAdapter ncAdapter = new NcAdapter()) + { + ncAdapter.Connect(); + CmsError cmsError = ncAdapter.GetMaintenanceDataById(dbMaint.MaintenanceId, Convert.ToInt32(userId.Value), out DTOMaintenanceModel maintenance); + if (cmsError.IsError()) + return BadRequest(cmsError.localizationKey); + + return Ok(maintenance); + } + } } } diff --git a/Step/wwwroot/assets/styles/base/maintenance-card.less b/Step/wwwroot/assets/styles/base/maintenance-card.less index cc1eca01..74cf2652 100644 --- a/Step/wwwroot/assets/styles/base/maintenance-card.less +++ b/Step/wwwroot/assets/styles/base/maintenance-card.less @@ -74,33 +74,38 @@ left: 0%; width: 100%; } - .estimated-time, .expiring{ + .estimated-time,.expiring{ height: calc(~'96px - 20px'); border-radius: 2px; background-color: @color-white2; margin: 20px 0 20px 0; padding: 10px; - .title{ - display: block; - margin: 18px auto; - text-align: center; - font-size: 14px; - color: @color-greyish-brown; - } - .time{ - display: block; - margin: 18px auto; - text-align: center; - font-size: 24px; - line-height: 0.75px; - color: @color-clear-blue; - &.yellow{ - color: @color-squash; + display: flex; + flex-flow: row; + justify-content: space-around; + .internalExpiring{ + .title{ + display: block; + margin: 18px auto; + text-align: center; + font-size: 14px; + color: @color-greyish-brown; } - &.red{ - color: @color-scarlet; + .time{ + display: block; + margin: 18px auto; + text-align: center; + font-size: 24px; + line-height: 0.75px; + color: @color-clear-blue; + &.yellow{ + color: @color-squash; + } + &.red{ + color: @color-scarlet; + } } - } + } } } .row-wizard{ diff --git a/Step/wwwroot/assets/styles/style.css b/Step/wwwroot/assets/styles/style.css index 6fcc7a5a..c88d973b 100644 --- a/Step/wwwroot/assets/styles/style.css +++ b/Step/wwwroot/assets/styles/style.css @@ -852,8 +852,8 @@ margin-top: 17px; font-size: 18px; } -.modal.create-maintenance .typology .radiobutton label[for="datefixed"] { - margin-right: 209px; +.modal.create-maintenance .typology .radiobutton label { + width: 220px; } .modal.create-maintenance .typology .radiobutton [type="radio"]:checked, .modal.create-maintenance .typology .radiobutton [type="radio"]:not(:checked) { @@ -1113,6 +1113,9 @@ -moz-appearance: none; appearance: none; background: url(/assets/icons/_png/carets-up-down-blu-25x25.png) no-repeat 99% 50%; + font-family: 'Work Sans', sans-serif; + color: #4b4b4b; + font-size: 18px; } .modal.info-equipment-box { width: 896px; @@ -18015,17 +18018,20 @@ footer .container button.big:before { background-color: #f1f1f1; margin: 20px 0 20px 0; padding: 10px; + display: flex; + flex-flow: row; + justify-content: space-around; } -.maintenance-card .body .box .info .estimated-time .title, -.maintenance-card .body .box .info .expiring .title { +.maintenance-card .body .box .info .estimated-time .internalExpiring .title, +.maintenance-card .body .box .info .expiring .internalExpiring .title { display: block; margin: 18px auto; text-align: center; font-size: 14px; color: #4b4b4b; } -.maintenance-card .body .box .info .estimated-time .time, -.maintenance-card .body .box .info .expiring .time { +.maintenance-card .body .box .info .estimated-time .internalExpiring .time, +.maintenance-card .body .box .info .expiring .internalExpiring .time { display: block; margin: 18px auto; text-align: center; @@ -18033,12 +18039,12 @@ footer .container button.big:before { line-height: 0.75px; color: #1791ff; } -.maintenance-card .body .box .info .estimated-time .time.yellow, -.maintenance-card .body .box .info .expiring .time.yellow { +.maintenance-card .body .box .info .estimated-time .internalExpiring .time.yellow, +.maintenance-card .body .box .info .expiring .internalExpiring .time.yellow { color: #f5a623; } -.maintenance-card .body .box .info .estimated-time .time.red, -.maintenance-card .body .box .info .expiring .time.red { +.maintenance-card .body .box .info .estimated-time .internalExpiring .time.red, +.maintenance-card .body .box .info .expiring .internalExpiring .time.red { color: #d0021b; } .maintenance-card .body .box .row-wizard { diff --git a/Step/wwwroot/src/app_modules/maintenance/components/maintenance-card.ts b/Step/wwwroot/src/app_modules/maintenance/components/maintenance-card.ts index 549e981a..ca228c4b 100644 --- a/Step/wwwroot/src/app_modules/maintenance/components/maintenance-card.ts +++ b/Step/wwwroot/src/app_modules/maintenance/components/maintenance-card.ts @@ -40,6 +40,10 @@ export default class MaintenanceCard extends Vue { @Prop({ default: false }) canPerform:boolean; + + @Prop({ default: "" }) + plcCounter:string; + // enableModifyNote: {default: true} diff --git a/Step/wwwroot/src/app_modules/maintenance/components/maintenance-card.vue b/Step/wwwroot/src/app_modules/maintenance/components/maintenance-card.vue index f19bf573..091975e7 100644 --- a/Step/wwwroot/src/app_modules/maintenance/components/maintenance-card.vue +++ b/Step/wwwroot/src/app_modules/maintenance/components/maintenance-card.vue @@ -25,8 +25,22 @@ {{'maintenance_card_created_timestamp' | localize("Manutenzione creata in data %s alle ore %s",convertDate(selectedMaintenance.creationDate),convertDateToTime(selectedMaintenance.creationDate))}}
-
{{'maintenance_state_'+selectedMaintenance.state | localize("Stato")}}
-
{{expiration}}
+
+
+ {{'maintenance_state_'+selectedMaintenance.state | localize("Stato")}} +
+
+ {{expiration}} +
+
+
+
+ {{'maintenance_machine_timer' | localize("Machine timer value")}} +
+
+ {{plcCounter}} +
+