考核指标管理
parent
7b647d7d10
commit
a475d78afd
|
|
@ -0,0 +1,56 @@
|
|||
package com.gunshi.project.xyt.controller;
|
||||
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.xyt.model.AssessCategory;
|
||||
import com.gunshi.project.xyt.service.AssessCategoryService;
|
||||
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||
import com.gunshi.project.xyt.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 描述: 考核类目
|
||||
* author: xusan
|
||||
* date: 2024-09-03 17:46:30
|
||||
*/
|
||||
@Tag(name = "考核类目")
|
||||
@RestController
|
||||
@RequestMapping(value="/assessCategory")
|
||||
public class AssessCategoryController {
|
||||
|
||||
@Autowired
|
||||
private AssessCategoryService service;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<AssessCategory> insert(@Validated(Insert.class) @RequestBody AssessCategory dto) {
|
||||
return R.ok(service.saveData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<AssessCategory> update(@Validated(Update.class) @RequestBody AssessCategory dto) {
|
||||
return R.ok(service.updateData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
return R.ok(service.delData(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "列表")
|
||||
@PostMapping("/list")
|
||||
public R<List<AssessCategory>> list() {
|
||||
return R.ok(service.lambdaQuery().orderByAsc(AssessCategory::getOrderIndex).list());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.gunshi.project.xyt.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.xyt.entity.dto.InspectItemDto;
|
||||
import com.gunshi.project.xyt.entity.so.AttCctvBasePage;
|
||||
import com.gunshi.project.xyt.model.AssessIndicator;
|
||||
import com.gunshi.project.xyt.service.AssessIndicatorService;
|
||||
import com.gunshi.project.xyt.validate.markers.Insert;
|
||||
import com.gunshi.project.xyt.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
/**
|
||||
* 描述: 考核指标
|
||||
* author: xusan
|
||||
* date: 2024-09-03 17:46:56
|
||||
*/
|
||||
@Tag(name = "考核指标")
|
||||
@RestController
|
||||
@RequestMapping(value="/assessIndicator")
|
||||
public class AssessIndicatorController {
|
||||
|
||||
@Autowired
|
||||
private AssessIndicatorService service;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<AssessIndicator> insert(@Validated(Insert.class) @RequestBody AssessIndicator dto) {
|
||||
return R.ok(service.saveData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<AssessIndicator> update(@Validated(Update.class) @RequestBody AssessIndicator dto) {
|
||||
return R.ok(service.updateData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Long id) {
|
||||
return R.ok(service.delData(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "启停")
|
||||
@PostMapping("/startStop")
|
||||
public R<String> startStop(@RequestBody InspectItemDto dto) {
|
||||
return R.ok(service.startStop(dto));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "分页")
|
||||
@PostMapping("/page")
|
||||
public R<Page<AssessIndicator>> page(@RequestBody @Validated AttCctvBasePage page) {
|
||||
return R.ok(service.pageQuery(page));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.AssessCategory;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 考核类目
|
||||
* author: xusan
|
||||
* date: 2024-09-03 17:46:30
|
||||
*/
|
||||
@Mapper
|
||||
public interface AssessCategoryMapper extends BaseMapper<AssessCategory> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.AssessIndicator;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 考核指标
|
||||
* author: xusan
|
||||
* date: 2024-09-03 17:46:56
|
||||
*/
|
||||
@Mapper
|
||||
public interface AssessIndicatorMapper extends BaseMapper<AssessIndicator> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.AssessIndicatorRating;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 考核指标评分细则
|
||||
* author: xusan
|
||||
* date: 2024-09-03 17:47:17
|
||||
*/
|
||||
@Mapper
|
||||
public interface AssessIndicatorRatingMapper extends BaseMapper<AssessIndicatorRating> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.gunshi.project.xyt.model;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.project.xyt.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述: 考核类目
|
||||
* author: xusan
|
||||
* date: 2024-09-03 17:46:29
|
||||
*/
|
||||
@Schema(description="考核类目")
|
||||
@Data
|
||||
@TableName("public.assess_category")
|
||||
public class AssessCategory implements Serializable {
|
||||
|
||||
public final static String thisTableName = "AssessCategory";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@Schema(description="主键")
|
||||
@NotNull(message = "id不能为空",groups = { Update.class})
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value="name")
|
||||
@Schema(description="名称")
|
||||
@Size(max = 255,message = "名称最大长度要小于 255")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField(value="order_index")
|
||||
@Schema(description="排序")
|
||||
private Integer orderIndex;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
package com.gunshi.project.xyt.model;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.project.xyt.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 考核指标
|
||||
* author: xusan
|
||||
* date: 2024-09-03 17:46:55
|
||||
*/
|
||||
@Schema(description="考核指标")
|
||||
@Data
|
||||
@TableName("public.assess_indicator")
|
||||
public class AssessIndicator implements Serializable {
|
||||
|
||||
public final static String thisTableName = "AssessIndicator";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@Schema(description="主键")
|
||||
@NotNull(message = "id不能为空",groups = { Update.class})
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 考核类目id
|
||||
*/
|
||||
@TableField(value="category_id")
|
||||
@Schema(description="考核类目id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
@TableField(value="indicator_name")
|
||||
@Schema(description="指标名称")
|
||||
@Size(max = 100,message = "指标名称最大长度要小于 100")
|
||||
private String indicatorName;
|
||||
|
||||
/**
|
||||
* 指标编码
|
||||
*/
|
||||
@TableField(value="indicator_code")
|
||||
@Schema(description="指标编码")
|
||||
@Size(max = 100,message = "指标编码最大长度要小于 100")
|
||||
private String indicatorCode;
|
||||
|
||||
/**
|
||||
* 标准分数
|
||||
*/
|
||||
@TableField(value="standard_score")
|
||||
@Schema(description="标准分数")
|
||||
private Integer standardScore;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
@TableField(value="order_index")
|
||||
@Schema(description="排序号")
|
||||
private Integer orderIndex;
|
||||
|
||||
/**
|
||||
* 状态(0启用 1停用)
|
||||
*/
|
||||
@TableField(value="status")
|
||||
@Schema(description="状态(0启用 1停用)")
|
||||
private Integer status;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "评分细则")
|
||||
private List<AssessIndicatorRating> indicatorRatings;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.gunshi.project.xyt.model;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.project.xyt.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述: 考核指标评分细则
|
||||
* author: xusan
|
||||
* date: 2024-09-03 17:47:16
|
||||
*/
|
||||
@Schema(description="考核指标评分细则")
|
||||
@Data
|
||||
@TableName("public.assess_indicator_rating")
|
||||
public class AssessIndicatorRating implements Serializable {
|
||||
|
||||
public final static String thisTableName = "AssessIndicatorRating";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@Schema(description="主键")
|
||||
@NotNull(message = "id不能为空",groups = { Update.class})
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 指标id
|
||||
*/
|
||||
@TableField(value="indicator_id")
|
||||
@Schema(description="指标id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long indicatorId;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@TableField(value="rating_desc")
|
||||
@Schema(description="描述")
|
||||
@Size(max = 500,message = "描述最大长度要小于 500")
|
||||
private String ratingDesc;
|
||||
|
||||
/**
|
||||
* 标准分数
|
||||
*/
|
||||
@TableField(value="standard_score")
|
||||
@Schema(description="标准分数")
|
||||
private Integer standardScore;
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
@TableField(value="order_index")
|
||||
@Schema(description="排序号")
|
||||
private Integer orderIndex;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.xyt.mapper.AssessCategoryMapper;
|
||||
import com.gunshi.project.xyt.mapper.AssessIndicatorMapper;
|
||||
import com.gunshi.project.xyt.model.AssessCategory;
|
||||
import com.gunshi.project.xyt.model.AssessIndicator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述: 考核类目
|
||||
* author: xusan
|
||||
* date: 2024-09-03 17:46:30
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class AssessCategoryService extends ServiceImpl<AssessCategoryMapper, AssessCategory>
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private AssessIndicatorMapper indicatorMapper;
|
||||
|
||||
public AssessCategory saveData(AssessCategory dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
QueryWrapper<AssessCategory> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderBy(true, false, "order_index");
|
||||
AssessCategory lastOne = super.getOne(queryWrapper, false);
|
||||
int order = 0;
|
||||
if (lastOne == null) {
|
||||
order = 1;
|
||||
} else {
|
||||
order = lastOne.getOrderIndex() + 1;
|
||||
}
|
||||
dto.setOrderIndex(order);
|
||||
this.save(dto);
|
||||
return dto;
|
||||
}
|
||||
|
||||
public AssessCategory updateData(AssessCategory dto) {
|
||||
if (Objects.isNull(this.getById(dto.getId()))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
this.updateById(dto);
|
||||
return dto;
|
||||
}
|
||||
|
||||
public Boolean delData(Serializable id) {
|
||||
if (Objects.isNull(this.getById(id))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
//判断是否关联指标
|
||||
LambdaQueryWrapper<AssessIndicator> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(AssessIndicator::getCategoryId,id);
|
||||
if(indicatorMapper.selectCount(wrapper) > 0){
|
||||
throw new IllegalArgumentException("请先删除关联的考核指标");
|
||||
}
|
||||
return this.removeById(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.xyt.mapper.AssessIndicatorRatingMapper;
|
||||
import com.gunshi.project.xyt.model.AssessIndicatorRating;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 考核指标评分细则
|
||||
* author: xusan
|
||||
* date: 2024-09-03 17:47:17
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class AssessIndicatorRatingService extends ServiceImpl<AssessIndicatorRatingMapper, AssessIndicatorRating>
|
||||
{
|
||||
|
||||
public void saveRating(List<AssessIndicatorRating> indicatorRatings,Long id) {
|
||||
indicatorRatings.stream().forEach(o->{
|
||||
o.setId(IdWorker.getId());
|
||||
o.setIndicatorId(id);
|
||||
});
|
||||
this.saveBatch(indicatorRatings);
|
||||
}
|
||||
|
||||
public void updateRating(List<AssessIndicatorRating> indicatorRatings, Long id) {
|
||||
delRating(id);
|
||||
saveRating(indicatorRatings,id);
|
||||
}
|
||||
|
||||
public void delRating(Long indicatorId) {
|
||||
this.remove(new QueryWrapper<AssessIndicatorRating>().eq("indicator_id",indicatorId));
|
||||
}
|
||||
|
||||
public List<AssessIndicatorRating> queryRatingList(List<Long> ids) {
|
||||
return this.list(new QueryWrapper<AssessIndicatorRating>().in("indicator_id",ids));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.xyt.entity.dto.InspectItemDto;
|
||||
import com.gunshi.project.xyt.entity.so.AttCctvBasePage;
|
||||
import com.gunshi.project.xyt.mapper.AssessIndicatorMapper;
|
||||
import com.gunshi.project.xyt.model.AssessIndicator;
|
||||
import com.gunshi.project.xyt.model.AssessIndicatorRating;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 描述: 考核指标
|
||||
* author: xusan
|
||||
* date: 2024-09-03 17:46:56
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class AssessIndicatorService extends ServiceImpl<AssessIndicatorMapper, AssessIndicator> {
|
||||
@Autowired
|
||||
private AssessIndicatorRatingService indicatorRatingService;
|
||||
|
||||
public String startStop(InspectItemDto dto) {
|
||||
Integer status = dto.getStatus();
|
||||
AssessIndicator indicator = super.getById(dto.getId());
|
||||
if (indicator == null) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
indicator.setStatus(status);
|
||||
boolean flag = super.updateById(indicator);
|
||||
if (flag) {
|
||||
return status == 0 ? "启用成功" : "禁用成功";
|
||||
}
|
||||
return status == 0 ? "启用失败" : "禁用失败";
|
||||
}
|
||||
|
||||
public Page<AssessIndicator> pageQuery(AttCctvBasePage page) {
|
||||
LambdaQueryWrapper<AssessIndicator> query = Wrappers.lambdaQuery();
|
||||
if (ObjectUtils.isNotNull(page.getMenuId())) {
|
||||
query.eq(AssessIndicator::getCategoryId, page.getMenuId());
|
||||
}
|
||||
query.orderByAsc(AssessIndicator::getStatus).orderByAsc(AssessIndicator::getOrderIndex);
|
||||
Page<AssessIndicator> res = this.page(page.getPageSo().toPage(), query);
|
||||
if (res.getRecords() != null && res.getRecords().size() > 0) {
|
||||
fillRating(res.getRecords());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private void fillRating(List<AssessIndicator> records) {
|
||||
List<Long> ids = records.stream().map(AssessIndicator::getId).collect(Collectors.toList());
|
||||
List<AssessIndicatorRating> relList = indicatorRatingService.queryRatingList(ids);
|
||||
Map<Long, List<AssessIndicatorRating>> map = relList.stream().collect(Collectors.groupingBy(AssessIndicatorRating::getIndicatorId));
|
||||
for (AssessIndicator record : records) {
|
||||
record.setIndicatorRatings(map.get(record.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
public AssessIndicator saveData(AssessIndicator dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
dto.setStatus(0);
|
||||
this.save(dto);
|
||||
indicatorRatingService.saveRating(dto.getIndicatorRatings(),dto.getId());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public AssessIndicator updateData(AssessIndicator dto) {
|
||||
if (Objects.isNull(this.getById(dto.getId()))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
this.updateById(dto);
|
||||
indicatorRatingService.updateRating(dto.getIndicatorRatings(),dto.getId());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public Boolean delData(Long id) {
|
||||
if (Objects.isNull(this.getById(id))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
indicatorRatingService.delRating(id);
|
||||
return this.removeById(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue