mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 12:52:07 +08:00
1、标签设计支持新增自定义类型;2、标签模板支持indict;
This commit is contained in:
+1
@@ -224,6 +224,7 @@ public class ErrorCodeConstants {
|
|||||||
public static final ErrorCode MACHINE_USE_LABEL = new ErrorCode(1_002_300_003, "machine.use.label");
|
public static final ErrorCode MACHINE_USE_LABEL = new ErrorCode(1_002_300_003, "machine.use.label");
|
||||||
public static final ErrorCode DEFAULT_NOT_DELETED = new ErrorCode(1_002_300_004, "default.not.deleted");
|
public static final ErrorCode DEFAULT_NOT_DELETED = new ErrorCode(1_002_300_004, "default.not.deleted");
|
||||||
public static final ErrorCode LABEL_IS_USE_ERROR = new ErrorCode(1_002_300_006, "label.is.use.error");
|
public static final ErrorCode LABEL_IS_USE_ERROR = new ErrorCode(1_002_300_006, "label.is.use.error");
|
||||||
|
public static final ErrorCode LABEL_SYSTEM_TYPE_NOT_OPERABLE = new ErrorCode(1_002_300_007, "label.type.not.operable");
|
||||||
|
|
||||||
|
|
||||||
// ========== 系统数据源 1_002_301_000 ==========
|
// ========== 系统数据源 1_002_301_000 ==========
|
||||||
|
|||||||
+10
-12
@@ -1,10 +1,9 @@
|
|||||||
package com.cf.imes.module.system.controller.admin.label.vo;
|
package com.cf.imes.module.system.controller.admin.label.vo;
|
||||||
|
|
||||||
import com.cf.imes.framework.dict.core.validation.InDict;
|
|
||||||
import com.cf.imes.module.system.enums.DictTypeConstants;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
@@ -16,28 +15,27 @@ public class LabelSaveReqVO {
|
|||||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "939")
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "939")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "标签类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
@Schema(description = "标签类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "materialLabel")
|
||||||
@NotNull(message = "标签类型不能为空")
|
@NotBlank(message = "label.save.type.notBlank")
|
||||||
@Size(max = 32, message = "标签类型长度不能超过32个字符")
|
@Size(max = 32, message = "label.save.type.size")
|
||||||
@InDict(DictTypeConstants.LABEL_TYPE)
|
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
@Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
@Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||||
@NotEmpty(message = "标签名称不能为空")
|
@NotEmpty(message = "label.save.name.notEmpty")
|
||||||
@Size(max = 50, message = "标签名称长度不能超过50个字符")
|
@Size(max = 50, message = "label.save.name.size")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
|
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
|
||||||
@NotEmpty(message = "备注不能为空")
|
@NotEmpty(message = "label.save.remark.notEmpty")
|
||||||
@Size(max = 255, message = "备注长度不能超过255个字符")
|
@Size(max = 255, message = "label.save.remark.size")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "宽度不能为空")
|
@NotNull(message = "label.save.width.notNull")
|
||||||
private Integer width;
|
private Integer width;
|
||||||
|
|
||||||
@Schema(description = "高度", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "高度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "高度不能为空")
|
@NotNull(message = "label.save.height.notNull")
|
||||||
private Integer height;
|
private Integer height;
|
||||||
|
|
||||||
@Schema(description = "配置")
|
@Schema(description = "配置")
|
||||||
|
|||||||
+4
-3
@@ -1,11 +1,12 @@
|
|||||||
package com.cf.imes.module.system.controller.admin.labeltemplate;
|
package com.cf.imes.module.system.controller.admin.labeltemplate;
|
||||||
|
|
||||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
|
import com.cf.imes.framework.dict.core.validation.InDict;
|
||||||
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
||||||
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.LabelTemplateRespVO;
|
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.LabelTemplateRespVO;
|
||||||
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.LabelTemplateSaveReqVO;
|
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.LabelTemplateSaveReqVO;
|
||||||
|
import com.cf.imes.module.system.enums.DictTypeConstants;
|
||||||
import com.cf.imes.module.system.service.labeltemplate.LabelTemplateService;
|
import com.cf.imes.module.system.service.labeltemplate.LabelTemplateService;
|
||||||
import com.cf.imes.module.system.validation.label.LabelTemplateTypeValid;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@@ -68,7 +69,7 @@ public class LabelTemplateController {
|
|||||||
@Parameter(name = "type", description = "标签类型", required = true, example = "1024")
|
@Parameter(name = "type", description = "标签类型", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasAnyPermissions('system:label-template:query','sysTagDesignManager:query')")
|
@PreAuthorize("@ss.hasAnyPermissions('system:label-template:query','sysTagDesignManager:query')")
|
||||||
@OperateLog(enable = false)
|
@OperateLog(enable = false)
|
||||||
public CommonResult<LabelTemplateRespVO> getDefaultLabelTemplate(@RequestParam("type") @LabelTemplateTypeValid String type) {
|
public CommonResult<LabelTemplateRespVO> getDefaultLabelTemplate(@RequestParam("type") @InDict(DictTypeConstants.LABEL_TYPE) String type) {
|
||||||
return success(labelTemplateService.getDefaultLabelTemplate(type));
|
return success(labelTemplateService.getDefaultLabelTemplate(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,4 +79,4 @@ public class LabelTemplateController {
|
|||||||
public CommonResult<Boolean> setDefaultTemplate(@RequestParam Long id) {
|
public CommonResult<Boolean> setDefaultTemplate(@RequestParam Long id) {
|
||||||
return success(labelTemplateService.setDefaultTemplate(id));
|
return success(labelTemplateService.setDefaultTemplate(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -7,6 +7,8 @@ import com.cf.imes.module.system.controller.admin.dict.vo.data.DictDataPageReqVO
|
|||||||
import com.cf.imes.module.system.dal.dataobject.dict.DictDataDO;
|
import com.cf.imes.module.system.dal.dataobject.dict.DictDataDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -46,4 +48,8 @@ public interface DictDataMapper extends BaseMapperX<DictDataDO> {
|
|||||||
.eqIfPresent(DictDataDO::getDictType, dictType));
|
.eqIfPresent(DictDataDO::getDictType, dictType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 查询字典类型的全部历史值,包含已逻辑删除的数据。 */
|
||||||
|
@Select("SELECT value FROM system_dict_data WHERE dict_type = #{dictType}")
|
||||||
|
List<String> selectAllValuesByDictType(@Param("dictType") String dictType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-2
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.service.lable;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||||
import com.cf.imes.framework.common.enums.DeletedCodeEnum;
|
import com.cf.imes.framework.common.enums.DeletedCodeEnum;
|
||||||
import com.cf.imes.framework.common.enums.UserSettingTypeEnum;
|
import com.cf.imes.framework.common.enums.UserSettingTypeEnum;
|
||||||
import com.cf.imes.framework.common.exception.ServiceException;
|
import com.cf.imes.framework.common.exception.ServiceException;
|
||||||
@@ -12,14 +13,17 @@ import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|||||||
import com.cf.imes.module.system.controller.admin.label.vo.LabelPageReqVO;
|
import com.cf.imes.module.system.controller.admin.label.vo.LabelPageReqVO;
|
||||||
import com.cf.imes.module.system.controller.admin.label.vo.LabelRespVO;
|
import com.cf.imes.module.system.controller.admin.label.vo.LabelRespVO;
|
||||||
import com.cf.imes.module.system.controller.admin.label.vo.LabelSaveReqVO;
|
import com.cf.imes.module.system.controller.admin.label.vo.LabelSaveReqVO;
|
||||||
|
import com.cf.imes.module.system.dal.dataobject.dict.DictDataDO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelTemplateDO;
|
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelTemplateDO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.lable.LabelDO;
|
import com.cf.imes.module.system.dal.dataobject.lable.LabelDO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.machine.MachineDO;
|
import com.cf.imes.module.system.dal.dataobject.machine.MachineDO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.setting.PackageConfigDO;
|
import com.cf.imes.module.system.dal.dataobject.setting.PackageConfigDO;
|
||||||
import com.cf.imes.module.system.dal.mysql.label.LabelMapper;
|
import com.cf.imes.module.system.dal.mysql.label.LabelMapper;
|
||||||
|
import com.cf.imes.module.system.dal.mysql.dict.DictDataMapper;
|
||||||
import com.cf.imes.module.system.dal.mysql.labeltemplate.LabelTemplateMapper;
|
import com.cf.imes.module.system.dal.mysql.labeltemplate.LabelTemplateMapper;
|
||||||
import com.cf.imes.module.system.dal.mysql.machine.MachineMapper;
|
import com.cf.imes.module.system.dal.mysql.machine.MachineMapper;
|
||||||
import com.cf.imes.module.system.dal.mysql.setting.PackageConfigMapper;
|
import com.cf.imes.module.system.dal.mysql.setting.PackageConfigMapper;
|
||||||
|
import com.cf.imes.module.system.enums.DictTypeConstants;
|
||||||
import com.cf.imes.module.system.enums.label.LabelTemplateType;
|
import com.cf.imes.module.system.enums.label.LabelTemplateType;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -29,8 +33,10 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.cf.imes.framework.common.util.json.JsonUtils.parseTree;
|
import static com.cf.imes.framework.common.util.json.JsonUtils.parseTree;
|
||||||
@@ -51,6 +57,9 @@ public class LabelServiceImpl implements LabelService {
|
|||||||
@Resource
|
@Resource
|
||||||
private LabelMapper labelMapper;
|
private LabelMapper labelMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DictDataMapper dictDataMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private LabelTemplateMapper labelTemplateMapper;
|
private LabelTemplateMapper labelTemplateMapper;
|
||||||
|
|
||||||
@@ -63,8 +72,12 @@ public class LabelServiceImpl implements LabelService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createLabel(LabelSaveReqVO createReqVO) {
|
public Long createLabel(LabelSaveReqVO createReqVO) {
|
||||||
|
String type = normalizeType(createReqVO.getType());
|
||||||
|
validateCustomType(type);
|
||||||
|
|
||||||
// 插入
|
// 插入
|
||||||
LabelDO label = BeanUtils.toBean(createReqVO, LabelDO.class);
|
LabelDO label = BeanUtils.toBean(createReqVO, LabelDO.class);
|
||||||
|
label.setType(type);
|
||||||
label.setTemplate(JsonUtils.zipString(label.getTemplate()));
|
label.setTemplate(JsonUtils.zipString(label.getTemplate()));
|
||||||
labelMapper.insert(label);
|
labelMapper.insert(label);
|
||||||
// 返回
|
// 返回
|
||||||
@@ -77,8 +90,14 @@ public class LabelServiceImpl implements LabelService {
|
|||||||
|
|
||||||
// 校验存在
|
// 校验存在
|
||||||
LabelDO labelDO = validateLabelExists(updateReqVO.getId());
|
LabelDO labelDO = validateLabelExists(updateReqVO.getId());
|
||||||
|
validateCustomType(labelDO.getType());
|
||||||
|
|
||||||
|
String type = normalizeType(updateReqVO.getType());
|
||||||
|
validateCustomType(type);
|
||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
LabelDO updateObj = BeanUtils.toBean(updateReqVO, LabelDO.class);
|
LabelDO updateObj = BeanUtils.toBean(updateReqVO, LabelDO.class);
|
||||||
|
updateObj.setType(type);
|
||||||
if(!updateReqVO.getTemplate().isEmpty()){
|
if(!updateReqVO.getTemplate().isEmpty()){
|
||||||
updateObj.setTemplate(JsonUtils.zipString(updateObj.getTemplate()));
|
updateObj.setTemplate(JsonUtils.zipString(updateObj.getTemplate()));
|
||||||
}
|
}
|
||||||
@@ -92,6 +111,7 @@ public class LabelServiceImpl implements LabelService {
|
|||||||
public void deleteLabel(Long id) {
|
public void deleteLabel(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
LabelDO labelDO = validateLabelExists(id);
|
LabelDO labelDO = validateLabelExists(id);
|
||||||
|
validateCustomType(labelDO.getType());
|
||||||
|
|
||||||
List<MachineDO> machineDOS = machineMapper.selectList(new LambdaQueryWrapperX<MachineDO>()
|
List<MachineDO> machineDOS = machineMapper.selectList(new LambdaQueryWrapperX<MachineDO>()
|
||||||
.select(MachineDO::getId)
|
.select(MachineDO::getId)
|
||||||
@@ -159,14 +179,32 @@ public class LabelServiceImpl implements LabelService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<LabelRespVO>> getGroupList(Long organId) {
|
public Map<String, List<LabelRespVO>> getGroupList(Long organId) {
|
||||||
|
Set<String> dictTypes = new HashSet<>(dictDataMapper.selectAllValuesByDictType(DictTypeConstants.LABEL_TYPE));
|
||||||
|
Set<String> enabledDictTypes = dictDataMapper
|
||||||
|
.selectListByStatusAndDictType(CommonStatusEnum.ENABLE.getStatus(), DictTypeConstants.LABEL_TYPE)
|
||||||
|
.stream().map(DictDataDO::getValue).collect(Collectors.toSet());
|
||||||
|
|
||||||
List<LabelDO> LabelDOS = labelMapper.selectList(new LambdaQueryWrapperX<LabelDO>()
|
List<LabelDO> LabelDOS = labelMapper.selectList(new LambdaQueryWrapperX<LabelDO>()
|
||||||
.eqIfPresent(LabelDO::getOrganId, organId)
|
.eqIfPresent(LabelDO::getOrganId, organId)
|
||||||
)
|
)
|
||||||
.stream().map(m -> m.setTemplate(unzipString(m.getTemplate()))).toList();
|
.stream()
|
||||||
|
.filter(label -> !dictTypes.contains(label.getType()) || enabledDictTypes.contains(label.getType()))
|
||||||
|
.map(m -> m.setTemplate(unzipString(m.getTemplate()))).toList();
|
||||||
List<LabelRespVO> LabelRespVOS = BeanUtils.toBean(LabelDOS, LabelRespVO.class);
|
List<LabelRespVO> LabelRespVOS = BeanUtils.toBean(LabelDOS, LabelRespVO.class);
|
||||||
return LabelRespVOS.stream().collect(Collectors.groupingBy(LabelRespVO::getType));
|
return LabelRespVOS.stream().collect(Collectors.groupingBy(LabelRespVO::getType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String normalizeType(String type) {
|
||||||
|
return type == null ? null : type.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 标签接口只能操作自定义类型,系统默认类型由字段管理维护。 */
|
||||||
|
private void validateCustomType(String type) {
|
||||||
|
if (type != null && dictDataMapper.selectByDictTypeAndValue(DictTypeConstants.LABEL_TYPE, type) != null) {
|
||||||
|
throw new ServiceException(LABEL_SYSTEM_TYPE_NOT_OPERABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LabelDO> list(String type) {
|
public List<LabelDO> list(String type) {
|
||||||
|
|
||||||
@@ -209,4 +247,4 @@ public class LabelServiceImpl implements LabelService {
|
|||||||
|
|
||||||
labelMapper.insertBatch(addList);
|
labelMapper.insertBatch(addList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
label.system.type.not.operable=系统默认标签类型只能在字段管理中操作
|
||||||
|
label.type.not.operable=当前标签类型不可操作
|
||||||
|
label.save.type.notBlank=标签类型不能为空
|
||||||
|
label.save.type.size=标签类型长度不能超过32个字符
|
||||||
|
label.save.name.notEmpty=标签名称不能为空
|
||||||
|
label.save.name.size=标签名称长度不能超过50个字符
|
||||||
|
label.save.remark.notEmpty=备注不能为空
|
||||||
|
label.save.remark.size=备注长度不能超过255个字符
|
||||||
|
label.save.width.notNull=宽度不能为空
|
||||||
|
label.save.height.notNull=高度不能为空
|
||||||
|
|||||||
+11
-1
File diff suppressed because one or more lines are too long
+11
-1
File diff suppressed because one or more lines are too long
+11
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user