80 changed files with 2343 additions and 171 deletions
@ -0,0 +1,21 @@ |
|||
package org.dromara.system.api; |
|||
import org.dromara.system.api.domain.vo.RemoteAiLabelPostVo; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @auther yq |
|||
* @data 2025/3/12 |
|||
*/ |
|||
public interface RemoteLabelPostService { |
|||
|
|||
|
|||
/** |
|||
* 根据岗位编码和部门id进行查询绑定的标签集合 |
|||
* @param postCode 岗位编码 |
|||
* @param deptId 部门id |
|||
* @return 标签集合 |
|||
* |
|||
* */ |
|||
List<RemoteAiLabelPostVo> selectLabelByList(String postCode, Long deptId); |
|||
|
|||
} |
@ -0,0 +1,56 @@ |
|||
package org.dromara.system.api.domain.vo; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
|
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
|
|||
/** |
|||
* ai 识别类型视图对象 ai_label |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
@Data |
|||
|
|||
public class RemoteAiLabelPostVo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* id |
|||
*/ |
|||
// @ExcelProperty(value = "id")
|
|||
private Long lableId; |
|||
|
|||
/** |
|||
* 标签名-英 |
|||
*/ |
|||
|
|||
private String labelEn; |
|||
|
|||
/** |
|||
* 标签名-中 |
|||
*/ |
|||
|
|||
private String labelCn; |
|||
|
|||
/** |
|||
* 算法类型 |
|||
*/ |
|||
private String aiType; |
|||
|
|||
/** |
|||
* 算法名称 |
|||
*/ |
|||
private String aiName; |
|||
|
|||
private Long postId; |
|||
private String postName; |
|||
} |
@ -0,0 +1,22 @@ |
|||
package org.dromara.workflow.api.domain; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class FlowDepartVo { |
|||
|
|||
|
|||
private Long id; |
|||
|
|||
/** |
|||
* 流程类型 |
|||
*/ |
|||
private String flowType; |
|||
|
|||
/** |
|||
* 流程编码 |
|||
*/ |
|||
private String flowCode; |
|||
|
|||
|
|||
} |
@ -0,0 +1,12 @@ |
|||
package org.dromara.workflow.api.domain; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class RemoteFlowNode { |
|||
|
|||
private Long definitionId; |
|||
|
|||
private String permission_flag; |
|||
|
|||
} |
@ -0,0 +1,74 @@ |
|||
package org.dromara.business.controller; |
|||
|
|||
import cn.hutool.core.collection.ListUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.apache.dubbo.config.annotation.DubboReference; |
|||
import org.dromara.business.domain.BusinessAlert; |
|||
import org.dromara.business.mapper.BusinessAlertMapper; |
|||
import org.dromara.business.service.IBusinessAlertService; |
|||
import org.dromara.business.utils.BatchProcessorUtil; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.utils.StringUtils; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.system.api.domain.vo.RemoteAiLabelPostVo; |
|||
import org.dromara.workflow.api.RemoteWorkflowService; |
|||
import org.dromara.workflow.api.domain.RemoteStartProcess; |
|||
import org.dromara.workflow.api.domain.RemoteStartProcessReturn; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
import java.util.concurrent.CompletableFuture; |
|||
import java.util.concurrent.ExecutorService; |
|||
import java.util.concurrent.Executors; |
|||
import java.util.concurrent.TimeUnit; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/fix") |
|||
@Tag(name = "fix") |
|||
public class FixController extends BaseController { |
|||
|
|||
@DubboReference(timeout = 30000) |
|||
RemoteWorkflowService remoteWorkflowService; |
|||
|
|||
private final BusinessAlertMapper baseMapper; |
|||
|
|||
@Operation(summary ="生成流程",description = "生成流程") |
|||
@GetMapping("startFlow") |
|||
public R<Void> startFlow(@RequestParam String flowCode) { |
|||
LambdaQueryWrapper<BusinessAlert> wrapper = new LambdaQueryWrapper<>(); |
|||
wrapper.eq(BusinessAlert::getHandleType,"verify"); |
|||
wrapper.in(BusinessAlert::getLabelEn,"plough","towns"); |
|||
List<BusinessAlert> businessAlerts = baseMapper.selectList(wrapper); |
|||
|
|||
List<BusinessAlert> alertList = ListUtil.sub(businessAlerts, 0, 10); |
|||
|
|||
List<RemoteStartProcess> flowList = alertList.stream() |
|||
.map(alert -> { |
|||
RemoteStartProcess remoteStartProcess = new RemoteStartProcess(); |
|||
remoteStartProcess.setFlowCode(flowCode); |
|||
remoteStartProcess.setBusinessId(alert.getId()); |
|||
return remoteStartProcess; |
|||
}) |
|||
.collect(Collectors.toList()); |
|||
|
|||
// 分批处理
|
|||
int startIndex = 0; // 从第 0 条开始
|
|||
int batchSize = 5; // 每批处理 5 条
|
|||
boolean flag = BatchProcessorUtil.processBatches(flowList, batchSize, startIndex, batch -> { |
|||
//批量新增部门区域数据
|
|||
remoteWorkflowService.startWorkFlowBatch(batch); |
|||
}); |
|||
|
|||
|
|||
return toAjax(flag); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,57 @@ |
|||
package org.dromara.business.domain.bo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@Schema(name = "流回调对象") |
|||
public class BusinessHookBo { |
|||
|
|||
@Schema(name = "流应用名") |
|||
private String app; |
|||
|
|||
@Schema(name = "TCP链接唯一ID") |
|||
private String id; |
|||
|
|||
@Schema(name = "播放器ip/推流器ip") |
|||
private String ip; |
|||
|
|||
@Schema(name = "播放url参数/推流url参数") |
|||
private String params; |
|||
|
|||
@Schema(name = "播放器端口号/推流器端口号") |
|||
private String port; |
|||
|
|||
@Schema(name = "播放的协议,可能是rtsp、rtmp、http") |
|||
private String schema; |
|||
|
|||
@Schema(name = "流ID") |
|||
private String stream; |
|||
|
|||
@Schema(name = "流虚拟主机") |
|||
private String vhost; |
|||
|
|||
@Schema(name = "服务器 id,通过配置文件设置") |
|||
private String mediaServerId; |
|||
|
|||
@Schema(name = "文件名") |
|||
private String file_name; |
|||
|
|||
@Schema(name = "文件绝对路径") |
|||
private String file_path; |
|||
|
|||
@Schema(name = "文件大小,单位字节") |
|||
private String file_size; |
|||
|
|||
@Schema(name = "文件所在目录路径") |
|||
private String folder; |
|||
|
|||
@Schema(name = "开始录制时间戳") |
|||
private Integer start_time; |
|||
|
|||
@Schema(name = "录制时长,单位秒") |
|||
private Float time_len; |
|||
|
|||
@Schema(name = "http/rtsp/rtmp点播相对url路径") |
|||
private String url; |
|||
} |
@ -0,0 +1,116 @@ |
|||
package org.dromara.system.controller.system; |
|||
|
|||
import java.util.List; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import jakarta.servlet.http.HttpServletResponse; |
|||
import jakarta.validation.constraints.*; |
|||
import cn.dev33.satoken.annotation.SaCheckPermission; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
|||
import org.dromara.common.log.annotation.Log; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import org.dromara.common.log.enums.BusinessType; |
|||
import org.dromara.common.excel.utils.ExcelUtil; |
|||
import org.dromara.system.domain.vo.AiLabelVo; |
|||
import org.dromara.system.domain.bo.AiLabelBo; |
|||
import org.dromara.system.service.IAiLabelService; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
|
|||
/** |
|||
* ai 识别类型 |
|||
* 前端访问路由地址为:/system/label |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
@Validated |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/label") |
|||
public class AiLabelController extends BaseController { |
|||
|
|||
private final IAiLabelService aiLabelService; |
|||
|
|||
/** |
|||
* 查询ai 识别类型列表 |
|||
*/ |
|||
@SaCheckPermission("system:label:list") |
|||
@GetMapping("/list") |
|||
public TableDataInfo<AiLabelVo> list(AiLabelBo bo, PageQuery pageQuery) { |
|||
return aiLabelService.queryPageList(bo, pageQuery); |
|||
} |
|||
|
|||
/** |
|||
* 下拉框集合 |
|||
*/ |
|||
@SaCheckPermission("system:label:list") |
|||
@GetMapping("/allList") |
|||
public List<AiLabelVo> list() { |
|||
return aiLabelService.allList(); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 导出ai 识别类型列表 |
|||
*/ |
|||
@SaCheckPermission("system:label:export") |
|||
@Log(title = "ai 识别类型", businessType = BusinessType.EXPORT) |
|||
@PostMapping("/export") |
|||
public void export(AiLabelBo bo, HttpServletResponse response) { |
|||
List<AiLabelVo> list = aiLabelService.queryList(bo); |
|||
ExcelUtil.exportExcel(list, "ai 识别类型", AiLabelVo.class, response); |
|||
} |
|||
|
|||
/** |
|||
* 获取ai 识别类型详细信息 |
|||
* |
|||
* @param lableId 主键 |
|||
*/ |
|||
@SaCheckPermission("system:label:query") |
|||
@GetMapping("/{lableId}") |
|||
public R<AiLabelVo> getInfo(@NotNull(message = "主键不能为空") |
|||
@PathVariable Long lableId) { |
|||
return R.ok(aiLabelService.queryById(lableId)); |
|||
} |
|||
|
|||
/** |
|||
* 新增ai 识别类型 |
|||
*/ |
|||
@SaCheckPermission("system:label:add") |
|||
@Log(title = "ai 识别类型", businessType = BusinessType.INSERT) |
|||
@RepeatSubmit() |
|||
@PostMapping() |
|||
public R<Void> add(@Validated(AddGroup.class) @RequestBody AiLabelBo bo) { |
|||
return toAjax(aiLabelService.insertByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 修改ai 识别类型 |
|||
*/ |
|||
@SaCheckPermission("system:label:edit") |
|||
@Log(title = "ai 识别类型", businessType = BusinessType.UPDATE) |
|||
@RepeatSubmit() |
|||
@PutMapping() |
|||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody AiLabelBo bo) { |
|||
return toAjax(aiLabelService.updateByBo(bo)); |
|||
} |
|||
|
|||
/** |
|||
* 删除ai 识别类型 |
|||
* |
|||
* @param lableIds 主键串 |
|||
*/ |
|||
@SaCheckPermission("system:label:remove") |
|||
@Log(title = "ai识别类型", businessType = BusinessType.DELETE) |
|||
@DeleteMapping("/{lableIds}") |
|||
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
|||
@PathVariable Long[] lableIds) { |
|||
return toAjax(aiLabelService.deleteWithValidByIds(List.of(lableIds), true)); |
|||
} |
|||
} |
@ -0,0 +1,51 @@ |
|||
package org.dromara.system.domain; |
|||
|
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.io.Serial; |
|||
|
|||
/** |
|||
* ai 识别类型对象 ai_label |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
@Data |
|||
|
|||
@TableName("ai_label") |
|||
public class AiLabel { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* id |
|||
*/ |
|||
@TableId(value = "label_id") |
|||
private Long labelId; |
|||
|
|||
/** |
|||
* 标签名-英 |
|||
*/ |
|||
private String labelEn; |
|||
|
|||
/** |
|||
* 标签名-中 |
|||
*/ |
|||
private String labelCn; |
|||
|
|||
/** |
|||
* 算法类型 |
|||
*/ |
|||
private String aiType; |
|||
|
|||
/** |
|||
* 算法名称 |
|||
*/ |
|||
private String aiName; |
|||
|
|||
|
|||
} |
@ -0,0 +1,37 @@ |
|||
package org.dromara.system.domain; |
|||
|
|||
|
|||
import com.baomidou.mybatisplus.annotation.*; |
|||
import lombok.Data; |
|||
|
|||
|
|||
import java.io.Serial; |
|||
|
|||
/** |
|||
* 职能-标签关系对象 ai_lable_post |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
@Data |
|||
@TableName("ai_label_post") |
|||
public class AiLabelPost { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@TableId(value = "id") |
|||
private Long id; |
|||
/** |
|||
* 标签id |
|||
*/ |
|||
private Long labelId; |
|||
|
|||
/** |
|||
* 岗位id |
|||
*/ |
|||
|
|||
private Long postId; |
|||
|
|||
|
|||
} |
@ -0,0 +1,71 @@ |
|||
package org.dromara.system.domain.bo; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import org.dromara.system.domain.AiLabel; |
|||
import org.dromara.common.mybatis.core.domain.BaseEntity; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
import jakarta.validation.constraints.*; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* ai 识别类型业务对象 ai_label |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
@Data |
|||
@AutoMapper(target = AiLabel.class, reverseConvertGenerate = false) |
|||
public class AiLabelBo { |
|||
|
|||
/** |
|||
* 搜索值 |
|||
*/ |
|||
@JsonIgnore |
|||
@TableField(exist = false) |
|||
private String searchValue; |
|||
/** |
|||
* id |
|||
*/ |
|||
@NotNull(message = "id不能为空", groups = { EditGroup.class }) |
|||
private Long labelId; |
|||
|
|||
/** |
|||
* 标签名-英 |
|||
*/ |
|||
@NotBlank(message = "标签名-英不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String labelEn; |
|||
|
|||
/** |
|||
* 标签名-中 |
|||
*/ |
|||
@NotBlank(message = "标签名-中不能为空", groups = { AddGroup.class, EditGroup.class }) |
|||
private String labelCn; |
|||
|
|||
/** |
|||
* 算法类型 |
|||
*/ |
|||
|
|||
private String aiType; |
|||
|
|||
/** |
|||
* 算法名称 |
|||
*/ |
|||
|
|||
private String aiName; |
|||
|
|||
|
|||
/** |
|||
* 请求参数 |
|||
*/ |
|||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
|||
@TableField(exist = false) |
|||
private Map<String, Object> params = new HashMap<>(); |
|||
} |
@ -0,0 +1,44 @@ |
|||
package org.dromara.system.domain.bo; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.fasterxml.jackson.annotation.JsonInclude; |
|||
import org.dromara.common.core.validate.EditGroup; |
|||
import org.dromara.system.domain.AiLabelPost; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
import jakarta.validation.constraints.*; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 职能-标签关系业务对象 ai_lable_post |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
@Data |
|||
@AutoMapper(target = AiLabelPost.class, reverseConvertGenerate = false) |
|||
public class AiLabelPostBo { |
|||
|
|||
/** |
|||
* 标签id |
|||
*/ |
|||
@NotNull(message = "标签id不能为空", groups = { AddGroup.class , EditGroup.class }) |
|||
private Long lableId; |
|||
|
|||
/** |
|||
* 岗位id |
|||
*/ |
|||
@NotNull(message = "岗位id不能为空" ) |
|||
private Long postId; |
|||
|
|||
/** |
|||
* 请求参数 |
|||
*/ |
|||
@JsonInclude(JsonInclude.Include.NON_EMPTY) |
|||
@TableField(exist = false) |
|||
private Map<String, Object> params = new HashMap<>(); |
|||
|
|||
} |
@ -0,0 +1,23 @@ |
|||
package org.dromara.system.domain.bo; |
|||
|
|||
import jakarta.validation.constraints.NotNull; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @auther yq |
|||
* @data 2025/3/11 |
|||
*/ |
|||
|
|||
@Data |
|||
public class AiLablePostBindBo { |
|||
|
|||
@NotNull(message = "postId不能为空") |
|||
private Long postId; |
|||
|
|||
|
|||
@NotNull(message = "标签不能为空") |
|||
private List<Long> lableIdList; |
|||
|
|||
} |
@ -0,0 +1,44 @@ |
|||
package org.dromara.system.domain.vo; |
|||
|
|||
import org.dromara.system.domain.AiLabelPost; |
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
|
|||
/** |
|||
* 职能-标签关系视图对象 ai_lable_post |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
@AutoMapper(target = AiLabelPost.class) |
|||
public class AiLabelPostVo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
|
|||
/** |
|||
* 标签id |
|||
*/ |
|||
private Long labelId; |
|||
|
|||
private String labelCn; |
|||
|
|||
private String labelEn; |
|||
|
|||
/** |
|||
* 岗位id |
|||
*/ |
|||
|
|||
private Long postId; |
|||
|
|||
private String postName; |
|||
|
|||
} |
@ -0,0 +1,58 @@ |
|||
package org.dromara.system.domain.vo; |
|||
|
|||
import org.dromara.system.domain.AiLabel; |
|||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import io.github.linpeilie.annotations.AutoMapper; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
|
|||
/** |
|||
* ai 识别类型视图对象 ai_label |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
@Data |
|||
@ExcelIgnoreUnannotated |
|||
@AutoMapper(target = AiLabel.class) |
|||
public class AiLabelVo implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* id |
|||
*/ |
|||
// @ExcelProperty(value = "id")
|
|||
private Long labelId; |
|||
|
|||
/** |
|||
* 标签名-英 |
|||
*/ |
|||
@ExcelProperty(value = "标签名-英") |
|||
private String labelEn; |
|||
|
|||
/** |
|||
* 标签名-中 |
|||
*/ |
|||
@ExcelProperty(value = "标签名-中") |
|||
private String labelCn; |
|||
|
|||
/** |
|||
* 算法类型 |
|||
*/ |
|||
// @ExcelProperty(value = "算法类型")
|
|||
private String aiType; |
|||
|
|||
/** |
|||
* 算法名称 |
|||
*/ |
|||
// @ExcelProperty(value = "算法名称")
|
|||
private String aiName; |
|||
|
|||
|
|||
} |
@ -0,0 +1,56 @@ |
|||
package org.dromara.system.dubbo; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import org.apache.dubbo.config.annotation.DubboService; |
|||
import org.dromara.common.core.utils.MapstructUtils; |
|||
import org.dromara.common.core.utils.StreamUtils; |
|||
import org.dromara.system.api.RemoteLabelPostService; |
|||
import org.dromara.system.api.domain.vo.RemoteAiLabelPostVo; |
|||
import org.dromara.system.domain.AiLabel; |
|||
import org.dromara.system.domain.AiLabelPost; |
|||
import org.dromara.system.domain.vo.AiLabelPostVo; |
|||
import org.dromara.system.domain.vo.SysPostVo; |
|||
import org.dromara.system.service.IAiLabelPostService; |
|||
import org.dromara.system.service.IAiLabelService; |
|||
import org.dromara.system.service.ISysPostService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @auther yq |
|||
* @data 2025/3/12 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
@DubboService |
|||
public class RemoteLabelPostServicelmpl implements RemoteLabelPostService { |
|||
|
|||
private final ISysPostService sysPostService; |
|||
private final IAiLabelPostService aiLabelPostService; |
|||
private final IAiLabelService aiLabelService; |
|||
|
|||
@Override |
|||
public List<RemoteAiLabelPostVo> selectLabelByList(String postCode, Long deptId) { |
|||
//获取岗位只能Id
|
|||
SysPostVo sysPostVo = sysPostService.selectLableByList(postCode, deptId); |
|||
if(sysPostVo != null){ |
|||
//根据岗位职能Id获取标签id
|
|||
List<AiLabelPost> aiLabelPostVos = aiLabelPostService.queryListByLabel(sysPostVo.getPostId()); |
|||
//根据标签id获取标签
|
|||
List<AiLabel> aiLabelList = aiLabelService.queryListByLabel(StreamUtils.toList(aiLabelPostVos,AiLabelPost::getLabelId)); |
|||
return aiLabelList.stream() |
|||
.map(aiLabel -> { |
|||
RemoteAiLabelPostVo remoteAiLabelPostVo = new RemoteAiLabelPostVo(); |
|||
remoteAiLabelPostVo.setLableId(aiLabel.getLabelId()); |
|||
remoteAiLabelPostVo.setLabelEn(aiLabel.getLabelEn()); |
|||
remoteAiLabelPostVo.setLabelCn(aiLabel.getLabelCn()); |
|||
return remoteAiLabelPostVo; |
|||
}) |
|||
.collect(Collectors.toList()); |
|||
} |
|||
return new ArrayList<>(); |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
package org.dromara.system.mapper; |
|||
|
|||
import org.dromara.system.domain.AiLabel; |
|||
import org.dromara.system.domain.vo.AiLabelVo; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
|
|||
/** |
|||
* ai 识别类型Mapper接口 |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
public interface AiLabelMapper extends BaseMapperPlus<AiLabel, AiLabelVo> { |
|||
|
|||
} |
@ -0,0 +1,18 @@ |
|||
package org.dromara.system.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.dromara.system.domain.AiLabelPost; |
|||
import org.dromara.system.domain.vo.AiLabelPostVo; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
|
|||
/** |
|||
* 职能-标签关系Mapper接口 |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
public interface AiLabelPostMapper extends BaseMapperPlus<AiLabelPost, AiLabelPostVo> { |
|||
Page<AiLabelPostVo> selectAiLabelPostPage(@Param("page") Page<?> page, @Param("ew") QueryWrapper<AiLabelPost> wrapper); |
|||
} |
@ -0,0 +1,71 @@ |
|||
package org.dromara.system.service; |
|||
|
|||
import org.dromara.system.domain.AiLabelPost; |
|||
import org.dromara.system.domain.bo.AiLabelPostBo; |
|||
import org.dromara.system.domain.vo.AiLabelPostVo; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 职能-标签关系Service接口 |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
public interface IAiLabelPostService { |
|||
|
|||
/** |
|||
* 查询职能-标签关系 |
|||
* |
|||
* @param labelId 主键 |
|||
* @return 职能-标签关系 |
|||
*/ |
|||
AiLabelPostVo queryById(Long labelId); |
|||
|
|||
/** |
|||
* 分页查询职能-标签关系列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 职能-标签关系分页列表 |
|||
*/ |
|||
TableDataInfo<AiLabelPostVo> queryPageList(AiLabelPostBo bo, PageQuery pageQuery); |
|||
|
|||
/** |
|||
* 查询符合条件的职能-标签关系列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 职能-标签关系列表 |
|||
*/ |
|||
List<AiLabelPostVo> queryList(AiLabelPostBo bo); |
|||
|
|||
/** |
|||
* 新增职能-标签关系 |
|||
* |
|||
* @param bo 职能-标签关系 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
Boolean insertByBo(AiLabelPostBo bo); |
|||
|
|||
/** |
|||
* 修改职能-标签关系 |
|||
* |
|||
* @param bo 职能-标签关系 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
Boolean updateByBo(AiLabelPostBo bo); |
|||
|
|||
/** |
|||
* 校验并批量删除职能-标签关系信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
|||
|
|||
List<AiLabelPost> queryListByLabel(Long postId); |
|||
} |
@ -0,0 +1,75 @@ |
|||
package org.dromara.system.service; |
|||
|
|||
import org.dromara.system.domain.AiLabel; |
|||
import org.dromara.system.domain.vo.AiLabelVo; |
|||
import org.dromara.system.domain.bo.AiLabelBo; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* ai 识别类型Service接口 |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
public interface IAiLabelService { |
|||
|
|||
/** |
|||
* 查询ai 识别类型 |
|||
* |
|||
* @param labelId 主键 |
|||
* @return ai 识别类型 |
|||
*/ |
|||
AiLabelVo queryById(Long labelId); |
|||
|
|||
List<AiLabelVo> allList(); |
|||
|
|||
|
|||
|
|||
/** |
|||
* 分页查询ai 识别类型列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return ai 识别类型分页列表 |
|||
*/ |
|||
TableDataInfo<AiLabelVo> queryPageList(AiLabelBo bo, PageQuery pageQuery); |
|||
|
|||
/** |
|||
* 查询符合条件的ai 识别类型列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return ai 识别类型列表 |
|||
*/ |
|||
List<AiLabelVo> queryList(AiLabelBo bo); |
|||
|
|||
/** |
|||
* 新增ai 识别类型 |
|||
* |
|||
* @param bo ai 识别类型 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
Boolean insertByBo(AiLabelBo bo); |
|||
|
|||
/** |
|||
* 修改ai 识别类型 |
|||
* |
|||
* @param bo ai 识别类型 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
Boolean updateByBo(AiLabelBo bo); |
|||
|
|||
/** |
|||
* 校验并批量删除ai 识别类型信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
|||
|
|||
List<AiLabel> queryListByLabel(List<Long> labelIds); |
|||
} |
@ -0,0 +1,145 @@ |
|||
package org.dromara.system.service.impl; |
|||
|
|||
import org.dromara.common.core.utils.MapstructUtils; |
|||
import org.dromara.common.core.utils.StringUtils; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
import org.dromara.system.domain.bo.AiLabelBo; |
|||
import org.dromara.system.domain.vo.AiLabelVo; |
|||
import org.dromara.system.domain.AiLabel; |
|||
import org.dromara.system.mapper.AiLabelMapper; |
|||
import org.dromara.system.service.IAiLabelService; |
|||
|
|||
import java.util.Comparator; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Collection; |
|||
|
|||
/** |
|||
* ai 识别类型Service业务层处理 |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class AiLabelServiceImpl implements IAiLabelService { |
|||
|
|||
private final AiLabelMapper baseMapper; |
|||
|
|||
/** |
|||
* 查询ai 识别类型 |
|||
* |
|||
* @param labelId 主键 |
|||
* @return ai 识别类型 |
|||
*/ |
|||
@Override |
|||
public AiLabelVo queryById(Long labelId){ |
|||
return baseMapper.selectVoById(labelId); |
|||
} |
|||
|
|||
@Override |
|||
public List<AiLabelVo> allList() { |
|||
return baseMapper.selectVoList().stream().sorted(Comparator.comparing(AiLabelVo::getLabelId)).toList(); |
|||
} |
|||
|
|||
/** |
|||
* 分页查询ai 识别类型列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return ai 识别类型分页列表 |
|||
*/ |
|||
@Override |
|||
public TableDataInfo<AiLabelVo> queryPageList(AiLabelBo bo, PageQuery pageQuery) { |
|||
LambdaQueryWrapper<AiLabel> lqw = buildQueryWrapper(bo); |
|||
Page<AiLabelVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|||
return TableDataInfo.build(result); |
|||
} |
|||
|
|||
/** |
|||
* 查询符合条件的ai 识别类型列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return ai 识别类型列表 |
|||
*/ |
|||
@Override |
|||
public List<AiLabelVo> queryList(AiLabelBo bo) { |
|||
LambdaQueryWrapper<AiLabel> lqw = buildQueryWrapper(bo); |
|||
return baseMapper.selectVoList(lqw); |
|||
} |
|||
|
|||
private LambdaQueryWrapper<AiLabel> buildQueryWrapper(AiLabelBo bo) { |
|||
Map<String, Object> params = bo.getParams(); |
|||
LambdaQueryWrapper<AiLabel> lqw = Wrappers.lambdaQuery(); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getLabelEn()), AiLabel::getLabelEn, bo.getLabelEn()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getLabelCn()), AiLabel::getLabelCn, bo.getLabelCn()); |
|||
lqw.eq(StringUtils.isNotBlank(bo.getAiType()), AiLabel::getAiType, bo.getAiType()); |
|||
lqw.like(StringUtils.isNotBlank(bo.getAiName()), AiLabel::getAiName, bo.getAiName()); |
|||
return lqw; |
|||
} |
|||
|
|||
/** |
|||
* 新增ai 识别类型 |
|||
* |
|||
* @param bo ai 识别类型 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
@Override |
|||
public Boolean insertByBo(AiLabelBo bo) { |
|||
AiLabel add = MapstructUtils.convert(bo, AiLabel.class); |
|||
validEntityBeforeSave(add); |
|||
boolean flag = baseMapper.insert(add) > 0; |
|||
if (flag) { |
|||
bo.setLabelId(add.getLabelId()); |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 修改ai 识别类型 |
|||
* |
|||
* @param bo ai 识别类型 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
@Override |
|||
public Boolean updateByBo(AiLabelBo bo) { |
|||
AiLabel update = MapstructUtils.convert(bo, AiLabel.class); |
|||
validEntityBeforeSave(update); |
|||
return baseMapper.updateById(update) > 0; |
|||
} |
|||
|
|||
/** |
|||
* 保存前的数据校验 |
|||
*/ |
|||
private void validEntityBeforeSave(AiLabel entity){ |
|||
//TODO 做一些数据校验,如唯一约束
|
|||
} |
|||
|
|||
/** |
|||
* 校验并批量删除ai 识别类型信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
@Override |
|||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
|||
if(isValid){ |
|||
//TODO 做一些业务上的校验,判断是否需要校验
|
|||
} |
|||
return baseMapper.deleteByIds(ids) > 0; |
|||
} |
|||
|
|||
@Override |
|||
public List<AiLabel> queryListByLabel(List<Long> labelIds) { |
|||
LambdaQueryWrapper<AiLabel> wrapper = new LambdaQueryWrapper<>(); |
|||
wrapper.in(AiLabel::getLabelId, labelIds); |
|||
return this.baseMapper.selectList(wrapper); |
|||
} |
|||
} |
@ -0,0 +1,140 @@ |
|||
package org.dromara.system.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import org.dromara.common.core.utils.MapstructUtils; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.dromara.system.domain.AiLabelPost; |
|||
import org.dromara.system.domain.vo.AiLabelPostVo; |
|||
import org.dromara.system.mapper.AiLabelMapper; |
|||
import org.springframework.stereotype.Service; |
|||
import org.dromara.system.domain.bo.AiLabelPostBo; |
|||
import org.dromara.system.mapper.AiLabelPostMapper; |
|||
import org.dromara.system.service.IAiLabelPostService; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Collection; |
|||
|
|||
/** |
|||
* 职能-标签关系Service业务层处理 |
|||
* |
|||
* @author LionLi |
|||
* @date 2025-03-11 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Service |
|||
public class AiLablePostServiceImpl implements IAiLabelPostService { |
|||
|
|||
private final AiLabelPostMapper baseMapper; |
|||
private final AiLabelMapper aiLabelMapper; |
|||
|
|||
/** |
|||
* 查询职能-标签关系 |
|||
* |
|||
* @param lableId 主键 |
|||
* @return 职能-标签关系 |
|||
*/ |
|||
@Override |
|||
public AiLabelPostVo queryById(Long lableId){ |
|||
return baseMapper.selectVoById(lableId); |
|||
} |
|||
|
|||
/** |
|||
* 分页查询职能-标签关系列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 职能-标签关系分页列表 |
|||
*/ |
|||
@Override |
|||
public TableDataInfo<AiLabelPostVo> queryPageList(AiLabelPostBo bo, PageQuery pageQuery) { |
|||
QueryWrapper queryWrapper = new QueryWrapper(); |
|||
queryWrapper.eq("a.post_id", bo.getPostId()); |
|||
Page<AiLabelPostVo> result = baseMapper.selectAiLabelPostPage(pageQuery.build(), queryWrapper); |
|||
return TableDataInfo.build(result); |
|||
} |
|||
|
|||
/** |
|||
* 查询符合条件的职能-标签关系列表 |
|||
* |
|||
* @param bo 查询条件 |
|||
* @return 职能-标签关系列表 |
|||
*/ |
|||
@Override |
|||
public List<AiLabelPostVo> queryList(AiLabelPostBo bo) { |
|||
LambdaQueryWrapper<AiLabelPost> lqw = buildQueryWrapper(bo); |
|||
return baseMapper.selectVoList(lqw); |
|||
} |
|||
|
|||
private LambdaQueryWrapper<AiLabelPost> buildQueryWrapper(AiLabelPostBo bo) { |
|||
Map<String, Object> params = bo.getParams(); |
|||
LambdaQueryWrapper<AiLabelPost> lqw = Wrappers.lambdaQuery(); |
|||
return lqw; |
|||
} |
|||
|
|||
/** |
|||
* 新增职能-标签关系 |
|||
* |
|||
* @param bo 职能-标签关系 |
|||
* @return 是否新增成功 |
|||
*/ |
|||
@Override |
|||
public Boolean insertByBo(AiLabelPostBo bo) { |
|||
AiLabelPost add = MapstructUtils.convert(bo, AiLabelPost.class); |
|||
validEntityBeforeSave(add); |
|||
boolean flag = baseMapper.insert(add) > 0; |
|||
if (flag) { |
|||
bo.setLableId(add.getLabelId()); |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* 修改职能-标签关系 |
|||
* |
|||
* @param bo 职能-标签关系 |
|||
* @return 是否修改成功 |
|||
*/ |
|||
@Override |
|||
public Boolean updateByBo(AiLabelPostBo bo) { |
|||
AiLabelPost update = MapstructUtils.convert(bo, AiLabelPost.class); |
|||
validEntityBeforeSave(update); |
|||
return baseMapper.updateById(update) > 0; |
|||
} |
|||
|
|||
/** |
|||
* 保存前的数据校验 |
|||
*/ |
|||
private void validEntityBeforeSave(AiLabelPost entity){ |
|||
//TODO 做一些数据校验,如唯一约束
|
|||
} |
|||
|
|||
/** |
|||
* 校验并批量删除职能-标签关系信息 |
|||
* |
|||
* @param ids 待删除的主键集合 |
|||
* @param isValid 是否进行有效性校验 |
|||
* @return 是否删除成功 |
|||
*/ |
|||
@Override |
|||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
|||
if(isValid){ |
|||
//TODO 做一些业务上的校验,判断是否需要校验
|
|||
} |
|||
return baseMapper.deleteByIds(ids) > 0; |
|||
} |
|||
|
|||
@Override |
|||
public List<AiLabelPost> queryListByLabel(Long postId) { |
|||
LambdaQueryWrapper<AiLabelPost> wrapper = new LambdaQueryWrapper<>(); |
|||
|
|||
wrapper.eq(AiLabelPost::getPostId, postId); |
|||
|
|||
return this.baseMapper.selectList(wrapper); |
|||
} |
|||
} |
@ -0,0 +1,7 @@ |
|||
<?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="org.dromara.system.mapper.AiLabelMapper"> |
|||
|
|||
</mapper> |
@ -0,0 +1,10 @@ |
|||
<?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="org.dromara.system.mapper.AiLabelPostMapper"> |
|||
|
|||
<select id="selectAiLabelPostPage" resultType="org.dromara.system.domain.vo.AiLabelPostVo"> |
|||
SELECT *,a.label_cn as ,label_en FROM ai_lable_post p inner JOIN ai_label a ON p.label_id = a.label_id ${ew.customSqlSegment} |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,46 @@ |
|||
package org.dromara.workflow.controller; |
|||
|
|||
|
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.workflow.common.ConditionalOnEnable; |
|||
import org.dromara.workflow.domain.FlowDepart; |
|||
import org.dromara.workflow.service.FlwDepartService; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
@Tag(name = "流程部门管理") |
|||
@ConditionalOnEnable |
|||
@Validated |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@RequestMapping("/depart") |
|||
public class FlwDepartController { |
|||
|
|||
|
|||
private final FlwDepartService flwDepartService; |
|||
|
|||
/** |
|||
* 查询流程部门关系 |
|||
* flowCode |
|||
*/ |
|||
@Operation(summary = "查询流程部门关系",description = "查询流程部门关系") |
|||
@GetMapping("/{flowCode}/getInfo") |
|||
public R<FlowDepart> getInfo(@PathVariable String flowCode) { |
|||
return R.ok(flwDepartService.getInfo(flowCode)); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 绑定流程部门关系 |
|||
* flowCode |
|||
*/ |
|||
@Operation(summary = "绑定流程部门关系",description = "绑定流程部门关系") |
|||
@PostMapping("/bind/depart") |
|||
public R<FlowDepart> bindDepart(@Validated({AddGroup.class}) @RequestBody FlowDepart flowDepart) { |
|||
return R.ok(flwDepartService.bindDepart(flowDepart)); |
|||
} |
|||
} |
@ -0,0 +1,48 @@ |
|||
package org.dromara.workflow.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import jakarta.validation.constraints.NotNull; |
|||
import lombok.Data; |
|||
import org.dromara.common.core.validate.AddGroup; |
|||
import org.dromara.workflow.handler.ListTypeHandler; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 部门流程关系表 |
|||
*/ |
|||
@Data |
|||
@TableName(value = "flow_depart",autoResultMap = true) |
|||
public class FlowDepart { |
|||
|
|||
|
|||
@TableId(type = IdType.ASSIGN_ID) |
|||
private Long id; |
|||
|
|||
/** |
|||
* 流程类型 |
|||
*/ |
|||
@NotNull(message = "流程类型不能为空", groups = AddGroup.class) |
|||
private String flowType; |
|||
|
|||
/** |
|||
* 流程编码 |
|||
*/ |
|||
@NotNull(message = "流程编码不能为空", groups = AddGroup.class) |
|||
private String flowCode; |
|||
|
|||
/** |
|||
* 租户编号 |
|||
*/ |
|||
private String tenantId; |
|||
|
|||
/** |
|||
* 部门id集合 |
|||
*/ |
|||
@NotNull(message = "部门id不能为空", groups = AddGroup.class) |
|||
@TableField(value = "dept_ids",typeHandler = ListTypeHandler.class) |
|||
List<Long> departIds; |
|||
} |
@ -0,0 +1,51 @@ |
|||
package org.dromara.workflow.handler; |
|||
|
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.apache.ibatis.type.JdbcType; |
|||
import org.apache.ibatis.type.MappedJdbcTypes; |
|||
import org.apache.ibatis.type.MappedTypes; |
|||
import org.apache.ibatis.type.TypeHandler; |
|||
import org.dromara.workflow.utils.JsonUtil; |
|||
|
|||
import java.sql.CallableStatement; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.ResultSet; |
|||
import java.sql.SQLException; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@MappedJdbcTypes(JdbcType.VARCHAR) |
|||
@MappedTypes({List.class}) |
|||
public class ListTypeHandler implements TypeHandler<List<Long>> { |
|||
|
|||
@Override |
|||
public void setParameter(PreparedStatement ps, int i, List<Long> list, JdbcType jdbcType) throws SQLException { |
|||
ps.setString(i, JsonUtil.toJson(list)); |
|||
} |
|||
|
|||
@Override |
|||
public List<Long> getResult(ResultSet rs, String columnName) throws SQLException { |
|||
if (StringUtils.isBlank(rs.getString(columnName))) { |
|||
return new ArrayList<>(); |
|||
} |
|||
return JsonUtil.jsonToList(rs.getString(columnName), Long.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<Long> getResult(ResultSet rs, int columnIndex) throws SQLException { |
|||
if (StringUtils.isBlank(rs.getString(columnIndex))) { |
|||
return new ArrayList<>(); |
|||
} |
|||
return JsonUtil.jsonToList(rs.getString(columnIndex), Long.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<Long> getResult(CallableStatement cs, int columnIndex) throws SQLException { |
|||
String value = cs.getString(columnIndex); |
|||
|
|||
if (StringUtils.isBlank(value)) { |
|||
return new ArrayList<>(); |
|||
} |
|||
return JsonUtil.jsonToList(value, Long.class); |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
package org.dromara.workflow.mapper; |
|||
|
|||
import jakarta.validation.constraints.NotNull; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|||
import org.dromara.workflow.domain.FlowDepart; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface FlwDepartMapper extends BaseMapperPlus<FlowDepart, FlowDepart> { |
|||
FlowDepart getFlowDepart(@Param("deptId") Long deptId); |
|||
|
|||
Integer checkFlowDepart(@Param("deptIds") List<Long> departIds); |
|||
} |
@ -0,0 +1,11 @@ |
|||
package org.dromara.workflow.service; |
|||
|
|||
import org.dromara.workflow.domain.FlowDepart; |
|||
|
|||
public interface FlwDepartService { |
|||
FlowDepart getInfo(String flowCode); |
|||
|
|||
FlowDepart bindDepart(FlowDepart flowDepart); |
|||
|
|||
FlowDepart getFlowDepart(Long deptId); |
|||
} |
@ -0,0 +1,49 @@ |
|||
package org.dromara.workflow.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.dromara.common.core.exception.ServiceException; |
|||
import org.dromara.workflow.domain.FlowDepart; |
|||
import org.dromara.workflow.mapper.FlwDepartMapper; |
|||
import org.dromara.workflow.service.FlwDepartService; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class FlwDepartServiceImpl extends ServiceImpl<FlwDepartMapper, FlowDepart> implements FlwDepartService { |
|||
|
|||
|
|||
@Override |
|||
public FlowDepart getInfo(String flowCode) { |
|||
LambdaQueryWrapper<FlowDepart> wrapper = new LambdaQueryWrapper<>(); |
|||
wrapper.eq(FlowDepart::getFlowCode, flowCode); |
|||
|
|||
return this.baseMapper.selectOne(wrapper); |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public FlowDepart bindDepart(FlowDepart flowDepart) { |
|||
LambdaQueryWrapper<FlowDepart> updateWrapper = new LambdaQueryWrapper<>(); |
|||
updateWrapper.eq(FlowDepart::getFlowCode, flowDepart.getFlowCode()); |
|||
this.baseMapper.delete(updateWrapper); |
|||
|
|||
//查询部门是否还存在别的流程
|
|||
if (this.baseMapper.checkFlowDepart(flowDepart.getDepartIds()) > 0){ |
|||
throw new ServiceException("所选的部门中,已存在在其他流程中,请检查后在提交!"); |
|||
} |
|||
|
|||
this.baseMapper.insert(flowDepart); |
|||
|
|||
return flowDepart; |
|||
} |
|||
|
|||
@Override |
|||
public FlowDepart getFlowDepart(Long deptId) { |
|||
return this.baseMapper.getFlowDepart(deptId); |
|||
} |
|||
} |
@ -0,0 +1,39 @@ |
|||
package org.dromara.workflow.utils; |
|||
|
|||
import java.util.List; |
|||
import java.util.function.Consumer; |
|||
|
|||
/** |
|||
* 分批处理工具类 |
|||
*/ |
|||
public class BatchProcessorUtil { |
|||
|
|||
/** |
|||
* 分批处理数据 |
|||
* |
|||
* @param dataList 数据集合 |
|||
* @param batchSize 每批处理的数据量 |
|||
* @param startIndex 起始位置 |
|||
* @param batchHandler 每批数据的处理逻辑 |
|||
* @return 下一次的起始位置 |
|||
*/ |
|||
public static <T> boolean processBatches(List<T> dataList, int batchSize, int startIndex, Consumer<List<T>> batchHandler) { |
|||
if (dataList == null || dataList.isEmpty()) { |
|||
return true; // 数据为空,直接返回当前起始位置
|
|||
} |
|||
|
|||
int totalSize = dataList.size(); |
|||
while (startIndex < totalSize) { |
|||
int endIndex = Math.min(startIndex + batchSize, totalSize); |
|||
List<T> batch = dataList.subList(startIndex, endIndex); |
|||
|
|||
// 处理当前批次的数据
|
|||
batchHandler.accept(batch); |
|||
|
|||
// 更新起始位置
|
|||
startIndex = endIndex; |
|||
} |
|||
|
|||
return startIndex >= totalSize; // 返回下一次的起始位置
|
|||
} |
|||
} |
@ -0,0 +1,126 @@ |
|||
package org.dromara.workflow.utils; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.core.type.TypeReference; |
|||
import com.fasterxml.jackson.databind.JavaType; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
import java.lang.reflect.Field; |
|||
import java.util.HashMap; |
|||
import java.util.LinkedHashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 定义响应结构 |
|||
*/ |
|||
public class JsonUtil { |
|||
|
|||
private static ObjectMapper MAPPER; |
|||
static{ |
|||
MAPPER=new ObjectMapper(); |
|||
} |
|||
|
|||
/** |
|||
* 将对象转换成json字符串。 |
|||
* @param data |
|||
* @return |
|||
*/ |
|||
public static String toJson(Object data){ |
|||
String string = null; |
|||
try { |
|||
string = MAPPER.writeValueAsString(data); |
|||
if(StringUtils.isEmpty(string)){ |
|||
return null; |
|||
} |
|||
return string; |
|||
} catch (JsonProcessingException e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 将json结果集转化为对象 |
|||
* |
|||
* @param jsonData json数据 |
|||
* @return |
|||
*/ |
|||
public static <T> T jsonToPojo(String jsonData, Class<T> beanType) { |
|||
try { |
|||
T t = MAPPER.readValue(jsonData, beanType); |
|||
return t; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 将json数据转换成pojo对象list |
|||
* <p>Title: jsonToList</p> |
|||
* <p>Description: </p> |
|||
* @param jsonData |
|||
* @param beanType |
|||
* @return |
|||
*/ |
|||
public static <T>List<T> jsonToList(String jsonData, Class<T> beanType) { |
|||
JavaType javaType = MAPPER.getTypeFactory().constructParametricType(List.class, beanType); |
|||
try { |
|||
List<T> list = MAPPER.readValue(jsonData, javaType); |
|||
return list; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 将Object对象里面的属性和值转化成Map对象 |
|||
* |
|||
* @param obj |
|||
* @return |
|||
* @throws IllegalAccessException |
|||
*/ |
|||
public static Map<String, Object> objectToMap(Object obj){ |
|||
try { |
|||
Map<String, Object> map = new HashMap<String,Object>(); |
|||
Class<?> clazz = obj.getClass(); |
|||
for (Field field : clazz.getDeclaredFields()) { |
|||
field.setAccessible(true); |
|||
String fieldName = field.getName(); |
|||
if(ObjectUtil.isNotEmpty(field.get(obj))){ |
|||
Object value = field.get(obj); |
|||
map.put(fieldName, value); |
|||
}else{ |
|||
map.put(fieldName, ""); |
|||
} |
|||
} |
|||
return map; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public static Map<String, Object> jsonToMap(String json){ |
|||
try { |
|||
return MAPPER.readValue(json, new TypeReference<Map<String, Object>>(){}); |
|||
} catch (JsonProcessingException e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public static LinkedHashMap<String, String> jsonToStrMap(String json){ |
|||
try { |
|||
return MAPPER.readValue(json, new TypeReference<LinkedHashMap<String, String>>(){}); |
|||
} catch (JsonProcessingException e) { |
|||
e.printStackTrace(); |
|||
return null; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,22 @@ |
|||
<?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="org.dromara.workflow.mapper.FlwDepartMapper"> |
|||
|
|||
<select id="getFlowDepart" resultType="org.dromara.workflow.domain.FlowDepart"> |
|||
select fd.* from flow_depart fd where JSON_CONTAINS(fd.dept_ids, #{deptId}) |
|||
</select> |
|||
|
|||
<select id="checkFlowDepart" resultType="java.lang.Integer"> |
|||
SELECT |
|||
count(1) |
|||
FROM flow_depart fd |
|||
where |
|||
<foreach collection="deptIds" item="item" open="(" separator=" OR " close=")"> |
|||
JSON_CONTAINS(fd.dept_ids, CONCAT('"', #{item}, '"')) |
|||
</foreach> |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
Loading…
Reference in new issue