Merge branch 'develop' into working

This commit is contained in:
Suphonchai Phoonsawat 2025-03-31 10:35:56 +07:00
commit 31625d0418
16 changed files with 21274 additions and 513 deletions

View file

@ -68,40 +68,40 @@ jobs:
docker compose pull
docker compose up -d
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- name: Notify Discord Success
if: success()
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d '{
"embeds": [{
"title": "✅ Deployment Success!",
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
"color": 3066993,
"footer": {
"text": "Release Notification",
"icon_url": "https://example.com/success-icon.png"
},
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}]
}' \
${{ secrets.DISCORD_WEBHOOK }}
# - name: Notify Discord Success
# if: success()
# run: |
# curl -H "Content-Type: application/json" \
# -X POST \
# -d '{
# "embeds": [{
# "title": "✅ Deployment Success!",
# "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
# "color": 3066993,
# "footer": {
# "text": "Release Notification",
# "icon_url": "https://example.com/success-icon.png"
# },
# "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
# }]
# }' \
# ${{ secrets.DISCORD_WEBHOOK }}
- name: Notify Discord Failure
if: failure()
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d '{
"embeds": [{
"title": "❌ Deployment Failed!",
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
"color": 15158332,
"footer": {
"text": "Release Notification",
"icon_url": "https://example.com/failure-icon.png"
},
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}]
}' \
${{ secrets.DISCORD_WEBHOOK }}
# - name: Notify Discord Failure
# if: failure()
# run: |
# curl -H "Content-Type: application/json" \
# -X POST \
# -d '{
# "embeds": [{
# "title": "❌ Deployment Failed!",
# "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
# "color": 15158332,
# "footer": {
# "text": "Release Notification",
# "icon_url": "https://example.com/failure-icon.png"
# },
# "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
# }]
# }' \
# ${{ secrets.DISCORD_WEBHOOK }}

View file

@ -6,102 +6,102 @@ on:
- "placement-[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
IMAGE_NAME: ehr/bma-ehr-placement-service
DEPLOY_HOST: frappet.com
DEPLOY_PORT: 10102
# COMPOSE_PATH: /home/frappet/docker/bma-ehr
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-placement
TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
REGISTRY: docker.frappet.com
IMAGE_NAME: ehr/bma-ehr-placement-service
DEPLOY_HOST: frappet.com
DEPLOY_PORT: 10102
# COMPOSE_PATH: /home/frappet/docker/bma-ehr
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-placement
TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs:
# act workflow_dispatch -W .github/workflows/release_placement.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
release-dev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set output tags
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Gen Version
id: gen_ver
run: |
if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
IMAGE_VER=${{ steps.vars.outputs.tag }}
else
IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
fi
if [[ $IMAGE_VER == '' ]]; then
IMAGE_VER='test-vBeta'
fi
echo '::set-output name=image_ver::'$IMAGE_VER
- name: Check Version
run: |
echo $GITHUB_REF
echo ${{ steps.gen_ver.outputs.image_ver }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login in to registry
uses: docker/login-action@v2
with:
registry: ${{env.REGISTRY}}
username: ${{secrets.DOCKER_USER}}
password: ${{secrets.DOCKER_PASS}}
- name: Build and load local docker image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
file: BMA.EHR.Placement.Service/Dockerfile
push: true
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
# act workflow_dispatch -W .github/workflows/release_placement.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
release-dev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set output tags
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Gen Version
id: gen_ver
run: |
if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
IMAGE_VER=${{ steps.vars.outputs.tag }}
else
IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
fi
if [[ $IMAGE_VER == '' ]]; then
IMAGE_VER='test-vBeta'
fi
echo '::set-output name=image_ver::'$IMAGE_VER
- name: Check Version
run: |
echo $GITHUB_REF
echo ${{ steps.gen_ver.outputs.image_ver }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login in to registry
uses: docker/login-action@v2
with:
registry: ${{env.REGISTRY}}
username: ${{secrets.DOCKER_USER}}
password: ${{secrets.DOCKER_PASS}}
- name: Build and load local docker image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
file: BMA.EHR.Placement.Service/Dockerfile
push: true
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- name: Reload docker compose
uses: appleboy/ssh-action@v0.1.8
with:
host: ${{env.DEPLOY_HOST}}
username: frappet
password: ${{ secrets.SSH_PASSWORD }}
port: ${{env.DEPLOY_PORT}}
script: |
cd "${{env.COMPOSE_PATH}}"
docker compose pull
docker compose up -d
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- name: Notify Discord Success
if: success()
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d '{
"embeds": [{
"title": "✅ Deployment Success!",
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
"color": 3066993,
"footer": {
"text": "Release Notification",
"icon_url": "https://example.com/success-icon.png"
},
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}]
}' \
${{ secrets.DISCORD_WEBHOOK }}
- name: Reload docker compose
uses: appleboy/ssh-action@v0.1.8
with:
host: ${{env.DEPLOY_HOST}}
username: frappet
password: ${{ secrets.SSH_PASSWORD }}
port: ${{env.DEPLOY_PORT}}
script: |
cd "${{env.COMPOSE_PATH}}"
docker compose pull
docker compose up -d
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
# - name: Notify Discord Success
# if: success()
# run: |
# curl -H "Content-Type: application/json" \
# -X POST \
# -d '{
# "embeds": [{
# "title": "✅ Deployment Success!",
# "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
# "color": 3066993,
# "footer": {
# "text": "Release Notification",
# "icon_url": "https://example.com/success-icon.png"
# },
# "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
# }]
# }' \
# ${{ secrets.DISCORD_WEBHOOK }}
- name: Notify Discord Failure
if: failure()
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d '{
"embeds": [{
"title": "❌ Deployment Failed!",
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
"color": 15158332,
"footer": {
"text": "Release Notification",
"icon_url": "https://example.com/failure-icon.png"
},
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}]
}' \
${{ secrets.DISCORD_WEBHOOK }}
# - name: Notify Discord Failure
# if: failure()
# run: |
# curl -H "Content-Type: application/json" \
# -X POST \
# -d '{
# "embeds": [{
# "title": "❌ Deployment Failed!",
# "description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
# "color": 15158332,
# "footer": {
# "text": "Release Notification",
# "icon_url": "https://example.com/failure-icon.png"
# },
# "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
# }]
# }' \
# ${{ secrets.DISCORD_WEBHOOK }}

View file

