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

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

【中心服务】修复distinct问题

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