Browse Source

信件三率统计

master
laishajiang 2 years ago
parent
commit
052bac741c
  1. 47
      mailbox-lan/src/main/java/com/biutag/lan/controller/DataController.java
  2. 19
      mailbox-lan/src/main/java/com/biutag/lan/controller/system/DeptController.java
  3. 46
      mailbox-lan/src/main/java/com/biutag/lan/domain/vo/DataVo.java
  4. 20
      mailbox-lan/src/main/java/com/biutag/lan/domain/vo/EasyDeptVO.java
  5. 24
      mailbox-lan/src/main/java/com/biutag/lan/mapper/DataMapper.java
  6. 85
      mailbox-lan/src/main/java/com/biutag/lan/service/DataService.java
  7. 30
      mailbox-lan/src/main/java/com/biutag/lan/validate/system/DataSearchValidate.java
  8. 185
      mailbox-lan/src/main/resources/mapper/DataMapper.xml

47
mailbox-lan/src/main/java/com/biutag/lan/controller/DataController.java

@ -0,0 +1,47 @@
package com.biutag.lan.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.aop.NotPower;
import com.biutag.core.AjaxResult;
import com.biutag.enums.RoleEnum;
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.flow.FlowNameEnum;
import com.biutag.lan.service.DataService;
import com.biutag.lan.service.NoticeService;
import com.biutag.lan.service.WorkService;
import com.biutag.lan.validate.system.DataSearchValidate;
import com.biutag.lan.validate.system.NoticeSearchValidate;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RequiredArgsConstructor
@RequestMapping("/api/data")
@RestController
public class DataController {
private final DataService dataService;
@NotPower
@GetMapping("list")
public AjaxResult<Page<Map<String, Object>>> list(Page page, @Validated DataSearchValidate searchValidate) {
Page<Map<String, Object>> list = dataService.list(page, searchValidate);
return AjaxResult.success(list);
}
}

19
mailbox-lan/src/main/java/com/biutag/lan/controller/system/DeptController.java

@ -5,6 +5,7 @@ import com.biutag.aop.NotPower;
import com.biutag.core.AjaxResult;
import com.biutag.entity.system.Dept;
import com.biutag.entity.system.Duty;
import com.biutag.lan.domain.vo.EasyDeptVO;
import com.biutag.lan.service.IDeptService;
import com.biutag.lan.validate.commons.IdValidate;
import com.biutag.lan.validate.system.DeptCreateValidate;
@ -18,6 +19,8 @@ import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -129,4 +132,20 @@ public class DeptController {
return AjaxResult.success(iDeptService.getDuty());
}
@NotPower
@GetMapping("/Easylist")
@ApiOperation(value="简易部门列表")
public AjaxResult<List<EasyDeptVO>> Easylist() {
List<EasyDeptVO> list = new ArrayList<>();
EasyDeptVO easyDeptVO1 = new EasyDeptVO();
easyDeptVO1.setId(1);
easyDeptVO1.setLabelName("市局");
list.add(easyDeptVO1);
EasyDeptVO easyDeptVO2 = new EasyDeptVO();
easyDeptVO2.setId(2);
easyDeptVO2.setLabelName("二级机构");
list.add(easyDeptVO2);
return AjaxResult.success(list);
}
}

46
mailbox-lan/src/main/java/com/biutag/lan/domain/vo/DataVo.java

@ -0,0 +1,46 @@
package com.biutag.lan.domain.vo;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Accessors(chain = true)
@Setter
@Getter
public class DataVo {
private static final long serialVersionUID = 1L;
private String cname;
private String cratenumber;
private String crate;
private String completed;
private String csum;
private String rname;
private String resolved;
private String rsum;
private String ratenumber;
private String rate;
private String sname;
private String satisfied;
private String sum;
private String sratenumber;
private String srate;
private String score;
}

20
mailbox-lan/src/main/java/com/biutag/lan/domain/vo/EasyDeptVO.java

@ -0,0 +1,20 @@
package com.biutag.lan.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("简易deptVO")
public class EasyDeptVO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Integer id;
@ApiModelProperty(value = "名称")
private String labelName;
}

24
mailbox-lan/src/main/java/com/biutag/lan/mapper/DataMapper.java

