提交 c70fa2eb 编写于 作者: O o2null

Merge branch 'fix/record' into 'wrdp'

添加回record到work

See merge request o2oa/o2oa!2190
package com.x.general.assemble.control.jaxrs.worktime;
import java.util.Date;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.tools.DateTools;
public class ActionIsHoliday extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String date) throws Exception {
ActionResult<Wo> result = new ActionResult<>();
Date dateObject = DateTools.parse(date);
Wo wo = new Wo();
wo.setValue(!Config.workTime().isWorkDay(dateObject));
result.setData(wo);
return result;
}
public static class Wo extends WrapBoolean {
}
}
......@@ -138,4 +138,22 @@ public class WorkTimeAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "返回指定时间是否是节假日.", action = ActionIsHoliday.class)
@GET
@Path("isholiday/{date}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void isHoliday(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("指定日期") @PathParam("date") String date) {
ActionResult<ActionIsHoliday.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionIsHoliday().execute(effectivePerson, date);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
......@@ -74,6 +74,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
CompletableFuture<Void> creatorPersonFuture = this.creatorPersonFuture(work.getCreatorPerson(), wo);
CompletableFuture<Void> creatorUnitFuture = this.creatorUnitFuture(work.getCreatorUnit(), wo);
CompletableFuture<Void> attachmentFuture = this.attachmentFuture(effectivePerson, work.getJob(), wo);
CompletableFuture<Void> recordFuture = this.recordFuture(effectivePerson, work.getJob(), wo);
workJsonFuture.get(10, TimeUnit.SECONDS);
activityRouteFuture.get(10, TimeUnit.SECONDS);
dataFuture.get(10, TimeUnit.SECONDS);
......@@ -83,6 +84,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
creatorPersonFuture.get(10, TimeUnit.SECONDS);
creatorUnitFuture.get(10, TimeUnit.SECONDS);
attachmentFuture.get(10, TimeUnit.SECONDS);
recordFuture.get(10, TimeUnit.SECONDS);
for (WoTask woTask : wo.getTaskList()) {
wo.getRecordList().add(taskToRecord(woTask));
}
......@@ -95,6 +97,8 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
CompletableFuture<Void> creatorPersonFuture = creatorPersonFuture(workCompleted.getCreatorPerson(), wo);
CompletableFuture<Void> creatorUnitFuture = creatorUnitFuture(workCompleted.getCreatorUnit(), wo);
CompletableFuture<Void> attachmentFuture = attachmentFuture(effectivePerson, workCompleted.getJob(), wo);
CompletableFuture<Void> workCompletedRecordFuture = this.workCompletedRecordFuture(effectivePerson,
workCompleted, wo);
workCompletedJsonFuture.get(10, TimeUnit.SECONDS);
workCompletedDataFuture.get(10, TimeUnit.SECONDS);
readFuture.get(10, TimeUnit.SECONDS);
......@@ -102,6 +106,7 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
creatorPersonFuture.get(10, TimeUnit.SECONDS);
creatorUnitFuture.get(10, TimeUnit.SECONDS);
attachmentFuture.get(10, TimeUnit.SECONDS);
workCompletedRecordFuture.get(10, TimeUnit.SECONDS);
}
if (BooleanUtils.isFalse(checkControlFuture.get(10, TimeUnit.SECONDS))) {
......@@ -146,8 +151,6 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
});
}
private CompletableFuture<Void> taskFuture(EffectivePerson effectivePerson, String job, Wo wo) {
return CompletableFuture.runAsync(() -> {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
......@@ -277,6 +280,35 @@ class V2GetWorkOrWorkCompleted extends BaseAction {
});
}
private CompletableFuture<Void> recordFuture(EffectivePerson effectivePerson, String job, Wo wo) {
return CompletableFuture.runAsync(() -> {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
wo.setRecordList(emc.fetchEqual(Record.class, WoRecord.copier, Record.job_FIELDNAME, job).stream()
.sorted(Comparator.comparing(WoRecord::getOrder)).collect(Collectors.toList()));
} catch (Exception e) {
logger.error(e);
}
});
}
private CompletableFuture<Void> workCompletedRecordFuture(EffectivePerson effectivePerson,
WorkCompleted workCompleted, Wo wo) {
return CompletableFuture.runAsync(() -> {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
if (ListTools.isNotEmpty(workCompleted.getProperties().getRecordList())) {
wo.setRecordList(WoRecord.copier.copy(workCompleted.getProperties().getRecordList()).stream()
.sorted(Comparator.comparing(WoRecord::getOrder)).collect(Collectors.toList()));
} else {
wo.setRecordList(emc
.fetchEqual(Record.class, WoRecord.copier, Record.job_FIELDNAME, workCompleted.getJob())
.stream().sorted(Comparator.comparing(WoRecord::getOrder)).collect(Collectors.toList()));
}
} catch (Exception e) {
logger.error(e);
}
});
}
private CompletableFuture<Void> workCompletedDataFuture(WorkCompleted workCompleted, Wo wo) {
return CompletableFuture.runAsync(() -> {
if (BooleanUtils.isTrue(workCompleted.getMerged())) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册