feat(coding): 在属性和分类实体中添加排序字段并更新服务

在属性和属性分类实体中引入排序字段,以便对它们进行有序管理。更新相关服务方法以支持排序字段的查询,确保数据能够按排序字段进行升序处理。
This commit is contained in:
lijiaqi 2024-09-18 11:38:08 +08:00
parent 8daedaba75
commit 724929d92d
10 changed files with 62 additions and 12 deletions

View File

@ -37,5 +37,8 @@ public class Attribute extends BaseEntity {
@Schema(description = "是否锁定") @Schema(description = "是否锁定")
private Boolean locked; private Boolean locked;
@Schema(description = "排序")
private Integer sortNo;
} }

View File

@ -25,5 +25,8 @@ public class AttributeClassification extends BaseEntity {
@Schema(description = "属性分类名称") @Schema(description = "属性分类名称")
private String attributeClassificationName; private String attributeClassificationName;
@Schema(description = "排序")
private Integer sortNo;
} }

View File

@ -91,11 +91,14 @@ public class AttributeClassificationService extends BaseService<AttributeClassif
return Result.data(this.page(page, new QueryWrapper<AttributeClassification>() return Result.data(this.page(page, new QueryWrapper<AttributeClassification>()
.lambda() .lambda()
.like(StrUtil.isNotBlank(vo.getAttributeClassificationName()), AttributeClassification::getAttributeClassificationName, vo.getAttributeClassificationName()) .like(StrUtil.isNotBlank(vo.getAttributeClassificationName()), AttributeClassification::getAttributeClassificationName, vo.getAttributeClassificationName())
.orderByAsc(AttributeClassification::getSortNo)
)); ));
} }
public Result<List<AttributeClassification>> getAttributeClassificationList() { public Result<List<AttributeClassification>> getAttributeClassificationList() {
return Result.data(this.list()); return Result.data(this.list(new QueryWrapper<AttributeClassification>()
.lambda()
.orderByAsc(AttributeClassification::getSortNo)));
} }
} }

View File

@ -102,6 +102,7 @@ public class AttributeService extends BaseService<AttributeMapper, Attribute> {
.like(StrUtil.isNotBlank(vo.getAttributeDescription()), Attribute::getAttributeDescription, vo.getAttributeDescription()) .like(StrUtil.isNotBlank(vo.getAttributeDescription()), Attribute::getAttributeDescription, vo.getAttributeDescription())
.like(StrUtil.isNotBlank(vo.getAttributeRemarks()), Attribute::getAttributeRemarks, vo.getAttributeRemarks()) .like(StrUtil.isNotBlank(vo.getAttributeRemarks()), Attribute::getAttributeRemarks, vo.getAttributeRemarks())
.like(StrUtil.isNotBlank(vo.getAttributeName()), Attribute::getAttributeName, vo.getAttributeName()) .like(StrUtil.isNotBlank(vo.getAttributeName()), Attribute::getAttributeName, vo.getAttributeName())
.orderByAsc(Attribute::getSortNo)
))); )));
} }
@ -109,6 +110,7 @@ public class AttributeService extends BaseService<AttributeMapper, Attribute> {
return Result.data(AttributeWrapper.INSTANCE.toDto(this.list(new QueryWrapper<Attribute>() return Result.data(AttributeWrapper.INSTANCE.toDto(this.list(new QueryWrapper<Attribute>()
.lambda() .lambda()
.eq(StrUtil.isNotBlank(attributeClassificationId), Attribute::getAttributeClassificationId, attributeClassificationId) .eq(StrUtil.isNotBlank(attributeClassificationId), Attribute::getAttributeClassificationId, attributeClassificationId)
.orderByAsc(Attribute::getSortNo)
))); )));
} }

View File

