Kaynağa Gözat

新建每次称重数据。

zhuoning 3 yıl önce
ebeveyn
işleme
e4666c1ab2

+ 6 - 0
huimv-farm-receiver/pom.xml

@@ -45,6 +45,12 @@
             <version>5.7.16</version>
             <scope>compile</scope>
         </dependency>
+        <!--ICC-->
+        <dependency>
+            <groupId>com.dahuatech.icc</groupId>
+            <artifactId>java-sdk-oauth</artifactId>
+            <version>1.0.8</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 131 - 0
huimv-farm-receiver/src/main/java/com/huimv/produce/warning/dao/entity/ProdWeightEntity.java

@@ -0,0 +1,131 @@
+package com.huimv.produce.warning.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "prod_weight")
+public class ProdWeightEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "add_time")
+    private Timestamp addTime;
+
+    /**
+     * 毛重
+     */
+    @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;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setAddTime(Timestamp addTime) {
+        this.addTime = addTime;
+    }
+
+    public Timestamp getAddTime() {
+        return addTime;
+    }
+
+    /**
+     * 毛重
+     */
+    public void setGrossWeight(Float grossWeight) {
+        this.grossWeight = grossWeight;
+    }
+
+    /**
+     * 毛重
+     */
+    public Float getGrossWeight() {
+        return grossWeight;
+    }
+
+    /**
+     * 皮重
+     */
+    public void setTareWeight(Float tareWeight) {
+        this.tareWeight = tareWeight;
+    }
+
+    /**
+     * 皮重
+     */
+    public Float getTareWeight() {
+        return tareWeight;
+    }
+
+    /**
+     * 净重
+     */
+    public void setNetWeight(Float netWeight) {
+        this.netWeight = netWeight;
+    }
+
+    /**
+     * 净重
+     */
+    public Float getNetWeight() {
+        return netWeight;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    public void setBatchId(Integer batchId) {
+        this.batchId = batchId;
+    }
+
+    public Integer getBatchId() {
+        return batchId;
+    }
+
+    @Override
+    public String toString() {
+        return "ProdWeightEntity{" +
+                "id=" + id + '\'' +
+                "addTime=" + addTime + '\'' +
+                "grossWeight=" + grossWeight + '\'' +
+                "tareWeight=" + tareWeight + '\'' +
+                "netWeight=" + netWeight + '\'' +
+                "farmId=" + farmId + '\'' +
+                "batchId=" + batchId + '\'' +
+                '}';
+    }
+}

+ 9 - 0
huimv-farm-receiver/src/main/java/com/huimv/produce/warning/dao/repo/ProdWeightRepo.java

@@ -0,0 +1,9 @@
+package com.huimv.produce.warning.dao.repo;
+
+import com.huimv.produce.warning.dao.entity.ProdWeightEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface ProdWeightRepo extends JpaRepository<ProdWeightEntity, Integer>, JpaSpecificationExecutor<ProdWeightEntity> {
+
+}

+ 8 - 0
huimv-farm-receiver/src/main/java/com/huimv/receiver/farm/controller/WeightController.java

@@ -37,4 +37,12 @@ public class WeightController {
         weight.saveBatchWeight(data);
     }
 
+    //保存每次称重
+    @RequestMapping(value = "/putEveryTimeWeight",method = RequestMethod.POST)
+    public void putEveryTimeWeight(@RequestParam(value = "data",required = true) String data){
+        log.info("接收每次称重>>"+data);
+        //
+        weight.saveEveryTimeWeight(data);
+    }
+
 }

+ 131 - 0
huimv-farm-receiver/src/main/java/com/huimv/receiver/farm/dao/entity/ProdWeightEntity.java

