标签修改
This commit is contained in:
parent
a344a3495e
commit
181f2d8a79
@ -89,4 +89,12 @@ public class LabelFieldContentController extends BaseController {
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(labelFieldContentService.deleteLabelFieldContentByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组信息
|
||||
*/
|
||||
@GetMapping("/groupingContent")
|
||||
public AjaxResult groupingContent(String taskPartitionDictName) {
|
||||
return labelFieldContentService.groupingContent(taskPartitionDictName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xinelu.manage.mapper.taskpartitiondict;
|
||||
|
||||
import com.xinelu.manage.domain.labelfieldinfo.LabelFieldInfo;
|
||||
import com.xinelu.manage.domain.taskpartitiondict.TaskPartitionDict;
|
||||
|
||||
import java.util.List;
|
||||
@ -59,4 +60,12 @@ public interface TaskPartitionDictMapper {
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteTaskPartitionDictByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 分组信息
|
||||
*
|
||||
* @param taskPartitionDictName 分组名
|
||||
* @return LabelFieldInfo
|
||||
*/
|
||||
List<LabelFieldInfo> taskPartitionDictIdList(String taskPartitionDictName);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xinelu.manage.service.labelfieldcontent;
|
||||
|
||||
import com.xinelu.common.core.domain.AjaxResult;
|
||||
import com.xinelu.manage.domain.labelfieldcontent.LabelFieldContent;
|
||||
import com.xinelu.manage.dto.labelfieldcontent.LabelFieldContentAddDTO;
|
||||
|
||||
@ -64,4 +65,12 @@ public interface ILabelFieldContentService {
|
||||
* 批量新增标签字段内容信息
|
||||
*/
|
||||
int insertLabelFieldContents(LabelFieldContentAddDTO labelFieldContentAddDTO);
|
||||
|
||||
/**
|
||||
* 分组信息
|
||||
*
|
||||
* @param taskPartitionDictName 分组名
|
||||
* @return LabelFieldInfo
|
||||
*/
|
||||
AjaxResult groupingContent(String taskPartitionDictName);
|
||||
}
|
||||
|
||||
@ -1,21 +1,25 @@
|
||||
package com.xinelu.manage.service.labelfieldcontent.impl;
|
||||
|
||||
import com.xinelu.common.constant.Constants;
|
||||
import com.xinelu.common.core.domain.AjaxResult;
|
||||
import com.xinelu.common.exception.ServiceException;
|
||||
import com.xinelu.common.utils.SecurityUtils;
|
||||
import com.xinelu.common.utils.bean.BeanUtils;
|
||||
import com.xinelu.common.utils.codes.GenerateSystemCodeUtil;
|
||||
import com.xinelu.manage.domain.labelfieldcontent.LabelFieldContent;
|
||||
import com.xinelu.manage.domain.labelfieldinfo.LabelFieldInfo;
|
||||
import com.xinelu.manage.dto.labelfieldcontent.LabelFieldContentAddDTO;
|
||||
import com.xinelu.manage.dto.labelfieldcontent.LabelFieldContentDTO;
|
||||
import com.xinelu.manage.mapper.labelfieldcontent.LabelFieldContentMapper;
|
||||
import com.xinelu.manage.mapper.taskpartitiondict.TaskPartitionDictMapper;
|
||||
import com.xinelu.manage.service.labelfieldcontent.ILabelFieldContentService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -28,9 +32,8 @@ import java.util.List;
|
||||
public class LabelFieldContentServiceImpl implements ILabelFieldContentService {
|
||||
@Resource
|
||||
private LabelFieldContentMapper labelFieldContentMapper;
|
||||
|
||||
@Resource
|
||||
private GenerateSystemCodeUtil systemCodeUtil;
|
||||
private TaskPartitionDictMapper taskPartitionDictMapper;
|
||||
|
||||
/**
|
||||
* 查询标签字段内容信息
|
||||
@ -62,6 +65,7 @@ public class LabelFieldContentServiceImpl implements ILabelFieldContentService {
|
||||
*/
|
||||
@Override
|
||||
public int insertLabelFieldContent(LabelFieldContent labelFieldContent) {
|
||||
labelFieldContent.setPortraitSn(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
|
||||
labelFieldContent.setCreateTime(LocalDateTime.now());
|
||||
return labelFieldContentMapper.insertLabelFieldContent(labelFieldContent);
|
||||
}
|
||||
@ -78,11 +82,6 @@ public class LabelFieldContentServiceImpl implements ILabelFieldContentService {
|
||||
if (ObjectUtils.isEmpty(labelFieldContentMapper.selectLabelFieldContentById(labelFieldContent.getId()))) {
|
||||
throw new ServiceException("当前字段内容不存在,无法修改,请联系管理员");
|
||||
}
|
||||
// 检查除去当前记录外有没有重复内容名称
|
||||
int existCount = labelFieldContentMapper.existCountByContentNameExcludingId(labelFieldContent.getId(), labelFieldContent.getFieldId(), null);
|
||||
if (existCount > 0) {
|
||||
throw new ServiceException("当前标签字段类型下字段内容名称已存在");
|
||||
}
|
||||
labelFieldContent.setUpdateBy(SecurityUtils.getUsername());
|
||||
labelFieldContent.setUpdateTime(LocalDateTime.now());
|
||||
return labelFieldContentMapper.updateLabelFieldContent(labelFieldContent);
|
||||
@ -140,4 +139,26 @@ public class LabelFieldContentServiceImpl implements ILabelFieldContentService {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组信息
|
||||
*
|
||||
* @param taskPartitionDictName 分组名
|
||||
* @return LabelFieldInfo
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult groupingContent(String taskPartitionDictName) {
|
||||
ArrayList<LabelFieldInfo> labelFieldInfos = new ArrayList<>();
|
||||
LabelFieldInfo labelFieldInfo = new LabelFieldInfo();
|
||||
labelFieldInfo.setTaskPartitionDictId(0L);
|
||||
labelFieldInfo.setTaskPartitionDictName("全部");
|
||||
labelFieldInfos.add(labelFieldInfo);
|
||||
List<LabelFieldInfo> labelFieldInfoList = taskPartitionDictMapper.taskPartitionDictIdList(taskPartitionDictName);
|
||||
if (CollectionUtils.isNotEmpty(labelFieldInfoList)) {
|
||||
labelFieldInfos.addAll(labelFieldInfoList);
|
||||
}
|
||||
labelFieldInfo.setTaskPartitionDictName("未分组");
|
||||
labelFieldInfos.add(labelFieldInfo);
|
||||
return AjaxResult.success(labelFieldInfos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,22 +153,6 @@ public class LabelFieldInfoServiceImpl implements ILabelFieldInfoService {
|
||||
if (CollectionUtils.isEmpty(fieldInfoList)) {
|
||||
throw new ServiceException("请填加标签字段信息");
|
||||
}
|
||||
// 如果不为空,按字段类型分组并且收集每个类型下的字段名称
|
||||
Map<String, List<String>> fieldTypeToNamesMap = fieldInfoList.stream().
|
||||
collect(Collectors.groupingBy(LabelFieldInfo::getFieldType,
|
||||
Collectors.mapping(LabelFieldInfo::getFieldName, Collectors.toList())));
|
||||
// 对于每个字段类型下字段名称进行重复性检查
|
||||
for (Map.Entry<String, List<String>> entry : fieldTypeToNamesMap.entrySet()) {
|
||||
// 获取字段类型和字段名称集合
|
||||
String fieldType = entry.getKey();
|
||||
List<String> fieldNames = entry.getValue();
|
||||
// 查询数据库中是否存在同字段类型下字段名称
|
||||
int duplicateCount = labelFieldInfoMapper.countDuplicateFieldNamesByType(fieldType, fieldNames);
|
||||
// 如果存在,提示该字段类型下已存在
|
||||
if (duplicateCount > 0) {
|
||||
throw new ServiceException("当前字段类型下字段名称已存在");
|
||||
}
|
||||
}
|
||||
// 如果不存在,执行新增操作
|
||||
for (LabelFieldInfo labelFieldInfo : fieldInfoList) {
|
||||
labelFieldInfo.setFieldCode(Constants.FIELD_ENCODING + systemCodeUtil.generateDepartCode(Constants.FIELD_ENCODING));
|
||||
|
||||
@ -206,4 +206,11 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="taskPartitionDictIdList" resultType="com.xinelu.manage.domain.labelfieldinfo.LabelFieldInfo">
|
||||
select id taskPartitionDictId,
|
||||
task_partition_name taskPartitionDictName
|
||||
from task_partition_dict
|
||||
where task_partition_name like concat('%', #{taskPartitionDictName}, '%')
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user