Browse Source

美维大屏修改4

wwh 1 year ago
parent
commit
40c45e6749

+ 37 - 37
huimv-eartag2-platform/huimv-eartag2-api/pom.xml

@@ -122,43 +122,43 @@
 
 
 
 
             <!--  代码混淆proguard maven插件  -->
             <!--  代码混淆proguard maven插件  -->
-            <plugin>
-                <groupId>com.github.wvengen</groupId>
-                <artifactId>proguard-maven-plugin</artifactId>
-                <version>2.6.0</version>
-                <executions>
-                    <!--   package时执行proguard   -->
-                    <execution>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>proguard</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <configuration>
-                    <putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>
-                    <!--  输入的jar包  -->
-                    <injar>${project.build.finalName}.jar</injar>
-                    <!--  输出的jar包  -->
-                    <outjar>${project.build.finalName}.jar</outjar>
-                    <!--  是否进行混淆,默认为true  -->
-                    <obfuscate>true</obfuscate>
-                    <!--  配置文件,通常为proguard.cfg,主要对options选项进行配置,所有的options选项都可以进行配置  -->
-                    <proguardInclude>../huimv-eartag2-eartag/proguard.cfg</proguardInclude>
-                    <!--  额外的jar,项目编译所需的jar  -->
-                    <libs>
-                        <lib>${java.home}/lib/rt.jar</lib>
-                        <!--<lib>${java.home}/lib/jce.jar</lib>-->
-                        <lib>${java.home}/lib/jsse.jar</lib>
-                    </libs>
-                    <!--  对输入jar进行过滤,如对META-INFO文件不处理  -->
-                    <inLibsFilter>!META-INF/**,!META-INF/versions/**</inLibsFilter>
-                    <!--  输出路径配置,必须包含injar标签中填写的jar  -->
-                    <outputDirectory>${project.build.directory}</outputDirectory>
-                    <!--  上面使用了conf配置文件,options无需配置  -->
-                    <!--<options></options>-->
-                </configuration>
-            </plugin>
+<!--            <plugin>-->
+<!--                <groupId>com.github.wvengen</groupId>-->
+<!--                <artifactId>proguard-maven-plugin</artifactId>-->
+<!--                <version>2.6.0</version>-->
+<!--                <executions>-->
+<!--                    &lt;!&ndash;   package时执行proguard   &ndash;&gt;-->
+<!--                    <execution>-->
+<!--                        <phase>package</phase>-->
+<!--                        <goals>-->
+<!--                            <goal>proguard</goal>-->
+<!--                        </goals>-->
+<!--                    </execution>-->
+<!--                </executions>-->
+<!--                <configuration>-->
+<!--                    <putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>-->
+<!--                    &lt;!&ndash;  输入的jar包  &ndash;&gt;-->
+<!--                    <injar>${project.build.finalName}.jar</injar>-->
+<!--                    &lt;!&ndash;  输出的jar包  &ndash;&gt;-->
+<!--                    <outjar>${project.build.finalName}.jar</outjar>-->
+<!--                    &lt;!&ndash;  是否进行混淆,默认为true  &ndash;&gt;-->
+<!--                    <obfuscate>true</obfuscate>-->
+<!--                    &lt;!&ndash;  配置文件,通常为proguard.cfg,主要对options选项进行配置,所有的options选项都可以进行配置  &ndash;&gt;-->
+<!--                    <proguardInclude>../huimv-eartag2-eartag/proguard.cfg</proguardInclude>-->
+<!--                    &lt;!&ndash;  额外的jar,项目编译所需的jar  &ndash;&gt;-->
+<!--                    <libs>-->
+<!--                        <lib>${java.home}/lib/rt.jar</lib>-->
+<!--                        &lt;!&ndash;<lib>${java.home}/lib/jce.jar</lib>&ndash;&gt;-->
+<!--                        <lib>${java.home}/lib/jsse.jar</lib>-->
+<!--                    </libs>-->
+<!--                    &lt;!&ndash;  对输入jar进行过滤,如对META-INFO文件不处理  &ndash;&gt;-->
+<!--                    <inLibsFilter>!META-INF/**,!META-INF/versions/**</inLibsFilter>-->
+<!--                    &lt;!&ndash;  输出路径配置,必须包含injar标签中填写的jar  &ndash;&gt;-->
+<!--                    <outputDirectory>${project.build.directory}</outputDirectory>-->
+<!--                    &lt;!&ndash;  上面使用了conf配置文件,options无需配置  &ndash;&gt;-->
+<!--                    &lt;!&ndash;<options></options>&ndash;&gt;-->
+<!--                </configuration>-->
+<!--            </plugin>-->
         </plugins>
         </plugins>
         <resources>
         <resources>
             <resource>
             <resource>

+ 36 - 36
huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/HuimvApiApplication.java

@@ -1,37 +1,37 @@
-//package com.huimv.eartag2.api;
-//
-////import com.huimv.eartag2.api.netty.EartagServer;
-//import org.mybatis.spring.annotation.MapperScan;
-//import org.springframework.boot.SpringApplication;
-//import org.springframework.boot.autoconfigure.SpringBootApplication;
-//import org.springframework.boot.autoconfigure.domain.EntityScan;
-//import org.springframework.context.ApplicationContext;
-//import org.springframework.context.annotation.Bean;
-//import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
-//import org.springframework.scheduling.annotation.EnableScheduling;
-//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
-// **/
-//@SpringBootApplication
-//@EnableScheduling
-//@MapperScan("com.huimv.eartag2.api.mapper")
-//@EntityScan(value = "com.huimv.eartag2.common.dao.entity")
-//@EnableJpaRepositories(basePackages = "com.huimv.eartag2.common.dao.repo")
-////@Import(InterceptorConfig.class)
-//public class HuimvApiApplication {
-//    public static void main(String[] args) throws InterruptedException {
-//        ApplicationContext applicationContext =SpringApplication.run(HuimvApiApplication.class, args);
+package com.huimv.eartag2.api;
+
+//import com.huimv.eartag2.api.netty.EartagServer;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.scheduling.annotation.EnableScheduling;
+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
+ **/
+@SpringBootApplication
+@EnableScheduling
+@MapperScan("com.huimv.eartag2.api.mapper")
+@EntityScan(value = "com.huimv.eartag2.common.dao.entity")
+@EnableJpaRepositories(basePackages = "com.huimv.eartag2.common.dao.repo")
+//@Import(InterceptorConfig.class)
+public class HuimvApiApplication {
+    public static void main(String[] args) throws InterruptedException {
+        SpringApplication.run(HuimvApiApplication.class, args);
 //        applicationContext.getBean(EartagServer.class).run();
 //        applicationContext.getBean(EartagServer.class).run();
-//    }
-//    @Bean
-//    public static RestTemplate getRestTemplate(){
-//        return new RestTemplate();
-//    }
-//}
+    }
+    @Bean
+    public static RestTemplate getRestTemplate(){
+        return new RestTemplate();
+    }
+}