@ -6,16 +6,19 @@ import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.workde.core.base.BaseService; import cn.workde.core.base.BaseService;
import cn.workde.core.data.dto.Result; import cn.workde.core.data.dto.Result;
import cn.workde.core.util.SpringUtil;
import cn.workde.module.drone.coding.dto.AttributeValueDto; import cn.workde.module.drone.coding.dto.AttributeValueDto;
import cn.workde.module.drone.coding.dto.BatchesDto; import cn.workde.module.drone.coding.dto.BatchesDto;
import cn.workde.module.drone.coding.dto.CodeDto; import cn.workde.module.drone.coding.dto.CodeDto;
import cn.workde.module.drone.coding.entity.*; import cn.workde.module.drone.coding.entity.*;
import cn.workde.module.drone.coding.mapper.AttributeValueMapper;
import cn.workde.module.drone.coding.mapper.BatchesMapper; import cn.workde.module.drone.coding.mapper.BatchesMapper;
import cn.workde.module.drone.coding.vo.AttributeValueVo2; import cn.workde.module.drone.coding.vo.AttributeValueVo2;
import cn.workde.module.drone.coding.vo.BatchesVo; import cn.workde.module.drone.coding.vo.BatchesVo;
import cn.workde.module.drone.coding.wrapper.BatchesWrapper; import cn.workde.module.drone.coding.wrapper.BatchesWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
@ -127,12 +130,16 @@ public class BatchesService extends BaseService<BatchesMapper, Batches> {
.like(StrUtil.isNotBlank(vo.getBatchesDescription()), Batches::getBatchesDescription, vo.getBatchesDescription()) .like(StrUtil.isNotBlank(vo.getBatchesDescription()), Batches::getBatchesDescription, vo.getBatchesDescription())
.eq(StrUtil.isNotBlank(vo.getMfcId()), Batches::getMfcId, vo.getMfcId()) .eq(StrUtil.isNotBlank(vo.getMfcId()), Batches::getMfcId, vo.getMfcId())
.eq(StrUtil.isNotBlank(vo.getRuleId()), Batches::getRuleId, vo.getRuleId()) .eq(StrUtil.isNotBlank(vo.getRuleId()), Batches::getRuleId, vo.getRuleId())
.orderByAsc(Batches::getCreatedAt)
); );
return Result.data(BatchesWrapper.INSTANCE.toDto(paged)); return Result.data(BatchesWrapper.INSTANCE.toDto(paged));
} }
public Result<List<BatchesDto>> getBatchesList() { public Result<List<BatchesDto>> getBatchesList() {
List<Batches> list = this.list(new QueryWrapper<Batches>()); List<Batches> list = this.list(new QueryWrapper<Batches>()
.lambda()
.orderByAsc(Batches::getCreatedAt)
);
return Result.data(BatchesWrapper.INSTANCE.toDto(list)); return Result.data(BatchesWrapper.INSTANCE.toDto(list));
} }
@ -148,6 +155,7 @@ public class BatchesService extends BaseService<BatchesMapper, Batches> {
new QueryWrapper<AttributeClassification>() new QueryWrapper<AttributeClassification>()
.lambda() .lambda()
.inSql(AttributeClassification::getId, "select distinct attribute_classification_id from dss_drone_coding_attribute_value where mfc_id = '" + mfcId + "'") .inSql(AttributeClassification::getId, "select distinct attribute_classification_id from dss_drone_coding_attribute_value where mfc_id = '" + mfcId + "'")
.orderByAsc(AttributeClassification::getSortNo)
); );
if (CollUtil.isNotEmpty(attributeClassifications)) { if (CollUtil.isNotEmpty(attributeClassifications)) {
List<AttributeValueDto.AttributeClassificationDTO> attributeClassificationDtoList = new ArrayList<AttributeValueDto.AttributeClassificationDTO>(); List<AttributeValueDto.AttributeClassificationDTO> attributeClassificationDtoList = new ArrayList<AttributeValueDto.AttributeClassificationDTO>();
@ -156,11 +164,14 @@ public class BatchesService extends BaseService<BatchesMapper, Batches> {
attributeClassificationDTO.setAttributeClassificationId(attributeClassification.getId()); attributeClassificationDTO.setAttributeClassificationId(attributeClassification.getId());
attributeClassificationDTO.setAttributeClassificationName(attributeClassification.getAttributeClassificationName()); attributeClassificationDTO.setAttributeClassificationName(attributeClassification.getAttributeClassificationName());
//获取属性值 //获取属性值
List<AttributeValue> attributeValues = attributeValueService.list( List<AttributeValue> attributeValues = SpringUtil.getBean(AttributeValueMapper.class).selectJoinList(
new QueryWrapper<AttributeValue>() AttributeValue.class,
.lambda() new MPJLambdaWrapper<AttributeValue>()
.selectAll(AttributeValue.class)
.leftJoin(Attribute.class, Attribute::getId, AttributeValue::getAttributeId)
.eq(AttributeValue::getMfcId, mfcId) .eq(AttributeValue::getMfcId, mfcId)
.eq(AttributeValue::getAttributeClassificationId, attributeClassification.getId()) .eq(AttributeValue::getAttributeClassificationId, attributeClassification.getId())
.orderByAsc(Attribute::getSortNo)
); );
if (CollUtil.isNotEmpty(attributeValues)) { if (CollUtil.isNotEmpty(attributeValues)) {
List<AttributeValueDto.AttributeDTO> attributeDtoList = new ArrayList<AttributeValueDto.AttributeDTO>(); List<AttributeValueDto.AttributeDTO> attributeDtoList = new ArrayList<AttributeValueDto.AttributeDTO>();

View File

@ -265,7 +265,7 @@ public class CodeService extends BaseService<CodeMapper, Code>{
.like(StrUtil.isNotBlank(mfcCode), Code::getMfcCode, mfcCode) .like(StrUtil.isNotBlank(mfcCode), Code::getMfcCode, mfcCode)
.like(StrUtil.isNotBlank(ruleCode), Code::getRuleCode, ruleCode) .like(StrUtil.isNotBlank(ruleCode), Code::getRuleCode, ruleCode)
.like(StrUtil.isNotBlank(snCode), Code::getSnCode, snCode) .like(StrUtil.isNotBlank(snCode), Code::getSnCode, snCode)
.orderByDesc(Code::getCreatedAt) .orderByAsc(Code::getCode)
); );
return Result.data(CodeWrapper.INSTANCE.toDto(paged)); return Result.data(CodeWrapper.INSTANCE.toDto(paged));
} }

View File

@ -6,15 +6,18 @@ import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.workde.core.base.BaseService; import cn.workde.core.base.BaseService;
import cn.workde.core.data.dto.Result; import cn.workde.core.data.dto.Result;
import cn.workde.core.util.SpringUtil;
import cn.workde.module.drone.coding.dto.AttributeClassificationDto; import cn.workde.module.drone.coding.dto.AttributeClassificationDto;
import cn.workde.module.drone.coding.dto.AttributeValueDto; import cn.workde.module.drone.coding.dto.AttributeValueDto;
import cn.workde.module.drone.coding.entity.*; import cn.workde.module.drone.coding.entity.*;
import cn.workde.module.drone.coding.mapper.AttributeValueMapper;
import cn.workde.module.drone.coding.mapper.MfcMapper; import cn.workde.module.drone.coding.mapper.MfcMapper;
import cn.workde.module.drone.coding.vo.AttributeValueVo; import cn.workde.module.drone.coding.vo.AttributeValueVo;
import cn.workde.module.drone.coding.vo.AttributeValueVo2; import cn.workde.module.drone.coding.vo.AttributeValueVo2;
import cn.workde.module.drone.coding.vo.MfcVo; import cn.workde.module.drone.coding.vo.MfcVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -123,24 +126,32 @@ public class MfcService extends BaseService<MfcMapper, Mfc> {
} }
public Result<Page<Mfc>> getMfcPageList(Page page, MfcVo vo) { public Result<Page<Mfc>> getMfcPageList(Page page, MfcVo vo) {
Page paged = this.page(page, new QueryWrapper<Mfc>() Page<Mfc> paged = this.page(page, new QueryWrapper<Mfc>()
.lambda() .lambda()
.like(StrUtil.isNotBlank(vo.getMfcCode()), Mfc::getMfcCode, vo.getMfcCode()) .like(StrUtil.isNotBlank(vo.getMfcCode()), Mfc::getMfcCode, vo.getMfcCode())
.like(StrUtil.isNotBlank(vo.getMfcName()), Mfc::getMfcName, vo.getMfcName()) .like(StrUtil.isNotBlank(vo.getMfcName()), Mfc::getMfcName, vo.getMfcName())
.like(StrUtil.isNotBlank(vo.getMfcDescription()), Mfc::getMfcDescription, vo.getMfcDescription()) .like(StrUtil.isNotBlank(vo.getMfcDescription()), Mfc::getMfcDescription, vo.getMfcDescription())
.orderByAsc(Mfc::getCreatedAt)
); );
return Result.data(paged); return Result.data(paged);
} }
public Result<List<Mfc>> getMfcList() { public Result<List<Mfc>> getMfcList() {
List<Mfc> list = this.list(); List<Mfc> list = this.list(new QueryWrapper<Mfc>()
.lambda()
.orderByAsc(Mfc::getCreatedAt)
);
return Result.data(list); return Result.data(list);
} }
public Result<List<AttributeClassificationDto>> getAttributeOptions() { public Result<List<AttributeClassificationDto>> getAttributeOptions() {
//获取所有属性分类 //获取所有属性分类
List<AttributeClassification> attributeClassificationList = attributeClassificationService.list(); List<AttributeClassification> attributeClassificationList = attributeClassificationService.list(
new QueryWrapper<AttributeClassification>()
.lambda()
.orderByAsc(AttributeClassification::getSortNo)
);
if (ObjUtil.isNotNull(attributeClassificationList)) { if (ObjUtil.isNotNull(attributeClassificationList)) {
List<AttributeClassificationDto> attributeClassificationDtoList = new ArrayList<AttributeClassificationDto>(); List<AttributeClassificationDto> attributeClassificationDtoList = new ArrayList<AttributeClassificationDto>();
attributeClassificationList.forEach(attributeClassification -> { attributeClassificationList.forEach(attributeClassification -> {
@ -150,6 +161,7 @@ public class MfcService extends BaseService<MfcMapper, Mfc> {
List<Attribute> attributeList = attributeService.list(new QueryWrapper<Attribute>() List<Attribute> attributeList = attributeService.list(new QueryWrapper<Attribute>()
.lambda() .lambda()
.eq(Attribute::getAttributeClassificationId, attributeClassification.getId()) .eq(Attribute::getAttributeClassificationId, attributeClassification.getId())
.orderByAsc(Attribute::getSortNo)
); );
attributeClassificationDto.setAttributeList(attributeList); attributeClassificationDto.setAttributeList(attributeList);
attributeClassificationDtoList.add(attributeClassificationDto); attributeClassificationDtoList.add(attributeClassificationDto);
@ -245,6 +257,7 @@ public class MfcService extends BaseService<MfcMapper, Mfc> {
new QueryWrapper<AttributeClassification>() new QueryWrapper<AttributeClassification>()
.lambda() .lambda()
.inSql(AttributeClassification::getId, "select distinct attribute_classification_id from dss_drone_coding_attribute_value where mfc_id = '" + mfcId + "'") .inSql(AttributeClassification::getId, "select distinct attribute_classification_id from dss_drone_coding_attribute_value where mfc_id = '" + mfcId + "'")
.orderByAsc(AttributeClassification::getSortNo)
); );
if (CollUtil.isNotEmpty(attributeClassifications)) { if (CollUtil.isNotEmpty(attributeClassifications)) {
List<AttributeValueDto.AttributeClassificationDTO> attributeClassificationDtoList = new ArrayList<AttributeValueDto.AttributeClassificationDTO>(); List<AttributeValueDto.AttributeClassificationDTO> attributeClassificationDtoList = new ArrayList<AttributeValueDto.AttributeClassificationDTO>();
@ -253,11 +266,14 @@ public class MfcService extends BaseService<MfcMapper, Mfc> {
attributeClassificationDTO.setAttributeClassificationId(attributeClassification.getId()); attributeClassificationDTO.setAttributeClassificationId(attributeClassification.getId());
attributeClassificationDTO.setAttributeClassificationName(attributeClassification.getAttributeClassificationName()); attributeClassificationDTO.setAttributeClassificationName(attributeClassification.getAttributeClassificationName());
//获取属性值 //获取属性值
List<AttributeValue> attributeValues = attributeValueService.list( List<AttributeValue> attributeValues = SpringUtil.getBean(AttributeValueMapper.class).selectJoinList(
new QueryWrapper<AttributeValue>() AttributeValue.class,
.lambda() new MPJLambdaWrapper<AttributeValue>()
.selectAll(AttributeValue.class)
.leftJoin(Attribute.class, Attribute::getId, AttributeValue::getAttributeId)
.eq(AttributeValue::getMfcId, mfcId) .eq(AttributeValue::getMfcId, mfcId)
.eq(AttributeValue::getAttributeClassificationId, attributeClassification.getId()) .eq(AttributeValue::getAttributeClassificationId, attributeClassification.getId())
.orderByAsc(Attribute::getSortNo)
); );
if (CollUtil.isNotEmpty(attributeValues)) { if (CollUtil.isNotEmpty(attributeValues)) {
List<AttributeValueDto.AttributeDTO> attributeDtoList = new ArrayList<AttributeValueDto.AttributeDTO>(); List<AttributeValueDto.AttributeDTO> attributeDtoList = new ArrayList<AttributeValueDto.AttributeDTO>();

View File

@ -123,12 +123,15 @@ public class RuleService extends BaseService<RuleMapper, Rule> {
.like(StrUtil.isNotBlank(vo.getRuleCode()), Rule::getRuleCode, vo.getRuleCode()) .like(StrUtil.isNotBlank(vo.getRuleCode()), Rule::getRuleCode, vo.getRuleCode())
.like(StrUtil.isNotBlank(vo.getRuleName()), Rule::getRuleName, vo.getRuleName()) .like(StrUtil.isNotBlank(vo.getRuleName()), Rule::getRuleName, vo.getRuleName())
.like(StrUtil.isNotBlank(vo.getRuleDescription()), Rule::getRuleDescription, vo.getRuleDescription()) .like(StrUtil.isNotBlank(vo.getRuleDescription()), Rule::getRuleDescription, vo.getRuleDescription())
.orderByAsc(Rule::getCreatedAt)
); );
return Result.data(paged); return Result.data(paged);
} }
public Result<List<Rule>> getRuleList() { public Result<List<Rule>> getRuleList() {
List<Rule> list = this.list(new QueryWrapper<Rule>() List<Rule> list = this.list(new QueryWrapper<Rule>()
.lambda()
.orderByAsc(Rule::getCreatedAt)
); );
return Result.data(list); return Result.data(list);
} }

View File

@ -2,6 +2,7 @@ package cn.workde.module.drone.coding.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
@Data @Data
@ -10,4 +11,8 @@ public class AttributeClassificationVo {
@Schema(description = "属性分类名称") @Schema(description = "属性分类名称")
@NotBlank(message = "属性分类名称不能为空") @NotBlank(message = "属性分类名称不能为空")
private String attributeClassificationName; private String attributeClassificationName;
@Schema(description = "排序")
@NotNull(message = "排序不能为空")
private Integer sortNo;
} }

View File

@ -26,4 +26,8 @@ public class AttributeVo {
@Schema(description = "是否锁定") @Schema(description = "是否锁定")
@NotNull(message = "请选择是否锁定") @NotNull(message = "请选择是否锁定")
private Boolean locked; private Boolean locked;
@Schema(description = "排序")
@NotNull(message = "请输入排序")
private Integer sortNo;
} }