|
@@ -24,6 +24,7 @@ import net.sf.json.JSONObject;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
@@ -2918,154 +2919,9 @@ public class GkjyrCtl extends BaseWebCtl {
|
|
|
return cb.and(list.toArray(new Predicate[] {}));
|
|
|
}
|
|
|
};
|
|
|
- /*Specification<GkjyrEntity> spec = new Specification<GkjyrEntity>() {
|
|
|
- // 查询条件
|
|
|
- @Override
|
|
|
- public Predicate toPredicate(Root<GkjyrEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
-
|
|
|
- boolean xkzflag = false;
|
|
|
- boolean bwflag = false;
|
|
|
-
|
|
|
- List<Predicate> list = new ArrayList<Predicate>();
|
|
|
- //
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(gkjyr)) {
|
|
|
-
|
|
|
- list.add(cb.like(root.get("gkjyr").as(String.class), "%" + gkjyr + "%"));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(szdid)) {
|
|
|
- list.add(cb.like(root.get("szd").get("id").as(String.class), "%" + szdid + "%"));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(szgkid)) {
|
|
|
- list.add(cb.like(root.get("szgk").get("id").as(String.class), "%" + szgkid + "%"));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(szgqid)) {
|
|
|
- list.add(cb.like(root.get("szgq").get("id").as(String.class), "%" + szgqid + "%"));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(gkjyxkzh)) {
|
|
|
- list.add(cb.like(root.get("gkjyxkzh").as(String.class), "%" + gkjyxkzh + "%"));
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(fddbr)) {
|
|
|
- list.add(cb.like(root.get("fddbr").as(String.class), "%" + fddbr + "%"));
|
|
|
- }
|
|
|
- // 危货附证编号
|
|
|
- if (StringUtils.isNotEmpty(whfzbh)) {
|
|
|
- list.add(cb.like(root.get("gkwxhwzyfzbh").as(String.class), "%" + whfzbh + "%"));
|
|
|
- }
|
|
|
- // 是否危货企业
|
|
|
- if (StringUtils.isNotEmpty(sfcswhzy)) {
|
|
|
- if (!sfcswhzy.equals("all")) {
|
|
|
- list.add(cb.like(root.get("sfwhqy").get("id").as(String.class), "%" + sfcswhzy + "%"));
|
|
|
- }
|
|
|
- }
|
|
|
- // 是否有许可证
|
|
|
- Subquery<XkzxxEntity> subquery1 = query.subquery(XkzxxEntity.class);
|
|
|
- Root<XkzxxEntity> dpRoot1 = subquery1.from(XkzxxEntity.class);
|
|
|
- subquery1.select(dpRoot1);
|
|
|
- List<Predicate> subQueryPredicates1 = new ArrayList<Predicate>();
|
|
|
- if (StringUtils.isNotEmpty(sfcyxkz)) {
|
|
|
- if (!sfcyxkz.equals("all")) {
|
|
|
- if ("201".equals(sfcyxkz)) {
|
|
|
- subQueryPredicates1.add(cb.equal(dpRoot1.get("gkjyr").as(String.class), root.get("id").as(String.class)));
|
|
|
- subQueryPredicates1.add(cb.equal(dpRoot1.get("recordStatus").as(Integer.class), BaseEntity.RECORD_STATE_VALID));
|
|
|
- subQueryPredicates1.add(cb.equal(dpRoot1.get("sfyx").as(Integer.class), BaseEntity.RECORD_STATE_VALID));
|
|
|
- subquery1.where(subQueryPredicates1.toArray(new Predicate[] {}));
|
|
|
- list.add(cb.exists(subquery1));
|
|
|
- } else {
|
|
|
- subQueryPredicates1.add(cb.equal(dpRoot1.get("gkjyr").as(String.class), root.get("id").as(String.class)));
|
|
|
- subQueryPredicates1.add(cb.equal(dpRoot1.get("recordStatus").as(Integer.class), BaseEntity.RECORD_STATE_VALID));
|
|
|
- subQueryPredicates1.add(cb.equal(dpRoot1.get("sfyx").as(Integer.class), BaseEntity.RECORD_STATE_VALID));
|
|
|
- subquery1.where(subQueryPredicates1.toArray(new Predicate[] {}));
|
|
|
- list.add(cb.not(cb.exists(subquery1)));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- Subquery<BwEntity> subquery2 = query.subquery(BwEntity.class);
|
|
|
- Root<BwEntity> dpRoot2 = subquery2.from(BwEntity.class);
|
|
|
- subquery2.select(dpRoot2);
|
|
|
- List<Predicate> subQueryPredicates2 = new ArrayList<Predicate>();
|
|
|
- subQueryPredicates2.add(cb.equal(root.get("id").as(String.class), dpRoot2.get("ssjyr").get("id").as(String.class)));
|
|
|
- // 泊位用途
|
|
|
- if (StringUtils.isNotEmpty(bwyt)) {
|
|
|
- subQueryPredicates2.add(cb.like(dpRoot2.get("bwyt").as(String.class), "%" + bwyt + "%"));
|
|
|
- bwflag = true;
|
|
|
- }
|
|
|
- if (bwflag) {
|
|
|
- subquery2.where(subQueryPredicates2.toArray(new Predicate[] {}));
|
|
|
- list.add(cb.exists(subquery2));
|
|
|
- }
|
|
|
- // // 企业性质
|
|
|
- // if (StringUtils.isNotEmpty(qyxz)) {
|
|
|
- // list.add(cb.like(root.get("qyxz").as(String.class), "%" +
|
|
|
- // qyxz + "%"));
|
|
|
- // }
|
|
|
-
|
|
|
- // 危货附证有效期
|
|
|
- if (fzstartDate != null) {
|
|
|
- list.add(cb.greaterThanOrEqualTo(root.get("fzyxq").as(Date.class), fzstartDate));
|
|
|
- }
|
|
|
- if (fzendDate != null) {
|
|
|
- list.add(cb.lessThanOrEqualTo(root.get("fzyxq").as(Date.class), fzendDate));
|
|
|
- }
|
|
|
- // 子查询
|
|
|
- Subquery<XkzxxEntity> subquery = query.subquery(XkzxxEntity.class);
|
|
|
- Root<XkzxxEntity> dpRoot = subquery.from(XkzxxEntity.class);
|
|
|
- subquery.select(dpRoot);
|
|
|
- List<Predicate> subQueryPredicates = new ArrayList<Predicate>();
|
|
|
- Date now = new Date();
|
|
|
- subQueryPredicates.add(cb.equal(dpRoot.get("gkjyr").as(String.class), root.get("id").as(String.class)));
|
|
|
- subQueryPredicates.add(cb.equal(dpRoot.get("recordStatus").as(Integer.class), BaseEntity.RECORD_STATE_VALID));
|
|
|
- // 许可证有效期
|
|
|
- if (xkzstartDate != null) {
|
|
|
- subQueryPredicates.add(cb.greaterThanOrEqualTo(dpRoot.get("yxqz").as(Date.class), xkzstartDate));
|
|
|
- xkzflag = true;
|
|
|
- }
|
|
|
- if (xkzendDate != null) {
|
|
|
- subQueryPredicates.add(cb.lessThanOrEqualTo(dpRoot.get("yxqz").as(Date.class), xkzendDate));
|
|
|
- xkzflag = true;
|
|
|
- }
|
|
|
- // 许可证是否将到期
|
|
|
- if (StringUtils.isNotEmpty(jyrxkzsfdq)) {
|
|
|
- if ((jyrxkzsfdq).equals("6103")) {
|
|
|
- subQueryPredicates.add(cb.lessThanOrEqualTo(dpRoot.get("yxqz").as(Date.class), now));
|
|
|
- xkzflag = true;
|
|
|
- } else if ((jyrxkzsfdq).equals("6101")) {
|
|
|
- subQueryPredicates.add(cb.greaterThan(dpRoot.get("yxqz").as(Date.class), now));
|
|
|
- xkzflag = true;
|
|
|
- } else {
|
|
|
- subQueryPredicates.add(cb.lessThanOrEqualTo(dpRoot.get("yxqz").as(Date.class), DateTime.addDays(now, 30)));
|
|
|
- }
|
|
|
- }
|
|
|
- if (xkzflag) {
|
|
|
- subquery.where(subQueryPredicates.toArray(new Predicate[] {}));
|
|
|
- list.add(cb.exists(subquery));
|
|
|
- }
|
|
|
-
|
|
|
- // 经营人只能查看自己企业下的数据,非经营人只能查看自己所在地的数据
|
|
|
- if (isJyr()) {
|
|
|
- list.add(cb.like(root.get("id").as(String.class), "%" + getSsjyr().getId() + "%"));
|
|
|
- } else {
|
|
|
- In<String> in = cb.in(root.get("szgq").get("id").as(String.class));
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
- List<String> gqlist = (List<String>) Utils.getSession().getAttribute("gqList");
|
|
|
- if (gqlist != null && gqlist.size() > 0) {
|
|
|
- for (int i = 0; i < gqlist.size(); i++) {
|
|
|
- in.value(gqlist.get(i));
|
|
|
- }
|
|
|
- list.add(in);
|
|
|
- }
|
|
|
- }
|
|
|
- // 状态为0,9,10,11不显示
|
|
|
- list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_COPY));
|
|
|
- list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORD_STATE_DELETE));
|
|
|
- list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_BGFLAG));
|
|
|
- list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_ZXFLAG));
|
|
|
-
|
|
|
- return cb.and(list.toArray(new Predicate[] {}));
|
|
|
- }
|
|
|
- };*/
|
|
|
-
|
|
|
- List<GkjyrEntity> list = query.findAll(spec, GkjyrEntity.class);
|
|
|
+
|
|
|
+ Sort sort = new Sort(Sort.Direction.DESC, new String[]{"updateDateTime","id"});
|
|
|
+ List<GkjyrEntity> list = query.findAll(spec, sort, GkjyrEntity.class);
|
|
|
List<GkjyrVo> voList = entityToVo(list);
|
|
|
|
|
|
response.setContentType("application/binary;charset=iso-8859-1");
|