1.添加数据源列表接口,2.修改标签、标签模板中配置字段存储方式

This commit is contained in:
yangsb
2024-04-02 14:59:21 +08:00
parent 0d9fd5292d
commit 4b70938da8
23 changed files with 358 additions and 60 deletions
@@ -82,11 +82,12 @@ public class DataSourceController {
@GetMapping("/list") @GetMapping("/list")
@Operation(summary = "获得系统数据源列表") @Operation(summary = "获得系统数据源列表")
@Parameter(name = "type", description = "类型", required = false)
@PreAuthorize("@ss.hasPermission('system:data-source:query')") @PreAuthorize("@ss.hasPermission('system:data-source:query')")
public CommonResult<List<DataSourceRespVO>> list( @RequestParam(value = "type", required = false) Integer type) { public CommonResult<List<DataSourceRespVO>> list( ) {
List<DataSourceDO> list = dataSourceService.list(type); return success(dataSourceService.list());
return success(BeanUtils.toBean(list, DataSourceRespVO.class));
/*List<DataSourceDO> list =
return success(BeanUtils.toBean(list, DataSourceRespVO.class));*/
} }
@GetMapping("/export-excel") @GetMapping("/export-excel")
@@ -1,10 +1,17 @@
package com.cf.imes.module.system.controller.admin.label.vo; package com.cf.imes.module.system.controller.admin.label.vo;
import com.alibaba.fastjson.JSONObject;
import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO; import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
@Data @Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class LabelElementRespVO { public class LabelElementRespVO {
@Schema(description = "主键") @Schema(description = "主键")
@@ -17,6 +24,8 @@ public class LabelElementRespVO {
private String type; private String type;
@Schema(description = "数据源id") @Schema(description = "数据源id")
private Long sourceId; private Long sourceId;
/*@Schema(description = "标签元素属性")
private LabelElementPropertyDO propertyDO;*/
@Schema(description = "标签元素属性") @Schema(description = "标签元素属性")
private LabelElementPropertyDO propertyDO; private JSONObject propertyDO;
} }
@@ -1,5 +1,6 @@
package com.cf.imes.module.system.controller.admin.label.vo; package com.cf.imes.module.system.controller.admin.label.vo;
import com.alibaba.fastjson.JSONObject;
import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO; import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@@ -19,6 +20,8 @@ public class LabelElementSaveReqVO {
private String type; private String type;
@Schema(description = "数据源id") @Schema(description = "数据源id")
private Long sourceId; private Long sourceId;
/*@Schema(description = "标签元素属性")
private LabelElementPropertyDO propertyDO;*/
@Schema(description = "标签元素属性") @Schema(description = "标签元素属性")
private LabelElementPropertyDO propertyDO; private JSONObject propertyDO;
} }
@@ -1,10 +1,19 @@
package com.cf.imes.module.system.controller.admin.labeltemplate.vo; package com.cf.imes.module.system.controller.admin.labeltemplate.vo;
import com.alibaba.fastjson.JSONObject;
import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO; import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Map;
@Data @Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class LabelElementTemplateRespVO { public class LabelElementTemplateRespVO {
@Schema(description = "主键") @Schema(description = "主键")
@@ -17,6 +26,10 @@ public class LabelElementTemplateRespVO {
private String type; private String type;
@Schema(description = "数据源id") @Schema(description = "数据源id")
private Long sourceId; private Long sourceId;
/*@Schema(description = "标签元素属性")
private LabelElementPropertyDO propertyDO;*/
/*@Schema(description = "标签元素属性")
private Map<String,Object> propertyDO;*/
@Schema(description = "标签元素属性") @Schema(description = "标签元素属性")
private LabelElementPropertyDO propertyDO; private JSONObject propertyDO;
} }
@@ -1,9 +1,12 @@
package com.cf.imes.module.system.controller.admin.labeltemplate.vo; package com.cf.imes.module.system.controller.admin.labeltemplate.vo;
import com.alibaba.fastjson.JSONObject;
import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO; import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.util.Map;
/** /**
* @author there * @author there
*/ */
@@ -19,6 +22,11 @@ public class LabelElementTemplateSaveReqVO {
private String type; private String type;
@Schema(description = "数据源id") @Schema(description = "数据源id")
private Long sourceId; private Long sourceId;
/*@Schema(description = "标签元素属性")
private LabelElementPropertyDO propertyDO;*/
/*@Schema(description = "标签元素属性")
private Map<String, Object> propertyDO;*/
@Schema(description = "标签元素属性") @Schema(description = "标签元素属性")
private LabelElementPropertyDO propertyDO; private JSONObject propertyDO;
} }
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import static com.cf.imes.framework.common.pojo.CommonResult.success; import static com.cf.imes.framework.common.pojo.CommonResult.success;
@@ -55,7 +56,14 @@ public class MachineAuthController {
@PreAuthorize("@ss.hasPermission('machine-template::query')") @PreAuthorize("@ss.hasPermission('machine-template::query')")
public CommonResult<PageResult<TemplateAutoResp>> pageTemplateAuth(MachinePageReqVO pageParam) { public CommonResult<PageResult<TemplateAutoResp>> pageTemplateAuth(MachinePageReqVO pageParam) {
PageResult<MachineTemplateDO> page = machineTemplateService.page(pageParam); PageResult<MachineTemplateDO> page = machineTemplateService.page(pageParam);
List<TemplateAutoResp> list = BeanUtils.toBean(page.getList(), TemplateAutoResp.class); List<TemplateAutoResp> list = page.getList().stream().map(e->TemplateAutoResp.builder()
.id(e.getId())
.machineType(e.getMachineType())
.templateName(e.getName())
.isDefault(e.getIsDefault())
.build()
).collect(Collectors.toList());
return success(new PageResult<TemplateAutoResp>(list, page.getTotal())); return success(new PageResult<TemplateAutoResp>(list, page.getTotal()));
} }
} }
@@ -2,12 +2,18 @@ package com.cf.imes.module.system.controller.admin.machine.vo;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @author Beal * @author Beal
*/ */
@Data @Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TemplateAutoResp { public class TemplateAutoResp {
@Schema(description = "机台模板id") @Schema(description = "机台模板id")
private Long id; private Long id;
@@ -15,7 +21,7 @@ public class TemplateAutoResp {
* 名称 * 名称
*/ */
@Schema(description = "机台模板名称") @Schema(description = "机台模板名称")
private String name; private String templateName;
/** /**
* 1机台设备 2CNC设备 * 1机台设备 2CNC设备
*/ */
@@ -1,5 +1,6 @@
package com.cf.imes.module.system.controller.admin.organ; package com.cf.imes.module.system.controller.admin.organ;
import com.cf.imes.framework.common.enums.CommonStatusEnum;
import com.cf.imes.framework.common.pojo.CommonResult; import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.pojo.PageParam; import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.common.pojo.PageResult;
@@ -25,8 +26,10 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map;
import static com.cf.imes.framework.common.pojo.CommonResult.success; import static com.cf.imes.framework.common.pojo.CommonResult.success;
import static com.cf.imes.framework.common.util.collection.CollectionUtils.convertList;
import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@Tag(name = "管理后台 - 组织") @Tag(name = "管理后台 - 组织")
@@ -109,4 +112,12 @@ public class OrganController {
BeanUtils.toBean(list, OrganRespVO.class)); BeanUtils.toBean(list, OrganRespVO.class));
} }
@GetMapping({"/list-all-simple", "/simple-list"})
@Operation(summary = "获取组织精简信息列表", description = "主要用于前端的下拉选项")
@Parameter(name = "name", description = "组织名称", required = false, example = "xxx")
public CommonResult<List<OrganSimpleRespVO>> getSimpleOrganList(@RequestParam(required = false, value = "name") String name) {
return success(organService.getSimpleOrganList(name));
}
} }
@@ -0,0 +1,16 @@
package com.cf.imes.module.system.convert.label;
import com.cf.imes.module.system.controller.admin.label.vo.LabelElementRespVO;
import com.cf.imes.module.system.controller.admin.label.vo.LabelElementSaveReqVO;
import com.cf.imes.module.system.dal.dataobject.lable.LabelElementDO;
import java.util.List;
public interface LabelConvert {
List<LabelElementRespVO> convert1 (List<LabelElementDO> labelElementDOS);
List<LabelElementDO> convert2 (List<LabelElementRespVO> labelElementRespVOS);
LabelElementDO convert(LabelElementSaveReqVO vo);
}
@@ -0,0 +1,52 @@
package com.cf.imes.module.system.convert.label;
import com.alibaba.fastjson.JSON;
import com.cf.imes.module.system.controller.admin.label.vo.LabelElementRespVO;
import com.cf.imes.module.system.controller.admin.label.vo.LabelElementSaveReqVO;
import com.cf.imes.module.system.dal.dataobject.lable.LabelElementDO;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class LabelConvertImpl implements LabelConvert{
@Override
public List<LabelElementRespVO> convert1(List<LabelElementDO> labelElementDOS) {
return labelElementDOS.stream().map(
e-> LabelElementRespVO.builder()
.labelId(e.getLabelId())
.name(e.getName())
.id(e.getId())
.type(e.getType())
.sourceId(e.getSourceId())
.propertyDO(JSON.parseObject(e.getConfig()))
.build()
).collect(Collectors.toList());
}
@Override
public List<LabelElementDO> convert2(List<LabelElementRespVO> labelElementRespVOS) {
return labelElementRespVOS.stream().map(e-> LabelElementDO.builder()
.labelId(e.getLabelId())
.type(e.getType())
.name(e.getName())
.sourceId(e.getSourceId())
.id(e.getId())
.config(e.getPropertyDO().toJSONString())
.build()
).collect(Collectors.toList());
}
@Override
public LabelElementDO convert(LabelElementSaveReqVO vo) {
return LabelElementDO.builder()
.config(vo.getPropertyDO().toJSONString())
.labelId(vo.getLabelId())
.type(vo.getType())
.sourceId(vo.getSourceId())
.id(vo.getId())
.name(vo.getName())
.build();
}
}
@@ -0,0 +1,16 @@
package com.cf.imes.module.system.convert.labletemplate;
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.LabelElementTemplateRespVO;
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.LabelElementTemplateSaveReqVO;
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelElementTemplateDO;
import java.util.List;
public interface LabelTemplateConvert {
List<LabelElementTemplateRespVO> convert1 (List<LabelElementTemplateDO> labelElementTemplateDOS);
List<LabelElementTemplateDO> convert2 (List<LabelElementTemplateRespVO> labelElementTemplateRespVOS);
LabelElementTemplateDO convert(LabelElementTemplateSaveReqVO vo);
}
@@ -0,0 +1,77 @@
package com.cf.imes.module.system.convert.labletemplate;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.alibaba.fastjson.JSON;
import com.cf.imes.framework.common.util.collection.MapUtils;
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.LabelElementTemplateRespVO;
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.LabelElementTemplateSaveReqVO;
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelElementTemplateDO;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import org.springframework.stereotype.Service;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author Beal
*/
@Service
public class LabelTemplateConvertImpl implements LabelTemplateConvert {
@Override
public List<LabelElementTemplateRespVO> convert1 (List<LabelElementTemplateDO> labelElementTemplateDOS) {
return labelElementTemplateDOS.stream().map(e -> {
Gson gson = new Gson();
Type type = new TypeToken<Map<String, Object>>() {
}.getType();
return LabelElementTemplateRespVO.builder()
.labelTemplateId(e.getLabelTemplateId())
.id(e.getId())
.type(e.getType())
.name(e.getName())
.propertyDO(JSON.parseObject(e.getConfig()))
// .propertyDO(StrUtil.isBlank(e.getPropertyDO()) ? new HashMap<String, Object>(): gson.fromJson(e.getPropertyDO(), type))
//{extra=, x=100, y=100, width=100, height=100, value=, html=, isRepeat=false, borderWidth=1, fontSize=1, divHeight=1, colNum=1, enableSourceExpress=false, sourceExpress=, visible=true, isScrapBlock=false, visibleExpression=, isVertical=false, dataText=, dataExpression=, displayType=1, barcodeType=, fontWeight=1, fontFamily=, textAlign=, textBaseline=, qrcodeErrorRate=, showSideHole=false}
.sourceId(e.getSourceId())
.build();
}
).collect(Collectors.toList());
}
@Override
public List<LabelElementTemplateDO> convert2(List<LabelElementTemplateRespVO> labelElementTemplateRespVOS) {
return labelElementTemplateRespVOS.stream().map(e->
LabelElementTemplateDO.builder()
.config(e.getPropertyDO().toJSONString())
.labelTemplateId(e.getLabelTemplateId())
.type(e.getType())
.id(e.getId())
.name(e.getName())
.sourceId(e.getSourceId())
.build()
).collect(Collectors.toList());
}
@Override
public LabelElementTemplateDO convert(LabelElementTemplateSaveReqVO vo) {
return LabelElementTemplateDO.builder()
.name(vo.getName())
.config(vo.getPropertyDO().toJSONString())
.labelTemplateId(vo.getLabelTemplateId())
.sourceId(vo.getSourceId())
.id(vo.getId())
.type(vo.getType())
.build()
;
}
}
@@ -1,11 +1,13 @@
package com.cf.imes.module.system.dal.dataobject.labeltemplate; package com.cf.imes.module.system.dal.dataobject.labeltemplate;
import com.alibaba.fastjson.JSONObject;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO; import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
import org.apache.ibatis.type.JdbcType;
/** /**
* 标签元素模板 DO * 标签元素模板 DO
@@ -43,5 +45,9 @@ public class LabelElementTemplateDO extends BaseDO {
* 数据源id * 数据源id
*/ */
private Long sourceId; private Long sourceId;
/**
* 元素配置
*/
private String config;
} }
@@ -43,5 +43,9 @@ public class LabelElementDO extends OrganBaseDO {
* 数据源id * 数据源id
*/ */
private Long sourceId; private Long sourceId;
/**
* 元素配置
*/
private String config;
} }
@@ -26,4 +26,5 @@ public interface DataSourceMapper extends BaseMapperX<DataSourceDO> {
.orderByDesc(DataSourceDO::getId)); .orderByDesc(DataSourceDO::getId));
} }
List<DataSourceRespVO> selectListVO();
} }
@@ -54,4 +54,6 @@ public interface DataSourceService {
PageResult<DataSourceDO> getDataSourcePage(DataSourcePageReqVO pageReqVO); PageResult<DataSourceDO> getDataSourcePage(DataSourcePageReqVO pageReqVO);
List<DataSourceDO> list(Integer type); List<DataSourceDO> list(Integer type);
List<DataSourceRespVO> list();
} }
@@ -75,4 +75,9 @@ public class DataSourceServiceImpl implements DataSourceService {
return dataSourceMapper.selectList(new LambdaQueryWrapperX<DataSourceDO>().eqIfPresent(DataSourceDO::getType, type)); return dataSourceMapper.selectList(new LambdaQueryWrapperX<DataSourceDO>().eqIfPresent(DataSourceDO::getType, type));
} }
@Override
public List<DataSourceRespVO> list() {
return dataSourceMapper.selectListVO();
}
} }
@@ -3,15 +3,19 @@ package com.cf.imes.module.system.service.labeltemplate;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference; import cn.hutool.core.lang.TypeReference;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.FieldValue; import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch._types.query_dsl.TermsQuery; import co.elastic.clients.elasticsearch._types.query_dsl.TermsQuery;
import co.elastic.clients.elasticsearch.core.DeleteByQueryRequest; import co.elastic.clients.elasticsearch.core.DeleteByQueryRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse; import co.elastic.clients.elasticsearch.core.SearchResponse;
import co.elastic.clients.elasticsearch.core.search.Hit; import co.elastic.clients.elasticsearch.core.search.Hit;
import com.alibaba.fastjson.JSON;
import com.cf.imes.framework.common.exception.ServiceException; import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.es.core.service.ESDocumentService; import com.cf.imes.framework.es.core.service.ESDocumentService;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.module.system.convert.labletemplate.LabelTemplateConvert;
import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO; import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO;
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelElementTemplateDO; import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelElementTemplateDO;
import com.cf.imes.module.system.dal.dataobject.machine.CuttingSettingDO; import com.cf.imes.module.system.dal.dataobject.machine.CuttingSettingDO;
@@ -55,6 +59,8 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
private ESDocumentService esDocumentService; private ESDocumentService esDocumentService;
@Resource @Resource
private ElasticsearchClient elasticsearchClient; private ElasticsearchClient elasticsearchClient;
@Resource
private LabelTemplateConvert labelTemplateConvert;
private static final String LABEL_TEMPLATE_ELEMENT_PROPERTY_INX = "label_template_element_property"; private static final String LABEL_TEMPLATE_ELEMENT_PROPERTY_INX = "label_template_element_property";
@@ -71,19 +77,19 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>(); List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>();
createReqVOElements.forEach(e -> { createReqVOElements.forEach(e -> {
e.setLabelTemplateId(labelTemplate.getId()); e.setLabelTemplateId(labelTemplate.getId());
LabelElementTemplateDO elementTemplateDO = Convert.convert(LabelElementTemplateDO.class, e); LabelElementTemplateDO elementTemplateDO = labelTemplateConvert.convert(e);
labelElementTemplateMapper.insert(elementTemplateDO); labelElementTemplateMapper.insert(elementTemplateDO);
LabelElementPropertyDO propertyDO = e.getPropertyDO(); /*LabelElementPropertyDO propertyDO = e.getPropertyDO();
propertyDO.setElementId(elementTemplateDO.getId()); propertyDO.setElementId(elementTemplateDO.getId());
labelElementPropertyDOS.add(propertyDO); labelElementPropertyDOS.add(propertyDO);*/
}); });
//插入索引 //插入索引
try { /* try {
esDocumentService.bulkCreate(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX, labelElementPropertyDOS); esDocumentService.bulkCreate(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX, labelElementPropertyDOS);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw exception(INTERNAL_SERVER_ERROR); throw exception(INTERNAL_SERVER_ERROR);
} }*/
} }
// 返回 // 返回
return labelTemplate.getId(); return labelTemplate.getId();
@@ -97,12 +103,13 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
// 更新 // 更新
LabelTemplateDO updateObj = BeanUtils.toBean(updateReqVO, LabelTemplateDO.class); LabelTemplateDO updateObj = BeanUtils.toBean(updateReqVO, LabelTemplateDO.class);
labelTemplateMapper.updateById(updateObj); labelTemplateMapper.updateById(updateObj);
labelElementTemplateMapper.delete(new LambdaQueryWrapperX<LabelElementTemplateDO>().eq(LabelElementTemplateDO::getLabelTemplateId, updateReqVO.getId()));
List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectList(new LambdaQueryWrapperX<LabelElementTemplateDO>() /* List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectList(new LambdaQueryWrapperX<LabelElementTemplateDO>()
.select(LabelElementTemplateDO::getId) .select(LabelElementTemplateDO::getId)
.eq(LabelElementTemplateDO::getLabelTemplateId, updateReqVO.getId())); .eq(LabelElementTemplateDO::getLabelTemplateId, updateReqVO.getId()));*/
//删除旧的元素 //删除旧的元素
DeleteByQueryRequest.Builder builder = null; /*DeleteByQueryRequest.Builder builder = null;
if(CollectionUtil.isNotEmpty(labelElementTemplateDOS)) { if(CollectionUtil.isNotEmpty(labelElementTemplateDOS)) {
List<Long> templateIds = labelElementTemplateDOS.stream() List<Long> templateIds = labelElementTemplateDOS.stream()
.map(LabelElementTemplateDO::getId) .map(LabelElementTemplateDO::getId)
@@ -112,7 +119,7 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
builder = new DeleteByQueryRequest.Builder() builder = new DeleteByQueryRequest.Builder()
.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX) .index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX)
.query(TermsQuery.of(e -> e.field("elementId").terms(b -> b.value(fieldValues)))._toQuery()); .query(TermsQuery.of(e -> e.field("elementId").terms(b -> b.value(fieldValues)))._toQuery());
} }*/
//新增新的元素 //新增新的元素
@@ -120,14 +127,15 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>(); List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>();
createReqVOElements.forEach(e -> { createReqVOElements.forEach(e -> {
e.setLabelTemplateId(updateObj.getId()); e.setLabelTemplateId(updateObj.getId());
LabelElementTemplateDO elementTemplateDO = Convert.convert(LabelElementTemplateDO.class, e); LabelElementTemplateDO elementTemplateDO = labelTemplateConvert.convert(e);
//LabelElementTemplateDO elementTemplateDO = Convert.convert(LabelElementTemplateDO.class, e);
labelElementTemplateMapper.insert(elementTemplateDO); labelElementTemplateMapper.insert(elementTemplateDO);
LabelElementPropertyDO propertyDO = e.getPropertyDO(); /*LabelElementPropertyDO propertyDO = e.getPropertyDO();
propertyDO.setElementId(elementTemplateDO.getId()); propertyDO.setElementId(elementTemplateDO.getId());
labelElementPropertyDOS.add(propertyDO); labelElementPropertyDOS.add(propertyDO);*/
}); });
//插入索引 //插入索引
try { /*try {
if(CollectionUtil.isNotEmpty(labelElementPropertyDOS)) { if(CollectionUtil.isNotEmpty(labelElementPropertyDOS)) {
esDocumentService.bulkCreate(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX, labelElementPropertyDOS); esDocumentService.bulkCreate(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX, labelElementPropertyDOS);
} }
@@ -137,7 +145,7 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw exception(INTERNAL_SERVER_ERROR); throw exception(INTERNAL_SERVER_ERROR);
} }*/
/*updateLabelElementTemplateList(updateReqVO.getId(), Convert.convert(new TypeReference<List<LabelElementTemplateDO>>() { /*updateLabelElementTemplateList(updateReqVO.getId(), Convert.convert(new TypeReference<List<LabelElementTemplateDO>>() {
@@ -163,7 +171,7 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
throw exception(LABEL_TEMPLATE_NOT_EXISTS); throw exception(LABEL_TEMPLATE_NOT_EXISTS);
} }
List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectListByLabelTemplateId(id); List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectListByLabelTemplateId(id);
List<FieldValue> fieldValues = labelElementTemplateDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList()); /*List<FieldValue> fieldValues = labelElementTemplateDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
// 删除索引 // 删除索引
DeleteByQueryRequest.Builder builder = new DeleteByQueryRequest.Builder() DeleteByQueryRequest.Builder builder = new DeleteByQueryRequest.Builder()
.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX) .index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX)
@@ -173,7 +181,7 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
} catch (IOException e) { } catch (IOException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw exception(INTERNAL_SERVER_ERROR); throw exception(INTERNAL_SERVER_ERROR);
} }*/
// 删除标签模板表 // 删除标签模板表
labelTemplateMapper.deleteById(id); labelTemplateMapper.deleteById(id);
// 删除标签元素模板表 // 删除标签元素模板表
@@ -192,8 +200,10 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
LabelTemplateDO labelTemplateDO = labelTemplateMapper.selectById(id); LabelTemplateDO labelTemplateDO = labelTemplateMapper.selectById(id);
List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectListByLabelTemplateId(labelTemplateDO.getId()); List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectListByLabelTemplateId(labelTemplateDO.getId());
LabelTemplateRespVO labelTemplateRespVO = BeanUtils.toBean(labelTemplateDO, LabelTemplateRespVO.class); LabelTemplateRespVO labelTemplateRespVO = BeanUtils.toBean(labelTemplateDO, LabelTemplateRespVO.class);
List<LabelElementTemplateRespVO> labelElementTemplateRespVOS = BeanUtils.toBean(labelElementTemplateDOS, LabelElementTemplateRespVO.class); List<LabelElementTemplateRespVO> labelElementTemplateRespVOS = labelTemplateConvert.convert1(labelElementTemplateDOS);
List<FieldValue> fieldValues = labelElementTemplateDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList()); //List<LabelElementTemplateRespVO> labelElementTemplateRespVOS = Convert.convert(new TypeReference<List<LabelElementTemplateRespVO>>() {}, labelElementTemplateDOS);
//List<LabelElementTemplateRespVO> labelElementTemplateRespVOS = BeanUtils.toBean(labelElementTemplateDOS, LabelElementTemplateRespVO.class);
/*List<FieldValue> fieldValues = labelElementTemplateDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
SearchResponse<CuttingSettingDO> searchSetting = null; SearchResponse<CuttingSettingDO> searchSetting = null;
try { try {
SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX) SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX)
@@ -212,7 +222,7 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
} catch (IOException e) { } catch (IOException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw new ServiceException(INTERNAL_SERVER_ERROR); throw new ServiceException(INTERNAL_SERVER_ERROR);
} }*/
labelTemplateRespVO.setLabelElementTemplates(labelElementTemplateRespVOS); labelTemplateRespVO.setLabelElementTemplates(labelElementTemplateRespVOS);
return labelTemplateRespVO; return labelTemplateRespVO;
@@ -229,7 +239,7 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
public List<LabelElementTemplateRespVO> getLabelElementTemplateListByLabelTemplateId(Long labelTemplateId) { public List<LabelElementTemplateRespVO> getLabelElementTemplateListByLabelTemplateId(Long labelTemplateId) {
List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectListByLabelTemplateId(labelTemplateId); List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectListByLabelTemplateId(labelTemplateId);
List<LabelElementTemplateRespVO> respVOS = BeanUtils.toBean(labelElementTemplateDOS, LabelElementTemplateRespVO.class); List<LabelElementTemplateRespVO> respVOS = BeanUtils.toBean(labelElementTemplateDOS, LabelElementTemplateRespVO.class);
List<FieldValue> fieldValues = labelElementTemplateDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList()); /* List<FieldValue> fieldValues = labelElementTemplateDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
try { try {
SearchResponse<LabelElementPropertyDO> response = elasticsearchClient.search(b -> b.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX) SearchResponse<LabelElementPropertyDO> response = elasticsearchClient.search(b -> b.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX)
.from(0) .from(0)
@@ -246,7 +256,7 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
} catch (IOException e) { } catch (IOException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw exception(INTERNAL_SERVER_ERROR); throw exception(INTERNAL_SERVER_ERROR);
} }*/
return respVOS; return respVOS;
} }
@@ -256,8 +266,10 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
List<LabelTemplateRespVO> labelTemplateRespVOS = BeanUtils.toBean(labelTemplateDOS, LabelTemplateRespVO.class); List<LabelTemplateRespVO> labelTemplateRespVOS = BeanUtils.toBean(labelTemplateDOS, LabelTemplateRespVO.class);
Set<Long> ids = labelTemplateRespVOS.stream().map(e -> e.getId()).collect(Collectors.toSet()); Set<Long> ids = labelTemplateRespVOS.stream().map(e -> e.getId()).collect(Collectors.toSet());
List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectList(new LambdaQueryWrapperX<LabelElementTemplateDO>().in(LabelElementTemplateDO::getLabelTemplateId, ids)); List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectList(new LambdaQueryWrapperX<LabelElementTemplateDO>().in(LabelElementTemplateDO::getLabelTemplateId, ids));
List<LabelElementTemplateRespVO> labelElementTemplateRespVOS = BeanUtils.toBean(labelElementTemplateDOS, LabelElementTemplateRespVO.class); List<LabelElementTemplateRespVO> labelElementTemplateRespVOS = labelTemplateConvert.convert1(labelElementTemplateDOS);
List<FieldValue> fieldValues = labelElementTemplateRespVOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList()); //List<LabelElementTemplateRespVO> labelElementTemplateRespVOS = Convert.convert(new TypeReference<List<LabelElementTemplateRespVO>>() {}, labelTemplateDOS);
//List<LabelElementTemplateRespVO> labelElementTemplateRespVOS = BeanUtils.toBean(labelElementTemplateDOS, LabelElementTemplateRespVO.class);
/*List<FieldValue> fieldValues = labelElementTemplateRespVOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
try { try {
SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX) SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX)
.query(TermsQuery.of(e -> e.field("elementId") .query(TermsQuery.of(e -> e.field("elementId")
@@ -276,7 +288,7 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
} catch (IOException e) { } catch (IOException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw new ServiceException(INTERNAL_SERVER_ERROR); throw new ServiceException(INTERNAL_SERVER_ERROR);
} }*/
for (LabelTemplateRespVO labelTemplateRespVO : labelTemplateRespVOS) { for (LabelTemplateRespVO labelTemplateRespVO : labelTemplateRespVOS) {
labelTemplateRespVO.setLabelElementTemplates(labelElementTemplateRespVOS.stream().filter(e -> Objects.equals(e.getLabelTemplateId(), labelTemplateRespVO.getId())).toList()); labelTemplateRespVO.setLabelElementTemplates(labelElementTemplateRespVOS.stream().filter(e -> Objects.equals(e.getLabelTemplateId(), labelTemplateRespVO.getId())).toList());
} }
@@ -298,4 +310,5 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
labelElementTemplateMapper.deleteByLabelTemplateId(labelTemplateId); labelElementTemplateMapper.deleteByLabelTemplateId(labelTemplateId);
} }
} }
@@ -16,6 +16,7 @@ import com.cf.imes.framework.es.core.service.ESDocumentService;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.module.system.controller.admin.label.vo.*; import com.cf.imes.module.system.controller.admin.label.vo.*;
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.LabelElementTemplateSaveReqVO; import com.cf.imes.module.system.controller.admin.labeltemplate.vo.LabelElementTemplateSaveReqVO;
import com.cf.imes.module.system.convert.label.LabelConvert;
import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO; import com.cf.imes.module.system.dal.dataobject.labelelementproperty.LabelElementPropertyDO;
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelElementTemplateDO; import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelElementTemplateDO;
import com.cf.imes.module.system.dal.dataobject.lable.LabelDO; import com.cf.imes.module.system.dal.dataobject.lable.LabelDO;
@@ -55,6 +56,8 @@ public class LabelServiceImpl implements LabelService {
private ESDocumentService esDocumentService; private ESDocumentService esDocumentService;
@Resource @Resource
private ElasticsearchClient elasticsearchClient; private ElasticsearchClient elasticsearchClient;
@Resource
private LabelConvert labelConvert;
private static final String LABEL_ELEMENT_PROPERTY_INX = "label_element_property"; private static final String LABEL_ELEMENT_PROPERTY_INX = "label_element_property";
@@ -71,19 +74,20 @@ public class LabelServiceImpl implements LabelService {
List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>(); List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>();
createReqVOElements.forEach(e -> { createReqVOElements.forEach(e -> {
e.setLabelId(Label.getId()); e.setLabelId(Label.getId());
LabelElementDO elementDO = Convert.convert(LabelElementDO.class, e); //LabelElementDO elementDO = Convert.convert(LabelElementDO.class, e);
LabelElementDO elementDO = labelConvert.convert(e);
labelElementMapper.insert(elementDO); labelElementMapper.insert(elementDO);
LabelElementPropertyDO propertyDO = e.getPropertyDO(); /* LabelElementPropertyDO propertyDO = e.getPropertyDO();
propertyDO.setElementId(elementDO.getId()); propertyDO.setElementId(elementDO.getId());
labelElementPropertyDOS.add(propertyDO); labelElementPropertyDOS.add(propertyDO);*/
}); });
//插入索引 //插入索引
try { /* try {
esDocumentService.bulkCreate(LABEL_ELEMENT_PROPERTY_INX, labelElementPropertyDOS); esDocumentService.bulkCreate(LABEL_ELEMENT_PROPERTY_INX, labelElementPropertyDOS);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw exception(INTERNAL_SERVER_ERROR); throw exception(INTERNAL_SERVER_ERROR);
} }*/
} }
// 返回 // 返回
return Label.getId(); return Label.getId();
@@ -98,21 +102,23 @@ public class LabelServiceImpl implements LabelService {
LabelDO updateObj = BeanUtils.toBean(updateReqVO, LabelDO.class); LabelDO updateObj = BeanUtils.toBean(updateReqVO, LabelDO.class);
LabelMapper.updateById(updateObj); LabelMapper.updateById(updateObj);
List<LabelElementDO> labelElementDOS = labelElementMapper.selectList(new LambdaQueryWrapperX<LabelElementDO>() labelElementMapper.delete(new LambdaQueryWrapperX<LabelElementDO>().eq(LabelElementDO::getLabelId, updateReqVO.getId()));
/*List<LabelElementDO> labelElementDOS = labelElementMapper.selectList(new LambdaQueryWrapperX<LabelElementDO>()
.select(LabelElementDO::getId) .select(LabelElementDO::getId)
.eq(LabelElementDO::getLabelId, updateReqVO.getId())); .eq(LabelElementDO::getLabelId, updateReqVO.getId()));*/
//删除旧的元素 //删除旧的元素
DeleteByQueryRequest.Builder builder = null; /*DeleteByQueryRequest.Builder builder = null;
if(CollectionUtil.isNotEmpty(labelElementDOS)) { if(CollectionUtil.isNotEmpty(labelElementDOS)) {
List<Long> templateIds = labelElementDOS.stream() List<Long> templateIds = labelElementDOS.stream()
.map(LabelElementDO::getId) .map(LabelElementDO::getId)
.toList(); .toList();
labelElementMapper.deleteBatchIds(templateIds); labelElementMapper.deleteBatchIds(templateIds);
List<FieldValue> fieldValues = templateIds.stream().map(FieldValue::of).collect(Collectors.toList()); *//*List<FieldValue> fieldValues = templateIds.stream().map(FieldValue::of).collect(Collectors.toList());
builder = new DeleteByQueryRequest.Builder() builder = new DeleteByQueryRequest.Builder()
.index(LABEL_ELEMENT_PROPERTY_INX) .index(LABEL_ELEMENT_PROPERTY_INX)
.query(TermsQuery.of(e -> e.field("elementId").terms(b -> b.value(fieldValues)))._toQuery()); .query(TermsQuery.of(e -> e.field("elementId").terms(b -> b.value(fieldValues)))._toQuery());*//*
} }*/
//新增新的元素 //新增新的元素
@@ -120,14 +126,15 @@ public class LabelServiceImpl implements LabelService {
List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>(); List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>();
createReqVOElements.forEach(e -> { createReqVOElements.forEach(e -> {
e.setLabelId(updateObj.getId()); e.setLabelId(updateObj.getId());
LabelElementDO labelElementDO = Convert.convert(LabelElementDO.class, e); LabelElementDO labelElementDO = labelConvert.convert(e);
//LabelElementDO labelElementDO = Convert.convert(LabelElementDO.class, e);
labelElementMapper.insert(labelElementDO); labelElementMapper.insert(labelElementDO);
LabelElementPropertyDO propertyDO = e.getPropertyDO(); /* LabelElementPropertyDO propertyDO = e.getPropertyDO();
propertyDO.setElementId(labelElementDO.getId()); propertyDO.setElementId(labelElementDO.getId());
labelElementPropertyDOS.add(propertyDO); labelElementPropertyDOS.add(propertyDO);*/
}); });
//插入索引 //插入索引
try { /* try {
if(CollectionUtil.isNotEmpty(labelElementPropertyDOS)) { if(CollectionUtil.isNotEmpty(labelElementPropertyDOS)) {
esDocumentService.bulkCreate(LABEL_ELEMENT_PROPERTY_INX, labelElementPropertyDOS); esDocumentService.bulkCreate(LABEL_ELEMENT_PROPERTY_INX, labelElementPropertyDOS);
} }
@@ -137,7 +144,7 @@ public class LabelServiceImpl implements LabelService {
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw exception(INTERNAL_SERVER_ERROR); throw exception(INTERNAL_SERVER_ERROR);
} }*/
/* List<LabelElementSaveReqVO> elements = updateReqVO.getElements(); /* List<LabelElementSaveReqVO> elements = updateReqVO.getElements();
*//*updateLabelElementList(updateReqVO.getId(), Convert.convert(new TypeReference<List<LabelElementDO>>() { *//*updateLabelElementList(updateReqVO.getId(), Convert.convert(new TypeReference<List<LabelElementDO>>() {
@@ -192,8 +199,9 @@ public class LabelServiceImpl implements LabelService {
LabelDO LabelDO = LabelMapper.selectById(id); LabelDO LabelDO = LabelMapper.selectById(id);
List<LabelElementDO> labelElementDOS = labelElementMapper.selectListByLabelId(LabelDO.getId()); List<LabelElementDO> labelElementDOS = labelElementMapper.selectListByLabelId(LabelDO.getId());
LabelRespVO LabelRespVO = BeanUtils.toBean(LabelDO, LabelRespVO.class); LabelRespVO LabelRespVO = BeanUtils.toBean(LabelDO, LabelRespVO.class);
List<LabelElementRespVO> labelElementRespVOS = BeanUtils.toBean(labelElementDOS, LabelElementRespVO.class); List<LabelElementRespVO> labelElementRespVOS = labelConvert.convert1(labelElementDOS);
List<FieldValue> fieldValues = labelElementDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList()); //List<LabelElementRespVO> labelElementRespVOS = BeanUtils.toBean(labelElementDOS, LabelElementRespVO.class);
/* List<FieldValue> fieldValues = labelElementDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
SearchResponse<CuttingSettingDO> searchSetting = null; SearchResponse<CuttingSettingDO> searchSetting = null;
try { try {
SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_ELEMENT_PROPERTY_INX) SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_ELEMENT_PROPERTY_INX)
@@ -212,7 +220,7 @@ public class LabelServiceImpl implements LabelService {
} catch (IOException e) { } catch (IOException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw new ServiceException(INTERNAL_SERVER_ERROR); throw new ServiceException(INTERNAL_SERVER_ERROR);
} }*/
LabelRespVO.setLabelElements(labelElementRespVOS); LabelRespVO.setLabelElements(labelElementRespVOS);
return LabelRespVO; return LabelRespVO;
@@ -228,8 +236,9 @@ public class LabelServiceImpl implements LabelService {
@Override @Override
public List<LabelElementRespVO> getLabelElementListByLabelId(Long LabelId) { public List<LabelElementRespVO> getLabelElementListByLabelId(Long LabelId) {
List<LabelElementDO> labelElementDOS = labelElementMapper.selectListByLabelId(LabelId); List<LabelElementDO> labelElementDOS = labelElementMapper.selectListByLabelId(LabelId);
List<LabelElementRespVO> respVOS = BeanUtils.toBean(labelElementDOS, LabelElementRespVO.class); List<LabelElementRespVO> respVOS = labelConvert.convert1(labelElementDOS);
List<FieldValue> fieldValues = labelElementDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList()); //List<LabelElementRespVO> respVOS = BeanUtils.toBean(labelElementDOS, LabelElementRespVO.class);
/* List<FieldValue> fieldValues = labelElementDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
try { try {
SearchResponse<LabelElementPropertyDO> response = elasticsearchClient.search(b -> b.index(LABEL_ELEMENT_PROPERTY_INX) SearchResponse<LabelElementPropertyDO> response = elasticsearchClient.search(b -> b.index(LABEL_ELEMENT_PROPERTY_INX)
.from(0) .from(0)
@@ -246,7 +255,7 @@ public class LabelServiceImpl implements LabelService {
} catch (IOException e) { } catch (IOException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw exception(INTERNAL_SERVER_ERROR); throw exception(INTERNAL_SERVER_ERROR);
} }*/
return respVOS; return respVOS;
} }
@@ -256,8 +265,9 @@ public class LabelServiceImpl implements LabelService {
List<LabelRespVO> LabelRespVOS = BeanUtils.toBean(LabelDOS, LabelRespVO.class); List<LabelRespVO> LabelRespVOS = BeanUtils.toBean(LabelDOS, LabelRespVO.class);
Set<Long> ids = LabelRespVOS.stream().map(e -> e.getId()).collect(Collectors.toSet()); Set<Long> ids = LabelRespVOS.stream().map(e -> e.getId()).collect(Collectors.toSet());
List<LabelElementDO> labelElementDOS = labelElementMapper.selectList(new LambdaQueryWrapperX<LabelElementDO>().in(LabelElementDO::getLabelId, ids)); List<LabelElementDO> labelElementDOS = labelElementMapper.selectList(new LambdaQueryWrapperX<LabelElementDO>().in(LabelElementDO::getLabelId, ids));
List<LabelElementRespVO> labelElementRespVOS = BeanUtils.toBean(labelElementDOS, LabelElementRespVO.class); List<LabelElementRespVO> labelElementRespVOS = labelConvert.convert1(labelElementDOS);
List<FieldValue> fieldValues = labelElementRespVOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList()); //List<LabelElementRespVO> labelElementRespVOS = BeanUtils.toBean(labelElementDOS, LabelElementRespVO.class);
/*List<FieldValue> fieldValues = labelElementRespVOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
try { try {
SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_ELEMENT_PROPERTY_INX) SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_ELEMENT_PROPERTY_INX)
.query(TermsQuery.of(e -> e.field("elementId") .query(TermsQuery.of(e -> e.field("elementId")
@@ -276,7 +286,7 @@ public class LabelServiceImpl implements LabelService {
} catch (IOException e) { } catch (IOException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw new ServiceException(INTERNAL_SERVER_ERROR); throw new ServiceException(INTERNAL_SERVER_ERROR);
} }*/
for (LabelRespVO LabelRespVO : LabelRespVOS) { for (LabelRespVO LabelRespVO : LabelRespVOS) {
LabelRespVO.setLabelElements(labelElementRespVOS.stream().filter(e -> Objects.equals(e.getLabelId(), LabelRespVO.getId())).toList()); LabelRespVO.setLabelElements(labelElementRespVOS.stream().filter(e -> Objects.equals(e.getLabelId(), LabelRespVO.getId())).toList());
} }
@@ -4,6 +4,8 @@ import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.organ.core.context.OrganContextHolder; import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO; import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSaveReqVO; import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSaveReqVO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSimpleRespVO;
import com.cf.imes.module.system.controller.admin.user.vo.user.UserSimpleRespVO;
import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO; import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO;
import com.cf.imes.module.system.service.organ.handler.OrganInfoHandler; import com.cf.imes.module.system.service.organ.handler.OrganInfoHandler;
import com.cf.imes.module.system.service.organ.handler.OrganMenuHandler; import com.cf.imes.module.system.service.organ.handler.OrganMenuHandler;
@@ -127,4 +129,5 @@ public interface OrganService {
*/ */
void validOrgan(Long id); void validOrgan(Long id);
List<OrganSimpleRespVO> getSimpleOrganList(String name);
} }
@@ -10,13 +10,16 @@ import com.cf.imes.framework.common.util.collection.CollectionUtils;
import com.cf.imes.framework.common.util.date.DateUtils; import com.cf.imes.framework.common.util.date.DateUtils;
import com.cf.imes.framework.common.util.object.BeanUtils; import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.framework.common.util.pinyin.PinYinUtils; import com.cf.imes.framework.common.util.pinyin.PinYinUtils;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.organ.config.OrganProperties; import com.cf.imes.framework.organ.config.OrganProperties;
import com.cf.imes.framework.organ.core.context.OrganContextHolder; import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.framework.organ.core.util.OrganUtils; import com.cf.imes.framework.organ.core.util.OrganUtils;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSimpleRespVO;
import com.cf.imes.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; import com.cf.imes.module.system.controller.admin.permission.vo.role.RoleSaveReqVO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO; import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganPageReqVO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSaveReqVO; import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSaveReqVO;
import com.cf.imes.module.system.controller.admin.user.vo.user.UserSaveReqVO; import com.cf.imes.module.system.controller.admin.user.vo.user.UserSaveReqVO;
import com.cf.imes.module.system.controller.admin.user.vo.user.UserSimpleRespVO;
import com.cf.imes.module.system.convert.organ.OrganConvert; import com.cf.imes.module.system.convert.organ.OrganConvert;
import com.cf.imes.module.system.dal.dataobject.permission.MenuDO; import com.cf.imes.module.system.dal.dataobject.permission.MenuDO;
import com.cf.imes.module.system.dal.dataobject.permission.RoleDO; import com.cf.imes.module.system.dal.dataobject.permission.RoleDO;
@@ -96,6 +99,14 @@ public class OrganServiceImpl implements OrganService {
} }
} }
@Override
public List<OrganSimpleRespVO> getSimpleOrganList(String name) {
List<OrganizationDO> organizationDOS = organMapper.selectList(new LambdaQueryWrapperX<OrganizationDO>()
.likeIfPresent(OrganizationDO::getName, name)
.select(OrganizationDO::getId, OrganizationDO::getName));
return BeanUtils.toBean(organizationDOS, OrganSimpleRespVO.class);
}
@Override @Override
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换 @DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
public Long createOrgan(OrganSaveReqVO createReqVO) { public Long createOrgan(OrganSaveReqVO createReqVO) {
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.cf.imes.module.system.dal.mysql.datasource.DataSourceMapper">
<resultMap id="map" type="com.cf.imes.module.system.controller.admin.datasource.vo.DataSourceRespVO">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="type" column="type"/>
<result property="createTime" column="create_time"/>
<result property="sql" column="sql"/>
<collection property="filedList" javaType="java.util.List" ofType="com.cf.imes.module.system.dal.dataobject.datasource.DataSourceFiledDO">
<result property="name" column="field_name"/>
<result property="sourceId" column="field_source_id"/>
<result property="id" column="field_id"/>
<result property="key" column="field_key"/>
</collection>
</resultMap>
<select id="selectListVO" resultMap="map">
select a.*, b.id field_id, b.name field_name, b.source_id field_source_id, b.key field_key
from system_data_source a
left join system_data_source_field b on a.id = b.source_id
</select>
</mapper>
@@ -95,7 +95,7 @@
</where> </where>
</select> </select>
<select id="xxselectOrganTemplatePage" resultMap="xxMap"> <select id="selectOrganTemplatePage" resultMap="xxMap">
select * from ( select * from (
select a.id as organId, a.name as organName, max(b.create_time) as updateTime, select a.id as organId, a.name as organName, max(b.create_time) as updateTime,
case when ('${vo.templateName}' != '') then '${vo.templateName}' else '' end as templateName case when ('${vo.templateName}' != '') then '${vo.templateName}' else '' end as templateName