提交 06c5e700 编写于 作者: O o2null

Merge branch 'fix/中心服务distinct问题' into 'develop'

【中心服务】修复distinct问题

See merge request o2oa/o2oa!1609
...@@ -408,7 +408,7 @@ public class SyncOrganization { ...@@ -408,7 +408,7 @@ public class SyncOrganization {
Root<Identity> root = cq.from(Identity.class); Root<Identity> root = cq.from(Identity.class);
Predicate p = cb.equal(root.get(Identity_.person), person.getId()); Predicate p = cb.equal(root.get(Identity_.person), person.getId());
p = cb.and(p, cb.equal(root.get(Identity_.unit), unit.getId())); p = cb.and(p, cb.equal(root.get(Identity_.unit), unit.getId()));
List<Identity> os = em.createQuery(cq.select(root).where(p).distinct(true)).setMaxResults(1).getResultList(); List<Identity> os = em.createQuery(cq.select(root).where(p)).setMaxResults(1).getResultList();
Identity identity = null; Identity identity = null;
Long order = null; Long order = null;
if (StringUtils.isNotEmpty(user.getOrderInDepts())) { if (StringUtils.isNotEmpty(user.getOrderInDepts())) {
...@@ -543,7 +543,7 @@ public class SyncOrganization { ...@@ -543,7 +543,7 @@ public class SyncOrganization {
Root<Unit> root = cq.from(Unit.class); Root<Unit> root = cq.from(Unit.class);
Predicate p = cb.notEqual(root.get(Unit_.dingdingId), ""); Predicate p = cb.notEqual(root.get(Unit_.dingdingId), "");
p = cb.and(p, cb.isNotNull(root.get(Unit_.dingdingId))); p = cb.and(p, cb.isNotNull(root.get(Unit_.dingdingId)));
List<Unit> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList(); List<Unit> os = em.createQuery(cq.select(root).where(p)).getResultList();
return os; return os;
} }
...@@ -555,7 +555,7 @@ public class SyncOrganization { ...@@ -555,7 +555,7 @@ public class SyncOrganization {
Root<Person> root = cq.from(Person.class); Root<Person> root = cq.from(Person.class);
Predicate p = cb.notEqual(root.get(Person_.dingdingId), ""); Predicate p = cb.notEqual(root.get(Person_.dingdingId), "");
p = cb.and(p, cb.isNotNull(root.get(Person_.dingdingId))); p = cb.and(p, cb.isNotNull(root.get(Person_.dingdingId)));
List<Person> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList(); List<Person> os = em.createQuery(cq.select(root).where(p)).getResultList();
return os; return os;
} }
......
...@@ -13,6 +13,7 @@ import javax.persistence.criteria.CriteriaBuilder; ...@@ -13,6 +13,7 @@ import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
class ActionListCategory extends BaseAction { class ActionListCategory extends BaseAction {
...@@ -24,8 +25,8 @@ class ActionListCategory extends BaseAction { ...@@ -24,8 +25,8 @@ class ActionListCategory extends BaseAction {
CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class); CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Application> root = cq.from(Application.class); Root<Application> root = cq.from(Application.class);
cq.select(root.get(Application_.category)).distinct(true); cq.select(root.get(Application_.category));
List<String> categoryList = em.createQuery(cq).getResultList(); List<String> categoryList = em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
Wo wo = new Wo(); Wo wo = new Wo();
wo.setValueList(categoryList); wo.setValueList(categoryList);
......
...@@ -47,7 +47,7 @@ class ActionCountWithExceptionClass extends BaseAction { ...@@ -47,7 +47,7 @@ class ActionCountWithExceptionClass extends BaseAction {
CriteriaQuery<String> cq = cb.createQuery(String.class); CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<PromptErrorLog> root = cq.from(PromptErrorLog.class); Root<PromptErrorLog> root = cq.from(PromptErrorLog.class);
cq.select(root.get(PromptErrorLog_.exceptionClass)); cq.select(root.get(PromptErrorLog_.exceptionClass));
return em.createQuery(cq.distinct(true)).getResultList(); return em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
} }
private Long count(Business business, String exceptionClass) throws Exception { private Long count(Business business, String exceptionClass) throws Exception {
......
...@@ -47,7 +47,7 @@ class ActionCountWithLoggerName extends BaseAction { ...@@ -47,7 +47,7 @@ class ActionCountWithLoggerName extends BaseAction {
CriteriaQuery<String> cq = cb.createQuery(String.class); CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<PromptErrorLog> root = cq.from(PromptErrorLog.class); Root<PromptErrorLog> root = cq.from(PromptErrorLog.class);
cq.select(root.get(PromptErrorLog_.loggerName)); cq.select(root.get(PromptErrorLog_.loggerName));
return em.createQuery(cq.distinct(true)).getResultList(); return em.createQuery(cq).getResultList().stream().distinct().collect(Collectors.toList());
} }
private Long count(Business business, String loggerName) throws Exception { private Long count(Business business, String loggerName) throws Exception {
......
...@@ -403,7 +403,7 @@ public class SyncOrganization { ...@@ -403,7 +403,7 @@ public class SyncOrganization {
Root<Identity> root = cq.from(Identity.class); Root<Identity> root = cq.from(Identity.class);
Predicate p = cb.equal(root.get(Identity_.person), person.getId()); Predicate p = cb.equal(root.get(Identity_.person), person.getId());
p = cb.and(p, cb.equal(root.get(Identity_.unit), unit.getId())); p = cb.and(p, cb.equal(root.get(Identity_.unit), unit.getId()));
List<Identity> os = em.createQuery(cq.select(root).where(p).distinct(true)).setMaxResults(1).getResultList(); List<Identity> os = em.createQuery(cq.select(root).where(p)).setMaxResults(1).getResultList();
Identity identity = null; Identity identity = null;
Long order = null; Long order = null;
if (ListTools.isNotEmpty(user.getOrder())) { if (ListTools.isNotEmpty(user.getOrder())) {
...@@ -533,7 +533,7 @@ public class SyncOrganization { ...@@ -533,7 +533,7 @@ public class SyncOrganization {
Root<Unit> root = cq.from(Unit.class); Root<Unit> root = cq.from(Unit.class);
Predicate p = cb.notEqual(root.get(Unit_.qiyeweixinId), ""); Predicate p = cb.notEqual(root.get(Unit_.qiyeweixinId), "");
p = cb.and(p, cb.isNotNull(root.get(Unit_.qiyeweixinId))); p = cb.and(p, cb.isNotNull(root.get(Unit_.qiyeweixinId)));
List<Unit> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList(); List<Unit> os = em.createQuery(cq.select(root).where(p)).getResultList();
return os; return os;
} }
...@@ -545,7 +545,7 @@ public class SyncOrganization { ...@@ -545,7 +545,7 @@ public class SyncOrganization {
Root<Person> root = cq.from(Person.class); Root<Person> root = cq.from(Person.class);
Predicate p = cb.notEqual(root.get(Person_.qiyeweixinId), ""); Predicate p = cb.notEqual(root.get(Person_.qiyeweixinId), "");
p = cb.and(p, cb.isNotNull(root.get(Person_.qiyeweixinId))); p = cb.and(p, cb.isNotNull(root.get(Person_.qiyeweixinId)));
List<Person> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList(); List<Person> os = em.createQuery(cq.select(root).where(p)).getResultList();
return os; return os;
} }
......
...@@ -171,7 +171,7 @@ public class SyncOrganization { ...@@ -171,7 +171,7 @@ public class SyncOrganization {
Root<Identity> root = cq.from(Identity.class); Root<Identity> root = cq.from(Identity.class);
Predicate p = cb.equal(root.get(Identity_.person), person.getId()); Predicate p = cb.equal(root.get(Identity_.person), person.getId());
p = cb.and(p, cb.equal(root.get(Identity_.unit), unit.getId())); p = cb.and(p, cb.equal(root.get(Identity_.unit), unit.getId()));
List<Identity> os = em.createQuery(cq.select(root).where(p).distinct(true)).setMaxResults(1).getResultList(); List<Identity> os = em.createQuery(cq.select(root).where(p)).setMaxResults(1).getResultList();
Identity identity = null; Identity identity = null;
Long order = null; Long order = null;
// if (StringUtils.isNotEmpty(user.getOrderInDepts())) { // if (StringUtils.isNotEmpty(user.getOrderInDepts())) {
...@@ -450,7 +450,7 @@ public class SyncOrganization { ...@@ -450,7 +450,7 @@ public class SyncOrganization {
Root<Unit> root = cq.from(Unit.class); Root<Unit> root = cq.from(Unit.class);
Predicate p = cb.notEqual(root.get(Unit_.weLinkId), ""); Predicate p = cb.notEqual(root.get(Unit_.weLinkId), "");
p = cb.and(p, cb.isNotNull(root.get(Unit_.weLinkId))); p = cb.and(p, cb.isNotNull(root.get(Unit_.weLinkId)));
List<Unit> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList(); List<Unit> os = em.createQuery(cq.select(root).where(p)).getResultList();
return os; return os;
} }
...@@ -462,7 +462,7 @@ public class SyncOrganization { ...@@ -462,7 +462,7 @@ public class SyncOrganization {
Root<Person> root = cq.from(Person.class); Root<Person> root = cq.from(Person.class);
Predicate p = cb.notEqual(root.get(Person_.weLinkId), ""); Predicate p = cb.notEqual(root.get(Person_.weLinkId), "");
p = cb.and(p, cb.isNotNull(root.get(Person_.weLinkId))); p = cb.and(p, cb.isNotNull(root.get(Person_.weLinkId)));
List<Person> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList(); List<Person> os = em.createQuery(cq.select(root).where(p)).getResultList();
return os; return os;
} }
......
...@@ -384,7 +384,7 @@ public class SyncOrganization { ...@@ -384,7 +384,7 @@ public class SyncOrganization {
Root<Identity> root = cq.from(Identity.class); Root<Identity> root = cq.from(Identity.class);
Predicate p = cb.equal(root.get(Identity_.person), person.getId()); Predicate p = cb.equal(root.get(Identity_.person), person.getId());
p = cb.and(p, cb.equal(root.get(Identity_.unit), unit.getId())); p = cb.and(p, cb.equal(root.get(Identity_.unit), unit.getId()));
List<Identity> os = em.createQuery(cq.select(root).where(p).distinct(true)).setMaxResults(1).getResultList(); List<Identity> os = em.createQuery(cq.select(root).where(p)).setMaxResults(1).getResultList();
Identity identity = null; Identity identity = null;
if (os.size() == 0) { if (os.size() == 0) {
identity = this.createIdentity(business, result, person, unit, user); identity = this.createIdentity(business, result, person, unit, user);
...@@ -520,7 +520,7 @@ public class SyncOrganization { ...@@ -520,7 +520,7 @@ public class SyncOrganization {
Root<Unit> root = cq.from(Unit.class); Root<Unit> root = cq.from(Unit.class);
Predicate p = cb.notEqual(root.get(Unit_.zhengwuDingdingId), ""); Predicate p = cb.notEqual(root.get(Unit_.zhengwuDingdingId), "");
p = cb.and(p, cb.isNotNull(root.get(Unit_.zhengwuDingdingId))); p = cb.and(p, cb.isNotNull(root.get(Unit_.zhengwuDingdingId)));
List<Unit> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList(); List<Unit> os = em.createQuery(cq.select(root).where(p)).getResultList();
return os; return os;
} }
...@@ -532,7 +532,7 @@ public class SyncOrganization { ...@@ -532,7 +532,7 @@ public class SyncOrganization {
Root<Person> root = cq.from(Person.class); Root<Person> root = cq.from(Person.class);
Predicate p = cb.notEqual(root.get(Person_.zhengwuDingdingId), ""); Predicate p = cb.notEqual(root.get(Person_.zhengwuDingdingId), "");
p = cb.and(p, cb.isNotNull(root.get(Person_.zhengwuDingdingId))); p = cb.and(p, cb.isNotNull(root.get(Person_.zhengwuDingdingId)));
List<Person> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList(); List<Person> os = em.createQuery(cq.select(root).where(p)).getResultList();
return os; return os;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册