@ -174,23 +174,17 @@ namespace BMA.EHR.Application.Repositories.Reports
// previousPosTypeName = profile.posTypeName;
// bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
// previousPosLevelName = profile.posLevelName;
var _child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
(profile.child4 == null ? "" : profile.child4 + "\n") +
(profile.child3 == null ? "" : profile.child3 + "\n") +
(profile.child2 == null ? "" : profile.child2 + "\n") +
(profile.child1 == null ? "" : profile.child1 + "\n") +
(profile.reason == null ? "" : profile.reason);
int lastNewLinechild = _child.LastIndexOf('\n');
if (lastNewLinechild != -1)
{
_child = _child.Remove(lastNewLinechild, 1);
}
return new ProfileRetireJsonRequest
{
order = $"{ (index + 1).ToString().ToThaiNumber() }. ลำดับที่ { (profile.order).ToString().ToThaiNumber() }",
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
root = "",
child = _child,
child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
(profile.child4 == null ? "" : profile.child4 + "\n") +
(profile.child3 == null ? "" : profile.child3 + "\n") +
(profile.child2 == null ? "" : profile.child2 + "\n") +
(profile.child1 == null ? "" : profile.child1 + "\n") +
(profile.reason == null ? "" : profile.reason),
position = profile.position != "" && profile.position != null ? profile.position : "-",
posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-",
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",
@ -300,38 +294,29 @@ namespace BMA.EHR.Application.Repositories.Reports
}
bool isDuplicateHospital = profile.child1 == previousChild1;
previousChild1 = profile.child1;
if (isDuplicateHospital == false)
{
previousPosTypeName = null;
previousPosLevelName = null;
}
bool isDuplicatePosType = profile.posTypeName == previousPosTypeName;
previousPosTypeName = profile.posTypeName;
bool isDuplicatePosLevel = profile.posLevelName == previousPosLevelName;
previousPosLevelName = profile.posLevelName;
var _root = (isDuplicateRoot ? "" : profile.root + "\n") +
(isDuplicateHospital || !hospital.ToObject<List<string>>().Contains(profile.child1)
? ""
: profile.child1 + "\n") +
(isDuplicatePosType ? "" : $"ตำแหน่งประเภท{profile.posTypeName}" + "\n") +
(isDuplicatePosLevel ? "" : $"ระดับ{profile.posLevelName}");
int lastNewLineroot = _root.LastIndexOf('\n');
if (lastNewLineroot != -1)
{
_root = _root.Remove(lastNewLineroot, 1);
}
var _child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
(profile.child4 == null ? "" : profile.child4 + "\n") +
(profile.child3 == null ? "" : profile.child3 + "\n") +
(profile.child2 == null ? "" : profile.child2 + "\n") +
(profile.child1 == null || hospital.ToObject<List<string>>().Contains(profile.child1) ? "" : profile.child1 + "\n") +
(profile.reason == null ? "" : profile.reason);
int lastNewLinechild = _child.LastIndexOf('\n');
if (lastNewLinechild != -1)
{
_child = _child.Remove(lastNewLinechild, 1);
}
return new ProfileRetireJsonRequest
{
order = (index + 1).ToString().ToThaiNumber(),
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
root = _root,
child = _child,
root = (isDuplicateRoot ? "" : profile.root + "\n") +
(isDuplicateHospital || !hospital.ToObject<List<string>>().Contains(profile.child1) ? "" : profile.child1 + "\n") +
(isDuplicatePosType ? "" : $"ตำแหน่งประเภท{profile.posTypeName}" + "\n") +
(isDuplicatePosLevel ? "" : $"ระดับ{profile.posLevelName}"),
child = (profile.posExecutiveName == null ? "" : profile.posExecutiveName + "\n") +
(profile.child4 == null ? "" : profile.child4 + "\n") +
(profile.child3 == null ? "" : profile.child3 + "\n") +
(profile.child2 == null ? "" : profile.child2 + "\n") +
(profile.child1 == null || hospital.ToObject<List<string>>().Contains(profile.child1) ? "" : profile.child1 + "\n") +
(profile.reason == null ? "" : profile.reason),
position = profile.position != "" && profile.position != null ? profile.position : "-",
posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-",
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",

View file

@ -14,6 +14,8 @@ namespace BMA.EHR.Domain.Models.Retirement
public string Status { get; set; } = "WAITTING";
[Comment("วันที่บรรจุ")]
public DateTime? RecruitDate { get; set; }
[Comment("วันที่รายงานตัว")]
public DateTime? ReportingDate { get; set; }
[Comment("เงินเดือน")]
public double? Amount { get; set; }
@ -113,6 +115,72 @@ namespace BMA.EHR.Domain.Models.Retirement
public string? posLevelNameOld { get; set; }
[Comment("ชื่อหน่วยงาน root")]
public string? root { get; set; }
[Comment("id หน่วยงาน root")]
public string? rootId { get; set; }
[Comment("id หน่วยงาน rootDna")]
public string? rootDnaId { get; set; }
[Comment("ชื่อย่อหน่วยงาน root")]
public string? rootShortName { get; set; }
[Comment("ชื่อหน่วยงาน child1")]
public string? child1 { get; set; }
[Comment("id หน่วยงาน child1")]
public string? child1Id { get; set; }
[Comment("id หน่วยงาน child1Dna")]
public string? child1DnaId { get; set; }
[Comment("ชื่อย่อหน่วยงาน child1")]
public string? child1ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child2")]
public string? child2 { get; set; }
[Comment("id หน่วยงาน child2")]
public string? child2Id { get; set; }
[Comment("id หน่วยงาน child2Dna")]
public string? child2DnaId { get; set; }
[Comment("ชื่อย่อหน่วยงาน child2")]
public string? child2ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child3")]
public string? child3 { get; set; }
[Comment("id หน่วยงาน child3")]
public string? child3Id { get; set; }
[Comment("id หน่วยงาน child3Dna")]
public string? child3DnaId { get; set; }
[Comment("ชื่อย่อหน่วยงาน child3")]
public string? child3ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child4")]
public string? child4 { get; set; }
[Comment("id หน่วยงาน child4")]
public string? child4Id { get; set; }
[Comment("id หน่วยงาน child4Dna")]
public string? child4DnaId { get; set; }
[Comment("ชื่อย่อหน่วยงาน child4")]
public string? child4ShortName { get; set; }
[Comment("ระดับโครงสร้าง")]
public int? node { get; set; }
[Comment("id โครงสร้าง")]
public Guid? nodeId { get; set; }
[Comment("id อัตรากำลัง")]
public string? posmasterId { get; set; }
[Comment("id revision")]
public string? orgRevisionId { get; set; }
[Comment("id ตำแหน่ง")]
public string? positionId { get; set; }
[Comment("สายงาน")]
public string? positionField { get; set; }
[Comment("เลขที่ตำแหน่ง")]
public int? posMasterNo { get; set; }
[Comment("ชื่อตำแหน่งในสายงาน")]
public string? position { get; set; }
[Comment("ตำแหน่งทางการบริหาร")]
public string? PositionExecutive { get; set; }
[Comment("id ประเภทตำแหน่ง")]
public string? posTypeId { get; set; }
[Comment("ชื่อประเภทตำแหน่ง")]
public string? posTypeName { get; set; }
[Comment("id ระดับตำแหน่ง")]
public string? posLevelId { get; set; }
[Comment("ชื่อระดับตำแหน่ง")]
public string? posLevelName { get; set; }
public virtual List<RetirementOtherDoc> RetirementOtherDocs { get; set; } = new List<RetirementOtherDoc>();
}
}

View file

@ -0,0 +1,424 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class update_table_retirementOther_add_position : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "PositionExecutive",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ตำแหน่งทางการบริหาร")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<DateTime>(
name: "ReportingDate",
table: "RetirementOthers",
type: "datetime(6)",
nullable: true,
comment: "วันที่รายงานตัว");
migrationBuilder.AddColumn<string>(
name: "child1",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child1DnaId",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child1Dna")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child1Id",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child1ShortName",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2DnaId",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child2Dna")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2Id",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2ShortName",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3DnaId",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child3Dna")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3Id",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3ShortName",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4DnaId",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child4Dna")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4Id",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4ShortName",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "node",
table: "RetirementOthers",
type: "int",
nullable: true,
comment: "ระดับโครงสร้าง");
migrationBuilder.AddColumn<Guid>(
name: "nodeId",
table: "RetirementOthers",
type: "char(36)",
nullable: true,
comment: "id โครงสร้าง",
collation: "ascii_general_ci");
migrationBuilder.AddColumn<string>(
name: "orgRevisionId",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id revision")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posLevelId",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id ระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posLevelName",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "posMasterNo",
table: "RetirementOthers",
type: "int",
nullable: true,
comment: "เลขที่ตำแหน่ง");
migrationBuilder.AddColumn<string>(
name: "posTypeId",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id ประเภทตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posTypeName",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อประเภทตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "position",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อตำแหน่งในสายงาน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "positionField",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "สายงาน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "positionId",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id ตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posmasterId",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id อัตรากำลัง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "root",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "rootDnaId",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน rootDna")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "rootId",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "rootShortName",
table: "RetirementOthers",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PositionExecutive",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "ReportingDate",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child1",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child1DnaId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child1Id",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child1ShortName",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child2",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child2DnaId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child2Id",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child2ShortName",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child3",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child3DnaId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child3Id",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child3ShortName",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child4",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child4DnaId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child4Id",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "child4ShortName",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "node",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "nodeId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "orgRevisionId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "posLevelId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "posLevelName",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "posMasterNo",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "posTypeId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "posTypeName",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "position",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "positionField",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "positionId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "posmasterId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "root",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "rootDnaId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "rootId",
table: "RetirementOthers");
migrationBuilder.DropColumn(
name: "rootShortName",
table: "RetirementOthers");
}
}
}

