Преглед изворни кода

增加蛋场称重功能。

zhuoning пре 2 година
родитељ
комит
12b1b1b70a

+ 2 - 0
huimv-farm-produce/src/main/java/com/huimv/produce/HuimvProduceApplication.java

@@ -6,6 +6,7 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Import;
+import org.springframework.scheduling.annotation.EnableScheduling;
 
 /**
  * @Project : huimv.shiwan
@@ -18,6 +19,7 @@ import org.springframework.context.annotation.Import;
 @SpringBootApplication
 @MapperScan("com.huimv.produce.*.mapper")
 @Import(InterceptorConfig.class)
+@EnableScheduling
 public class HuimvProduceApplication {
     public static void main(String[] args) {
         ApplicationContext applicationContext = SpringApplication.run(HuimvProduceApplication.class, args);

+ 32 - 0
huimv-farm-produce/src/main/java/com/huimv/produce/config/RestTemplateConfig.java

@@ -0,0 +1,32 @@
+package com.huimv.produce.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.client.ClientHttpRequestFactory;
+import org.springframework.http.client.SimpleClientHttpRequestFactory;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Configuration
+public class RestTemplateConfig {
+    @Bean
+    public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
+        return new RestTemplate(factory);
+    }
+
+    @Bean
+    public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
+        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
+        factory.setReadTimeout(150000); // ms
+        factory.setConnectTimeout(150000); // ms
+        return factory;
+    }
+
+}

+ 31 - 0
huimv-farm-produce/src/main/java/com/huimv/produce/produce/controller/WeightController.java

@@ -28,6 +28,37 @@ public class WeightController {
     @Autowired
     private DateUtil dateUtil;
 
+//    @RequestMapping(value = "/getEggWeightDetails")
+//    public Result getEggWeightDetails() throws ParseException {
+//        //
+//        return weight.getEggWeightDetails();
+//    }
+
+    // 读取前N天的记录
+    @RequestMapping(value = "/getManyDayWeight")
+    public Result getManyDayWeight(@RequestParam("days") Integer days,
+                                   @RequestParam("poundType") String poundType) throws ParseException {
+        //
+        return weight.getManyDayWeight(days,poundType);
+    }
+
+    //读取蛋场称重明细明细
+    @RequestMapping(value = "/getWeightDetails")
+    public Result getWeightDetails(@RequestParam("poundType") String poundType,
+                                   @RequestParam("carNumber") String carNumber,
+                                   @RequestParam("consigner") String consigner,
+                                   @RequestParam("consignee") String consignee,
+                                   @RequestParam("variety") String variety,
+                                   @RequestParam("startDate") String startDate,
+                                   @RequestParam("endDate") String endDate,
+                                   @RequestParam("pageNo") Integer pageNo,
+                                   @RequestParam("pageSize") Integer pageSize) throws ParseException {
+        DateUtil du = new DateUtil();
+        //
+        return weight.getWeightDetails(poundType, carNumber,consigner,consignee,variety, du.parseDate(startDate),du.parseDate(endDate),pageNo,pageSize);
+    }
+
+
     //指定查询日期期间
     @RequestMapping(value = "/getWeight")
     public Result getDayWeight(@RequestParam(value = "farmId", required = true) Integer farmId, @RequestParam(value = "startDate", required = true) String startDate, @RequestParam(value = "endDate", required = true) String endDate) {

+ 53 - 0
huimv-farm-produce/src/main/java/com/huimv/produce/produce/entity/ProdWeightDayEntity.java

@@ -0,0 +1,53 @@
+package com.huimv.produce.produce.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Date;
+
+@Entity
+@Table(name = "prod_weight_day")
+@Data
+@Accessors(chain = true)
+public class ProdWeightDayEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "add_date")
+    private Date addDate;
+
+    /**
+     * 毛重
+     */
+    @Column(name = "gross_weight")
+    private Float grossWeight;
+
+    /**
+     * 皮重
+     */
+    @Column(name = "tare_weight")
+    private Float tareWeight;
+
+    /**
+     * 净重
+     */
+    @Column(name = "net_weight")
+    private Float netWeight;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    @Column(name = "batch_id")
+    private Integer batchId;
+
+    @Column(name = "pound_type")
+    private String poundType;
+
+}

