|
@@ -2,6 +2,7 @@ package com.huimv.manage.eartag.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.huimv.manage.dao.entity.EtApplyEntity;
|
|
import com.huimv.manage.dao.entity.EtEarmarkEntity;
|
|
import com.huimv.manage.dao.entity.EtEarmarkEntity;
|
|
import com.huimv.manage.dao.repo.EarmarkRepo;
|
|
import com.huimv.manage.dao.repo.EarmarkRepo;
|
|
import com.huimv.manage.eartag.service.IEarmarkService;
|
|
import com.huimv.manage.eartag.service.IEarmarkService;
|
|
@@ -15,11 +16,17 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.data.domain.Example;
|
|
import org.springframework.data.domain.Example;
|
|
import org.springframework.data.domain.ExampleMatcher;
|
|
import org.springframework.data.domain.ExampleMatcher;
|
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.persistence.criteria.Order;
|
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
@@ -62,6 +69,52 @@ public class EarmarkServiceImpl implements IEarmarkService {
|
|
return new Result(ResultCode.SUCCESS,earmarkEntityList);
|
|
return new Result(ResultCode.SUCCESS,earmarkEntityList);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Result listEarmark(Integer applyId, Integer packageId, Integer earMarkId, Integer earMarkNumber, Integer returnState, Integer writeState, Integer printState, Date startDate, Date endDate, Integer pageSize, Integer pageNo) {
|
|
|
|
+ Specification<EtEarmarkEntity> sf = (Specification<EtEarmarkEntity>) (root, criteriaQuery, criteriaBuilder) -> {
|
|
|
|
+ //
|
|
|
|
+ List<Predicate> predList = new ArrayList<>();
|
|
|
|
+ if (null != applyId) {
|
|
|
|
+ predList.add(criteriaBuilder.equal(root.get("applyId").as(Integer.class), applyId));
|
|
|
|
+ }
|
|
|
|
+ if (null != packageId) {
|
|
|
|
+ predList.add(criteriaBuilder.equal(root.get("packageId").as(Integer.class), packageId));
|
|
|
|
+ }
|
|
|
|
+ if (null != earMarkId) {
|
|
|
|
+ predList.add(criteriaBuilder.equal(root.get("earMarkId").as(Integer.class), earMarkId));
|
|
|
|
+ }
|
|
|
|
+ if (null != earMarkNumber) {
|
|
|
|
+ predList.add(criteriaBuilder.equal(root.get("earMarkNumber").as(Integer.class), earMarkNumber));
|
|
|
|
+ }
|
|
|
|
+ if (null != startDate) {
|
|
|
|
+ predList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("startDate").as(Date.class), startDate));
|
|
|
|
+ }
|
|
|
|
+ if (null != endDate) {
|
|
|
|
+ predList.add(criteriaBuilder.lessThanOrEqualTo(root.get("endDate").as(Date.class), endDate));
|
|
|
|
+ }
|
|
|
|
+ if (null != returnState) {
|
|
|
|
+ predList.add(criteriaBuilder.equal(root.get("returnState").as(Integer.class), returnState));
|
|
|
|
+ }
|
|
|
|
+ if (null != writeState) {
|
|
|
|
+ predList.add(criteriaBuilder.equal(root.get("writeState").as(Integer.class), writeState));
|
|
|
|
+ }
|
|
|
|
+ if (null != printState) {
|
|
|
|
+ predList.add(criteriaBuilder.equal(root.get("printState").as(Integer.class), printState));
|
|
|
|
+ }
|
|
|
|
+ //
|
|
|
|
+ Predicate[] pred = new Predicate[predList.size()];
|
|
|
|
+ Predicate and = criteriaBuilder.and(predList.toArray(pred));
|
|
|
|
+ criteriaQuery.where(and);
|
|
|
|
+ //
|
|
|
|
+ List<Order> orders = new ArrayList<>();
|
|
|
|
+ orders.add(criteriaBuilder.desc(root.get("id")));
|
|
|
|
+ return criteriaQuery.orderBy(orders).getRestriction();
|
|
|
|
+ };
|
|
|
|
+ //分页
|
|
|
|
+ Pageable pageable = PageRequest.of( pageNo - 1, pageSize);
|
|
|
|
+ return new Result(ResultCode.SUCCESS, earmarkRepo.findAll(sf, pageable));
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @Method : getEarmark
|
|
* @Method : getEarmark
|
|
* @Description : 下载耳标号
|
|
* @Description : 下载耳标号
|