View file

@ -15148,6 +15148,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("datetime(6)")
.HasComment("ดำรงตำแหน่งในระดับปัจจุบันเมื่อ");
b.Property<string>("PositionExecutive")
.HasColumnType("longtext")
.HasComment("ตำแหน่งทางการบริหาร");
b.Property<string>("PositionExecutiveOld")
.HasColumnType("longtext")
.HasComment("ตำแหน่งทางการบริหารเดิม");
@ -15176,15 +15180,31 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("datetime(6)")
.HasComment("วันที่บรรจุ");
b.Property<DateTime?>("ReportingDate")
.HasColumnType("datetime(6)")
.HasComment("วันที่รายงานตัว");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานะคำขอ");
b.Property<string>("child1")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน child1");
b.Property<string>("child1DnaId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child1Dna");
b.Property<string>("child1DnaOldId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child1Dna old");
b.Property<string>("child1Id")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child1");
b.Property<string>("child1Old")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน child1 old");
@ -15193,14 +15213,30 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child1 old");
b.Property<string>("child1ShortName")
.HasColumnType("longtext")
.HasComment("ชื่อย่อหน่วยงาน child1");
b.Property<string>("child1ShortNameOld")
.HasColumnType("longtext")
.HasComment("ชื่อย่อหน่วยงาน child1 old");
b.Property<string>("child2")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน child2");
b.Property<string>("child2DnaId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child2Dna");
b.Property<string>("child2DnaOldId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child2Dna old");
b.Property<string>("child2Id")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child2");
b.Property<string>("child2Old")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน child2 old");
@ -15209,14 +15245,30 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child2 old");
b.Property<string>("child2ShortName")
.HasColumnType("longtext")
.HasComment("ชื่อย่อหน่วยงาน child2");
b.Property<string>("child2ShortNameOld")
.HasColumnType("longtext")
.HasComment("ชื่อย่อหน่วยงาน child2 old");
b.Property<string>("child3")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน child3");
b.Property<string>("child3DnaId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child3Dna");
b.Property<string>("child3DnaOldId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child3Dna old");
b.Property<string>("child3Id")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child3");
b.Property<string>("child3Old")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน child3 old");
@ -15225,14 +15277,30 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child3 old");
b.Property<string>("child3ShortName")
.HasColumnType("longtext")
.HasComment("ชื่อย่อหน่วยงาน child3");
b.Property<string>("child3ShortNameOld")
.HasColumnType("longtext")
.HasComment("ชื่อย่อหน่วยงาน child3 old");
b.Property<string>("child4")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน child4");
b.Property<string>("child4DnaId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child4Dna");
b.Property<string>("child4DnaOldId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child4Dna old");
b.Property<string>("child4Id")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child4");
b.Property<string>("child4Old")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน child4 old");
@ -15241,6 +15309,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("id หน่วยงาน child4 old");
b.Property<string>("child4ShortName")
.HasColumnType("longtext")
.HasComment("ชื่อย่อหน่วยงาน child4");
b.Property<string>("child4ShortNameOld")
.HasColumnType("longtext")
.HasComment("ชื่อย่อหน่วยงาน child4 old");
@ -15257,6 +15329,26 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("นามสกุล");
b.Property<int?>("node")
.HasColumnType("int")
.HasComment("ระดับโครงสร้าง");
b.Property<Guid?>("nodeId")
.HasColumnType("char(36)")
.HasComment("id โครงสร้าง");
b.Property<string>("orgRevisionId")
.HasColumnType("longtext")
.HasComment("id revision");
b.Property<string>("posLevelId")
.HasColumnType("longtext")
.HasComment("id ระดับตำแหน่ง");
b.Property<string>("posLevelName")
.HasColumnType("longtext")
.HasComment("ชื่อระดับตำแหน่ง");
b.Property<string>("posLevelNameOld")
.HasColumnType("longtext")
.HasComment("ชื่อระดับตำแหน่ง old");
@ -15265,10 +15357,22 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("id ระดับตำแหน่ง old");
b.Property<int?>("posMasterNo")
.HasColumnType("int")
.HasComment("เลขที่ตำแหน่ง");
b.Property<int?>("posMasterNoOld")
.HasColumnType("int")
.HasComment("เลขที่ตำแหน่ง old");
b.Property<string>("posTypeId")
.HasColumnType("longtext")
.HasComment("id ประเภทตำแหน่ง");
b.Property<string>("posTypeName")
.HasColumnType("longtext")
.HasComment("ชื่อประเภทตำแหน่ง");
b.Property<string>("posTypeNameOld")
.HasColumnType("longtext")
.HasComment("ชื่อประเภทตำแหน่ง old");
@ -15277,6 +15381,22 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("id ประเภทตำแหน่ง old");
b.Property<string>("position")
.HasColumnType("longtext")
.HasComment("ชื่อตำแหน่งในสายงาน");
b.Property<string>("positionField")
.HasColumnType("longtext")
.HasComment("สายงาน");
b.Property<string>("positionId")
.HasColumnType("longtext")
.HasComment("id ตำแหน่ง");
b.Property<string>("posmasterId")
.HasColumnType("longtext")
.HasComment("id อัตรากำลัง");
b.Property<string>("prefix")
.HasColumnType("longtext")
.HasComment("คำนำหน้า");
@ -15285,10 +15405,22 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("profile Id");
b.Property<string>("root")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน root");
b.Property<string>("rootDnaId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน rootDna");
b.Property<string>("rootDnaOldId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน rootDna old");
b.Property<string>("rootId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน root");
b.Property<string>("rootOld")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน root old");
@ -15297,6 +15429,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("id หน่วยงาน root old");
b.Property<string>("rootShortName")
.HasColumnType("longtext")
.HasComment("ชื่อย่อหน่วยงาน root");
b.Property<string>("rootShortNameOld")
.HasColumnType("longtext")
.HasComment("ชื่อย่อหน่วยงาน root old");

View file

