29 changed files with 1372 additions and 523 deletions
@ -0,0 +1,217 @@ |
|||||
|
package org.dromara.productManagement.common.service; |
||||
|
|
||||
|
import cn.dev33.satoken.stp.StpUtil; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
|
import lombok.Data; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.dromara.common.core.service.DictService; |
||||
|
import org.dromara.common.satoken.utils.LoginHelper; |
||||
|
import org.dromara.productManagement.domain.ModelPrompts; |
||||
|
import org.dromara.productManagement.domain.ModelUserPromptssetting; |
||||
|
import org.dromara.productManagement.domain.bo.BaseTaskBo; |
||||
|
import org.dromara.productManagement.domain.vo.DocumentTasksPermissionsVo; |
||||
|
import org.dromara.productManagement.mapper.DocumentTasksPermissionsMapper; |
||||
|
import org.dromara.productManagement.mapper.ModelPromptsMapper; |
||||
|
import org.dromara.productManagement.mapper.ModelUserPromptssettingMapper; |
||||
|
import org.dromara.productManagement.service.IDocumentTasksPermissionsService; |
||||
|
import org.dromara.productManagement.utils.MyHttpUtils; |
||||
|
import org.dromara.system.domain.vo.SysOssVo; |
||||
|
import org.dromara.system.service.ISysOssService; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.io.File; |
||||
|
import java.io.IOException; |
||||
|
import java.io.InputStream; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 任务处理器抽象基类 |
||||
|
|
||||
|
* |
||||
|
* @param <T> 任务数据类型 |
||||
|
* @param <E> 任务实体类型 |
||||
|
*/ |
||||
|
@Data |
||||
|
@RequiredArgsConstructor |
||||
|
public abstract class AbstractTaskProcessor<T extends BaseTaskBo, E> implements TaskProcessor<T, E> { |
||||
|
protected final ISysOssService ossService; |
||||
|
protected final ModelPromptsMapper modelPromptsMapper; |
||||
|
|
||||
|
protected final ModelUserPromptssettingMapper modelUserPromptssettingMapper; |
||||
|
protected final DocumentTasksPermissionsMapper documentTasksPermissionsMapper; |
||||
|
protected final IDocumentTasksPermissionsService documentTasksPermissionsService; |
||||
|
protected final DictService dictTypeService; |
||||
|
|
||||
|
@Value("${chat.filePath}") |
||||
|
protected String fileRootPath; |
||||
|
|
||||
|
@Value("${chat.chatUrl}") |
||||
|
protected String chatUrl; |
||||
|
|
||||
|
@Value("${chat.tempfilePath}") |
||||
|
protected String tempfilePath; |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public Boolean processTask(T taskData, String taskType) throws IOException, InterruptedException { |
||||
|
List<String> taskNames = taskData.getTaskNameList(); |
||||
|
Long userId = LoginHelper.getUserId(); |
||||
|
|
||||
|
// 校验提示词
|
||||
|
validatePrompts(taskNames, taskData, taskType); |
||||
|
|
||||
|
// 处理用户提示词设置
|
||||
|
handleUserPromptsSetting(userId, taskData, taskType); |
||||
|
|
||||
|
// 验证用户任务权限
|
||||
|
documentTasksPermissionsService.validateUserTaskPermissions(taskType, taskNames, userId); |
||||
|
|
||||
|
// 处理文件相关操作
|
||||
|
FileProcessResult fileResult = processFile(taskData.getOssId()); |
||||
|
|
||||
|
return processTaskItems(taskNames, taskData, fileResult, taskType); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void validatePrompts(List<String> taskNames, T taskData, String taskType) { |
||||
|
taskNames.forEach(taskName -> { |
||||
|
ModelPrompts modelPrompts = modelPromptsMapper.selectOne(Wrappers.<ModelPrompts>lambdaQuery() |
||||
|
.eq(ModelPrompts::getTaskType, taskType) |
||||
|
.eq(ModelPrompts::getTaskName, taskName) |
||||
|
.eq(ModelPrompts::getTaskIndustry, taskData.getTaskIndustry()) |
||||
|
.eq(ModelPrompts::getTaskRegion, taskData.getTaskRegion())); |
||||
|
if(modelPrompts == null) { |
||||
|
String label = dictTypeService.getDictLabel(taskType, taskName); |
||||
|
throw new RuntimeException("任务名称:["+label+"],当前任务所属区域或所属行业不存在模型,请联系管理员配置"); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void handleUserPromptsSetting(Long userId, T taskData, String taskType) { |
||||
|
ModelUserPromptssetting promptssetting = modelUserPromptssettingMapper.selectOne( |
||||
|
Wrappers.<ModelUserPromptssetting>lambdaQuery() |
||||
|
.eq(ModelUserPromptssetting::getUserId, userId) |
||||
|
.eq(ModelUserPromptssetting::getTaskType, taskType)); |
||||
|
|
||||
|
if(promptssetting != null) { |
||||
|
promptssetting.setTaskIndustry(taskData.getTaskIndustry()); |
||||
|
promptssetting.setTaskRegion(taskData.getTaskRegion()); |
||||
|
promptssetting.setTaskType(taskType); |
||||
|
modelUserPromptssettingMapper.updateById(promptssetting); |
||||
|
} else { |
||||
|
ModelUserPromptssetting userPromptssetting = new ModelUserPromptssetting(); |
||||
|
userPromptssetting.setUserId(userId); |
||||
|
userPromptssetting.setTaskIndustry(taskData.getTaskIndustry()); |
||||
|
userPromptssetting.setTaskRegion(taskData.getTaskRegion()); |
||||
|
userPromptssetting.setTaskType(taskType); |
||||
|
modelUserPromptssettingMapper.insert(userPromptssetting); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public FileProcessResult processFile(Long ossId) throws IOException, InterruptedException { |
||||
|
SysOssVo fileInfo = ossService.getById(ossId); |
||||
|
String fileName = fileInfo.getOriginalName(); |
||||
|
String filePath = fileRootPath + fileInfo.getFileName(); |
||||
|
|
||||
|
// 处理文件转换
|
||||
|
if(!fileName.toLowerCase().endsWith(".docx")) { |
||||
|
filePath = convertToDocx(filePath, fileName); |
||||
|
} |
||||
|
|
||||
|
return new FileProcessResult(fileInfo.getOriginalName(), filePath); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 转换文件为docx格式 |
||||
|
*/ |
||||
|
private String convertToDocx(String filePath, String fileName) throws IOException, InterruptedException { |
||||
|
String parentPath = new File(filePath).getParent(); |
||||
|
ProcessBuilder builder = new ProcessBuilder("libreoffice", "--headless", "--convert-to", "docx", filePath, "--outdir", parentPath); |
||||
|
Process process = builder.start(); |
||||
|
|
||||
|
int completed = process.waitFor(); |
||||
|
if (completed != 0) { |
||||
|
InputStream errorStream = process.getErrorStream(); |
||||
|
String errorMessage = new String(errorStream.readAllBytes()); |
||||
|
process.destroyForcibly(); |
||||
|
throw new RuntimeException(fileName + "转docx失败,请检查文件是否正确~ 错误信息: " + errorMessage); |
||||
|
} |
||||
|
|
||||
|
process.destroyForcibly(); |
||||
|
return getDocxFilePath(filePath); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取转换后的docx文件路径 |
||||
|
*/ |
||||
|
private String getDocxFilePath(String filePath) { |
||||
|
int lastDotIndex = filePath.lastIndexOf('.'); |
||||
|
return lastDotIndex == -1 ? filePath + ".docx" : filePath.substring(0, lastDotIndex) + ".docx"; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Long calculatePriority(String taskName) { |
||||
|
// 默认优先级为1
|
||||
|
Long priority = 1L; |
||||
|
|
||||
|
// 如果不是超级管理员,则获取用户特定的任务优先级
|
||||
|
if (!StpUtil.hasRole("superadmin")) { |
||||
|
DocumentTasksPermissionsVo permissionsVo = documentTasksPermissionsMapper |
||||
|
.selectDocumentPermissionsByUserIdAndTaskName( |
||||
|
LoginHelper.getUserId(), |
||||
|
taskName |
||||
|
); |
||||
|
if (permissionsVo != null) { |
||||
|
priority = permissionsVo.getPriority(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return priority; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 处理具体任务项 |
||||
|
*/ |
||||
|
protected Boolean processTaskItems(List<String> taskNames, T taskData, FileProcessResult fileResult, String taskType) { |
||||
|
boolean flag = false; |
||||
|
for (String taskName : taskNames) { |
||||
|
// 转换为对应的任务实体
|
||||
|
E taskEntity = convertToTaskEntity(taskData, taskName, fileResult.getFileName(), taskType); |
||||
|
|
||||
|
// 在插入数据库前调用扩展点
|
||||
|
beforeTaskInsert(taskData, taskName, fileResult); |
||||
|
|
||||
|
// 保存实体到数据库
|
||||
|
flag = saveTaskEntity(taskEntity); |
||||
|
|
||||
|
if (!flag) { |
||||
|
throw new RuntimeException("新增任务失败"); |
||||
|
} |
||||
|
|
||||
|
// 获取任务ID
|
||||
|
Long taskId = getTaskId(taskEntity); |
||||
|
|
||||
|
// 在发送消息前调用扩展点
|
||||
|
beforeTaskMessageSent(taskId, taskName, taskData); |
||||
|
|
||||
|
// 计算优先级并发送消息
|
||||
|
Long priority = calculatePriority(taskName); |
||||
|
MyHttpUtils.sendTaskStartMessage(chatUrl + "/back/taskStart", |
||||
|
taskId, taskName, fileResult.getFilePath(), priority); |
||||
|
} |
||||
|
return flag; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void beforeTaskInsert(T taskData, String taskName, FileProcessResult fileResult) { |
||||
|
// 默认空实现,子类可以覆盖
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void beforeTaskMessageSent(Long taskId, String taskName, T taskData) { |
||||
|
// 默认空实现,子类可以覆盖
|
||||
|
} |
||||
|
} |
@ -0,0 +1,114 @@ |
|||||
|
package org.dromara.productManagement.common.service; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.IOException; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 任务处理器接口 |
||||
|
* 定义了处理任务的核心方法 |
||||
|
* @param <T> 任务数据类型 |
||||
|
* @param <E> 任务实体类型 |
||||
|
*/ |
||||
|
public interface TaskProcessor<T, E> { |
||||
|
|
||||
|
/** |
||||
|
* 文件处理结果 |
||||
|
*/ |
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
class FileProcessResult { |
||||
|
private String fileName; |
||||
|
private String filePath; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 处理任务 |
||||
|
* |
||||
|
* @param taskData 任务数据 |
||||
|
* @param taskType 任务类型 |
||||
|
* @return 处理结果 |
||||
|
*/ |
||||
|
Boolean processTask(T taskData, String taskType) throws IOException, InterruptedException; |
||||
|
|
||||
|
/** |
||||
|
* 验证提示词 |
||||
|
* |
||||
|
* @param taskNames 任务名称列表 |
||||
|
* @param taskData 任务数据 |
||||
|
* @param taskType 任务类型 |
||||
|
*/ |
||||
|
void validatePrompts(List<String> taskNames, T taskData, String taskType); |
||||
|
|
||||
|
/** |
||||
|
* 处理用户提示词设置 |
||||
|
* |
||||
|
* @param userId 用户ID |
||||
|
* @param taskData 任务数据 |
||||
|
* @param taskType 任务类型 |
||||
|
*/ |
||||
|
void handleUserPromptsSetting(Long userId, T taskData, String taskType); |
||||
|
|
||||
|
/** |
||||
|
* 处理文件 |
||||
|
* |
||||
|
* @param ossId 文件ID |
||||
|
* @return 处理结果 |
||||
|
*/ |
||||
|
FileProcessResult processFile(Long ossId) throws IOException, InterruptedException; |
||||
|
|
||||
|
/** |
||||
|
* 计算任务优先级 |
||||
|
* |
||||
|
* @param taskName 任务名称 |
||||
|
* @return 优先级 |
||||
|
*/ |
||||
|
Long calculatePriority(String taskName); |
||||
|
|
||||
|
/** |
||||
|
* 任务插入数据库前的扩展点 |
||||
|
* |
||||
|
* @param taskData 任务数据 |
||||
|
* @param taskName 任务名称 |
||||
|
* @param fileResult 文件处理结果 |
||||
|
*/ |
||||
|
void beforeTaskInsert(T taskData, String taskName, FileProcessResult fileResult); |
||||
|
|
||||
|
/** |
||||
|
* 任务消息发送前的扩展点 |
||||
|
* |
||||
|
* @param taskId 任务ID |
||||
|
* @param taskName 任务名称 |
||||
|
* @param taskData 任务数据 |
||||
|
*/ |
||||
|
void beforeTaskMessageSent(Long taskId, String taskName, T taskData); |
||||
|
|
||||
|
/** |
||||
|
* 将任务数据转换为任务实体 |
||||
|
* |
||||
|
* @param taskData 任务数据 |
||||
|
* @param taskName 任务名称 |
||||
|
* @param fileName 文件名 |
||||
|
* @param taskType 任务类型 |
||||
|
* @return 任务实体 |
||||
|
*/ |
||||
|
E convertToTaskEntity(T taskData, String taskName, String fileName, String taskType); |
||||
|
|
||||
|
/** |
||||
|
* 保存任务实体到数据库 |
||||
|
* |
||||
|
* @param entity 任务实体 |
||||
|
* @return 是否保存成功 |
||||
|
*/ |
||||
|
boolean saveTaskEntity(E entity); |
||||
|
|
||||
|
/** |
||||
|
* 获取任务ID |
||||
|
* |
||||
|
* @param entity 任务实体 |
||||
|
* @return 任务ID |
||||
|
*/ |
||||
|
Long getTaskId(E entity); |
||||
|
} |
@ -0,0 +1,122 @@ |
|||||
|
package org.dromara.productManagement.controller; |
||||
|
|
||||
|
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.productManagement.domain.vo.ContractualTaskChecklistVo; |
||||
|
import org.dromara.productManagement.domain.bo.ContractualTaskChecklistBo; |
||||
|
import org.dromara.productManagement.service.IContractualTaskChecklistService; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
|
||||
|
/** |
||||
|
* 合同任务审查清单 |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2025-05-16 |
||||
|
*/ |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/productManagement/ContractualTaskChecklist") |
||||
|
public class ContractualTaskChecklistController extends BaseController { |
||||
|
|
||||
|
private final IContractualTaskChecklistService contractualTaskChecklistService; |
||||
|
|
||||
|
/** |
||||
|
* 查询合同任务审查清单列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("productManagement:ContractualTaskChecklist:list") |
||||
|
@GetMapping("/list") |
||||
|
public TableDataInfo<ContractualTaskChecklistVo> list(ContractualTaskChecklistBo bo, PageQuery pageQuery) { |
||||
|
return contractualTaskChecklistService.queryPageList(bo, pageQuery); |
||||
|
} |
||||
|
/** |
||||
|
* 查询合同任务审查清单列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("productManagement:ContractualTaskChecklist:list") |
||||
|
@GetMapping("/queryList") |
||||
|
public R<List<ContractualTaskChecklistVo>> list(ContractualTaskChecklistBo bo) { |
||||
|
return R.ok(contractualTaskChecklistService.queryList(bo)); |
||||
|
} |
||||
|
/** |
||||
|
* 导出合同任务审查清单列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("productManagement:ContractualTaskChecklist:export") |
||||
|
@Log(title = "合同任务审查清单", businessType = BusinessType.EXPORT) |
||||
|
@PostMapping("/export") |
||||
|
public void export(ContractualTaskChecklistBo bo, HttpServletResponse response) { |
||||
|
List<ContractualTaskChecklistVo> list = contractualTaskChecklistService.queryList(bo); |
||||
|
ExcelUtil.exportExcel(list, "合同任务审查清单", ContractualTaskChecklistVo.class, response); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取合同任务审查清单详细信息 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
*/ |
||||
|
@SaCheckPermission("productManagement:ContractualTaskChecklist:query") |
||||
|
@GetMapping("/{id}") |
||||
|
public R<ContractualTaskChecklistVo> getInfo(@NotNull(message = "主键不能为空") |
||||
|
@PathVariable Long id) { |
||||
|
return R.ok(contractualTaskChecklistService.queryById(id)); |
||||
|
} |
||||
|
/** |
||||
|
* 获取合同任务审查清单详细信息 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
*/ |
||||
|
@SaCheckPermission("productManagement:ContractualTaskChecklist:query") |
||||
|
@GetMapping("/queryByGroupId/{id}") |
||||
|
public R<List<ContractualTaskChecklistVo>> queryByGroupId(@NotNull(message = "主键不能为空") |
||||
|
@PathVariable String id) { |
||||
|
return R.ok(contractualTaskChecklistService.queryByGroupId(id)); |
||||
|
} |
||||
|
/** |
||||
|
* 新增合同任务审查清单 |
||||
|
*/ |
||||
|
@SaCheckPermission("productManagement:ContractualTaskChecklist:add") |
||||
|
@Log(title = "合同任务审查清单", businessType = BusinessType.INSERT) |
||||
|
@RepeatSubmit() |
||||
|
@PostMapping() |
||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody List<ContractualTaskChecklistBo> boList) { |
||||
|
return toAjax(contractualTaskChecklistService.insertByBoList(boList)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改合同任务审查清单 |
||||
|
*/ |
||||
|
@SaCheckPermission("productManagement:ContractualTaskChecklist:edit") |
||||
|
@Log(title = "合同任务审查清单", businessType = BusinessType.UPDATE) |
||||
|
@RepeatSubmit() |
||||
|
@PutMapping() |
||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody List<ContractualTaskChecklistBo> boList) { |
||||
|
return toAjax(contractualTaskChecklistService.updateByBoList(boList)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除合同任务审查清单 |
||||
|
* |
||||
|
* @param ids 主键串 |
||||
|
*/ |
||||
|
@SaCheckPermission("productManagement:ContractualTaskChecklist:remove") |
||||
|
@Log(title = "合同任务审查清单", businessType = BusinessType.DELETE) |
||||
|
@DeleteMapping("/{ids}") |
||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
||||
|
@PathVariable String[] ids) { |
||||
|
return toAjax(contractualTaskChecklistService.deleteWithValidByIds(List.of(ids), true)); |
||||
|
} |
||||
|
} |
@ -0,0 +1,59 @@ |
|||||
|
package org.dromara.productManagement.domain; |
||||
|
|
||||
|
import org.dromara.common.tenant.core.TenantEntity; |
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
|
||||
|
/** |
||||
|
* 合同任务审查清单对象 contractual_task_checklist |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2025-05-16 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@TableName("contractual_task_checklist") |
||||
|
public class ContractualTaskChecklist extends TenantEntity { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* id |
||||
|
*/ |
||||
|
@TableId(value = "id") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 清单名称 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 清单项内容 |
||||
|
*/ |
||||
|
private String checklistItem; |
||||
|
|
||||
|
/** |
||||
|
* 排序 |
||||
|
*/ |
||||
|
private Long sortOrder; |
||||
|
private String checklistItemDesc; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
@TableLogic |
||||
|
private String delFlag; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
@Version |
||||
|
private Long version; |
||||
|
|
||||
|
private String groupId; |
||||
|
} |
@ -0,0 +1,43 @@ |
|||||
|
package org.dromara.productManagement.domain.bo; |
||||
|
|
||||
|
import org.dromara.productManagement.domain.ContractualTaskChecklist; |
||||
|
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.*; |
||||
|
|
||||
|
/** |
||||
|
* 合同任务审查清单业务对象 contractual_task_checklist |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2025-05-16 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@AutoMapper(target = ContractualTaskChecklist.class, reverseConvertGenerate = false) |
||||
|
public class ContractualTaskChecklistBo extends BaseEntity { |
||||
|
|
||||
|
/** |
||||
|
* id |
||||
|
*/ |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 清单名称 |
||||
|
*/ |
||||
|
@NotBlank(message = "清单名称不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 清单项内容 |
||||
|
*/ |
||||
|
@NotBlank(message = "清单项内容不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String checklistItem; |
||||
|
|
||||
|
private String checklistItemDesc; |
||||
|
private String groupId; |
||||
|
|
||||
|
} |
@ -1,42 +0,0 @@ |
|||||
package org.dromara.productManagement.domain.bo; |
|
||||
|
|
||||
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 org.dromara.productManagement.domain.ContractualTaskSupplement; |
|
||||
|
|
||||
/** |
|
||||
* 合同任务额外字段 |
|
||||
业务对象 contractual_task_supplement |
|
||||
* |
|
||||
* @author Lion Li |
|
||||
* @date 2025-01-21 |
|
||||
*/ |
|
||||
@Data |
|
||||
@EqualsAndHashCode(callSuper = true) |
|
||||
@AutoMapper(target = ContractualTaskSupplement.class, reverseConvertGenerate = false) |
|
||||
public class ContractualTaskSupplementBo extends BaseEntity { |
|
||||
|
|
||||
/** |
|
||||
* |
|
||||
*/ |
|
||||
private Long id; |
|
||||
|
|
||||
/** |
|
||||
* 任务id |
|
||||
*/ |
|
||||
@NotNull(message = "任务id不能为空", groups = { AddGroup.class, EditGroup.class }) |
|
||||
private Long documentTasksId; |
|
||||
|
|
||||
/** |
|
||||
* 合同角色 |
|
||||
*/ |
|
||||
@NotBlank(message = "合同角色不能为空", groups = { AddGroup.class, EditGroup.class }) |
|
||||
private String contractPartyRole; |
|
||||
|
|
||||
|
|
||||
} |
|
@ -0,0 +1,52 @@ |
|||||
|
package org.dromara.productManagement.domain.vo; |
||||
|
|
||||
|
import org.dromara.productManagement.domain.ContractualTaskChecklist; |
||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||
|
import org.dromara.common.excel.annotation.ExcelDictFormat; |
||||
|
import org.dromara.common.excel.convert.ExcelDictConvert; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 合同任务审查清单视图对象 contractual_task_checklist |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2025-05-16 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ExcelIgnoreUnannotated |
||||
|
@AutoMapper(target = ContractualTaskChecklist.class) |
||||
|
public class ContractualTaskChecklistVo implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* id |
||||
|
*/ |
||||
|
@ExcelProperty(value = "id") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 清单名称 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "清单名称") |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 清单项内容 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "清单项内容") |
||||
|
private String checklistItem; |
||||
|
private String checklistItemDesc; |
||||
|
private int checklistItemNum; |
||||
|
private String groupId; |
||||
|
|
||||
|
} |
@ -1,50 +0,0 @@ |
|||||
package org.dromara.productManagement.domain.vo; |
|
||||
|
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
|
||||
|
|
||||
import io.github.linpeilie.annotations.AutoMapper; |
|
||||
import lombok.Data; |
|
||||
import org.dromara.productManagement.domain.ContractualTaskSupplement; |
|
||||
|
|
||||
import java.io.Serial; |
|
||||
import java.io.Serializable; |
|
||||
import java.util.Date; |
|
||||
|
|
||||
|
|
||||
|
|
||||
/** |
|
||||
* 合同任务额外字段 |
|
||||
视图对象 contractual_task_supplement |
|
||||
* |
|
||||
* @author Lion Li |
|
||||
* @date 2025-01-21 |
|
||||
*/ |
|
||||
@Data |
|
||||
@ExcelIgnoreUnannotated |
|
||||
@AutoMapper(target = ContractualTaskSupplement.class) |
|
||||
public class ContractualTaskSupplementVo implements Serializable { |
|
||||
|
|
||||
@Serial |
|
||||
private static final long serialVersionUID = 1L; |
|
||||
|
|
||||
/** |
|
||||
* |
|
||||
*/ |
|
||||
@ExcelProperty(value = "") |
|
||||
private Long id; |
|
||||
|
|
||||
/** |
|
||||
* 任务id |
|
||||
*/ |
|
||||
@ExcelProperty(value = "任务id") |
|
||||
private Long documentTasksId; |
|
||||
|
|
||||
/** |
|
||||
* 合同角色 |
|
||||
*/ |
|
||||
@ExcelProperty(value = "合同角色") |
|
||||
private String contractPartyRole; |
|
||||
|
|
||||
|
|
||||
} |
|
@ -0,0 +1,31 @@ |
|||||
|
package org.dromara.productManagement.mapper; |
||||
|
|
||||
|
import org.dromara.productManagement.domain.ContractualTaskChecklist; |
||||
|
import org.dromara.productManagement.domain.vo.ContractualTaskChecklistVo; |
||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 合同任务审查清单Mapper接口 |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2025-05-16 |
||||
|
*/ |
||||
|
public interface ContractualTaskChecklistMapper extends BaseMapperPlus<ContractualTaskChecklist, ContractualTaskChecklistVo> { |
||||
|
|
||||
|
/** |
||||
|
* 按name和groupId分组查询 |
||||
|
*/ |
||||
|
Page<ContractualTaskChecklistVo> selectGroupPage(Page<ContractualTaskChecklistVo> page, String name); |
||||
|
|
||||
|
/** |
||||
|
* 真实删除数据 |
||||
|
*/ |
||||
|
int realDelete(String groupId); |
||||
|
|
||||
|
/** |
||||
|
* 按name和groupId分组查询列表 |
||||
|
*/ |
||||
|
List<ContractualTaskChecklistVo> selectGroupList(String name); |
||||
|
} |
@ -1,8 +0,0 @@ |
|||||
package org.dromara.productManagement.mapper; |
|
||||
|
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
|
||||
import org.dromara.productManagement.domain.ContractualTaskSupplement; |
|
||||
import org.dromara.productManagement.domain.vo.ContractualTaskSupplementVo; |
|
||||
|
|
||||
public interface ContractualTaskSupplementMapper extends BaseMapperPlus<ContractualTaskSupplement, ContractualTaskSupplementVo> { |
|
||||
} |
|
@ -0,0 +1,70 @@ |
|||||
|
package org.dromara.productManagement.service; |
||||
|
|
||||
|
import org.dromara.productManagement.domain.vo.ContractualTaskChecklistVo; |
||||
|
import org.dromara.productManagement.domain.bo.ContractualTaskChecklistBo; |
||||
|
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 Lion Li |
||||
|
* @date 2025-05-16 |
||||
|
*/ |
||||
|
public interface IContractualTaskChecklistService { |
||||
|
|
||||
|
/** |
||||
|
* 查询合同任务审查清单 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 合同任务审查清单 |
||||
|
*/ |
||||
|
ContractualTaskChecklistVo queryById(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 分页查询合同任务审查清单列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 合同任务审查清单分页列表 |
||||
|
*/ |
||||
|
TableDataInfo<ContractualTaskChecklistVo> queryPageList(ContractualTaskChecklistBo bo, PageQuery pageQuery); |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的合同任务审查清单列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 合同任务审查清单列表 |
||||
|
*/ |
||||
|
List<ContractualTaskChecklistVo> queryList(ContractualTaskChecklistBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 批量新增合同任务审查清单 |
||||
|
* |
||||
|
* @param boList 合同任务审查清单列表 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
Boolean insertByBoList(List<ContractualTaskChecklistBo> boList); |
||||
|
|
||||
|
/** |
||||
|
* 批量修改合同任务审查清单 |
||||
|
* |
||||
|
* @param boList 合同任务审查清单列表 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
Boolean updateByBoList(List<ContractualTaskChecklistBo> boList); |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除合同任务审查清单信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid); |
||||
|
|
||||
|
List<ContractualTaskChecklistVo> queryByGroupId(String id); |
||||
|
} |
@ -1,87 +0,0 @@ |
|||||
package org.dromara.productManagement.service; |
|
||||
|
|
||||
|
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|
||||
import org.dromara.common.mybatis.core.page.PageQuery; |
|
||||
import org.dromara.productManagement.domain.bo.ContractualTaskSupplementBo; |
|
||||
import org.dromara.productManagement.domain.vo.ContractualTaskSupplementVo; |
|
||||
|
|
||||
import java.util.Collection; |
|
||||
import java.util.List; |
|
||||
|
|
||||
/** |
|
||||
* 合同任务额外字段 |
|
||||
Service接口 |
|
||||
* |
|
||||
* @author Lion Li |
|
||||
* @date 2025-01-21 |
|
||||
*/ |
|
||||
public interface IContractualTaskSupplementService { |
|
||||
|
|
||||
/** |
|
||||
* 查询合同任务额外字段 |
|
||||
|
|
||||
* |
|
||||
* @param id 主键 |
|
||||
* @return 合同任务额外字段 |
|
||||
|
|
||||
*/ |
|
||||
ContractualTaskSupplementVo queryById(Long id); |
|
||||
|
|
||||
/** |
|
||||
* 分页查询合同任务额外字段 |
|
||||
列表 |
|
||||
* |
|
||||
* @param bo 查询条件 |
|
||||
* @param pageQuery 分页参数 |
|
||||
* @return 合同任务额外字段 |
|
||||
分页列表 |
|
||||
*/ |
|
||||
TableDataInfo<ContractualTaskSupplementVo> queryPageList(ContractualTaskSupplementBo bo, PageQuery pageQuery); |
|
||||
|
|
||||
/** |
|
||||
* 查询符合条件的合同任务额外字段 |
|
||||
列表 |
|
||||
* |
|
||||
* @param bo 查询条件 |
|
||||
* @return 合同任务额外字段 |
|
||||
列表 |
|
||||
*/ |
|
||||
List<ContractualTaskSupplementVo> queryList(ContractualTaskSupplementBo bo); |
|
||||
|
|
||||
/** |
|
||||
* 新增合同任务额外字段 |
|
||||
|
|
||||
* |
|
||||
* @param bo 合同任务额外字段 |
|
||||
|
|
||||
* @return 是否新增成功 |
|
||||
*/ |
|
||||
Boolean insertByBo(ContractualTaskSupplementBo bo); |
|
||||
|
|
||||
/** |
|
||||
* 修改合同任务额外字段 |
|
||||
|
|
||||
* |
|
||||
* @param bo 合同任务额外字段 |
|
||||
|
|
||||
* @return 是否修改成功 |
|
||||
*/ |
|
||||
Boolean updateByBo(ContractualTaskSupplementBo bo); |
|
||||
|
|
||||
/** |
|
||||
* 校验并批量删除合同任务额外字段 |
|
||||
信息 |
|
||||
* |
|
||||
* @param ids 待删除的主键集合 |
|
||||
* @param isValid 是否进行有效性校验 |
|
||||
* @return 是否删除成功 |
|
||||
*/ |
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
|
||||
/** |
|
||||
* 根据合同id查询合同方角色 |
|
||||
* @param id |
|
||||
* @return |
|
||||
*/ |
|
||||
String queryContractPartyRole(String id); |
|
||||
} |
|
@ -0,0 +1,182 @@ |
|||||
|
package org.dromara.productManagement.service.impl; |
||||
|
|
||||
|
|
||||
|
import cn.dev33.satoken.stp.StpUtil; |
||||
|
import org.dromara.common.core.exception.ServiceException; |
||||
|
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.dromara.common.satoken.utils.LoginHelper; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.dromara.productManagement.domain.bo.ContractualTaskChecklistBo; |
||||
|
import org.dromara.productManagement.domain.vo.ContractualTaskChecklistVo; |
||||
|
import org.dromara.productManagement.domain.ContractualTaskChecklist; |
||||
|
import org.dromara.productManagement.mapper.ContractualTaskChecklistMapper; |
||||
|
import org.dromara.productManagement.service.IContractualTaskChecklistService; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Collection; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
/** |
||||
|
* 合同任务审查清单Service业务层处理 |
||||
|
* |
||||
|
* @author Lion Li |
||||
|
* @date 2025-05-16 |
||||
|
*/ |
||||
|
@RequiredArgsConstructor |
||||
|
@Service |
||||
|
public class ContractualTaskChecklistServiceImpl implements IContractualTaskChecklistService { |
||||
|
|
||||
|
private final ContractualTaskChecklistMapper baseMapper; |
||||
|
|
||||
|
/** |
||||
|
* 查询合同任务审查清单 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 合同任务审查清单 |
||||
|
*/ |
||||
|
@Override |
||||
|
public ContractualTaskChecklistVo queryById(Long id){ |
||||
|
return baseMapper.selectVoById(id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 分页查询合同任务审查清单列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 合同任务审查清单分页列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public TableDataInfo<ContractualTaskChecklistVo> queryPageList(ContractualTaskChecklistBo bo, PageQuery pageQuery) { |
||||
|
Page<ContractualTaskChecklistVo> page = baseMapper.selectGroupPage(pageQuery.build(), bo.getName()); |
||||
|
return TableDataInfo.build(page); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的合同任务审查清单列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 合同任务审查清单列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<ContractualTaskChecklistVo> queryList(ContractualTaskChecklistBo bo) { |
||||
|
return baseMapper.selectGroupList(bo.getName()); |
||||
|
} |
||||
|
|
||||
|
private LambdaQueryWrapper<ContractualTaskChecklist> buildQueryWrapper(ContractualTaskChecklistBo bo) { |
||||
|
LambdaQueryWrapper<ContractualTaskChecklist> lqw = Wrappers.lambdaQuery(); |
||||
|
lqw.like(StringUtils.isNotBlank(bo.getName()), ContractualTaskChecklist::getName, bo.getName()); |
||||
|
Long userId = LoginHelper.getUserId(); |
||||
|
if(!StpUtil.hasRole("superadmin")){ |
||||
|
lqw.eq(userId != null, ContractualTaskChecklist::getCreateBy, userId); |
||||
|
} |
||||
|
return lqw; |
||||
|
} |
||||
|
|
||||
|
// /**
|
||||
|
// * 新增合同任务审查清单
|
||||
|
// *
|
||||
|
// * @param bo 合同任务审查清单
|
||||
|
// * @return 是否新增成功
|
||||
|
// */
|
||||
|
// @Override
|
||||
|
// public Boolean insertByBo(ContractualTaskChecklistBo bo) {
|
||||
|
// ContractualTaskChecklist add = MapstructUtils.convert(bo, ContractualTaskChecklist.class);
|
||||
|
// validEntityBeforeSave(add);
|
||||
|
// boolean flag = baseMapper.insert(add) > 0;
|
||||
|
// if (flag) {
|
||||
|
// bo.setId(add.getId());
|
||||
|
// }
|
||||
|
// return flag;
|
||||
|
// }
|
||||
|
|
||||
|
// /**
|
||||
|
// * 修改合同任务审查清单
|
||||
|
// *
|
||||
|
// * @param bo 合同任务审查清单
|
||||
|
// * @return 是否修改成功
|
||||
|
// */
|
||||
|
// @Override
|
||||
|
// public Boolean updateByBo(ContractualTaskChecklistBo bo) {
|
||||
|
// ContractualTaskChecklist update = MapstructUtils.convert(bo, ContractualTaskChecklist.class);
|
||||
|
// validEntityBeforeSave(update);
|
||||
|
// return baseMapper.updateById(update) > 0;
|
||||
|
// }
|
||||
|
|
||||
|
/** |
||||
|
* 保存前的数据校验 |
||||
|
*/ |
||||
|
private void validEntityBeforeSave(ContractualTaskChecklist entity){ |
||||
|
//TODO 做一些数据校验,如唯一约束
|
||||
|
if(StringUtils.isBlank(entity.getName())){ |
||||
|
throw new ServiceException("清单名称不能为空"); |
||||
|
} |
||||
|
if(StringUtils.isBlank(entity.getChecklistItem())){ |
||||
|
throw new ServiceException("清单项不能为空"); |
||||
|
} |
||||
|
//name 不能重复
|
||||
|
LambdaQueryWrapper<ContractualTaskChecklist> lqw = Wrappers.lambdaQuery(); |
||||
|
lqw.eq(ContractualTaskChecklist::getName, entity.getName()); |
||||
|
List<ContractualTaskChecklist> list = baseMapper.selectList(lqw); |
||||
|
if(list.size() > 0){ |
||||
|
throw new ServiceException("清单名称不能重复"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 批量新增合同任务审查清单 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean insertByBoList(List<ContractualTaskChecklistBo> boList) { |
||||
|
List<ContractualTaskChecklist> list = MapstructUtils.convert(boList, ContractualTaskChecklist.class); |
||||
|
String uuid = UUID.randomUUID().toString().replaceAll("-", ""); |
||||
|
validEntityBeforeSave(list.get(0)); |
||||
|
for (ContractualTaskChecklist contractualTaskChecklist : list) { |
||||
|
contractualTaskChecklist.setGroupId(uuid); |
||||
|
baseMapper.insert(contractualTaskChecklist); |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 批量修改合同任务审查清单 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean updateByBoList(List<ContractualTaskChecklistBo> boList) { |
||||
|
baseMapper.realDelete(boList.get(0).getGroupId()); |
||||
|
insertByBoList(boList); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除合同任务审查清单信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) { |
||||
|
if(isValid){ |
||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
|
} |
||||
|
baseMapper.realDelete(ids.iterator().next()); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<ContractualTaskChecklistVo> queryByGroupId(String id) { |
||||
|
LambdaQueryWrapper<ContractualTaskChecklist> lqw = Wrappers.lambdaQuery(); |
||||
|
lqw.eq(ContractualTaskChecklist::getGroupId, id); |
||||
|
return baseMapper.selectVoList(lqw); |
||||
|
} |
||||
|
} |
@ -1,155 +0,0 @@ |
|||||
package org.dromara.productManagement.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.dromara.productManagement.domain.ContractualTaskSupplement; |
|
||||
import org.dromara.productManagement.domain.bo.ContractualTaskSupplementBo; |
|
||||
import org.dromara.productManagement.domain.vo.ContractualTaskSupplementVo; |
|
||||
import org.dromara.productManagement.mapper.ContractualTaskSupplementMapper; |
|
||||
import org.dromara.productManagement.service.IContractualTaskSupplementService; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
|
|
||||
|
|
||||
import java.util.List; |
|
||||
import java.util.Map; |
|
||||
import java.util.Collection; |
|
||||
|
|
||||
/** |
|
||||
* 合同任务额外字段 |
|
||||
Service业务层处理 |
|
||||
* |
|
||||
* @author Lion Li |
|
||||
* @date 2025-01-21 |
|
||||
*/ |
|
||||
@RequiredArgsConstructor |
|
||||
@Service |
|
||||
public class ContractualTaskSupplementServiceImpl implements IContractualTaskSupplementService { |
|
||||
|
|
||||
private final ContractualTaskSupplementMapper baseMapper; |
|
||||
|
|
||||
/** |
|
||||
* 查询合同任务额外字段 |
|
||||
|
|
||||
* |
|
||||
* @param id 主键 |
|
||||
* @return 合同任务额外字段 |
|
||||
|
|
||||
*/ |
|
||||
@Override |
|
||||
public ContractualTaskSupplementVo queryById(Long id){ |
|
||||
return baseMapper.selectVoById(id); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 分页查询合同任务额外字段 |
|
||||
列表 |
|
||||
* |
|
||||
* @param bo 查询条件 |
|
||||
* @param pageQuery 分页参数 |
|
||||
* @return 合同任务额外字段 |
|
||||
分页列表 |
|
||||
*/ |
|
||||
@Override |
|
||||
public TableDataInfo<ContractualTaskSupplementVo> queryPageList(ContractualTaskSupplementBo bo, PageQuery pageQuery) { |
|
||||
LambdaQueryWrapper<ContractualTaskSupplement> lqw = buildQueryWrapper(bo); |
|
||||
Page<ContractualTaskSupplementVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|
||||
return TableDataInfo.build(result); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 查询符合条件的合同任务额外字段 |
|
||||
列表 |
|
||||
* |
|
||||
* @param bo 查询条件 |
|
||||
* @return 合同任务额外字段 |
|
||||
列表 |
|
||||
*/ |
|
||||
@Override |
|
||||
public List<ContractualTaskSupplementVo> queryList(ContractualTaskSupplementBo bo) { |
|
||||
LambdaQueryWrapper<ContractualTaskSupplement> lqw = buildQueryWrapper(bo); |
|
||||
return baseMapper.selectVoList(lqw); |
|
||||
} |
|
||||
|
|
||||
private LambdaQueryWrapper<ContractualTaskSupplement> buildQueryWrapper(ContractualTaskSupplementBo bo) { |
|
||||
Map<String, Object> params = bo.getParams(); |
|
||||
LambdaQueryWrapper<ContractualTaskSupplement> lqw = Wrappers.lambdaQuery(); |
|
||||
lqw.eq(bo.getDocumentTasksId() != null, ContractualTaskSupplement::getDocumentTasksId, bo.getDocumentTasksId()); |
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getContractPartyRole()), ContractualTaskSupplement::getContractPartyRole, bo.getContractPartyRole()); |
|
||||
return lqw; |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 新增合同任务额外字段 |
|
||||
|
|
||||
* |
|
||||
* @param bo 合同任务额外字段 |
|
||||
|
|
||||
* @return 是否新增成功 |
|
||||
*/ |
|
||||
@Override |
|
||||
public Boolean insertByBo(ContractualTaskSupplementBo bo) { |
|
||||
ContractualTaskSupplement add = MapstructUtils.convert(bo, ContractualTaskSupplement.class); |
|
||||
validEntityBeforeSave(add); |
|
||||
boolean flag = baseMapper.insert(add) > 0; |
|
||||
if (flag) { |
|
||||
bo.setId(add.getId()); |
|
||||
} |
|
||||
return flag; |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 修改合同任务额外字段 |
|
||||
|
|
||||
* |
|
||||
* @param bo 合同任务额外字段 |
|
||||
|
|
||||
* @return 是否修改成功 |
|
||||
*/ |
|
||||
@Override |
|
||||
public Boolean updateByBo(ContractualTaskSupplementBo bo) { |
|
||||
ContractualTaskSupplement update = MapstructUtils.convert(bo, ContractualTaskSupplement.class); |
|
||||
validEntityBeforeSave(update); |
|
||||
return baseMapper.updateById(update) > 0; |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 保存前的数据校验 |
|
||||
*/ |
|
||||
private void validEntityBeforeSave(ContractualTaskSupplement 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 String queryContractPartyRole(String id) { |
|
||||
|
|
||||
LambdaQueryWrapper<ContractualTaskSupplement> lqw = Wrappers.lambdaQuery(); |
|
||||
lqw.eq(ContractualTaskSupplement::getDocumentTasksId, id); |
|
||||
ContractualTaskSupplement contractualTaskSupplement = baseMapper.selectOne(lqw); |
|
||||
if (contractualTaskSupplement == null) { |
|
||||
return null; |
|
||||
} |
|
||||
return contractualTaskSupplement.getContractPartyRole(); |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,39 @@ |
|||||
|
<?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.productManagement.mapper.ContractualTaskChecklistMapper"> |
||||
|
|
||||
|
<select id="selectGroupPage" resultType="org.dromara.productManagement.domain.vo.ContractualTaskChecklistVo"> |
||||
|
SELECT |
||||
|
name, |
||||
|
group_id as groupId, |
||||
|
COUNT(*) as checklistItemNum |
||||
|
FROM contractual_task_checklist |
||||
|
<where> |
||||
|
<if test="name != null and name != ''"> |
||||
|
AND name LIKE CONCAT('%', #{name}, '%') |
||||
|
</if> |
||||
|
</where> |
||||
|
GROUP BY name, group_id |
||||
|
</select> |
||||
|
|
||||
|
<select id="selectGroupList" resultType="org.dromara.productManagement.domain.vo.ContractualTaskChecklistVo"> |
||||
|
SELECT |
||||
|
name, |
||||
|
group_id as groupId, |
||||
|
COUNT(*) as checklistItemNum |
||||
|
FROM contractual_task_checklist |
||||
|
<where> |
||||
|
<if test="name != null and name != ''"> |
||||
|
AND name LIKE CONCAT('%', #{name}, '%') |
||||
|
</if> |
||||
|
</where> |
||||
|
GROUP BY name, group_id |
||||
|
</select> |
||||
|
|
||||
|
<delete id="realDelete"> |
||||
|
DELETE FROM contractual_task_checklist WHERE group_id = #{groupId} |
||||
|
</delete> |
||||
|
|
||||
|
</mapper> |
@ -1,7 +0,0 @@ |
|||||
<?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.productManagement.mapper.ContractualTaskSupplementMapper"> |
|
||||
|
|
||||
</mapper> |
|
Loading…
Reference in new issue