Quellcode durchsuchen

首页获取报表数据默认查询15天的数据 如果没有指定具体日期的话

王苗苗 vor 5 Monaten
Ursprung
Commit
c4b17289de

+ 8 - 0
src/main/java/com/xlht/xlhtproject/controller/FrontController.java

@@ -13,10 +13,13 @@ import com.xlht.xlhtproject.respParse.bean.R;
 import com.xlht.xlhtproject.respParse.page.TableDataInfo;
 import com.xlht.xlhtproject.service.IFrontService;
 import com.xlht.xlhtproject.service.ITShuju1Service;
+import com.xlht.xlhtproject.utils.DateUtils;
+import com.xlht.xlhtproject.utils.StringUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 
@@ -146,6 +149,11 @@ public class FrontController extends BaseController{
     public R<List<TShuju1>> homeList(@RequestParam(required = false, name = "timeBegin") String timeBegin, @RequestParam(required = false, name = "timeEnd") String timeEnd)
     {
         log.info("进入了 修改碳源投加 首页-报表信息 接口");
+        //2024年10月24日17:24:13 如果没有指定日期,那么这里给默认15天的数据
+        Date nowDate = DateUtils.getNowDate();
+        Date dayBefore14 = DateUtils.plusDate(-14, nowDate);
+        timeEnd = StringUtils.isBlank(timeEnd) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, nowDate) : timeEnd;
+        timeBegin = StringUtils.isBlank(timeBegin) ? DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, dayBefore14) : timeBegin;
         TShuju1 req = TShuju1.builder().timeBegin(timeBegin).timeEnd(timeEnd).build();
         return R.ok(this.tShuju1Service.selectTShuju1ListGroupByAssayId(req));
     }