提交 af3d66f7 编写于 作者: O o2sword

人员组织查询缓存修改

上级 0e2595bd
...@@ -41,13 +41,15 @@ public class GroupFactory extends AbstractFactory { ...@@ -41,13 +41,15 @@ public class GroupFactory extends AbstractFactory {
} }
Group o = null; Group o = null;
CacheKey cacheKey = new CacheKey(flag); CacheKey cacheKey = new CacheKey(Group.class.getName(), flag);
Optional<?> optional = CacheManager.get(cache, cacheKey); Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
o = (Group) optional.get(); o = (Group) optional.get();
} else { } else {
o = this.pickObject(flag); o = this.pickObject(flag);
CacheManager.put(cache, cacheKey, o); if (null != o) {
CacheManager.put(cache, cacheKey, o);
}
} }
return o; return o;
} }
...@@ -55,7 +57,7 @@ public class GroupFactory extends AbstractFactory { ...@@ -55,7 +57,7 @@ public class GroupFactory extends AbstractFactory {
public List<Group> pick(List<String> flags) throws Exception { public List<Group> pick(List<String> flags) throws Exception {
List<Group> list = new ArrayList<>(); List<Group> list = new ArrayList<>();
for (String str : flags) { for (String str : flags) {
CacheKey cacheKey = new CacheKey(str); CacheKey cacheKey = new CacheKey(Group.class.getName(), str);
Optional<?> optional = CacheManager.get(cache, cacheKey); Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
list.add((Group) optional.get()); list.add((Group) optional.get());
...@@ -258,4 +260,4 @@ public class GroupFactory extends AbstractFactory { ...@@ -258,4 +260,4 @@ public class GroupFactory extends AbstractFactory {
return this.entityManagerContainer().list(Group.class, ids); return this.entityManagerContainer().list(Group.class, ids);
} }
} }
\ No newline at end of file
...@@ -37,13 +37,15 @@ public class IdentityFactory extends AbstractFactory { ...@@ -37,13 +37,15 @@ public class IdentityFactory extends AbstractFactory {
return null; return null;
} }
Identity o = null; Identity o = null;
CacheKey cacheKey = new CacheKey(flag); CacheKey cacheKey = new CacheKey(Identity.class.getName(), flag);
Optional<?> optional = CacheManager.get(cache, cacheKey); Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
o = (Identity) optional.get(); o = (Identity) optional.get();
} else { } else {
o = this.pickObject(flag); o = this.pickObject(flag);
CacheManager.put(cache, cacheKey, o); if (null != o) {
CacheManager.put(cache, cacheKey, o);
}
} }
return o; return o;
} }
...@@ -82,14 +84,14 @@ public class IdentityFactory extends AbstractFactory { ...@@ -82,14 +84,14 @@ public class IdentityFactory extends AbstractFactory {
public List<Identity> pick(List<String> flags) throws Exception { public List<Identity> pick(List<String> flags) throws Exception {
List<Identity> list = new ArrayList<>(); List<Identity> list = new ArrayList<>();
for (String str : flags) { for (String str : flags) {
CacheKey cacheKey = new CacheKey(str); CacheKey cacheKey = new CacheKey(Identity.class.getName(), str);
Optional<?> optional = CacheManager.get(cache, cacheKey); Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
list.add((Identity) optional.get()); list.add((Identity) optional.get());
} else { } else {
Identity o = this.pickObject(str); Identity o = this.pickObject(str);
CacheManager.put(cache, cacheKey, o);
if (null != o) { if (null != o) {
CacheManager.put(cache, cacheKey, o);
list.add(o); list.add(o);
} }
} }
......
...@@ -36,13 +36,15 @@ public class PersonFactory extends AbstractFactory { ...@@ -36,13 +36,15 @@ public class PersonFactory extends AbstractFactory {
return null; return null;
} }
Person o = null; Person o = null;
CacheKey cacheKey = new CacheKey(flag); CacheKey cacheKey = new CacheKey(Person.class.getName(), flag);
Optional<?> optional = CacheManager.get(cache, cacheKey); Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
o = (Person) optional.get(); o = (Person) optional.get();
} else { } else {
o = this.pickObject(flag); o = this.pickObject(flag);
CacheManager.put(cache, cacheKey, o); if (null != o) {
CacheManager.put(cache, cacheKey, o);
}
} }
return o; return o;
} }
...@@ -81,14 +83,14 @@ public class PersonFactory extends AbstractFactory { ...@@ -81,14 +83,14 @@ public class PersonFactory extends AbstractFactory {
public List<Person> pick(List<String> flags) throws Exception { public List<Person> pick(List<String> flags) throws Exception {
List<Person> list = new ArrayList<>(); List<Person> list = new ArrayList<>();
for (String str : flags) { for (String str : flags) {
CacheKey cacheKey = new CacheKey(str); CacheKey cacheKey = new CacheKey(Person.class.getName(), str);
Optional<?> optional = CacheManager.get(cache, cacheKey); Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
list.add((Person) optional.get()); list.add((Person) optional.get());
} else { } else {
Person o = this.pickObject(str); Person o = this.pickObject(str);
CacheManager.put(cache, cacheKey, o);
if (null != o) { if (null != o) {
CacheManager.put(cache, cacheKey, o);
list.add(o); list.add(o);
} }
} }
......
...@@ -36,13 +36,15 @@ public class UnitDutyFactory extends AbstractFactory { ...@@ -36,13 +36,15 @@ public class UnitDutyFactory extends AbstractFactory {
return null; return null;
} }
UnitDuty o = null; UnitDuty o = null;
CacheKey cacheKey = new CacheKey(flag); CacheKey cacheKey = new CacheKey(UnitDuty.class.getName(), flag);
Optional<?> optional = CacheManager.get(cache, cacheKey); Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
o = (UnitDuty) optional.get(); o = (UnitDuty) optional.get();
} else { } else {
o = this.pickObject(flag); o = this.pickObject(flag);
CacheManager.put(cache, cacheKey, o); if (null != o) {
CacheManager.put(cache, cacheKey, o);
}
} }
return o; return o;
} }
...@@ -81,14 +83,14 @@ public class UnitDutyFactory extends AbstractFactory { ...@@ -81,14 +83,14 @@ public class UnitDutyFactory extends AbstractFactory {
public List<UnitDuty> pick(List<String> flags) throws Exception { public List<UnitDuty> pick(List<String> flags) throws Exception {
List<UnitDuty> list = new ArrayList<>(); List<UnitDuty> list = new ArrayList<>();
for (String str : flags) { for (String str : flags) {
CacheKey cacheKey = new CacheKey(str); CacheKey cacheKey = new CacheKey(UnitDuty.class.getName(), str);
Optional<?> optional = CacheManager.get(cache, cacheKey); Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
list.add((UnitDuty) optional.get()); list.add((UnitDuty) optional.get());
} else { } else {
UnitDuty o = this.pickObject(str); UnitDuty o = this.pickObject(str);
CacheManager.put(cache, cacheKey, o);
if (null != o) { if (null != o) {
CacheManager.put(cache, cacheKey, o);
list.add(o); list.add(o);
} }
} }
...@@ -103,4 +105,4 @@ public class UnitDutyFactory extends AbstractFactory { ...@@ -103,4 +105,4 @@ public class UnitDutyFactory extends AbstractFactory {
.collect(Collectors.toList()); .collect(Collectors.toList());
return list; return list;
} }
} }
\ No newline at end of file
...@@ -42,13 +42,15 @@ public class UnitFactory extends AbstractFactory { ...@@ -42,13 +42,15 @@ public class UnitFactory extends AbstractFactory {
return null; return null;
} }
Unit o = null; Unit o = null;
CacheKey cacheKey = new CacheKey(flag); CacheKey cacheKey = new CacheKey(Unit.class.getName(), flag);
Optional<?> optional = CacheManager.get(cache, cacheKey); Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
o = (Unit) optional.get(); o = (Unit) optional.get();
} else { } else {
o = this.pickObject(flag); o = this.pickObject(flag);
CacheManager.put(cache, cacheKey, o); if (null != o) {
CacheManager.put(cache, cacheKey, o);
}
} }
return o; return o;
} }
...@@ -104,14 +106,14 @@ public class UnitFactory extends AbstractFactory { ...@@ -104,14 +106,14 @@ public class UnitFactory extends AbstractFactory {
public List<Unit> pick(List<String> flags) throws Exception { public List<Unit> pick(List<String> flags) throws Exception {
List<Unit> list = new ArrayList<>(); List<Unit> list = new ArrayList<>();
for (String str : flags) { for (String str : flags) {
CacheKey cacheKey = new CacheKey(str); CacheKey cacheKey = new CacheKey(Unit.class.getName(), str);
Optional<?> optional = CacheManager.get(cache, cacheKey); Optional<?> optional = CacheManager.get(cache, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
list.add((Unit) optional.get()); list.add((Unit) optional.get());
} else { } else {
Unit o = this.pickObject(str); Unit o = this.pickObject(str);
CacheManager.put(cache, cacheKey, o);
if (null != o) { if (null != o) {
CacheManager.put(cache, cacheKey, o);
list.add(o); list.add(o);
} }
} }
...@@ -343,4 +345,4 @@ public class UnitFactory extends AbstractFactory { ...@@ -343,4 +345,4 @@ public class UnitFactory extends AbstractFactory {
} }
} }
} }
\ No newline at end of file
...@@ -42,7 +42,7 @@ public class IdentityFactory extends AbstractFactory { ...@@ -42,7 +42,7 @@ public class IdentityFactory extends AbstractFactory {
return null; return null;
} }
Identity o = null; Identity o = null;
CacheKey cacheKey = new CacheKey(flag); CacheKey cacheKey = new CacheKey(Identity.class.getName(), flag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey); Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
o = (Identity) optional.get(); o = (Identity) optional.get();
...@@ -89,7 +89,7 @@ public class IdentityFactory extends AbstractFactory { ...@@ -89,7 +89,7 @@ public class IdentityFactory extends AbstractFactory {
public List<Identity> pick(List<String> flags) throws Exception { public List<Identity> pick(List<String> flags) throws Exception {
List<Identity> list = new ArrayList<>(); List<Identity> list = new ArrayList<>();
for (String str : flags) { for (String str : flags) {
CacheKey cacheKey = new CacheKey(str); CacheKey cacheKey = new CacheKey(Identity.class.getName(), str);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey); Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
list.add((Identity) optional.get()); list.add((Identity) optional.get());
......
...@@ -40,7 +40,7 @@ public class PersonFactory extends AbstractFactory { ...@@ -40,7 +40,7 @@ public class PersonFactory extends AbstractFactory {
return null; return null;
} }
Person o = null; Person o = null;
CacheKey cacheKey = new CacheKey(flag); CacheKey cacheKey = new CacheKey(Person.class.getName(), flag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey); Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
o = (Person) optional.get(); o = (Person) optional.get();
...@@ -90,7 +90,7 @@ public class PersonFactory extends AbstractFactory { ...@@ -90,7 +90,7 @@ public class PersonFactory extends AbstractFactory {
public List<Person> pick(List<String> flags) throws Exception { public List<Person> pick(List<String> flags) throws Exception {
List<Person> list = new ArrayList<>(); List<Person> list = new ArrayList<>();
for (String str : ListTools.trim(flags, true, false)) { 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); Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
list.add((Person) optional.get()); list.add((Person) optional.get());
...@@ -210,4 +210,4 @@ public class PersonFactory extends AbstractFactory { ...@@ -210,4 +210,4 @@ public class PersonFactory extends AbstractFactory {
List<String> values = ListTools.extractProperty(list, JpaObject.DISTINGUISHEDNAME, String.class, true, true); List<String> values = ListTools.extractProperty(list, JpaObject.DISTINGUISHEDNAME, String.class, true, true);
return values; return values;
} }
} }
\ No newline at end of file
...@@ -23,6 +23,9 @@ import com.x.organization.assemble.express.Business; ...@@ -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;
import com.x.organization.core.entity.UnitDuty_; import com.x.organization.core.entity.UnitDuty_;
/**
* @author sword
*/
public class UnitDutyFactory extends AbstractFactory { public class UnitDutyFactory extends AbstractFactory {
private CacheCategory cacheCategory = new CacheCategory(UnitDuty.class); private CacheCategory cacheCategory = new CacheCategory(UnitDuty.class);
...@@ -36,7 +39,7 @@ public class UnitDutyFactory extends AbstractFactory { ...@@ -36,7 +39,7 @@ public class UnitDutyFactory extends AbstractFactory {
return null; return null;
} }
UnitDuty o = null; UnitDuty o = null;
CacheKey cacheKey = new CacheKey(flag); CacheKey cacheKey = new CacheKey(UnitDuty.class.getSimpleName(), flag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey); Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
o = (UnitDuty) optional.get(); o = (UnitDuty) optional.get();
...@@ -83,7 +86,7 @@ public class UnitDutyFactory extends AbstractFactory { ...@@ -83,7 +86,7 @@ public class UnitDutyFactory extends AbstractFactory {
public List<UnitDuty> pick(List<String> flags) throws Exception { public List<UnitDuty> pick(List<String> flags) throws Exception {
List<UnitDuty> list = new ArrayList<>(); List<UnitDuty> list = new ArrayList<>();
for (String str : flags) { for (String str : flags) {
CacheKey cacheKey = new CacheKey(str); CacheKey cacheKey = new CacheKey(UnitDuty.class.getSimpleName(), str);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey); Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
list.add((UnitDuty) optional.get()); list.add((UnitDuty) optional.get());
...@@ -105,4 +108,4 @@ public class UnitDutyFactory extends AbstractFactory { ...@@ -105,4 +108,4 @@ public class UnitDutyFactory extends AbstractFactory {
.collect(Collectors.toList()); .collect(Collectors.toList());
return list; return list;
} }
} }
\ No newline at end of file
...@@ -42,7 +42,7 @@ public class UnitFactory extends AbstractFactory { ...@@ -42,7 +42,7 @@ public class UnitFactory extends AbstractFactory {
return null; return null;
} }
Unit o = null; Unit o = null;
CacheKey cacheKey = new CacheKey(flag); CacheKey cacheKey = new CacheKey(Unit.class.getName(), flag);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey); Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
o = (Unit) optional.get(); o = (Unit) optional.get();
...@@ -106,7 +106,7 @@ public class UnitFactory extends AbstractFactory { ...@@ -106,7 +106,7 @@ public class UnitFactory extends AbstractFactory {
public List<Unit> pick(List<String> flags) throws Exception { public List<Unit> pick(List<String> flags) throws Exception {
List<Unit> list = new ArrayList<>(); List<Unit> list = new ArrayList<>();
for (String str : flags) { for (String str : flags) {
CacheKey cacheKey = new CacheKey(str); CacheKey cacheKey = new CacheKey(Unit.class.getName(), str);
Optional<?> optional = CacheManager.get(cacheCategory, cacheKey); Optional<?> optional = CacheManager.get(cacheCategory, cacheKey);
if (optional.isPresent()) { if (optional.isPresent()) {
list.add((Unit) optional.get()); list.add((Unit) optional.get());
...@@ -307,4 +307,4 @@ public class UnitFactory extends AbstractFactory { ...@@ -307,4 +307,4 @@ public class UnitFactory extends AbstractFactory {
List<String> values = ListTools.extractProperty(list, JpaObject.DISTINGUISHEDNAME, String.class, true, true); List<String> values = ListTools.extractProperty(list, JpaObject.DISTINGUISHEDNAME, String.class, true, true);
return values; return values;
} }
} }
\ No newline at end of file
...@@ -68,13 +68,7 @@ class ActionListWithUnitSubDirectObject extends BaseAction { ...@@ -68,13 +68,7 @@ class ActionListWithUnitSubDirectObject extends BaseAction {
private List<Wo> list(Business business, Wi wi) throws Exception { private List<Wo> list(Business business, Wi wi) throws Exception {
List<Wo> wos = new ArrayList<>(); List<Wo> wos = new ArrayList<>();
List<Unit> os = business.unit().pick(wi.getUnitList()); List<Unit> os = business.unit().pick(wi.getUnitList());
List<String> unitIds = new ArrayList<>(); List<String> unitIds = ListTools.extractField(os, Unit.id_FIELDNAME, String.class, true, true);
for (Unit o : os) {
if(!unitIds.contains(o.getId())) {
unitIds.add(o.getId());
}
}
unitIds = ListTools.trim(unitIds, true, true);
List<Identity> list = new ArrayList<>(); List<Identity> list = new ArrayList<>();
if(ListTools.isNotEmpty(unitIds)) { if(ListTools.isNotEmpty(unitIds)) {
list = business.entityManagerContainer().fetchIn(Identity.class, list = business.entityManagerContainer().fetchIn(Identity.class,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册