提交 86fec6a3 编写于 作者: O o2sword

管理员维护接口修改

上级 718c4f65
......@@ -41,18 +41,18 @@ class ActionManageReset extends BaseAction {
if (BooleanUtils.isNotTrue(control.getAllowReadReset())) {
throw new ExceptionAccessDenied(effectivePerson);
}
List<String> identites = business.organization().identity().list(wi.getIdentityList());
if (identites.isEmpty()) {
List<String> identities = business.organization().identity().list(wi.getIdentityList());
if (identities.isEmpty()) {
throw new ExceptionEmptyIdentity();
}
wi.setIdentityList(identites);
wi.setIdentityList(identities);
emc.beginTransaction(Read.class);
if (!StringUtils.isEmpty(wi.getOpinion())) {
read.setOpinion(wi.getOpinion());
}
emc.commit();
}
ThisApplication.context().applications().putQuery(x_processplatform_service_processing.class,
ThisApplication.context().applications().postQuery(x_processplatform_service_processing.class,
Applications.joinQueryUri("read", read.getId(), "reset"), wi, read.getJob());
wo.setId(read.getId());
result.setData(wo);
......
......@@ -540,7 +540,7 @@ public class ReadAction extends StandardJaxrsAction {
@Path("{id}/reset/manage")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void manageRead(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
public void manageResetRead(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("待阅标识") @PathParam("id") String id, JsonElement jsonElement) {
ActionResult<ActionManageReset.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
......@@ -558,7 +558,7 @@ public class ReadAction extends StandardJaxrsAction {
@Path("{id}/reset/manage/mockputtopost")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void manageReadMockPutToPost(@Suspended final AsyncResponse asyncResponse,
public void manageResetReadMockPutToPost(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request, @JaxrsParameterDescribe("待阅标识") @PathParam("id") String id,
JsonElement jsonElement) {
ActionResult<ActionManageReset.Wo> result = new ActionResult<>();
......@@ -851,4 +851,4 @@ public class ReadAction extends StandardJaxrsAction {
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
}
......@@ -408,11 +408,11 @@ public class ReadCompletedAction extends StandardJaxrsAction {
}
@JaxrsMethodDescribe(value = "管理修改意见.", action = ActionManageOpinion.class)
@PUT
@POST
@Path("{id}/opinion/manage")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void manageDelete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
public void manageUpdate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("已阅标识") @PathParam("id") String id, JsonElement jsonElement) {
ActionResult<ActionManageOpinion.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
......@@ -425,25 +425,6 @@ public class ReadCompletedAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "Mock Post To Put.", action = ActionManageOpinion.class)
@POST
@Path("{id}/opinion/manage/mockputtopost")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void manageDeleteMockPutToPost(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request, @JaxrsParameterDescribe("已阅标识") @PathParam("id") String id,
JsonElement jsonElement) {
ActionResult<ActionManageOpinion.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionManageOpinion().execute(effectivePerson, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示当前用户的已阅,分页.", action = ActionListMyPaging.class)
@GET
@Path("list/my/paging/{page}/size/{size}")
......@@ -668,4 +649,4 @@ public class ReadCompletedAction extends StandardJaxrsAction {
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
}
package com.x.processplatform.service.processing.jaxrs.read;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.annotation.CheckRemoveType;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.executor.ProcessPlatformExecutorFactory;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.core.entity.content.*;
import com.x.processplatform.service.processing.Business;
import com.x.processplatform.service.processing.MessageFactory;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
class ActionReset extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionReset.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String id, JsonElement jsonElement) throws Exception {
logger.debug(effectivePerson.getDistinguishedName());
ActionResult<Wo> result = new ActionResult<>();
Wo wo = new Wo();
final Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
String executorSeed;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Read read = emc.fetch(id, Read.class, ListTools.toList(Read.job_FIELDNAME));
if (null == read) {
throw new ExceptionEntityNotExist(id, Read.class);
}
executorSeed = read.getJob();
}
Callable<String> callable = () -> {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Read read = emc.find(id, Read.class);
if (null == read) {
throw new ExceptionEntityNotExist(id, Read.class);
}
List<String> identities = ListTools.trim(business.organization().identity().list(wi.getIdentityList()), true, true);
boolean flag = false;
if(identities.contains(read.getIdentity())){
flag = true;
identities.remove(read.getIdentity());
}
if (identities.isEmpty()) {
throw new ExceptionResetEmpty();
}
Date now = new Date();
List<Read> readList = new ArrayList<>();
assembleRead(identities, readList, read, business, now);
emc.beginTransaction(Read.class);
emc.beginTransaction(ReadCompleted.class);
for(Read resetRead : readList){
emc.persist(resetRead, CheckPersistType.all);
}
if(flag) {
if (StringUtils.isNotEmpty(wi.getOpinion())) {
read.setOpinion(wi.getOpinion());
}
emc.commit();
}else {
Long duration = Config.workTime().betweenMinutes(read.getStartTime(), now);
ReadCompleted readCompleted = new ReadCompleted(read, now, duration);
if (StringUtils.isNotEmpty(wi.getOpinion())) {
readCompleted.setOpinion(wi.getOpinion());
}
emc.persist(readCompleted, CheckPersistType.all);
emc.remove(read, CheckRemoveType.all);
emc.commit();
MessageFactory.readCompleted_create(readCompleted);
MessageFactory.read_to_readCompleted(readCompleted);
}
for(Read resetRead : readList){
MessageFactory.read_create(resetRead);
}
wo.setId(read.getId());
result.setData(wo);
}
return "";
};
ProcessPlatformExecutorFactory.get(executorSeed).submit(callable).get(300, TimeUnit.SECONDS);
return result;
}
private void assembleRead(List<String> identities, List<Read> readList, Read read, Business business, Date date) throws Exception{
for(String identity : identities){
String person = business.organization().person().getWithIdentity(identity);
String unit = business.organization().unit().getWithIdentity(identity);
if(StringUtils.isNotBlank(person)) {
Read resetRead = new Read();
read.copyTo(resetRead, Read.FieldsUnmodify);
resetRead.setIdentity(identity);
resetRead.setPerson(person);
resetRead.setUnit(unit);
resetRead.setCreatorPerson(read.getPerson());
resetRead.setCreatorIdentity(read.getIdentity());
resetRead.setCreatorUnit(read.getUnit());
resetRead.setStartTime(date);
resetRead.setViewed(false);
readList.add(resetRead);
}
}
}
private List<ReadCompleted> listExist(Business business, Read read) throws Exception {
return business.entityManagerContainer().listEqualAndEqual(ReadCompleted.class, ReadCompleted.job_FIELDNAME,
read.getJob(), ReadCompleted.person_FIELDNAME, read.getPerson());
}
public static class CallWrap {
String job;
}
public static class Wi extends GsonPropertyObject {
@FieldDescribe("身份")
private List<String> identityList;
@FieldDescribe("待阅意见")
private String opinion;
public List<String> getIdentityList() {
return identityList;
}
public void setIdentityList(List<String> identityList) {
this.identityList = identityList;
}
public String getOpinion() {
return opinion;
}
public void setOpinion(String opinion) {
this.opinion = opinion;
}
}
public static class Wo extends WoId {
}
}
package com.x.processplatform.service.processing.jaxrs.read;
import com.x.base.core.project.exception.PromptException;
class ExceptionResetEmpty extends PromptException {
private static final long serialVersionUID = -3439770681867963457L;
ExceptionResetEmpty() {
super("重置处理人为空.");
}
}
......@@ -106,4 +106,22 @@ public class ReadAction extends StandardJaxrsAction {
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
\ No newline at end of file
@JaxrsMethodDescribe(value = "重置处理人.", action = ActionReset.class)
@POST
@Path("{id}/reset")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void reset(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id, JsonElement jsonElement) {
ActionResult<ActionReset.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionReset().execute(effectivePerson, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册