baizonghao
2023-02-24 ebf167b950e735f873f3fcdbba276df47ada9834
ycl-platform/src/main/java/com/ycl/controller/intelligentPatrol/StatisticsController.java
@@ -5,17 +5,21 @@
import com.ycl.annotation.LogSave;
import com.ycl.api.CommonResult;
import com.ycl.controller.BaseController;
import com.ycl.dto.caseHandler.QueryForViolationParam;
import com.ycl.dto.statistics.UnlawfulDto;
import com.ycl.dto.statistics.UnlawfulShopDto;
import com.ycl.service.unlawful.UnlawfulService;
import com.ycl.utils.EasyExcelUtils;
import com.ycl.vo.casePool.QueryForViolationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -32,23 +36,26 @@
@Api(tags = "违章-违法统计")
public class StatisticsController extends BaseController {
    List<UnlawfulDto> ls = new ArrayList<>(Arrays.asList(
            new UnlawfulDto("市场监管", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("公安", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("自然资源", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("生态环境", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("地方立法", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("地震", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("教育", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("经信", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("林业", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("农村环境卫生", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("气象", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("人防", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("水行政", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("应急管理", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
            new UnlawfulDto("其他", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0))
    );
//    List<UnlawfulDto> ls = new ArrayList<>(Arrays.asList(
//            new UnlawfulDto("市场监管", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("公安", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("自然资源", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("生态环境", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("地方立法", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("地震", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("教育", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("经信", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("林业", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("农村环境卫生", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("气象", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("人防", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("水行政", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("应急管理", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0),
//            new UnlawfulDto("其他", 100, 0.6, 10, 1, 20, 5, 20, 0.6, 0.9, 0.0))
//    );
    @Autowired
    private UnlawfulService unlawfulService;
    @GetMapping("/unlawful/type")
    @ApiOperation("按违规类型统计")
@@ -57,13 +64,25 @@
                                                         @RequestParam(required = true) Integer pageSize,
                                                         @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime beginTime,
                                                         @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime) {
        DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String startTime = null;
        String endTime1 = null;
        if (beginTime != null){
            startTime = beginTime.format(fmt);
        }
        if (endTime != null){
            endTime1 = beginTime.format(fmt);
        }
        IPage<UnlawfulDto> page = new Page<>();
        page.setTotal(ls.size());
        page.setRecords(ls);
        List<UnlawfulDto> unlawfulByType = unlawfulService.getUnlawfulByType((currentPage - 1) * pageSize, pageSize, startTime, endTime1);
        page.setTotal(unlawfulByType.size());
        page.setRecords(unlawfulByType);
        return CommonResult.success(page);
    }
    @GetMapping("/unlawful/point")
    /*@GetMapping("/unlawful/point")
    @ApiOperation("按点位统计")
    @LogSave(operationType = "按点位统计", contain = "查询")
    public CommonResult<IPage<UnlawfulDto>> searchByPoint(@RequestParam(required = true) Integer currentPage,
@@ -74,9 +93,9 @@
        page.setTotal(ls.size());
        page.setRecords(ls);
        return CommonResult.success(page);
    }
    }*/
    @GetMapping("/unlawful/time")
    /*@GetMapping("/unlawful/time")
    @ApiOperation("按时间统计")
    @LogSave(operationType = "按时间统计", contain = "查询")
    public CommonResult<IPage<UnlawfulDto>> searchByTime(@RequestParam(required = true) Integer currentPage,
@@ -87,9 +106,9 @@
        page.setTotal(ls.size());
        page.setRecords(ls);
        return CommonResult.success(page);
    }
    }*/
    @GetMapping("/unlawful/area")
    /*@GetMapping("/unlawful/area")
    @ApiOperation("按区域统计")
    @LogSave(operationType = "按区域统计", contain = "查询")
    public CommonResult<IPage<UnlawfulDto>> searchByArea(@RequestParam(required = true) Integer currentPage,
@@ -100,9 +119,9 @@
        page.setTotal(ls.size());
        page.setRecords(ls);
        return CommonResult.success(page);
    }
    }*/
    @GetMapping("/unlawful/shop")
    /*@GetMapping("/unlawful/shop")
    @ApiOperation("门前三包统计")
    @LogSave(operationType = "门前三包统计", contain = "查询")
    public CommonResult<IPage<UnlawfulShopDto>> searchByShop(@RequestParam(required = true) Integer currentPage,
@@ -127,6 +146,34 @@
        page.setTotal(ls.size());
        page.setRecords(ls);
        return CommonResult.success(page);
    }*/
    @PostMapping("/export/unlawful")
    @ApiOperation("按各种统计方式-导出")
    public void export(HttpServletResponse response) {
        List<UnlawfulDto> unlawfulByTypeExport = unlawfulService.getUnlawfulByTypeExport();
        String sheetName = "按统计方式";
        EasyExcelUtils.export(response, sheetName, UnlawfulDto.class, unlawfulByTypeExport);
    }
    /*@PostMapping("/export/shop")
    @ApiOperation("门前三包-导出")
    public void exportShop(HttpServletResponse response) {
        List<UnlawfulShopDto> ls = new ArrayList<>();
        ls.add(new UnlawfulShopDto("店铺1", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺2", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺3", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺4", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺5", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺6", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺7", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺8", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺9", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺10", 100, 10, 1, 20, 5, 20, 0.6));
        ls.add(new UnlawfulShopDto("店铺11", 100, 10, 1, 20, 5, 20, 0.7));
        ls.add(new UnlawfulShopDto("店铺12", 100, 10, 1, 20, 5, 20, 0.8));
        ls.add(new UnlawfulShopDto("店铺13", 100, 10, 1, 20, 5, 20, 0.9));
        String sheetName = "门前三包";
        EasyExcelUtils.export(response, sheetName, UnlawfulShopDto.class, ls);
    }*/
}