更新项目管理模块中合同管理、项目安装、项目验收、回访记录等功能
This commit is contained in:
1 parent
307e9cf1b9
commit
b3cef22a54
32 files changed
+6094
-2600
No files matched your search
@@ -13,6 +13,7 @@ import SysUser from "../entity/sysUser.entity";
|
||||
import SysUserRole from "../entity/sysUserRole.entity";
|
||||
import SysRole from "../entity/sysRole.entity";
|
||||
import { UploadService } from "./upload.service";
|
||||
import { LogService } from "./log.service";
|
||||
|
||||
// 勘察工单状态:0待指派 1现场勘察中 2待技术复核 3已归档 4预留 5已取消
|
||||
const STATUS = { PENDING_ASSIGN: 0, SURVEYING: 1, PENDING_REVIEW: 2, ARCHIVED: 3, RESERVED: 4, CANCELED: 5 };
|
||||
@@ -57,6 +58,9 @@ export class SurveyOrderService {
|
||||
@Inject()
|
||||
uploadService!: UploadService;
|
||||
|
||||
@Inject()
|
||||
logService!: LogService;
|
||||
|
||||
private async isAdmin(userId: number): Promise<boolean> {
|
||||
const userRoles = await this.userRoleModel.findAll({ where: { userId }, include: [this.roleModel] });
|
||||
return userRoles.some((ur) => (ur as any).role?.roleCode === "ADMIN");
|
||||
@@ -479,6 +483,7 @@ export class SurveyOrderService {
|
||||
await this.createSopResults(created.id, templateCode);
|
||||
const vo = this.toVO(created);
|
||||
await this.decorate([vo]);
|
||||
await this.logService.logAction(ctx, "勘察派单", "创建", created.surveyNo, `创建勘察派单 ${created.surveyNo}`);
|
||||
return { code: 200, message: "创建勘察派单成功", data: vo };
|
||||
}
|
||||
|
||||
@@ -501,6 +506,7 @@ export class SurveyOrderService {
|
||||
const fresh = await this.surveyModel.findByPk(id);
|
||||
const vo = this.toVO(fresh!);
|
||||
await this.decorate([vo]);
|
||||
await this.logService.logAction(ctx, "勘察派单", "更新", record.surveyNo, `更新勘察派单 ${record.surveyNo}`);
|
||||
return { code: 200, message: "更新勘察派单成功", data: vo };
|
||||
}
|
||||
|
||||
@@ -535,6 +541,7 @@ export class SurveyOrderService {
|
||||
|
||||
const result = await this.assignCore(id, worker, dto.estimatedFee);
|
||||
if (!result.ok) return { code: result.code, message: result.message, data: null };
|
||||
await this.logService.logAction(ctx, "勘察派单", "指派", record.surveyNo, `指派勘察派单 ${record.surveyNo} 至 ${worker.workerName}`);
|
||||
return { code: 200, message: "派单成功", data: result.data };
|
||||
}
|
||||
|
||||
@@ -555,6 +562,7 @@ export class SurveyOrderService {
|
||||
failIds.push(id);
|
||||
}
|
||||
}
|
||||
await this.logService.logAction(ctx, "勘察派单", "批量指派", "", `批量指派 ${successCount} 条勘察派单至 ${worker.workerName},失败 ${failIds.length} 条`);
|
||||
return {
|
||||
code: 200,
|
||||
message: `批量派单完成,成功 ${successCount} 条`,
|
||||
@@ -580,6 +588,7 @@ export class SurveyOrderService {
|
||||
await record.update(patch);
|
||||
const vo = this.toVO(record);
|
||||
await this.decorate([vo]);
|
||||
await this.logService.logAction(ctx, "勘察派单", "复核", record.surveyNo, `复核勘察派单 ${record.surveyNo}: ${dto.result === "pass" ? "通过归档" : "退回勘察"}`);
|
||||
return { code: 200, message: dto.result === "pass" ? "复核通过,工单已归档" : "已退回现场勘察中", data: vo };
|
||||
}
|
||||
|
||||
@@ -594,6 +603,7 @@ export class SurveyOrderService {
|
||||
const urgeCount = (record.urgeCount || 0) + 1;
|
||||
const lastUrgedAt = new Date();
|
||||
await record.update({ urgeCount, lastUrgedAt });
|
||||
await this.logService.logAction(ctx, "勘察派单", "催办", record.surveyNo, `催办勘察派单 ${record.surveyNo}(第 ${urgeCount} 次)`);
|
||||
return { code: 200, message: "催办成功", data: { urgeCount, lastUrgedAt } };
|
||||
}
|
||||
|
||||
@@ -606,6 +616,7 @@ export class SurveyOrderService {
|
||||
}
|
||||
|
||||
await record.update({ status: STATUS.CANCELED, cancelReason: dto.reason || null });
|
||||
await this.logService.logAction(ctx, "勘察派单", "取消", record.surveyNo, `取消勘察派单 ${record.surveyNo}`);
|
||||
return { code: 200, message: "取消工单成功", data: this.toVO(record) };
|
||||
}
|
||||
|
||||
@@ -613,9 +624,11 @@ export class SurveyOrderService {
|
||||
const record = await this.surveyModel.findByPk(id);
|
||||
if (!record) return { code: 404, message: "勘察派单不存在", data: null };
|
||||
if (!(await this.isCustomerOwner(ctx.state.user.userId, record.customerId))) return { code: 403, message: "无权限删除该勘察派单", data: null };
|
||||
const surveyNo = record.surveyNo;
|
||||
// 级联清理回执后删除工单
|
||||
await this.sopResultModel.destroy({ where: { surveyOrderId: id } });
|
||||
await record.destroy();
|
||||
await this.logService.logAction(ctx, "勘察派单", "删除", surveyNo, `删除勘察派单 ${surveyNo}`);
|
||||
return { code: 200, message: "删除勘察派单成功", data: null };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user