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