feat: wps新增添加projectId

dev
zhanglei 2026-07-23 18:29:00 +08:00
parent 5964ba6769
commit 6ff29d373f
6 changed files with 27 additions and 17 deletions

View File

@ -123,16 +123,17 @@ public class H5OpenController {
@ApiOperation("打开页当前用户有文档返回最近一份没有则创建空白docx") @ApiOperation("打开页当前用户有文档返回最近一份没有则创建空白docx")
@GetMapping(value = "/doc/my-or-create", produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(value = "/doc/my-or-create", produces = MediaType.APPLICATION_JSON_VALUE)
public SingleResponse<WpsDocOpenCO> myOrCreate(@RequestParam("docxUrl") String docxUrl) { public SingleResponse<WpsDocOpenCO> myOrCreate(@RequestParam("docxUrl") String docxUrl, @RequestParam("projectId") Long projectId) {
log.info("wps my-or-create"); log.info("wps my-or-create");
return SingleResponse.of(wpsApi.myOrCreate(docxUrl)); return SingleResponse.of(wpsApi.myOrCreate(docxUrl, projectId));
} }
@ApiOperation("始终新建一份空白docx") @ApiOperation("始终新建一份空白docx")
@PostMapping(value = "/doc/create", produces = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "/doc/create", produces = MediaType.APPLICATION_JSON_VALUE)
public SingleResponse<WpsDocOpenCO> createBlank(@RequestBody Req<String> req) { public SingleResponse<WpsDocOpenCO> createBlank(@RequestBody Req<Map<String, String>> req) {
log.info("wps create blank"); log.info("wps create blank");
return SingleResponse.of(wpsApi.createBlank(req.getData())); Map<String, String> data = req.getData();
return SingleResponse.of(wpsApi.createBlank(data.getOrDefault("docxUrl", ""), Long.parseLong(data.getOrDefault("projectId", "0"))));
} }
@ApiOperation("模版文档(固定)") @ApiOperation("模版文档(固定)")

View File

@ -31,12 +31,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -315,7 +310,7 @@ public class WpsExecutor implements WpsApi {
} }
@Override @Override
public WpsDocOpenCO myOrCreate(String docxUrl) { public WpsDocOpenCO myOrCreate(String docxUrl, Long projectId) {
try { try {
Long userId = requireUserId(); Long userId = requireUserId();
String creatorId = String.valueOf(userId); String creatorId = String.valueOf(userId);
@ -323,7 +318,7 @@ public class WpsExecutor implements WpsApi {
if (existing != null) { if (existing != null) {
return toOpenCO(existing, false); return toOpenCO(existing, false);
} }
WpsDocEntity created = doCreateBlankDoc(userId, docxUrl); WpsDocEntity created = doCreateBlankDoc(userId, docxUrl, projectId);
return toOpenCO(created, true); return toOpenCO(created, true);
} catch (Exception e) { } catch (Exception e) {
log.error("wps myOrCreate failed", e); log.error("wps myOrCreate failed", e);
@ -332,10 +327,10 @@ public class WpsExecutor implements WpsApi {
} }
@Override @Override
public WpsDocOpenCO createBlank(String docxUrl) { public WpsDocOpenCO createBlank(String docxUrl, Long projectId) {
try { try {
Long userId = requireUserId(); Long userId = requireUserId();
WpsDocEntity created = doCreateBlankDoc(userId, docxUrl); WpsDocEntity created = doCreateBlankDoc(userId, docxUrl, projectId);
return toOpenCO(created, true); return toOpenCO(created, true);
} catch (Exception e) { } catch (Exception e) {
log.error("wps createBlank failed", e); log.error("wps createBlank failed", e);
@ -343,7 +338,10 @@ public class WpsExecutor implements WpsApi {
} }
} }
protected WpsDocEntity doCreateBlankDoc(Long userId, String docxUrl) { protected WpsDocEntity doCreateBlankDoc(Long userId, String docxUrl, Long projectId) {
if(Objects.nonNull(projectId)) {
throw new BizException(ErrorCode.EVAL_PROJECT_ERROR);
}
String resDocxUrl = !StringUtils.hasText(docxUrl) ? defDocxUrl : docxUrl; String resDocxUrl = !StringUtils.hasText(docxUrl) ? defDocxUrl : docxUrl;
if (!StringUtils.hasText(resDocxUrl)) { if (!StringUtils.hasText(resDocxUrl)) {
throw new BizException(ErrorCode.WPS_BLANK_DOCX_URL_EMPTY); throw new BizException(ErrorCode.WPS_BLANK_DOCX_URL_EMPTY);
@ -379,6 +377,7 @@ public class WpsExecutor implements WpsApi {
doc.setCreateTimeEpoch(nowEpoch); doc.setCreateTimeEpoch(nowEpoch);
doc.setModifyTimeEpoch(nowEpoch); doc.setModifyTimeEpoch(nowEpoch);
doc.setTenantId(AuthUserContextAdapter.getCurrentTenantId()); doc.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
doc.setProjectId(projectId);
WpsDocVersionEntity versionEntity = new WpsDocVersionEntity(); WpsDocVersionEntity versionEntity = new WpsDocVersionEntity();
versionEntity.setOrgId(orgId); versionEntity.setOrgId(orgId);
@ -392,6 +391,7 @@ public class WpsExecutor implements WpsApi {
versionEntity.setManualFlag(1); versionEntity.setManualFlag(1);
versionEntity.setCreateTimeEpoch(nowEpoch); versionEntity.setCreateTimeEpoch(nowEpoch);
versionEntity.setTenantId(doc.getTenantId()); versionEntity.setTenantId(doc.getTenantId());
versionEntity.setProjectId(doc.getProjectId());
return wpsDocDomainService.createInitial(doc, versionEntity); return wpsDocDomainService.createInitial(doc, versionEntity);
} }

View File

@ -40,10 +40,10 @@ public interface WpsApi {
/** /**
* docx * docx
*/ */
WpsDocOpenCO myOrCreate(String docxUrl); WpsDocOpenCO myOrCreate(String docxUrl, Long projectId);
/** /**
* docx使 * docx使
*/ */
WpsDocOpenCO createBlank(String docxUrl); WpsDocOpenCO createBlank(String docxUrl, Long projectId);
} }

View File

@ -30,4 +30,8 @@ public class WpsDocEntity {
private String pendingDownloadUrl; private String pendingDownloadUrl;
/** 三阶段上传待确认大小 */ /** 三阶段上传待确认大小 */
private Long pendingSize; private Long pendingSize;
/**
* id
*/
private Long projectId;
} }

View File

@ -24,4 +24,8 @@ public class WpsDocVersionEntity {
private Integer manualFlag; private Integer manualFlag;
private Long createTimeEpoch; private Long createTimeEpoch;
private Long tenantId; private Long tenantId;
/**
* id
*/
private Long projectId;
} }

View File

@ -159,6 +159,7 @@ public enum ErrorCode {
EVAL_ARCHIVE_ALREADY_DONE("06-05-016", "项目已归档,请勿重复归档"), EVAL_ARCHIVE_ALREADY_DONE("06-05-016", "项目已归档,请勿重复归档"),
EVAL_ARCHIVE_SIGN_INCOMPLETE("06-05-017", "签字未完成,无法归档"), EVAL_ARCHIVE_SIGN_INCOMPLETE("06-05-017", "签字未完成,无法归档"),
EVAL_HANDOVER_FORM_NOT_CREATED("06-05-018", "归档交接单未生成,无法归档"), EVAL_HANDOVER_FORM_NOT_CREATED("06-05-018", "归档交接单未生成,无法归档"),
EVAL_PROJECT_ERROR("06-05-019", "项目不存在"),
// ---- 监督检查告知phase2 P3 ---- // ---- 监督检查告知phase2 P3 ----
INSP_NOTICE_NOT_FOUND("06-06-001", "监督检查告知不存在"), INSP_NOTICE_NOT_FOUND("06-06-001", "监督检查告知不存在"),