提交 9cce7285 编写于 作者: O o2null

Merge branch 'feature/personManageUnit' into 'develop'

增加查找人员在管理列表中的组织.

See merge request o2oa/o2oa!1372
......@@ -183,7 +183,7 @@ public class General extends ConfigObject {
private List<String> fileTypeIncludes = new ArrayList<>();
@FieldDescribe("不允许上传的文件后缀")
private List<String> fileTypeExcludes = Arrays.asList("jsp", "exe", "sh", "tmp");
private List<String> fileTypeExcludes = Arrays.asList("jsp", "exe", "sh", "tmp", "html", "htm", "xhtml");
public Integer getFileSize() {
return fileSize;
......
......@@ -132,9 +132,6 @@ public class Main {
nodeAgent.start();
}
// SchedulerBuilder schedulerBuilder = new SchedulerBuilder();
// Scheduler scheduler = schedulerBuilder.start();
if (BooleanUtils.isTrue(Config.currentNode().autoStart())) {
startAll();
}
......
......@@ -34,43 +34,44 @@ import com.x.file.core.entity.personal.Share;
/**
* 定时清理回收站数据
*
* @author sword
*/
public class RecycleClean extends AbstractJob {
private static Logger logger = LoggerFactory.getLogger(RecycleClean.class);
private static final Logger LOGGER = LoggerFactory.getLogger(RecycleClean.class);
@Override
public void schedule(JobExecutionContext jobExecutionContext) throws Exception {
try {
logger.info("开始定时清理网盘回收站数据==========");
Date start = new Date();
this.cleanRecycle();
logger.info("结束定时清理网盘回收站数据==========");
LOGGER.info("结束定时清理网盘回收站数据,耗时:{}ms.", (new Date()).getTime() - start.getTime());
} catch (Exception e) {
throw new JobExecutionException(e);
}
}
private void cleanRecycle() throws Exception{
private void cleanRecycle() throws Exception {
List<String> list = this.listRecycle();
if(ListTools.isEmpty(list)){
if (ListTools.isEmpty(list)) {
return;
}
for (String id : list){
for (String id : list) {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Recycle recycle = emc.find(id, Recycle.class);
if(Share.FILE_TYPE_ATTACHMENT.equals(recycle.getFileType())){
if (Share.FILE_TYPE_ATTACHMENT.equals(recycle.getFileType())) {
Attachment2 att = emc.find(recycle.getFileId(), Attachment2.class);
this.deleteFile(business, att);
}else{
} else {
Folder2 folder = emc.find(recycle.getFileId(), Folder2.class);
if(folder!=null) {
if (folder != null) {
List<String> ids = new ArrayList<>();
ids.add(folder.getId());
ids.addAll(business.folder2().listSubNested(folder.getId(), null));
for (int i = ids.size() - 1; i >= 0; i--) {
List<Attachment2> attachments = business.attachment2().listWithFolder2(ids.get(i),null);
List<Attachment2> attachments = business.attachment2().listWithFolder2(ids.get(i), null);
for (Attachment2 att : attachments) {
this.deleteFile(business, att);
}
......@@ -83,24 +84,24 @@ public class RecycleClean extends AbstractJob {
emc.beginTransaction(Recycle.class);
emc.delete(Recycle.class, recycle.getId());
emc.commit();
} catch (Exception e){
logger.warn("清理网盘回收站文件{}异常:{}",id,e.getMessage());
} catch (Exception e) {
LOGGER.warn("清理网盘回收站文件{}异常:{}.", id, e.getMessage());
}
}
}
private void deleteFile(Business business, Attachment2 att) throws Exception{
if(att==null){
private void deleteFile(Business business, Attachment2 att) throws Exception {
if (att == null) {
return;
}
EntityManagerContainer emc = business.entityManagerContainer();
Long count = emc.countEqual(Attachment2.class, Attachment2.originFile_FIELDNAME, att.getOriginFile());
if(count.equals(1L)){
if (count.equals(1L)) {
OriginFile originFile = emc.find(att.getOriginFile(), OriginFile.class);
if(originFile!=null){
if (originFile != null) {
StorageMapping mapping = ThisApplication.context().storageMappings().get(OriginFile.class,
originFile.getStorage());
if(mapping!=null){
if (mapping != null) {
originFile.deleteContent(mapping);
}
emc.beginTransaction(Attachment2.class);
......@@ -109,18 +110,18 @@ public class RecycleClean extends AbstractJob {
emc.remove(originFile);
emc.commit();
}
}else{
} else {
emc.beginTransaction(Attachment2.class);
emc.remove(att);
emc.commit();
}
}
private List<String> listRecycle() throws Exception{
private List<String> listRecycle() throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Integer days = FileConfig.DEFAULT_RECYCLE_DAYS;
FileConfig config = emc.firstEqual(FileConfig.class, FileConfig.person_FIELDNAME, Business.SYSTEM_CONFIG);
if(config != null && config.getRecycleDays()!=null){
if (config != null && config.getRecycleDays() != null) {
days = config.getRecycleDays();
}
EntityManager em = emc.get(Recycle.class);
......
package com.x.organization.assemble.control.jaxrs.unit;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils;
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.JpaObject;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
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.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.organization.assemble.control.Business;
import com.x.organization.core.entity.Person;
import com.x.organization.core.entity.Unit;
import com.x.organization.core.entity.Unit_;
import io.swagger.v3.oas.annotations.media.Schema;
class ActionListWithController extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionListWithController.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
CacheKey cacheKey = new CacheKey(this.getClass(), StringUtils.join(wi.getPersonList(), ","));
Optional<?> optional = CacheManager.get(business.cache(), cacheKey);
if (optional.isPresent()) {
result.setData((List<Wo>) optional.get());
} else {
List<Wo> wos = this.list(business, wi.getPersonList());
CacheManager.put(business.cache(), cacheKey, wos);
result.setData(wos);
}
return result;
}
}
public static class Wi extends GsonPropertyObject {
@Schema(description = "指定人员.")
@FieldDescribe("指定人员.")
private List<String> personList = new ArrayList<>();
public List<String> getPersonList() {
return personList;
}
public void setPersonList(List<String> personList) {
this.personList = personList;
}
}
public static class Wo extends WoAbstractUnit {
static WrapCopier<Unit, Wo> copier = WrapCopierFactory.wo(Unit.class, Wo.class, null,
JpaObject.FieldsInvisible);
}
private List<Wo> list(Business business, List<String> people) throws Exception {
List<Person> list = business.person().pick(people);
EntityManager em = business.entityManagerContainer().get(Unit.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Unit> cq = cb.createQuery(Unit.class);
Root<Unit> root = cq.from(Unit.class);
List<String> ids = ListTools.extractField(list, JpaObject.id_FIELDNAME, String.class, true, true);
if (ids.isEmpty()) {
return new ArrayList<>();
}
Predicate p = root.get(Unit_.controllerList)
.in(ids);
List<Unit> os = em.createQuery(cq.select(root).where(p)).getResultList();
List<Wo> wos = Wo.copier.copy(os);
wos = business.unit().sort(wos);
return wos;
}
}
\ No newline at end of file
......@@ -216,7 +216,8 @@ public class UnitAction extends StandardJaxrsAction {
@Path("list/unit/type/mockputtopost")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithUnitWithTypeMockPutToPost(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
public void listWithUnitWithTypeMockPutToPost(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<List<ActionListWithUnitWithType.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
......@@ -393,7 +394,8 @@ public class UnitAction extends StandardJaxrsAction {
@Path("list/pinyininitial/mockputtopost")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPinyinInitialMockPutToPost(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
public void listPinyinInitialMockPutToPost(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<List<ActionListPinyinInitial.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
......@@ -465,7 +467,8 @@ public class UnitAction extends StandardJaxrsAction {
@Path("list/like/pinyin/mockputtopost")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listLikePinyinMockPutToPost(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
public void listLikePinyinMockPutToPost(@Suspended final AsyncResponse asyncResponse,
@Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<List<ActionListLikePinyin.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
......@@ -532,4 +535,22 @@ public class UnitAction extends StandardJaxrsAction {
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "列示指定人员在组织管理者中的组织.", action = ActionListWithController.class)
@POST
@Path("list/controller")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listWithController(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<List<ActionListWithController.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListWithController().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result, jsonElement));
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册