joniles / mpxj

Primary repository for MPXJ library

Home Page:http://www.mpxj.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getTimephasedWork() reports timephases that do not match the contents of the MS Project mpp.

bmoore27 opened this issue · comments

Im using mpjx 11.5.1 to extract information from an MS Project 2019 mpp file.

In MS Project, I see this for the work hours assigned by month:
image

When I look at the task with mpjx and I print out the getTimephasedWork() for the assigned resource I get the following:

>>(1) 1 Task1 Thu Jun 01 08:00:00 EDT 2023 assigned resource count:1
---TimephasedWork items: 5
Timephase Start: Thu Jun 01 08:00:00 EDT 2023 End: Sat Jul 08 00:00:00 EDT 2023 TotalAmount: 243.99999999999997
Timephase Start: Mon Jul 03 08:00:00 EDT 2023 End: Fri Aug 04 00:00:00 EDT 2023 TotalAmount: 208.25962954489697
Timephase Start: Fri Jul 28 08:00:00 EDT 2023 End: Mon Dec 18 00:00:00 EST 2023 TotalAmount: **932.5714285714304**
Timephase Start: Thu Oct 26 08:00:00 EDT 2023 End: Tue Dec 05 00:00:00 EST 2023 TotalAmount: 262.2857142857132
Timephase Start: Wed Nov 22 08:00:00 EST 2023 End: Tue Jan 09 00:00:00 EST 2024 TotalAmount: 335.14285714285774

getTimephaseIssueExample.zip

I have attached an example of the MPP file that demonstrates the issue. Let me know if I can provide any other information.

Any ideas?

Hi @bmoore27 apologies for the delay, I will look at this as soon as I can, but it may be a little while before I've worked my way through my backlog!

Hello @bmoore27 ! Apologies again for the delay in responding.

What you are seeing is a side effect of the "storage optimised" version of the timephased data which MS Project holds internally. Where you have a range of days with the same amount of work per day, these are just lumped together in one timephased segment, hence in your example the first segment starts on 1st June, and finishes on 8th July. After 8th July I assume the work per day changes for whatever reason.

Anyhow, the onus is on the caller to re-segment the timephased data into time ranges which are appropriate for your use case. I've provided a couple of utility classes to help you do this, and I've just added some sample code here which illustrates how these classes are used. The sample code is actually already set up to accept your example MPP file and segments the timephased data into months. If you run the code with your file you'll get this output:

[Resource Assignment task=Task1 resource=Moore_Beau start=2023-06-01T08:00 finish=2023-12-13T17:00 duration=1982.2596295448982h workContour=CONTOURED]
[LocalDateTimeRange start=2023-06-01T00:00 end=2023-06-30T23:59:59.999]	243.99999999999858h
[LocalDateTimeRange start=2023-07-01T00:00 end=2023-07-31T23:59:59.999]	237.40248668775266h
[LocalDateTimeRange start=2023-08-01T00:00 end=2023-08-31T23:59:59.999]	335.142857142834h
[LocalDateTimeRange start=2023-09-01T00:00 end=2023-09-30T23:59:59.999]	305.99999999997885h
[LocalDateTimeRange start=2023-10-01T00:00 end=2023-10-31T23:59:59.999]	317.50375939847834h
[LocalDateTimeRange start=2023-11-01T00:00 end=2023-11-30T23:59:59.999]	353.6926691729325h
[LocalDateTimeRange start=2023-12-01T00:00 end=2023-12-31T23:59:59.999]	188.51785714285626h

which matches the values you can see in your screenshot. I was using MPXJ 12.0.2 for this, but you should get the same result with the version of MPXJ you are using... however with the big date/time/timestamp refactor which landed with MPXJ 12.0.0 you'll see that I am now using java.time.LocalDateTime and related classes rather than java.util.Date. The utility classes are still present in the version of MPXJ you are using, you'll just need to use java.util.Date to set the start of the timescale.

Hope that helps!