考核模板
parent
0402b9b97d
commit
097d13e723
|
|
@ -59,4 +59,10 @@ public class AssessIndicatorController {
|
|||
return R.ok(service.pageQuery(page));
|
||||
}
|
||||
|
||||
@Operation(summary = "选择指标")
|
||||
@PostMapping("/choose")
|
||||
public R<Page<AssessIndicator>> choosePage(@RequestBody @Validated AttCctvBasePage page) {
|
||||
return R.ok(service.choosePage(page));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
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.model.AssessTemplate;
|
||||
import com.gunshi.project.xyt.service.AssessTemplateService;
|
||||
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.util.List;
|
||||
/**
|
||||
* 描述: 考核模板
|
||||
* author: xusan
|
||||
* date: 2024-09-04 13:42:40
|
||||
*/
|
||||
@Tag(name = "考核模板")
|
||||
@RestController
|
||||
@RequestMapping(value="/assessTemplate")
|
||||
public class AssessTemplateController {
|
||||
|
||||
@Autowired
|
||||
private AssessTemplateService service;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<AssessTemplate> insert(@Validated(Insert.class) @RequestBody AssessTemplate dto) {
|
||||
return R.ok(service.saveData(dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<AssessTemplate> update(@Validated(Update.class) @RequestBody AssessTemplate 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("/list")
|
||||
public R<List<AssessTemplate>> list() {
|
||||
return R.ok(service.lambdaQuery().list());
|
||||
}
|
||||
|
||||
@Operation(summary = "分页")
|
||||
@PostMapping("/page")
|
||||
public R<Page<AssessTemplate>> page(@RequestBody @Validated AttCctvBasePage page) {
|
||||
return R.ok(service.pageQuery(page));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据模板id查询关联的指标")
|
||||
@GetMapping("/queryIndicators/{id}")
|
||||
public R<List<AssessIndicator>> queryIndicators(@Schema(name = "id") @PathVariable("id") Long id) {
|
||||
return R.ok(service.queryIndicators(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -49,8 +49,8 @@ public class InspectItemController {
|
|||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
return R.ok(service.removeById(id));
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Long id) {
|
||||
return R.ok(service.delData(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "启停")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.project.xyt.entity.so.AttCctvBasePage;
|
||||
import com.gunshi.project.xyt.model.AssessIndicator;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 描述: 考核指标
|
||||
|
|
@ -12,4 +16,19 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
@Mapper
|
||||
public interface AssessIndicatorMapper extends BaseMapper<AssessIndicator> {
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
select t1.*,t2.name from public.assess_indicator t1
|
||||
left join public.assess_category t2 on t1.category_id = t2.id
|
||||
where t1.status = 0
|
||||
<if test="obj.menuId != null ">
|
||||
and t1.category_id = #{obj.menuId}
|
||||
</if>
|
||||
<if test="obj.name != null and obj.name != ''">
|
||||
and t1.indicator_name like concat('%', #{obj.name}, '%')
|
||||
</if>
|
||||
order by t2.order_index,t1.order_index
|
||||
</script>
|
||||
""")
|
||||
Page<AssessIndicator> choosePage(Page<AssessIndicator> page,@Param("obj") AttCctvBasePage page1);
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.AssessTemplateIndicatorRel;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 描述: 模板关联指标
|
||||
* author: xusan
|
||||
* date: 2024-09-04 13:43:05
|
||||
*/
|
||||
@Mapper
|
||||
public interface AssessTemplateIndicatorRelMapper extends BaseMapper<AssessTemplateIndicatorRel> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.xyt.model.AssessIndicator;
|
||||
import com.gunshi.project.xyt.model.AssessTemplate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 考核模板
|
||||
* author: xusan
|
||||
* date: 2024-09-04 13:42:40
|
||||
*/
|
||||
@Mapper
|
||||
public interface AssessTemplateMapper extends BaseMapper<AssessTemplate> {
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
select t1.*,t2.name from public.assess_indicator t1
|
||||
left join public.assess_category t2 on t1.category_id = t2.id
|
||||
where t1.id in (select indicator_id from public.assess_template_indicator_rel where template_id = #{id})
|
||||
order by t1.order_index
|
||||
</script>
|
||||
""")
|
||||
List<AssessIndicator> queryIndicators(@Param("id") Long id);
|
||||
}
|
||||
|
|
@ -47,6 +47,10 @@ public class AssessIndicator implements Serializable {
|
|||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long categoryId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description="考核类目名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
|
|
@ -84,6 +88,13 @@ public class AssessIndicator implements Serializable {
|
|||
@Schema(description="状态(0启用 1停用)")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否被使用(0否 1是)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@Schema(description="是否被使用(0否 1是)")
|
||||
private Integer isUsed;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "评分细则")
|
||||
private List<AssessIndicatorRating> indicatorRatings;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,129 @@
|
|||
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.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.core.dateformat.DateFormatString;
|
||||
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.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 考核模板
|
||||
* author: xusan
|
||||
* date: 2024-09-04 13:42:39
|
||||
*/
|
||||
@Schema(description="考核模板")
|
||||
@Data
|
||||
@TableName("public.assess_template")
|
||||
public class AssessTemplate implements Serializable {
|
||||
|
||||
public final static String thisTableName = "AssessTemplate";
|
||||
|
||||
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="template_name")
|
||||
@Schema(description="模板名称")
|
||||
@Size(max = 100,message = "模板名称最大长度要小于 100")
|
||||
private String templateName;
|
||||
|
||||
/**
|
||||
* 考核频次(1年度 2季度 3月度)
|
||||
*/
|
||||
@TableField(value="template_freq")
|
||||
@Schema(description="考核频次(1年度 2季度 3月度)")
|
||||
private Integer templateFreq;
|
||||
|
||||
/**
|
||||
* 标准分数
|
||||
*/
|
||||
@TableField(value="standard_score")
|
||||
@Schema(description="标准分数")
|
||||
private Integer standardScore;
|
||||
|
||||
/**
|
||||
* 优秀分
|
||||
*/
|
||||
@TableField(value="excellent_score")
|
||||
@Schema(description="优秀分")
|
||||
private BigDecimal excellentScore;
|
||||
|
||||
/**
|
||||
* 良好分
|
||||
*/
|
||||
@TableField(value="good_score")
|
||||
@Schema(description="良好分")
|
||||
private BigDecimal goodScore;
|
||||
|
||||
/**
|
||||
* 合格分
|
||||
*/
|
||||
@TableField(value="pass_score")
|
||||
@Schema(description="合格分")
|
||||
private BigDecimal passScore;
|
||||
|
||||
/**
|
||||
* 状态(0启用 1停用)
|
||||
*/
|
||||
@TableField(value="status")
|
||||
@Schema(description="状态(0启用 1停用)")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(value="create_user_id")
|
||||
@Schema(description="创建人id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名称
|
||||
*/
|
||||
@TableField(value="create_user_name")
|
||||
@Schema(description="创建人名称")
|
||||
@Size(max = 100,message = "创建人名称最大长度要小于 100")
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value="create_time")
|
||||
@Schema(description="创建时间")
|
||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 是否被使用(0否 1是)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@Schema(description="是否被使用(0否 1是)")
|
||||
private Integer isUsed;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "关联的考核指标")
|
||||
private List<Long> indicatorIds;
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
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 io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 描述: 模板关联指标
|
||||
* author: xusan
|
||||
* date: 2024-09-04 13:43:04
|
||||
*/
|
||||
@Schema(description="模板关联指标")
|
||||
@Data
|
||||
@TableName("public.assess_template_indicator_rel")
|
||||
public class AssessTemplateIndicatorRel implements Serializable {
|
||||
|
||||
public final static String thisTableName = "AssessTemplateIndicatorRel";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value="id", type= IdType.AUTO)
|
||||
@Schema(description="主键")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 模板id
|
||||
*/
|
||||
@TableField(value="template_id")
|
||||
@Schema(description="模板id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long templateId;
|
||||
|
||||
/**
|
||||
* 指标id
|
||||
*/
|
||||
@TableField(value="indicator_id")
|
||||
@Schema(description="指标id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long indicatorId;
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
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.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
|
@ -9,8 +10,10 @@ 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.mapper.AssessTemplateIndicatorRelMapper;
|
||||
import com.gunshi.project.xyt.model.AssessIndicator;
|
||||
import com.gunshi.project.xyt.model.AssessIndicatorRating;
|
||||
import com.gunshi.project.xyt.model.AssessTemplateIndicatorRel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -33,6 +36,9 @@ public class AssessIndicatorService extends ServiceImpl<AssessIndicatorMapper, A
|
|||
@Autowired
|
||||
private AssessIndicatorRatingService indicatorRatingService;
|
||||
|
||||
@Autowired
|
||||
private AssessTemplateIndicatorRelMapper relMapper;
|
||||
|
||||
public String startStop(InspectItemDto dto) {
|
||||
Integer status = dto.getStatus();
|
||||
AssessIndicator indicator = super.getById(dto.getId());
|
||||
|
|
@ -55,11 +61,21 @@ public class AssessIndicatorService extends ServiceImpl<AssessIndicatorMapper, A
|
|||
query.orderByAsc(AssessIndicator::getStatus).orderByAsc(AssessIndicator::getOrderIndex);
|
||||
Page<AssessIndicator> res = this.page(page.getPageSo().toPage(), query);
|
||||
if (res.getRecords() != null && res.getRecords().size() > 0) {
|
||||
fillUsedInfo(res.getRecords());
|
||||
fillRating(res.getRecords());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private void fillUsedInfo(List<AssessIndicator> records) {
|
||||
List<Long> ids = records.stream().map(AssessIndicator::getId).collect(Collectors.toList());
|
||||
List<AssessTemplateIndicatorRel> list = relMapper.selectList(new QueryWrapper<AssessTemplateIndicatorRel>().in("indicator_id", ids));
|
||||
Map<Long, Long> map = list.stream().collect(Collectors.groupingBy(AssessTemplateIndicatorRel::getIndicatorId, Collectors.counting()));
|
||||
for (AssessIndicator record : records) {
|
||||
record.setIsUsed(map.containsKey(record.getId()) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void fillRating(List<AssessIndicator> records) {
|
||||
List<Long> ids = records.stream().map(AssessIndicator::getId).collect(Collectors.toList());
|
||||
List<AssessIndicatorRating> relList = indicatorRatingService.queryRatingList(ids);
|
||||
|
|
@ -90,9 +106,17 @@ public class AssessIndicatorService extends ServiceImpl<AssessIndicatorMapper, A
|
|||
if (Objects.isNull(this.getById(id))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
Long count = relMapper.selectCount(new QueryWrapper<AssessTemplateIndicatorRel>().eq("indicator_id", id));
|
||||
if(count > 0){
|
||||
throw new IllegalArgumentException("该考核指标已被使用,不可删除");
|
||||
}
|
||||
indicatorRatingService.delRating(id);
|
||||
return this.removeById(id);
|
||||
}
|
||||
|
||||
public Page<AssessIndicator> choosePage(AttCctvBasePage page) {
|
||||
return this.baseMapper.choosePage(page.getPageSo().toPage(),page);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.AssessTemplateIndicatorRelMapper;
|
||||
import com.gunshi.project.xyt.model.AssessTemplateIndicatorRel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 描述: 模板关联指标
|
||||
* author: xusan
|
||||
* date: 2024-09-04 13:43:05
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class AssessTemplateIndicatorRelService extends ServiceImpl<AssessTemplateIndicatorRelMapper, AssessTemplateIndicatorRel>
|
||||
{
|
||||
|
||||
public void saveRel(List<Long> indicatorIds, Long id) {
|
||||
List<AssessTemplateIndicatorRel> list = indicatorIds.stream().map(o -> {
|
||||
AssessTemplateIndicatorRel rel = new AssessTemplateIndicatorRel();
|
||||
rel.setId(IdWorker.getId());
|
||||
rel.setTemplateId(id);
|
||||
rel.setIndicatorId(o);
|
||||
return rel;
|
||||
}).collect(Collectors.toList());
|
||||
this.saveBatch(list);
|
||||
}
|
||||
|
||||
public void delRel(Long templateId) {
|
||||
this.remove(new QueryWrapper<AssessTemplateIndicatorRel>().eq("template_id",templateId));
|
||||
}
|
||||
|
||||
public void updateRel(List<Long> indicatorIds, Long id) {
|
||||
this.delRel(id);
|
||||
this.saveRel(indicatorIds,id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
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.AssessTemplateMapper;
|
||||
import com.gunshi.project.xyt.model.AssessIndicator;
|
||||
import com.gunshi.project.xyt.model.AssessTemplate;
|
||||
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.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 描述: 考核模板
|
||||
* author: xusan
|
||||
* date: 2024-09-04 13:42:40
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class AssessTemplateService extends ServiceImpl<AssessTemplateMapper, AssessTemplate>
|
||||
{
|
||||
@Autowired
|
||||
private AssessTemplateIndicatorRelService relService;
|
||||
|
||||
public AssessTemplate saveData(AssessTemplate dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
dto.setStatus(0);
|
||||
dto.setCreateTime(new Date());
|
||||
this.save(dto);
|
||||
relService.saveRel(dto.getIndicatorIds(),dto.getId());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public AssessTemplate updateData(AssessTemplate dto) {
|
||||
if (Objects.isNull(this.getById(dto.getId()))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
this.updateById(dto);
|
||||
relService.updateRel(dto.getIndicatorIds(),dto.getId());
|
||||
return dto;
|
||||
}
|
||||
|
||||
public Boolean delData(Long id) {
|
||||
if (Objects.isNull(this.getById(id))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
relService.delRel(id);
|
||||
return this.removeById(id);
|
||||
|
||||
}
|
||||
|
||||
public Page<AssessTemplate> pageQuery(AttCctvBasePage page) {
|
||||
LambdaQueryWrapper<AssessTemplate> query = Wrappers.lambdaQuery();
|
||||
if (ObjectUtils.isNotNull(page.getName())) {
|
||||
query.like(AssessTemplate::getTemplateName, page.getName());
|
||||
}
|
||||
query.orderByAsc(AssessTemplate::getStatus).orderByDesc(AssessTemplate::getCreateTime);
|
||||
Page<AssessTemplate> res = this.page(page.getPageSo().toPage(), query);
|
||||
return res;
|
||||
}
|
||||
|
||||
public String startStop(InspectItemDto dto) {
|
||||
Integer status = dto.getStatus();
|
||||
AssessTemplate template = super.getById(dto.getId());
|
||||
if (template == null) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
template.setStatus(status);
|
||||
boolean flag = super.updateById(template);
|
||||
if (flag) {
|
||||
return status == 0 ? "启用成功" : "禁用成功";
|
||||
}
|
||||
return status == 0 ? "启用失败" : "禁用失败";
|
||||
}
|
||||
|
||||
public List<AssessIndicator> queryIndicators(Long id) {
|
||||
return this.baseMapper.queryIndicators(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
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.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
|
@ -8,11 +9,16 @@ 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.InspectItemMapper;
|
||||
import com.gunshi.project.xyt.mapper.InspectTaskDetailMapper;
|
||||
import com.gunshi.project.xyt.model.InspectItem;
|
||||
import com.gunshi.project.xyt.model.InspectTaskDetail;
|
||||
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.Objects;
|
||||
|
||||
/**
|
||||
* 描述: 巡检项
|
||||
* author: xusan
|
||||
|
|
@ -23,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public class InspectItemService extends ServiceImpl<InspectItemMapper, InspectItem>
|
||||
{
|
||||
@Autowired
|
||||
private InspectTaskDetailMapper taskDetailMapper;
|
||||
|
||||
public Page<InspectItem> pageQuery(AttCctvBasePage page) {
|
||||
LambdaQueryWrapper<InspectItem> query = Wrappers.lambdaQuery();
|
||||
|
|
@ -47,6 +55,17 @@ public class InspectItemService extends ServiceImpl<InspectItemMapper, InspectIt
|
|||
}
|
||||
return status == 0 ? "启用失败" : "禁用失败";
|
||||
}
|
||||
|
||||
public Boolean delData(Long id) {
|
||||
if (Objects.isNull(this.getById(id))) {
|
||||
throw new IllegalArgumentException("当前数据不存在");
|
||||
}
|
||||
Long count = taskDetailMapper.selectCount(new QueryWrapper<InspectTaskDetail>().eq("item_id", id));
|
||||
if(count > 0){
|
||||
throw new IllegalArgumentException("该巡检项已被巡检任务使用,不可删除");
|
||||
}
|
||||
return this.removeById(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue