This commit is contained in:
harid 2025-12-15 17:50:54 +07:00
parent d3534a3085
commit 6a7082b5b1

View file

@ -2952,8 +2952,8 @@ export class DevelopmentController extends Controller {
const oldProfile: any = getDevelopment.developmentHistorys.find(
(x) => x.citizenId == item["รหัสประจำตัวประชาชน"],
);
if (oldProfile.length > 0) {
return;
if (oldProfile != null) {
if (oldProfile.isDone == true) return;
}
if (item["ประเภท"] == undefined) return;
let development = Object.assign(new DevelopmentHistory(), oldProfile);
@ -3204,26 +3204,29 @@ export class DevelopmentController extends Controller {
if (oldProfile != null) {
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ข้อมูลนี้ได้ถูกบันทึกแล้ว");
}
oldProfile.dateStart = requestBody.dateStart == undefined ? _null : requestBody.dateStart;
oldProfile.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd;
oldProfile.order = requestBody.commandNumber == undefined ? _null : requestBody.commandNumber;
oldProfile.dateOrder = requestBody.commandDate == undefined ? _null : new Date(requestBody.commandDate);
oldProfile.trainingDays = requestBody.trainingDays == undefined ? _null : requestBody.trainingDays;
oldProfile.createdUserId = request.user.sub;
oldProfile.createdFullName = request.user.name;
oldProfile.lastUpdateUserId = request.user.sub;
oldProfile.lastUpdateFullName = request.user.name;
oldProfile.createdAt = new Date();
oldProfile.lastUpdatedAt = new Date();
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Store DevelopmentHistory.",
// });
await this.developmentHistoryRepository.save(oldProfile, { data: request });
setLogDataDiff(request, { before, after: oldProfile });
status = oldProfile.isProfile;
if (oldProfile != null) {
if (oldProfile.isDone == true)
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ข้อมูลนี้ได้ถูกบันทึกแล้ว");
oldProfile.dateStart = requestBody.dateStart == undefined ? _null : requestBody.dateStart;
oldProfile.dateEnd = requestBody.dateEnd == undefined ? _null : requestBody.dateEnd;
oldProfile.order = requestBody.commandNumber == undefined ? _null : requestBody.commandNumber;
oldProfile.dateOrder = requestBody.commandDate == undefined ? _null : new Date(requestBody.commandDate);
oldProfile.trainingDays = requestBody.trainingDays == undefined ? _null : requestBody.trainingDays;
oldProfile.createdUserId = request.user.sub;
oldProfile.createdFullName = request.user.name;
oldProfile.lastUpdateUserId = request.user.sub;
oldProfile.lastUpdateFullName = request.user.name;
oldProfile.createdAt = new Date();
oldProfile.lastUpdatedAt = new Date();
// addLogSequence(request, {
// action: "database",
// status: "success",
// description: "Store DevelopmentHistory.",
// });
await this.developmentHistoryRepository.save(oldProfile, { data: request });
setLogDataDiff(request, { before, after: oldProfile });
status = oldProfile.isProfile;
}
if (requestBody.type == "OFFICER") {
await new CallAPI()