forked from luyan/epmet-cloud-lingshan
19 changed files with 620 additions and 0 deletions
@ -0,0 +1,12 @@ |
|||
package com.epmet.group.constant; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 15:24 |
|||
*/ |
|||
public interface GroupConstant { |
|||
|
|||
String MONTH = "month"; |
|||
String DATE = "date"; |
|||
|
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.epmet.group.dto.form; |
|||
|
|||
import lombok.Data; |
|||
import lombok.NonNull; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 12:07 |
|||
*/ |
|||
@Data |
|||
public class GroupIncrTrendFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1788937450915240575L; |
|||
|
|||
public interface GroupJava {} |
|||
|
|||
/** |
|||
* 类型 month:月 date:日 |
|||
*/ |
|||
@NotBlank(message = "type不能为空", groups = {GroupJava.class}) |
|||
private String type; |
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.epmet.group.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 14:30 |
|||
*/ |
|||
@Data |
|||
public class GridInfoResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 5301902590768338888L; |
|||
|
|||
/** |
|||
* 网格id |
|||
*/ |
|||
private String gridId; |
|||
|
|||
/** |
|||
* 网格名称 |
|||
*/ |
|||
private String gridName; |
|||
} |
@ -0,0 +1,30 @@ |
|||
package com.epmet.group.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 12:03 |
|||
*/ |
|||
@Data |
|||
public class GroupIncrTrendResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 5132636251609157706L; |
|||
|
|||
/** |
|||
* 日期 |
|||
*/ |
|||
private String date; |
|||
|
|||
/** |
|||
* 值 【小组数量】 |
|||
*/ |
|||
private Integer value; |
|||
|
|||
/** |
|||
* 类型 【小组数量】 |
|||
*/ |
|||
private String type; |
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.epmet.group.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 11:56 |
|||
* 网格小组——下级机关小组数柱状图 |
|||
*/ |
|||
@Data |
|||
public class GroupSubAgencyResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 8562403482616167221L; |
|||
|
|||
/** |
|||
* 名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 值 |
|||
*/ |
|||
private Integer value; |
|||
|
|||
/** |
|||
* 类型 |
|||
*/ |
|||
private String type; |
|||
|
|||
/** |
|||
* 机关ID |
|||
*/ |
|||
private String agencyId; |
|||
|
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.epmet.group.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 11:56 |
|||
* 网格小组——下级机关小组数柱状图 |
|||
*/ |
|||
@Data |
|||
public class GroupSubGridResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -3260124064513560994L; |
|||
|
|||
/** |
|||
* 名称 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 值 |
|||
*/ |
|||
private Integer value; |
|||
|
|||
/** |
|||
* 类型 |
|||
*/ |
|||
private String type; |
|||
|
|||
/** |
|||
* 机关ID |
|||
*/ |
|||
private String gridId; |
|||
|
|||
} |
@ -0,0 +1,40 @@ |
|||
package com.epmet.group.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 11:05 |
|||
*/ |
|||
@Data |
|||
public class GroupSummaryInfoResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 8529179932504931368L; |
|||
|
|||
/** |
|||
* 网格总数量 |
|||
*/ |
|||
private Integer gridTotalCount; |
|||
|
|||
/** |
|||
* 小组总数量 |
|||
*/ |
|||
private Integer groupTotalCount; |
|||
|
|||
/** |
|||
* 小组平均人数 |
|||
*/ |
|||
private Integer groupPeopleAvg; |
|||
|
|||
/** |
|||
* 小组人数中位数 |
|||
*/ |
|||
private Integer groupPeopleMedian; |
|||
|
|||
/** |
|||
* 数据更新至 时间 |
|||
*/ |
|||
private String deadline; |
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.epmet.group.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 14:02 |
|||
*/ |
|||
@Data |
|||
public class SubAgencyResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 2276056225590553307L; |
|||
|
|||
/** |
|||
* 机关ID |
|||
*/ |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* 机关名称 |
|||
*/ |
|||
private String agencyName; |
|||
} |
@ -0,0 +1,74 @@ |
|||
package com.epmet.module.group.controller; |
|||
|
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.group.dto.form.GroupIncrTrendFormDTO; |
|||
import com.epmet.group.dto.result.GroupIncrTrendResultDTO; |
|||
import com.epmet.group.dto.result.GroupSubAgencyResultDTO; |
|||
import com.epmet.group.dto.result.GroupSubGridResultDTO; |
|||
import com.epmet.group.dto.result.GroupSummaryInfoResultDTO; |
|||
import com.epmet.module.group.service.GroupService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
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 java.util.List; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 10:54 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("group") |
|||
public class GroupController { |
|||
|
|||
@Autowired |
|||
private GroupService groupService; |
|||
|
|||
/** |
|||
* @Description 网格小组:网格总数、网格小组数、小组平均数、小组人数中位数 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
@PostMapping("summaryinfo") |
|||
public Result<GroupSummaryInfoResultDTO> summaryInfo(@LoginUser TokenDto tokenDto){ |
|||
return new Result<GroupSummaryInfoResultDTO>().ok(groupService.summaryInfo(tokenDto)); |
|||
} |
|||
|
|||
/** |
|||
* @Description 网格小组——下级机关小组数柱状图 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
@PostMapping("subagency") |
|||
public Result<List<GroupSubAgencyResultDTO>> subAgency(@LoginUser TokenDto tokenDto){ |
|||
return new Result<List<GroupSubAgencyResultDTO>>().ok(groupService.subAgency(tokenDto)); |
|||
} |
|||
|
|||
/** |
|||
* @Description 网格小组——直属网格小组数 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
@PostMapping("subgrid") |
|||
public Result<List<GroupSubGridResultDTO>> subGrid(@LoginUser TokenDto tokenDto){ |
|||
return new Result<List<GroupSubGridResultDTO>>().ok(groupService.subGrid(tokenDto)); |
|||
} |
|||
|
|||
/** |
|||
* @Description 网格小组——小组分析 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
@PostMapping("incrtrend") |
|||
public Result<List<GroupIncrTrendResultDTO>> IncrTrend(@LoginUser TokenDto tokenDto, @RequestBody GroupIncrTrendFormDTO formDTO){ |
|||
ValidatorUtils.validateEntity(formDTO, GroupIncrTrendFormDTO.GroupJava.class); |
|||
return new Result<List<GroupIncrTrendResultDTO>>().ok(groupService.IncrTrend(tokenDto,formDTO)); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,58 @@ |
|||
package com.epmet.module.group.dao; |
|||
|
|||
import com.epmet.group.dto.result.*; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 10:55 |
|||
*/ |
|||
@Mapper |
|||
public interface GroupDao { |
|||
|
|||
/** |
|||
* @Description 网格小组:网格总数、网格小组数、小组平均数、小组人数中位数 |
|||
* @param |
|||
* @author zxc |
|||
*/ |
|||
GroupSummaryInfoResultDTO summaryInfo(@Param("agencyId") String agencyId); |
|||
|
|||
/** |
|||
* @Description 获取下级机关信息 |
|||
* @param agencyId |
|||
* @author zxc |
|||
*/ |
|||
List<SubAgencyResultDTO> getSubAgencyList(@Param("agencyId") String agencyId); |
|||
|
|||
/** |
|||
* @Description 获取下级机关的小组数 |
|||
* @param |
|||
* @author zxc |
|||
*/ |
|||
List<GroupSubAgencyResultDTO> getSubGroupCount(); |
|||
|
|||
/** |
|||
* @Description 获取直属网格下的小组数 |
|||
* @param agencyId |
|||
* @author zxc |
|||
*/ |
|||
List<GroupSubGridResultDTO> getSubGridGroupCount(@Param("agencyId") String agencyId); |
|||
|
|||
/** |
|||
* @Description 小组数量 日增长 |
|||
* @param agencyId |
|||
* @author zxc |
|||
*/ |
|||
List<GroupIncrTrendResultDTO> getIncrDaily(@Param("agencyId") String agencyId); |
|||
|
|||
/** |
|||
* @Description 小组数量 月增长 |
|||
* @param agencyId |
|||
* @author zxc |
|||
*/ |
|||
List<GroupIncrTrendResultDTO> getIncrMonthly(@Param("agencyId") String agencyId); |
|||
|
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.epmet.module.group.service; |
|||
|
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.group.dto.form.GroupIncrTrendFormDTO; |
|||
import com.epmet.group.dto.result.GroupIncrTrendResultDTO; |
|||
import com.epmet.group.dto.result.GroupSubAgencyResultDTO; |
|||
import com.epmet.group.dto.result.GroupSubGridResultDTO; |
|||
import com.epmet.group.dto.result.GroupSummaryInfoResultDTO; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 10:55 |
|||
*/ |
|||
public interface GroupService { |
|||
|
|||
/** |
|||
* @Description 网格小组:网格总数、网格小组数、小组平均数、小组人数中位数 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
GroupSummaryInfoResultDTO summaryInfo(TokenDto tokenDto); |
|||
|
|||
/** |
|||
* @Description 网格小组——下级机关小组数柱状图 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
List<GroupSubAgencyResultDTO> subAgency(TokenDto tokenDto); |
|||
|
|||
/** |
|||
* @Description 网格小组——直属网格小组数 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
List<GroupSubGridResultDTO> subGrid(TokenDto tokenDto); |
|||
|
|||
/** |
|||
* @Description 网格小组——小组分析 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
List<GroupIncrTrendResultDTO> IncrTrend(TokenDto tokenDto, GroupIncrTrendFormDTO formDTO); |
|||
} |
@ -0,0 +1,107 @@ |
|||
package com.epmet.module.group.service.impl; |
|||
|
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.dto.form.LoginUserDetailsFormDTO; |
|||
import com.epmet.dto.result.LoginUserDetailsResultDTO; |
|||
import com.epmet.feign.EpmetUserOpenFeignClient; |
|||
import com.epmet.group.constant.GroupConstant; |
|||
import com.epmet.group.dto.form.GroupIncrTrendFormDTO; |
|||
import com.epmet.group.dto.result.*; |
|||
import com.epmet.module.group.dao.GroupDao; |
|||
import com.epmet.module.group.service.GroupService; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @CreateTime 2020/6/20 10:56 |
|||
*/ |
|||
@Service |
|||
public class GroupServiceImpl implements GroupService { |
|||
|
|||
@Autowired |
|||
private GroupDao groupDao; |
|||
@Autowired |
|||
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|||
|
|||
/** |
|||
* @Description 网格小组:网格总数、网格小组数、小组平均数、小组人数中位数 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
@Override |
|||
public GroupSummaryInfoResultDTO summaryInfo(TokenDto tokenDto) { |
|||
String agencyId = this.getLoginUserDetails(tokenDto); |
|||
return groupDao.summaryInfo(agencyId); |
|||
} |
|||
|
|||
/** |
|||
* @Description 网格小组——下级机关小组数柱状图 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
@Override |
|||
public List<GroupSubAgencyResultDTO> subAgency(TokenDto tokenDto) { |
|||
String agencyId = this.getLoginUserDetails(tokenDto); |
|||
List<GroupSubAgencyResultDTO> result = new ArrayList<>(); |
|||
List<SubAgencyResultDTO> subAgencyList = groupDao.getSubAgencyList(agencyId); |
|||
List<GroupSubAgencyResultDTO> subGroupCount = groupDao.getSubGroupCount(); |
|||
if (subAgencyList.size()!= NumConstant.ZERO){ |
|||
subGroupCount.forEach(group -> { |
|||
subAgencyList.forEach(subAgency -> { |
|||
if (subAgency.getAgencyId().equals(group.getAgencyId())){ |
|||
group.setName(subAgency.getAgencyName()); |
|||
result.add(group); |
|||
} |
|||
}); |
|||
}); |
|||
return result; |
|||
} |
|||
return new ArrayList<>(); |
|||
} |
|||
|
|||
/** |
|||
* @Description 网格小组——直属网格小组数 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
@Override |
|||
public List<GroupSubGridResultDTO> subGrid(TokenDto tokenDto) { |
|||
String agencyId = this.getLoginUserDetails(tokenDto); |
|||
return groupDao.getSubGridGroupCount(agencyId); |
|||
} |
|||
|
|||
/** |
|||
* @Description 网格小组——小组分析 |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
@Override |
|||
public List<GroupIncrTrendResultDTO> IncrTrend(TokenDto tokenDto, GroupIncrTrendFormDTO formDTO) { |
|||
String agencyId = this.getLoginUserDetails(tokenDto); |
|||
List<GroupIncrTrendResultDTO> result = new ArrayList<>(); |
|||
if (formDTO.getType().equals(GroupConstant.DATE)){ |
|||
result = groupDao.getIncrDaily(agencyId); |
|||
}else { |
|||
result = groupDao.getIncrMonthly(agencyId); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取机关ID |
|||
* @param tokenDto |
|||
* @author zxc |
|||
*/ |
|||
public String getLoginUserDetails(TokenDto tokenDto){ |
|||
LoginUserDetailsFormDTO dto = new LoginUserDetailsFormDTO(); |
|||
BeanUtils.copyProperties(tokenDto,dto); |
|||
LoginUserDetailsResultDTO data = epmetUserOpenFeignClient.getLoginUserDetails(dto).getData(); |
|||
return data.getAgencyId(); |
|||
} |
|||
} |
@ -0,0 +1,92 @@ |
|||
<?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.epmet.module.group.dao.GroupDao"> |
|||
|
|||
<!-- 网格小组:网格总数、网格小组数、小组平均数、小组人数中位数 --> |
|||
<select id="summaryInfo" parameterType="java.lang.String" resultType="com.epmet.group.dto.result.GroupSummaryInfoResultDTO"> |
|||
SELECT |
|||
grid_total AS gridTotalCount, |
|||
group_total_count AS groupTotalCount, |
|||
group_member_avg_count AS groupPeopleAvg, |
|||
group_median AS groupPeopleMedian, |
|||
DATE_FORMAT( date_id, '%Y-%m-%d' ) AS deadline |
|||
FROM fact_group_agency_daily |
|||
WHERE del_flag = '0' |
|||
AND agency_id = #{agencyId} |
|||
</select> |
|||
|
|||
<!--获取下级机关信息--> |
|||
<select id="getSubAgencyList" parameterType="java.lang.String" resultType="com.epmet.group.dto.result.SubAgencyResultDTO"> |
|||
SELECT |
|||
id AS agencyId, |
|||
agency_name AS agencyName |
|||
FROM |
|||
dim_agency |
|||
WHERE |
|||
del_flag = '0' |
|||
AND pid = #{agencyId} |
|||
</select> |
|||
|
|||
<!--获取下级机关的小组数--> |
|||
<select id="getSubGroupCount" resultType="com.epmet.group.dto.result.GroupSubAgencyResultDTO"> |
|||
SELECT |
|||
'小组数量' AS type, |
|||
fgad.group_total_count AS value, |
|||
fgad.agency_id AS agencyId |
|||
FROM |
|||
fact_group_agency_daily fgad |
|||
LEFT JOIN dim_agency da ON da.id = fgad.agency_id |
|||
AND da.del_flag = '0' |
|||
WHERE |
|||
fgad.del_flag = '0' |
|||
GROUP BY fgad.agency_id |
|||
ORDER BY fgad.date_id desc |
|||
</select> |
|||
|
|||
<!--获取直属网格下的小组数--> |
|||
<select id="getSubGridGroupCount" parameterType="java.lang.String" resultType="com.epmet.group.dto.result.GroupSubGridResultDTO"> |
|||
SELECT |
|||
fggd.grid_id AS gridId, |
|||
fggd.group_total AS value, |
|||
"小组数量" AS type , |
|||
dg.grid_name AS name |
|||
FROM |
|||
fact_group_grid_daily fggd |
|||
LEFT JOIN dim_grid dg ON dg.id = fggd.grid_id AND dg.del_flag = '0' |
|||
WHERE |
|||
fggd.del_flag = '0' |
|||
AND fggd.agency_id = #{agencyId} |
|||
</select> |
|||
|
|||
<!--小组数量 日增长--> |
|||
<select id="getIncrDaily" parameterType="java.lang.String" resultType="com.epmet.group.dto.result.GroupIncrTrendResultDTO"> |
|||
SELECT |
|||
DATE_FORMAT( date_id, '%Y/%m/%d' ) AS date, |
|||
group_incr AS value, |
|||
'小组数量' AS type |
|||
FROM |
|||
fact_group_agency_daily |
|||
WHERE |
|||
del_flag = '0' |
|||
AND agency_id = #{agencyId} |
|||
ORDER BY |
|||
date_id DESC |
|||
</select> |
|||
|
|||
<!--小组数量 月增长--> |
|||
<select id="getIncrMonthly" parameterType="java.lang.String" resultType="com.epmet.group.dto.result.GroupIncrTrendResultDTO"> |
|||
SELECT |
|||
CONCAT(SUBSTRING(month_id,1,4),'/',SUBSTRING(month_id,5,6)) AS date, |
|||
group_incr AS value, |
|||
'小组数量' AS type |
|||
FROM |
|||
fact_group_agency_daily |
|||
WHERE |
|||
del_flag = '0' |
|||
AND agency_id = #{agencyId} |
|||
ORDER BY |
|||
month_id DESC |
|||
</select> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue