diff --git a/mailbox-lan/src/main/java/com/biutag/lan/controller/DataController.java b/mailbox-lan/src/main/java/com/biutag/lan/controller/DataController.java index ced620c..7114403 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/controller/DataController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/controller/DataController.java @@ -10,10 +10,7 @@ import com.biutag.lan.config.AdminThreadLocal; import com.biutag.lan.domain.Notice; import com.biutag.lan.domain.Work; import com.biutag.lan.domain.bo.MailQuery; -import com.biutag.lan.domain.vo.DataVo; -import com.biutag.lan.domain.vo.NoticeTotalVo; -import com.biutag.lan.domain.vo.NoticeVo; -import com.biutag.lan.domain.vo.WorkVo; +import com.biutag.lan.domain.vo.*; import com.biutag.lan.flow.FlowNameEnum; import com.biutag.lan.service.DataService; import com.biutag.lan.service.NoticeService; @@ -26,6 +23,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; import java.util.Map; @RequiredArgsConstructor @@ -44,4 +42,11 @@ public class DataController { return AjaxResult.success(list); } + @NotPower + @GetMapping("listForCategory") + public AjaxResult> > listForCategory(Page page, @Validated DataSearchValidate searchValidate) { + Page> list = dataService.listForCategory(page, searchValidate); + return AjaxResult.success(list); + } + } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/mapper/DataMapper.java b/mailbox-lan/src/main/java/com/biutag/lan/mapper/DataMapper.java index 6e89037..4bbe656 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/mapper/DataMapper.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/mapper/DataMapper.java @@ -20,5 +20,12 @@ public interface DataMapper extends BaseMapper { List> getThirdList(Page page,@Param("searchStartTime") String searchStartTime,@Param("searchEndTime") String searchEndTime,@Param("deptId") String deptId); + List> selectMailCategoryWithCount(@Param("dept_level") String dept_level,@Param("deptId") String deptId,@Param("deptName") String deptName); + + List> selectMailFirstCategoryWithCount(); + + List> selectMailThreeCategoryWithCount(@Param("dept_level") String dept_level,@Param("deptId") String deptId,@Param("deptName") String deptName); + + } diff --git a/mailbox-lan/src/main/java/com/biutag/lan/service/DataService.java b/mailbox-lan/src/main/java/com/biutag/lan/service/DataService.java index beb5de0..63a3ec6 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/service/DataService.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/service/DataService.java @@ -1,26 +1,21 @@ package com.biutag.lan.service; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.biutag.constants.AppConstants; -import com.biutag.enums.RoleEnum; -import com.biutag.lan.config.AdminThreadLocal; +import com.biutag.entity.system.Dept; import com.biutag.lan.domain.*; -import com.biutag.lan.domain.vo.DataVo; -import com.biutag.lan.domain.vo.NoticeVo; +import com.biutag.lan.domain.vo.DataCategoryVo; import com.biutag.lan.mapper.*; import com.biutag.lan.validate.system.DataSearchValidate; -import com.biutag.lan.validate.system.NoticeSearchValidate; -import com.biutag.mapper.setting.DictDataMapper; import com.biutag.mapper.system.DeptMapper; import jakarta.annotation.Resource; import lombok.RequiredArgsConstructor; -import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import java.time.format.DateTimeFormatter; -import java.util.LinkedList; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -31,11 +26,12 @@ import java.util.stream.Stream; @Service public class DataService extends ServiceImpl { - - + @Resource + private MailCategoryMapper mailCategoryMapper; @Resource private DataMapper dataMapper; - + @Resource + private DeptMapper deptMapper; public Page> list(Page page, @Validated DataSearchValidate searchValidate){ List> combinedList = null; List> mapfirst = null; @@ -84,5 +80,115 @@ public class DataService extends ServiceImpl { } + public Page> listForCategory(Page page, DataSearchValidate searchValidate) { + List deptslist = null; + List> list = new ArrayList<>(); + if (searchValidate.getEasydept()==null||searchValidate.getEasydept().equals("1")){ + List> categorylist = baseMapper.selectMailFirstCategoryWithCount(); + int keycount = 1; + Map map = new HashMap<>(); + for (Map item :categorylist){ + System.out.println(item); + map.put("countrate"+keycount,item.get("countrate")); + map.put("sumcount"+keycount,item.get("sumcount")); + map.put("name"+keycount,item.get("name")); + map.put("second_dept_name"+keycount,item.get("second_dept_name")); + map.put("allcount"+keycount,item.get("allcount")); + keycount++; + } + list.add(map); + Wrapper wrapper2 = new QueryWrapper<>().eq("level",2); + deptslist = deptMapper.selectPage(page,wrapper2).getRecords(); + for(Dept deptItem :deptslist){ + List> categorylistforsecond = baseMapper.selectMailCategoryWithCount(searchValidate.getEasydept(),deptItem.getId().toString(),deptItem.getName()); + int count = 1; + Map mapforsecond = new HashMap<>(); + for (Map item :categorylistforsecond){ + System.out.println(item); + mapforsecond.put("countrate"+count,item.get("countrate")); + mapforsecond.put("sumcount"+count,item.get("sumcount")); + mapforsecond.put("name"+count,item.get("name")); + mapforsecond.put("second_dept_name"+count,item.get("second_dept_name")); + mapforsecond.put("allcount"+count,item.get("allcount")); + count++; + } + list.add(mapforsecond); + } + + }else if (searchValidate.getEasydept().equals("2")){ + if (searchValidate.getSdept()==null){ + Wrapper wrapper2 = new QueryWrapper<>().eq("level",2); + deptslist = deptMapper.selectPage(page,wrapper2).getRecords(); + for(Dept deptItem :deptslist){ + List> categorylist = baseMapper.selectMailCategoryWithCount(searchValidate.getEasydept(),deptItem.getId().toString(),deptItem.getName()); + int count = 1; + Map map = new HashMap<>(); + for (Map item :categorylist){ + System.out.println(item); + map.put("countrate"+count,item.get("countrate")); + map.put("sumcount"+count,item.get("sumcount")); + map.put("name"+count,item.get("name")); + map.put("second_dept_name"+count,item.get("second_dept_name")); + map.put("allcount"+count,item.get("allcount")); + count++; + } + list.add(map); + } + + }else{ + Wrapper wrapper2 = new QueryWrapper<>().eq("level",2).eq("id",searchValidate.getSdept()); + deptslist = deptMapper.selectPage(page,wrapper2).getRecords(); + for(Dept deptItem :deptslist){ + List> categorylist = baseMapper.selectMailCategoryWithCount(searchValidate.getEasydept(),deptItem.getId().toString(),deptItem.getName()); + int count = 1; + Map map = new HashMap<>(); + for (Map item :categorylist){ + System.out.println(item); + map.put("countrate"+count,item.get("countrate")); + map.put("sumcount"+count,item.get("sumcount")); + map.put("name"+count,item.get("name")); + map.put("second_dept_name"+count,item.get("second_dept_name")); + map.put("allcount"+count,item.get("allcount")); + count++; + } + list.add(map); + } + Wrapper wrapper3 = new QueryWrapper<>().eq("level",3).eq("pid",searchValidate.getSdept()); + deptslist = deptMapper.selectPage(page,wrapper3).getRecords(); + for(Dept deptItem :deptslist){ + List> categorylist = baseMapper.selectMailThreeCategoryWithCount(searchValidate.getEasydept(),deptItem.getId().toString(),deptItem.getName()); + int count = 1; + Map map = new HashMap<>(); + for (Map item :categorylist){ + System.out.println(item); + map.put("countrate"+count,item.get("countrate")); + map.put("sumcount"+count,item.get("sumcount")); + map.put("name"+count,item.get("name")); + map.put("second_dept_name"+count,item.get("second_dept_name")); + map.put("allcount"+count,item.get("allcount")); + count++; + } + list.add(map); + } + + + + + + + + + } + } + Page> dataVoPage = new Page<>(); + dataVoPage.setRecords(list); + dataVoPage.setTotal(page.getTotal()); + dataVoPage.setCurrent(page.getCurrent()); + dataVoPage.setSize(page.getSize()); + dataVoPage.setPages(page.getPages()); + return dataVoPage; + + + } } \ No newline at end of file diff --git a/mailbox-lan/src/main/resources/mapper/DataMapper.xml b/mailbox-lan/src/main/resources/mapper/DataMapper.xml index cad4516..369079f 100644 --- a/mailbox-lan/src/main/resources/mapper/DataMapper.xml +++ b/mailbox-lan/src/main/resources/mapper/DataMapper.xml @@ -16,14 +16,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from dept a left join mail_mark b on a.id = b.second_dept_id - AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D') + AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime} where a.level = '2' - - and a.id = #{deptId} - - group by a.name,a.sort + + group by a.name,a.sort order by crateNumber desc ) t1 join @@ -34,13 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) sum from dept a left join mail_mark b on a.id = b.second_dept_id - AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D') + AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime} where a.level = '2' - - and a.id = #{deptId} - + group by a.name) t order by rateNumber desc ) t2 on t1.cname = t2.rname @@ -55,13 +51,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" CONCAT(srateNumber,'%') srate from dept a left join mail_mark b on a.id = b.second_dept_id - AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D') + AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime} where a.level = '2' - - and a.id = #{deptId} - + group by a.name order by srateNumber desc ) t4 on t3.cname = t4.sname ORDER BY score desc ,sort @@ -70,58 +64,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -135,15 +129,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" CONCAT(crateNumber,'%') crate, SUM(COALESCE(b.completed, 0)) completed,count(1) csum - from dept a left join mail_mark b on a.id = b.three_dept_id + from dept a left join mail_mark b on a.id = b.second_dept_id - AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D') + AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime} where a.level = '3' - and a.pid = #{deptId} + and a.pid = #{deptId} or a.id = #{deptId} group by a.name,a.sort order by crateNumber desc @@ -154,14 +148,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from (select a.name, SUM(COALESCE(b.resolved, 0)) resolved, SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) sum - from dept a left join mail_mark b on a.id = b.three_dept_id + from dept a left join mail_mark b on a.id = b.second_dept_id - AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D') + AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime} where a.level = '3' - and a.pid = #{deptId} + and a.pid = #{deptId} or a.id = #{deptId} group by a.name) t order by rateNumber desc @@ -175,17 +169,87 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) sum, CASE WHEN sum = 0 THEN 0 ELSE ROUND(sum(COALESCE(b.satisfied, 0))*100/sum,0) END srateNumber, CONCAT(srateNumber,'%') srate - from dept a left join mail_mark b on a.id = b.three_dept_id + from dept a left join mail_mark b on a.id = b.second_dept_id - AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D') + AND b.completion_time BETWEEN #{searchStartTime} AND #{searchEndTime} where a.level = '3' - and a.pid = #{deptId} + and a.pid = #{deptId} or a.id = #{deptId} group by a.name order by srateNumber desc ) t4 on t3.cname = t4.sname ORDER BY score desc ,sort + + + + + + + + + + + + +