|
|
|
|
@ -10,9 +10,6 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
|
|
|
|
|
|
|
|
import com.evolute.adt.TreeTools;
|
|
|
|
|
import com.evolute.utils.error.ErrorLogger;
|
|
|
|
|
|
|
|
|
|
import siprp.database.cayenne.objects.Empresas;
|
|
|
|
|
import siprp.database.cayenne.objects.Estabelecimentos;
|
|
|
|
|
import siprp.database.cayenne.objects.HsArea;
|
|
|
|
|
@ -52,6 +49,9 @@ import siprp.logic.node.NodeRiscoTema;
|
|
|
|
|
import siprp.logic.node.PostoNode;
|
|
|
|
|
import siprp.logic.node.PostoRelatorioNode;
|
|
|
|
|
|
|
|
|
|
import com.evolute.adt.TreeTools;
|
|
|
|
|
import com.evolute.utils.error.ErrorLogger;
|
|
|
|
|
|
|
|
|
|
public class HigieneSegurancaLogic
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@ -238,32 +238,52 @@ public class HigieneSegurancaLogic
|
|
|
|
|
relatorio.save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void reverterPostos( HsRelatorio relatorio, List<HsPostoEstabelecimento> postos )
|
|
|
|
|
private static void reverterPostos( HsRelatorio relatorio, List<HsPostoEstabelecimento> postos ) throws Exception
|
|
|
|
|
{
|
|
|
|
|
HashMap<HsArea,HsRelatorioArea> areasInserted = new HashMap<HsArea, HsRelatorioArea>();
|
|
|
|
|
for( HsPostoEstabelecimento rel : postos )
|
|
|
|
|
{
|
|
|
|
|
HsPosto posto = rel.getToHsPosto();
|
|
|
|
|
HsRelatorioPosto rPosto = new HsRelatorioPosto();
|
|
|
|
|
rPosto.setDescription( posto.getDescription() );
|
|
|
|
|
rPosto.setIsPrincipal( posto.getIsPrincipal() );
|
|
|
|
|
rPosto.setHsPostoId( posto.getId() );
|
|
|
|
|
HsArea area = posto.getToHsArea();
|
|
|
|
|
HsRelatorioArea rArea = areasInserted.get( area );
|
|
|
|
|
if( rArea == null )
|
|
|
|
|
{
|
|
|
|
|
rArea = new HsRelatorioArea();
|
|
|
|
|
rArea.setDescription( area.getDescription() );
|
|
|
|
|
rArea.setOrder( area.getOrder() );
|
|
|
|
|
rArea.setToHsRelatorio( relatorio );
|
|
|
|
|
rArea.setHsAreaId( area.getId() );
|
|
|
|
|
areasInserted.put( area, rArea );
|
|
|
|
|
}
|
|
|
|
|
rPosto.setToHsRelatorioArea( rArea );
|
|
|
|
|
revertMedidasAndRiscos( posto, rPosto );
|
|
|
|
|
HsRelatorioPosto newPosto = createRelatorioPostoFromHsPosto( relatorio, areasInserted.get( area ), posto );
|
|
|
|
|
areasInserted.put( area, newPosto.getToHsRelatorioArea() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static HsRelatorioPosto createRelatorioPostoFromHsPosto( HsRelatorio relatorio, HsRelatorioArea rArea, HsPosto posto ) throws Exception
|
|
|
|
|
{
|
|
|
|
|
HsRelatorioPosto rPosto = new HsRelatorioPosto();
|
|
|
|
|
|
|
|
|
|
HsArea area = posto.getToHsArea();
|
|
|
|
|
if( rArea == null )
|
|
|
|
|
{
|
|
|
|
|
rArea = new HsRelatorioArea();
|
|
|
|
|
updateRelatorioAreaFromHsArea( relatorio, rArea, area );
|
|
|
|
|
}
|
|
|
|
|
updateRelatorioPostoFromHsPosto( rPosto, rArea, posto );
|
|
|
|
|
revertMedidasAndRiscos( posto, rPosto );
|
|
|
|
|
rPosto.save();
|
|
|
|
|
return rPosto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void updateRelatorioAreaFromHsArea( HsRelatorio relatorio, HsRelatorioArea rArea, HsArea area ) throws Exception
|
|
|
|
|
{
|
|
|
|
|
rArea.setDescription( area.getDescription() );
|
|
|
|
|
rArea.setOrder( area.getOrder() );
|
|
|
|
|
rArea.setToHsRelatorio( relatorio );
|
|
|
|
|
rArea.setHsAreaId( area.getId() );
|
|
|
|
|
rArea.save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void updateRelatorioPostoFromHsPosto( HsRelatorioPosto rPosto, HsRelatorioArea rArea, HsPosto posto ) throws Exception
|
|
|
|
|
{
|
|
|
|
|
rPosto.setDescription( posto.getDescription() );
|
|
|
|
|
rPosto.setIsPrincipal( posto.getIsPrincipal() );
|
|
|
|
|
rPosto.setHsPostoId( posto.getId() );
|
|
|
|
|
rPosto.setToHsRelatorioArea( rArea );
|
|
|
|
|
rPosto.save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void addRiscoToRelatorioPosto( HsRisco risco, Integer order, HsRelatorioPosto rPosto )
|
|
|
|
|
{
|
|
|
|
|
HsRelatorioRisco rRelatorioRisco = new HsRelatorioRisco();
|
|
|
|
|
|