Fix import-export tool table
Fix mag position page
This commit is contained in:
Binary file not shown.
@@ -557,6 +557,8 @@ namespace Step.Database.Controllers
|
||||
Tools = FindTools(),
|
||||
Families = FindFamilies(),
|
||||
Shanks = FindShanks()
|
||||
.Select(x => { x.MagazineId = null; x.PositionId = null; return x; })
|
||||
.ToList()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -566,29 +568,32 @@ namespace Step.Database.Controllers
|
||||
List<DbNcFamilyModel> families = FindFamilies();
|
||||
List<DbNcShankModel> shanks = FindShanks();
|
||||
|
||||
// loop thought new families
|
||||
foreach (var family in data.Families)
|
||||
{
|
||||
// Check if not exist
|
||||
if (families.FirstOrDefault(x => x.FamilyId == family.FamilyId) == null)
|
||||
dbCtx.Families.Add(family);
|
||||
}
|
||||
if(data.Families != null)
|
||||
// loop thought new families
|
||||
foreach (var family in data.Families)
|
||||
{
|
||||
// Check if not exist
|
||||
if (families.FirstOrDefault(x => x.FamilyId == family.FamilyId) == null)
|
||||
dbCtx.Families.Add(family);
|
||||
}
|
||||
|
||||
// loop thought new shanks
|
||||
foreach (var shank in data.Shanks)
|
||||
{
|
||||
// Check if not exist
|
||||
if (shanks.FirstOrDefault(x => x.ShankId == shank.ShankId) == null)
|
||||
dbCtx.Shanks.Add(shank);
|
||||
}
|
||||
if(data.Shanks != null)
|
||||
// loop thought new shanks
|
||||
foreach (var shank in data.Shanks)
|
||||
{
|
||||
// Check if not exist
|
||||
if (shanks.FirstOrDefault(x => x.ShankId == shank.ShankId) == null)
|
||||
dbCtx.Shanks.Add(shank);
|
||||
}
|
||||
|
||||
// loop thought new tools
|
||||
foreach (var tool in data.Tools)
|
||||
{
|
||||
// Check if not exist
|
||||
if (tools.FirstOrDefault(x => x.ToolId == tool.ToolId) == null)
|
||||
dbCtx.Tools.Add(tool);
|
||||
}
|
||||
if(data.Tools != null)
|
||||
// loop thought new tools
|
||||
foreach (var tool in data.Tools)
|
||||
{
|
||||
// Check if not exist
|
||||
if (tools.FirstOrDefault(x => x.ToolId == tool.ToolId) == null)
|
||||
dbCtx.Tools.Add(tool);
|
||||
}
|
||||
|
||||
// Save
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
@@ -240,6 +240,7 @@ namespace Step.Model
|
||||
public const string MAG_POS_DISABLED = "error_mag_pos_disabled";
|
||||
public const string ID_ALREADY_EXIST = "error_id_already_exist";
|
||||
public const string PASSWORD_IS_INVALID = "error_password_is_invalid";
|
||||
public const string IMPORT_FILE_NOT_VALID = "error_import_file_not_valid";
|
||||
}
|
||||
|
||||
// File paths
|
||||
|
||||
@@ -402,8 +402,9 @@
|
||||
<tooling_equipment_cedgepar_boomLenght>Lunghezza Braccio</tooling_equipment_cedgepar_boomLenght>
|
||||
<tooling_equipment_cedgepar_ballRadius>Raggio Sfera</tooling_equipment_cedgepar_ballRadius>
|
||||
|
||||
<!-- Tool Manager - Select-Options -->
|
||||
<tooling_equipment_list_select_none>Nessuna selezione</tooling_equipment_list_select_none>
|
||||
<!-- Tool Manager - Select-Options -->
|
||||
<tooling_equipment_list_select_none>Nessuna selezione</tooling_equipment_list_select_none>
|
||||
<tooling_equipment_list_select_generic>Generico</tooling_equipment_list_select_generic>
|
||||
<tooling_equipment_list_select_timeLife>A Tempo</tooling_equipment_list_select_timeLife>
|
||||
<tooling_equipment_list_select_countLife>A Contatore</tooling_equipment_list_select_countLife>
|
||||
<tooling_equipment_list_select_wearLife>Ad Usura</tooling_equipment_list_select_wearLife>
|
||||
|
||||
@@ -401,7 +401,8 @@
|
||||
<tooling_equipment_cedgepar_ballRadius>Ball Radius</tooling_equipment_cedgepar_ballRadius>
|
||||
|
||||
<!-- Tool Manager - Select-Options -->
|
||||
<tooling_equipment_list_select_none>None</tooling_equipment_list_select_none>
|
||||
<tooling_equipment_list_select_none>None</tooling_equipment_list_select_none>
|
||||
<tooling_equipment_list_select_generic>Generic</tooling_equipment_list_select_generic>
|
||||
<tooling_equipment_list_select_timeLife>Time</tooling_equipment_list_select_timeLife>
|
||||
<tooling_equipment_list_select_countLife>Count</tooling_equipment_list_select_countLife>
|
||||
<tooling_equipment_list_select_wearLife>Wear</tooling_equipment_list_select_wearLife>
|
||||
|
||||
@@ -576,7 +576,7 @@ namespace Step.Controllers.WebApi
|
||||
}
|
||||
|
||||
using (NcToolTableHandler ncHandler = new NcToolTableHandler())
|
||||
{
|
||||
{
|
||||
CmsError cmsError = ncHandler.Connect();
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
@@ -944,8 +944,13 @@ namespace Step.Controllers.WebApi
|
||||
|
||||
// Convert bytes into json string
|
||||
string jsonString = Encoding.UTF8.GetString(fileBytes);
|
||||
// Deserialize the string into DTO object
|
||||
DTOExportToolTableModel importData = JsonConvert.DeserializeObject<DTOExportToolTableModel>(jsonString);
|
||||
|
||||
bool val = IsValidJson(jsonString, out DTOExportToolTableModel importData);
|
||||
if (!val)
|
||||
return BadRequest(API_ERROR_KEYS.IMPORT_FILE_NOT_VALID);
|
||||
|
||||
if(importData.Families == null || importData.Shanks == null || importData.Tools == null)
|
||||
return BadRequest(API_ERROR_KEYS.IMPORT_FILE_NOT_VALID);
|
||||
|
||||
using ( NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
@@ -958,5 +963,23 @@ namespace Step.Controllers.WebApi
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
public bool IsValidJson(string jsonString, out DTOExportToolTableModel data)
|
||||
{
|
||||
data = new DTOExportToolTableModel();
|
||||
if (string.IsNullOrWhiteSpace(jsonString))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
// Deserialize the string into DTO object
|
||||
data = JsonConvert.DeserializeObject<DTOExportToolTableModel>(jsonString);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,7 @@ export default class toolingMagPos extends Vue {
|
||||
}
|
||||
|
||||
public selectedTool: any = null;
|
||||
public copySelectedMagPos: any = null;
|
||||
|
||||
public enableModify: any = false;
|
||||
public disableList: any = false;
|
||||
@@ -79,6 +80,8 @@ export default class toolingMagPos extends Vue {
|
||||
|
||||
public selectTool(item){
|
||||
this.selectedTool = item;
|
||||
this.copySelectedMagPos = Object.assign({}, item);
|
||||
|
||||
this.enableModify = false;
|
||||
this.magposConfiguration = (this.$store.state as AppModel).tooling.magazinePosConfiguration;
|
||||
}
|
||||
@@ -92,7 +95,10 @@ export default class toolingMagPos extends Vue {
|
||||
// this.selectedTool = null;
|
||||
this.disableList = false;
|
||||
this.enableModify = false;
|
||||
|
||||
this.selectedTool = Object.assign({},this.copySelectedMagPos);
|
||||
}
|
||||
|
||||
async modifyMagPos(model) {
|
||||
if(this.isSiemens){
|
||||
awaiter(new ToolingService().UpdateMagPos(model).then(response => {
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
</div>
|
||||
<!-- Siemens -->
|
||||
<div class="box-right" v-if="(isSiemens) && selectedTool" :class="{'selected': disableList}" >
|
||||
<!-- <button class="btn"><i class="fa fa-trash"></i></button> -->
|
||||
<div class="box-right-label-header">{{'tooling_magpos_editlabel' | localize("Modifica della Manina %d nel magazzino %d",selectedTool.positionId,selectedTool.magazineId)}}</div>
|
||||
<div class="list-skill-magpos scrollable">
|
||||
<div class="list-skill-magpos-category">
|
||||
@@ -37,7 +36,7 @@
|
||||
<input-box v-for="m in magposConfiguration" :key="m.name"
|
||||
v-if="m.name != ''"
|
||||
v-model="selectedTool[m.name]"
|
||||
:minValue="m.minValue"
|
||||
:minValue="m.minValue"
|
||||
:maxValue="m.maxValue"
|
||||
:read-only="m.readOnly || !disableList"
|
||||
:title="'tooling_equipment_param_magpos_' + m.name | localize(m.name)"
|
||||
@@ -46,15 +45,14 @@
|
||||
</input-box>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tooling-magpos-footer">
|
||||
<div class="tooling-magpos-footer">
|
||||
<button class="btn" v-if="!enableModify" @click="modify()">{{'tooling_equipment_button_modify' | localize("Modifica")}}</button>
|
||||
<button class="btn" v-if="enableModify" @click="cancel('/tooling')">{{'tooling_equipment_button_cancel' | localize("Annulla")}}</button>
|
||||
<button class="btn blue-reverse" :disabled="!isValid" v-if="enableModify" @click="modifyMagPos(selectedTool)">{{'tooling_equipment_button_save' | localize("Salva")}}</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Osai -->
|
||||
<!-- OSAI-FANUC -->
|
||||
<div class="box-right" v-if="(!isSiemens) && selectedTool" :class="{'selected': disableList}" >
|
||||
<!-- <button class="btn"><i class="fa fa-trash"></i></button> -->
|
||||
<div class="box-right-label-header">{{'tooling_magpos_editlabel' | localize("Modifica della Manina %d nel magazzino %d",selectedTool.positionId,selectedTool.magazineId)}}</div>
|
||||
<div class="list-skill-magpos scrollable">
|
||||
<div class="list-skill-magpos-category">
|
||||
@@ -62,16 +60,16 @@
|
||||
<input-box v-for="m in magposConfiguration" :key="m.name"
|
||||
v-if="m.name != ''"
|
||||
v-model="selectedTool[m.name]"
|
||||
:minValue="m.minValue"
|
||||
:minValue="m.minValue"
|
||||
:maxValue="m.maxValue"
|
||||
:read-only="m.readOnly || !disableList"
|
||||
:title="'tooling_equipment_param_magpos_' + m.name | localize(m.name)"
|
||||
:type="m.type">
|
||||
<option v-for="(s, k) in m.selectValues" :key="k" :selected="selectedTool[m.name]" :value="k">{{'physical_type_position_select_' + s | localize(s)}}</option>
|
||||
<option v-for="(s, k) in m.selectValues" :key="k" :selected="selectedTool[m.name]" :value="k">{{k}} - {{'tooling_equipment_list_select_' + s | localize(s)}}</option>
|
||||
</input-box>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tooling-magpos-footer">
|
||||
<div class="tooling-magpos-footer">
|
||||
<button class="btn" v-if="!enableModify" @click="modify()">{{'tooling_equipment_button_modify' | localize("Modifica")}}</button>
|
||||
<button class="btn" v-if="enableModify" @click="cancel('/tooling')">{{'tooling_equipment_button_cancel' | localize("Annulla")}}</button>
|
||||
<button class="btn blue-reverse" :disabled="!isValid" v-if="enableModify" @click="modifyMagPos(selectedTool)">{{'tooling_equipment_button_save' | localize("Salva")}}</button>
|
||||
|
||||
@@ -33,6 +33,9 @@ export default class Tooling extends Vue {
|
||||
// return (this.$store.state as AppModel).tooling.magazines;
|
||||
// }
|
||||
|
||||
public loadingExport: boolean = false
|
||||
public loadingImport: boolean = false
|
||||
|
||||
@Watch("magazineStatusModel")
|
||||
public modalBlockMagazine() {
|
||||
if (this.magazineStatusModel.action == 1) {
|
||||
@@ -84,10 +87,12 @@ export default class Tooling extends Vue {
|
||||
}
|
||||
|
||||
public exportToolTable(){
|
||||
new DepotService().exportMagazines()
|
||||
this.loadingExport = true
|
||||
new DepotService().exportMagazines().then(() => this.loadingExport = false)
|
||||
}
|
||||
|
||||
async onChangeFile(e) {
|
||||
new DepotService().sendImportFile(e.target.files[0]);
|
||||
this.loadingImport = true
|
||||
new DepotService().sendImportFile(e.target.files[0]).then(() => this.loadingImport = false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,11 @@
|
||||
<label for="input" class="btn">
|
||||
<span>{{'tooling_magazine_export_label' | localize("Import")}}</span>
|
||||
<input id="input" type="file" @change="onChangeFile" accept="application/json" style="display: none"/>
|
||||
<i v-if="loadingImport" class="fa fa-spin"></i>
|
||||
</label>
|
||||
<button class="btn" @click="exportToolTable()">{{'tooling_magazine_export_label' | localize("Export")}}</button>
|
||||
<button class="btn" @click="exportToolTable()">{{'tooling_magazine_export_label' | localize("Export")}}
|
||||
<i v-if="loadingExport" class="fa fa-spin"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tooling-boxbody">
|
||||
|
||||
Reference in New Issue
Block a user