@ -310,6 +310,7 @@ namespace BMA.EHR.Placement.Service.Controllers
data.positionId,
data.posMasterNo,
data.position,
data.PositionExecutive,
data.positionField,
data.posTypeId,
data.posTypeName,
@ -357,6 +358,7 @@ namespace BMA.EHR.Placement.Service.Controllers
data.AmountOld,
organizationOld = data.OrganizationOld == "/" || data.OrganizationOld == null ? null : data.OrganizationOld,
data.positionOld,
data.PositionExecutiveOld,
// Docs = placementAppointmentDocs,
data.typeCommand,
data.posmasterId,
@ -813,7 +815,7 @@ namespace BMA.EHR.Placement.Service.Controllers
No = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Education = p.EducationOld == null ? "-" : p.EducationOld,
OldOc = p.OrganizationPositionOld,
OldOc = p.OrganizationPositionOld == null ? "-" : p.OrganizationPositionOld,
OldPositionType = p.PositionTypeOld == null ? "-" : p.PositionTypeOld,
OldPositionLevel = p.PositionLevelOld == null ? "-" : p.PositionLevelOld,
OldPositionNumber = p.PositionNumberOld == null ? "-" : p.PositionNumberOld.ToThaiNumber(),
@ -904,7 +906,7 @@ namespace BMA.EHR.Placement.Service.Controllers
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
positionExecutive = "",
positionExecutive = p.PositionExecutive,
positionType = p.posTypeName,
positionLevel = p.posLevelName,
posmasterId = p.posmasterId,
@ -1023,7 +1025,7 @@ namespace BMA.EHR.Placement.Service.Controllers
No = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Education = p.EducationOld == null ? "-" : p.EducationOld,
OldOc = p.OrganizationPositionOld,
OldOc = p.OrganizationPositionOld == null ? "-" : p.OrganizationPositionOld,
OldPositionType = p.PositionTypeOld == null ? "-" : p.PositionTypeOld,
OldPositionLevel = p.PositionLevelOld == null ? "-" : p.PositionLevelOld,
OldPositionNumber = p.PositionNumberOld == null ? "-" : p.PositionNumberOld.ToThaiNumber(),
@ -1114,7 +1116,7 @@ namespace BMA.EHR.Placement.Service.Controllers
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
positionExecutive = "",
positionExecutive = p.PositionExecutive,
positionType = p.posTypeName,
positionLevel = p.posLevelName,
posmasterId = p.posmasterId,
@ -1235,7 +1237,7 @@ namespace BMA.EHR.Placement.Service.Controllers
{
No = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
OldOrganization = p.OrganizationPositionOld,
OldOrganization = p.OrganizationPositionOld == null ? "-" : p.OrganizationPositionOld,
OldPositionLevel = p.PositionLevelOld == null ? "-" : p.PositionLevelOld.ToThaiNumber(),
OldPositionNumber = p.PositionNumberOld == null ? "-" : p.PositionNumberOld.ToThaiNumber(),
OldSalary = p.AmountOld == null ? "-" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
@ -1435,7 +1437,7 @@ namespace BMA.EHR.Placement.Service.Controllers
{
No = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
OldOc = p.OrganizationPositionOld,
OldOc = p.OrganizationPositionOld == null ? "-" : p.OrganizationPositionOld,
OldPositionNumber = p.posMasterNoOld == null ? "-" :
p.child4Old != null ? $"{p.child4ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
p.child3Old != null ? $"{p.child3ShortNameOld}{p.posMasterNoOld}".ToThaiNumber() :
@ -1646,7 +1648,7 @@ namespace BMA.EHR.Placement.Service.Controllers
No = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Education = p.EducationOld == null ? "-" : p.EducationOld,
OldOc = p.OrganizationPositionOld,
OldOc = p.OrganizationPositionOld == null ? "-" : p.OrganizationPositionOld,
OldPositionType = p.posTypeNameOld == null ? "-" : p.posTypeNameOld,
OldPositionLevel = p.posLevelNameOld == null ? "-" : p.posLevelNameOld,
OldPositionNumber = p.posMasterNoOld == null ? "-" :
@ -1741,7 +1743,7 @@ namespace BMA.EHR.Placement.Service.Controllers
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
positionExecutive = "",
positionExecutive = p.PositionExecutive,
positionType = p.posTypeName,
positionLevel = p.posLevelName,
posmasterId = p.posmasterId,

View file

@ -614,8 +614,8 @@ namespace BMA.EHR.Placement.Service.Controllers
{
No = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
PositionName = p.OrganizationPositionOld,
Organization = p.Organization == null ? "" : p.Organization,
PositionName = p.OrganizationPositionOld == null ? "-" : p.OrganizationPositionOld,
Organization = p.Organization == null ? "-" : p.Organization,
StartDate = p.DateStart == null ? "" : p.DateStart.Value.ToThaiShortDate2().ToThaiNumber(),
EndDate = p.DateEnd == null ? "" : p.DateEnd.Value.ToThaiShortDate2().ToThaiNumber(),
Reason = p.Reason == null ? "" : p.Reason.ToThaiNumber(),
@ -672,6 +672,7 @@ namespace BMA.EHR.Placement.Service.Controllers
on p.Id.ToString() equals r.refId
select new
{
refId = p.Id,
profileId = p.profileId,
amount = r.amount,
amountSpecial = r.amountSpecial,

View file

@ -221,10 +221,18 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
{
var placementOfficer = await _context.PlacementOfficers
.Where(x => x.Id == (req.OfficerId ?? Guid.Parse("00000000-0000-0000-0000-000000000000")))
.FirstOrDefaultAsync();
if (placementOfficer == null)
return Error("ไม่พบรายการช่วยราชการ", 404);
var placementRepatriation = new PlacementRepatriation
{
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
Organization = placementOfficer.Organization,
// Reason = placementOfficer.Reason,
Date = placementOfficer.DateStart,
DateRepatriation = placementOfficer.DateEnd,
Status = "WAITTING",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
@ -507,6 +515,7 @@ namespace BMA.EHR.Placement.Service.Controllers
on p.Id.ToString() equals r.refId
select new
{
refId = p.Id,
profileId = p.profileId,
amount = r.amount,
amountSpecial = r.amountSpecial,

View file

@ -805,7 +805,7 @@ namespace BMA.EHR.Placement.Service.Controllers
{
No = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
OldOc = p.OrganizationPositionOld,
OldOc = p.OrganizationPositionOld == null ? "-" : p.OrganizationPositionOld,
PositionType = p.PositionTypeOld == null ? "-" : p.PositionTypeOld,
PositionLevel = p.PositionLevelOld == null ? "-" : p.PositionLevelOld,
PositionNumber = p.PositionNumberOld == null ? "-" : p.PositionNumberOld.ToThaiNumber(),

View file

@ -6,5 +6,6 @@ namespace BMA.EHR.Placement.Service.Requests
public class PlacementAddProfileRequest
{
public Guid Id { get; set; }
public Guid? OfficerId { get; set; }
}
}

View file

@ -69,7 +69,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
#endregion
#region " จัดลำดับเกษียณ "
private class ObjectOrderRetire
{
public int Order { get; set; }
@ -81,173 +80,66 @@ namespace BMA.EHR.Retirement.Service.Controllers
public DateTime? LastUpdatedAt { get; set; }
public Guid? Id { get; set; }
}
private async Task GenOrderByYear(Guid id)
{
var Org = await _context.Organizations.FirstOrDefaultAsync(x => x.OrganizationOrder == null);
var ocIdList = await _context.Organizations.Select(x => x.Id).ToListAsync();
if (Org != null)
ocIdList = _documentService.GetAllIdByRoot(Org.Id);
var retire = await _context.RetirementPeriods
.FirstOrDefaultAsync(x => x.Id == id);
if (retire == null)
return;
var _retireProfile = await _context.RetirementProfiles
.Where(x => x.RetirementPeriod == retire)
.ToListAsync();
var profiles = new List<ObjectOrderRetire>();
if (retire.Type.Trim().ToUpper().Contains("OFFICER"))
{
profiles = await (from x in _context.RetirementProfiles
where x.RetirementPeriod == retire
select new ObjectOrderRetire
{
Id = x.Id,
Order = x.Order,
Order1 = x.Order,
// Order1 = x.Order == null ? 999999999 : x.Order,
Order2 = x.posTypeRank,
Order3 = x.posLevelRank,
LastUpdateFullName = x.LastUpdateFullName,
LastUpdateUserId = x.LastUpdateUserId,
LastUpdatedAt = x.LastUpdatedAt,
}).ToListAsync();
}
if (retire.Type.Trim().ToUpper().Contains("EMPLOYEE"))
{
profiles = await (from x in _context.RetirementProfiles
where x.RetirementPeriod == retire
// x.Profile.PositionEmployeeLevelId == null ? null : x.Profile.PositionEmployeeLevelId.Order
select new ObjectOrderRetire
{
Id = x.Id,
Order = x.Order,
Order1 = x.Order,
// Order1 = x.Order == null ? 999999999 : x.Order,
LastUpdateFullName = x.LastUpdateFullName,
LastUpdateUserId = x.LastUpdateUserId,
LastUpdatedAt = x.LastUpdatedAt,
}).ToListAsync();
}
var _profiles = profiles.AsQueryable().OrderBy(x => x.Order1).ThenBy(x => x.Order2).ThenBy(x => x.Order3).ToList();
var order = 1;
foreach (var profile in _profiles)
{
var retireProfile = _retireProfile.Find(x => x.Id == profile.Id);
retireProfile.Order = order;
retireProfile.LastUpdateFullName = FullName ?? "System Administrator";
retireProfile.LastUpdateUserId = UserId ?? "";
retireProfile.LastUpdatedAt = DateTime.Now;
order++;
}
await _context.SaveChangesAsync();
}
private int SortOrg(Guid? ocId)
{
if (ocId == null)
return 999999999;
var Org = _context.Organizations.Include(x => x.OrganizationOrganization).FirstOrDefault(x => x.OrganizationOrder == null);
if (Org != null && Org.OrganizationOrganization != null && Org.OrganizationOrganization.Name.Contains("ปลัด"))
return -1;
var ocIdList = _context.Organizations.Select(x => x.Id).ToList();
if (Org != null)
ocIdList = _documentService.GetAllIdByRoot(Org.Id);
int index = ocIdList.IndexOf((Guid)ocId);
if (index == -1)
return 999999999;
return index;
}
private async Task<string> GetAgency(Guid profileId)
{
var organizationAgency = "-";
var _profile = await _context.Profiles
.Where(x => x.Id == profileId)
.FirstOrDefaultAsync();
if (_profile != null)
{
if (_profile.ProfileType == "officer")
{
var organization = await _context.Organizations
.Where(x => x.Id == _profile.OcId)
.FirstOrDefaultAsync();
if (organization != null)
{
var _organizationAgency = await _context.Organizations
.Include(x => x.OrganizationOrganization)
.Where(x => x.Id == organization.OrganizationAgencyId)
.FirstOrDefaultAsync();
if (_organizationAgency != null && _organizationAgency.OrganizationOrganization != null)
{
organizationAgency = _organizationAgency.OrganizationOrganization.Name;
}
}
}
else
{
var profilePosition = await _context.OrganizationEmployees
.Include(x => x.OrganizationAgency)
.ThenInclude(x => x.OrganizationOrganization)
.Where(x => x.Organization != null)
.Where(x => x.OrganizationAgency != null)
.Where(x => x.OrganizationAgency.OrganizationOrganization != null)
.Where(x => x.OrganizationAgency.OrganizationOrganization.Name != null)
.Where(x => x.Organization.Id == _profile.OcId)
.FirstOrDefaultAsync();
if (profilePosition != null)
{
organizationAgency = profilePosition.OrganizationAgency.OrganizationOrganization.Name;
}
}
}
return organizationAgency;
}
private async Task<string> GetGovermentAgency(Guid profileId)
{
var organizationGovernmentAgency = "-";
var _profile = await _context.Profiles
.Where(x => x.Id == profileId)
.FirstOrDefaultAsync();
if (_profile != null)
{
if (_profile.ProfileType == "officer")
{
var organization = await _context.Organizations
.Where(x => x.Id == _profile.OcId)
.FirstOrDefaultAsync();
if (organization != null)
{
var _organizationGovernmentAgency = await _context.Organizations
.Include(x => x.OrganizationOrganization)
.Where(x => x.Id == organization.OrganizationGovernmentAgencyId)
.FirstOrDefaultAsync();
if (_organizationGovernmentAgency != null && _organizationGovernmentAgency.OrganizationOrganization != null)
{
organizationGovernmentAgency = _organizationGovernmentAgency.OrganizationOrganization.Name;
}
}
}
else
{
var profilePosition = await _context.OrganizationEmployees
.Include(x => x.OrganizationGovernmentAgency)
.ThenInclude(x => x.OrganizationOrganization)
.Where(x => x.Organization != null)
.Where(x => x.OrganizationGovernmentAgency != null)
.Where(x => x.OrganizationGovernmentAgency.OrganizationOrganization != null)
.Where(x => x.OrganizationGovernmentAgency.OrganizationOrganization.Name != null)
.Where(x => x.Organization.Id == _profile.OcId)
.FirstOrDefaultAsync();
if (profilePosition != null)
{
organizationGovernmentAgency = profilePosition.OrganizationGovernmentAgency.OrganizationOrganization.Name;
}
}
}
return organizationGovernmentAgency;
}
#endregion
// private async Task GenOrderByYear(Guid id)
// {
// // var Org = await _context.Organizations.FirstOrDefaultAsync(x => x.OrganizationOrder == null);
// // var ocIdList = await _context.Organizations.Select(x => x.Id).ToListAsync();
// // if (Org != null)
// // ocIdList = _documentService.GetAllIdByRoot(Org.Id);
// // var retire = await _context.RetirementPeriods
// // .FirstOrDefaultAsync(x => x.Id == id);
// // if (retire == null)
// // return;
// // var _retireProfile = await _context.RetirementProfiles
// // .Where(x => x.RetirementPeriod == retire)
// // .ToListAsync();
// // var profiles = new List<ObjectOrderRetire>();
// // if (retire.Type.Trim().ToUpper().Contains("OFFICER"))
// // {
// // profiles = await (from x in _context.RetirementProfiles
// // where x.RetirementPeriod == retire
// // select new ObjectOrderRetire
// // {
// // Id = x.Id,
// // Order = x.Order,
// // Order1 = x.Order,
// // // Order1 = x.Order == null ? 999999999 : x.Order,
// // Order2 = x.posTypeRank,
// // Order3 = x.posLevelRank,
// // LastUpdateFullName = x.LastUpdateFullName,
// // LastUpdateUserId = x.LastUpdateUserId,
// // LastUpdatedAt = x.LastUpdatedAt,
// // }).ToListAsync();
// // }
// // if (retire.Type.Trim().ToUpper().Contains("EMPLOYEE"))
// // {
// // profiles = await (from x in _context.RetirementProfiles
// // where x.RetirementPeriod == retire
// // // x.Profile.PositionEmployeeLevelId == null ? null : x.Profile.PositionEmployeeLevelId.Order
// // select new ObjectOrderRetire
// // {
// // Id = x.Id,
// // Order = x.Order,
// // Order1 = x.Order,
// // // Order1 = x.Order == null ? 999999999 : x.Order,
// // LastUpdateFullName = x.LastUpdateFullName,
// // LastUpdateUserId = x.LastUpdateUserId,
// // LastUpdatedAt = x.LastUpdatedAt,
// // }).ToListAsync();
// // }
// // var _profiles = profiles.AsQueryable().OrderBy(x => x.Order1).ThenBy(x => x.Order2).ThenBy(x => x.Order3).ToList();
// // var order = 1;
// // foreach (var profile in _profiles)
// // {
// // var retireProfile = _retireProfile.Find(x => x.Id == profile.Id);
// // retireProfile.Order = order;
// // retireProfile.LastUpdateFullName = FullName ?? "System Administrator";
// // retireProfile.LastUpdateUserId = UserId ?? "";
// // retireProfile.LastUpdatedAt = DateTime.Now;
// // order++;
// // }
// // await _context.SaveChangesAsync();
// }
/// <summary>
/// list ประกาศเกษียณอายุราชการ
@ -411,6 +303,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
// var retires = new List<dynamic>();
var _apiUrl = $"{_configuration["API"]}/org/root/search/sort";
dynamic rootOrder = new List<string>();
dynamic child1Order = new List<string>();
dynamic child2Order = new List<string>();
dynamic child3Order = new List<string>();
dynamic child4Order = new List<string>();
dynamic posTypeNameOrder = new List<string>();
dynamic posLevelNameOrder = new List<string>();
using (var client = new HttpClient())
@ -426,12 +322,20 @@ namespace BMA.EHR.Retirement.Service.Controllers
if (org != null && org.result != null)
{
rootOrder = org.result.root;
child1Order = org.result.child1;
child2Order = org.result.child2;
child3Order = org.result.child3;
child4Order = org.result.child4;
posTypeNameOrder = org.result.posTypeNameOrder;
posLevelNameOrder = org.result.posLevelNameOrder;
}
}
var order = 1;
foreach (var profile in profiles.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
.ThenBy(x => child1Order.ToObject<List<string>>().IndexOf(x.child1 ?? ""))
.ThenBy(x => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
.ThenBy(x => child4Order.ToObject<List<string>>().IndexOf(x.child4 ?? ""))
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? "")))
{
@ -526,7 +430,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
order++;
}
await _context.SaveChangesAsync();
await GenOrderByYear(retire.Id);
// await GenOrderByYear(retire.Id);
}
else
{
@ -534,78 +438,50 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Error(GlobalMessages.RetirementNotCreated);
if (req.Option == null)
req.Option = "EDIT";
var apiUrl = $"{_configuration["API"]}/org/root/search/sort";
dynamic rootOrder = new List<string>();
dynamic posTypeNameOrder = new List<string>();
dynamic posLevelNameOrder = new List<string>();
if(retire.TypeReport == null)
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<dynamic>(_result);
if (org != null && org.result != null)
{
rootOrder = org.result.root;
posTypeNameOrder = org.result.posTypeNameOrder;
posLevelNameOrder = org.result.posLevelNameOrder;
}
}
}
var profile_old = await _context.RetirementProfiles
.Where(x => x.RetirementPeriod == retire)
.Select((x,index) => new
{
order = x.Order,
id = x.Id,
reason = x.Reason,
remove = x.Remove,
profileId = x.profileId,
prefix = x.prefix,
firstName = x.firstName,
lastName = x.lastName,
citizenId = x.citizenId,
root = x.root,
rootId = x.rootId,
rootShortName = x.rootShortName,
child1 = x.child1,
child1Id = x.child1Id,
child1ShortName = x.child1ShortName,
child2 = x.child2,
child2Id = x.child2Id,
child2ShortName = x.child2ShortName,
child3 = x.child3,
child3Id = x.child3Id,
child3ShortName = x.child3ShortName,
child4 = x.child4,
child4Id = x.child4Id,
child4ShortName = x.child4ShortName,
posMasterNo = x.posMasterNo,
position = x.position,
posTypeId = x.posTypeId,
posTypeName = x.posTypeName,
posTypeRank = x.posTypeRank,
posLevelId = x.posLevelId,
posLevelName = x.posLevelName,
posLevelRank = x.posLevelRank,
posExecutiveId = x.posExecutiveId,
posExecutiveName = x.posExecutiveName,
posNo = x.posNo,
})
.ToListAsync();
var _profile_old = profile_old
.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? ""))
.Select((x,index) => new
{
order = retire.TypeReport == null ? index + 1 : x.Order,
id = x.Id,
reason = x.Reason,
remove = x.Remove,
profileId = x.profileId,
prefix = x.prefix,
firstName = x.firstName,
lastName = x.lastName,
citizenId = x.citizenId,
root = x.root,
rootId = x.rootId,
rootShortName = x.rootShortName,
child1 = x.child1,
child1Id = x.child1Id,
child1ShortName = x.child1ShortName,
child2 = x.child2,
child2Id = x.child2Id,
child2ShortName = x.child2ShortName,
child3 = x.child3,
child3Id = x.child3Id,
child3ShortName = x.child3ShortName,
child4 = x.child4,
child4Id = x.child4Id,
child4ShortName = x.child4ShortName,
posMasterNo = x.posMasterNo,
position = x.position,
posTypeId = x.posTypeId,
posTypeName = x.posTypeName,
posTypeRank = x.posTypeRank,
posLevelId = x.posLevelId,
posLevelName = x.posLevelName,
posLevelRank = x.posLevelRank,
posExecutiveId = x.posExecutiveId,
posExecutiveName = x.posExecutiveName,
posNo = x.posNo,
});
var file_name = $"retire_tmp_{DateTime.Now.ToString("yyyyMMddTHHmmss")}";
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(_profile_old);
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(profile_old);
await _documentService.GenerateJsonFile(profile, "/retire", file_name);
var history = new RetirementPeriodHistory
{
@ -1020,7 +896,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
retire_profile.LastUpdateUserId = UserId ?? "";
retire_profile.LastUpdatedAt = DateTime.Now;
}
var num = 1;
var num = 0;
var profileRawCount = await _context.RetirementRawProfiles
.CountAsync(x => x.RetirementPeriod.Id == retireId);
@ -1135,10 +1011,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
_context.RetirementProfiles.Add(data);
_context.RetirementRawProfiles.Add(dataRaw);
await _context.SaveChangesAsync();
if (retire.RetirementPeriodHistorys.Count() == 0)
{
await GenOrderByYear(retire.Id);
}
// if (retire.RetirementPeriodHistorys.Count() == 0)
// {
// await GenOrderByYear(retire.Id);
// }
return Success();
}
}
@ -1246,10 +1122,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
_context.RetirementProfiles.Add(data);
_context.RetirementRawProfiles.Add(dataRaw);
await _context.SaveChangesAsync();
if (retire.RetirementPeriodHistorys.Count() == 0)
{
await GenOrderByYear(retire.Id);
}
// if (retire.RetirementPeriodHistorys.Count() == 0)
// {
// await GenOrderByYear(retire.Id);
// }
return Success();
}
}
@ -1329,7 +1205,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
_context.RetirementProfiles.Remove(profile);
_context.SaveChanges();
await GenOrderByYear(profile.RetirementPeriod.Id);
// await GenOrderByYear(profile.RetirementPeriod.Id);
}
else
{
@ -1391,7 +1267,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
if (retire == null)
return Error(GlobalMessages.RetirementNotFound, 404);
await GenOrderByYear(retire.Id);
// await GenOrderByYear(retire.Id);
return Success();
}
@ -1415,6 +1291,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
}
var retire = await _context.RetirementPeriods
.Include(x=>x.RetirementProfiles)
.Include(x=>x.RetirementRawProfiles)
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
return Error(GlobalMessages.RetirementNotFound, 404);
@ -1432,6 +1310,67 @@ namespace BMA.EHR.Retirement.Service.Controllers
retire.LastUpdateUserId = UserId ?? "";
retire.LastUpdatedAt = DateTime.Now;
}
if(retire.TypeReport == null)
{
var apiUrl = $"{_configuration["API"]}/org/root/search/sort";
dynamic rootOrder = new List<string>();
dynamic child1Order = new List<string>();
dynamic child2Order = new List<string>();
dynamic child3Order = new List<string>();
dynamic child4Order = new List<string>();
dynamic posTypeNameOrder = new List<string>();
dynamic posLevelNameOrder = new List<string>();
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<dynamic>(_result);
if (org != null && org.result != null)
{
rootOrder = org.result.root;
child1Order = org.result.child1;
child2Order = org.result.child2;
child3Order = org.result.child3;
child4Order = org.result.child4;
posTypeNameOrder = org.result.posTypeNameOrder;
posLevelNameOrder = org.result.posLevelNameOrder;
}
}
var order = 1;
foreach (var profile in retire.RetirementProfiles
.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
.ThenBy(x => child1Order.ToObject<List<string>>().IndexOf(x.child1 ?? ""))
.ThenBy(x => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
.ThenBy(x => child4Order.ToObject<List<string>>().IndexOf(x.child4 ?? ""))
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? "")))
{
profile.Order = order;
order++;
}
order = 1;
foreach (var profile in retire.RetirementRawProfiles
.OrderBy(x => rootOrder.ToObject<List<string>>().IndexOf(x.root))
.ThenBy(x => child1Order.ToObject<List<string>>().IndexOf(x.child1 ?? ""))
.ThenBy(x => child2Order.ToObject<List<string>>().IndexOf(x.child2 ?? ""))
.ThenBy(x => child3Order.ToObject<List<string>>().IndexOf(x.child3 ?? ""))
.ThenBy(x => child4Order.ToObject<List<string>>().IndexOf(x.child4 ?? ""))
.ThenBy(x => posTypeNameOrder.ToObject<List<string>>().IndexOf(x.posTypeName ?? ""))
.ThenBy(x => posLevelNameOrder.ToObject<List<string>>().IndexOf(x.posLevelName ?? "")))
{
profile.Order = order;
order++;
}
}
await _context.SaveChangesAsync();
return Success();

