import net.sf.mpxj.*;
import net.sf.mpxj.mspdi.MSPDIWriter;
import java.io.IOException;
import java.time.LocalDateTime;
public class Main {
public static void main(String[] args) {
final ProjectFile file = new ProjectFile();
final CostRateTable table = new CostRateTable();
table.add(new CostRateTableEntry(
LocalDateTime.now(),
LocalDateTime.now().plusYears(1),
0,
// StandardRate = 100, StandardRateFormat-Material = 8
new Rate(100.00, TimeUnit.ELAPSED_MINUTES)));
final Resource resource = file.addResource();
resource.setName("material");
resource.setType(ResourceType.MATERIAL);
resource.setCostRateTable(0, table);
final Task task = file.addTask();
task.setDuration(Duration.getInstance(5, TimeUnit.DAYS));
task.setName("task");
final ResourceAssignment assignment = task.addResourceAssignment(resource);
// Units = 1.5
assignment.setRemainingWork(Duration.getInstance(1.5, TimeUnit.HOURS));
// assignment.setFinish(task.getFinish()); start = null
try {
final MSPDIWriter writer = new MSPDIWriter();
writer.setMicrosoftProjectCompatibleOutput(true);
writer.write(file, "project.xml");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Пример работает правильно, только если я добавляю к заданию дату окончания задачи. Однако фактические данные рассчитываются только при их импорте в MS Project. Есть ли другое решение?
С уважением
Мартин
public class Main { public static void main(String[] args) {
final ProjectFile file = new ProjectFile();
final CostRateTable table = new CostRateTable(); table.add(new CostRateTableEntry( LocalDateTime.now(), LocalDateTime.now().plusYears(1), 0, // StandardRate = 100, StandardRateFormat-Material = 8 new Rate(100.00, TimeUnit.ELAPSED_MINUTES)));
final Resource resource = file.addResource(); resource.setName("material"); resource.setType(ResourceType.MATERIAL); resource.setCostRateTable(0, table);
final Task task = file.addTask(); task.setDuration(Duration.getInstance(5, TimeUnit.DAYS)); task.setName("task");
final ResourceAssignment assignment = task.addResourceAssignment(resource); // Units = 1.5 assignment.setRemainingWork(Duration.getInstance(1.5, TimeUnit.HOURS)); // assignment.setFinish(task.getFinish()); start = null
try { final MSPDIWriter writer = new MSPDIWriter(); writer.setMicrosoftProjectCompatibleOutput(true); writer.write(file, "project.xml"); } catch (IOException e) { throw new RuntimeException(e); } } } [/code] Пример работает правильно, только если я добавляю к заданию дату окончания задачи. Однако фактические данные рассчитываются только при их импорте в MS Project. Есть ли другое решение? С уважением Мартин