@@ -0,0 +1,131 @@
+package com.huimv.receiver.farm.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "prod_weight")
+public class ProdWeightEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "add_time")
+    private Timestamp addTime;
+
+    /**
+     * 毛重
+     */
+    @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;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setAddTime(Timestamp addTime) {
+        this.addTime = addTime;
+    }
+
+    public Timestamp getAddTime() {
+        return addTime;
+    }
+
+    /**
+     * 毛重
+     */
+    public void setGrossWeight(Float grossWeight) {
+        this.grossWeight = grossWeight;
+    }
+
+    /**
+     * 毛重
+     */
+    public Float getGrossWeight() {
+        return grossWeight;
+    }
+
+    /**
+     * 皮重
+     */
+    public void setTareWeight(Float tareWeight) {
+        this.tareWeight = tareWeight;
+    }
+
+    /**
+     * 皮重
+     */
+    public Float getTareWeight() {
+        return tareWeight;
+    }
+
+    /**
+     * 净重
+     */
+    public void setNetWeight(Float netWeight) {
+        this.netWeight = netWeight;
+    }
+
+    /**
+     * 净重
+     */
+    public Float getNetWeight() {
+        return netWeight;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    public void setBatchId(Integer batchId) {
+        this.batchId = batchId;
+    }
+
+    public Integer getBatchId() {
+        return batchId;
+    }
+
+    @Override
+    public String toString() {
+        return "ProdWeightEntity{" +
+                "id=" + id + '\'' +
+                "addTime=" + addTime + '\'' +
+                "grossWeight=" + grossWeight + '\'' +
+                "tareWeight=" + tareWeight + '\'' +
+                "netWeight=" + netWeight + '\'' +
+                "farmId=" + farmId + '\'' +
+                "batchId=" + batchId + '\'' +
+                '}';
+    }
+}

+ 9 - 0
huimv-farm-receiver/src/main/java/com/huimv/receiver/farm/dao/repo/ProdWeightRepo.java

@@ -0,0 +1,9 @@
+package com.huimv.receiver.farm.dao.repo;
+
+import com.huimv.receiver.farm.dao.entity.ProdWeightEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface ProdWeightRepo extends JpaRepository<ProdWeightEntity, Integer>, JpaSpecificationExecutor<ProdWeightEntity> {
+
+}

+ 5 - 2
huimv-farm-receiver/src/main/java/com/huimv/receiver/farm/service/IWeight.java

@@ -1,9 +1,12 @@
 package com.huimv.receiver.farm.service;
 
 public interface IWeight {
-    //
+    //保存每天称重
     void saveDayWeight(String data);
 
-    //
+    //保存批次称重
     void saveBatchWeight(String data);
+
+    //保存每次称重
+    void saveEveryTimeWeight(String data);
 }

+ 13 - 0
huimv-farm-receiver/src/main/java/com/huimv/receiver/farm/service/impl/WeightImpl.java

@@ -1,10 +1,13 @@
 package com.huimv.receiver.farm.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.huimv.receiver.farm.dao.entity.ProdBatchWeightEntity;
 import com.huimv.receiver.farm.dao.entity.ProdDayWeightEntity;
+import com.huimv.receiver.farm.dao.entity.ProdWeightEntity;
 import com.huimv.receiver.farm.dao.repo.ProdBatchWeightRepo;
 import com.huimv.receiver.farm.dao.repo.ProdDayWeightRepo;
+import com.huimv.receiver.farm.dao.repo.ProdWeightRepo;
 import com.huimv.receiver.farm.service.IWeight;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +32,8 @@ public class WeightImpl implements IWeight {
     private ProdDayWeightRepo dayWeightRepo;
     @Autowired
     private ProdBatchWeightRepo batchWeightRepo;
+    @Autowired
+    private ProdWeightRepo prodWeightRepo;
 
     /**
      * @Method      : saveDayWeight
@@ -108,4 +113,12 @@ public class WeightImpl implements IWeight {
             log.info("编辑批次称重数据>>"+existBatchWeightEntity);
         }
     }
+
+    @Override
+    public void saveEveryTimeWeight(String data) {
+        JSONObject everyTimeWeightJo = JSONObject.parseObject(data);
+        ProdWeightEntity newWeightEntity = JSON.toJavaObject(everyTimeWeightJo,ProdWeightEntity.class);
+        ProdWeightEntity addWeightEntity = prodWeightRepo.saveAndFlush(newWeightEntity);
+        log.info("保存每次称重>>"+addWeightEntity);
+    }
 }

+ 13 - 0
huimv-farm-receiver/src/main/resources/config/iccSdk.properties

@@ -0,0 +1,13 @@
+# host
+icc.sdk.host=36.26.62.70:447
+# 客户端模式
+icc.sdk.clientId=huimv
+icc.sdk.clientSecret=1653d6c9-c611-4827-ac87-0bfd48deadd4
+# 1653d6c9-c611-4827-ac87-0bfd48deadd4
+# 密码校验模式
+icc.sdk.pwdClientId=huimv
+icc.sdk.pwdClientSecret=1653d6c9-c611-4827-ac87-0bfd48deadd4
+icc.sdk.username=system
+icc.sdk.password=admin123.
+# 使用授权类型password,client_credentials
+icc.sdk.grantType=password