Explorar el Código

体重新增修改

wwh hace 1 año
padre
commit
4ff857438b

+ 7 - 2
huimv-admin/src/main/java/com/huimv/guowei/admin/controller/EnvMoveCallController.java

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.Map;
 
@@ -45,8 +46,12 @@ public class EnvMoveCallController {
 
     @RequestMapping("/addDuck")
     public Result addDuck(HttpServletRequest httpServletRequest, @RequestBody EnvMoveCall envMoveCall) throws ParseException {
-       moveCallService.save(envMoveCall);
-        return new Result(10000, "添加成功!", true);
+        if (envMoveCall.getDuckWeight().compareTo(BigDecimal.ZERO) !=1) {
+            return new Result(10001, "体重必须大于0", false);
+        } else {
+            moveCallService.save(envMoveCall);
+            return new Result(10000, "添加成功!", true);
+        }
     }
 
     @RequestMapping("/editDuck")

+ 8 - 0
huimv-admin/src/main/java/com/huimv/guowei/admin/service/impl/EnvRegularCallEggServiceImpl.java

@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
@@ -108,7 +109,14 @@ public class EnvRegularCallEggServiceImpl extends ServiceImpl<EnvRegularCallEggM
         date = date + " 00:00:00";
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         String eggNum = paramsMap.get("eggNum");
+        if (Integer.parseInt(eggNum) < 0) {
+            return new Result(10001, "蛋的个数不能为负数", false);
+        }
         String eggWeight = paramsMap.get("eggWeight");
+        BigDecimal weight = new BigDecimal(eggWeight);
+        if (weight.compareTo(BigDecimal.ZERO) != 1) {
+            return new Result(10001, "蛋的重量必须大于0", false);
+        }
         EnvRegularCallEgg egg = new EnvRegularCallEgg();
         egg.setDuckNum(baseDuckInfo.getDuckNum());
         egg.setFarmId(Integer.parseInt(farmId));