| | |
| | | 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.*; |
| | | |
| | | 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; |
| | |
| | | @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("按违规类型统计") |
| | |
| | | @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, |
| | |
| | | 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, |
| | |
| | | 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, |
| | |
| | | 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, |
| | |
| | | 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, ls); |
| | | EasyExcelUtils.export(response, sheetName, UnlawfulDto.class, unlawfulByTypeExport); |
| | | } |
| | | |
| | | @PostMapping("/export/shop") |
| | | /*@PostMapping("/export/shop") |
| | | @ApiOperation("门前三包-导出") |
| | | public void exportShop(HttpServletResponse response) { |
| | | List<UnlawfulShopDto> ls = new ArrayList<>(); |
| | |
| | | ls.add(new UnlawfulShopDto("店铺13", 100, 10, 1, 20, 5, 20, 0.9)); |
| | | String sheetName = "门前三包"; |
| | | EasyExcelUtils.export(response, sheetName, UnlawfulShopDto.class, ls); |
| | | } |
| | | }*/ |
| | | } |
New file |
| | |
| | | package com.ycl.dto.statistics; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | public class CategoryDto { |
| | | Integer id; |
| | | String name; |
| | | } |
New file |
| | |
| | | package com.ycl.dto.statistics; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | @Data |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | public class StatusDto { |
| | | Integer total; |
| | | Integer register; |
| | | Integer notRegister; |
| | | Integer closing; |
| | | Integer relearn; |
| | | Integer checked; |
| | | } |
| | |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | |
| | | @Data |
| | | @AllArgsConstructor |
| | | @NoArgsConstructor |
| | | @Builder |
| | | public class UnlawfulDto { |
| | | |
| | | /** |
New file |
| | |
| | | package com.ycl.mapper.unlawful; |
| | | |
| | | import com.ycl.dto.statistics.CategoryDto; |
| | | import com.ycl.dto.statistics.StatusDto; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface UnlawfulMapper { |
| | | List<CategoryDto> getDataByType(Integer currentPage, Integer pageSize, String startTime, String endTime); |
| | | StatusDto getStatusDataByType(String startTime, String endTime, Integer dictionaryId); |
| | | |
| | | List<CategoryDto> getDataByTypeExp(); |
| | | |
| | | Integer getTotal(); |
| | | } |
New file |
| | |
| | | package com.ycl.service.unlawful; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ycl.dto.statistics.UnlawfulDto; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface UnlawfulService { |
| | | |
| | | public List<UnlawfulDto> getUnlawfulByType(Integer currentPage, Integer pageSize, String startTime, String endTime); |
| | | |
| | | public List<UnlawfulDto> getUnlawfulByTypeExport(); |
| | | } |
New file |
| | |
| | | package com.ycl.service.unlawful.impl; |
| | | |
| | | import com.ycl.dto.statistics.CategoryDto; |
| | | import com.ycl.dto.statistics.StatusDto; |
| | | import com.ycl.dto.statistics.UnlawfulDto; |
| | | import com.ycl.mapper.unlawful.UnlawfulMapper; |
| | | import com.ycl.service.unlawful.UnlawfulService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.RoundingMode; |
| | | import java.text.NumberFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.function.Consumer; |
| | | |
| | | @Service |
| | | public class UnlawfulServiceImpl implements UnlawfulService { |
| | | |
| | | @Resource |
| | | private UnlawfulMapper unlawfuldao; |
| | | |
| | | |
| | | @Override |
| | | public List<UnlawfulDto> getUnlawfulByType(Integer currentPage, Integer pageSize, String startTime, String endTime) { |
| | | List<UnlawfulDto> res = new ArrayList<>(); |
| | | Double total = unlawfuldao.getTotal().doubleValue(); |
| | | List<CategoryDto> data = unlawfuldao.getDataByType(currentPage, pageSize, startTime, endTime); |
| | | data.forEach(categoryDto -> { |
| | | Double checkedRatio; //审核率 |
| | | Double registerRatio; //立案率 |
| | | StatusDto statusData = unlawfuldao.getStatusDataByType(startTime, endTime, categoryDto.getId()); |
| | | UnlawfulDto build = new UnlawfulDto().builder().name(categoryDto.getName()) //类型名称 |
| | | .count(statusData.getTotal()) //事件总数 |
| | | .ratio(changeFormat(statusData.getTotal().doubleValue() / total)) //占比 |
| | | .register(statusData.getRegister()) //立案 |
| | | .notRegister(statusData.getNotRegister()) //暂不立案 |
| | | .closing(statusData.getClosing()) //结案 |
| | | .relearn(statusData.getRelearn()) //在学习 |
| | | .checked(statusData.getChecked()) //已审核 |
| | | .checkedRatio(changeFormat(statusData.getChecked().doubleValue() / statusData.getTotal().doubleValue())) //审核率 |
| | | .registerRatio(changeFormat(statusData.getRegister().doubleValue() / statusData.getTotal().doubleValue())) //立案率 |
| | | .build(); |
| | | res.add(build); |
| | | }); |
| | | return res; |
| | | } |
| | | |
| | | @Override |
| | | public List<UnlawfulDto> getUnlawfulByTypeExport() { |
| | | List<UnlawfulDto> res = new ArrayList<>(); |
| | | Double total = unlawfuldao.getTotal().doubleValue(); |
| | | List<CategoryDto> data = unlawfuldao.getDataByTypeExp(); |
| | | data.forEach(categoryDto -> { |
| | | Double checkedRatio; //审核率 |
| | | Double registerRatio; //立案率 |
| | | StatusDto statusData = unlawfuldao.getStatusDataByType(null, null, categoryDto.getId()); |
| | | UnlawfulDto build = new UnlawfulDto().builder().name(categoryDto.getName()) //类型名称 |
| | | .count(statusData.getTotal()) //事件总数 |
| | | .ratio(changeFormat(statusData.getTotal().doubleValue() / total)) //占比 |
| | | .register(statusData.getRegister()) //立案 |
| | | .notRegister(statusData.getNotRegister()) //暂不立案 |
| | | .closing(statusData.getClosing()) //结案 |
| | | .relearn(statusData.getRelearn()) //在学习 |
| | | .checked(statusData.getChecked()) //已审核 |
| | | .checkedRatio(changeFormat(statusData.getChecked().doubleValue() / statusData.getTotal().doubleValue())) //审核率 |
| | | .registerRatio(changeFormat(statusData.getRegister().doubleValue() / statusData.getTotal().doubleValue())) //立案率 |
| | | .build(); |
| | | res.add(build); |
| | | }); |
| | | return res; |
| | | } |
| | | |
| | | private Double changeFormat(Double previous){ |
| | | NumberFormat numberInstance = NumberFormat.getNumberInstance(); |
| | | numberInstance.setMaximumFractionDigits(2); |
| | | numberInstance.setRoundingMode(RoundingMode.HALF_UP); |
| | | String format = numberInstance.format(previous); |
| | | return Double.parseDouble(format); |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ycl.mapper.unlawful.UnlawfulMapper"> |
| | | <select id="getDataByType" resultType="com.ycl.dto.statistics.CategoryDto"> |
| | | SELECT |
| | | t4.id id, |
| | | t4.NAME name |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category =1 |
| | | and t4.`name` is NOT NULL |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | group by |
| | | t4.id |
| | | limit #{currentPage}, #{pageSize} |
| | | </select> |
| | | <select id="getStatusDataByType" resultType="com.ycl.dto.statistics.StatusDto"> |
| | | SELECT |
| | | count(1) total, |
| | | sum(case when ubc.state=5 then 1 else 0 end) register, |
| | | sum(case when ubc.state=4 then 1 else 0 end ) notRegister, |
| | | sum(case when ubc.state=9 then 1 else 0 end ) closing, |
| | | sum(case when ubc.state=3 then 1 else 0 end ) relearn, |
| | | sum(case when ubc.state=8 then 1 else 0 end ) checked |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category =1 |
| | | and t4.`id` = #{dictionaryId} |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | </select> |
| | | <select id="getTotal" resultType="java.lang.Integer"> |
| | | SELECT |
| | | count(*) |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category = 1 |
| | | AND t4.`name` IS NOT NULL |
| | | |
| | | </select> |
| | | <select id="getDataByTypeExp" resultType="com.ycl.dto.statistics.CategoryDto"> |
| | | SELECT |
| | | t4.id id, |
| | | t4.NAME name |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category =1 |
| | | and t4.`name` is NOT NULL |
| | | group by |
| | | t4.id |
| | | </select> |
| | | </mapper> |