+ 91 - 0
huimv-farm-produce/src/main/java/com/huimv/produce/produce/entity/ProdWeightDetailsEntity.java

@@ -0,0 +1,91 @@
+package com.huimv.produce.produce.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.sql.Date;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "prod_weight_details")
+@Data
+@Accessors(chain = true)
+public class ProdWeightDetailsEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "add_date")
+    private Timestamp addDate;
+
+    /**
+     * 毛重
+     */
+    @Column(name = "gross_weight")
+    private BigDecimal grossWeight;
+
+    /**
+     * 皮重
+     */
+    @Column(name = "tare_weight")
+    private BigDecimal tareWeight;
+
+    /**
+     * 净重
+     */
+    @Column(name = "net_weight")
+    private BigDecimal netWeight;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    @Column(name = "batch_id")
+    private Integer batchId;
+
+    @Column(name = "pound_type")
+    private String poundType;
+
+    @Column(name = "serial_number")
+    private String serialNumber;
+
+    @Column(name = "car_number")
+    private String carNumber;
+
+    @Column(name = "consigner")
+    private String consigner;
+
+    @Column(name = "consignee")
+    private String consignee;
+
+    @Column(name = "variety")
+    private String variety;
+
+    @Column(name = "specification")
+    private String specification;
+
+    @Column(name = "deduction_weight")
+    private BigDecimal deductionWeight;
+
+    @Column(name = "actual_weight")
+    private BigDecimal actualWeight;
+
+    @Column(name = "price")
+    private BigDecimal price;
+
+    @Column(name = "money")
+    private BigDecimal money;
+
+    @Column(name = "weighing_time")
+    private Date weighingTime;
+
+    @Column(name = "weighing_type")
+    private String weighingType;
+
+}

+ 17 - 0
huimv-farm-produce/src/main/java/com/huimv/produce/produce/repo/ProdWeightDayRepo.java

@@ -0,0 +1,17 @@
+package com.huimv.produce.produce.repo;
+
+import com.huimv.produce.produce.entity.ProdWeightDayEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+public interface ProdWeightDayRepo extends JpaRepository<ProdWeightDayEntity, Integer>, JpaSpecificationExecutor<ProdWeightDayEntity> {
+
+    @Query(nativeQuery = true,value = "SELECT * FROM prod_weight_day WHERE DATE_FORMAT(add_date,'%Y-%m-%d')=DATE_FORMAT(?1,'%Y-%m-%d')")
+    List<ProdWeightDayEntity> getDayWeightList(String todayDate);
+
+    @Query(nativeQuery = true,value = "SELECT * FROM prod_weight_day WHERE pound_type=?2 ORDER BY add_date DESC LIMIT ?1")
+    List<ProdWeightDayEntity> findDayWeight(Integer days, String poundType);
+}

+ 14 - 0
huimv-farm-produce/src/main/java/com/huimv/produce/produce/repo/ProdWeightDetailsRepo.java

@@ -0,0 +1,14 @@
+package com.huimv.produce.produce.repo;
+
+import com.huimv.produce.produce.entity.ProdWeightDetailsEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+public interface ProdWeightDetailsRepo extends JpaRepository<ProdWeightDetailsEntity, Integer>, JpaSpecificationExecutor<ProdWeightDetailsEntity> {
+
+    @Query(nativeQuery = true,value = "SELECT * FROM prod_weight_details WHERE DATE_FORMAT(weighing_time,'%Y-%m-%d')=DATE_FORMAT(?1,'%Y-%m-%d')")
+    List<ProdWeightDetailsEntity> getWeightDetails(String todayDate);
+}

