use of com.qcadoo.mes.productionPerShift.report.columns.ReportColumn in project mes by qcadoo.
the class PPSReportXlsService method addSeriesOfProductionLine.
private void addSeriesOfProductionLine(final HSSFSheet sheet, final Entity report, final PPSReportXlsStyleContainer styleContainer, final List<ReportColumn> columns) {
List<Entity> productionPerShifts = ppsReportXlsHelper.getProductionPerShiftForReport(report);
List<Entity> shifts = shiftsService.getShifts();
DateTime dateFrom = new DateTime(report.getDateField(PPSReportFields.DATE_FROM));
Shift shiftFirst = new Shift(shifts.get(0), dateFrom, false);
List<TimeRange> ranges = shiftFirst.findWorkTimeAt(new LocalDate(report.getDateField(PPSReportFields.DATE_FROM)));
if (ranges.isEmpty()) {
return;
}
LocalTime startTime = ranges.get(0).getFrom();
if (productionPerShifts.isEmpty()) {
return;
}
productionPerShifts.sort(new EntityProductionPerShiftsComparator());
String oldProductionLineNumber = "";
String newProductionLineNumber;
int rowNum = 6;
boolean isFirstRow;
boolean greyBg = false;
for (Entity productionPerShift : productionPerShifts) {
Entity order = ppsReportXlsHelper.getOrder(productionPerShift);
Entity changeover = ppsReportXlsHelper.getChangeover(order);
Entity productionLine = ppsReportXlsHelper.getProductionLine(productionPerShift);
newProductionLineNumber = productionLine.getStringField(ProductionLineFields.NUMBER);
isFirstRow = !oldProductionLineNumber.equals(newProductionLineNumber);
if (isFirstRow) {
greyBg = !greyBg;
}
if (changeover != null && isChangeOverOnThisPrint(order, report, startTime)) {
HSSFRow row = sheet.createRow(rowNum++);
int colIndex = 0;
for (ReportColumn column : columns) {
HSSFCell cell = row.createCell(colIndex);
if (isFirstRow) {
cell.setCellValue(column.getFirstRowChangeoverValue(productionPerShift));
} else {
cell.setCellValue(column.getChangeoverValue(productionPerShift));
}
colIndex++;
}
isFirstRow = false;
addSeriesForChangeOver(sheet, report, row, changeover, order, styleContainer, columns);
}
HSSFRow row = sheet.createRow(rowNum++);
int colIndex = 0;
for (ReportColumn column : columns) {
HSSFCell cell = row.createCell(colIndex);
if (isFirstRow) {
Object firstRowValue = column.getFirstRowValue(productionPerShift);
if (firstRowValue instanceof Double) {
cell.setCellValue((Double) firstRowValue);
cell.setCellType(CellType.NUMERIC);
} else {
cell.setCellValue((String) firstRowValue);
}
} else {
Object value = column.getValue(productionPerShift);
if (value instanceof Double) {
cell.setCellValue((Double) value);
cell.setCellType(CellType.NUMERIC);
} else {
cell.setCellValue((String) value);
}
}
if (greyBg) {
if (columns.size() == colIndex - 1) {
column.setGreyDataStyleEnd(cell, styleContainer);
} else {
column.setGreyDataStyle(cell, styleContainer);
}
} else {
if (columns.size() == colIndex - 1) {
column.setWhiteDataStyleEnd(cell, styleContainer);
} else {
column.setWhiteDataStyle(cell, styleContainer);
}
}
colIndex++;
}
addSeriesOfDailyProgress(sheet, report, row, productionPerShift, greyBg, styleContainer, columns);
oldProductionLineNumber = newProductionLineNumber;
}
setColumnWidths(sheet, columns);
}
use of com.qcadoo.mes.productionPerShift.report.columns.ReportColumn in project mes by qcadoo.
the class StandardPPSReportColumnService method getReportColumns.
@Override
public List<ReportColumn> getReportColumns() {
List<ReportColumn> columns = Lists.newLinkedList();
List<String> sortedColumnNames = getSortedColumnIdentifiers();
Map<String, ReportColumn> reportColumns = applicationContext.getBeansOfType(ReportColumn.class);
for (String name : sortedColumnNames) {
ReportColumn column = reportColumns.get(name);
if (column != null) {
columns.add(column);
}
}
return columns;
}
use of com.qcadoo.mes.productionPerShift.report.columns.ReportColumn in project mes by qcadoo.
the class PPSReportXlsService method createHeaderLineForProduction.
private void createHeaderLineForProduction(final HSSFSheet sheet, final Locale locale, final HSSFRow headerMainLine, final HSSFRow headerProduction, final PPSReportXlsStyleContainer styleContainer, final List<ReportColumn> columns) {
CreationHelper helper = sheet.getWorkbook().getCreationHelper();
helper.createDataFormat();
appendHeaderMainLine(sheet, locale, headerMainLine, styleContainer);
int columnNumber = 0;
for (ReportColumn column : columns) {
HSSFCell cell = headerProduction.createCell(columnNumber);
cell.setCellValue(column.getHeader(locale));
column.setHeaderStyle(cell, styleContainer);
columnNumber++;
}
headerProduction.setHeightInPoints(20);
mergeHeaderCells(sheet, columns.size());
}
use of com.qcadoo.mes.productionPerShift.report.columns.ReportColumn in project mes by qcadoo.
the class PPSReportXlsService method setColumnWidths.
private void setColumnWidths(final HSSFSheet sheet, final List<ReportColumn> columns) {
int index = 0;
for (ReportColumn column : columns) {
sheet.setColumnWidth(index, column.getColumnWidth());
index++;
}
for (int columnNumber = columns.size(); columnNumber < columns.size() + 21; columnNumber++) {
sheet.setColumnWidth(columnNumber, 6 * 256);
}
}
use of com.qcadoo.mes.productionPerShift.report.columns.ReportColumn in project mes by qcadoo.
the class PPSReportXlsService method addHeader.
@Override
protected void addHeader(final HSSFSheet sheet, final Locale locale, final Entity report) {
PPSReportXlsStyleContainer styleContainer = new PPSReportXlsStyleContainer(sheet);
createHeaderForAuthor(sheet, locale, styleContainer);
HSSFRow headerMainLine = sheet.createRow(3);
HSSFRow headerProduction = sheet.createRow(4);
List<ReportColumn> columns = ppsReportColumnHelper.getReportColumns();
createHeaderLineForProduction(sheet, locale, headerMainLine, headerProduction, styleContainer, columns);
createHeaderLineForDaysWithShifts(sheet, locale, headerMainLine, headerProduction, report, styleContainer, columns);
}
Aggregations