package cn.updev.EventWeight.Rate;

import cn.updev.Events.Event.EventDAO;
import cn.updev.Events.Group.EventGroupDAO;
import cn.updev.Events.Group.EventGroupInfo;
import cn.updev.Events.Static.EventWeight;
import cn.updev.Events.Static.IEvent;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by hypo on 15-11-24.
 */
public class EventGroupRate {

    private Integer eventGroupId;
    private String eventGroupTitle;
    private Integer evnetNum;
    private Integer finishEventNum;
    private Integer groupRate;
    private EventWeight weight;
    private String createTime;
    private String groupExpect;

    public EventGroupRate(Integer eventGroupId) {
        this.eventGroupId = eventGroupId;
        EventGroupDAO groupDAO = new EventGroupDAO();
        EventDAO eventDAO = new EventDAO();
        EventGroupInfo groupInfo = groupDAO.getEventGroupInfo(eventGroupId);
        this.eventGroupTitle = groupInfo.getGroupTitle();
        this.weight = groupInfo.getWeight();

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        this.createTime = dateFormat.format(groupInfo.getCreateTime());
        this.groupExpect = dateFormat.format(groupInfo.getGroupExpect());

        List<IEvent> events = eventDAO.getEventByEventGroupId(eventGroupId);
        this.evnetNum = events.size();
        this.finishEventNum = 0;

        for(IEvent event : events){
            if(event.isFinish()){
                this.finishEventNum++;
            }
        }
        this.groupRate = 100 * this.finishEventNum / this.evnetNum;
    }

    public Integer getEventGroupId() {
        return eventGroupId;
    }

    public String getEventGroupTitle() {
        return eventGroupTitle;
    }

    public Integer getEvnetNum() {
        return evnetNum;
    }

    public Integer getFinishEventNum() {
        return finishEventNum;
    }

    public Integer getGroupRate() {
        return groupRate;
    }

    public String getCreateTime() {
        return createTime;
    }

    public String getGroupExpect() {
        return groupExpect;
    }

    public EventWeight getWeight() {
        return weight;
    }
}

@@ -29,16 +29,70 @@
 .Rate;%0A%0A
+import cn.updev.EventWeight.Weight.EventWeightManage;%0A
 import c
@@ -118,24 +118,24 @@
 t.EventDAO;%0A
-
 import cn.up
@@ -328,16 +328,39 @@
 Format;%0A
+import java.util.Date;%0A
 import j
@@ -707,16 +707,45 @@
 pExpect;
+%0A    private Date finishTime;
 %0A%0A    pu
@@ -1480,16 +1480,48 @@
 m = 0;%0A%0A
+        this.finishTime = null;%0A
         
@@ -1627,32 +1627,558 @@
 ;%0A            %7D%0A
+            EventWeightManage eventWeight = new EventWeightManage();%0A            cn.updev.EventWeight.Weight.EventWeight weight = eventWeight.getEventWeight(event.getEventId());%0A%0A            if(finishTime == null)%7B%0A                finishTime = weight.getEventReckon();%0A            %7Delse %7B%0A                Long temp = finishTime.getTime();%0A                Long next = weight.getEventReckon().getTime();%0A%0A                if(next %3E temp)%7B%0A                    finishTime = weight.getEventReckon();%0A                %7D%0A            %7D%0A
         %7D%0A      
@@ -2791,24 +2791,24 @@
 tWeight() %7B%0A
-
         retu
@@ -2823,11 +2823,174 @@
 t;%0A    %7D
+%0A%0A    public String getFinishTime() %7B%0A        SimpleDateFormat dateFormat = new SimpleDateFormat(%22yyyy-MM-dd%22);%0A        return dateFormat.format(finishTime);%0A    %7D
 %0A%7D%0A

update web page