فهرست منبع

饲料消耗添加删除

wwh 2 سال پیش
والد
کامیت
18ea3c31b7

+ 18 - 1
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/controller/FeedDayController.java

@@ -2,6 +2,7 @@ package com.huimv.env.produce.controller;
 
 
 import com.huimv.common.utils.Result;
+import com.huimv.env.produce.entity.FeedDay;
 import com.huimv.env.produce.service.FeedDayService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -11,11 +12,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author zn
@@ -33,5 +36,19 @@ public class FeedDayController {
         //
         return feedDayService.getFeedCount(paramsMap);
     }
+
+    //添加
+    @PostMapping("/newFeedCount")
+    public Result newFeedCount(@RequestBody List<FeedDay> list) throws ParseException {
+        //
+        return feedDayService.newFeedCount(list);
+    }
+
+    //删除
+    @PostMapping("/removeFeedCount")
+    public Result removeFeedCount(@RequestBody Map<String,String> paramsMap) throws ParseException {
+        //
+        return feedDayService.removeFeedCount(paramsMap);
+    }
 }
 

+ 24 - 0
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/controller/FeedMonthController.java

@@ -1,10 +1,19 @@
 package com.huimv.env.produce.controller;
 
 
+import com.huimv.common.utils.Result;
+import com.huimv.env.produce.entity.FeedMonth;
+import com.huimv.env.produce.service.FeedMonthService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  *  前端控制器
@@ -16,6 +25,21 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/feed-month")
 public class FeedMonthController {
+    @Autowired
+    private FeedMonthService feedMonthService;
+
+    //添加
+    @PostMapping("/newFeedMonthCount")
+    public Result newFeedMonthCount(@RequestBody List<FeedMonth> list) {
+        //
+        return feedMonthService.newFeedMonthCount(list);
+    }
 
+    //删除
+    @PostMapping("/removeMonthCount")
+    public Result removeMonthCount(@RequestBody Map<String,String> paramsMap) {
+        //
+        return feedMonthService.removeMonthCount(paramsMap);
+    }
 }
 

+ 3 - 0
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/entity/FeedDay.java

