use of com.qcadoo.model.api.NumberService in project mes by qcadoo.
the class OperationWorkTimeServiceTest method init.
@Before
public void init() {
operationWorkTimeService = new OperationWorkTimeServiceImpl();
MockitoAnnotations.initMocks(this);
ReflectionTestUtils.setField(operationWorkTimeService, "numberService", numberService);
when(numberService.getMathContext()).thenReturn(mc);
given(numberService.setScaleWithDefaultMathContext(Mockito.any(BigDecimal.class))).willAnswer((Answer<BigDecimal>) invocation -> {
Object[] args = invocation.getArguments();
BigDecimal number = (BigDecimal) args[0];
return number.setScale(5, RoundingMode.HALF_EVEN);
});
when(operComp1.getDataDefinition()).thenReturn(dataDefinition);
when(operComp2.getDataDefinition()).thenReturn(dataDefinition);
when(operComp3.getDataDefinition()).thenReturn(dataDefinition);
Long id1 = 1L;
Long id2 = 2L;
Long id3 = 3L;
when(operComp1.getId()).thenReturn(id1);
when(operComp2.getId()).thenReturn(id2);
when(operComp3.getId()).thenReturn(id3);
when(dataDefinition.get(id1)).thenReturn(operComp1);
when(dataDefinition.get(id2)).thenReturn(operComp2);
when(dataDefinition.get(id3)).thenReturn(operComp3);
when(dataDefinition.getName()).thenReturn("technologyOperationComponent");
neededNumberOfCycles1 = BigDecimal.ONE;
neededNumberOfCycles2 = new BigDecimal(2);
neededNumberOfCycles3 = new BigDecimal("2.3");
when(operComp1.getIntegerField("tj")).thenReturn(600);
when(operComp2.getIntegerField("tj")).thenReturn(300);
when(operComp3.getIntegerField("tj")).thenReturn(150);
when(operComp1.getIntegerField("tpz")).thenReturn(600);
when(operComp2.getIntegerField("tpz")).thenReturn(900);
when(operComp3.getIntegerField("tpz")).thenReturn(1200);
when(operComp1.getIntegerField("timeNextOperation")).thenReturn(600);
when(operComp2.getIntegerField("timeNextOperation")).thenReturn(300);
when(operComp3.getIntegerField("timeNextOperation")).thenReturn(450);
lu1 = new BigDecimal("2.2");
lu2 = new BigDecimal("0.6");
lu3 = new BigDecimal("0.8");
when(operComp1.getDecimalField("laborUtilization")).thenReturn(lu1);
when(operComp2.getDecimalField("laborUtilization")).thenReturn(lu2);
when(operComp3.getDecimalField("laborUtilization")).thenReturn(lu3);
mu1 = new BigDecimal("0.2");
mu2 = new BigDecimal("1.6");
mu3 = new BigDecimal("0.7");
when(operComp1.getDecimalField("machineUtilization")).thenReturn(mu1);
when(operComp2.getDecimalField("machineUtilization")).thenReturn(mu2);
when(operComp3.getDecimalField("machineUtilization")).thenReturn(mu3);
workstations1 = 1;
workstations2 = 2;
workstations3 = 1;
workstations.put(operComp1, workstations1);
workstations.put(operComp2, workstations2);
workstations.put(operComp3, workstations3);
workstationsMap.put(operComp1.getId(), workstations1);
workstationsMap.put(operComp2.getId(), workstations2);
workstationsMap.put(operComp3.getId(), workstations3);
operationsRuns.put(operComp1, new BigDecimal(3));
operationsRuns.put(operComp2, new BigDecimal("1.5"));
operationsRuns.put(operComp3, new BigDecimal(7));
operationRuns.put(operComp1.getId(), new BigDecimal(3));
operationRuns.put(operComp2.getId(), new BigDecimal("1.5"));
operationRuns.put(operComp3.getId(), new BigDecimal(7));
}
use of com.qcadoo.model.api.NumberService in project mes by qcadoo.
the class DispositionOrderPdfService method addPositionsTable.
private void addPositionsTable(Document document, Entity documentEntity, Locale locale) throws DocumentException {
List<Integer> headerWidthsList = new ArrayList<>(Arrays.asList(25, 50, 50, 50, 65, 90, 40, 35));
int numOfColumns = 8;
if (acceptanceOfDocumentBeforePrinting) {
headerWidthsList.add(45);
numOfColumns++;
}
int[] headerWidths = headerWidthsList.stream().mapToInt(i -> i).toArray();
Map<String, HeaderAlignment> headerValues = getPositionsTableHeaderLabels(locale);
PdfPTable positionsTable = pdfHelper.createTableWithHeader(numOfColumns, Lists.newArrayList(headerValues.keySet()), false, headerWidths, headerValues);
positionsTable.getDefaultCell().disableBorderSide(PdfPCell.RIGHT);
positionsTable.getDefaultCell().disableBorderSide(PdfPCell.LEFT);
positionsTable.setHeaderRows(1);
List<Entity> positions = PositionDataProvider.getPositions(documentEntity);
PositionsHolder positionsHolder = new PositionsHolder(numberService);
fillPositions(positionsHolder, positions);
List<Position> _positions = positionsHolder.getPositions();
if (acceptanceOfDocumentBeforePrinting) {
Collections.sort(_positions, new Comparator<Position>() {
@Override
public int compare(Position p1, Position p2) {
return ComparisonChain.start().compare(p1.getTargetPallet(), p2.getTargetPallet()).compare(p1.getStorageLocation(), p2.getStorageLocation()).result();
}
});
} else {
Collections.sort(_positions, new Comparator<Position>() {
@Override
public int compare(Position p1, Position p2) {
return ComparisonChain.start().compare(p1.getStorageLocation(), p2.getStorageLocation()).result();
}
});
}
Integer index = 1;
for (Position position : _positions) {
positionsTable.addCell(createCell(index.toString(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getStorageLocation(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getPalletNumber(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getTypeOfPallet(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getAdditionalCodeAndBatch(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getProductName(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(PositionDataProvider.quantity(position.getQuantity()), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getUnit(), Element.ALIGN_LEFT));
if (acceptanceOfDocumentBeforePrinting) {
positionsTable.addCell(createCell(position.getTargetPallet(), Element.ALIGN_LEFT));
}
index++;
}
positionsTable.setSpacingAfter(20);
document.add(positionsTable);
}
use of com.qcadoo.model.api.NumberService in project qcadoo by qcadoo.
the class UnitConversionServiceImplTest method init.
@Before
public final void init() {
MockitoAnnotations.initMocks(this);
unitConversionService = new UnitConversionServiceImpl();
final NumberService numberService = mock(NumberService.class);
given(numberService.getMathContext()).willReturn(MATH_CONTEXT);
given(unitConversionModelService.getDataDefinition()).willReturn(unitConversionItemDD);
ReflectionTestUtils.setField(unitConversionService, "numberService", numberService);
ReflectionTestUtils.setField(unitConversionService, "unitConversionModelService", unitConversionModelService);
ReflectionTestUtils.setField(unitConversionService, "dictionaryService", dictionaryService);
}
Aggregations