|
@@ -7,6 +7,7 @@ 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.cattle.utils.FarmCodeUtils;
|
|
|
import com.huimv.common.utils.Result;
|
|
|
import com.huimv.common.utils.ResultCode;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -38,8 +39,10 @@ public class PreventDetectionController {
|
|
|
|
|
|
@PostMapping("/savePreventDetection")
|
|
|
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()));
|
|
|
+ String farmCode = FarmCodeUtils.getFarmCode(preventDetection.getFarmCode(), request);
|
|
|
+ System.out.println(farmCode);
|
|
|
+ PreventDetection one = preventDetectionService.getOne(new QueryWrapper<PreventDetection>().eq("farm_code", farmCode).eq("month", preventDetection.getMonth()).eq("year", preventDetection.getYear()));
|
|
|
+ preventDetection.setFarmCode(farmCode);
|
|
|
if (ObjectUtil.isNotEmpty(one)){
|
|
|
one.setAcceptanceNum(preventDetection.getAcceptanceNum());
|
|
|
one.setDetectionNum(preventDetection.getDetectionNum());
|
|
@@ -68,8 +71,9 @@ public class PreventDetectionController {
|
|
|
return new Result(10000,"删除成功",true);
|
|
|
}
|
|
|
@PostMapping("/getPreventDetection")
|
|
|
- public Result list(@RequestBody PreventDetection preventDetection){
|
|
|
- List<PreventDetection> list = preventDetectionService.list(new QueryWrapper<PreventDetection>().orderByDesc("year").orderByDesc("month"));
|
|
|
+ public Result list(@RequestBody PreventDetection preventDetection,HttpServletRequest request){
|
|
|
+ String farmCode = FarmCodeUtils.getFarmCode(preventDetection.getFarmCode(), request);
|
|
|
+ List<PreventDetection> list = preventDetectionService.list(new QueryWrapper<PreventDetection>().eq("farm_code",farmCode).orderByDesc("year").orderByDesc("month"));
|
|
|
if (ObjectUtil.isEmpty(list)){
|
|
|
return new Result(ResultCode.SUCCESS,new ArrayList<>());
|
|
|
}
|