Мне нужно проанализировать результат PlanningEntity, чтобы рассчитать время между двумя распределениями производственных заказов - PullRequest
0 голосов
/ 24 апреля 2019

Я разрабатываю систему для упорядочения производственных заказов для пищевой промышленности.

Мне нужно проанализировать время наладки оборудования между двумя производственными заказами при изменении продукта, производимого на оборудовании.

Я пытаюсь использовать теневую переменную, но мне нужно проанализировать результат решателя оптапланера.Для этого я использую список распределений (PlanningEntity), который я получаю из ScoreDirector метода afterEntityAdded.

Является ли эта процедура правильной?

'Shadow Variable Code

private static final Logger logger = LoggerFactory.getLogger(SetupVariableListener.class);

@Override
public void beforeEntityAdded(ScoreDirector scoreDirector, Alocacao entity) {
    // Do nothing
}

@Override
public void afterEntityAdded(ScoreDirector scoreDirector, Alocacao entity) {
    updateAllocation(scoreDirector, entity);
}

@Override
public void beforeVariableChanged(ScoreDirector scoreDirector, Alocacao entity) {
    // Do nothing
}

@Override
public void afterVariableChanged(ScoreDirector scoreDirector, Alocacao entity) {
    updateAllocation(scoreDirector, entity);
}

@Override
public void beforeEntityRemoved(ScoreDirector scoreDirector, Alocacao entity) {
    // Do nothing
}

@Override
public void afterEntityRemoved(ScoreDirector scoreDirector, Alocacao entity) {
    // Do nothing
}

protected void updateAllocation(ScoreDirector scoreDirector, Alocacao originalAllocation) {
    boolean updated = false;
    int tempo = 0;
    int tempoPausa = 0;
    Hashtable<Setup, Integer> st = new Hashtable<>();
    Agenda agenda = (Agenda) scoreDirector.getWorkingSolution();
    if (originalAllocation.getProcessoProducao().getSequenciaProducao() == 1) {
        List<Alocacao> alocacoes = agenda.getAlocacoesOrdens().stream().filter(g -> g.getProcessoProducao().getSequenciaProducao() == 1 && g.getEquipamento().equals(originalAllocation.getEquipamento())).sorted((a1, b1) -> {
            return new CompareToBuilder()
                    .append(a1.getProcessoProducao().getOrdemProducao().getNrOrdemProducao(), b1.getProcessoProducao().getOrdemProducao().getNrOrdemProducao())
                    .append(a1.getProcessoProducao().getOrdemProducao().getSequenciaDivisao(), b1.getProcessoProducao().getOrdemProducao().getSequenciaDivisao())
                    .append(a1.getProcessoProducao().getSequenciaProducao(), b1.getProcessoProducao().getSequenciaProducao())
                    .toComparison();
        }).collect(Collectors.toList());
        int posicaoOrigem = alocacoes.indexOf(originalAllocation);
        if ((posicaoOrigem + 1) < alocacoes.size()) {
            SeqItem itemOrigem = originalAllocation.getProcessoProducao().getOrdemProducao().getItem();
            SeqItem itemDestino = alocacoes.get(posicaoOrigem + 1).getProcessoProducao().getOrdemProducao().getItem();
            Setup s = new Setup(itemOrigem, itemDestino, 0);
            tempo = agenda.getListaSetup().get(s);
            st.put(s, tempo);

            SeqPeriodo seqOrigem = originalAllocation.getPeriodoInicial();
            SeqPeriodo seqDestino = alocacoes.get(posicaoOrigem + 1).getPeriodoInicial();
            if (seqOrigem != null && seqDestino != null) {
                tempoPausa = seqDestino.getPeriodoIndex() - seqOrigem.getPeriodoIndex();
            }

            //tempo = agenda.getListaSetup().stream().filter(g -> g.getItemOrigem().equals(s.getItemOrigem())).filter(g -> g.getItemDestino().equals(s.getItemDestino())).collect(Collectors.toList()).get(0).getTempo();
        }
    }
    originalAllocation.setTempoSetup(tempo);
    originalAllocation.setDiferencaProximaProducao(tempoPausa);
    originalAllocation.setSetupSelecionado(st);

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...