diff --git a/src/main/java/com/lz/modules/performance/controller/IndicatorLibraryController.java b/src/main/java/com/lz/modules/performance/controller/IndicatorLibraryController.java new file mode 100644 index 00000000..b85c1228 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/controller/IndicatorLibraryController.java @@ -0,0 +1,100 @@ +package com.lz.modules.performance.controller; + + +import cn.hutool.core.bean.BeanUtil; +import com.lz.common.utils.PageUtils; +import com.lz.common.utils.R; +import com.lz.common.utils.StringUtil; +import com.lz.modules.performance.dto.IndicatorLibraryDto; +import com.lz.modules.performance.dto.IndicatorLibraryMoveDto; +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.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.math.BigDecimal; +import java.util.List; + +@Slf4j +@RestController +@RequestMapping("/indicatorLibrary") +@Api(value = "指标相关接口", tags = { "指标相关接口" }) +public class IndicatorLibraryController { + + + @Autowired + private IndicatorLibraryService indicatorLibraryService; + + + @PostMapping("/list") + @ApiOperation("获取指标列表") + @ApiResponses({@ApiResponse(code = 200, message = "成功", response = IndicatorLibraryDto.class)}) + public R list(@RequestBody IndicatorLibraryReq req) { + PageUtils page = indicatorLibraryService.selectIndicatorLibrarysByReq(req); + return R.ok().put("data",page); + } + + + @GetMapping("/getById") + @ApiOperation("获取指标") + public R getById(@RequestParam @ApiParam(value = "获取指标id",name = "id")Long id) { + IndicatorLibrary indicatorLibrary = indicatorLibraryService.selectIndicatorLibraryById(id); + IndicatorLibraryDto dto = new IndicatorLibraryDto(); + BeanUtil.copyProperties(indicatorLibrary,dto); + return R.ok().put("data",dto); + } + + + + @PostMapping("/saveOrUpdate") + @ApiOperation("保存/修改指标") + public R save(@RequestBody IndicatorLibraryDto dto) { + IndicatorLibrary indicatorLibrary = new IndicatorLibrary(); + BeanUtil.copyProperties(dto,indicatorLibrary); + if(StringUtil.isNotBlank(dto.getWeight())){ + indicatorLibrary.setWeight(new BigDecimal(dto.getWeight())); + } + boolean success = indicatorLibraryService.saveOrUpdate(indicatorLibrary); + + return success ? R.ok():R.error(); + + } + + + @GetMapping("/delete") + @ApiOperation("删除指标") + public R delete(@RequestParam @ApiParam(value = "指标删除id,逗号隔开",name = "ids") String ids) { + try { + indicatorLibraryService.deleteIndicatorLibrarysByIds(ids); + } catch (Exception e) { + log.error("删除指标异常",e); + return R.error(); + } + return R.ok(); + } + + + @PostMapping("/move") + @ApiOperation("移动指标") + public R move(@RequestBody IndicatorLibraryMoveDto dto) { + try { + indicatorLibraryService.updateIndicatorLibrarysMove(dto); + } catch (Exception e) { + log.error("移动指标异常",e); + return R.error(); + } + return R.ok(); + } + + @GetMapping("/statistical") + @ApiOperation("统计指标") + @ApiResponses({@ApiResponse(code = 200, message = "成功", response = StatisticalIndicatorTypeRes.class)}) + public R statistical(@RequestParam(name = "type",required = false) @ApiParam(value = "指标维度id",name = "type") Long type,@RequestParam(name = "name",required = false) @ApiParam(value = "指标名称",name = "name") String name) { + List dtos = indicatorLibraryService.statisticalByType(type,name); + return R.ok().put("data",dtos); + } +} \ No newline at end of file diff --git a/src/main/java/com/lz/modules/performance/controller/IndicatorTypeController.java b/src/main/java/com/lz/modules/performance/controller/IndicatorTypeController.java new file mode 100644 index 00000000..5aff7bf6 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/controller/IndicatorTypeController.java @@ -0,0 +1,77 @@ +package com.lz.modules.performance.controller; + + +import cn.hutool.core.bean.BeanUtil; +import com.lz.common.utils.PageUtils; +import com.lz.common.utils.R; +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.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@Slf4j +@RestController +@RequestMapping("/indicatorType") +@Api(value = "指标分类相关接口", tags = { "指标分类相关接口" }) +public class IndicatorTypeController { + + + @Autowired + private IndicatorTypeService indicatorTypeService; + @Autowired + private IndicatorLibraryService indicatorLibraryService; + + + @PostMapping("/list") + @ApiOperation("获取分类/类型列表") + @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); + } + + + + @ApiOperation("保存/修改分类") + @PostMapping("/saveOrUpdate") + public R save(@RequestBody IndicatorTypeDto dto) { + if(dto.getId()==null){ + if(StringUtil.isBlank(dto.getName())){ + return R.error("分类名称不能为空"); + } + IndicatorType indicatorType = indicatorTypeService.selectIndicatorTypeByName(dto.getName()); + if(indicatorType!=null){ + return R.error("分类名称重复"); + } + } + IndicatorType indicatorType = new IndicatorType(); + BeanUtil.copyProperties(dto,indicatorType); + boolean success = indicatorTypeService.saveOrUpdate(indicatorType); + + return success ? R.ok():R.error(); + + } + + + @GetMapping("/delete") + @ApiOperation("删除指标分类") + public R delete(@RequestParam @ApiParam(value = "删除指标分类id",name = "id") Long id) { + try { + indicatorTypeService.deleteIndicatorTypeById(id); + indicatorLibraryService.deleteIndicatorLibrarysIndicatorType(id.intValue()); + + } catch (Exception e) { + log.error("删除指标异常",e); + return R.error(); + } + return R.ok(); + } + +} diff --git a/src/main/java/com/lz/modules/performance/dao/IndicatorLibraryMapper.java b/src/main/java/com/lz/modules/performance/dao/IndicatorLibraryMapper.java new file mode 100644 index 00000000..fc449c37 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/dao/IndicatorLibraryMapper.java @@ -0,0 +1,52 @@ +package com.lz.modules.performance.dao; +/** +*

+* (设置)指标库 服务类 +*

+* +* @author quyixiao +* @since 2021-01-12 +*/ +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.res.StatisticalIndicatorTypeRes; +import com.lz.modules.performance.entity.IndicatorLibrary; +import com.lz.modules.performance.req.IndicatorLibraryReq; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface IndicatorLibraryMapper extends BaseMapper { + + + IndicatorLibrary selectIndicatorLibraryById(@Param("id") Long id); + + + Long insertIndicatorLibrary(IndicatorLibrary indicatorLibrary); + + + int updateIndicatorLibraryById(IndicatorLibrary indicatorLibrary); + + + int updateCoverIndicatorLibraryById(IndicatorLibrary indicatorLibrary); + + + int deleteIndicatorLibraryById(@Param("id") Long id); + + List selectIndicatorLibrarysByReq(@Param("page") IPage page, @Param("req")IndicatorLibraryReq req); + + void deleteIndicatorLibrarysByIds(@Param("ids") List ids); + + void updateIndicatorLibrarysMove(@Param("ids")List ids,@Param("indicatorType")Long indicatorType); + + List statisticalByType(@Param("type") Long type,@Param("name") String name); + + int deleteIndicatorLibrarysByIndicatorType(@Param("indicatorType") Integer indicatorType); + + int countIndicatorLibrarysByIndicatorType(@Param("indicatorType") Integer indicatorType,@Param("type") Long type,@Param("name") String name); + + +} \ No newline at end of file diff --git a/src/main/java/com/lz/modules/performance/dao/IndicatorTypeMapper.java b/src/main/java/com/lz/modules/performance/dao/IndicatorTypeMapper.java new file mode 100644 index 00000000..b4f7aec4 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/dao/IndicatorTypeMapper.java @@ -0,0 +1,44 @@ +package com.lz.modules.performance.dao; +/** +*

+* 指标分类 服务类 +*

+* +* @author quyixiao +* @since 2021-01-12 +*/ +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.lz.modules.equipment.entity.TCountReq; +import com.lz.modules.performance.dto.IndicatorTypeDto; +import com.lz.modules.performance.entity.IndicatorType; +import com.lz.modules.performance.req.IndicatorReq; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface IndicatorTypeMapper extends BaseMapper { + + + IndicatorType selectIndicatorTypeById(@Param("id") Long id); + + + Long insertIndicatorType(IndicatorType indicatorType); + + + int updateIndicatorTypeById(IndicatorType indicatorType); + + + int updateCoverIndicatorTypeById(IndicatorType indicatorType); + + + int deleteIndicatorTypeById(@Param("id") Long id); + + List selectIndicatorTypesByReq(@Param("page") IPage page, @Param("req")IndicatorReq req); + + IndicatorType selectIndicatorTypeByName(@Param("name") String name); + + +} \ No newline at end of file diff --git a/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryDto.java b/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryDto.java new file mode 100644 index 00000000..aebc6135 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryDto.java @@ -0,0 +1,45 @@ +package com.lz.modules.performance.dto; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author: djc + * @Desc: + * @Date: 2021/1/12 14:41 + */ +@Data +@ApiModel("指标保存/修改实体") +public class IndicatorLibraryDto { + // + @TableId(value = "id", type = IdType.AUTO) + private Long id; + //指标名称 + @ApiModelProperty(value = "指标名称", name = "name") + private String name; + //指标类型 lz_result_dimension 表id" + @ApiModelProperty(value = "指标维度 lz_result_dimension 表id", name = "type") + private Integer type; + //指标分类 lz_indicator_type 表id + @ApiModelProperty(value = "指标分类 lz_indicator_type 表id", name = "indicatorType") + private Integer indicatorType; + //权重 + @ApiModelProperty(value = "权重", name = "weight") + private String weight; + //考核标准,关键结果 + @ApiModelProperty(value = "考核标准,关键结果", name = "keyResult") + private String keyResult; + //排序 + @ApiModelProperty(value = "排序", name = "sort") + private Integer sort; + + @ApiModelProperty(value = "类型名称", name = "typeName") + private String typeName; + + +} diff --git a/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryMoveDto.java b/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryMoveDto.java new file mode 100644 index 00000000..4b446658 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/dto/IndicatorLibraryMoveDto.java @@ -0,0 +1,21 @@ +package com.lz.modules.performance.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author: djc + * @Desc: + * @Date: 2021/1/13 11:38 + */ +@Data +@ApiModel("移动指标实体") +public class IndicatorLibraryMoveDto { + @ApiModelProperty(value = "移动的id,逗号隔开",name = "ids") + private String ids; + + @ApiModelProperty(value = "要移动的目标分类",name = "indicatorType") + private Long indicatorType; + +} diff --git a/src/main/java/com/lz/modules/performance/dto/IndicatorTypeDto.java b/src/main/java/com/lz/modules/performance/dto/IndicatorTypeDto.java new file mode 100644 index 00000000..3dbca138 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/dto/IndicatorTypeDto.java @@ -0,0 +1,27 @@ +package com.lz.modules.performance.dto; + +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 IndicatorTypeDto { + + @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; +} diff --git a/src/main/java/com/lz/modules/performance/entity/IndicatorLibrary.java b/src/main/java/com/lz/modules/performance/entity/IndicatorLibrary.java new file mode 100644 index 00000000..5cac3268 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/entity/IndicatorLibrary.java @@ -0,0 +1,217 @@ +package com.lz.modules.performance.entity; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +/** +*

+*

*(设置)指标库 +* @author quyixiao +* @since 2021-01-12 +*/ + +@Data +@TableName("lz_indicator_library") +@ApiModel(value = "(设置)指标库") +public class IndicatorLibrary implements java.io.Serializable { + // + @TableId(value = "id", type = IdType.AUTO) + private Long id; + // + @ApiModelProperty(value = "", name = "isDelete") + private Integer isDelete; + // + @ApiModelProperty(value = "", name = "gmtCreate") + private Date gmtCreate; + // + @ApiModelProperty(value = "", name = "gmtModified") + private Date gmtModified; + //指标名称 + @ApiModelProperty(value = "指标名称", name = "name") + private String name; + //指标类型 0:量化指标 1:行为价值观指标 2:团队管理 + @ApiModelProperty(value = "指标类型 lz_result_dimension 表id", name = "type") + private Integer type; + //指标分类 lz_indicator_type 表id + @ApiModelProperty(value = "指标分类 lz_indicator_type 表id", name = "indicatorType") + private Integer indicatorType; + //权重 + @ApiModelProperty(value = "权重", name = "weight") + private BigDecimal weight; + //考核标准,关键结果 + @ApiModelProperty(value = "考核标准,关键结果", name = "keyResult") + private String keyResult; + //排序 + @ApiModelProperty(value = "排序", name = "sort") + private Integer sort; + /** + * + * @return + */ + public Long getId() { + return id; + } + /** + * + * @param id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * + * @return + */ + public Integer getIsDelete() { + return isDelete; + } + /** + * + * @param isDelete + */ + public void setIsDelete(Integer isDelete) { + this.isDelete = isDelete; + } + + /** + * + * @return + */ + public Date getGmtCreate() { + return gmtCreate; + } + /** + * + * @param gmtCreate + */ + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + /** + * + * @return + */ + public Date getGmtModified() { + return gmtModified; + } + /** + * + * @param gmtModified + */ + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + /** + * 指标名称 + * @return + */ + public String getName() { + return name; + } + /** + * 指标名称 + * @param name + */ + public void setName(String name) { + this.name = name; + } + + /** + * 指标类型 0:量化指标 1:行为价值观指标 2:团队管理 + * @return + */ + public Integer getType() { + return type; + } + /** + * 指标类型 0:量化指标 1:行为价值观指标 2:团队管理 + * @param type + */ + public void setType(Integer type) { + this.type = type; + } + + /** + * 指标分类 lz_indicator_type 表id + * @return + */ + public Integer getIndicatorType() { + return indicatorType; + } + /** + * 指标分类 lz_indicator_type 表id + * @param indicatorType + */ + public void setIndicatorType(Integer indicatorType) { + this.indicatorType = indicatorType; + } + + /** + * 权重 + * @return + */ + public BigDecimal getWeight() { + return weight; + } + /** + * 权重 + * @param weight + */ + public void setWeight(BigDecimal weight) { + this.weight = weight; + } + + /** + * 考核标准,关键结果 + * @return + */ + public String getKeyResult() { + return keyResult; + } + /** + * 考核标准,关键结果 + * @param keyResult + */ + public void setKeyResult(String keyResult) { + this.keyResult = keyResult; + } + + /** + * 排序 + * @return + */ + public Integer getSort() { + return sort; + } + /** + * 排序 + * @param sort + */ + public void setSort(Integer sort) { + this.sort = sort; + } + + @Override + public String toString() { + return "IndicatorLibrary{" + + ",id=" + id + + ",isDelete=" + isDelete + + ",gmtCreate=" + gmtCreate + + ",gmtModified=" + gmtModified + + ",name=" + name + + ",type=" + type + + ",indicatorType=" + indicatorType + + ",weight=" + weight + + ",keyResult=" + keyResult + + ",sort=" + sort + + "}"; + } +} \ No newline at end of file diff --git a/src/main/java/com/lz/modules/performance/entity/IndicatorType.java b/src/main/java/com/lz/modules/performance/entity/IndicatorType.java new file mode 100644 index 00000000..f1956664 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/entity/IndicatorType.java @@ -0,0 +1,158 @@ +package com.lz.modules.performance.entity; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.util.Date; +/** +*

+*

*指标分类 +* @author quyixiao +* @since 2021-01-12 +*/ + +@Data +@TableName("lz_indicator_type") +@ApiModel(value = "指标分类") +public class IndicatorType implements java.io.Serializable { + // + @TableId(value = "id", type = IdType.AUTO) + private Long id; + // + @ApiModelProperty(value = "", name = "isDelete") + private Integer isDelete; + // + @ApiModelProperty(value = "", name = "gmtCreate") + private Date gmtCreate; + // + @ApiModelProperty(value = "", name = "gmtModified") + private Date gmtModified; + //指标分类名称 + @ApiModelProperty(value = "指标分类名称", name = "name") + private String name; + //0: 指标分类 1:指标类型 + @ApiModelProperty(value = "0: 指标分类 1:指标类型", name = "type") + private Integer type; + //排序 + @ApiModelProperty(value = "排序", name = "sort") + private Integer sort; + /** + * + * @return + */ + public Long getId() { + return id; + } + /** + * + * @param id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * + * @return + */ + public Integer getIsDelete() { + return isDelete; + } + /** + * + * @param isDelete + */ + public void setIsDelete(Integer isDelete) { + this.isDelete = isDelete; + } + + /** + * + * @return + */ + public Date getGmtCreate() { + return gmtCreate; + } + /** + * + * @param gmtCreate + */ + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + /** + * + * @return + */ + public Date getGmtModified() { + return gmtModified; + } + /** + * + * @param gmtModified + */ + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + /** + * 指标分类名称 + * @return + */ + public String getName() { + return name; + } + /** + * 指标分类名称 + * @param name + */ + public void setName(String name) { + this.name = name; + } + + /** + * 0: 指标分类 1:指标类型 + * @return + */ + public Integer getType() { + return type; + } + /** + * 0: 指标分类 1:指标类型 + * @param type + */ + public void setType(Integer type) { + this.type = type; + } + + /** + * 排序 + * @return + */ + public Integer getSort() { + return sort; + } + /** + * 排序 + * @param sort + */ + public void setSort(Integer sort) { + this.sort = sort; + } + + @Override + public String toString() { + return "IndicatorType{" + + ",id=" + id + + ",isDelete=" + isDelete + + ",gmtCreate=" + gmtCreate + + ",gmtModified=" + gmtModified + + ",name=" + name + + ",type=" + type + + ",sort=" + sort + + "}"; + } +} \ No newline at end of file diff --git a/src/main/java/com/lz/modules/performance/req/IndicatorLibraryReq.java b/src/main/java/com/lz/modules/performance/req/IndicatorLibraryReq.java new file mode 100644 index 00000000..c362a698 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/req/IndicatorLibraryReq.java @@ -0,0 +1,28 @@ +package com.lz.modules.performance.req; + +import com.fasterxml.jackson.databind.ser.Serializers; +import com.lz.modules.equipment.entity.model.BasePage; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author: djc + * @Desc: + * @Date: 2021/1/12 14:50 + */ +@Data +@ApiModel("获取指标列表实体") +public class IndicatorLibraryReq extends BasePage{ + //指标名称 + @ApiModelProperty(value = "指标名称", name = "name") + private String name; + //指标分类 lz_indicator_type 表id + @ApiModelProperty(value = "指标分类 lz_indicator_type 表id", name = "indicatorType") + private Integer indicatorType; + + //指标分类 lz_result_dimension 表id + @ApiModelProperty(value = "指标类型 lz_result_dimension 表id", name = "type") + private Integer type; + +} diff --git a/src/main/java/com/lz/modules/performance/req/IndicatorReq.java b/src/main/java/com/lz/modules/performance/req/IndicatorReq.java new file mode 100644 index 00000000..7cf8abf5 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/req/IndicatorReq.java @@ -0,0 +1,22 @@ +package com.lz.modules.performance.req; + +import com.lz.modules.equipment.entity.model.BasePage; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author: djc + * @Desc: + * @Date: 2021/1/12 11:39 + */ +@Data +@ApiModel("获取分类/类型实体") +public class IndicatorReq extends BasePage{ + //指标名称 + @ApiModelProperty(value = "指标分类名称", name = "name") + private String name; + //指标名称 + @ApiModelProperty(value = "类型 0: 指标分类 1:指标类型", name = "type") + private Integer type; +} diff --git a/src/main/java/com/lz/modules/performance/res/IndicatorTypeRes.java b/src/main/java/com/lz/modules/performance/res/IndicatorTypeRes.java new file mode 100644 index 00000000..068e7454 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/res/IndicatorTypeRes.java @@ -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; +} diff --git a/src/main/java/com/lz/modules/performance/res/StatisticalIndicatorTypeRes.java b/src/main/java/com/lz/modules/performance/res/StatisticalIndicatorTypeRes.java new file mode 100644 index 00000000..f2d2c6d7 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/res/StatisticalIndicatorTypeRes.java @@ -0,0 +1,28 @@ +package com.lz.modules.performance.res; + +import com.lz.modules.performance.entity.IndicatorType; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author: djc + * @Desc: + * @Date: 2021/1/13 17:20 + */ +@Data +@ApiModel("统计响应实体") +public class StatisticalIndicatorTypeRes { + + @ApiModelProperty(value = "名称",name = "name") + private String name; + + @ApiModelProperty(value = "分类",name = "indicatorType") + private Integer indicatorType; + + @ApiModelProperty(value = "个数",name = "count") + private int count; + + @ApiModelProperty(value = "是否可以删除 0:可以 1:不可以",name = "delete") + private int delete; +} diff --git a/src/main/java/com/lz/modules/performance/service/IndicatorLibraryService.java b/src/main/java/com/lz/modules/performance/service/IndicatorLibraryService.java new file mode 100644 index 00000000..5b1a4a8f --- /dev/null +++ b/src/main/java/com/lz/modules/performance/service/IndicatorLibraryService.java @@ -0,0 +1,49 @@ +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.res.StatisticalIndicatorTypeRes; +import com.lz.modules.performance.entity.IndicatorLibrary; +import com.lz.modules.performance.req.IndicatorLibraryReq; + +import java.util.List; + +/** +*

+* (设置)指标库 服务类 +*

+* +* @author quyixiao +* @since 2021-01-12 +*/ +public interface IndicatorLibraryService extends IService { + + + + IndicatorLibrary selectIndicatorLibraryById(Long id); + + + Long insertIndicatorLibrary(IndicatorLibrary indicatorLibrary); + + + int updateIndicatorLibraryById(IndicatorLibrary indicatorLibrary); + + + int updateCoverIndicatorLibraryById(IndicatorLibrary indicatorLibrary); + + + int deleteIndicatorLibraryById(Long id); + + PageUtils selectIndicatorLibrarysByReq(IndicatorLibraryReq req); + + void deleteIndicatorLibrarysByIds(String ids); + + void updateIndicatorLibrarysMove(IndicatorLibraryMoveDto dto); + + List statisticalByType(Long indicatorType,String name); + + int deleteIndicatorLibrarysIndicatorType(Integer indicatorType); + + +} \ No newline at end of file diff --git a/src/main/java/com/lz/modules/performance/service/IndicatorTypeService.java b/src/main/java/com/lz/modules/performance/service/IndicatorTypeService.java new file mode 100644 index 00000000..f652ec99 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/service/IndicatorTypeService.java @@ -0,0 +1,39 @@ +package com.lz.modules.performance.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.lz.common.utils.PageUtils; +import com.lz.modules.performance.req.IndicatorReq; +import com.lz.modules.performance.entity.IndicatorType; + +/** +*

+* 指标分类 服务类 +*

+* +* @author quyixiao +* @since 2021-01-12 +*/ +public interface IndicatorTypeService extends IService { + + + + IndicatorType selectIndicatorTypeById(Long id); + + + Long insertIndicatorType(IndicatorType indicatorType); + + + int updateIndicatorTypeById(IndicatorType indicatorType); + + + int updateCoverIndicatorTypeById(IndicatorType indicatorType); + + + int deleteIndicatorTypeById(Long id); + + PageUtils selectIndicatorTypesByReq(IndicatorReq req); + + IndicatorType selectIndicatorTypeByName(String name); + + +} \ No newline at end of file diff --git a/src/main/java/com/lz/modules/performance/service/impl/IndicatorLibraryServiceImpl.java b/src/main/java/com/lz/modules/performance/service/impl/IndicatorLibraryServiceImpl.java new file mode 100644 index 00000000..6ea8db5b --- /dev/null +++ b/src/main/java/com/lz/modules/performance/service/impl/IndicatorLibraryServiceImpl.java @@ -0,0 +1,132 @@ +package com.lz.modules.performance.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +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.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.jsonwebtoken.lang.Collections; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +*

+* (设置)指标库 服务类 +*

+* +* @author quyixiao +* @since 2021-01-12 +*/ + +@Service +public class IndicatorLibraryServiceImpl extends ServiceImpl implements IndicatorLibraryService { + + + @Autowired + private IndicatorLibraryMapper indicatorLibraryMapper; + + + + @Override + public IndicatorLibrary selectIndicatorLibraryById(Long id){ + return indicatorLibraryMapper.selectIndicatorLibraryById(id); + } + + + + @Override + public Long insertIndicatorLibrary(IndicatorLibrary indicatorLibrary){ + return indicatorLibraryMapper.insertIndicatorLibrary(indicatorLibrary); + } + + + + @Override + public int updateIndicatorLibraryById(IndicatorLibrary indicatorLibrary){ + return indicatorLibraryMapper.updateIndicatorLibraryById(indicatorLibrary); + } + + + + @Override + public int updateCoverIndicatorLibraryById(IndicatorLibrary indicatorLibrary){ + return indicatorLibraryMapper.updateCoverIndicatorLibraryById(indicatorLibrary); + } + + + + @Override + public int deleteIndicatorLibraryById(Long id){ + return indicatorLibraryMapper.deleteIndicatorLibraryById(id); + } + + @Override + public PageUtils selectIndicatorLibrarysByReq(IndicatorLibraryReq req) { + PageUtils page = PageUtils.startPage(req.getCurrPage(), req.getPageSize()).doSelect( + page1 -> indicatorLibraryMapper.selectIndicatorLibrarysByReq(page1,req) + ); + return page; + } + + @Override + public void deleteIndicatorLibrarysByIds(String ids) { + if(StringUtil.isBlank(ids)){ + return; + } + String[] split = ids.split(","); + List list = Collections.arrayToList(split); + indicatorLibraryMapper.deleteIndicatorLibrarysByIds(list); + + } + + @Override + public void updateIndicatorLibrarysMove(IndicatorLibraryMoveDto dto) { + String ids = dto.getIds(); + if(StringUtil.isBlank(ids)){ + return; + } + String[] split = ids.split(","); + List list = Collections.arrayToList(split); + indicatorLibraryMapper.updateIndicatorLibrarysMove(list,dto.getIndicatorType()); + + } + + @Override + public List statisticalByType(Long type,String name) { + List dtos = indicatorLibraryMapper.statisticalByType(type,name); + StatisticalIndicatorTypeRes dto = new StatisticalIndicatorTypeRes(); + dto.setName("未分类指标"); + dto.setIndicatorType(0); + dto.setDelete(1); + int count = indicatorLibraryMapper.countIndicatorLibrarysByIndicatorType(0,type,name); + dto.setCount(count); + if(count>0){ + dtos.add(dto); + } + + dto = new StatisticalIndicatorTypeRes(); + dto.setName("全部分类"); + dto.setIndicatorType(null); + dto.setDelete(1); + if(CollectionUtils.isNotEmpty(dtos)){ + double sum = dtos.stream().mapToDouble(value -> value.getCount()).sum(); + dto.setCount(Double.valueOf(sum).intValue()); + } + //加入首位 + dtos.add(0,dto); + + return dtos; + } + + @Override + public int deleteIndicatorLibrarysIndicatorType(Integer indicatorType) { + return indicatorLibraryMapper.deleteIndicatorLibrarysByIndicatorType(indicatorType); + } +} diff --git a/src/main/java/com/lz/modules/performance/service/impl/IndicatorTypeServiceImpl.java b/src/main/java/com/lz/modules/performance/service/impl/IndicatorTypeServiceImpl.java new file mode 100644 index 00000000..7aad6c06 --- /dev/null +++ b/src/main/java/com/lz/modules/performance/service/impl/IndicatorTypeServiceImpl.java @@ -0,0 +1,76 @@ +package com.lz.modules.performance.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.lz.common.utils.PageUtils; +import com.lz.modules.performance.dao.IndicatorTypeMapper; +import com.lz.modules.performance.req.IndicatorReq; +import com.lz.modules.performance.entity.IndicatorType; +import com.lz.modules.performance.service.IndicatorTypeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** +*

+* 指标分类 服务类 +*

+* +* @author quyixiao +* @since 2021-01-12 +*/ + +@Service +public class IndicatorTypeServiceImpl extends ServiceImpl implements IndicatorTypeService { + + + @Autowired + private IndicatorTypeMapper indicatorTypeMapper; + + + + @Override + public IndicatorType selectIndicatorTypeById(Long id){ + return indicatorTypeMapper.selectIndicatorTypeById(id); + } + + + + @Override + public Long insertIndicatorType(IndicatorType indicatorType){ + return indicatorTypeMapper.insertIndicatorType(indicatorType); + } + + + + @Override + public int updateIndicatorTypeById(IndicatorType indicatorType){ + return indicatorTypeMapper.updateIndicatorTypeById(indicatorType); + } + + + + @Override + public int updateCoverIndicatorTypeById(IndicatorType indicatorType){ + return indicatorTypeMapper.updateCoverIndicatorTypeById(indicatorType); + } + + + + @Override + public int deleteIndicatorTypeById(Long id){ + return indicatorTypeMapper.deleteIndicatorTypeById(id); + } + + @Override + public PageUtils selectIndicatorTypesByReq(IndicatorReq req) { + + PageUtils page = PageUtils.startPage(req.getCurrPage(), req.getPageSize()).doSelect( + page1 -> indicatorTypeMapper.selectIndicatorTypesByReq(page1,req) + ); + return page; + } + + @Override + public IndicatorType selectIndicatorTypeByName(String name) { + return indicatorTypeMapper.selectIndicatorTypeByName(name); + } +} diff --git a/src/main/resources/mapper/performance/IndicatorLibraryMapper.xml b/src/main/resources/mapper/performance/IndicatorLibraryMapper.xml new file mode 100644 index 00000000..3a4870ab --- /dev/null +++ b/src/main/resources/mapper/performance/IndicatorLibraryMapper.xml @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, name AS name, type AS type, indicator_type AS indicatorType, weight AS weight, key_result AS keyResult, sort AS sort + + + + + + + + insert into lz_indicator_library( + name, + type, + indicator_type, + weight, + key_result, + sort, + is_delete, + gmt_create, + gmt_modified + )values( + #{ name}, + #{ type}, + #{ indicatorType}, + #{ weight}, + #{ keyResult}, + #{ sort}, + 0, + now(), + now() + ) + + + + + update + lz_indicator_library + + is_delete = #{isDelete}, + gmt_create = #{gmtCreate}, + name = #{name}, + type = #{type}, + indicator_type = #{indicatorType}, + weight = #{weight}, + key_result = #{keyResult}, + sort = #{sort} + + ,gmt_modified = now() + where id = #{id} + + + + + update + lz_indicator_library + set + is_delete = #{isDelete}, + gmt_create = #{gmtCreate}, + name = #{name}, + type = #{type}, + indicator_type = #{indicatorType}, + weight = #{weight}, + key_result = #{keyResult}, + sort = #{sort} + ,gmt_modified = now() + where id = #{id} + + + + update lz_indicator_library set is_delete = 1 where id=#{id} limit 1 + + + + + + update lz_indicator_library set is_delete = 1 where is_delete = 0 AND + id in + ( + + #{id} + + ) + + + update lz_indicator_library set indicator_type = #{indicatorType} where is_delete = 0 AND + id in + ( + + #{id} + + ) + + + + + + + + update lz_indicator_library set is_delete = 1 where indicator_type=#{indicatorType} + + + + + + + + diff --git a/src/main/resources/mapper/performance/IndicatorTypeMapper.xml b/src/main/resources/mapper/performance/IndicatorTypeMapper.xml new file mode 100644 index 00000000..ec5fa83f --- /dev/null +++ b/src/main/resources/mapper/performance/IndicatorTypeMapper.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, name AS name, type AS type, sort AS sort + + + + + + + + + + insert into lz_indicator_type( + name, + type, + sort, + is_delete, + gmt_create, + gmt_modified + )values( + #{ name}, + #{ type}, + #{ sort}, + 0, + now(), + now() + ) + + + + + update + lz_indicator_type + + is_delete = #{isDelete}, + gmt_create = #{gmtCreate}, + name = #{name}, + type = #{type}, + sort = #{sort} + + ,gmt_modified = now() + where id = #{id} + + + + + update + lz_indicator_type + set + is_delete = #{isDelete}, + gmt_create = #{gmtCreate}, + name = #{name}, + type = #{type}, + sort = #{sort} + ,gmt_modified = now() + where id = #{id} + + + + + update lz_indicator_type set is_delete = 1 where id=#{id} limit 1 + + + + + + + + diff --git a/src/test/java/com/lz/mysql/MysqlMain.java b/src/test/java/com/lz/mysql/MysqlMain.java index 58c7b554..656c2568 100644 --- a/src/test/java/com/lz/mysql/MysqlMain.java +++ b/src/test/java/com/lz/mysql/MysqlMain.java @@ -85,6 +85,8 @@ public class MysqlMain { List list = new ArrayList(); + list.add(new TablesBean("lz_indicator_library")); + list.add(new TablesBean("lz_indicator_type")); list.add(new TablesBean("lz_task_resp")); diff --git a/src/test/java/com/lz/mysql/MysqlUtilTable2Contoller.java b/src/test/java/com/lz/mysql/MysqlUtilTable2Contoller.java index 32fb9d06..328c88b8 100644 --- a/src/test/java/com/lz/mysql/MysqlUtilTable2Contoller.java +++ b/src/test/java/com/lz/mysql/MysqlUtilTable2Contoller.java @@ -46,7 +46,7 @@ public class MysqlUtilTable2Contoller { content.append(" if(StringUtil.isNotBlank(body)){\n"); content.append(" params = JSONObject.parseObject(body,Map.class);\n"); content.append(" }\n"); - content.append(" PageUtils page = " + tableBean.getJavaName() + "service.queryPage(params);\n"); + content.append(" PageUtils page = " + tableBean.getJavaName() + "Service.queryPage(params);\n"); content.append(" return R.ok().put(\"page\", page);\n"); content.append(" }\n"); content.append("\n");