mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
修改标签、标签模板的存储结构
This commit is contained in:
+8
-3
@@ -15,10 +15,15 @@ public class GetSourceDataReq {
|
|||||||
@NotNull(message = "生产单id不能空")
|
@NotNull(message = "生产单id不能空")
|
||||||
private Long orderId;
|
private Long orderId;
|
||||||
|
|
||||||
@Schema(description = "排单id")
|
|
||||||
private Long planId;
|
|
||||||
|
|
||||||
@Schema(description = "数据源id")
|
@Schema(description = "数据源id")
|
||||||
@NotNull(message = "数据源id不能空")
|
@NotNull(message = "数据源id不能空")
|
||||||
private Long dataSourceId;
|
private Long dataSourceId;
|
||||||
|
|
||||||
|
@Schema(description = "排单id")
|
||||||
|
private Long planId;
|
||||||
|
|
||||||
|
@Schema(description = "包裹id")
|
||||||
|
private Long packageId;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -89,5 +89,5 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
|||||||
return selectList(wrapper);
|
return selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> selectDynamicSqlString(String sql);
|
Map<String, Object> selectDynamicSqlString(@Param("sqlStr") String sqlStr);
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-1
@@ -237,7 +237,14 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getLabelDataSourceValue(GetSourceDataReq req) {
|
public Map<String, Object> getLabelDataSourceValue(GetSourceDataReq req) {
|
||||||
String sqlStr = dataSourceApi.getSqlById(req.getDataSourceId()).getCheckedData();
|
String sqlStr = dataSourceApi.getSqlById(req.getDataSourceId()).getCheckedData();
|
||||||
return orderMapper.selectDynamicSqlString(String.format(sqlStr, req.getOrderId()));
|
String sql = sqlStr.replace("#{orderId}", req.getOrderId() + "");
|
||||||
|
if(!Objects.isNull(req.getPackageId())) {
|
||||||
|
sql = sql.replace("#{packageId}", req.getPackageId() + "");
|
||||||
|
}
|
||||||
|
if(!Objects.isNull(req.getPlanId())) {
|
||||||
|
sql = sql.replace("#{planId}", req.getPlanId() + "");
|
||||||
|
}
|
||||||
|
return orderMapper.selectDynamicSqlString(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+7
-15
@@ -6,12 +6,10 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
|||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
||||||
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.label.vo.LabelElementRespVO;
|
|
||||||
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.lable.LabelDO;
|
import com.cf.imes.module.system.dal.dataobject.lable.LabelDO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.lable.LabelElementDO;
|
|
||||||
import com.cf.imes.module.system.service.lable.LabelService;
|
import com.cf.imes.module.system.service.lable.LabelService;
|
||||||
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;
|
||||||
@@ -40,7 +38,7 @@ public class LabelController {
|
|||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建标签")
|
@Operation(summary = "创建标签")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label:create')")
|
@PreAuthorize("@ss.hasPermission('system:label:create')")
|
||||||
@OperateLog(logArgs = false)
|
@OperateLog(enable = false)
|
||||||
public CommonResult<Long> createLabel(@Valid @RequestBody LabelSaveReqVO createReqVO) {
|
public CommonResult<Long> createLabel(@Valid @RequestBody LabelSaveReqVO createReqVO) {
|
||||||
return success(labelService.createLabel(createReqVO));
|
return success(labelService.createLabel(createReqVO));
|
||||||
}
|
}
|
||||||
@@ -48,7 +46,7 @@ public class LabelController {
|
|||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新标签")
|
@Operation(summary = "更新标签")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label:update')")
|
@PreAuthorize("@ss.hasPermission('system:label:update')")
|
||||||
@OperateLog(logArgs = false)
|
@OperateLog(enable = false)
|
||||||
public CommonResult<Boolean> updateLabel(@Valid @RequestBody LabelSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateLabel(@Valid @RequestBody LabelSaveReqVO updateReqVO) {
|
||||||
labelService.updateLabel(updateReqVO);
|
labelService.updateLabel(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -67,6 +65,7 @@ public class LabelController {
|
|||||||
@Operation(summary = "获得标签")
|
@Operation(summary = "获得标签")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label:query')")
|
@PreAuthorize("@ss.hasPermission('system:label:query')")
|
||||||
|
@OperateLog(enable = false)
|
||||||
public CommonResult<LabelRespVO> getLabel(@RequestParam("id") Long id) {
|
public CommonResult<LabelRespVO> getLabel(@RequestParam("id") Long id) {
|
||||||
return success(labelService.getLabel(id));
|
return success(labelService.getLabel(id));
|
||||||
}
|
}
|
||||||
@@ -74,6 +73,7 @@ public class LabelController {
|
|||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得标签分页")
|
@Operation(summary = "获得标签分页")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label:query')")
|
@PreAuthorize("@ss.hasPermission('system:label:query')")
|
||||||
|
@OperateLog(enable = false)
|
||||||
public CommonResult<PageResult<LabelRespVO>> getLabelPage(@Valid LabelPageReqVO pageReqVO) {
|
public CommonResult<PageResult<LabelRespVO>> getLabelPage(@Valid LabelPageReqVO pageReqVO) {
|
||||||
PageResult<LabelDO> pageResult = labelService.getLabelPage(pageReqVO);
|
PageResult<LabelDO> pageResult = labelService.getLabelPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, LabelRespVO.class));
|
return success(BeanUtils.toBean(pageResult, LabelRespVO.class));
|
||||||
@@ -83,13 +83,15 @@ public class LabelController {
|
|||||||
@Operation(summary = "获得标签列表")
|
@Operation(summary = "获得标签列表")
|
||||||
@Parameter(name = "type", description = "类型", required = false, example = "1024")
|
@Parameter(name = "type", description = "类型", required = false, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label:query')")
|
@PreAuthorize("@ss.hasPermission('system:label:query')")
|
||||||
public CommonResult<List<LabelRespVO>> getLabel(@RequestParam("type") String type) {
|
@OperateLog(enable = false)
|
||||||
|
public CommonResult<List<LabelRespVO>> getList(@RequestParam("type") String type) {
|
||||||
return success(BeanUtils.toBean(labelService.list(type), LabelRespVO.class));
|
return success(BeanUtils.toBean(labelService.list(type), LabelRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/group-list")
|
@GetMapping("/group-list")
|
||||||
@Operation(summary = "获得分组标签列表")
|
@Operation(summary = "获得分组标签列表")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label:query')")
|
@PreAuthorize("@ss.hasPermission('system:label:query')")
|
||||||
|
@OperateLog(enable = false)
|
||||||
public CommonResult<Map<String, List<LabelRespVO>>> getGroupList() {
|
public CommonResult<Map<String, List<LabelRespVO>>> getGroupList() {
|
||||||
return success(labelService.getGroupList());
|
return success(labelService.getGroupList());
|
||||||
}
|
}
|
||||||
@@ -107,14 +109,4 @@ public class LabelController {
|
|||||||
BeanUtils.toBean(list, LabelRespVO.class));
|
BeanUtils.toBean(list, LabelRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 子表(标签元素) ====================
|
|
||||||
|
|
||||||
@GetMapping("/label-element/list-by-label-id")
|
|
||||||
@Operation(summary = "获得标签元素列表")
|
|
||||||
@Parameter(name = "labelId", description = "标签id")
|
|
||||||
@PreAuthorize("@ss.hasPermission('system:label:query')")
|
|
||||||
public CommonResult<List<LabelElementRespVO>> getLabelElementListByLabelId(@RequestParam("labelId") Long labelId) {
|
|
||||||
return success(labelService.getLabelElementListByLabelId(labelId));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+5
-2
@@ -46,7 +46,10 @@ public class LabelRespVO {
|
|||||||
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@Schema(description = "标签元素模板列表")
|
/*@Schema(description = "标签元素模板列表")
|
||||||
private List<LabelElementRespVO> labelElements;
|
private List<LabelElementRespVO> labelElements;*/
|
||||||
|
|
||||||
|
@Schema(description = "配置")
|
||||||
|
private String template;
|
||||||
|
|
||||||
}
|
}
|
||||||
+6
-2
@@ -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 co.elastic.clients.elasticsearch.watcher.DeactivateWatchRequest;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -34,7 +35,10 @@ public class LabelSaveReqVO {
|
|||||||
@NotNull(message = "高度不能为空")
|
@NotNull(message = "高度不能为空")
|
||||||
private Integer height;
|
private Integer height;
|
||||||
|
|
||||||
@Schema(description = "标签元素模板列表")
|
/*@Schema(description = "标签元素模板列表")
|
||||||
private List<LabelElementSaveReqVO> elements;
|
private List<LabelElementSaveReqVO> elements;*/
|
||||||
|
|
||||||
|
@Schema(description = "配置")
|
||||||
|
private String template;
|
||||||
|
|
||||||
}
|
}
|
||||||
+6
-17
@@ -1,27 +1,21 @@
|
|||||||
package com.cf.imes.module.system.controller.admin.labeltemplate;
|
package com.cf.imes.module.system.controller.admin.labeltemplate;
|
||||||
|
|
||||||
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelElementTemplateDO;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
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;
|
||||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
||||||
import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.*;
|
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.*;
|
||||||
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.service.labeltemplate.LabelTemplateService;
|
import com.cf.imes.module.system.service.labeltemplate.LabelTemplateService;
|
||||||
@@ -41,7 +35,7 @@ public class LabelTemplateController {
|
|||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建标签模板")
|
@Operation(summary = "创建标签模板")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label-template:create')")
|
@PreAuthorize("@ss.hasPermission('system:label-template:create')")
|
||||||
@OperateLog(logArgs = false)
|
@OperateLog(enable = false)
|
||||||
public CommonResult<Long> createLabelTemplate(@Valid @RequestBody LabelTemplateSaveReqVO createReqVO) {
|
public CommonResult<Long> createLabelTemplate(@Valid @RequestBody LabelTemplateSaveReqVO createReqVO) {
|
||||||
return success(labelTemplateService.createLabelTemplate(createReqVO));
|
return success(labelTemplateService.createLabelTemplate(createReqVO));
|
||||||
}
|
}
|
||||||
@@ -49,7 +43,7 @@ public class LabelTemplateController {
|
|||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新标签模板")
|
@Operation(summary = "更新标签模板")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label-template:update')")
|
@PreAuthorize("@ss.hasPermission('system:label-template:update')")
|
||||||
@OperateLog(logArgs = false)
|
@OperateLog(enable = false)
|
||||||
public CommonResult<Boolean> updateLabelTemplate(@Valid @RequestBody LabelTemplateSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateLabelTemplate(@Valid @RequestBody LabelTemplateSaveReqVO updateReqVO) {
|
||||||
labelTemplateService.updateLabelTemplate(updateReqVO);
|
labelTemplateService.updateLabelTemplate(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
@@ -68,6 +62,7 @@ public class LabelTemplateController {
|
|||||||
@Operation(summary = "获得标签模板")
|
@Operation(summary = "获得标签模板")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label-template:query')")
|
@PreAuthorize("@ss.hasPermission('system:label-template:query')")
|
||||||
|
@OperateLog(enable = false)
|
||||||
public CommonResult<LabelTemplateRespVO> getLabelTemplate(@RequestParam("id") Long id) {
|
public CommonResult<LabelTemplateRespVO> getLabelTemplate(@RequestParam("id") Long id) {
|
||||||
return success(labelTemplateService.getLabelTemplate(id));
|
return success(labelTemplateService.getLabelTemplate(id));
|
||||||
}
|
}
|
||||||
@@ -75,6 +70,7 @@ public class LabelTemplateController {
|
|||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得标签模板分页")
|
@Operation(summary = "获得标签模板分页")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label-template:query')")
|
@PreAuthorize("@ss.hasPermission('system:label-template:query')")
|
||||||
|
@OperateLog(enable = false)
|
||||||
public CommonResult<PageResult<LabelTemplateRespVO>> getLabelTemplatePage(@Valid LabelTemplatePageReqVO pageReqVO) {
|
public CommonResult<PageResult<LabelTemplateRespVO>> getLabelTemplatePage(@Valid LabelTemplatePageReqVO pageReqVO) {
|
||||||
PageResult<LabelTemplateDO> pageResult = labelTemplateService.getLabelTemplatePage(pageReqVO);
|
PageResult<LabelTemplateDO> pageResult = labelTemplateService.getLabelTemplatePage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, LabelTemplateRespVO.class));
|
return success(BeanUtils.toBean(pageResult, LabelTemplateRespVO.class));
|
||||||
@@ -83,6 +79,7 @@ public class LabelTemplateController {
|
|||||||
@GetMapping("/group-list")
|
@GetMapping("/group-list")
|
||||||
@Operation(summary = "获得分组标签模板列表")
|
@Operation(summary = "获得分组标签模板列表")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label-template:query')")
|
@PreAuthorize("@ss.hasPermission('system:label-template:query')")
|
||||||
|
@OperateLog(enable = false)
|
||||||
public CommonResult<Map<String, List<LabelTemplateRespVO>>> getGroupList() {
|
public CommonResult<Map<String, List<LabelTemplateRespVO>>> getGroupList() {
|
||||||
return success(labelTemplateService.getGroupList());
|
return success(labelTemplateService.getGroupList());
|
||||||
}
|
}
|
||||||
@@ -91,6 +88,7 @@ public class LabelTemplateController {
|
|||||||
@Operation(summary = "获得默认标签模板")
|
@Operation(summary = "获得默认标签模板")
|
||||||
@Parameter(name = "type", description = "标签类型", required = true, example = "1024")
|
@Parameter(name = "type", description = "标签类型", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('system:label-template:query')")
|
@PreAuthorize("@ss.hasPermission('system:label-template:query')")
|
||||||
|
@OperateLog(enable = false)
|
||||||
public CommonResult<LabelTemplateRespVO> getDefaultLabelTemplate(@RequestParam("type") String type) {
|
public CommonResult<LabelTemplateRespVO> getDefaultLabelTemplate(@RequestParam("type") String type) {
|
||||||
return success(labelTemplateService.getDefaultLabelTemplate(type));
|
return success(labelTemplateService.getDefaultLabelTemplate(type));
|
||||||
}
|
}
|
||||||
@@ -108,14 +106,5 @@ public class LabelTemplateController {
|
|||||||
BeanUtils.toBean(list, LabelTemplateRespVO.class));
|
BeanUtils.toBean(list, LabelTemplateRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 子表(标签元素模板) ====================
|
|
||||||
|
|
||||||
@GetMapping("/label-element-template/list-by-label-template-id")
|
|
||||||
@Operation(summary = "获得标签元素模板列表")
|
|
||||||
@Parameter(name = "labelTemplateId", description = "标签模板id")
|
|
||||||
@PreAuthorize("@ss.hasPermission('system:label-template:query')")
|
|
||||||
public CommonResult<List<LabelElementTemplateRespVO>> getLabelElementTemplateListByLabelTemplateId(@RequestParam("labelTemplateId") Long labelTemplateId) {
|
|
||||||
return success(labelTemplateService.getLabelElementTemplateListByLabelTemplateId(labelTemplateId));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+5
-6
@@ -1,12 +1,9 @@
|
|||||||
package com.cf.imes.module.system.controller.admin.labeltemplate.vo;
|
package com.cf.imes.module.system.controller.admin.labeltemplate.vo;
|
||||||
|
|
||||||
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelElementTemplateDO;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import java.util.*;
|
|
||||||
import java.util.*;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import com.alibaba.excel.annotation.*;
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
@@ -47,7 +44,9 @@ public class LabelTemplateRespVO {
|
|||||||
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@Schema(description = "标签元素模板列表")
|
/*@Schema(description = "标签元素模板列表")
|
||||||
private List<LabelElementTemplateRespVO> labelElementTemplates;
|
private List<LabelElementTemplateRespVO> labelElementTemplates;*/
|
||||||
|
@Schema(description = "配置")
|
||||||
|
private String template;
|
||||||
|
|
||||||
}
|
}
|
||||||
+4
-4
@@ -1,11 +1,9 @@
|
|||||||
package com.cf.imes.module.system.controller.admin.labeltemplate.vo;
|
package com.cf.imes.module.system.controller.admin.labeltemplate.vo;
|
||||||
|
|
||||||
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelElementTemplateDO;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 标签模板新增/修改 Request VO")
|
@Schema(description = "管理后台 - 标签模板新增/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@@ -34,7 +32,9 @@ public class LabelTemplateSaveReqVO {
|
|||||||
@NotNull(message = "高度不能为空")
|
@NotNull(message = "高度不能为空")
|
||||||
private Integer height;
|
private Integer height;
|
||||||
|
|
||||||
@Schema(description = "标签元素模板列表")
|
/*@Schema(description = "标签元素模板列表")
|
||||||
private List<LabelElementTemplateSaveReqVO> elements;
|
private List<LabelElementTemplateSaveReqVO> elements;*/
|
||||||
|
@Schema(description = "配置")
|
||||||
|
private String template;
|
||||||
|
|
||||||
}
|
}
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
-52
@@ -1,52 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
-76
@@ -1,76 +0,0 @@
|
|||||||
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))
|
|
||||||
.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()
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-53
@@ -1,53 +0,0 @@
|
|||||||
package com.cf.imes.module.system.dal.dataobject.labeltemplate;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import lombok.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
|
||||||
import org.apache.ibatis.type.JdbcType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 标签元素模板 DO
|
|
||||||
*
|
|
||||||
* @author 晨丰科技
|
|
||||||
*/
|
|
||||||
@TableName("system_label_element_template")
|
|
||||||
@KeySequence("system_label_element_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class LabelElementTemplateDO extends BaseDO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注释
|
|
||||||
*/
|
|
||||||
@TableId
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* 标签模板id
|
|
||||||
*/
|
|
||||||
private Long labelTemplateId;
|
|
||||||
/**
|
|
||||||
* 标签元素名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
/**
|
|
||||||
* 元素类型
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
/**
|
|
||||||
* 数据源id
|
|
||||||
*/
|
|
||||||
private Long sourceId;
|
|
||||||
/**
|
|
||||||
* 元素配置
|
|
||||||
*/
|
|
||||||
private String config;
|
|
||||||
|
|
||||||
}
|
|
||||||
+4
@@ -51,5 +51,9 @@ public class LabelTemplateDO extends BaseDO {
|
|||||||
* 是否默认
|
* 是否默认
|
||||||
*/
|
*/
|
||||||
private Boolean isDefault;
|
private Boolean isDefault;
|
||||||
|
/**
|
||||||
|
* 配置
|
||||||
|
*/
|
||||||
|
private String template;
|
||||||
|
|
||||||
}
|
}
|
||||||
+4
@@ -47,5 +47,9 @@ public class LabelDO extends OrganBaseDO {
|
|||||||
* 高度
|
* 高度
|
||||||
*/
|
*/
|
||||||
private Integer height;
|
private Integer height;
|
||||||
|
/**
|
||||||
|
* 配置
|
||||||
|
*/
|
||||||
|
private String template;
|
||||||
|
|
||||||
}
|
}
|
||||||
-51
@@ -1,51 +0,0 @@
|
|||||||
package com.cf.imes.module.system.dal.dataobject.lable;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
|
||||||
import com.cf.imes.framework.organ.core.db.OrganBaseDO;
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 标签元素模板 DO
|
|
||||||
*
|
|
||||||
* @author 晨丰科技
|
|
||||||
*/
|
|
||||||
@TableName("system_label_element")
|
|
||||||
@KeySequence("system_label_element_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class LabelElementDO extends OrganBaseDO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注释
|
|
||||||
*/
|
|
||||||
@TableId
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* 标签模板id
|
|
||||||
*/
|
|
||||||
private Long labelId;
|
|
||||||
/**
|
|
||||||
* 标签元素名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
/**
|
|
||||||
* 元素类型
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
/**
|
|
||||||
* 数据源id
|
|
||||||
*/
|
|
||||||
private Long sourceId;
|
|
||||||
/**
|
|
||||||
* 元素配置
|
|
||||||
*/
|
|
||||||
private String config;
|
|
||||||
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
package com.cf.imes.module.system.dal.mysql.label;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
|
||||||
import com.cf.imes.module.system.dal.dataobject.lable.LabelElementDO;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 标签元素模板 Mapper
|
|
||||||
*
|
|
||||||
* @author 晨丰科技
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface LabelElementMapper extends BaseMapperX<LabelElementDO> {
|
|
||||||
|
|
||||||
default List<LabelElementDO> selectListByLabelId(Long labelTemplateId) {
|
|
||||||
return selectList(LabelElementDO::getLabelId, labelTemplateId);
|
|
||||||
}
|
|
||||||
|
|
||||||
default int deleteByLabelId(Long labelTemplateId) {
|
|
||||||
return delete(LabelElementDO::getLabelId, labelTemplateId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
package com.cf.imes.module.system.dal.mysql.labeltemplate;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import com.cf.imes.framework.common.pojo.PageResult;
|
|
||||||
import com.cf.imes.framework.common.pojo.PageParam;
|
|
||||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
||||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
|
||||||
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelElementTemplateDO;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 标签元素模板 Mapper
|
|
||||||
*
|
|
||||||
* @author 晨丰科技
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface LabelElementTemplateMapper extends BaseMapperX<LabelElementTemplateDO> {
|
|
||||||
|
|
||||||
default List<LabelElementTemplateDO> selectListByLabelTemplateId(Long labelTemplateId) {
|
|
||||||
return selectList(LabelElementTemplateDO::getLabelTemplateId, labelTemplateId);
|
|
||||||
}
|
|
||||||
|
|
||||||
default int deleteByLabelTemplateId(Long labelTemplateId) {
|
|
||||||
return delete(LabelElementTemplateDO::getLabelTemplateId, labelTemplateId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-9
@@ -2,10 +2,8 @@ package com.cf.imes.module.system.service.labeltemplate;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.*;
|
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.*;
|
||||||
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelElementTemplateDO;
|
|
||||||
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelTemplateDO;
|
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelTemplateDO;
|
||||||
import com.cf.imes.framework.common.pojo.PageResult;
|
import com.cf.imes.framework.common.pojo.PageResult;
|
||||||
import com.cf.imes.framework.common.pojo.PageParam;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
@@ -56,13 +54,6 @@ public interface LabelTemplateService {
|
|||||||
|
|
||||||
// ==================== 子表(标签元素模板) ====================
|
// ==================== 子表(标签元素模板) ====================
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得标签元素模板列表
|
|
||||||
*
|
|
||||||
* @param labelTemplateId 标签模板id
|
|
||||||
* @return 标签元素模板列表
|
|
||||||
*/
|
|
||||||
List<LabelElementTemplateRespVO> getLabelElementTemplateListByLabelTemplateId(Long labelTemplateId);
|
|
||||||
|
|
||||||
Map<String, List<LabelTemplateRespVO>> getGroupList();
|
Map<String, List<LabelTemplateRespVO>> getGroupList();
|
||||||
|
|
||||||
|
|||||||
+1
-233
@@ -1,43 +1,18 @@
|
|||||||
package com.cf.imes.module.system.service.labeltemplate;
|
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.lang.TypeReference;
|
|
||||||
import cn.hutool.json.JSONObject;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
||||||
import co.elastic.clients.elasticsearch._types.FieldValue;
|
|
||||||
import co.elastic.clients.elasticsearch._types.query_dsl.TermsQuery;
|
|
||||||
import co.elastic.clients.elasticsearch.core.DeleteByQueryRequest;
|
|
||||||
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
|
||||||
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.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.labeltemplate.LabelElementTemplateDO;
|
|
||||||
import com.cf.imes.module.system.dal.dataobject.machine.CuttingSettingDO;
|
|
||||||
import com.cf.imes.module.system.dal.mysql.labeltemplate.LabelElementTemplateMapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.*;
|
import com.cf.imes.module.system.controller.admin.labeltemplate.vo.*;
|
||||||
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelTemplateDO;
|
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelTemplateDO;
|
||||||
import com.cf.imes.framework.common.pojo.PageResult;
|
import com.cf.imes.framework.common.pojo.PageResult;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
import com.cf.imes.module.system.dal.mysql.labeltemplate.LabelTemplateMapper;
|
import com.cf.imes.module.system.dal.mysql.labeltemplate.LabelTemplateMapper;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
|
|
||||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
@@ -53,140 +28,33 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private LabelTemplateMapper labelTemplateMapper;
|
private LabelTemplateMapper labelTemplateMapper;
|
||||||
@Resource
|
|
||||||
private LabelElementTemplateMapper labelElementTemplateMapper;
|
|
||||||
@Resource
|
|
||||||
private ESDocumentService esDocumentService;
|
|
||||||
@Resource
|
|
||||||
private ElasticsearchClient elasticsearchClient;
|
|
||||||
@Resource
|
|
||||||
private LabelTemplateConvert labelTemplateConvert;
|
|
||||||
|
|
||||||
private static final String LABEL_TEMPLATE_ELEMENT_PROPERTY_INX = "label_template_element_property";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public Long createLabelTemplate(LabelTemplateSaveReqVO createReqVO) {
|
public Long createLabelTemplate(LabelTemplateSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
LabelTemplateDO labelTemplate = BeanUtils.toBean(createReqVO, LabelTemplateDO.class);
|
LabelTemplateDO labelTemplate = BeanUtils.toBean(createReqVO, LabelTemplateDO.class);
|
||||||
labelTemplateMapper.insert(labelTemplate);
|
labelTemplateMapper.insert(labelTemplate);
|
||||||
|
|
||||||
// 插入子表
|
|
||||||
List<LabelElementTemplateSaveReqVO> createReqVOElements = createReqVO.getElements();
|
|
||||||
if(CollectionUtil.isNotEmpty(createReqVOElements)) {
|
|
||||||
List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>();
|
|
||||||
createReqVOElements.forEach(e -> {
|
|
||||||
e.setLabelTemplateId(labelTemplate.getId());
|
|
||||||
LabelElementTemplateDO elementTemplateDO = labelTemplateConvert.convert(e);
|
|
||||||
labelElementTemplateMapper.insert(elementTemplateDO);
|
|
||||||
/*LabelElementPropertyDO propertyDO = e.getPropertyDO();
|
|
||||||
propertyDO.setElementId(elementTemplateDO.getId());
|
|
||||||
labelElementPropertyDOS.add(propertyDO);*/
|
|
||||||
});
|
|
||||||
//插入索引
|
|
||||||
/* try {
|
|
||||||
esDocumentService.bulkCreate(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX, labelElementPropertyDOS);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw exception(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
// 返回
|
// 返回
|
||||||
return labelTemplate.getId();
|
return labelTemplate.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updateLabelTemplate(LabelTemplateSaveReqVO updateReqVO) {
|
public void updateLabelTemplate(LabelTemplateSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateLabelTemplateExists(updateReqVO.getId());
|
validateLabelTemplateExists(updateReqVO.getId());
|
||||||
// 更新
|
// 更新
|
||||||
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>()
|
|
||||||
.select(LabelElementTemplateDO::getId)
|
|
||||||
.eq(LabelElementTemplateDO::getLabelTemplateId, updateReqVO.getId()));*/
|
|
||||||
//删除旧的元素
|
|
||||||
/*DeleteByQueryRequest.Builder builder = null;
|
|
||||||
if(CollectionUtil.isNotEmpty(labelElementTemplateDOS)) {
|
|
||||||
List<Long> templateIds = labelElementTemplateDOS.stream()
|
|
||||||
.map(LabelElementTemplateDO::getId)
|
|
||||||
.toList();
|
|
||||||
labelElementTemplateMapper.deleteBatchIds(templateIds);
|
|
||||||
List<FieldValue> fieldValues = templateIds.stream().map(FieldValue::of).collect(Collectors.toList());
|
|
||||||
builder = new DeleteByQueryRequest.Builder()
|
|
||||||
.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX)
|
|
||||||
.query(TermsQuery.of(e -> e.field("elementId").terms(b -> b.value(fieldValues)))._toQuery());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
//新增新的元素
|
|
||||||
List<LabelElementTemplateSaveReqVO> createReqVOElements = updateReqVO.getElements();
|
|
||||||
List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>();
|
|
||||||
createReqVOElements.forEach(e -> {
|
|
||||||
e.setLabelTemplateId(updateObj.getId());
|
|
||||||
LabelElementTemplateDO elementTemplateDO = labelTemplateConvert.convert(e);
|
|
||||||
//LabelElementTemplateDO elementTemplateDO = Convert.convert(LabelElementTemplateDO.class, e);
|
|
||||||
labelElementTemplateMapper.insert(elementTemplateDO);
|
|
||||||
/*LabelElementPropertyDO propertyDO = e.getPropertyDO();
|
|
||||||
propertyDO.setElementId(elementTemplateDO.getId());
|
|
||||||
labelElementPropertyDOS.add(propertyDO);*/
|
|
||||||
});
|
|
||||||
//插入索引
|
|
||||||
/*try {
|
|
||||||
if(CollectionUtil.isNotEmpty(labelElementPropertyDOS)) {
|
|
||||||
esDocumentService.bulkCreate(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX, labelElementPropertyDOS);
|
|
||||||
}
|
|
||||||
if(!Objects.isNull(builder)) {
|
|
||||||
elasticsearchClient.deleteByQuery(builder.build());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw exception(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
/*updateLabelElementTemplateList(updateReqVO.getId(), Convert.convert(new TypeReference<List<LabelElementTemplateDO>>() {
|
|
||||||
}, elements));*/
|
|
||||||
/* labelElementTemplateMapper.updateBatch(Convert.convert(new TypeReference<List<LabelElementTemplateDO>>() {
|
|
||||||
}, elements));
|
|
||||||
List<LabelElementPropertyDO> labelElementPropertyDOS = elements.stream().map(e -> e.getPropertyDO()).collect(Collectors.toList());
|
|
||||||
try {
|
|
||||||
esDocumentService.bulkCreate(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX, labelElementPropertyDOS);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw exception(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void deleteLabelTemplate(Long id) {
|
public void deleteLabelTemplate(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
LabelTemplateDO labelTemplateDO = labelTemplateMapper.selectById(id);
|
LabelTemplateDO labelTemplateDO = labelTemplateMapper.selectById(id);
|
||||||
if (labelTemplateDO == null) {
|
if (labelTemplateDO == null) {
|
||||||
throw exception(LABEL_TEMPLATE_NOT_EXISTS);
|
throw exception(LABEL_TEMPLATE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectListByLabelTemplateId(id);
|
|
||||||
/*List<FieldValue> fieldValues = labelElementTemplateDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
|
|
||||||
// 删除索引
|
|
||||||
DeleteByQueryRequest.Builder builder = new DeleteByQueryRequest.Builder()
|
|
||||||
.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX)
|
|
||||||
.query(TermsQuery.of(e -> e.field("elementId").terms(b -> b.value(fieldValues)))._toQuery());
|
|
||||||
try {
|
|
||||||
elasticsearchClient.deleteByQuery(builder.build());
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw exception(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
// 删除标签模板表
|
|
||||||
labelTemplateMapper.deleteById(id);
|
labelTemplateMapper.deleteById(id);
|
||||||
// 删除标签元素模板表
|
|
||||||
labelElementTemplateMapper.delete(new LambdaQueryWrapperX<LabelElementTemplateDO>().eq(LabelElementTemplateDO::getLabelTemplateId, id));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateLabelTemplateExists(Long id) {
|
private void validateLabelTemplateExists(Long id) {
|
||||||
@@ -198,33 +66,7 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
|
|||||||
@Override
|
@Override
|
||||||
public LabelTemplateRespVO getLabelTemplate(Long id) {
|
public LabelTemplateRespVO getLabelTemplate(Long id) {
|
||||||
LabelTemplateDO labelTemplateDO = labelTemplateMapper.selectById(id);
|
LabelTemplateDO labelTemplateDO = labelTemplateMapper.selectById(id);
|
||||||
List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectListByLabelTemplateId(labelTemplateDO.getId());
|
|
||||||
LabelTemplateRespVO labelTemplateRespVO = BeanUtils.toBean(labelTemplateDO, LabelTemplateRespVO.class);
|
LabelTemplateRespVO labelTemplateRespVO = BeanUtils.toBean(labelTemplateDO, LabelTemplateRespVO.class);
|
||||||
List<LabelElementTemplateRespVO> labelElementTemplateRespVOS = labelTemplateConvert.convert1(labelElementTemplateDOS);
|
|
||||||
//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;
|
|
||||||
try {
|
|
||||||
SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX)
|
|
||||||
.query(TermsQuery.of(e -> e.field("elementId")
|
|
||||||
.terms(b -> b.value(fieldValues)))._toQuery())
|
|
||||||
.from(0)
|
|
||||||
.size(10000),
|
|
||||||
LabelElementPropertyDO.class);
|
|
||||||
List<Hit<LabelElementPropertyDO>> hits = search.hits().hits();
|
|
||||||
if (CollectionUtil.isNotEmpty(hits)) {
|
|
||||||
List<LabelElementPropertyDO> propertyDOS = hits.stream().map(e -> e.source()).collect(Collectors.toList());
|
|
||||||
for (LabelElementTemplateRespVO respVO : labelElementTemplateRespVOS) {
|
|
||||||
respVO.setPropertyDO(propertyDOS.stream().filter(e -> Objects.equals(e.getElementId(), respVO.getId())).findAny().orElse(null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw new ServiceException(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
labelTemplateRespVO.setLabelElementTemplates(labelElementTemplateRespVOS);
|
|
||||||
return labelTemplateRespVO;
|
return labelTemplateRespVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,67 +75,12 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
|
|||||||
return labelTemplateMapper.selectPage(pageReqVO);
|
return labelTemplateMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 子表(标签元素模板) ====================
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<LabelElementTemplateRespVO> getLabelElementTemplateListByLabelTemplateId(Long labelTemplateId) {
|
|
||||||
List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectListByLabelTemplateId(labelTemplateId);
|
|
||||||
List<LabelElementTemplateRespVO> respVOS = labelTemplateConvert.convert1(labelElementTemplateDOS);
|
|
||||||
//List<LabelElementTemplateRespVO> respVOS = BeanUtils.toBean(labelElementTemplateDOS, LabelElementTemplateRespVO.class);
|
|
||||||
/* List<FieldValue> fieldValues = labelElementTemplateDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
|
|
||||||
try {
|
|
||||||
SearchResponse<LabelElementPropertyDO> response = elasticsearchClient.search(b -> b.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX)
|
|
||||||
.from(0)
|
|
||||||
.size(10000)
|
|
||||||
.query(TermsQuery.of(e -> e.field("elementId").terms(t -> t.value(fieldValues)))._toQuery()),
|
|
||||||
LabelElementPropertyDO.class);
|
|
||||||
List<Hit<LabelElementPropertyDO>> hits = response.hits().hits();
|
|
||||||
if(CollectionUtil.isNotEmpty(hits)) {
|
|
||||||
List<LabelElementPropertyDO> propertyDOS = hits.stream().map(e -> e.source()).collect(Collectors.toList());
|
|
||||||
for (LabelElementTemplateRespVO respVO : respVOS) {
|
|
||||||
respVO.setPropertyDO(propertyDOS.stream().filter(e -> Objects.equals(e.getElementId(), respVO.getId())).findAny().orElse(null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw exception(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
return respVOS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<LabelTemplateRespVO>> getGroupList() {
|
public Map<String, List<LabelTemplateRespVO>> getGroupList() {
|
||||||
List<LabelTemplateDO> labelTemplateDOS = labelTemplateMapper.selectList();
|
List<LabelTemplateDO> labelTemplateDOS = labelTemplateMapper.selectList();
|
||||||
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());
|
return labelTemplateRespVOS.stream().collect(Collectors.groupingBy(LabelTemplateRespVO::getType));
|
||||||
List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectList(new LambdaQueryWrapperX<LabelElementTemplateDO>().in(LabelElementTemplateDO::getLabelTemplateId, ids));
|
|
||||||
List<LabelElementTemplateRespVO> labelElementTemplateRespVOS = labelTemplateConvert.convert1(labelElementTemplateDOS);
|
|
||||||
//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 {
|
|
||||||
SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_TEMPLATE_ELEMENT_PROPERTY_INX)
|
|
||||||
.query(TermsQuery.of(e -> e.field("elementId")
|
|
||||||
.terms(b -> b.value(fieldValues)))._toQuery())
|
|
||||||
.from(0)
|
|
||||||
.size(10000),
|
|
||||||
LabelElementPropertyDO.class);
|
|
||||||
List<Hit<LabelElementPropertyDO>> hits = search.hits().hits();
|
|
||||||
if (CollectionUtil.isNotEmpty(hits)) {
|
|
||||||
List<LabelElementPropertyDO> propertyDOS = hits.stream().map(e -> e.source()).collect(Collectors.toList());
|
|
||||||
for (LabelElementTemplateRespVO respVO : labelElementTemplateRespVOS) {
|
|
||||||
respVO.setPropertyDO(propertyDOS.stream().filter(e -> Objects.equals(e.getElementId(), respVO.getId())).findAny().orElse(null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw new ServiceException(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
for (LabelTemplateRespVO labelTemplateRespVO : labelTemplateRespVOS) {
|
|
||||||
labelTemplateRespVO.setLabelElementTemplates(labelElementTemplateRespVOS.stream().filter(e -> Objects.equals(e.getLabelTemplateId(), labelTemplateRespVO.getId())).toList());
|
|
||||||
}
|
|
||||||
return labelTemplateRespVOS.stream().collect(Collectors.groupingBy(e -> e.getType()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -307,29 +94,10 @@ public class LabelTemplateServiceImpl implements LabelTemplateService {
|
|||||||
throw exception(DEFAULT_TEMPLATE_COUNT);
|
throw exception(DEFAULT_TEMPLATE_COUNT);
|
||||||
}
|
}
|
||||||
LabelTemplateDO labelTemplateDO = labelTemplateDOS.get(0);
|
LabelTemplateDO labelTemplateDO = labelTemplateDOS.get(0);
|
||||||
List<LabelElementTemplateDO> labelElementTemplateDOS = labelElementTemplateMapper.selectListByLabelTemplateId(labelTemplateDO.getId());
|
|
||||||
LabelTemplateRespVO labelTemplateRespVO = BeanUtils.toBean(labelTemplateDO, LabelTemplateRespVO.class);
|
LabelTemplateRespVO labelTemplateRespVO = BeanUtils.toBean(labelTemplateDO, LabelTemplateRespVO.class);
|
||||||
List<LabelElementTemplateRespVO> labelElementTemplateRespVOS = labelTemplateConvert.convert1(labelElementTemplateDOS);
|
|
||||||
labelTemplateRespVO.setLabelElementTemplates(labelElementTemplateRespVOS);
|
|
||||||
return labelTemplateRespVO;
|
return labelTemplateRespVO;
|
||||||
}
|
}
|
||||||
throw exception(DEFAULT_LABEL_NOT_EXISTS);
|
throw exception(DEFAULT_LABEL_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createLabelElementTemplateList(Long labelTemplateId, List<LabelElementTemplateDO> list) {
|
|
||||||
list.forEach(o -> o.setLabelTemplateId(labelTemplateId));
|
|
||||||
labelElementTemplateMapper.insertBatch(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLabelElementTemplateList(Long labelTemplateId, List<LabelElementTemplateDO> list) {
|
|
||||||
deleteLabelElementTemplateByLabelTemplateId(labelTemplateId);
|
|
||||||
list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
|
||||||
createLabelElementTemplateList(labelTemplateId, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteLabelElementTemplateByLabelTemplateId(Long labelTemplateId) {
|
|
||||||
labelElementTemplateMapper.deleteByLabelTemplateId(labelTemplateId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-11
@@ -1,12 +1,10 @@
|
|||||||
package com.cf.imes.module.system.service.lable;
|
package com.cf.imes.module.system.service.lable;
|
||||||
|
|
||||||
import com.cf.imes.framework.common.pojo.PageResult;
|
import com.cf.imes.framework.common.pojo.PageResult;
|
||||||
import com.cf.imes.module.system.controller.admin.label.vo.LabelElementRespVO;
|
|
||||||
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.lable.LabelDO;
|
import com.cf.imes.module.system.dal.dataobject.lable.LabelDO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.lable.LabelElementDO;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -57,15 +55,6 @@ public interface LabelService {
|
|||||||
*/
|
*/
|
||||||
PageResult<LabelDO> getLabelPage(LabelPageReqVO pageReqVO);
|
PageResult<LabelDO> getLabelPage(LabelPageReqVO pageReqVO);
|
||||||
|
|
||||||
// ==================== 子表(标签元素模板) ====================
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得标签元素模板列表
|
|
||||||
*
|
|
||||||
* @param LabelId 标签模板id
|
|
||||||
* @return 标签元素模板列表
|
|
||||||
*/
|
|
||||||
List<LabelElementRespVO> getLabelElementListByLabelId(Long LabelId);
|
|
||||||
|
|
||||||
Map<String, List<LabelRespVO>> getGroupList();
|
Map<String, List<LabelRespVO>> getGroupList();
|
||||||
|
|
||||||
|
|||||||
+11
-228
@@ -1,40 +1,18 @@
|
|||||||
package com.cf.imes.module.system.service.lable;
|
package com.cf.imes.module.system.service.lable;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
import cn.hutool.core.convert.Convert;
|
|
||||||
import cn.hutool.core.lang.TypeReference;
|
|
||||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|
||||||
import co.elastic.clients.elasticsearch._types.FieldValue;
|
|
||||||
import co.elastic.clients.elasticsearch._types.query_dsl.TermsQuery;
|
|
||||||
import co.elastic.clients.elasticsearch.core.DeleteByQueryRequest;
|
|
||||||
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
|
||||||
import co.elastic.clients.elasticsearch.core.search.Hit;
|
|
||||||
import com.cf.imes.framework.common.exception.ServiceException;
|
|
||||||
import com.cf.imes.framework.common.pojo.PageResult;
|
import com.cf.imes.framework.common.pojo.PageResult;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
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.convert.label.LabelConvert;
|
|
||||||
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.lable.LabelDO;
|
import com.cf.imes.module.system.dal.dataobject.lable.LabelDO;
|
||||||
import com.cf.imes.module.system.dal.dataobject.lable.LabelElementDO;
|
|
||||||
import com.cf.imes.module.system.dal.dataobject.machine.CuttingSettingDO;
|
|
||||||
import com.cf.imes.module.system.dal.mysql.label.LabelElementMapper;
|
|
||||||
import com.cf.imes.module.system.dal.mysql.label.LabelMapper;
|
import com.cf.imes.module.system.dal.mysql.label.LabelMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
|
|
||||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.LABEL_NOT_EXISTS;
|
import static com.cf.imes.module.system.enums.ErrorCodeConstants.LABEL_NOT_EXISTS;
|
||||||
|
|
||||||
@@ -49,46 +27,15 @@ import static com.cf.imes.module.system.enums.ErrorCodeConstants.LABEL_NOT_EXIST
|
|||||||
public class LabelServiceImpl implements LabelService {
|
public class LabelServiceImpl implements LabelService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private LabelMapper LabelMapper;
|
private LabelMapper labelMapper;
|
||||||
@Resource
|
|
||||||
private LabelElementMapper labelElementMapper;
|
|
||||||
@Resource
|
|
||||||
private ESDocumentService esDocumentService;
|
|
||||||
@Resource
|
|
||||||
private ElasticsearchClient elasticsearchClient;
|
|
||||||
@Resource
|
|
||||||
private LabelConvert labelConvert;
|
|
||||||
|
|
||||||
private static final String LABEL_ELEMENT_PROPERTY_INX = "label_element_property";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createLabel(LabelSaveReqVO createReqVO) {
|
public Long createLabel(LabelSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
LabelDO Label = BeanUtils.toBean(createReqVO, LabelDO.class);
|
LabelDO Label = BeanUtils.toBean(createReqVO, LabelDO.class);
|
||||||
LabelMapper.insert(Label);
|
labelMapper.insert(Label);
|
||||||
|
|
||||||
// 插入子表
|
|
||||||
List<LabelElementSaveReqVO> createReqVOElements = createReqVO.getElements();
|
|
||||||
if(CollectionUtil.isNotEmpty(createReqVOElements)) {
|
|
||||||
List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>();
|
|
||||||
createReqVOElements.forEach(e -> {
|
|
||||||
e.setLabelId(Label.getId());
|
|
||||||
//LabelElementDO elementDO = Convert.convert(LabelElementDO.class, e);
|
|
||||||
LabelElementDO elementDO = labelConvert.convert(e);
|
|
||||||
labelElementMapper.insert(elementDO);
|
|
||||||
/* LabelElementPropertyDO propertyDO = e.getPropertyDO();
|
|
||||||
propertyDO.setElementId(elementDO.getId());
|
|
||||||
labelElementPropertyDOS.add(propertyDO);*/
|
|
||||||
});
|
|
||||||
//插入索引
|
|
||||||
/* try {
|
|
||||||
esDocumentService.bulkCreate(LABEL_ELEMENT_PROPERTY_INX, labelElementPropertyDOS);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw exception(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
// 返回
|
// 返回
|
||||||
return Label.getId();
|
return Label.getId();
|
||||||
}
|
}
|
||||||
@@ -100,217 +47,53 @@ public class LabelServiceImpl implements LabelService {
|
|||||||
validateLabelExists(updateReqVO.getId());
|
validateLabelExists(updateReqVO.getId());
|
||||||
// 更新
|
// 更新
|
||||||
LabelDO updateObj = BeanUtils.toBean(updateReqVO, LabelDO.class);
|
LabelDO updateObj = BeanUtils.toBean(updateReqVO, LabelDO.class);
|
||||||
LabelMapper.updateById(updateObj);
|
labelMapper.updateById(updateObj);
|
||||||
|
|
||||||
labelElementMapper.delete(new LambdaQueryWrapperX<LabelElementDO>().eq(LabelElementDO::getLabelId, updateReqVO.getId()));
|
|
||||||
|
|
||||||
/*List<LabelElementDO> labelElementDOS = labelElementMapper.selectList(new LambdaQueryWrapperX<LabelElementDO>()
|
|
||||||
.select(LabelElementDO::getId)
|
|
||||||
.eq(LabelElementDO::getLabelId, updateReqVO.getId()));*/
|
|
||||||
//删除旧的元素
|
|
||||||
/*DeleteByQueryRequest.Builder builder = null;
|
|
||||||
if(CollectionUtil.isNotEmpty(labelElementDOS)) {
|
|
||||||
List<Long> templateIds = labelElementDOS.stream()
|
|
||||||
.map(LabelElementDO::getId)
|
|
||||||
.toList();
|
|
||||||
labelElementMapper.deleteBatchIds(templateIds);
|
|
||||||
*//*List<FieldValue> fieldValues = templateIds.stream().map(FieldValue::of).collect(Collectors.toList());
|
|
||||||
builder = new DeleteByQueryRequest.Builder()
|
|
||||||
.index(LABEL_ELEMENT_PROPERTY_INX)
|
|
||||||
.query(TermsQuery.of(e -> e.field("elementId").terms(b -> b.value(fieldValues)))._toQuery());*//*
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
//新增新的元素
|
|
||||||
List<LabelElementSaveReqVO> createReqVOElements = updateReqVO.getElements();
|
|
||||||
List<LabelElementPropertyDO> labelElementPropertyDOS = new ArrayList<>();
|
|
||||||
createReqVOElements.forEach(e -> {
|
|
||||||
e.setLabelId(updateObj.getId());
|
|
||||||
LabelElementDO labelElementDO = labelConvert.convert(e);
|
|
||||||
//LabelElementDO labelElementDO = Convert.convert(LabelElementDO.class, e);
|
|
||||||
labelElementMapper.insert(labelElementDO);
|
|
||||||
/* LabelElementPropertyDO propertyDO = e.getPropertyDO();
|
|
||||||
propertyDO.setElementId(labelElementDO.getId());
|
|
||||||
labelElementPropertyDOS.add(propertyDO);*/
|
|
||||||
});
|
|
||||||
//插入索引
|
|
||||||
/* try {
|
|
||||||
if(CollectionUtil.isNotEmpty(labelElementPropertyDOS)) {
|
|
||||||
esDocumentService.bulkCreate(LABEL_ELEMENT_PROPERTY_INX, labelElementPropertyDOS);
|
|
||||||
}
|
|
||||||
if(!Objects.isNull(builder)) {
|
|
||||||
elasticsearchClient.deleteByQuery(builder.build());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw exception(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/* List<LabelElementSaveReqVO> elements = updateReqVO.getElements();
|
|
||||||
*//*updateLabelElementList(updateReqVO.getId(), Convert.convert(new TypeReference<List<LabelElementDO>>() {
|
|
||||||
}, elements));*//*
|
|
||||||
labelElementMapper.updateBatch(Convert.convert(new TypeReference<List<LabelElementDO>>() {
|
|
||||||
}, elements));
|
|
||||||
List<LabelElementPropertyDO> labelElementPropertyDOS = elements.stream().map(e -> e.getPropertyDO()).collect(Collectors.toList());
|
|
||||||
try {
|
|
||||||
esDocumentService.bulkCreate(LABEL_ELEMENT_PROPERTY_INX, labelElementPropertyDOS);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw exception(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteLabel(Long id) {
|
public void deleteLabel(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
LabelDO LabelDO = LabelMapper.selectById(id);
|
LabelDO LabelDO = labelMapper.selectById(id);
|
||||||
if (LabelDO == null) {
|
if (LabelDO == null) {
|
||||||
throw exception(LABEL_NOT_EXISTS);
|
throw exception(LABEL_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
List<LabelElementDO> labelElementDOS = labelElementMapper.selectListByLabelId(id);
|
|
||||||
List<FieldValue> fieldValues = labelElementDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
|
|
||||||
// 删除索引
|
|
||||||
DeleteByQueryRequest.Builder builder = new DeleteByQueryRequest.Builder()
|
|
||||||
.index(LABEL_ELEMENT_PROPERTY_INX)
|
|
||||||
.query(TermsQuery.of(e -> e.field("elementId").terms(b -> b.value(fieldValues)))._toQuery());
|
|
||||||
try {
|
|
||||||
elasticsearchClient.deleteByQuery(builder.build());
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw exception(INTERNAL_SERVER_ERROR);
|
|
||||||
}
|
|
||||||
// 删除标签模板表
|
// 删除标签模板表
|
||||||
LabelMapper.deleteById(id);
|
labelMapper.deleteById(id);
|
||||||
// 删除标签元素模板表
|
|
||||||
labelElementMapper.delete(new LambdaQueryWrapperX<LabelElementDO>().eq(LabelElementDO::getLabelId, id));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateLabelExists(Long id) {
|
private void validateLabelExists(Long id) {
|
||||||
if (LabelMapper.selectById(id) == null) {
|
if (labelMapper.selectById(id) == null) {
|
||||||
throw exception(LABEL_NOT_EXISTS);
|
throw exception(LABEL_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LabelRespVO getLabel(Long id) {
|
public LabelRespVO getLabel(Long id) {
|
||||||
LabelDO LabelDO = LabelMapper.selectById(id);
|
LabelDO LabelDO = labelMapper.selectById(id);
|
||||||
List<LabelElementDO> labelElementDOS = labelElementMapper.selectListByLabelId(LabelDO.getId());
|
|
||||||
LabelRespVO LabelRespVO = BeanUtils.toBean(LabelDO, LabelRespVO.class);
|
LabelRespVO LabelRespVO = BeanUtils.toBean(LabelDO, LabelRespVO.class);
|
||||||
List<LabelElementRespVO> labelElementRespVOS = labelConvert.convert1(labelElementDOS);
|
|
||||||
//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;
|
|
||||||
try {
|
|
||||||
SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_ELEMENT_PROPERTY_INX)
|
|
||||||
.query(TermsQuery.of(e -> e.field("elementId")
|
|
||||||
.terms(b -> b.value(fieldValues)))._toQuery())
|
|
||||||
.from(0)
|
|
||||||
.size(10000),
|
|
||||||
LabelElementPropertyDO.class);
|
|
||||||
List<Hit<LabelElementPropertyDO>> hits = search.hits().hits();
|
|
||||||
if (CollectionUtil.isNotEmpty(hits)) {
|
|
||||||
List<LabelElementPropertyDO> propertyDOS = hits.stream().map(e -> e.source()).collect(Collectors.toList());
|
|
||||||
for (LabelElementRespVO respVO : labelElementRespVOS) {
|
|
||||||
respVO.setPropertyDO(propertyDOS.stream().filter(e -> Objects.equals(e.getElementId(), respVO.getId())).findAny().orElse(null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw new ServiceException(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
LabelRespVO.setLabelElements(labelElementRespVOS);
|
|
||||||
return LabelRespVO;
|
return LabelRespVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<LabelDO> getLabelPage(LabelPageReqVO pageReqVO) {
|
public PageResult<LabelDO> getLabelPage(LabelPageReqVO pageReqVO) {
|
||||||
return LabelMapper.selectPage(pageReqVO);
|
return labelMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 子表(标签元素模板) ====================
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<LabelElementRespVO> getLabelElementListByLabelId(Long LabelId) {
|
|
||||||
List<LabelElementDO> labelElementDOS = labelElementMapper.selectListByLabelId(LabelId);
|
|
||||||
List<LabelElementRespVO> respVOS = labelConvert.convert1(labelElementDOS);
|
|
||||||
//List<LabelElementRespVO> respVOS = BeanUtils.toBean(labelElementDOS, LabelElementRespVO.class);
|
|
||||||
/* List<FieldValue> fieldValues = labelElementDOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
|
|
||||||
try {
|
|
||||||
SearchResponse<LabelElementPropertyDO> response = elasticsearchClient.search(b -> b.index(LABEL_ELEMENT_PROPERTY_INX)
|
|
||||||
.from(0)
|
|
||||||
.size(10000)
|
|
||||||
.query(TermsQuery.of(e -> e.field("elementId").terms(t -> t.value(fieldValues)))._toQuery()),
|
|
||||||
LabelElementPropertyDO.class);
|
|
||||||
List<Hit<LabelElementPropertyDO>> hits = response.hits().hits();
|
|
||||||
if(CollectionUtil.isNotEmpty(hits)) {
|
|
||||||
List<LabelElementPropertyDO> propertyDOS = hits.stream().map(e -> e.source()).collect(Collectors.toList());
|
|
||||||
for (LabelElementRespVO respVO : respVOS) {
|
|
||||||
respVO.setPropertyDO(propertyDOS.stream().filter(e -> Objects.equals(e.getElementId(), respVO.getId())).findAny().orElse(null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw exception(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
return respVOS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<LabelRespVO>> getGroupList() {
|
public Map<String, List<LabelRespVO>> getGroupList() {
|
||||||
List<LabelDO> LabelDOS = LabelMapper.selectList();
|
List<LabelDO> LabelDOS = labelMapper.selectList();
|
||||||
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());
|
return LabelRespVOS.stream().collect(Collectors.groupingBy(LabelRespVO::getType));
|
||||||
List<LabelElementDO> labelElementDOS = labelElementMapper.selectList(new LambdaQueryWrapperX<LabelElementDO>().in(LabelElementDO::getLabelId, ids));
|
|
||||||
List<LabelElementRespVO> labelElementRespVOS = labelConvert.convert1(labelElementDOS);
|
|
||||||
//List<LabelElementRespVO> labelElementRespVOS = BeanUtils.toBean(labelElementDOS, LabelElementRespVO.class);
|
|
||||||
/*List<FieldValue> fieldValues = labelElementRespVOS.stream().map(e -> FieldValue.of(e.getId())).collect(Collectors.toList());
|
|
||||||
try {
|
|
||||||
SearchResponse<LabelElementPropertyDO> search = elasticsearchClient.search(builder -> builder.index(LABEL_ELEMENT_PROPERTY_INX)
|
|
||||||
.query(TermsQuery.of(e -> e.field("elementId")
|
|
||||||
.terms(b -> b.value(fieldValues)))._toQuery())
|
|
||||||
.from(0)
|
|
||||||
.size(10000),
|
|
||||||
LabelElementPropertyDO.class);
|
|
||||||
List<Hit<LabelElementPropertyDO>> hits = search.hits().hits();
|
|
||||||
if (CollectionUtil.isNotEmpty(hits)) {
|
|
||||||
List<LabelElementPropertyDO> propertyDOS = hits.stream().map(e -> e.source()).collect(Collectors.toList());
|
|
||||||
for (LabelElementRespVO respVO : labelElementRespVOS) {
|
|
||||||
respVO.setPropertyDO(propertyDOS.stream().filter(e -> Objects.equals(e.getElementId(), respVO.getId())).findAny().orElse(null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
throw new ServiceException(INTERNAL_SERVER_ERROR);
|
|
||||||
}*/
|
|
||||||
for (LabelRespVO LabelRespVO : LabelRespVOS) {
|
|
||||||
LabelRespVO.setLabelElements(labelElementRespVOS.stream().filter(e -> Objects.equals(e.getLabelId(), LabelRespVO.getId())).toList());
|
|
||||||
}
|
|
||||||
return LabelRespVOS.stream().collect(Collectors.groupingBy(e -> e.getType()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LabelDO> list(String type) {
|
public List<LabelDO> list(String type) {
|
||||||
return LabelMapper.selectList(new LambdaQueryWrapperX<LabelDO>().eqIfPresent(LabelDO::getType, type));
|
return labelMapper.selectList(new LambdaQueryWrapperX<LabelDO>().eqIfPresent(LabelDO::getType, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createLabelElementList(Long LabelId, List<LabelElementDO> list) {
|
|
||||||
list.forEach(o -> o.setLabelId(LabelId));
|
|
||||||
labelElementMapper.insertBatch(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLabelElementList(Long LabelId, List<LabelElementDO> list) {
|
|
||||||
deleteLabelElementByLabelId(LabelId);
|
|
||||||
list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
|
|
||||||
createLabelElementList(LabelId, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteLabelElementByLabelId(Long LabelId) {
|
|
||||||
labelElementMapper.deleteByLabelId(LabelId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user