|
@@ -6,6 +6,11 @@ import java.util.List;
|
|
|
|
|
|
import javax.jws.HandlerChain;
|
|
|
import javax.jws.WebService;
|
|
|
+import javax.persistence.criteria.CriteriaBuilder;
|
|
|
+import javax.persistence.criteria.CriteriaQuery;
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+import javax.persistence.criteria.Root;
|
|
|
+import javax.persistence.criteria.Subquery;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
@@ -21,6 +26,7 @@ import com.jtgh.yjpt.common.SpecificationCreater;
|
|
|
import com.jtgh.yjpt.common.Utils;
|
|
|
import com.jtgh.yjpt.controller.BaseController;
|
|
|
import com.jtgh.yjpt.entity.BaseEntity;
|
|
|
+import com.jtgh.yjpt.entity.auth.UserEntity;
|
|
|
import com.jtgh.yjpt.entity.common.AccessoryEntity;
|
|
|
import com.jtgh.yjpt.entity.gg.GgEntity;
|
|
|
import com.jtgh.yjpt.entity.gg.GgViewEntity;
|
|
@@ -126,47 +132,81 @@ public class GgWebService extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 分页查询公告信息
|
|
|
- * @param lkr
|
|
|
- * @param title
|
|
|
- * @param n
|
|
|
- * @param pageCount
|
|
|
+ * 分页查询公告信息--公告管理
|
|
|
+ * @param lkr 落款人
|
|
|
+ * @param title 标题
|
|
|
+ * @param n 每页数据条数
|
|
|
+ * @param pageCount 页码
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<GgEntity> getGgPageListByParams(String lkr, String title,int n, int pageCount){
|
|
|
- List<PredicateModel> filterList = new ArrayList<PredicateModel>();
|
|
|
- addNotEmptyModel(filterList, "lkr", lkr, PredicateModel.Operator.LIKE);
|
|
|
- addNotEmptyModel(filterList, "title", title,
|
|
|
- PredicateModel.Operator.LIKE);
|
|
|
- // 只检索非删除状态记录
|
|
|
- addNotEmptyModel(filterList, "recordStatus",
|
|
|
- BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
|
|
|
- Specification<GgEntity> spec = SpecificationCreater
|
|
|
- .searchByPredicateModels(filterList);
|
|
|
- SinglePageRequest page = new SinglePageRequest(pageCount, n,
|
|
|
- "desc", "id");
|
|
|
- Page<GgEntity> pageList = service.findAll(spec, page);
|
|
|
- if (pageList == null || pageList.getTotalPages() <= pageCount) {
|
|
|
- return new ArrayList<GgEntity>();
|
|
|
- }
|
|
|
- for (GgEntity gg : pageList) {
|
|
|
- List<PredicateModel> filterList2 = new ArrayList<PredicateModel>();
|
|
|
- addNotEmptyModel(filterList2, "entityType.id",
|
|
|
- Constants.FJSSLX_T_YJPT_GG, Operator.EQ);
|
|
|
- addNotEmptyModel(filterList2, "recordStatus",
|
|
|
- BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
|
|
|
- addNotEmptyModel(filterList2, "entityId", gg.getId(),
|
|
|
- PredicateModel.Operator.EQ);
|
|
|
- Specification<AccessoryEntity> accSpec = SpecificationCreater
|
|
|
- .searchByPredicateModels(filterList2);
|
|
|
- List<AccessoryEntity> acc = accessoryService.findAll(accSpec);
|
|
|
- if (acc != null && acc.size() > 0) {
|
|
|
- gg.setAccessory(acc.get(0));
|
|
|
+ public List<GgEntity> getGgPageListByParams(final String lkr,final String title,int n, int pageCount){
|
|
|
+ final UserEntity user = Utils.getWebServiceUser();
|
|
|
+ SinglePageRequest page = new SinglePageRequest(pageCount, n, "desc", "id");
|
|
|
+ if (user.getSfjyr().equals(Constants.YES) && !user.getSfcd().equals(Constants.YES)) {
|
|
|
+ //是经营人&&非船代
|
|
|
+
|
|
|
+ // ----------------------------------specification经营人只能看经营人可见的公告----------------------------------
|
|
|
+ Specification<GgEntity> spec = new Specification<GgEntity>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<GgEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
+ List<Predicate> list = new ArrayList<Predicate>();
|
|
|
+ list.add(cb.equal(root.get("qykj").as(String.class), "Y"));
|
|
|
+ list.add(cb.notEqual(root.get("recordStatus").as(String.class),BaseEntity.RECORD_STATE_DELETE));
|
|
|
+ list.add(cb.like(root.get("lkr").as(String.class),"%" + lkr +"%"));
|
|
|
+ list.add(cb.like(root.get("title").as(String.class),"%" + title +"%"));
|
|
|
+ Subquery<GgViewEntity> subquery = query.subquery(GgViewEntity.class);
|
|
|
+ Root<GgViewEntity> ggviewRoot = subquery.from(GgViewEntity.class);
|
|
|
+ subquery.select(ggviewRoot);
|
|
|
+ List<Predicate> subQueryPredicates = new ArrayList<Predicate>();
|
|
|
+ subQueryPredicates.add(cb.equal(root.get("id").as(String.class),ggviewRoot.get("ggid").get("id").as(String.class)));
|
|
|
+ subQueryPredicates.add(cb.equal(ggviewRoot.get("sfkj").as(String.class), "Y"));
|
|
|
+ if (user.getJyrjcxx() != null) {
|
|
|
+ subQueryPredicates.add(cb.equal(ggviewRoot.get("qymc").get("id").as(String.class), user.getJyrjcxx().getId().toString()));
|
|
|
+ }
|
|
|
+ subQueryPredicates.add(cb.notEqual(ggviewRoot.get("recordStatus").as(String.class),BaseEntity.RECORD_STATE_DELETE));
|
|
|
+ subquery.where(subQueryPredicates.toArray(new Predicate[] {}));
|
|
|
+ list.add(cb.or(new Predicate[] { cb.exists(subquery), cb.equal(root.get("byzd3").as(String.class), "Y") }));
|
|
|
+ return cb.and(list.toArray(new Predicate[] {}));
|
|
|
+ }
|
|
|
+ };
|
|
|
+ //-------------------------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
+ Page<GgEntity> pageList = service.findAll(spec, page);
|
|
|
+ if (pageList == null || pageList.getTotalPages() <= pageCount) {
|
|
|
+ return new ArrayList<GgEntity>();
|
|
|
}
|
|
|
- }
|
|
|
- return pageList.getContent();
|
|
|
+ else{
|
|
|
+ return pageList.getContent();
|
|
|
+ }
|
|
|
+ }//end if 是经营人&&非船代
|
|
|
+ else {
|
|
|
+
|
|
|
+ List<PredicateModel> filterList = new ArrayList<PredicateModel>();
|
|
|
+ addNotEmptyModel(filterList, "recordStatus", BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);// 只检索非删除状态记录
|
|
|
+ addNotEmptyModel(filterList, "lkr", lkr, PredicateModel.Operator.LIKE);
|
|
|
+ addNotEmptyModel(filterList, "title", title, PredicateModel.Operator.LIKE);
|
|
|
+ Specification<GgEntity> spec = SpecificationCreater.searchByPredicateModels(filterList);
|
|
|
+ Page<GgEntity> pageList = service.findAll(spec, page);
|
|
|
+ if (pageList == null || pageList.getTotalPages() <= pageCount) {
|
|
|
+ return new ArrayList<GgEntity>();
|
|
|
+ }
|
|
|
+ for (GgEntity gg : pageList) {
|
|
|
+ List<PredicateModel> filterList2 = new ArrayList<PredicateModel>();
|
|
|
+ addNotEmptyModel(filterList2, "entityType.id",Constants.FJSSLX_T_YJPT_GG, Operator.EQ);
|
|
|
+ addNotEmptyModel(filterList2, "recordStatus",BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
|
|
|
+ addNotEmptyModel(filterList2, "entityId", gg.getId(),PredicateModel.Operator.EQ);
|
|
|
+ Specification<AccessoryEntity> accSpec = SpecificationCreater.searchByPredicateModels(filterList2);
|
|
|
+ List<AccessoryEntity> acc = accessoryService.findAll(accSpec);
|
|
|
+ if (acc != null && acc.size() > 0) {
|
|
|
+ gg.setAccessory(acc.get(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pageList.getContent();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 查询公告详细信息
|
|
|
* @param id
|