Forráskód Böngészése

基本信息修改

523096025 4 éve
szülő
commit
6bf871a891

+ 7 - 2
huimv-smart-management/src/main/java/com/huimv/management/controller/YearPigBaseController.java

@@ -1,11 +1,13 @@
  package com.huimv.management.controller;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
 import io.swagger.annotations.Api;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -142,7 +144,7 @@ public class YearPigBaseController {
      * 查谱系问题,请求头中需要有ID
      */
     @RequestMapping("/queryByRelationship")
-    public R queryPageByRelationship(@RequestParam Map<String, Object> params){
+    public R queryPageByRelationship(@RequestParam Map<String, Object> params) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
         Map<String, Object> stringObjectMap = yearPigBaseService.queryPageByRelationship(params);
         return R.ok().put("Result", stringObjectMap);
     }
@@ -156,7 +158,10 @@ public class YearPigBaseController {
         String startTime = (String)params.get("startTime");
         String endTime = (String)params.get("endTime");
         String farmId = (String)params.get("formFarmId");
-
+        if (StringUtils.isBlank(farmId)) {
+            return R.error("牧场信息为空");
+        }
+        yearPigBaseService.suchStatistics(startTime,endTime,Integer.parseInt(farmId));
 
         return R.ok();
     }

+ 5 - 0
huimv-smart-management/src/main/java/com/huimv/management/dao/YearPigBaseDao.java

@@ -4,11 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.huimv.management.entity.YearPigBaseEntity;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.huimv.management.entity.vo.CountOut;
 import com.huimv.management.entity.vo.DrinkingWaterVo;
 import com.huimv.management.entity.vo.PigBaseVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 年猪基本
  * 
@@ -25,4 +28,6 @@ public interface YearPigBaseDao extends BaseMapper<YearPigBaseEntity> {
     void such(Integer[] ids);
 
     IPage<PigBaseVo> list(@Param("page")IPage page, @Param("ew") QueryWrapper<DrinkingWaterVo> queryWrapper);
+
+    List<CountOut> suchStatistics(@Param("farmId") Integer farmId,@Param("ew") QueryWrapper<YearPigBaseEntity> wrapper);
 }

+ 16 - 0
huimv-smart-management/src/main/java/com/huimv/management/entity/vo/CountOut.java

@@ -0,0 +1,16 @@
+package com.huimv.management.entity.vo;
+
+import lombok.Data;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.management.entity.vo
+ * @Description : TODO
+ * @Author : yuxuexuan
+ * @Create : 2021/6/18 0018 16:49
+ **/
+@Data
+public class CountOut {
+    private String date;
+    private  Integer total;
+}

+ 4 - 1
huimv-smart-management/src/main/java/com/huimv/management/service/YearPigBaseService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.huimv.common.utils.PageUtils;
 import com.huimv.management.entity.YearPigBaseEntity;
 
+import java.lang.reflect.InvocationTargetException;
 import java.rmi.MarshalledObject;
 import java.util.List;
 import java.util.Map;
@@ -22,7 +23,7 @@ public interface YearPigBaseService extends IService<YearPigBaseEntity> {
 
 
     //查一只猪的上下两代
-    Map<String ,Object> queryPageByRelationship(Map<String, Object> params);
+    Map<String ,Object> queryPageByRelationship(Map<String, Object> params) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException;
 
 
 
@@ -39,5 +40,7 @@ public interface YearPigBaseService extends IService<YearPigBaseEntity> {
     void such(Integer[] ids);
 
     Integer findByoutFenceStatus(int i, Integer farmId);
+
+    void suchStatistics(String startTime, String endTime, Integer farmId);
 }
 

+ 60 - 12
huimv-smart-management/src/main/java/com/huimv/management/service/impl/YearPigBaseServiceImpl.java

@@ -5,13 +5,17 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.huimv.management.entity.YearPigBaseEntity;
+import com.huimv.management.entity.vo.CountOut;
 import com.huimv.management.entity.vo.DrinkingWaterVo;
 import com.huimv.management.entity.vo.PigBaseVo;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.apache.commons.beanutils.BeanUtils;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -147,15 +151,14 @@ public class YearPigBaseServiceImpl extends ServiceImpl<YearPigBaseDao, YearPigB
 
 
     @Override
-    public   Map<String ,Object> queryPageByRelationship(Map<String, Object> params) {
+    public   Map<String ,Object> queryPageByRelationship(Map<String, Object> params) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
 
         Map<String, Object> result = new HashMap<>();
         String eartag_no = (String) params.get("eartag");
         System.out.println(eartag_no);
         YearPigBaseEntity  self = baseMapper.selectOne(Wrappers.<YearPigBaseEntity>lambdaQuery().eq(YearPigBaseEntity::getEartag, eartag_no));
         System.out.println(self);
-        result.put("self",   self  );
-
+        // result.put("self",   self  );
 
         System.out.println("父亲ID"+self.getFatherEartag());   System.out.println("母亲ID"+self.getMotherEartag());
         String math = self.getMotherEartag();
@@ -164,22 +167,67 @@ public class YearPigBaseServiceImpl extends ServiceImpl<YearPigBaseDao, YearPigB
         YearPigBaseEntity mother = self.getMotherEartag() == null ? null :  baseMapper.selectOne(Wrappers.<YearPigBaseEntity>lambdaQuery().eq(YearPigBaseEntity::getEartag, math));
 
 
-
         //父亲父母
-        result.put("father", father);
-        result.put("mother", mother);
+        // result.put("father", father);
+        // result.put("mother", mother);
         YearPigBaseEntity fathermother = father == null ? null :  baseMapper.selectOne(Wrappers.<YearPigBaseEntity>lambdaQuery().eq(YearPigBaseEntity::getEartag, father.getFatherEartag()));
         YearPigBaseEntity fatherfather = father == null ? null :  baseMapper.selectOne(Wrappers.<YearPigBaseEntity>lambdaQuery().eq(YearPigBaseEntity::getEartag, father.getMotherEartag()));
-        result.put("fathermother", fathermother);
-        result.put("fatherfather", fatherfather);
+        //  result.put("fathermother", fathermother);
+        // result.put("fatherfather", fatherfather);
         //母亲父母
         YearPigBaseEntity mothermother = mother == null ? null :  baseMapper.selectOne(Wrappers.<YearPigBaseEntity>lambdaQuery().eq(YearPigBaseEntity::getEartag, mother.getFatherEartag()));
         YearPigBaseEntity  motherfather = mother == null ? null :  baseMapper.selectOne(Wrappers.<YearPigBaseEntity>lambdaQuery().eq(YearPigBaseEntity::getEartag, mother.getMotherEartag()));
-        result.put("mothermother", mothermother);
-        result.put("motherfather", motherfather);
-
-
+        //  result.put("mothermother", mothermother);
+        // result.put("motherfather", motherfather);
+
+
+
+
+        Object[] intArr = new Object[7];
+        Map<String, String> selfmap = BeanUtils.describe(self);
+        selfmap.put("name","self");
+        Map<String, String> fathermap = BeanUtils.describe(father);
+        fathermap.put("name","father");
+        Map<String, String> mothermap = BeanUtils.describe(mother);
+        mothermap.put("name","mother");
+        Map<String, String> fathermothermap = BeanUtils.describe(fathermother);
+        fathermothermap.put("name","fathermother");
+        Map<String, String> fatherfatherself = BeanUtils.describe(fatherfather);
+        fatherfatherself.put("name","fatherfather");
+        Map<String, String> mothermotherself = BeanUtils.describe(mothermother);
+        mothermotherself.put("name","mothermother");
+        Map<String, String> motherfatherself = BeanUtils.describe(motherfather);
+        motherfatherself.put("name","motherfather");
+
+
+        intArr[0] = selfmap;
+        intArr[1] = fathermap;
+        intArr[2] = mothermap;
+        intArr[3] = fathermothermap;
+        intArr[4] = fatherfatherself;
+        intArr[5] = mothermotherself;
+        intArr[6] = motherfatherself;
+
+        result.put("value",intArr);
         return   result;
     }
 
+    @Override
+    public void suchStatistics(String startTime, String endTime, Integer farmId) {
+        QueryWrapper<YearPigBaseEntity> wrapper = new QueryWrapper<>();
+        wrapper.eq("farm_id", farmId);
+
+        //开始时间
+        if (StringUtils.isNotEmpty(startTime)) {
+            wrapper.ge("out_fence_time", startTime);
+        }
+        //开始时间
+        if (StringUtils.isNotEmpty(endTime)) {
+            wrapper.le("out_fence_time", endTime);
+        }
+        wrapper.apply("deleted = 0 AND out_fence_status = 1 ");
+
+        List<CountOut> endList  = pigBaseDao.suchStatistics(farmId,wrapper);
+        System.out.println(endList);
+    }
 }

+ 6 - 0
huimv-smart-management/src/main/resources/mapper/management/YearPigBaseDao.xml

@@ -59,4 +59,10 @@
 
     </select>
 
+    <select id="suchStatistics" resultType="com.huimv.management.entity.vo.CountOut">
+        SELECT DATE_FORMAT(out_fence_time,"%Y-%m-%d") DATE,COUNT(*) total
+        FROM `mgt_year_pig_base`
+        ${ew.customSqlSegment}
+        GROUP BY DATE_FORMAT(out_fence_time,"%Y-%m-%d")
+    </select>
 </mapper>