@ -0,0 +1,24 @@
package com.biutag.lan.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.entity.system.Duty;
import com.biutag.lan.domain.Mail;
import com.biutag.lan.domain.vo.DataVo;
import com.biutag.lan.domain.vo.MailDetail;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface DataMapper extends BaseMapper<Mail> {
List<Map<String, Object>> getFirstAllList(@Param("searchStartTime") String searchStartTime,@Param("searchEndTime") String searchEndTime);
List<Map<String, Object>> getSecondList(Page page,@Param("searchStartTime") String searchStartTime,@Param("searchEndTime") String searchEndTime);
List<Map<String, Object>> getThirdList(Page page,@Param("searchStartTime") String searchStartTime,@Param("searchEndTime") String searchEndTime,@Param("deptId") String deptId);
}

85
mailbox-lan/src/main/java/com/biutag/lan/service/DataService.java

@ -0,0 +1,85 @@
package com.biutag.lan.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.lan.domain.*;
import com.biutag.lan.domain.vo.DataVo;
import com.biutag.lan.domain.vo.NoticeVo;
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.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@RequiredArgsConstructor
@Service
public class DataService extends ServiceImpl<DataMapper, Mail> {
@Resource
private DataMapper dataMapper;
public Page<Map<String, Object>> list(Page page, @Validated DataSearchValidate searchValidate){
List<Map<String, Object>> combinedList = null;
List<Map<String, Object>> mapfirst = null;
List<Map<String, Object>> mapSecond = null;
List<Map<String, Object>> mapThird = null;
if (searchValidate.getEasydept()==null||!searchValidate.getEasydept().equals("2")){
if (searchValidate.getSearchTime()!=null){
mapfirst = dataMapper.getFirstAllList(searchValidate.getSearchStartTime(),searchValidate.getSearchEndTime());
mapSecond = dataMapper.getSecondList(page,searchValidate.getSearchStartTime(),searchValidate.getSearchEndTime());
}else {
mapfirst = dataMapper.getFirstAllList(null,null);
mapSecond = dataMapper.getSecondList(page,null,null);
}
combinedList = Stream.concat(mapfirst.stream(), mapSecond.stream())
.collect(Collectors.toList());
}else if (searchValidate.getEasydept()!=null&&searchValidate.getEasydept().equals("2")){
if (searchValidate.getSdept()!=null){
if (searchValidate.getSearchTime()!=null){
mapThird = dataMapper.getThirdList(page,searchValidate.getSearchStartTime(),searchValidate.getSearchEndTime(),searchValidate.getSdept());
}else {
mapThird = dataMapper.getThirdList(page,null,null,searchValidate.getSdept());
}
combinedList = mapThird;
}else{
if (searchValidate.getSearchTime()!=null){
mapfirst = dataMapper.getFirstAllList(searchValidate.getSearchStartTime(),searchValidate.getSearchEndTime());
mapSecond = dataMapper.getSecondList(page,searchValidate.getSearchStartTime(),searchValidate.getSearchEndTime());
}else {
mapfirst = dataMapper.getFirstAllList(null,null);
mapSecond = dataMapper.getSecondList(page,null,null);
}
combinedList = Stream.concat(mapfirst.stream(), mapSecond.stream())
.collect(Collectors.toList());
}
}
Page<Map<String, Object>> dataVoPage = new Page<>();
dataVoPage.setRecords(combinedList);
dataVoPage.setTotal(page.getTotal());
dataVoPage.setCurrent(page.getCurrent());
dataVoPage.setSize(page.getSize());
dataVoPage.setPages(page.getPages());
return dataVoPage;
}
}

30
mailbox-lan/src/main/java/com/biutag/lan/validate/system/DataSearchValidate.java

@ -0,0 +1,30 @@
package com.biutag.lan.validate.system;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("通知搜素参数")
public class DataSearchValidate implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "搜索时间")
private String searchTime;
@ApiModelProperty(value = "搜索时间")
private String searchStartTime;
@ApiModelProperty(value = "搜索时间")
private String searchEndTime;
@ApiModelProperty(value = "机构level")
private String easydept;
@ApiModelProperty(value = "二级机构id")
private String sdept;
}

185
mailbox-lan/src/main/resources/mapper/DataMapper.xml

