This commit is contained in:
DirectionOfMind 2021-01-13 16:14:43 +08:00
parent 26ff04f9a8
commit 0d87dd9801
15 changed files with 142 additions and 8 deletions

View File

@ -7,9 +7,14 @@ 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.entity.IndicatorLibrary;
import com.lz.modules.performance.req.IndicatorLibraryReq;
import com.lz.modules.performance.service.IndicatorLibraryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -17,8 +22,10 @@ import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/indicatorLibrary")
@Api(value = "指标相关接口", tags = { "指标相关接口" })
public class IndicatorLibraryController {
@ -27,6 +34,7 @@ public class IndicatorLibraryController {
@PostMapping("/list")
@ApiOperation("获取指标列表")
public R list(@RequestBody IndicatorLibraryReq req) {
PageUtils page = indicatorLibraryService.selectIndicatorLibrarysByReq(req);
return R.ok().put("data",page);
@ -34,7 +42,8 @@ public class IndicatorLibraryController {
@GetMapping("/getById")
public R getById(@Param("id")Long id) {
@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);
@ -44,7 +53,8 @@ public class IndicatorLibraryController {
@PostMapping("/saveOrUpdate")
public R save(@RequestBody IndicatorLibraryDto dto) {
@ApiOperation("保存/修改指标")
public R save(@RequestBody IndicatorLibraryDto dto) {
IndicatorLibrary indicatorLibrary = new IndicatorLibrary();
BeanUtil.copyProperties(dto,indicatorLibrary);
boolean success = indicatorLibraryService.saveOrUpdate(indicatorLibrary);
@ -56,8 +66,27 @@ public class IndicatorLibraryController {
@GetMapping("/delete")
public R delete(@RequestParam String ids) {
indicatorLibraryService.deleteIndicatorLibrarysByIds(ids);
@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();
}
}

View File

@ -4,17 +4,22 @@ 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.service.IndicatorTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;
@RestController
@RequestMapping("/indicatorType")
@Api(value = "指标分类相关接口", tags = { "指标分类相关接口" })
public class IndicatorTypeController {
@ -22,7 +27,8 @@ public class IndicatorTypeController {
private IndicatorTypeService indicatorTypeService;
@RequestMapping("/list")
@PostMapping("/list")
@ApiOperation("获取分类/类型列表")
public R list(@RequestBody IndicatorReq req) {
PageUtils page = indicatorTypeService.selectIndicatorTypesByReq(req);
return R.ok().put("data", page);
@ -30,8 +36,18 @@ public class IndicatorTypeController {
@RequestMapping("/saveOrUpdate")
@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);

View File

@ -39,4 +39,6 @@ public interface IndicatorLibraryMapper extends BaseMapper<IndicatorLibrary> {
void deleteIndicatorLibrarysByIds(@Param("ids") List<Long> ids);
void updateIndicatorLibrarysMove(@Param("ids")List<Long> ids,@Param("indicatorType")Long indicatorType);
}

View File

@ -38,6 +38,7 @@ public interface IndicatorTypeMapper extends BaseMapper<IndicatorType> {
List<IndicatorTypeDto> selectIndicatorTypesByReq(@Param("page") IPage page, @Param("req")IndicatorReq req);
IndicatorType selectIndicatorTypeByName(@Param("name") String name);
}

View File

@ -2,7 +2,9 @@ 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;
@ -11,6 +13,8 @@ import java.math.BigDecimal;
* @Desc:
* @Date: 2021/1/12 14:41
*/
@Data
@ApiModel("指标保存/修改实体")
public class IndicatorLibraryDto {
//
@TableId(value = "id", type = IdType.AUTO)

View File

@ -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;
}

View File

@ -1,5 +1,6 @@
package com.lz.modules.performance.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -9,6 +10,7 @@ import lombok.Data;
* @Date: 2021/1/12 10:21
*/
@Data
@ApiModel("保存/修改分类实体")
public class IndicatorTypeDto {
@ApiModelProperty(value = "id", name = "id")
@ -16,6 +18,9 @@ public class IndicatorTypeDto {
//指标名称
@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

@ -2,6 +2,7 @@ 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;
@ -11,6 +12,7 @@ import lombok.Data;
* @Date: 2021/1/12 14:50
*/
@Data
@ApiModel("获取指标列表实体")
public class IndicatorLibraryReq extends BasePage{
//指标名称
@ApiModelProperty(value = "指标名称", name = "name")

View File

@ -1,6 +1,7 @@
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;
@ -10,6 +11,7 @@ import lombok.Data;
* @Date: 2021/1/12 11:39
*/
@Data
@ApiModel("获取分类/类型实体")
public class IndicatorReq extends BasePage{
//指标名称
@ApiModelProperty(value = "指标分类名称", name = "name")

View File

@ -2,6 +2,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.entity.IndicatorLibrary;
import com.lz.modules.performance.req.IndicatorLibraryReq;
@ -35,5 +36,7 @@ public interface IndicatorLibraryService extends IService<IndicatorLibrary> {
void deleteIndicatorLibrarysByIds(String ids);
void updateIndicatorLibrarysMove(IndicatorLibraryMoveDto dto);
}

View File

@ -33,5 +33,7 @@ public interface IndicatorTypeService extends IService<IndicatorType> {
PageUtils selectIndicatorTypesByReq(IndicatorReq req);
IndicatorType selectIndicatorTypeByName(String name);
}

View File

@ -1,9 +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.entity.IndicatorLibrary;
import com.lz.modules.performance.req.IndicatorLibraryReq;
import com.lz.modules.performance.service.IndicatorLibraryService;
@ -12,6 +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;
/**
@ -83,4 +86,16 @@ public class IndicatorLibraryServiceImpl extends ServiceImpl<IndicatorLibraryMap
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());
}
}

View File

@ -68,4 +68,9 @@ public class IndicatorTypeServiceImpl extends ServiceImpl<IndicatorTypeMapper, I
);
return page;
}
@Override
public IndicatorType selectIndicatorTypeByName(String name) {
return indicatorTypeMapper.selectIndicatorTypeByName(name);
}
}

View File

@ -93,7 +93,14 @@
<select id="selectIndicatorLibrarysByReq" resultType="com.lz.modules.performance.dto.IndicatorLibraryDto">
select id ,name,type,indicator_type, weight, key_result, sort from lz_indicator_library
where name LIKE CONCAT('%',#{req.name},'%') and indicator_type = #{req.indicatorType} and is_delete = 0 order by sort
where is_delete = 0
<if test="req.name!=null and req.name!=''">
and name LIKE CONCAT('%',#{req.name},'%')
</if>
<if test="req.indicatorType!=null">
and indicator_type = #{req.indicatorType}
</if>
order by sort
</select>
<update id="deleteIndicatorLibrarysByIds">
@ -105,6 +112,15 @@
</foreach>
)
</update>
<update id="updateIndicatorLibrarysMove">
update lz_indicator_library set indicator_type = #{indicatorType} where is_delete = 0 AND
id in
(
<foreach collection="ids" item="id" separator=",">
#{id}
</foreach>
)
</update>
</mapper>

View File

@ -80,7 +80,18 @@
</update>
<select id="selectIndicatorTypesByReq" resultType="com.lz.modules.performance.dto.IndicatorTypeDto">
select id,name,sort from lz_indicator_type where name LIKE CONCAT('%',#{req.name},'%') and type = #{req.type} and is_delete = 0 order by sort
select id,name,type,sort from lz_indicator_type where is_delete = 0
<if test="req.type !=null">
and type = #{req.type}
</if>
<if test="req.name !=null and req.name !=''">
and name LIKE CONCAT('%',#{req.name},'%')
</if>
order by sort
</select>
<select id="selectIndicatorTypeByName" resultType="com.lz.modules.performance.entity.IndicatorType">
select * from lz_indicator_type where name = #{name} and is_delete = 0 limit 1
</select>
</mapper>