Activated projects can update duties, approval policy, and document enablement. Changing the workflow definition stays rejected, and project 143 remains frozen. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.5 KiB
Go
44 lines
1.5 KiB
Go
package projectinstance
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
)
|
|
|
|
// readonlyLivePlanProjectID 是历史验收项目。激活后保持只读,禁止改写规划与补文档行。
|
|
const readonlyLivePlanProjectID int64 = 143
|
|
|
|
// TemplateDocMaterializer 把已启用文档任务物化到 document_records。
|
|
// 实现放在 app 适配层,避免 projectinstance 依赖 docgov。
|
|
type TemplateDocMaterializer interface {
|
|
MaterializeTemplateDocs(ctx context.Context, projectID int64, plan WorkflowPlan) error
|
|
}
|
|
|
|
func (s *Service) SetTemplateDocMaterializer(m TemplateDocMaterializer) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
s.templateDocs = m
|
|
}
|
|
|
|
// MaterializeLiveDocs 按 live 快照补齐受控文档台账。列表接口可重复调用。
|
|
func (s *Service) MaterializeLiveDocs(ctx context.Context, projectID int64) error {
|
|
if s == nil || s.templateDocs == nil || s.store == nil || projectID <= 0 || projectID == readonlyLivePlanProjectID {
|
|
return nil
|
|
}
|
|
live, err := s.store.GetLiveInstance(ctx, projectID)
|
|
if err != nil || live == nil {
|
|
return err
|
|
}
|
|
return s.templateDocs.MaterializeTemplateDocs(ctx, projectID, live.ConfigSnapshot)
|
|
}
|
|
|
|
func (s *Service) materializePlan(ctx context.Context, projectID int64, plan WorkflowPlan) {
|
|
if s == nil || s.templateDocs == nil || projectID <= 0 || projectID == readonlyLivePlanProjectID {
|
|
return
|
|
}
|
|
if err := s.templateDocs.MaterializeTemplateDocs(ctx, projectID, plan); err != nil {
|
|
slog.Warn("materialize template docs", "project_id", projectID, "err", err)
|
|
}
|
|
}
|