|
|
@@ -0,0 +1,80 @@
|
|
|
+package com.uas.platform.b2c.trade.order.service.impl;
|
|
|
+
|
|
|
+import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
+import com.uas.platform.b2c.common.account.model.User;
|
|
|
+import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
+import com.uas.platform.b2c.trade.order.dao.AdminToDoDao;
|
|
|
+import com.uas.platform.b2c.trade.order.model.AdminToDo;
|
|
|
+import com.uas.platform.b2c.trade.order.model.MessageNotifyPersonalManagement;
|
|
|
+import com.uas.platform.b2c.trade.order.service.AdminToDoService;
|
|
|
+import com.uas.platform.b2c.trade.order.service.MessageNotifyPersonalManagementService;
|
|
|
+import com.uas.platform.core.model.PageInfo;
|
|
|
+import com.uas.platform.core.model.PageParams;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.persistence.criteria.CriteriaBuilder;
|
|
|
+import javax.persistence.criteria.CriteriaQuery;
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+import javax.persistence.criteria.Root;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 待办事项service
|
|
|
+ *
|
|
|
+ * @author yuj 2018-07-24 15:59
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class AdminToDoServiceImpl implements AdminToDoService {
|
|
|
+
|
|
|
+ private final AdminToDoDao adminToDoDao;
|
|
|
+
|
|
|
+ private final MessageNotifyPersonalManagementService messageNotifyPersonalManagementService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public AdminToDoServiceImpl(AdminToDoDao adminToDoDao, MessageNotifyPersonalManagementService messageNotifyPersonalManagementService) {
|
|
|
+ this.adminToDoDao = adminToDoDao;
|
|
|
+ this.messageNotifyPersonalManagementService = messageNotifyPersonalManagementService;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页获取待办事项
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ * @return Page<AdminToDo>
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Page<AdminToDo> getPageAdminToDo(PageParams params) {
|
|
|
+ final PageInfo info = new PageInfo(params);
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ Enterprise enterprise = user.getEnterprise();
|
|
|
+ if (enterprise == null) {
|
|
|
+ return new PageImpl<AdminToDo>(Collections.emptyList(), info, 0l);
|
|
|
+ }
|
|
|
+ List<MessageNotifyPersonalManagement> managements = messageNotifyPersonalManagementService.findNotifyPersonalEnuu(enterprise.getUu());
|
|
|
+ Boolean canNotify = false;
|
|
|
+ for (MessageNotifyPersonalManagement management : managements) {
|
|
|
+ if (management.getNotifyPersonalUseruu().longValue() == user.getUserUU().longValue()) {
|
|
|
+ canNotify = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!canNotify) {
|
|
|
+ return new PageImpl<AdminToDo>(Collections.emptyList(), info, 0l);
|
|
|
+ }
|
|
|
+ info.sorting("applytime", Sort.Direction.DESC);
|
|
|
+ org.springframework.data.domain.Page<AdminToDo> adminToDos = adminToDoDao.findAll(new Specification<AdminToDo>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<AdminToDo> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
+ query.where(info.getPredicates(root, query, cb));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }, info);
|
|
|
+ return adminToDos;
|
|
|
+ }
|
|
|
+}
|