@@ -6,6 +6,8 @@ import java.util.Date;
 import com.baomidou.mybatisplus.annotation.Version;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -28,6 +30,7 @@ public class FeedDay implements Serializable {
 
     private BigDecimal consumption;
 
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
     private Date addDate;
 
     private String farmCode;

+ 3 - 0
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/entity/Indicator.java

@@ -6,6 +6,8 @@ import java.util.Date;
 import com.baomidou.mybatisplus.annotation.Version;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -38,6 +40,7 @@ public class Indicator implements Serializable {
 
     private BigDecimal psy;
 
+    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
     private Date addDate;
 
     private String addPeople;

+ 6 - 0
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/service/FeedDayService.java

@@ -4,6 +4,8 @@ import com.huimv.common.utils.Result;
 import com.huimv.env.produce.entity.FeedDay;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.text.ParseException;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -17,4 +19,8 @@ import java.util.Map;
 public interface FeedDayService extends IService<FeedDay> {
 
     Result getFeedCount(Map<String, String> paramsMap);
+
+    Result newFeedCount(List<FeedDay> list);
+
+    Result removeFeedCount(Map<String,String> paramSMap);
 }

+ 11 - 0
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/service/FeedMonthService.java

@@ -1,8 +1,14 @@
 package com.huimv.env.produce.service;
 
+import com.huimv.common.utils.Result;
+import com.huimv.env.produce.entity.FeedDay;
 import com.huimv.env.produce.entity.FeedMonth;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.text.ParseException;
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  *  服务类
@@ -13,4 +19,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface FeedMonthService extends IService<FeedMonth> {
 
+    Result newFeedMonthCount(List<FeedMonth> list);
+
+    Result removeMonthCount(Map<String,String> paramsMap);
+
+
 }

+ 36 - 5
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/service/impl/FeedDayServiceImpl.java

@@ -1,5 +1,6 @@
 package com.huimv.env.produce.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.huimv.common.utils.Result;
@@ -11,13 +12,14 @@ import com.huimv.env.produce.mapper.FeedDayMapper;
 import com.huimv.env.produce.mapper.FeedMonthMapper;
 import com.huimv.env.produce.service.FeedDayService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.undertow.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * <p>
@@ -35,8 +37,6 @@ public class FeedDayServiceImpl extends ServiceImpl<FeedDayMapper, FeedDay> impl
     private FeedMonthMapper feedMonthMapper;
     @Autowired
     private static final String globalFarmCode = "14";
-    @Autowired
-    private DateUtil dateUtil;
 
 
     @Override
@@ -110,6 +110,36 @@ public class FeedDayServiceImpl extends ServiceImpl<FeedDayMapper, FeedDay> impl
         return new Result(ResultCode.SUCCESS, resultJo);
     }
 
+
+    @Override
+    public Result newFeedCount(List<FeedDay> list) {
+
+
+        QueryWrapper<FeedDay> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("farm_code", globalFarmCode);
+        feedDayMapper.delete(queryWrapper);
+
+        for (int i = 0; i <list.size(); i++) {
+            FeedDay feedDay = new FeedDay();
+            feedDay.setConsumption(list.get(i).getConsumption());
+            feedDay.setAddDate(list.get(i).getAddDate());
+            feedDay.setFarmCode(globalFarmCode);
+            feedDayMapper.insert(feedDay);
+        }
+        return new Result(ResultCode.SUCCESS);
+    }
+
+
+    @Override
+    public Result removeFeedCount(Map<String, String> paramSMap) {
+        String ids = paramSMap.get("ids");
+        String[] idArray = ids.split(",");
+        List<String> idList = Arrays.asList(idArray);
+        feedDayMapper.deleteBatchIds(idList);
+        return new Result(ResultCode.SUCCESS, feedDayMapper.deleteBatchIds(idList));
+    }
+
+
     private List<Object> _getFeedHistoryConsumption(Map<String, String> paramsMap) {
         String months = paramsMap.get("months");
         String days = paramsMap.get("days");
@@ -136,4 +166,5 @@ public class FeedDayServiceImpl extends ServiceImpl<FeedDayMapper, FeedDay> impl
         }
         return consumptionList;
     }
+
 }

+ 44 - 0
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/service/impl/FeedMonthServiceImpl.java

@@ -1,11 +1,25 @@
 package com.huimv.env.produce.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.huimv.common.utils.Result;
+import com.huimv.common.utils.ResultCode;
+import com.huimv.env.common.utils.DateUtil;
+import com.huimv.env.produce.entity.FeedDay;
 import com.huimv.env.produce.entity.FeedMonth;
 import com.huimv.env.produce.mapper.FeedMonthMapper;
 import com.huimv.env.produce.service.FeedMonthService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  *  服务实现类
@@ -17,4 +31,34 @@ import org.springframework.stereotype.Service;
 @Service
 public class FeedMonthServiceImpl extends ServiceImpl<FeedMonthMapper, FeedMonth> implements FeedMonthService {
 
+    @Autowired
+    private FeedMonthMapper feedMonthMapper;
+    @Autowired
+    private static final String globalFarmCode = "14";
+
+    @Override
+    public Result removeMonthCount(Map<String, String> paramsMap) {
+        String ids = paramsMap.get("ids");
+        String[] idArray = ids.split(",");
+        List<String> idList = Arrays.asList(idArray);
+        feedMonthMapper.deleteBatchIds(idList);
+        return new Result(ResultCode.SUCCESS, feedMonthMapper.deleteBatchIds(idList));
+    }
+
+    @Override
+    public Result newFeedMonthCount(List<FeedMonth> list) {
+        QueryWrapper<FeedMonth> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("farm_code", globalFarmCode);
+        feedMonthMapper.delete(queryWrapper);
+
+        for (int i = 0; i <list.size(); i++) {
+            FeedMonth feedMonth = new FeedMonth();
+            feedMonth.setConsumption(list.get(i).getConsumption());
+            feedMonth.setMonth(list.get(i).getMonth());
+            feedMonth.setYear(list.get(i).getYear());
+            feedMonth.setFarmCode(globalFarmCode);
+            feedMonthMapper.insert(feedMonth);
+        }
+        return new Result(ResultCode.SUCCESS);
+    }
 }