+ 119 - 119
huimv-eartag2-platform/huimv-eartag2-api/src/main/java/com/huimv/eartag2/api/service/impl/FarmerAssetServiceImpl.java

@@ -1,119 +1,119 @@
-//package com.huimv.eartag2.api.service.impl;
-//
-//import com.alibaba.fastjson.JSONObject;
-//import com.huimv.eartag2.api.mapper.BaseFarmerMapper;
-//import com.huimv.eartag2.api.mapper.EartagDeviceRegisterMapper;
-//import com.huimv.eartag2.api.mapper.EartagEartagRegister2Mapper;
-//import com.huimv.eartag2.api.mapper.FarmerAssetMapper;
-//import com.huimv.eartag2.api.pojo.EartagEartagRegister2;
-//import com.huimv.eartag2.api.pojo.FarmerAsset;
-//import com.huimv.eartag2.common.utils.DateUtil;
-//import com.huimv.eartag2.common.utils.Result;
-//import com.huimv.eartag2.common.utils.ResultCode;
-//import com.huimv.eartag2.api.service.FarmerAssetService;
-//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-//import lombok.extern.slf4j.Slf4j;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.beans.factory.annotation.Value;
-//import org.springframework.stereotype.Service;
-//
-//import java.math.BigDecimal;
-//import java.text.ParseException;
-//import java.util.*;
-//
-///**
-// * <p>
-// *  服务实现类
-// * </p>
-// *
-// * @author zn
-// * @since 2022-08-29
-// */
-//@Service
-//@Slf4j
-//public class FarmerAssetServiceImpl extends ServiceImpl<FarmerAssetMapper, FarmerAsset> implements FarmerAssetService {
-//    @Autowired
-//    private FarmerAssetMapper farmerAssetMapper;
-//    @Autowired
-//    private EartagEartagRegister2Mapper eartagEartagRegister2Mapper;
-//    @Autowired
-//    private EartagDeviceRegisterMapper eartagDeviceRegisterMapper;
-//
-//    @Autowired
-//    private BaseFarmerMapper baseFarmerMapper;
-//    @Value("${farmer.pig.price}")
-//    private String pigPrice;
-//
-//    @Override
-//    public List<FarmerAsset> getLastManyMonthAssets(String farmCode, String manyMonth) {
-//        //{}
-//        return farmerAssetMapper.getLastManyMonthAssets(farmCode,manyMonth);
-//    }
-//
-//    @Override
-//    public Result getAssetStatistics(Map<String, Object> paramsMap) throws ParseException {
-//        //--农户
-//        String farmerId = paramsMap.get("farmerId")+"";
-//        System.out.println("farmerId="+farmerId);
-//
-//        //{根据农户读取采集器}
-//        String deviceCode = eartagDeviceRegisterMapper.getDeviceIdByFarmerId(farmerId);
-//        //{读取最后一批猪信息}
-//        JSONObject lastBatchJo = _getlastBatchAdoptPig(deviceCode);
-//        //读取资产信息
-//        List<FarmerAsset> farmerAssetList = farmerAssetMapper.getAssetByMonth(6,farmerId);
-//        List reverseList = new ArrayList();
-//        //--反转排序
-//        for(int a=farmerAssetList.size()-1;a>=0;a--){
-//            reverseList.add(farmerAssetList.get(a));
-//        }
-//        if(lastBatchJo != null){
-//            lastBatchJo.put("estimated",reverseList);
-//            return new Result(ResultCode.SUCCESS,lastBatchJo);
-//        }else{
-//            JSONObject nullLastBatchJo = new JSONObject();
-//            nullLastBatchJo.put("adoptTime","");
-//            nullLastBatchJo.put("husbandryTime","");
-//            nullLastBatchJo.put("currentPrices",0);
-//            nullLastBatchJo.put("expectedEarning",0);
-//            nullLastBatchJo.put("estimated",reverseList);
-//            return new Result(ResultCode.SUCCESS,nullLastBatchJo);
-//        }
-//
-//    }
-//
-//
-//
-//    //{读取最后一批猪信息}
-//    private JSONObject _getlastBatchAdoptPig(String deviceCode) throws ParseException {
-//        //{获取最后一条记录create_date日期}
-//        Date createDate = eartagEartagRegister2Mapper.getLastBatchCreateDate(deviceCode);
-//        if(createDate == null){
-//            log.error("该采集器["+deviceCode+"]没有耳标注册数据.");
-//            return null;
-//        }else{
-//            DateUtil dateUtil = new DateUtil();
-//            List<EartagEartagRegister2> eartagEartagRegister2List = eartagEartagRegister2Mapper.getLastBatchPig(deviceCode,createDate);
-//            if(eartagEartagRegister2List.size()>0){
-//                long diff = dateUtil.getTodayDate().getTime()-createDate.getTime();
-//                long days = diff / (1000 * 60 * 60 * 24);
-//                //读取重量
-//                BigDecimal weightBd = farmerAssetMapper.getPigWeightByDayage(days);
-//                BigDecimal planValue = weightBd.multiply(new BigDecimal(pigPrice)).multiply(new BigDecimal(eartagEartagRegister2List.size())).setScale(2,BigDecimal.ROUND_HALF_UP);
-//                JSONObject outJo = new JSONObject();
-//                outJo.put("adoptTime",dateUtil.formatDateText(createDate));
-//                outJo.put("husbandryTime",days);
-//                outJo.put("currentPrices",pigPrice);
-//                outJo.put("expectedEarning",planValue.toString());
-//                return outJo;
-//            }else{
-//                JSONObject outJo = new JSONObject();
-//                outJo.put("adoptTime",null);
-//                outJo.put("husbandryTime",null);
-//                outJo.put("currentPrices",0);
-//                outJo.put("expectedEarning",0);
-//                return outJo;
-//            }
-//        }
-//    }
-//}
+package com.huimv.eartag2.api.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.eartag2.api.mapper.BaseFarmerMapper;
+import com.huimv.eartag2.api.mapper.EartagDeviceRegisterMapper;
+import com.huimv.eartag2.api.mapper.EartagEartagRegister2Mapper;
+import com.huimv.eartag2.api.mapper.FarmerAssetMapper;
+import com.huimv.eartag2.api.pojo.EartagEartagRegister2;
+import com.huimv.eartag2.api.pojo.FarmerAsset;
+import com.huimv.eartag2.common.utils.DateUtil;
+import com.huimv.eartag2.common.utils.Result;
+import com.huimv.eartag2.common.utils.ResultCode;
+import com.huimv.eartag2.api.service.FarmerAssetService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.util.*;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author zn
+ * @since 2022-08-29
+ */
+@Service
+@Slf4j
+public class FarmerAssetServiceImpl extends ServiceImpl<FarmerAssetMapper, FarmerAsset> implements FarmerAssetService {
+    @Autowired
+    private FarmerAssetMapper farmerAssetMapper;
+    @Autowired
+    private EartagEartagRegister2Mapper eartagEartagRegister2Mapper;
+    @Autowired
+    private EartagDeviceRegisterMapper eartagDeviceRegisterMapper;
+
+    @Autowired
+    private BaseFarmerMapper baseFarmerMapper;
+    @Value("${farmer.pig.price}")
+    private String pigPrice;
+
+    @Override
+    public List<FarmerAsset> getLastManyMonthAssets(String farmCode, String manyMonth) {
+        //{}
+        return farmerAssetMapper.getLastManyMonthAssets(farmCode,manyMonth);
+    }
+
+    @Override
+    public Result getAssetStatistics(Map<String, Object> paramsMap) throws ParseException {
+        //--农户
+        String farmerId = paramsMap.get("farmerId")+"";
+        System.out.println("farmerId="+farmerId);
+
+        //{根据农户读取采集器}
+        String deviceCode = eartagDeviceRegisterMapper.getDeviceIdByFarmerId(farmerId);
+        //{读取最后一批猪信息}
+        JSONObject lastBatchJo = _getlastBatchAdoptPig(deviceCode);
+        //读取资产信息
+        List<FarmerAsset> farmerAssetList = farmerAssetMapper.getAssetByMonth(6,farmerId);
+        List reverseList = new ArrayList();
+        //--反转排序
+        for(int a=farmerAssetList.size()-1;a>=0;a--){
+            reverseList.add(farmerAssetList.get(a));
+        }
+        if(lastBatchJo != null){
+            lastBatchJo.put("estimated",reverseList);
+            return new Result(ResultCode.SUCCESS,lastBatchJo);
+        }else{
+            JSONObject nullLastBatchJo = new JSONObject();
+            nullLastBatchJo.put("adoptTime","");
+            nullLastBatchJo.put("husbandryTime","");
+            nullLastBatchJo.put("currentPrices",0);
+            nullLastBatchJo.put("expectedEarning",0);
+            nullLastBatchJo.put("estimated",reverseList);
+            return new Result(ResultCode.SUCCESS,nullLastBatchJo);
+        }
+
+    }
+
+
+
+    //{读取最后一批猪信息}
+    private JSONObject _getlastBatchAdoptPig(String deviceCode) throws ParseException {
+        //{获取最后一条记录create_date日期}
+        Date createDate = eartagEartagRegister2Mapper.getLastBatchCreateDate(deviceCode);
+        if(createDate == null){
+            log.error("该采集器["+deviceCode+"]没有耳标注册数据.");
+            return null;
+        }else{
+            DateUtil dateUtil = new DateUtil();
+            List<EartagEartagRegister2> eartagEartagRegister2List = eartagEartagRegister2Mapper.getLastBatchPig(deviceCode,createDate);
+            if(eartagEartagRegister2List.size()>0){
+                long diff = dateUtil.getTodayDate().getTime()-createDate.getTime();
+                long days = diff / (1000 * 60 * 60 * 24);
+                //读取重量
+                BigDecimal weightBd = farmerAssetMapper.getPigWeightByDayage(days);
+                BigDecimal planValue = weightBd.multiply(new BigDecimal(pigPrice)).multiply(new BigDecimal(eartagEartagRegister2List.size())).setScale(2,BigDecimal.ROUND_HALF_UP);
+                JSONObject outJo = new JSONObject();
+                outJo.put("adoptTime",dateUtil.formatDateText(createDate));
+                outJo.put("husbandryTime",days);
+                outJo.put("currentPrices",pigPrice);
+                outJo.put("expectedEarning",planValue.toString());
+                return outJo;
+            }else{
+                JSONObject outJo = new JSONObject();
+                outJo.put("adoptTime",null);
+                outJo.put("husbandryTime",null);
+                outJo.put("currentPrices",0);
+                outJo.put("expectedEarning",0);
+                return outJo;
+            }
+        }
+    }
+}