@ -0,0 +1,185 @@
<?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.biutag.lan.mapper.DataMapper">
<select id="getSecondList" resultType="java.util.Map" parameterType="java.util.Map">
SELECT * , (cratenumber * 0.5 + sratenumber * 0.3 + ratenumber * 0.2) score FROM
(
(
select a.name cname,a.sort,
ROUND(sum(COALESCE(b.completed, 0))*100/count(1),0) crateNumber,
count(b.mail_id) total,
CONCAT(crateNumber,'%') crate,
SUM(COALESCE(b.completed, 0)) completed,count(1) csum
from dept a left join mail_mark b on a.id = b.second_dept_id
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>
where a.level = '2'
group by a.name,a.sort
order by crateNumber desc
) t1
join
(select t.name rname, t.resolved, t.sum rsum, CASE WHEN t.sum = 0 THEN 0 ELSE ROUND((t.resolved / t.sum) * 100) END AS rateNumber, concat(rateNumber, '%') rate
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.second_dept_id
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>
where a.level = '2'
group by a.name) t order by rateNumber desc
) t2 on t1.cname = t2.rname
) t3 JOIN
(
select a.name sname,
SUM(COALESCE(b.satisfied, 0)) satisfied,
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.second_dept_id
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>
where a.level = '2'
group by a.name
order by srateNumber desc
) t4 on t3.cname = t4.sname ORDER BY score desc ,sort
</select>
<select id="getFirstAllList" resultType="java.util.Map" >
SELECT *, (CAST(REPLACE(crate, '%', '') AS NUMERIC) * 0.5 +
CAST(REPLACE(srate, '%', '') AS NUMERIC) * 0.3 +
CAST(REPLACE(rate, '%', '') AS NUMERIC) * 0.2) AS score,'长沙市公安局' as cname FROM
(
(
select
ROUND(sum(COALESCE(b.completed, 0))*100/count(1),0) crateNumber,
CONCAT(ROUND(SUM(COALESCE(b.completed, 0))*100 / NULLIF(COUNT(1), 0),0),'%') AS cRate,
SUM(COALESCE(b.completed, 0)) AS completed,
COUNT(1) AS cSum,
(SELECT COUNT(*) FROM mail_mark b where 1=1
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>) AS total
from mail_mark b left join dept a on a.id=b.second_dept_id where 1=1
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>
) t1
join
(
select CONCAT(ROUND(sum(COALESCE(b.resolved, 0))*100/SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END),0),'%') Rate,
SUM(COALESCE(b.resolved, 0)) resolved,SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) rSum,
(SELECT COUNT(*) FROM mail_mark b where 1=1
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>) AS total
from mail_mark b left join dept a on a.id=b.second_dept_id where 1=1
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>
) t2 on t1.total = t2.total
) t3 JOIN
(
select
CONCAT(ROUND(SUM(COALESCE(b.satisfied, 0))*100 / NULLIF(SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END), 0),0),'%') AS sRate,
SUM(COALESCE(b.satisfied, 0)) AS satisfied,
SUM(CASE WHEN b.completed = '1' THEN 1 ELSE 0 END) AS Sum,
(SELECT COUNT(*) FROM mail_mark b where 1=1
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>) AS total
from mail_mark b left join dept a on a.id=b.second_dept_id where 1=1
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>
) t4 on t3.total = t4.total
</select>
<select id="getThirdList" resultType="java.util.Map" parameterType="java.util.Map">
SELECT * , (cratenumber * 0.5 + sratenumber * 0.3 + ratenumber * 0.2) score FROM
(
(
select a.name cname,a.sort,
ROUND(sum(COALESCE(b.completed, 0))*100/count(1),0) crateNumber,
count(b.mail_id) total,
CONCAT(crateNumber,'%') crate,
SUM(COALESCE(b.completed, 0)) completed,count(1) csum
from dept a left join mail_mark b on a.id = b.second_dept_id
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>
where a.level = '3'
<if test="deptId != null">
and a.pid = #{deptId} or a.id = #{deptId}
</if>
group by a.name,a.sort
order by crateNumber desc
) t1
join
(select t.name rname, t.resolved, t.sum rsum, CASE WHEN t.sum = 0 THEN 0 ELSE ROUND((t.resolved / t.sum) * 100) END AS rateNumber, concat(rateNumber, '%') rate
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.second_dept_id
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>
where a.level = '3'
<if test="deptId != null">
and a.pid = #{deptId} or a.id = #{deptId}
</if>
group by a.name) t order by rateNumber desc
) t2 on t1.cname = t2.rname
) t3 JOIN
(
select a.name sname,
SUM(COALESCE(b.satisfied, 0)) satisfied,
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.second_dept_id
<if test="searchStartTime != null and searchEndTime != null">
AND b.completion_time BETWEEN #{searchStartTime} AND (to_date(#{searchEndTime}) + interval '1 D')
</if>
where a.level = '3'
<if test="deptId != null">
and a.pid = #{deptId} or a.id = #{deptId}
</if>
group by a.name
order by srateNumber desc
) t4 on t3.cname = t4.sname ORDER BY score desc ,sort
</select>
</mapper>
Loading…
Cancel
Save