This commit is contained in:
DirectionOfMind 2021-01-20 17:29:13 +08:00
parent c74d643f2f
commit f2f2669ece
9 changed files with 63 additions and 54 deletions

View File

@ -2,44 +2,20 @@ package com.lz.modules.performance.controller;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import com.lz.common.utils.PageUtils;
import com.lz.common.utils.R;
import com.lz.common.utils.StringUtil;
import com.lz.modules.flow.entity.FlowStart;
import com.lz.modules.performance.dto.IndicatorLibraryDto;
import com.lz.modules.performance.dto.IndicatorLibraryMoveDto;
import com.lz.modules.performance.dto.StatisticalIndicatorTypeDto;
import com.lz.modules.performance.res.StatisticalIndicatorTypeRes;
import com.lz.modules.performance.entity.IndicatorLibrary;
import com.lz.modules.performance.req.IndicatorLibraryReq;
import com.lz.modules.performance.service.IndicatorLibraryService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.aopalliance.aop.Advice;
import org.apache.ibatis.annotations.Param;
import org.springframework.aop.Advisor;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.framework.adapter.AdvisorAdapter;
import org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor;
import org.springframework.aop.framework.adapter.UnknownAdviceTypeException;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import javax.annotation.PostConstruct;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
@RestController
@ -110,9 +86,9 @@ public class IndicatorLibraryController {
@GetMapping("/statistical")
@ApiOperation("统计指标")
@ApiResponses({@ApiResponse(code = 200, message = "成功", response = StatisticalIndicatorTypeDto.class)})
public R statistical(@RequestParam(name = "indicatorType",required = false) @ApiParam(value = "指标分类id",name = "indicatorType") Long indicatorType) {
List<StatisticalIndicatorTypeDto> dtos = indicatorLibraryService.statisticalByIndicatorType(indicatorType);
@ApiResponses({@ApiResponse(code = 200, message = "成功", response = StatisticalIndicatorTypeRes.class)})
public R statistical(@RequestParam(name = "type",required = false) @ApiParam(value = "指标分类id",name = "type") Long type) {
List<StatisticalIndicatorTypeRes> dtos = indicatorLibraryService.statisticalByType(type);
return R.ok().put("data",dtos);
}
}

View File

@ -8,11 +8,10 @@ import com.lz.common.utils.StringUtil;
import com.lz.modules.performance.dto.IndicatorTypeDto;
import com.lz.modules.performance.entity.IndicatorType;
import com.lz.modules.performance.req.IndicatorReq;
import com.lz.modules.performance.res.IndicatorTypeRes;
import com.lz.modules.performance.service.IndicatorLibraryService;
import com.lz.modules.performance.service.IndicatorTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -32,7 +31,8 @@ public class IndicatorTypeController {
@PostMapping("/list")
@ApiOperation("获取分类/类型列表")
public R list(@RequestBody IndicatorReq req) {
@ApiResponses({@ApiResponse(code = 200, message = "成功", response = IndicatorTypeRes.class)})
public R list(@RequestBody IndicatorReq req) {
PageUtils page = indicatorTypeService.selectIndicatorTypesByReq(req);
return R.ok().put("data", page);
}

View File

@ -10,7 +10,7 @@ package com.lz.modules.performance.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lz.modules.performance.dto.IndicatorLibraryDto;
import com.lz.modules.performance.dto.StatisticalIndicatorTypeDto;
import com.lz.modules.performance.res.StatisticalIndicatorTypeRes;
import com.lz.modules.performance.entity.IndicatorLibrary;
import com.lz.modules.performance.req.IndicatorLibraryReq;
import org.apache.ibatis.annotations.Mapper;
@ -42,7 +42,7 @@ public interface IndicatorLibraryMapper extends BaseMapper<IndicatorLibrary> {
void updateIndicatorLibrarysMove(@Param("ids")List<Long> ids,@Param("indicatorType")Long indicatorType);
List<StatisticalIndicatorTypeDto> statisticalByIndicatorType(Long indicatorType);
List<StatisticalIndicatorTypeRes> statisticalByType(Long type);
int deleteIndicatorLibrarysByIndicatorType(@Param("indicatorType") Integer indicatorType);

View File

@ -21,4 +21,8 @@ public class IndicatorLibraryReq extends BasePage{
@ApiModelProperty(value = "指标分类 lz_indicator_type 表id", name = "indicatorType")
private Integer indicatorType;
//指标分类 lz_indicator_type 表id
@ApiModelProperty(value = "指标类型 lz_indicator_type 表id", name = "type")
private Integer type;
}

View File

@ -0,0 +1,27 @@
package com.lz.modules.performance.res;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author: djc
* @Desc:
* @Date: 2021/1/12 10:21
*/
@Data
@ApiModel("分类响应实体")
public class IndicatorTypeRes {
@ApiModelProperty(value = "id 分类或类型标识", name = "id")
private Long id;
//指标名称
@ApiModelProperty(value = "指标分类名称", name = "name")
private String name;
//指标名称
@ApiModelProperty(value = "类型0: 指标分类 1指标类型", name = "type")
private Integer type;
//排序
@ApiModelProperty(value = "排序(非必须)", name = "orderBy")
private Integer orderBy;
}

View File

@ -1,4 +1,4 @@
package com.lz.modules.performance.dto;
package com.lz.modules.performance.res;
import com.lz.modules.performance.entity.IndicatorType;
import io.swagger.annotations.ApiModel;
@ -12,12 +12,12 @@ import lombok.Data;
*/
@Data
@ApiModel("统计响应实体")
public class StatisticalIndicatorTypeDto {
public class StatisticalIndicatorTypeRes {
@ApiModelProperty(value = "名称",name = "name")
private String name;
@ApiModelProperty(value = "",name = "indicatorType")
@ApiModelProperty(value = "",name = "indicatorType")
private Integer indicatorType;
@ApiModelProperty(value = "个数",name = "count")

View File

@ -3,7 +3,7 @@ package com.lz.modules.performance.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lz.common.utils.PageUtils;
import com.lz.modules.performance.dto.IndicatorLibraryMoveDto;
import com.lz.modules.performance.dto.StatisticalIndicatorTypeDto;
import com.lz.modules.performance.res.StatisticalIndicatorTypeRes;
import com.lz.modules.performance.entity.IndicatorLibrary;
import com.lz.modules.performance.req.IndicatorLibraryReq;
@ -41,7 +41,7 @@ public interface IndicatorLibraryService extends IService<IndicatorLibrary> {
void updateIndicatorLibrarysMove(IndicatorLibraryMoveDto dto);
List<StatisticalIndicatorTypeDto> statisticalByIndicatorType(Long indicatorType);
List<StatisticalIndicatorTypeRes> statisticalByType(Long indicatorType);
int deleteIndicatorLibrarysIndicatorType(Integer indicatorType);

View File

@ -1,12 +1,11 @@
package com.lz.modules.performance.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.lz.common.utils.PageUtils;
import com.lz.common.utils.StringUtil;
import com.lz.modules.performance.dao.IndicatorLibraryMapper;
import com.lz.modules.performance.dto.IndicatorLibraryMoveDto;
import com.lz.modules.performance.dto.StatisticalIndicatorTypeDto;
import com.lz.modules.performance.res.StatisticalIndicatorTypeRes;
import com.lz.modules.performance.entity.IndicatorLibrary;
import com.lz.modules.performance.req.IndicatorLibraryReq;
import com.lz.modules.performance.service.IndicatorLibraryService;
@ -15,10 +14,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.ToDoubleFunction;
/**
* <p>
@ -103,9 +99,9 @@ public class IndicatorLibraryServiceImpl extends ServiceImpl<IndicatorLibraryMap
}
@Override
public List<StatisticalIndicatorTypeDto> statisticalByIndicatorType(Long indicatorType) {
List<StatisticalIndicatorTypeDto> dtos = indicatorLibraryMapper.statisticalByIndicatorType(indicatorType);
StatisticalIndicatorTypeDto dto = new StatisticalIndicatorTypeDto();
public List<StatisticalIndicatorTypeRes> statisticalByType(Long type) {
List<StatisticalIndicatorTypeRes> dtos = indicatorLibraryMapper.statisticalByType(type);
StatisticalIndicatorTypeRes dto = new StatisticalIndicatorTypeRes();
dto.setName("未分类指标");
dto.setIndicatorType(0);
dto.setDelete(1);
@ -115,7 +111,7 @@ public class IndicatorLibraryServiceImpl extends ServiceImpl<IndicatorLibraryMap
dtos.add(dto);
}
dto = new StatisticalIndicatorTypeDto();
dto = new StatisticalIndicatorTypeRes();
dto.setName("全部分类");
dto.setIndicatorType(null);
dto.setDelete(1);

View File

@ -100,6 +100,9 @@
<if test="req.indicatorType!=null">
and indicator_type = #{req.indicatorType}
</if>
<if test="req.type!=null and req.type!=0">
and type = #{req.type}
</if>
order by sort
</select>
@ -123,15 +126,18 @@
</update>
<select id="statisticalByIndicatorType"
resultType="com.lz.modules.performance.dto.StatisticalIndicatorTypeDto">
<select id="statisticalByType"
resultType="com.lz.modules.performance.res.StatisticalIndicatorTypeRes">
SELECT t.id indicatorType,t.name,IFNULL(l.count,0) count from lz_indicator_type t
LEFT JOIN (SELECT name,indicator_type,count(indicator_type) count from lz_indicator_library where is_delete = 0
<if test="indicatorType!=null">
and l.indicator_type=#{indicatorType}
LEFT JOIN
(SELECT name,indicator_type,count(indicator_type) count from lz_indicator_library where is_delete=0
<if test="type!=null and type!=0">
and type = #{type}
</if>
GROUP BY indicator_type) l
on t.is_delete = 0 and t.id = l.indicator_type
on t.id = l.indicator_type
where t.is_delete = 0
</select>