View file

@ -112,6 +112,36 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootId,
p.rootShortName,
p.child1,
p.child1Id,
p.child1ShortName,
p.child2,
p.child2Id,
p.child2ShortName,
p.child3,
p.child3Id,
p.child3ShortName,
p.child4,
p.child4Id,
p.child4ShortName,
p.orgRevisionId,
p.positionId,
p.posMasterNo,
p.position,
p.PositionExecutive,
p.positionField,
p.posTypeId,
p.posTypeName,
p.posLevelId,
p.posLevelName,
node = p.root == null ? (int?)null : (p.child1 == null ? 0 : (p.child2 == null ? 1 : (p.child3 == null ? 2 : (p.child4 == null ? 3 : 4)))),
nodeName = p.root == null ? null : (p.child1 == null ? p.root : (p.child2 == null ? p.child1 : (p.child3 == null ? p.child2 : (p.child4 == null ? p.child3 : p.child4)))),
nodeId = p.rootId == null ? null : (p.child1Id == null ? p.rootId : (p.child2Id == null ? p.child1Id : (p.child3Id == null ? p.child2Id : (p.child4Id == null ? p.child3Id : p.child4Id)))),
nodeShortName = p.rootShortName == null ? null : (p.child1ShortName == null ? p.rootShortName : (p.child2ShortName == null ? p.child1ShortName : (p.child3ShortName == null ? p.child2ShortName : (p.child4ShortName == null ? p.child3ShortName : p.child4ShortName)))),
p.rootOld,
p.rootOldId,
p.rootShortNameOld,
@ -134,7 +164,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.posTypeNameOld,
p.posLevelOldId,
p.posLevelNameOld,
p.Status,
p.Amount,
p.ReportingDate,
p.CreatedAt,
p.Reason,
p.MilitaryDate,
@ -144,6 +178,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.posmasterId,
p.PositionDate,
CommandType = p.CommandType == null ? null : p.CommandType.Name,
})
@ -204,6 +239,36 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootId,
p.rootShortName,
p.child1,
p.child1Id,
p.child1ShortName,
p.child2,
p.child2Id,
p.child2ShortName,
p.child3,
p.child3Id,
p.child3ShortName,
p.child4,
p.child4Id,
p.child4ShortName,
node = p.root == null ? (int?)null : (p.child1 == null ? 0 : (p.child2 == null ? 1 : (p.child3 == null ? 2 : (p.child4 == null ? 3 : 4)))),
nodeName = p.root == null ? null : (p.child1 == null ? p.root : (p.child2 == null ? p.child1 : (p.child3 == null ? p.child2 : (p.child4 == null ? p.child3 : p.child4)))),
nodeId = p.rootId == null ? null : (p.child1Id == null ? p.rootId : (p.child2Id == null ? p.child1Id : (p.child3Id == null ? p.child2Id : (p.child4Id == null ? p.child3Id : p.child4Id)))),
nodeShortName = p.rootShortName == null ? null : (p.child1ShortName == null ? p.rootShortName : (p.child2ShortName == null ? p.child1ShortName : (p.child3ShortName == null ? p.child2ShortName : (p.child4ShortName == null ? p.child3ShortName : p.child4ShortName)))),
p.orgRevisionId,
p.positionId,
p.posMasterNo,
p.position,
p.PositionExecutive,
p.positionField,
p.posTypeId,
p.posTypeName,
p.posLevelId,
p.posLevelName,
p.rootOld,
p.rootOldId,
p.rootShortNameOld,
@ -219,12 +284,20 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.child4Old,
p.child4OldId,
p.child4ShortNameOld,
nodeOld = p.rootOld == null ? (int?)null : (p.child1Old == null ? 0 : (p.child2Old == null ? 1 : (p.child3Old == null ? 2 : (p.child4Old == null ? 3 : 4)))),
nodeNameOld = p.rootOld == null ? null : (p.child1Old == null ? p.root : (p.child2Old == null ? p.child1Old : (p.child3Old == null ? p.child2Old : (p.child4Old == null ? p.child3Old : p.child4Old)))),
nodeOldId = p.rootOldId == null ? null : (p.child1OldId == null ? p.rootOldId : (p.child2OldId == null ? p.child1OldId : (p.child3OldId == null ? p.child2OldId : (p.child4OldId == null ? p.child3OldId : p.child4OldId)))),
nodeShortNameOld = p.rootShortNameOld == null ? null : (p.child1ShortNameOld == null ? p.rootShortNameOld : (p.child2ShortNameOld == null ? p.child1ShortNameOld : (p.child3ShortNameOld == null ? p.child2ShortNameOld : (p.child4ShortNameOld == null ? p.child3ShortNameOld : p.child4ShortNameOld)))),
p.posMasterNoOld,
p.posTypeOldId,
p.posTypeNameOld,
p.posLevelOldId,
p.posLevelNameOld,
p.Status,
p.Amount,
p.ReportingDate,
p.CreatedAt,
p.Reason,
p.MilitaryDate,
@ -238,6 +311,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.PositionExecutiveOld,
p.OrganizationOld,
p.PositionDate,
p.posmasterId,
CommandType = p.CommandType == null ? null : p.CommandType.Name,
})
.FirstOrDefaultAsync();
@ -368,84 +442,97 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Success();
}
// /// <summary>
// /// เลือกหน่วยงาน
// /// </summary>
// /// <param name="id">Id อื่นๆ</param>
// /// <returns></returns>
// /// <response code="200"></response>
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
// [HttpPut("position/{id:length(36)}")]
// public async Task<ActionResult<ResponseObject>> UpdatePositionRetirementOther([FromBody] PersonSelectPositionOtherRequest req, Guid id)
// {
// var uppdated = await _context.RetirementOthers
// .FirstOrDefaultAsync(x => x.Id == id);
// if (uppdated == null)
// return Error(GlobalMessages.RetirementOtherNotFound, 404);
// if (req.PosNoId != null)
// {
// var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoId);
// if (save_posNo == null)
// return Error(GlobalMessages.PositionPosNoNotFound, 404);
// uppdated.PositionNumber = save_posNo;
/// <summary>
/// เลือกหน่วยงาน
/// </summary>
/// <param name="id">Id อื่นๆ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("position/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdatePositionRetirementOther([FromBody] PersonSelectPositionOtherRequest req, Guid id)
{
var uppdated = await _context.RetirementOthers
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.RetirementOtherNotFound, 404);
var apiUrl = $"{_configuration["API"]}/org/find/all";
// var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
// if (save_orgPosition == null)
// return Error(GlobalMessages.PositionPosNoNotFound, 404);
// uppdated.OrganizationPosition = save_orgPosition;
// }
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
node = req.node,
nodeId = req.nodeId,
});
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
// if (req.PositionId != null)
// {
// var save = await _context.PositionPaths.FindAsync(req.PositionId);
// if (save == null)
// return Error(GlobalMessages.PositionPathNotFound, 404);
// uppdated.PositionPath = save;
// }
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานนี้ในระบบ", 404);
uppdated.root = org.result.root;
uppdated.rootId = org.result.rootId;
uppdated.rootDnaId = org.result.rootDnaId;
uppdated.rootShortName = org.result.rootShortName;
uppdated.child1 = req.node <= 0 ? null : org.result.child1;
uppdated.child1Id = req.node <= 0 ? null : org.result.child1Id;
uppdated.child1DnaId = req.node <= 0 ? null : org.result.child1DnaId;
uppdated.child1ShortName = req.node <= 0 ? null : org.result.child1ShortName;
uppdated.child2 = req.node <= 1 ? null : org.result.child2;
uppdated.child2Id = req.node <= 1 ? null : org.result.child2Id;
uppdated.child2DnaId = req.node <= 1 ? null : org.result.child2DnaId;
uppdated.child2ShortName = req.node <= 1 ? null : org.result.child2ShortName;
uppdated.child3 = req.node <= 2 ? null : org.result.child3;
uppdated.child3Id = req.node <= 2 ? null : org.result.child3Id;
uppdated.child3DnaId = req.node <= 2 ? null : org.result.child3DnaId;
uppdated.child3ShortName = req.node <= 2 ? null : org.result.child3ShortName;
uppdated.child4 = req.node <= 3 ? null : org.result.child4;
uppdated.child4Id = req.node <= 3 ? null : org.result.child4Id;
uppdated.child4DnaId = req.node <= 3 ? null : org.result.child4DnaId;
uppdated.child4ShortName = req.node <= 3 ? null : org.result.child4ShortName;
}
// if (req.PositionLevelId != null)
// {
// var save = await _context.PositionLevels.FindAsync(req.PositionLevelId);
// if (save == null)
// return Error(GlobalMessages.PositionLevelNotFound, 404);
// uppdated.PositionLevel = save;
// }
var apiUrlUpdate = $"{_configuration["API"]}/org/pos/officer/master-old/book";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _resUpdate = await client.PostAsJsonAsync(apiUrlUpdate, new
{
posMasterOldId = uppdated.posmasterId,
posMasterId = req.posmasterId,
profileId = uppdated.profileId,
});
}
uppdated.posmasterId = req.posmasterId;
uppdated.node = req.node;
uppdated.nodeId = req.nodeId;
uppdated.orgRevisionId = req.orgRevisionId;
uppdated.positionId = req.positionId;
uppdated.posMasterNo = req.posMasterNo;
uppdated.position = req.positionName;
uppdated.PositionExecutive = req.posExecutiveName;
uppdated.positionField = req.positionField;
uppdated.posTypeId = req.posTypeId;
uppdated.posTypeName = req.posTypeName;
uppdated.posLevelId = req.posLevelId;
uppdated.posLevelName = req.posLevelName;
uppdated.Amount = req.Amount;
uppdated.ReportingDate = req.reportingDate;
uppdated.Status = "PENDING";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
// if (req.PositionLineId != null)
// {
// var save = await _context.PositionLines.FindAsync(req.PositionLineId);
// if (save == null)
// return Error(GlobalMessages.PositionLineNotFound, 404);
// uppdated.PositionLine = save;
// }
// if (req.PositionPathSideId != null)
// {
// var save = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
// if (save == null)
// return Error(GlobalMessages.PositionPathSideNotFound, 404);
// uppdated.PositionPathSide = save;
// }
// if (req.PositionTypeId != null)
// {
// var save = await _context.PositionTypes.FindAsync(req.PositionTypeId);
// if (save == null)
// return Error(GlobalMessages.PositionTypeNotFound, 404);
// uppdated.PositionType = save;
// }
// uppdated.RecruitDate = req.RecruitDate;
// uppdated.Status = "PENDING";
// uppdated.LastUpdateFullName = FullName ?? "System Administrator";
// uppdated.LastUpdateUserId = UserId ?? "";
// uppdated.LastUpdatedAt = DateTime.Now;
// await _context.SaveChangesAsync();
// return Success();
// }
return Success();
}
/// <summary>
/// แก้ไขอื่นๆ
@ -757,6 +844,25 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Success();
}
/// <summary>
/// หน่วยงานที่ถูกเลือกไปแล้ว
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("use")]
public async Task<ActionResult<ResponseObject>> GetPositionUse()
{
var position = await _context.RetirementOthers
.Where(x => x.posmasterId != null)
.Where(x => x.Status != "DONE")
.Select(x => x.posmasterId)
.ToListAsync();
return Success(position);
}
/// <summary>
/// ส่งรายชื่อออกคำสั่ง C-PM-09
/// </summary>
@ -825,7 +931,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
No = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Education = p.EducationOld == null ? "-" : p.EducationOld,
OldOc = p.OrganizationPositionOld,
OldOc = p.OrganizationPositionOld == null ? "-" : p.OrganizationPositionOld,
OldPositionType = p.PositionTypeOld == null ? "-" : p.PositionTypeOld,
OldPositionLevel = p.PositionLevelOld == null ? "-" : p.PositionLevelOld,
OldPositionNumber = p.PositionNumberOld == null ? "-" : p.PositionNumberOld.ToThaiNumber(),

