南昌市物联网技防平台-后台
Administrator
2021-04-12 36afc3a1f1437b8a3283dc0bf6475e96fded05a7
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/healthcode/controller/healthcodeController.java
@@ -16,7 +16,6 @@
 */
package org.springblade.jfpt.healthcode.controller;
import com.alibaba.nacos.common.utils.JacksonUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
@@ -24,15 +23,19 @@
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.jfpt.healthcode.entity.healthcode;
import org.springblade.jfpt.alarm.vo.AlarmExcel;
import org.springblade.jfpt.alarm.vo.AlarmVO;
import org.springblade.jfpt.healthcode.entity.Healthcode;
import org.springblade.jfpt.healthcode.service.IhealthcodeService;
import org.springblade.jfpt.healthcode.vo.healthcodeVO;
import org.springblade.jfpt.healthcode.vo.HealthcodeExcel;
import org.springblade.jfpt.healthcode.vo.HealthcodeVO;
import org.springblade.jfpt.healthcode.wrapper.healthcodeWrapper;
import org.springblade.jfpt.parcel.util.JacksonUtil;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
@@ -61,8 +64,8 @@
   @GetMapping("/detail")
   @ApiOperationSupport(order = 1)
   @ApiOperation(value = "详情", notes = "传入lx")
   public R<healthcodeVO> detail(healthcode healthcode) {
      healthcode detail = ihealthcodeService.getOne(Condition.getQueryWrapper(healthcode));
   public R<HealthcodeVO> detail(Healthcode healthcode) {
      Healthcode detail = ihealthcodeService.getOne(Condition.getQueryWrapper(healthcode));
      return R.data(healthcodeWrapper.build().entityVO(detail));
   }
@@ -72,9 +75,22 @@
   @GetMapping("/list")
   @ApiOperationSupport(order = 2)
   @ApiOperation(value = "分页", notes = "传入lx")
   public R<IPage<healthcodeVO>> list(healthcode healthcode, Query query) {
      IPage<healthcode> pages = ihealthcodeService.page(Condition.getPage(query), Condition.getQueryWrapper(healthcode));
   public R<IPage<HealthcodeVO>> list(Healthcode healthcode, Query query) {
      IPage<Healthcode> pages = ihealthcodeService.page(Condition.getPage(query), Condition.getQueryWrapper(healthcode));
      return R.data(healthcodeWrapper.build().pageVO(pages));
   }
   /**
    * 自定义健康码分页/健康码统计图表点击事件
    * @param healthcodeVO 健康码对象
    * @param query 分页对象(页码)
    * @return
    */
   @GetMapping("/page")
   @ApiOperationSupport(order = 2)
   @ApiOperation(value = "自定义分页", notes = "传入lx")
   public R<IPage<Healthcode>> page(HealthcodeVO healthcodeVO, Query query) {
      return R.data(ihealthcodeService.selectHealthcodeListPage(Condition.getPage(query),healthcodeVO));
   }
@@ -84,7 +100,7 @@
   @PostMapping("/save")
   @ApiOperationSupport(order = 4)
   @ApiOperation(value = "新增", notes = "传入lx")
   public R save(@Valid @RequestBody healthcode healthcode) {
   public R save(@Valid @RequestBody Healthcode healthcode) {
      return R.status(ihealthcodeService.save(healthcode));
   }
@@ -94,7 +110,7 @@
   @PostMapping("/update")
   @ApiOperationSupport(order = 5)
   @ApiOperation(value = "修改", notes = "传入lx")
   public R update(@Valid @RequestBody healthcode healthcode) {
   public R update(@Valid @RequestBody Healthcode healthcode) {
      return R.status(ihealthcodeService.updateById(healthcode));
   }
@@ -104,7 +120,7 @@
   @PostMapping("/submit")
   @ApiOperationSupport(order = 6)
   @ApiOperation(value = "新增或修改", notes = "传入lx")
   public R submit(@Valid @RequestBody healthcode healthcode) {
   public R submit(@Valid @RequestBody Healthcode healthcode) {
      return R.status(ihealthcodeService.saveOrUpdate(healthcode));
   }
@@ -134,8 +150,8 @@
   /**
    * 统计接口
    */
   @PostMapping("/selectCount")
   public R selectCount(@RequestBody String type,HttpServletResponse response) {
   @GetMapping("/selectCount")
   public R selectCount(Integer type,HttpServletResponse response) {
      response.setHeader("Access-Control-Allow-Origin", "*");
      response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
      response.setHeader("Access-Control-Allow-Credentials","true");
@@ -150,15 +166,14 @@
      if (1 == dayWeek) {
         cal.add(Calendar.DAY_OF_MONTH, -1);
      }
      String dataType = JacksonUtil.parseString(type, "type");
      switch(dataType){
         case "0" :
      switch(type){
         case 0 :
            //日
            String times = sdf.format(cal.getTime());
            System.out.println("times = " + times);
            list=ihealthcodeService.selectCountr(times);
            break;
         case "1" :
         case 1 :
            System.out.println("要计算日期为:" + sdf.format(cal.getTime())); // 输出要计算日期
            // 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
            cal.setFirstDayOfWeek(Calendar.MONDAY);
@@ -226,4 +241,16 @@
      return calendar.getTime();
   }
   /**
    * 导出健康码数据表格
    * @param healthcodeVO 查询条件
    * @param response
    */
   @GetMapping("/export-healthcode")
   public void exportHealthcode(HealthcodeVO healthcodeVO, HttpServletResponse response){
      List<HealthcodeExcel> list = ihealthcodeService.exportHealthcode(healthcodeVO);
      ExcelUtil.export(response, "健康码数据" + DateUtil.time(), "健康码数据表", list, HealthcodeExcel.class);
   }
}