提交 d8ac23a1 编写于 作者: hlwwx's avatar hlwwx

'增加了会议模块增加根据会议室id查询,某一时间段(一天)一个会议的使用情况'

上级 ac5e19f7
......@@ -170,6 +170,21 @@ public class MeetingFactory extends AbstractFactory {
cq.select(root.get(Meeting_.id)).where(p);
return em.createQuery(cq).getResultList();
}
public List<String> listWithDateAndRoom(Date start, Date end,String roomId) throws Exception {
EntityManager em = this.entityManagerContainer().get(Meeting.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Meeting> root = cq.from(Meeting.class);
//Predicate p = cb.greaterThanOrEqualTo(root.get(Meeting_.startTime), start);
//p = cb.and(p, cb.lessThanOrEqualTo(root.get(Meeting_.startTime), end));
Predicate p = cb.greaterThanOrEqualTo(root.get(Meeting_.completedTime), start);
p = cb.and(p, cb.lessThanOrEqualTo(root.get(Meeting_.completedTime), end));
p = cb.and(p, cb.equal(root.get(Meeting_.room), roomId));
cq.select(root.get(Meeting_.id)).where(p);
return em.createQuery(cq).getResultList();
}
public List<String> listWithPersonWithDate(String person, Date start, Date end) throws Exception {
EntityManager em = this.entityManagerContainer().get(Meeting.class);
......
package com.x.meeting.assemble.control.jaxrs.meeting;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.tools.SortTools;
import com.x.meeting.assemble.control.Business;
import com.x.meeting.assemble.control.WrapTools;
import com.x.meeting.assemble.control.wrapout.WrapOutMeeting;
import com.x.meeting.core.entity.Meeting;
class ActionListOnDayByRoomID extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, Integer year, Integer month, Integer day,String roomId)
throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date start = calendar.getTime();
/** 一天内 */
calendar.add(Calendar.DAY_OF_MONTH, 1);
calendar.add(Calendar.MILLISECOND, -1);
Date end = calendar.getTime();
List<String> ids = new ArrayList<>();
ids = business.meeting().listWithDateAndRoom(start, end,roomId);
List<Wo> wos = Wo.copier.copy(emc.list(Meeting.class, ids));
WrapTools.decorate(business, wos, effectivePerson);
WrapTools.setAttachment(business, wos);
SortTools.asc(wos, false, "startTime");
result.setData(wos);
return result;
}
}
public static class Wo extends WrapOutMeeting {
private static final long serialVersionUID = 4609263020989488356L;
public static WrapCopier<Meeting, Wo> copier = WrapCopierFactory.wo(Meeting.class, Wo.class, null, Wo.Excludes);
}
}
......@@ -19,6 +19,7 @@ import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
......@@ -427,6 +428,24 @@ public class MeetingAction extends BaseAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示指定会议室id、指定日期的会议.", action = ActionListOnDayByRoomID.class)
@GET
@Path("list/year/{year}/month/{month}/day/{day}/{roomId}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listOnDayByRoomID(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("年份") @PathParam("year") Integer year,@JaxrsParameterDescribe("月份") @PathParam("month") Integer month, @JaxrsParameterDescribe("日") @PathParam("day") Integer day, @JaxrsParameterDescribe("会议室记录ID") @PathParam("roomId") String roomId) {
ActionResult<List<ActionListOnDayByRoomID.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListOnDayByRoomID().execute(effectivePerson, year, month, day,roomId);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示等待我确认的会议.", action = ActionWaitConfirm.class)
@GET
@Path("list/wait/confirm")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册