|
@@ -1,11 +1,20 @@
|
|
|
package com.huimv.eartag2.manage2.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.huimv.eartag2.common.utils.Result;
|
|
|
+import com.huimv.eartag2.common.utils.ResultCode;
|
|
|
import com.huimv.eartag2.manage2.pojo.EartagData;
|
|
|
import com.huimv.eartag2.manage2.mapper.EartagDataMapper;
|
|
|
import com.huimv.eartag2.manage2.service.EartagDataService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 服务实现类
|
|
@@ -17,4 +26,26 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class EartagDataServiceImpl extends ServiceImpl<EartagDataMapper, EartagData> implements EartagDataService {
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result getEnvByTime(Map<String, String> map) {
|
|
|
+ String earmark = map.get("earmark");
|
|
|
+ String startDate = map.get("startDate");
|
|
|
+ String endDate = map.get("endDate");
|
|
|
+ Date now = new Date();
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(earmark)){
|
|
|
+ return new Result(10001,"请选择耳标",false);
|
|
|
+ }
|
|
|
+ QueryWrapper<EartagData> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("earmark",earmark);
|
|
|
+ if (StringUtils.isBlank(startDate)){
|
|
|
+ wrapper.ge("ask_time", DateUtil.beginOfDay(now));
|
|
|
+ }else {
|
|
|
+ wrapper.between("ask_time",startDate,endDate);
|
|
|
+ }
|
|
|
+ wrapper.orderByDesc("ask_time");
|
|
|
+ List<EartagData> list = this.list(wrapper);
|
|
|
+
|
|
|
+ return new Result(ResultCode.SUCCESS,list);
|
|
|
+ }
|
|
|
}
|