模版编制相关实现
This commit is contained in:
@@ -55,6 +55,7 @@ public class TemplateInstanceController extends AbstractFileUploadController {
|
||||
setFileUploadInfo(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
@Resource
|
||||
private TemplateInstanceService templateInstanceService;
|
||||
|
||||
@@ -105,6 +106,9 @@ public class TemplateInstanceController extends AbstractFileUploadController {
|
||||
public CommonResult<TemplateInstanceRespVO> getTemplateInstance(@RequestParam("id") Long id) {
|
||||
TemplateInstanceDO templateInstance = templateInstanceService.getTemplateInstance(id);
|
||||
TemplateInstanceRespVO templateInstanceRespVO = BeanUtils.toBean(templateInstance, TemplateInstanceRespVO.class);
|
||||
if (templateInstance == null) {
|
||||
return success(templateInstanceRespVO);
|
||||
}
|
||||
templateInstanceService.getDetailedInfo(templateInstanceRespVO);
|
||||
return success(templateInstanceRespVO);
|
||||
}
|
||||
@@ -116,7 +120,9 @@ public class TemplateInstanceController extends AbstractFileUploadController {
|
||||
PageResult<TemplateInstanceDO> pageResult = templateInstanceService.getTemplateInstancePage(pageReqVO);
|
||||
PageResult<TemplateInstanceRespVO> templateInstanceRespVOPageResult = BeanUtils.toBean(pageResult, TemplateInstanceRespVO.class);
|
||||
templateInstanceRespVOPageResult.getList().forEach(templateInstanceRespVO -> {
|
||||
if (templateInstanceRespVO != null) {
|
||||
templateInstanceService.getDetailedInfo(templateInstanceRespVO);
|
||||
}
|
||||
});
|
||||
return success(templateInstanceRespVOPageResult);
|
||||
}
|
||||
@@ -150,23 +156,28 @@ public class TemplateInstanceController extends AbstractFileUploadController {
|
||||
public CommonResult<PageResult<TemplateInstanceRespVO>> listExcludingDisabled(@Valid TemplateInstancePageReqVO pageReqVO) {
|
||||
PageResult<TemplateInstanceRespVO> templateInstanceRespVOPageResult = BeanUtils.toBean(templateInstanceService.listExcludingDisabled(pageReqVO), TemplateInstanceRespVO.class);
|
||||
templateInstanceRespVOPageResult.getList().forEach(
|
||||
templateInstanceRespVO ->
|
||||
templateInstanceService.getDetailedInfo(templateInstanceRespVO));
|
||||
templateInstanceRespVO -> {
|
||||
if (templateInstanceRespVO != null) {
|
||||
templateInstanceService.getDetailedInfo(templateInstanceRespVO);
|
||||
}
|
||||
}
|
||||
);
|
||||
return success(templateInstanceRespVOPageResult);
|
||||
}
|
||||
|
||||
//停用和启用接口
|
||||
@PostMapping("/disable-enable")
|
||||
@Operation(summary = "实例停用和启用接口",description = "实例停用和启用接口")
|
||||
@Operation(summary = "实例停用和启用接口", description = "实例停用和启用接口")
|
||||
@PreAuthorize("@ss.hasPermission('bse:template-instance:disable-enable')")
|
||||
public CommonResult<Boolean> setDisableOrEnable(@Valid @RequestBody DisableEnableReqVO reqVO) {
|
||||
templateInstanceService.setDisableOrEnable(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
//根据id获取实例版本号
|
||||
@GetMapping("/get-version")
|
||||
@Operation(summary = "根据id获取实例版本号")
|
||||
public CommonResult<Map<String,Object>> getVersion(@Valid @NotEmpty(message = "模版实例id不能为空") @RequestParam("id") String id) {
|
||||
public CommonResult<Map<String, Object>> getVersion(@Valid @NotEmpty(message = "模版实例id不能为空") @RequestParam("id") String id) {
|
||||
return success(templateInstanceService.getVersion(id));
|
||||
}
|
||||
|
||||
@@ -180,7 +191,7 @@ public class TemplateInstanceController extends AbstractFileUploadController {
|
||||
|
||||
//通过模版编码查看历史版本
|
||||
@GetMapping("/list-by-template-cdg")
|
||||
@Operation(summary = "通过模版编码(cdg)查看历史版本",description = "通过模版编码查看历史版本,已按照发布时间和创建时间降序排序")
|
||||
@Operation(summary = "通过模版编码(cdg)查看历史版本", description = "通过模版编码查看历史版本,已按照发布时间和创建时间降序排序")
|
||||
public CommonResult<List<TemplateInstanceRespVO>> listByTemplateCode(@RequestParam("cdg") @Valid @NotEmpty(message = "模版编号不能为空") String templateCode) {
|
||||
return success(templateInstanceService.listByCdg(templateCode));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.zt.plat.module.base.service.tmpltp.TemplateInstanceService;
|
||||
import com.zt.plat.module.infra.api.file.FileApi;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileCreateReqDTO;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
|
||||
import com.zt.plat.module.system.api.dept.DeptApi;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -26,56 +27,56 @@ import static com.zt.plat.module.base.controller.admin.templtp.onlyoffice.util.U
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class OnlyOfficeCallbackServiceImpl implements OnlyOfficeCallbackService {
|
||||
|
||||
private final FileApi fileApi;
|
||||
private final TemplateInstanceService templateInstanceService;
|
||||
|
||||
@Override
|
||||
public void processCallback(OnlyOfficeCallback callback,String id) {
|
||||
log.info("Received OnlyOffice callback for document: {}", callback.getKey());
|
||||
log.info("Callback status: {}", callback.getStatus());
|
||||
public void processCallback(OnlyOfficeCallback callback, String id) {
|
||||
log.info("收到OnlyOffice文档回调: {}", callback.getKey());
|
||||
log.info("回调状态: {}", callback.getStatus());
|
||||
|
||||
// 根据不同的状态处理回调
|
||||
switch (callback.getStatus()) {
|
||||
case 1:
|
||||
handleEditingStatus(callback,id);
|
||||
handleEditingStatus(callback, id);
|
||||
break;
|
||||
case 2:
|
||||
handleDocumentSaved(callback,id);
|
||||
handleDocumentSaved(callback, id);
|
||||
break;
|
||||
case 3:
|
||||
handleSaveError(callback,id);
|
||||
handleSaveError(callback, id);
|
||||
break;
|
||||
case 4:
|
||||
handleDocumentClosedWithoutChanges(callback,id);
|
||||
handleDocumentClosedWithoutChanges(callback, id);
|
||||
break;
|
||||
case 6:
|
||||
handleForcedSave(callback,id);
|
||||
handleForcedSave(callback, id);
|
||||
break;
|
||||
case 7:
|
||||
handleForcedSaveError(callback,id);
|
||||
handleForcedSaveError(callback, id);
|
||||
break;
|
||||
default:
|
||||
log.warn("Received unknown callback status: {}", callback.getStatus());
|
||||
log.warn("收到未知的回调状态: {}", callback.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理文档正在编辑的状态
|
||||
*/
|
||||
private void handleEditingStatus(OnlyOfficeCallback callback,String id) {
|
||||
log.info("Document {} is being edited by users: {}",
|
||||
private void handleEditingStatus(OnlyOfficeCallback callback, String id) {
|
||||
log.info("文档 {} 正在被以下用户编辑: {}",
|
||||
callback.getKey(), callback.getUsers());
|
||||
|
||||
// 处理用户操作(连接或断开连接)
|
||||
if (callback.getActions() != null) {
|
||||
for (Action action : callback.getActions()) {
|
||||
String actionType = switch (action.getType()) {
|
||||
case 0 -> "disconnected from";
|
||||
case 1 -> "connected to";
|
||||
case 2 -> "clicked force save in";
|
||||
default -> "performed unknown action in";
|
||||
case 0 -> "断开了与";
|
||||
case 1 -> "连接到";
|
||||
case 2 -> "在中点击了强制保存";
|
||||
default -> "在中执行了未知操作";
|
||||
};
|
||||
log.info("User {} {}", action.getUserId(), actionType);
|
||||
log.info("用户 {} {}", action.getUserId(), actionType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,9 +84,9 @@ public class OnlyOfficeCallbackServiceImpl implements OnlyOfficeCallbackService
|
||||
/**
|
||||
* 处理文档已保存的状态
|
||||
*/
|
||||
private void handleDocumentSaved(OnlyOfficeCallback callback,String id) {
|
||||
log.info("Document {} is ready to be saved", callback.getKey());
|
||||
saveDocument(callback,id);
|
||||
private void handleDocumentSaved(OnlyOfficeCallback callback, String id) {
|
||||
log.info("文档 {} 已准备好保存", callback.getKey());
|
||||
saveDocument(callback, id);
|
||||
|
||||
// 处理历史记录
|
||||
// handleHistoryChanges(callback,id);
|
||||
@@ -94,48 +95,48 @@ public class OnlyOfficeCallbackServiceImpl implements OnlyOfficeCallbackService
|
||||
/**
|
||||
* 处理保存错误的状态
|
||||
*/
|
||||
private void handleSaveError(OnlyOfficeCallback callback,String id) {
|
||||
log.error("Error saving document {}", callback.getKey());
|
||||
private void handleSaveError(OnlyOfficeCallback callback, String id) {
|
||||
log.error("保存文档 {} 时出错", callback.getKey());
|
||||
// 可以在这里添加错误处理逻辑,如发送通知等
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理文档关闭且无更改的状态
|
||||
*/
|
||||
private void handleDocumentClosedWithoutChanges(OnlyOfficeCallback callback,String id) {
|
||||
log.info("Document {} closed without changes", callback.getKey());
|
||||
private void handleDocumentClosedWithoutChanges(OnlyOfficeCallback callback, String id) {
|
||||
log.info("文档 {} 已关闭,未做任何更改", callback.getKey());
|
||||
// 可以在这里添加清理资源等逻辑
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理强制保存的状态
|
||||
*/
|
||||
private void handleForcedSave(OnlyOfficeCallback callback,String id) {
|
||||
log.info("Document {} forced save. Type: {}",
|
||||
private void handleForcedSave(OnlyOfficeCallback callback, String id) {
|
||||
log.info("文档 {} 执行强制保存。类型: {}",
|
||||
callback.getKey(), callback.getForceSaveType());
|
||||
saveDocument(callback,id);
|
||||
saveDocument(callback, id);
|
||||
|
||||
// 处理历史记录
|
||||
handleHistoryChanges(callback,id);
|
||||
handleHistoryChanges(callback, id);
|
||||
|
||||
// 如果是表单提交,处理表单数据
|
||||
if (callback.getForceSaveType() == 3 && callback.getFormsDataUrl() != null) {
|
||||
handleFormSubmission(callback,id);
|
||||
handleFormSubmission(callback, id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理强制保存错误的状态
|
||||
*/
|
||||
private void handleForcedSaveError(OnlyOfficeCallback callback,String id) {
|
||||
log.error("Error during forced save of document {}", callback.getKey());
|
||||
private void handleForcedSaveError(OnlyOfficeCallback callback, String id) {
|
||||
log.error("文档 {} 强制保存时出错", callback.getKey());
|
||||
// 可以在这里添加错误处理逻辑
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文档到存储
|
||||
*/
|
||||
private void saveDocument(OnlyOfficeCallback callback,String id) {
|
||||
private void saveDocument(OnlyOfficeCallback callback, String id) {
|
||||
if (callback.getUrl() == null) {
|
||||
log.error("文件路径为空");
|
||||
return;
|
||||
@@ -182,17 +183,17 @@ public class OnlyOfficeCallbackServiceImpl implements OnlyOfficeCallbackService
|
||||
/**
|
||||
* 处理文档历史记录变更
|
||||
*/
|
||||
private void handleHistoryChanges(OnlyOfficeCallback callback,String id) {
|
||||
private void handleHistoryChanges(OnlyOfficeCallback callback, String id) {
|
||||
History history = callback.getHistory();
|
||||
if (history != null) {
|
||||
log.info("Processing document history changes for {}", callback.getKey());
|
||||
log.info("正在处理文档 {} 的历史记录变更", callback.getKey());
|
||||
// 这里可以实现处理历史记录的逻辑
|
||||
// 例如:调用refreshHistory方法更新历史记录
|
||||
}
|
||||
|
||||
// 处理变更历史URL
|
||||
if (callback.getChangesUrl() != null) {
|
||||
log.info("Changes URL for document {}: {}", callback.getKey(), callback.getChangesUrl());
|
||||
log.info("文档 {} 的变更历史URL: {}", callback.getKey(), callback.getChangesUrl());
|
||||
// 这里可以实现保存变更历史的逻辑
|
||||
// 例如:下载变更历史并使用setHistoryData方法存储
|
||||
}
|
||||
@@ -201,8 +202,8 @@ public class OnlyOfficeCallbackServiceImpl implements OnlyOfficeCallbackService
|
||||
/**
|
||||
* 处理表单提交数据
|
||||
*/
|
||||
private void handleFormSubmission(OnlyOfficeCallback callback,String id) {
|
||||
log.info("Processing form submission for document {}", callback.getKey());
|
||||
private void handleFormSubmission(OnlyOfficeCallback callback, String id) {
|
||||
log.info("正在处理文档 {} 的表单提交", callback.getKey());
|
||||
// 这里可以实现处理表单数据的逻辑
|
||||
// 例如:从formsDataUrl下载并解析表单数据
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.zt.plat.module.base.controller.admin.templtp.vo;
|
||||
|
||||
import com.zt.plat.module.system.api.dept.dto.DeptDetailRespDTO;
|
||||
import com.zt.plat.module.system.api.dept.dto.DeptRespDTO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
@@ -59,12 +61,18 @@ public class TemplateInstanceRespVO {
|
||||
@Schema(description = "发布时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("发布时间")
|
||||
private LocalDateTime publishTime;
|
||||
|
||||
|
||||
@Schema(description = "使用部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "")
|
||||
private List<String> deptIds;
|
||||
@Schema(description = "实例字段;这个是实例字段绑定的字段", requiredMode = Schema.RequiredMode.REQUIRED, example = "")
|
||||
private List<TemplateInstanceDataRespVO> templateInstanceDataRespVOS;
|
||||
@Schema(description = "实例条款;这个是实例条款绑定的条款;", requiredMode = Schema.RequiredMode.REQUIRED, example = "")
|
||||
private List<TemplateInstanceItemRespVO> instanceItemRespVOS;
|
||||
|
||||
@Schema(description = "使用部门编", requiredMode = Schema.RequiredMode.REQUIRED, example = "")
|
||||
private List<DeptRespDTO> DeptRespVOS;
|
||||
|
||||
@Schema(description = "模版分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试分类名称")
|
||||
@ExcelProperty("模版分类名称")
|
||||
private String tpName;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(value = "baseRpcConfiguration", proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {DeptApi.class, FileApi.class})
|
||||
@EnableFeignClients(clients = {DeptApi.class, FileApi.class,DeptApi.class})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
||||
@@ -7,9 +7,7 @@ import com.zt.plat.module.base.dal.dataobject.tmpltp.TemplateInstanceDO;
|
||||
import jakarta.validation.*;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 模板实例 Service 接口
|
||||
@@ -86,5 +84,5 @@ public interface TemplateInstanceService {
|
||||
//
|
||||
// Map<String, Object> saveFile(MultipartFile file, String id);
|
||||
|
||||
boolean updateTemplateInstanceFileUrlByInstanceId(@Valid @NotEmpty(message = "模版实例id不能为空") String id, @Valid @NotEmpty(message = "文件参数不能为空") String params);
|
||||
void updateTemplateInstanceFileUrlByInstanceId(@Valid @NotEmpty(message = "模版实例id不能为空") String id, @Valid @NotEmpty(message = "文件参数不能为空") String params);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ import com.zt.plat.framework.tenant.core.context.CompanyContextHolder;
|
||||
import com.zt.plat.module.base.controller.admin.templtp.vo.*;
|
||||
import com.zt.plat.module.base.dal.dataobject.tmpltp.*;
|
||||
import com.zt.plat.module.base.dal.mysql.tmpltp.*;
|
||||
import com.zt.plat.module.infra.api.file.FileApi;
|
||||
import com.zt.plat.module.system.api.dept.DeptApi;
|
||||
import com.zt.plat.module.system.api.dept.dto.DeptRespDTO;
|
||||
import com.zt.plat.module.tmpltp.enums.DeleteStatusEnum;
|
||||
import com.zt.plat.module.tmpltp.enums.PublishStatusEnum;
|
||||
import com.zt.plat.module.tmpltp.enums.TmplStsEnum;
|
||||
@@ -23,7 +24,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
@@ -45,7 +45,7 @@ import static com.zt.plat.module.tmpltp.enums.ErrorCodeConstants.*;
|
||||
@Validated
|
||||
public class TemplateInstanceServiceImpl implements TemplateInstanceService {
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
private DeptApi deptApi;
|
||||
@Resource
|
||||
private TemplateInstanceMapper templateInstanceMapper;
|
||||
@Resource
|
||||
@@ -55,6 +55,9 @@ public class TemplateInstanceServiceImpl implements TemplateInstanceService {
|
||||
@Resource
|
||||
private TemplateInstanceItemMapper templateInstanceItemMapper;
|
||||
|
||||
@Resource
|
||||
private TmplTpService tmplTpService;
|
||||
|
||||
private static final Pattern VERSION_PATTERN = Pattern.compile("^(.*?)([0-9]+(?:\\.[0-9]+)*)(.*)$");
|
||||
|
||||
@Override
|
||||
@@ -312,6 +315,7 @@ public class TemplateInstanceServiceImpl implements TemplateInstanceService {
|
||||
newTpInstanceDO.setId(null);
|
||||
newTpInstanceDO.setVer(incrementVersion(templateInstanceDO.getVer()));
|
||||
newTpInstanceDO.setPublishTime(LocalDateTime.now());
|
||||
newTpInstanceDO.setOrigCntt(templateInstanceDO.getCntt());
|
||||
newTpInstanceDO.setCreateTime(null);
|
||||
newTpInstanceDO.setUpdateTime(null);
|
||||
templateInstanceMapper.insert(newTpInstanceDO);
|
||||
@@ -391,14 +395,22 @@ public class TemplateInstanceServiceImpl implements TemplateInstanceService {
|
||||
templateInstanceRespVO.setDeptIds(getDeptByInstanId(templateInstanceRespVO.getId())); // 部门
|
||||
templateInstanceRespVO.setInstanceItemRespVOS(setInstanceItemRespVOS(templateInstanceRespVO.getId())); // 条款
|
||||
templateInstanceRespVO.setTemplateInstanceDataRespVOS(setTemplateInstanceDataRespVOS(templateInstanceRespVO.getId())); // 实例字段
|
||||
if (!templateInstanceRespVO.getDeptIds().isEmpty()){
|
||||
templateInstanceRespVO.setDeptRespVOS(deptApi.getDeptList(templateInstanceRespVO.getDeptIds().stream().map(Long::valueOf).toList()).getData()); // 部门详情
|
||||
}
|
||||
TmplTpDO tmplTp = tmplTpService.getTmplTp(templateInstanceRespVO.getTpId());
|
||||
if (tmplTp != null){
|
||||
templateInstanceRespVO.setTpName(!tmplTp.getName().isEmpty()?tmplTp.getName():"分类未命名");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateTemplateInstanceFileUrlByInstanceId(String id, String params) {
|
||||
public void updateTemplateInstanceFileUrlByInstanceId(String id, String params) {
|
||||
validateTemplateInstanceExists(Long.valueOf(id));
|
||||
LambdaUpdateWrapper<TemplateInstanceDO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(TemplateInstanceDO::getId, id).set(TemplateInstanceDO::getCntt, params);
|
||||
return templateInstanceMapper.update(updateWrapper)>0;
|
||||
templateInstanceMapper.update(updateWrapper);
|
||||
}
|
||||
// 实例条款值
|
||||
private List<TemplateInstanceItemRespVO> setInstanceItemRespVOS(Long id) {
|
||||
|
||||
Reference in New Issue
Block a user