|
@@ -6,6 +6,7 @@ import com.alibaba.druid.wall.violation.ErrorCode;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.huimv.cattle.pojo.PreventDetection;
|
|
|
import com.huimv.cattle.service.PreventDetectionService;
|
|
|
+import com.huimv.cattle.token.TokenSign;
|
|
|
import com.huimv.common.utils.Result;
|
|
|
import com.huimv.common.utils.ResultCode;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -15,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -34,14 +37,16 @@ public class PreventDetectionController {
|
|
|
private PreventDetectionService preventDetectionService;
|
|
|
|
|
|
@PostMapping("/savePreventDetection")
|
|
|
- public Result add(@RequestBody PreventDetection preventDetection){
|
|
|
- PreventDetection one = preventDetectionService.getOne(new QueryWrapper<PreventDetection>().eq("month", preventDetection.getMonth()).eq("year", preventDetection.getYear()));
|
|
|
+ public Result add(@RequestBody PreventDetection preventDetection, HttpServletRequest request){
|
|
|
+ String farmIds = TokenSign.getFarmCode(request);
|
|
|
+ PreventDetection one = preventDetectionService.getOne(new QueryWrapper<PreventDetection>().eq("farm_code",false).eq("month", preventDetection.getMonth()).eq("year", preventDetection.getYear()));
|
|
|
if (ObjectUtil.isNotEmpty(one)){
|
|
|
one.setAcceptanceNum(preventDetection.getAcceptanceNum());
|
|
|
one.setDetectionNum(preventDetection.getDetectionNum());
|
|
|
one.setMonth(preventDetection.getMonth());
|
|
|
one.setMonthName(preventDetection.getMonthName());
|
|
|
one.setYear(preventDetection.getYear());
|
|
|
+ one.setFarmCode(preventDetection.getFarmCode());
|
|
|
preventDetectionService.updateById(one);
|
|
|
}else {
|
|
|
preventDetectionService.save(preventDetection);
|