+ 9 - 0
huimv-farm-produce/src/main/java/com/huimv/produce/produce/service/IWeight.java

@@ -8,6 +8,9 @@ import java.text.ParseException;
 import java.util.Date;
 
 public interface IWeight {
+
+    Result getEggWeightDetails() throws ParseException;
+
     //查询称重
     Result getDayWeight(Integer farmId, String startDate, String endDate);
 
@@ -30,4 +33,10 @@ public interface IWeight {
     Result getBatchWeightOnPage3(Integer farmId, Date parseDate, Date parseDate1, Integer pageNo, Integer pageSize);
 
     Result getBatchWeightOnPage4(Integer farmId, String startDate, String endDate, Integer pageNo, Integer pageSize);
+
+    Result getManyDayWeight(Integer days, String poundType);
+
+//    Result getWeightDetails(String poundType, String carNumber, String consigner, String consignee, String variety, String startDate,String endDate, String date);
+
+    Result getWeightDetails(String poundType, String carNumber, String consigner, String consignee, String variety, Date startDate, Date endDate, Integer pageNo, Integer pageSize);
 }

+ 308 - 13
huimv-farm-produce/src/main/java/com/huimv/produce/produce/service/impl/WeightImpl.java

@@ -1,22 +1,31 @@
 package com.huimv.produce.produce.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.huimv.common.utils.Result;
 import com.huimv.common.utils.ResultCode;
+import com.huimv.produce.produce.entity.ProdWeightDayEntity;
+import com.huimv.produce.produce.entity.ProdWeightDetailsEntity;
 import com.huimv.produce.produce.repo.*;
 import com.huimv.produce.produce.service.IWeight;
 import com.huimv.produce.produce.utils.DateUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.domain.*;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
 
+import javax.annotation.Resource;
 import javax.persistence.EntityManager;
 import javax.persistence.PersistenceContext;
 import javax.persistence.Query;
 import javax.persistence.criteria.Order;
 import javax.persistence.criteria.Predicate;
 import java.math.BigDecimal;
+import java.sql.Timestamp;
 import java.text.ParseException;
 import java.util.*;
 
@@ -29,6 +38,7 @@ import java.util.*;
  * @Create : 2020-12-25
  **/
 @Service
+@Slf4j
 public class WeightImpl implements IWeight {
     @Autowired
     private ProdDayWeightRepo dayWeightRepo;
@@ -38,6 +48,211 @@ public class WeightImpl implements IWeight {
     private ProdWeightRepo weightRepo;
     @Autowired
     private DateUtil dateUtil;
+    @Resource
+    private RestTemplate restTemplate;
+    @Autowired
+    private ProdWeightDetailsRepo prodWeightDetailsRepo;
+    @Autowired
+    private ProdWeightDayRepo prodWeightDayRepo;
+    @Value("${weight.http}")
+    private String weightHttp;
+    @Value("${weight.path}")
+    private String weightPath;
+
+    @Override
+    public Result getEggWeightDetails() throws ParseException {
+//        String url = "http://39.171.45.196:9200/egg/getWeightDetails?date=2022-06-10";
+//        String url = "http://39.171.45.196:9200/egg/getWeightDetails";
+        // 获取全部数据;
+//        String url = initUrl();
+        // 获取今天数据
+//        String todayDate = new DateUtil().getTodayDateText();
+        // test
+        String todayDate = "2022-06-10";
+        String url = weightHttp + weightPath;
+        url += "?date=" + todayDate;
+//        url += "?date=2022-06-10";
+//        System.out.println("url=" + url);
+        String result = restTemplate.getForObject(url, String.class);
+        JSONArray resultJa = JSONArray.parseArray(result);
+        log.info("接口返回数量=" + resultJa.size());
+
+        // 保存每天明细
+        saveWeightDetails(resultJa, todayDate);
+
+        // 保存汇总每天总重
+        saveDayWeight(resultJa, todayDate);
+
+        return new Result(ResultCode.SUCCESS);
+    }
+
+    /**
+     * @Method : saveDayWeight
+     * @Description :
+     * @Params : [resultJa, todayDate]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/7/2
+     * @Time : 4:08
+     */
+    private void saveDayWeight(JSONArray resultJa, String todayDate) throws ParseException {
+        JSONArray purchaseJa = new JSONArray();
+        JSONArray salesJa = new JSONArray();
+        JSONArray otherJa = new JSONArray();
+        for (int a = 0; a < resultJa.size(); a++) {
+            JSONObject resultJo = resultJa.getJSONObject(a);
+            if (resultJo.getString("poundType").equalsIgnoreCase("Purchase")) {
+                purchaseJa.add(resultJo);
+            } else if (resultJo.getString("poundType").equalsIgnoreCase("Sales")) {
+                salesJa.add(resultJo);
+            } else {
+                otherJa.add(resultJo);
+            }
+        }
+        //
+        List<ProdWeightDayEntity> ProdWeightDayEntityList = getDayWeightList(todayDate);
+        prodWeightDayRepo.deleteAll(ProdWeightDayEntityList);
+
+        BigDecimal grossTotalPurchaseBg = new BigDecimal("0");
+        BigDecimal tareTotalPurchaseBg = new BigDecimal("0");
+        BigDecimal netTotalPurchaseBg = new BigDecimal("0");
+        for (int a = 0; a < purchaseJa.size(); a++) {
+            JSONObject purchaseJo = purchaseJa.getJSONObject(a);
+//            System.out.println("" + purchaseJo.getBigDecimal("grossWeight") + " " + purchaseJo.getBigDecimal("tareWeight") + " " + purchaseJo.getBigDecimal("netWeight"));
+            BigDecimal gw = purchaseJo.getBigDecimal("grossWeight");
+            if (gw == null) {
+                gw = new BigDecimal("0");
+            }
+            grossTotalPurchaseBg = grossTotalPurchaseBg.add(gw);
+            BigDecimal tw = purchaseJo.getBigDecimal("tareWeight");
+            if (tw == null) {
+                tw = new BigDecimal("0");
+            }
+            tareTotalPurchaseBg = tareTotalPurchaseBg.add(tw);
+            BigDecimal nw = purchaseJo.getBigDecimal("netWeight");
+            if (nw == null) {
+                nw = new BigDecimal("0");
+            }
+            netTotalPurchaseBg = netTotalPurchaseBg.add(nw);
+        }
+//        System.out.println("grossTotalPurchaseBg=" + grossTotalPurchaseBg.toString());
+//        System.out.println("tareTotalPurchaseBg=" + tareTotalPurchaseBg.toString());
+//        System.out.println("netTotalPurchaseBg=" + netTotalPurchaseBg.toString());
+
+        ProdWeightDayEntity purchaseWeightDayEntity = new ProdWeightDayEntity();
+        purchaseWeightDayEntity.setAddDate(new java.sql.Date(dateUtil.parseDate(todayDate).getTime()));
+        purchaseWeightDayEntity.setGrossWeight(grossTotalPurchaseBg.floatValue());
+        purchaseWeightDayEntity.setTareWeight(tareTotalPurchaseBg.floatValue());
+        purchaseWeightDayEntity.setNetWeight(netTotalPurchaseBg.floatValue());
+        purchaseWeightDayEntity.setPoundType("Purchase");
+        prodWeightDayRepo.save(purchaseWeightDayEntity);
+
+        BigDecimal grossTotalSalesBg = new BigDecimal("0");
+        BigDecimal tareTotalSalesBg = new BigDecimal("0");
+        BigDecimal netTotalSalesBg = new BigDecimal("0");
+        for (int a = 0; a < salesJa.size(); a++) {
+            JSONObject salesJo = salesJa.getJSONObject(a);
+//            System.out.println("" + salesJo.getBigDecimal("grossWeight") + " " + salesJo.getBigDecimal("tareWeight") + " " + salesJo.getBigDecimal("netWeight"));
+            BigDecimal gw = salesJo.getBigDecimal("grossWeight");
+            if (gw == null) {
+                gw = new BigDecimal("0");
+            }
+            grossTotalSalesBg = grossTotalSalesBg.add(gw);
+            BigDecimal tw = salesJo.getBigDecimal("tareWeight");
+            if (tw == null) {
+                tw = new BigDecimal("0");
+            }
+            tareTotalSalesBg = tareTotalSalesBg.add(tw);
+            BigDecimal nw = salesJo.getBigDecimal("netWeight");
+            if (nw == null) {
+                nw = new BigDecimal("0");
+            }
+            netTotalSalesBg = netTotalSalesBg.add(nw);
+        }
+//        System.out.println("grossTotalSalesBg=" + grossTotalSalesBg.toString());
+//        System.out.println("tareTotalSalesBg=" + tareTotalSalesBg.toString());
+//        System.out.println("netTotalSalesBg=" + netTotalSalesBg.toString());
+
+        ProdWeightDayEntity salesWeightDayEntity = new ProdWeightDayEntity();
+        salesWeightDayEntity.setAddDate(new java.sql.Date(dateUtil.parseDate(todayDate).getTime()));
+        salesWeightDayEntity.setGrossWeight(grossTotalSalesBg.floatValue());
+        salesWeightDayEntity.setTareWeight(tareTotalSalesBg.floatValue());
+        salesWeightDayEntity.setNetWeight(netTotalSalesBg.floatValue());
+        salesWeightDayEntity.setPoundType("Sales");
+        prodWeightDayRepo.save(salesWeightDayEntity);
+    }
+
+    //
+    private List<ProdWeightDayEntity> getDayWeightList(String todayDate) {
+        return prodWeightDayRepo.getDayWeightList(todayDate);
+    }
+
+    /**
+     * @Method : saveWeightDetails
+     * @Description :
+     * @Params : [resultJa, todayDate]
+     * @Return : void
+     * @Author : ZhuoNing
+     * @Date : 2022/7/2
+     * @Time : 4:03
+     */
+    private void saveWeightDetails(JSONArray resultJa, String todayDate) throws ParseException {
+        // 读取每天的一个称重数据
+        List<ProdWeightDetailsEntity> existEntityList = getTodayWeightDetails(todayDate);
+        System.out.println("今天已经取回数量=" + existEntityList.size());
+        JSONArray dataJa = new JSONArray();
+        for (int a = 0; a < resultJa.size(); a++) {
+            JSONObject resultJo = resultJa.getJSONObject(a);
+            boolean isExist = false;
+            for (ProdWeightDetailsEntity weightDetailsEntity : existEntityList) {
+                if (weightDetailsEntity.getSerialNumber().equalsIgnoreCase(resultJo.getString("serialNumber"))) {
+                    isExist = true;
+                    break;
+                }
+            }
+            if (!isExist) {
+                dataJa.add(resultJo);
+            }
+        }
+        System.out.println("dataJa.size=" + dataJa.size());
+        for (int a = 0; a < dataJa.size(); a++) {
+            System.out.println("" + (a + 1));
+            JSONObject dataJo = dataJa.getJSONObject(a);
+            ProdWeightDetailsEntity prodWeightDetailsEntity = new ProdWeightDetailsEntity();
+            prodWeightDetailsEntity.setSerialNumber(dataJo.getString("serialNumber"));
+            prodWeightDetailsEntity.setCarNumber(dataJo.getString("carNumber"));
+            prodWeightDetailsEntity.setPoundType(dataJo.getString("poundType"));
+            prodWeightDetailsEntity.setConsigner(dataJo.getString("consigner"));
+            prodWeightDetailsEntity.setConsignee(dataJo.getString("consignee"));
+            prodWeightDetailsEntity.setVariety(dataJo.getString("variety"));
+            prodWeightDetailsEntity.setSpecification(dataJo.getString("specification"));
+            prodWeightDetailsEntity.setGrossWeight(dataJo.getBigDecimal("grossWeight"));
+            prodWeightDetailsEntity.setTareWeight(dataJo.getBigDecimal("tareWeight"));
+            prodWeightDetailsEntity.setNetWeight(dataJo.getBigDecimal("netWeight"));
+            prodWeightDetailsEntity.setDeductionWeight(dataJo.getBigDecimal("deductionWeight"));
+            prodWeightDetailsEntity.setActualWeight(dataJo.getBigDecimal("actualWeight"));
+            prodWeightDetailsEntity.setPrice(dataJo.getBigDecimal("price"));
+            prodWeightDetailsEntity.setMoney(dataJo.getBigDecimal("money"));
+            prodWeightDetailsEntity.setWeighingTime(new java.sql.Date(new DateUtil().parseDateTime(dataJo.getString("weighingTime")).getTime()));
+            prodWeightDetailsEntity.setWeighingType(dataJo.getString("weighingType"));
+            prodWeightDetailsEntity.setAddDate(new Timestamp(new Date().getTime()));
+            prodWeightDetailsRepo.save(prodWeightDetailsEntity);
+        }
+    }
+
+    //
+    private List<ProdWeightDetailsEntity> getTodayWeightDetails(String todayDate) {
+        List<ProdWeightDetailsEntity> list = prodWeightDetailsRepo.getWeightDetails(todayDate);
+        return list;
+    }
+
+    private String todayUrl() throws ParseException {
+        return weightHttp + weightPath + "?date=" + new DateUtil().getTodayDateText();
+    }
+
+    public String initUrl() {
+        return weightHttp + weightPath;
+    }
 
     /**
      * @Method : getDayWeight
@@ -226,14 +441,13 @@ public class WeightImpl implements IWeight {
     }
 
     /**
-     * @Method      : getEveryTimeWeightOnPage
-     * @Description : 
-     * @Params      : [farmId, startDate, endDate, pageNo, pageSize]
-     * @Return      : com.huimv.common.utils.Result
-     * 
-     * @Author      : ZhuoNing
-     * @Date        : 2021/12/22       
-     * @Time        : 19:41
+     * @Method : getEveryTimeWeightOnPage
+     * @Description :
+     * @Params : [farmId, startDate, endDate, pageNo, pageSize]
+     * @Return : com.huimv.common.utils.Result
+     * @Author : ZhuoNing
+     * @Date : 2021/12/22
+     * @Time : 19:41
      */
     @Override
     public Result getEveryTimeWeightOnPage(Integer farmId, Date startDate, Date endDate, Integer pageNo, Integer pageSize) throws ParseException {
@@ -261,12 +475,12 @@ public class WeightImpl implements IWeight {
             params.put("farmId", farmId);
         }
         //startDate
-        if(startDate != null){
+        if (startDate != null) {
             whereSql.append(" and addTime>=:startDate ");
             params.put("startDate", startDate);
         }
         //endDate
-        if(endDate != null){
+        if (endDate != null) {
             whereSql.append(" and addTime<=:endDate ");
             params.put("endDate", endDate);
         }
@@ -313,12 +527,12 @@ public class WeightImpl implements IWeight {
             params.put("farmId", farmId);
         }
         //startDate
-        if(startDate != null){
+        if (startDate != null) {
             whereSql.append(" AND date_format(add_time,'%Y-%m-%d')>= :startDate ");
             params.put("startDate", startDate);
         }
         //endDate
-        if(endDate != null){
+        if (endDate != null) {
             whereSql.append(" AND date_format(add_time,'%Y-%m-%d')<= :endDate");
             params.put("endDate", endDate);
         }
@@ -330,7 +544,7 @@ public class WeightImpl implements IWeight {
 //        Long count = (Long) countQuery.getSingleResult();
         int size = countQuery.getResultList().size();
 //        System.out.println("count>>"+count);
-        System.out.println("size>>"+size);
+        System.out.println("size>>" + size);
 
         String querySql = new StringBuilder().append(selectSql).append(whereSql).toString();
         Query query = this.entityManager.createNativeQuery(querySql);
@@ -344,4 +558,85 @@ public class WeightImpl implements IWeight {
 
         return new Result(ResultCode.SUCCESS, batchWeightList);
     }
+
+    /**
+     * @Method      : getManyDayWeight
+     * @Description : 
+     * @Params      : [days, poundType]
+     * @Return      : com.huimv.common.utils.Result
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/7/2       
+     * @Time        : 5:57
+     */
+    @Override
+    public Result getManyDayWeight(Integer days, String poundType) {
+        if(StringUtils.isBlank(poundType)){
+            poundType = "Sales";
+        }
+        //
+        List<ProdWeightDayEntity> dayWeightList = prodWeightDayRepo.findDayWeight(days,poundType);
+        List newList = new ArrayList();
+        for(int a=dayWeightList.size()-1 ; a >= 0 ; a--){
+            newList.add(dayWeightList.get(a));
+        }
+        return new Result(ResultCode.SUCCESS,newList);
+    }
+
+    /**
+     * @Method      : getWeightDetails
+     * @Description : 
+     * @Params      : [poundType, carNumber, consigner, consignee, variety, startDate, endDate, pageNo, pageSize]
+     * @Return      : com.huimv.common.utils.Result
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2022/7/2       
+     * @Time        : 6:03
+     */
+    @Override
+    public Result getWeightDetails(String poundType, String carNumber, String consigner, String consignee, String variety, Date startDate,Date endDate,Integer pageNo,Integer pageSize) {
+//        .
+        Specification<ProdWeightDetailsEntity> sf = (Specification<ProdWeightDetailsEntity>) (root, criteriaQuery, criteriaBuilder) -> {
+            //
+            List<Predicate> predList = new ArrayList<>();
+            if (null != poundType) {
+                predList.add(criteriaBuilder.equal(root.get("poundType").as(String.class), poundType));
+            }
+            if (null != carNumber) {
+                predList.add(criteriaBuilder.like(root.get("poundType").as(String.class), carNumber));
+            }
+            if (null != consigner) {
+                predList.add(criteriaBuilder.like(root.get("consigner").as(String.class), consigner));
+            }
+            if (null != consignee) {
+                predList.add(criteriaBuilder.like(root.get("consignee").as(String.class), consignee));
+            }
+            if (null != variety) {
+                predList.add(criteriaBuilder.like(root.get("variety").as(String.class), variety));
+            }
+            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 != deliverState) {
+//                predList.add(criteriaBuilder.equal(root.get("deliverState").as(Integer.class), deliverState));
+//            }
+            //
+            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,applyRepo.listApply(pageable,applyId));
+        return new Result(ResultCode.SUCCESS, prodWeightDetailsRepo.findAll(sf, pageable));
+    }
 }

+ 28 - 0
huimv-farm-produce/src/main/java/com/huimv/produce/task/MyScheduledTask.java

@@ -0,0 +1,28 @@
+package com.huimv.produce.task;
+
+import com.huimv.produce.produce.service.IWeight;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.text.ParseException;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Component
+public class MyScheduledTask {
+    @Autowired
+    private IWeight iWeight;
+
+//    @Scheduled(cron = "0 0/30 * * * ?")
+    @Scheduled(cron = "0/10 * * * * ?")
+    public void scheduledTask1() throws ParseException {
+        iWeight.getEggWeightDetails();
+    }
+}

+ 4 - 2
huimv-farm-produce/src/main/resources/application.properties

@@ -1,5 +1,7 @@
-#spring.profiles.active=dev
+spring.profiles.active=dev
 #spring.profiles.active=demo
-spring.profiles.active=prod
+#spring.profiles.active=prod
 #spring.profiles.active=prod2
 
+weight.http=http://39.171.45.196:9200
+weight.path=/egg/getWeightDetails