package com.example.demo.controller; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.example.demo.constant.DapingCache; import com.example.demo.constant.Log; import com.example.demo.domain.TsjbData; import com.example.demo.domain.TsjbDataAudit; import com.example.demo.domain.TsjbJubao; import com.example.demo.domain.TsjbShuqiu; import com.example.demo.domain.TsjbZongju; import com.example.demo.entity.TongJi.TouSuJuBaoLv; import com.example.demo.entity.enums.BusinessType; import com.example.demo.entity.request.AllQuery; import com.example.demo.entity.vo.MonthTimeVo; import com.example.demo.mapper.ClickhouseDockerMapper; import com.example.demo.mapper.ShipinshengchanxukeqiyeMapper; import com.example.demo.mapper.TsjbDataMapper; import com.example.demo.service.TsjbDataService; import com.example.demo.service.TsjbJubaoService; import com.example.demo.service.TsjbShuqiuService; import com.example.demo.service.TsjbZongjuService; import com.example.demo.service.impl.DataProcessService; import com.example.demo.util.CacheJob; import com.example.demo.util.R; import com.example.demo.util.TimeUtil; import com.example.demo.util.ZR; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; /** * @author zhuyuchen * @date 2023/10/31 14:45 * @description : 投诉举报 控制层 */ @Slf4j @CrossOrigin @RestController @RequestMapping("/TSJB") @Api(tags = "投诉举报") public class TSJBController { @Resource private DataProcessService processService; @Resource private TsjbJubaoService tsjbJubaoService; @Resource private TsjbShuqiuService tsjbShuqiuService; @Resource private TsjbZongjuService tsjbZongjuService; @Resource private TsjbDataMapper tsjbDataMapper; @Resource private ClickhouseDockerMapper clickhouseDockerMapper; @Resource private TsjbDataService tsjbDataService; @Resource private ShipinshengchanxukeqiyeMapper shipinshengchanxukeqiyeMapper; @Resource private ObjectMapper objectMapper; @Resource private CacheJob cacheJob; @ApiOperation(value = "统计模块-投诉举报-查看投诉率") @GetMapping("/GetTouSuLv") public ZR> GetTouSuLv(String wherestr) { AllQuery allQuery = JSONUtil.toBean(wherestr, AllQuery.class); MonthTimeVo timeByMonth = TimeUtil.getTimeByMonth(allQuery.rwnf, allQuery.getMonth(), allQuery.getMonth(), TimeUtil.FORMAT_1); return tsjbDataService.GetTouSuLv(timeByMonth.getStartTime(), timeByMonth.getEndTime(), allQuery.getHj(), allQuery.getSzqx() ); } @ApiOperation(value = "初始化全部的clickhouse表格到docker的clickhouse库") @GetMapping("/initClickhouse") public R initClickhouse() { List clickhouseTableSQLList = tsjbDataMapper.getClickhouseTableSQL(); for (String clickhouseTableSQL : clickhouseTableSQLList) { clickhouseDockerMapper.createClickhouseTable(clickhouseTableSQL); } return R.success(); } @GetMapping("/touSuLvExport") @ApiOperation(value = "投诉相关结果导出") @Log(title = "投诉相关结果导出", businessType = BusinessType.EXPORT) public void touSuLvExport(String wherestr, HttpServletResponse response) { AllQuery allQuery = JSONUtil.toBean(wherestr, AllQuery.class); MonthTimeVo timeByMonth = TimeUtil.getTimeByMonth(allQuery.rwnf, allQuery.getMonth(), allQuery.getMonth(), TimeUtil.FORMAT_1); tsjbDataService.getTouSuLvExport(timeByMonth.getStartTime(), timeByMonth.getEndTime(), allQuery.getHj(), allQuery.getSzqx(), response ); } @PostMapping("/UpdateData") @ApiOperation(value = "数据审核") @Log(title = "数据审核", businessType = BusinessType.UPDATE) public Object UpdateData(@RequestBody TsjbDataAudit tsjbDataAudit) throws JsonProcessingException { return tsjbDataService.updateData(tsjbDataAudit); } @GetMapping("/selectAuditCount") @ApiOperation(value = "审核总量查询") public R selectAuditCount(String auditName) { return R.success(tsjbDataService.selectAuditCount(auditName)); } @PostMapping("/UpdateDataPending") @ApiOperation(value = "待定状态更新") @Log(title = "待定状态更新", businessType = BusinessType.UPDATE) public void UpdateDataPending(@RequestBody TsjbDataAudit tsjbDataAudit) { tsjbDataService.updateDataPending(tsjbDataAudit); } @GetMapping("/GetTouSuLvDaPing") @ApiOperation(value = "投诉举报(大屏演示)") @Log(title = "投诉举报(大屏演示)", businessType = BusinessType.SELECT) @DapingCache(isEnableCache = true) public ZR> GetTouSuLvDaPing(String hj, String szqx, String month) { // String userName = BaseContext.getUserName(); // if (Tools.isNotEmpty(userName) && userName.contains("区")) { // szqx = userName; // } String startMonth = ObjectUtils.isEmpty(month) ? "1" : month; String endMonth = ObjectUtils.isEmpty(month) ? "12" : month; //开始时间不用 String start = "2023/" + startMonth + "/1"; String end = "2023/" + endMonth + "/31"; return tsjbDataService.getTouSuLvDaPing(start, end, hj, szqx); } @GetMapping("/GetTouSuLvDaPingStreet") @ApiOperation(value = "投诉举报(大屏演示)街道") @Log(title = "投诉举报(大屏)街道", businessType = BusinessType.SELECT) @DapingCache(isEnableCache = true) public ZR> GetTouSuLvDaPingStreet(String hj, String szqx, String month,String street) { String startMonth = ObjectUtils.isEmpty(month) ? "1" : month; String endMonth = ObjectUtils.isEmpty(month) ? "12" : month; //开始时间不用 String start = "2023/" + startMonth + "/1"; String end = "2023/" + endMonth + "/31"; return tsjbDataService.getTouSuLvDaPingStreet(start, end, hj, szqx,street); } @GetMapping("/GetTouSuLvDaPingStreetDasai") @ApiOperation(value = "投诉举报(大屏演示)街道") @Log(title = "投诉举报(大屏)街道", businessType = BusinessType.SELECT) @DapingCache(isEnableCache = true) public ZR> GetTouSuLvDaPingStreetDasai(String hj, String szqx, String month,String street, int littlemonth) { if("上海市".equals(szqx)){ szqx = null; } String startMonth = ObjectUtils.isEmpty(month) ? "1" : month; String endMonth = ObjectUtils.isEmpty(month) ? "12" : month; //开始时间不用 String start = "2023/" + startMonth + "/1"; String end = "2023/" + endMonth + "/31"; return tsjbDataService.getTouSuLvDaPingStreet(start, end, hj, szqx,street,littlemonth); } //投诉举报 @GetMapping("/GetScoreByHuanJie") @Log(title = "投诉举报根据环节获取成绩", businessType = BusinessType.SELECT) @DapingCache(isEnableCache = true) public Object GetScoreByHuanJie(String szqx, String month) { String startMonth = ObjectUtils.isEmpty(month) ? "1" : month; String endMonth = ObjectUtils.isEmpty(month) ? "12" : month; //开始时间不用 String start = "2023/" + startMonth + "/1"; String end = "2023/" + endMonth + "/31"; return tsjbDataService.getScoreByHuanJie(szqx, start, end); } //投诉举报各区的成绩 @GetMapping("/GetScoreByQu") public Object GetScoreByDQ() throws JsonProcessingException { return tsjbDataService.getScoreByQu(); } @GetMapping("/exportByHuanJie") public void exportByHuanJie(HttpServletResponse response, String wherestr) { AllQuery AllQuery = JSONUtil.toBean(wherestr, AllQuery.class); tsjbDataService.exportByHuanJie(response, AllQuery.getStartTime(), AllQuery.getEndTime(), AllQuery.getHj(), AllQuery.getSzqx()); } @GetMapping("/YPLB/test") public void text() throws Exception { tsjbJubaoService.updataStatus(); tsjbShuqiuService.updataStatus(); tsjbZongjuService.updataStatus(); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.last("limit 100"); List list = tsjbJubaoService.list(queryWrapper); QueryWrapper queryWrapper2 = new QueryWrapper<>(); queryWrapper2.last("limit 100"); List list2 = tsjbShuqiuService.list(queryWrapper2); QueryWrapper queryWrapper3 = new QueryWrapper<>(); queryWrapper3.last("limit 100"); List list3 = tsjbZongjuService.list(queryWrapper3); System.out.println("list3 = " + list3); QueryWrapper queryWrapper4 = new QueryWrapper<>(); queryWrapper4.last("limit 100"); List list1 = tsjbDataService.list(queryWrapper4); } @GetMapping("/init") @ApiOperation(value = "初始化python缓存") public void init() throws Exception { processService.init(); } @GetMapping("/clean") @ApiOperation(value = "清空python缓存") public void clean() throws Exception { processService.clean(); } @GetMapping("/job") public R job() throws Exception { // cacheJob.cacheZSUpdateJob(); cacheJob.cacheUpdateJob(); return R.success(); } // 测试 @GetMapping("/cleanTest") public R cleanTest() { Page pageable = Page.of(1, 10, false); Page page = tsjbDataService.page(pageable); tsjbDataService.saveBatch(page.getRecords()); return R.success(); } // 测试 @GetMapping("/cleanJuBaoTest") public R cleanJuBaoTest() throws Exception { tsjbDataService.cleanJuBaoTest(); return R.success(); } @GetMapping("/cleanShuQiu") public R cleanShuQiu() throws Exception { tsjbDataService.cleanShuQiu(); return R.success(); } @GetMapping("/cleanJuBao") public R cleanJuBao() throws Exception { tsjbDataService.cleanJuBao(); return R.success(); } @GetMapping("/cleanZongJu") public R cleanZongJu() throws Exception { tsjbDataService.cleanZongJu(); return R.success(); } @GetMapping("/page") public Object page(String wherestr, int page, int limit) { page = page / limit + 1; return R.success(tsjbDataService.pageTsjb(wherestr, page, limit)); } @GetMapping("/export") public void export(HttpServletResponse response, String wherestr, String page, String limit) { tsjbDataService.export(response, wherestr, Integer.parseInt(page), Integer.parseInt(limit)); } @PostMapping("/Import") public void Import(MultipartFile file) throws IOException { tsjbDataService.Import(file); } }