View file

@ -1610,11 +1610,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
No = r.Sequence.ToString().ToThaiNumber(),
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
PositionName = p.PositionOld ?? "",
Organization = p.OrganizationPositionOld ?? "",
PositionName = p.PositionOld ?? "-",
Organization = p.OrganizationPositionOld ?? "-",
PositionLevel = p.PositionLevelOld == null ? "-" : p.PositionLevelOld.ToThaiNumber(),
PositionType = p.PositionTypeOld ?? "",
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
PositionType = p.PositionTypeOld ?? "-",
PositionNumber = p.PositionNumberOld == null ? "-" : p.PositionNumberOld.ToThaiNumber(),
ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(),
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
Remark = p.Reason ?? "",

View file

@ -6,11 +6,29 @@ namespace BMA.EHR.Retirement.Service.Requests
public class PersonSelectPositionOtherRequest
{
public DateTime? RecruitDate { get; set; }
public Guid? PosNoId { get; set; }
public Guid? PositionId { get; set; }
public Guid? PositionLevelId { get; set; }
public Guid? PositionLineId { get; set; }
public Guid? PositionPathSideId { get; set; }
public Guid? PositionTypeId { get; set; }
// public Guid? PosNoId { get; set; }
// public Guid? PositionId { get; set; }
// public Guid? PositionLevelId { get; set; }
// public Guid? PositionLineId { get; set; }
// public Guid? PositionPathSideId { get; set; }
// public Guid? PositionTypeId { get; set; }
public double? Amount { get; set; }
public string? posmasterId { get; set; }
public Guid? personalId { get; set; }
public DateTime? reportingDate { get; set; }
public int? node { get; set; }
public Guid? nodeId { get; set; }
public string? orgRevisionId { get; set; }
public int? posMasterNo { get; set; }
public string? positionId { get; set; }
public string? positionName { get; set; }
public string? positionField { get; set; }
public string? posTypeId { get; set; }
public string? posTypeName { get; set; }
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
public string? typeCommand { get; set; }
public string? posExecutiveName { get; set; }
}
}