From af3d66f7a30ec5424bd895f7fc29bd94949999a4 Mon Sep 17 00:00:00 2001 From: o2sword <171715986@qq.com> Date: Fri, 3 Dec 2021 11:25:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E7=BB=84=E7=BB=87=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=BC=93=E5=AD=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assemble/control/factory/GroupFactory.java | 10 ++++++---- .../assemble/control/factory/IdentityFactory.java | 10 ++++++---- .../assemble/control/factory/PersonFactory.java | 10 ++++++---- .../assemble/control/factory/UnitDutyFactory.java | 12 +++++++----- .../assemble/control/factory/UnitFactory.java | 12 +++++++----- .../assemble/express/factory/IdentityFactory.java | 4 ++-- .../assemble/express/factory/PersonFactory.java | 6 +++--- .../assemble/express/factory/UnitDutyFactory.java | 9 ++++++--- .../assemble/express/factory/UnitFactory.java | 6 +++--- .../person/ActionListWithUnitSubDirectObject.java | 8 +------- 10 files changed, 47 insertions(+), 40 deletions(-) diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/GroupFactory.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/GroupFactory.java index 9a5e353c72..54825da509 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/GroupFactory.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/GroupFactory.java @@ -41,13 +41,15 @@ public class GroupFactory extends AbstractFactory { } Group o = null; - CacheKey cacheKey = new CacheKey(flag); + CacheKey cacheKey = new CacheKey(Group.class.getName(), flag); Optional optional = CacheManager.get(cache, cacheKey); if (optional.isPresent()) { o = (Group) optional.get(); } else { o = this.pickObject(flag); - CacheManager.put(cache, cacheKey, o); + if (null != o) { + CacheManager.put(cache, cacheKey, o); + } } return o; } @@ -55,7 +57,7 @@ public class GroupFactory extends AbstractFactory { public List pick(List flags) throws Exception { List list = new ArrayList<>(); for (String str : flags) { - CacheKey cacheKey = new CacheKey(str); + CacheKey cacheKey = new CacheKey(Group.class.getName(), str); Optional optional = CacheManager.get(cache, cacheKey); if (optional.isPresent()) { list.add((Group) optional.get()); @@ -258,4 +260,4 @@ public class GroupFactory extends AbstractFactory { return this.entityManagerContainer().list(Group.class, ids); } -} \ No newline at end of file +} diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/IdentityFactory.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/IdentityFactory.java index c3e28f7b68..cb53f975e1 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/IdentityFactory.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/IdentityFactory.java @@ -37,13 +37,15 @@ public class IdentityFactory extends AbstractFactory { return null; } Identity o = null; - CacheKey cacheKey = new CacheKey(flag); + CacheKey cacheKey = new CacheKey(Identity.class.getName(), flag); Optional optional = CacheManager.get(cache, cacheKey); if (optional.isPresent()) { o = (Identity) optional.get(); } else { o = this.pickObject(flag); - CacheManager.put(cache, cacheKey, o); + if (null != o) { + CacheManager.put(cache, cacheKey, o); + } } return o; } @@ -82,14 +84,14 @@ public class IdentityFactory extends AbstractFactory { public List pick(List flags) throws Exception { List list = new ArrayList<>(); for (String str : flags) { - CacheKey cacheKey = new CacheKey(str); + CacheKey cacheKey = new CacheKey(Identity.class.getName(), str); Optional optional = CacheManager.get(cache, cacheKey); if (optional.isPresent()) { list.add((Identity) optional.get()); } else { Identity o = this.pickObject(str); - CacheManager.put(cache, cacheKey, o); if (null != o) { + CacheManager.put(cache, cacheKey, o); list.add(o); } } diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/PersonFactory.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/PersonFactory.java index a49bcb9fee..6d20025362 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/PersonFactory.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/PersonFactory.java @@ -36,13 +36,15 @@ public class PersonFactory extends AbstractFactory { return null; } Person o = null; - CacheKey cacheKey = new CacheKey(flag); + CacheKey cacheKey = new CacheKey(Person.class.getName(), flag); Optional optional = CacheManager.get(cache, cacheKey); if (optional.isPresent()) { o = (Person) optional.get(); } else { o = this.pickObject(flag); - CacheManager.put(cache, cacheKey, o); + if (null != o) { + CacheManager.put(cache, cacheKey, o); + } } return o; } @@ -81,14 +83,14 @@ public class PersonFactory extends AbstractFactory { public List pick(List flags) throws Exception { List list = new ArrayList<>(); for (String str : flags) { - CacheKey cacheKey = new CacheKey(str); + CacheKey cacheKey = new CacheKey(Person.class.getName(), str); Optional optional = CacheManager.get(cache, cacheKey); if (optional.isPresent()) { list.add((Person) optional.get()); } else { Person o = this.pickObject(str); - CacheManager.put(cache, cacheKey, o); if (null != o) { + CacheManager.put(cache, cacheKey, o); list.add(o); } } diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/UnitDutyFactory.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/UnitDutyFactory.java index 28f01b9a55..35654822df 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/UnitDutyFactory.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/UnitDutyFactory.java @@ -36,13 +36,15 @@ public class UnitDutyFactory extends AbstractFactory { return null; } UnitDuty o = null; - CacheKey cacheKey = new CacheKey(flag); + CacheKey cacheKey = new CacheKey(UnitDuty.class.getName(), flag); Optional optional = CacheManager.get(cache, cacheKey); if (optional.isPresent()) { o = (UnitDuty) optional.get(); } else { o = this.pickObject(flag); - CacheManager.put(cache, cacheKey, o); + if (null != o) { + CacheManager.put(cache, cacheKey, o); + } } return o; } @@ -81,14 +83,14 @@ public class UnitDutyFactory extends AbstractFactory { public List pick(List flags) throws Exception { List list = new ArrayList<>(); for (String str : flags) { - CacheKey cacheKey = new CacheKey(str); + CacheKey cacheKey = new CacheKey(UnitDuty.class.getName(), str); Optional optional = CacheManager.get(cache, cacheKey); if (optional.isPresent()) { list.add((UnitDuty) optional.get()); } else { UnitDuty o = this.pickObject(str); - CacheManager.put(cache, cacheKey, o); if (null != o) { + CacheManager.put(cache, cacheKey, o); list.add(o); } } @@ -103,4 +105,4 @@ public class UnitDutyFactory extends AbstractFactory { .collect(Collectors.toList()); return list; } -} \ No newline at end of file +} diff --git a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/UnitFactory.java b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/UnitFactory.java index c51052e847..afd5108e8e 100644 --- a/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/UnitFactory.java +++ b/o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/factory/UnitFactory.java @@ -42,13 +42,15 @@ public class UnitFactory extends AbstractFactory { return null; } Unit o = null; - CacheKey cacheKey = new CacheKey(flag); + CacheKey cacheKey = new CacheKey(Unit.class.getName(), flag); Optional optional = CacheManager.get(cache, cacheKey); if (optional.isPresent()) { o = (Unit) optional.get(); } else { o = this.pickObject(flag); - CacheManager.put(cache, cacheKey, o); + if (null != o) { + CacheManager.put(cache, cacheKey, o); + } } return o; } @@ -104,14 +106,14 @@ public class UnitFactory extends AbstractFactory { public List pick(List flags) throws Exception { List list = new ArrayList<>(); for (String str : flags) { - CacheKey cacheKey = new CacheKey(str); + CacheKey cacheKey = new CacheKey(Unit.class.getName(), str); Optional optional = CacheManager.get(cache, cacheKey); if (optional.isPresent()) { list.add((Unit) optional.get()); } else { Unit o = this.pickObject(str); - CacheManager.put(cache, cacheKey, o); if (null != o) { + CacheManager.put(cache, cacheKey, o); list.add(o); } } @@ -343,4 +345,4 @@ public class UnitFactory extends AbstractFactory { } } -} \ No newline at end of file +} diff --git a/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/IdentityFactory.java b/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/IdentityFactory.java index f57e76e1a6..4aab5a2439 100644 --- a/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/IdentityFactory.java +++ b/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/IdentityFactory.java @@ -42,7 +42,7 @@ public class IdentityFactory extends AbstractFactory { return null; } Identity o = null; - CacheKey cacheKey = new CacheKey(flag); + CacheKey cacheKey = new CacheKey(Identity.class.getName(), flag); Optional optional = CacheManager.get(cacheCategory, cacheKey); if (optional.isPresent()) { o = (Identity) optional.get(); @@ -89,7 +89,7 @@ public class IdentityFactory extends AbstractFactory { public List pick(List flags) throws Exception { List list = new ArrayList<>(); for (String str : flags) { - CacheKey cacheKey = new CacheKey(str); + CacheKey cacheKey = new CacheKey(Identity.class.getName(), str); Optional optional = CacheManager.get(cacheCategory, cacheKey); if (optional.isPresent()) { list.add((Identity) optional.get()); diff --git a/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/PersonFactory.java b/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/PersonFactory.java index 305492e687..73735618be 100644 --- a/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/PersonFactory.java +++ b/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/PersonFactory.java @@ -40,7 +40,7 @@ public class PersonFactory extends AbstractFactory { return null; } Person o = null; - CacheKey cacheKey = new CacheKey(flag); + CacheKey cacheKey = new CacheKey(Person.class.getName(), flag); Optional optional = CacheManager.get(cacheCategory, cacheKey); if (optional.isPresent()) { o = (Person) optional.get(); @@ -90,7 +90,7 @@ public class PersonFactory extends AbstractFactory { public List pick(List flags) throws Exception { List list = new ArrayList<>(); for (String str : ListTools.trim(flags, true, false)) { - CacheKey cacheKey = new CacheKey(str); + CacheKey cacheKey = new CacheKey(Person.class.getName(), str); Optional optional = CacheManager.get(cacheCategory, cacheKey); if (optional.isPresent()) { list.add((Person) optional.get()); @@ -210,4 +210,4 @@ public class PersonFactory extends AbstractFactory { List values = ListTools.extractProperty(list, JpaObject.DISTINGUISHEDNAME, String.class, true, true); return values; } -} \ No newline at end of file +} diff --git a/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/UnitDutyFactory.java b/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/UnitDutyFactory.java index 26f05528de..c1073a733e 100644 --- a/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/UnitDutyFactory.java +++ b/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/UnitDutyFactory.java @@ -23,6 +23,9 @@ import com.x.organization.assemble.express.Business; import com.x.organization.core.entity.UnitDuty; import com.x.organization.core.entity.UnitDuty_; +/** + * @author sword + */ public class UnitDutyFactory extends AbstractFactory { private CacheCategory cacheCategory = new CacheCategory(UnitDuty.class); @@ -36,7 +39,7 @@ public class UnitDutyFactory extends AbstractFactory { return null; } UnitDuty o = null; - CacheKey cacheKey = new CacheKey(flag); + CacheKey cacheKey = new CacheKey(UnitDuty.class.getSimpleName(), flag); Optional optional = CacheManager.get(cacheCategory, cacheKey); if (optional.isPresent()) { o = (UnitDuty) optional.get(); @@ -83,7 +86,7 @@ public class UnitDutyFactory extends AbstractFactory { public List pick(List flags) throws Exception { List list = new ArrayList<>(); for (String str : flags) { - CacheKey cacheKey = new CacheKey(str); + CacheKey cacheKey = new CacheKey(UnitDuty.class.getSimpleName(), str); Optional optional = CacheManager.get(cacheCategory, cacheKey); if (optional.isPresent()) { list.add((UnitDuty) optional.get()); @@ -105,4 +108,4 @@ public class UnitDutyFactory extends AbstractFactory { .collect(Collectors.toList()); return list; } -} \ No newline at end of file +} diff --git a/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/UnitFactory.java b/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/UnitFactory.java index 98b5f34c6e..34cbfe81c8 100644 --- a/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/UnitFactory.java +++ b/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/UnitFactory.java @@ -42,7 +42,7 @@ public class UnitFactory extends AbstractFactory { return null; } Unit o = null; - CacheKey cacheKey = new CacheKey(flag); + CacheKey cacheKey = new CacheKey(Unit.class.getName(), flag); Optional optional = CacheManager.get(cacheCategory, cacheKey); if (optional.isPresent()) { o = (Unit) optional.get(); @@ -106,7 +106,7 @@ public class UnitFactory extends AbstractFactory { public List pick(List flags) throws Exception { List list = new ArrayList<>(); for (String str : flags) { - CacheKey cacheKey = new CacheKey(str); + CacheKey cacheKey = new CacheKey(Unit.class.getName(), str); Optional optional = CacheManager.get(cacheCategory, cacheKey); if (optional.isPresent()) { list.add((Unit) optional.get()); @@ -307,4 +307,4 @@ public class UnitFactory extends AbstractFactory { List values = ListTools.extractProperty(list, JpaObject.DISTINGUISHEDNAME, String.class, true, true); return values; } -} \ No newline at end of file +} diff --git a/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/person/ActionListWithUnitSubDirectObject.java b/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/person/ActionListWithUnitSubDirectObject.java index fe9bf356fa..6f6c17cd7d 100644 --- a/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/person/ActionListWithUnitSubDirectObject.java +++ b/o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/jaxrs/person/ActionListWithUnitSubDirectObject.java @@ -68,13 +68,7 @@ class ActionListWithUnitSubDirectObject extends BaseAction { private List list(Business business, Wi wi) throws Exception { List wos = new ArrayList<>(); List os = business.unit().pick(wi.getUnitList()); - List unitIds = new ArrayList<>(); - for (Unit o : os) { - if(!unitIds.contains(o.getId())) { - unitIds.add(o.getId()); - } - } - unitIds = ListTools.trim(unitIds, true, true); + List unitIds = ListTools.extractField(os, Unit.id_FIELDNAME, String.class, true, true); List list = new ArrayList<>(); if(ListTools.isNotEmpty(unitIds)) { list = business.entityManagerContainer().fetchIn(Identity.class, -- GitLab